test/fixtures: Migrate the packages fixture to TypeScript
This migrates the `packages` fixture to TypeScript and adds needed types to `index.ts`
This commit is contained in:
parent
9cef49097f
commit
e2ffc1705c
7 changed files with 108 additions and 20 deletions
|
|
@ -7,7 +7,7 @@ const config: ConfigFile = {
|
|||
outputFile: '../../src/store/contentSourcesApi.ts',
|
||||
exportName: 'contentSourcesApi',
|
||||
hooks: true,
|
||||
filterEndpoints: ['listRepositories'],
|
||||
filterEndpoints: ['listRepositories', 'listRepositoriesRpms'],
|
||||
}
|
||||
|
||||
export default config
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ const config: ConfigFile = {
|
|||
outputFile: '../../src/store/imageBuilderApi.ts',
|
||||
exportName: 'imageBuilderApi',
|
||||
hooks: true,
|
||||
filterEndpoints: ['getComposes', 'getComposeStatus', 'getComposeClones', 'getCloneStatus', 'getArchitectures'],
|
||||
filterEndpoints: ['getComposes', 'getComposeStatus', 'getComposeClones', 'getCloneStatus', 'getArchitectures', 'getPackages'],
|
||||
}
|
||||
|
||||
export default config
|
||||
|
|
|
|||
|
|
@ -22,6 +22,20 @@ const injectedRtkApi = api.injectEndpoints({
|
|||
},
|
||||
}),
|
||||
}),
|
||||
listRepositoriesRpms: build.query<
|
||||
ListRepositoriesRpmsApiResponse,
|
||||
ListRepositoriesRpmsApiArg
|
||||
>({
|
||||
query: (queryArg) => ({
|
||||
url: `/repositories/${queryArg.uuid}/rpms`,
|
||||
params: {
|
||||
limit: queryArg.limit,
|
||||
offset: queryArg.offset,
|
||||
search: queryArg.search,
|
||||
sort_by: queryArg.sortBy,
|
||||
},
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
overrideExisting: false,
|
||||
});
|
||||
|
|
@ -52,6 +66,20 @@ export type ListRepositoriesApiArg = {
|
|||
/** Comma separated list of statuses to optionally filter on */
|
||||
status?: string;
|
||||
};
|
||||
export type ListRepositoriesRpmsApiResponse =
|
||||
/** status 200 OK */ ApiRepositoryRpmCollectionResponse;
|
||||
export type ListRepositoriesRpmsApiArg = {
|
||||
/** Identifier of the Repository */
|
||||
uuid: string;
|
||||
/** Limit the number of items returned */
|
||||
limit?: number;
|
||||
/** Offset into the list of results to return in the response */
|
||||
offset?: number;
|
||||
/** Search term for name. */
|
||||
search?: string;
|
||||
/** Sets the sort order of the results. */
|
||||
sortBy?: string;
|
||||
};
|
||||
export type ApiRepositoryResponse = {
|
||||
account_id?: string;
|
||||
distribution_arch?: string;
|
||||
|
|
@ -95,4 +123,20 @@ export type ErrorsHandlerError = {
|
|||
export type ErrorsErrorResponse = {
|
||||
errors?: ErrorsHandlerError[];
|
||||
};
|
||||
export const { useListRepositoriesQuery } = injectedRtkApi;
|
||||
export type ApiRepositoryRpm = {
|
||||
arch?: string;
|
||||
checksum?: string;
|
||||
epoch?: number;
|
||||
name?: string;
|
||||
release?: string;
|
||||
summary?: string;
|
||||
uuid?: string;
|
||||
version?: string;
|
||||
};
|
||||
export type ApiRepositoryRpmCollectionResponse = {
|
||||
data?: ApiRepositoryRpm[];
|
||||
links?: ApiLinks;
|
||||
meta?: ApiResponseMetadata;
|
||||
};
|
||||
export const { useListRepositoriesQuery, useListRepositoriesRpmsQuery } =
|
||||
injectedRtkApi;
|
||||
|
|
|
|||
|
|
@ -34,6 +34,18 @@ const injectedRtkApi = api.injectEndpoints({
|
|||
params: { limit: queryArg.limit, offset: queryArg.offset },
|
||||
}),
|
||||
}),
|
||||
getPackages: build.query<GetPackagesApiResponse, GetPackagesApiArg>({
|
||||
query: (queryArg) => ({
|
||||
url: `/packages`,
|
||||
params: {
|
||||
distribution: queryArg.distribution,
|
||||
architecture: queryArg.architecture,
|
||||
search: queryArg.search,
|
||||
limit: queryArg.limit,
|
||||
offset: queryArg.offset,
|
||||
},
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
overrideExisting: false,
|
||||
});
|
||||
|
|
@ -74,6 +86,20 @@ export type GetComposeClonesApiArg = {
|
|||
/** clones page offset, default 0 */
|
||||
offset?: number;
|
||||
};
|
||||
export type GetPackagesApiResponse =
|
||||
/** status 200 a list of packages */ PackagesResponse;
|
||||
export type GetPackagesApiArg = {
|
||||
/** distribution to look up packages for */
|
||||
distribution: Distributions;
|
||||
/** architecture to look up packages for */
|
||||
architecture: "x86_64" | "aarch64";
|
||||
/** packages to look for */
|
||||
search: string;
|
||||
/** max amount of packages, default 100 */
|
||||
limit?: number;
|
||||
/** packages page offset, default 0 */
|
||||
offset?: number;
|
||||
};
|
||||
export type Repository = {
|
||||
baseurl?: string;
|
||||
check_gpg?: boolean;
|
||||
|
|
@ -281,10 +307,25 @@ export type ClonesResponse = {
|
|||
count: number;
|
||||
};
|
||||
};
|
||||
export type Package = {
|
||||
name: string;
|
||||
summary: string;
|
||||
};
|
||||
export type PackagesResponse = {
|
||||
data: Package[];
|
||||
links: {
|
||||
first: string;
|
||||
last: string;
|
||||
};
|
||||
meta: {
|
||||
count: number;
|
||||
};
|
||||
};
|
||||
export const {
|
||||
useGetArchitecturesQuery,
|
||||
useGetCloneStatusQuery,
|
||||
useGetComposesQuery,
|
||||
useGetComposeStatusQuery,
|
||||
useGetComposeClonesQuery,
|
||||
useGetPackagesQuery,
|
||||
} = injectedRtkApi;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import api from '../../../api.js';
|
|||
import { RHEL_8, RHEL_9, PROVISIONING_API } from '../../../constants.js';
|
||||
import { mockComposesEmpty } from '../../fixtures/composes.js';
|
||||
import { customizations, ids } from '../../fixtures/customizations.js';
|
||||
import { mockPkgResultAlphaContentSources } from '../../fixtures/packages.js';
|
||||
import { mockPkgResultAlphaContentSources } from '../../fixtures/packages';
|
||||
import { server } from '../../mocks/server.js';
|
||||
import {
|
||||
clickBack,
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import {
|
|||
mockPkgResultAlpha,
|
||||
mockPkgResultAll,
|
||||
mockPkgResultPartial,
|
||||
} from '../../fixtures/packages.js';
|
||||
} from '../../fixtures/packages';
|
||||
import {
|
||||
clickBack,
|
||||
clickNext,
|
||||
|
|
|
|||
|
|
@ -1,33 +1,39 @@
|
|||
export const mockPackagesResults = (search) => {
|
||||
import {
|
||||
ApiRepositoryRpm,
|
||||
ApiRepositoryRpmCollectionResponse,
|
||||
} from '../../store/contentSourcesApi';
|
||||
import { PackagesResponse } from '../../store/imageBuilderApi';
|
||||
|
||||
export const mockPackagesResults = (search: string): PackagesResponse => {
|
||||
if (search === 'test') {
|
||||
return {
|
||||
data: [
|
||||
{
|
||||
name: 'testPkg',
|
||||
summary: 'test package summary',
|
||||
version: '1.0',
|
||||
},
|
||||
{
|
||||
name: 'lib-test',
|
||||
summary: 'lib-test package summary',
|
||||
version: '1.0',
|
||||
},
|
||||
{
|
||||
name: 'test',
|
||||
summary: 'summary for test package',
|
||||
version: '1.0',
|
||||
},
|
||||
],
|
||||
links: { first: '', last: '' },
|
||||
meta: {
|
||||
count: 3,
|
||||
},
|
||||
};
|
||||
} else {
|
||||
return { data: [], meta: 0 };
|
||||
return { data: [], links: { first: '', last: '' }, meta: { count: 0 } };
|
||||
}
|
||||
};
|
||||
|
||||
export const mockSourcesPackagesResults = (search) => {
|
||||
export const mockSourcesPackagesResults = (
|
||||
search: string
|
||||
): ApiRepositoryRpm[] => {
|
||||
if (search === 'test') {
|
||||
return [
|
||||
{
|
||||
|
|
@ -51,29 +57,26 @@ export const mockSourcesPackagesResults = (search) => {
|
|||
}
|
||||
};
|
||||
|
||||
export const mockPkgResultAlpha = {
|
||||
export const mockPkgResultAlpha: PackagesResponse = {
|
||||
meta: { count: 3 },
|
||||
links: { first: '', last: '' },
|
||||
data: [
|
||||
{
|
||||
name: 'lib-test',
|
||||
summary: 'lib-test package summary',
|
||||
version: '1.0',
|
||||
},
|
||||
{
|
||||
name: 'Z-test',
|
||||
summary: 'Z-test package summary',
|
||||
version: '1.0',
|
||||
},
|
||||
{
|
||||
name: 'test',
|
||||
summary: 'summary for test package',
|
||||
version: '1.0',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const mockPkgResultAlphaContentSources = [
|
||||
export const mockPkgResultAlphaContentSources: ApiRepositoryRpm[] = [
|
||||
{
|
||||
name: 'lib-test',
|
||||
summary: 'lib-test package summary',
|
||||
|
|
@ -91,10 +94,10 @@ export const mockPkgResultAlphaContentSources = [
|
|||
},
|
||||
];
|
||||
|
||||
export const mockPkgResultPartial = {
|
||||
export const mockPkgResultPartial: PackagesResponse = {
|
||||
meta: { count: 132 },
|
||||
links: { first: '', last: '' },
|
||||
data: new Array(100).fill().map((_, i) => {
|
||||
data: new Array(100).fill(undefined).map((_, i) => {
|
||||
return {
|
||||
name: 'testPkg-' + i,
|
||||
summary: 'test package summary',
|
||||
|
|
@ -103,10 +106,10 @@ export const mockPkgResultPartial = {
|
|||
}),
|
||||
};
|
||||
|
||||
export const mockPkgResultAll = {
|
||||
export const mockPkgResultAll: ApiRepositoryRpmCollectionResponse = {
|
||||
meta: { count: 132 },
|
||||
links: { first: '', last: '' },
|
||||
data: new Array(132).fill().map((_, i) => {
|
||||
data: new Array(132).fill(undefined).map((_, i) => {
|
||||
return {
|
||||
name: 'testPkg-' + i,
|
||||
summary: 'test package summary',
|
||||
Loading…
Add table
Add a link
Reference in a new issue