Wizard: Add filtering to repositories

This commit adds filtering based on architecture and version to the
repositories table in the wizard.

Apart from filtering, this commit now shows *all* repositories,
regardless of their status. Previously, invalid repositories were not
displayed. A future PR will add a status column and edge case handling
(how to handle an invalid repo, etc...). For now, invalid repos are
displayed and can be selected.

RTK Query is now used to manage the state of the repositories.
Previously, the repositories were fetched in a useEffect hook upon
opening the wizard.

MSW is now used instead of jest mocking for the tests involving
repositories. The repositories test fixture now contains a function that
mimics the content sources API.
This commit is contained in:
lucasgarfield 2023-05-02 18:27:50 +02:00 committed by Lucas Garfield
parent ff8c275013
commit 383f2a6855
11 changed files with 682 additions and 715 deletions

View file

@ -1,4 +1,4 @@
import React, { useEffect, useMemo } from 'react';
import React, { useMemo } from 'react';
import componentTypes from '@data-driven-forms/react-form-renderer/component-types';
import { addNotification } from '@redhat-cloud-services/frontend-components-notifications/redux';
@ -31,7 +31,6 @@ import api from '../../api';
import { UNIT_GIB, UNIT_KIB, UNIT_MIB, MODAL_ANCHOR } from '../../constants';
import { useGetArchitecturesByDistributionQuery } from '../../store/apiSlice';
import { composeAdded } from '../../store/composesSlice';
import { fetchRepositories } from '../../store/repositoriesSlice';
import isRhel from '../../Utilities/isRhel';
import { resolveRelPath } from '../../Utilities/path';
import { useGetEnvironment } from '../../Utilities/useGetEnvironment';
@ -574,12 +573,6 @@ const CreateImageWizard = () => {
const appendTo = useMemo(() => document.querySelector(MODAL_ANCHOR), []);
useEffect(() => {
if (isBeta()) {
dispatch(fetchRepositories());
}
}, []);
return (
<ImageCreator
onClose={handleClose}

View file

@ -5,6 +5,7 @@ import {
useFormApi,
} from '@data-driven-forms/react-form-renderer';
import {
Alert,
Button,
Dropdown,
DropdownItem,
@ -16,6 +17,7 @@ import {
EmptyStateVariant,
Pagination,
SearchInput,
Spinner,
Title,
Toolbar,
ToolbarContent,
@ -32,9 +34,10 @@ import {
Tr,
} from '@patternfly/react-table';
import PropTypes from 'prop-types';
import { useSelector } from 'react-redux';
import { selectValidRepositories } from '../../../store/repositoriesSlice';
import { CENTOS_8, CENTOS_9, RHEL_8, RHEL_9 } from '../../../constants';
import { useGetRepositoriesQuery } from '../../../store/apiSlice';
import { useGetEnvironment } from '../../../Utilities/useGetEnvironment';
const BulkSelect = ({
selected,
@ -144,11 +147,30 @@ const convertSchemaToContentSources = (repo) => {
return contentSourcesRepo;
};
const releaseToVersion = (release) => {
switch (release) {
case RHEL_9:
return '9';
case RHEL_8:
return '8';
case CENTOS_9:
return '9';
case CENTOS_8:
return '8';
default:
return '';
}
};
const Repositories = (props) => {
const initializeRepositories = () => {
// Repositories obtained from Content Sources API are in Redux store
const contentSourcesRepos = useSelector((state) =>
selectValidRepositories(state)
const initializeRepositories = (contentSourcesReposList) => {
// Convert list of repositories into an object where key is repo URL
const contentSourcesRepos = contentSourcesReposList.reduce(
(accumulator, currentValue) => {
accumulator[currentValue.url] = currentValue;
return accumulator;
},
{}
);
// Repositories in the form state can be present when 'Recreate image' is used
@ -180,7 +202,6 @@ const Repositories = (props) => {
const { getState, change } = useFormApi();
const { input } = useFieldApi(props);
const [repositories] = useState(initializeRepositories());
const [filterValue, setFilterValue] = useState('');
const [perPage, setPerPage] = useState(10);
const [page, setPage] = useState(1);
@ -190,6 +211,18 @@ const Repositories = (props) => {
: []
);
const release = getState().values?.release;
const version = releaseToVersion(release);
const { data, isError, isLoading, isSuccess } = useGetRepositoriesQuery({
available_for_arch: 'x86_64',
available_for_version: version,
});
const repositories = useMemo(() => {
return data ? initializeRepositories(data.data) : {};
}, [data]);
const isRepoSelected = (repoURL) => selected.includes(repoURL);
const handlePerPageSelect = (event, newPerPage, newPage) => {
@ -215,7 +248,7 @@ const Repositories = (props) => {
.map((repo) => repo.url);
return filteredRepoURLs;
}, [filterValue]);
}, [filterValue, repositories]);
const handleClearFilter = () => {
setFilterValue('');
@ -281,131 +314,158 @@ const Repositories = (props) => {
};
return (
<>
{Object.values(repositories).length === 0 ? (
<EmptyState variant={EmptyStateVariant.large} data-testid="empty-state">
<EmptyStateIcon icon={RepositoryIcon} />
<Title headingLevel="h4" size="lg">
No Custom Repositories
</Title>
<EmptyStateBody>
Custom repositories managed via the Red Hat Insights Repositories
app will be available here to select and use to search for
additional packages.
</EmptyStateBody>
<Button
variant="primary"
component="a"
href={
getState()?.values?.isBeta
? '/beta/settings/content'
: '/settings/content'
}
>
Repositories
</Button>
</EmptyState>
) : (
<>
<Toolbar>
<ToolbarContent>
<ToolbarItem variant="bulk-select">
<BulkSelect
selected={selected}
count={Object.values(repositories).length}
filteredCount={filteredRepositoryURLs.length}
perPage={perPage}
handleSelectAll={handleSelectAll}
handleSelectPage={handleSelectPage}
handleDeselectAll={handleDeselectAll}
/>
</ToolbarItem>
<ToolbarItem variant="search-filter">
<SearchInput
aria-label="Search repositories"
onChange={handleFilterRepositories}
value={filterValue}
onClear={handleClearFilter}
/>
</ToolbarItem>
<ToolbarItem variant="pagination">
<Pagination
itemCount={filteredRepositoryURLs.length}
perPage={perPage}
page={page}
onSetPage={handleSetPage}
widgetId="compact-example"
onPerPageSelect={handlePerPageSelect}
isCompact
/>
</ToolbarItem>
</ToolbarContent>
</Toolbar>
<TableComposable variant="compact" data-testid="repositories-table">
<Thead>
<Tr>
<Th />
<Th width={50}>Name</Th>
<Th>Architecture</Th>
<Th>Versions</Th>
<Th>Packages</Th>
</Tr>
</Thead>
<Tbody>
{filteredRepositoryURLs
.slice()
.sort((a, b) => {
if (repositories[a].name < repositories[b].name) {
return -1;
} else if (repositories[b].name < repositories[a].name) {
return 1;
} else {
return 0;
}
})
.slice(computeStart(), computeEnd())
.map((repoURL, rowIndex) => {
const repo = repositories[repoURL];
return (
<Tr key={repo.url}>
<Td
select={{
isSelected: isRepoSelected(repo.url),
rowIndex: rowIndex,
onSelect: (event, isSelecting) =>
handleSelect(repo.url, rowIndex, isSelecting),
}}
/>
<Td dataLabel={'Name'}>
{repo.name}
<br />
<Button
component="a"
target="_blank"
variant="link"
icon={<ExternalLinkAltIcon />}
iconPosition="right"
isInline
href={repo.url}
>
{repo.url}
</Button>
</Td>
<Td dataLabel={'Architecture'}>
{repo.distribution_arch}
</Td>
<Td dataLabel={'Version'}>
{repo.distribution_versions}
</Td>
<Td dataLabel={'Packages'}>{repo.package_count}</Td>
</Tr>
);
})}
</Tbody>
</TableComposable>
</>
)}
</>
(isError && <Error />) ||
(isLoading && <Loading />) ||
(isSuccess && (
<>
{Object.values(repositories).length === 0 ? (
<Empty />
) : (
<>
<Toolbar>
<ToolbarContent>
<ToolbarItem variant="bulk-select">
<BulkSelect
selected={selected}
count={Object.values(repositories).length}
filteredCount={filteredRepositoryURLs.length}
perPage={perPage}
handleSelectAll={handleSelectAll}
handleSelectPage={handleSelectPage}
handleDeselectAll={handleDeselectAll}
/>
</ToolbarItem>
<ToolbarItem variant="search-filter">
<SearchInput
aria-label="Search repositories"
onChange={handleFilterRepositories}
value={filterValue}
onClear={handleClearFilter}
/>
</ToolbarItem>
<ToolbarItem variant="pagination">
<Pagination
itemCount={filteredRepositoryURLs.length}
perPage={perPage}
page={page}
onSetPage={handleSetPage}
widgetId="compact-example"
onPerPageSelect={handlePerPageSelect}
isCompact
/>
</ToolbarItem>
</ToolbarContent>
</Toolbar>
<TableComposable variant="compact" data-testid="repositories-table">
<Thead>
<Tr>
<Th />
<Th width={50}>Name</Th>
<Th>Architecture</Th>
<Th>Versions</Th>
<Th>Packages</Th>
</Tr>
</Thead>
<Tbody>
{filteredRepositoryURLs
.slice()
.sort((a, b) => {
if (repositories[a].name < repositories[b].name) {
return -1;
} else if (repositories[b].name < repositories[a].name) {
return 1;
} else {
return 0;
}
})
.slice(computeStart(), computeEnd())
.map((repoURL, rowIndex) => {
const repo = repositories[repoURL];
return (
<Tr key={repo.url}>
<Td
select={{
isSelected: isRepoSelected(repo.url),
rowIndex: rowIndex,
onSelect: (event, isSelecting) =>
handleSelect(repo.url, rowIndex, isSelecting),
}}
/>
<Td dataLabel={'Name'}>
{repo.name}
<br />
<Button
component="a"
target="_blank"
variant="link"
icon={<ExternalLinkAltIcon />}
iconPosition="right"
isInline
href={repo.url}
>
{repo.url}
</Button>
</Td>
<Td dataLabel={'Architecture'}>
{repo.distribution_arch}
</Td>
<Td dataLabel={'Version'}>
{repo.distribution_versions}
</Td>
<Td dataLabel={'Packages'}>{repo.package_count}</Td>
</Tr>
);
})}
</Tbody>
</TableComposable>
</>
)}
</>
))
);
};
const Error = () => {
return (
<Alert title="Repositories unavailable" variant="danger" isPlain isInline>
Repositories cannot be reached, try again later.
</Alert>
);
};
const Loading = () => {
return (
<EmptyState>
<EmptyStateIcon variant="container" component={Spinner} />
<Title size="lg" headingLevel="h4">
Loading
</Title>
</EmptyState>
);
};
const Empty = () => {
const { isBeta } = useGetEnvironment();
return (
<EmptyState variant={EmptyStateVariant.large} data-testid="empty-state">
<EmptyStateIcon icon={RepositoryIcon} />
<Title headingLevel="h4" size="lg">
No Custom Repositories
</Title>
<EmptyStateBody>
Custom repositories managed via the Red Hat Insights Repositories app
will be available here to select and use to search for additional
packages.
</EmptyStateBody>
<Button
variant="primary"
component="a"
target="_blank"
href={isBeta() ? '/beta/settings/content' : '/settings/content'}
>
Repositories
</Button>
</EmptyState>
);
};

View file

@ -42,14 +42,6 @@ async function getPackages(distribution, architecture, search, limit) {
return request.data;
}
async function getRepositories(limit) {
const params = new URLSearchParams();
limit && params.append('limit', limit);
const path = '/repositories/' + params.toString();
const request = await axios.get(CONTENT_SOURCES.concat(path));
return request.data;
}
async function getPackagesContentSources(repoUrls, search) {
// content-sources expects an array of urls but we store the whole repo object
// so map the urls into an array to send to the content-sources api
@ -113,6 +105,5 @@ export default {
getComposeStatus,
getPackages,
getPackagesContentSources,
getRepositories,
getVersion,
};

View file

@ -4,6 +4,8 @@ export const CONTENT_SOURCES = '/api/content-sources/v1';
export const PROVISIONING_SOURCES_ENDPOINT = '/api/provisioning/v1/sources';
export const RHEL_8 = 'rhel-87';
export const RHEL_9 = 'rhel-91';
export const CENTOS_8 = 'centos-8';
export const CENTOS_9 = 'centos-9';
export const UNIT_KIB = 1024 ** 1;
export const UNIT_MIB = 1024 ** 2;
@ -12,8 +14,8 @@ export const UNIT_GIB = 1024 ** 3;
export const RELEASES = new Map([
[RHEL_9, 'Red Hat Enterprise Linux (RHEL) 9'],
[RHEL_8, 'Red Hat Enterprise Linux (RHEL) 8'],
['centos-9', 'CentOS Stream 9'],
['centos-8', 'CentOS Stream 8'],
[CENTOS_9, 'CentOS Stream 9'],
[CENTOS_8, 'CentOS Stream 8'],
]);
export const DEFAULT_AWS_REGION = 'us-east-1';

View file

@ -1,6 +1,7 @@
import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react';
import {
CONTENT_SOURCES,
IMAGE_BUILDER_API,
PROVISIONING_SOURCES_ENDPOINT,
RHSM_API,
@ -63,6 +64,24 @@ export const apiSlice = createApi({
getActivationKeyInformation: builder.query({
query: (activationKey) => `${RHSM_API}/activation_keys/${activationKey}`,
}),
getRepositories: builder.query({
async queryFn(args, _queryApi, _extraOptions, fetchWithBQ) {
const { available_for_arch, available_for_version } = args;
const limit = 100;
let repositories = await fetchWithBQ(
`${CONTENT_SOURCES}/repositories/?available_for_arch=${available_for_arch}&available_for_version=${available_for_version}&limit=${limit}`
);
if (repositories.meta.count > limit) {
repositories = await fetchWithBQ(
`${CONTENT_SOURCES}/repositories/?available_for_arch=${available_for_arch}&available_for_version=${available_for_version}&limit=${repositories.meta.count}`
);
}
return repositories;
},
}),
}),
});
@ -73,5 +92,6 @@ export const {
useGetAzureSourceDetailQuery,
useGetActivationKeysQuery,
useGetActivationKeyInformationQuery,
useGetRepositoriesQuery,
usePrefetch,
} = apiSlice;

View file

@ -5,14 +5,12 @@ import promiseMiddleware from 'redux-promise-middleware';
import { apiSlice } from './apiSlice';
import clonesSlice from './clonesSlice';
import composesSlice from './composesSlice';
import repositoriesSlice from './repositoriesSlice';
export const reducer = {
[apiSlice.reducerPath]: apiSlice.reducer,
clones: clonesSlice,
composes: composesSlice,
notifications: notificationsReducer,
repositories: repositoriesSlice,
};
export const middleware = (getDefaultMiddleware) =>

View file

@ -1,67 +0,0 @@
import { createSlice } from '@reduxjs/toolkit';
import api from '../api';
const initialState = {
count: 0,
allIds: [],
byId: {},
error: null,
};
export const fetchRepositories = () => async (dispatch) => {
const response = await api.getRepositories();
let { data } = response;
const { meta } = response;
if (data.length < meta.count) {
({ data } = await api.getRepositories(meta.count));
}
dispatch(repositoriesAdded({ repositories: data }));
dispatch(repositoriesUpdatedCount({ count: data.length }));
};
export const repositoriesSlice = createSlice({
name: 'repositories',
initialState,
reducers: {
repositoriesAdded: (state, action) => {
action.payload.repositories.map((repo) => {
// The repo url is used as the id
if (!state.allIds.includes(repo.url)) {
state.allIds.push(repo.url);
}
state.byId[repo.url] = repo;
});
},
repositoriesUpdatedCount: (state, action) => {
state.count = action.payload.count;
},
},
});
export const selectRepositoryById = (state, repoId) =>
state.repositories.byId[repoId];
export const selectValidRepositoryIds = (state) => {
const validRepositoryIds = [];
for (const repoId of state.repositories.allIds) {
if (state.repositories.byId[repoId].status === 'Valid') {
validRepositoryIds.push(repoId);
}
}
return validRepositoryIds;
};
export const selectValidRepositories = (state) => {
const validRepositories = {};
for (const repoId of state.repositories.allIds) {
if (state.repositories.byId[repoId].status === 'Valid') {
validRepositories[repoId] = state.repositories.byId[repoId];
}
}
return validRepositories;
};
export const { repositoriesAdded, repositoriesUpdatedCount } =
repositoriesSlice.actions;
export default repositoriesSlice.reducer;

View file

@ -4,9 +4,7 @@ import { screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { rest } from 'msw';
import api from '../../../api.js';
import { PROVISIONING_SOURCES_ENDPOINT } from '../../../constants.js';
import { mockRepositoryResults } from '../../fixtures/repositories';
import { server } from '../../mocks/server.js';
import { renderWithReduxRouter } from '../../testUtils';
@ -48,10 +46,6 @@ describe('Step Upload to Azure', () => {
beforeAll(() => {
// scrollTo is not defined in jsdom
window.HTMLElement.prototype.scrollTo = function () {};
jest
.spyOn(api, 'getRepositories')
.mockImplementation(() => Promise.resolve(mockRepositoryResults));
});
afterEach(() => {

View file

@ -16,7 +16,6 @@ import {
RHEL_9,
PROVISIONING_SOURCES_ENDPOINT,
} from '../../../constants.js';
import { mockRepositoryResults } from '../../fixtures/repositories';
import { server } from '../../mocks/server.js';
import { renderWithReduxRouter } from '../../testUtils';
@ -85,72 +84,6 @@ const mockPkgResultAlphaContentSources = [
},
];
const mockRepositoryResponsePartial = {
data: new Array(100).fill().map((_, i) => {
return {
uuid: '9cf1d45d-aa06-46fe-87ea-121845cc6bbb',
name: '2lmdtj',
url:
'http://mirror.stream.centos.org/SIGs/9/kmods/x86_64/packages-main/' +
i,
distribution_versions: ['any'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 00:00:12.714873 +0000 UTC',
last_success_introspection_time: '2022-11-23 00:00:12.714873 +0000 UTC',
last_update_introspection_time: '2022-11-18 08:00:10.119093 +0000 UTC',
last_introspection_error: '',
package_count: 21,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
};
}),
meta: {
limit: 100,
offset: 0,
count: 132,
},
links: {
first: '/api/content-sources/v1/repositories/?limit=100&offset=0',
last: '/api/content-sources/v1/repositories/?limit=100&offset=0',
},
};
const mockRepositoryResponseAll = {
data: new Array(132).fill().map((_, i) => {
return {
uuid: '9cf1d45d-aa06-46fe-87ea-121845cc6bbb',
name: '2lmdtj',
url:
'http://mirror.stream.centos.org/SIGs/9/kmods/x86_64/packages-main/' +
i,
distribution_versions: ['any'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 00:00:12.714873 +0000 UTC',
last_success_introspection_time: '2022-11-23 00:00:12.714873 +0000 UTC',
last_update_introspection_time: '2022-11-18 08:00:10.119093 +0000 UTC',
last_introspection_error: '',
package_count: 21,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
};
}),
meta: {
limit: 132,
offset: 0,
count: 132,
},
links: {
first: '/api/content-sources/v1/repositories/?limit=132&offset=0',
last: '/api/content-sources/v1/repositories/?limit=132&offset=0',
},
};
const searchForAvailablePackages = async (searchbox, searchTerm) => {
const user = userEvent.setup();
await user.type(searchbox, searchTerm);
@ -633,43 +566,14 @@ describe('Step Custom repositories', () => {
getNextButton().click();
};
test('show only valid (successful) repositories', async () => {
jest
.spyOn(api, 'getRepositories')
.mockImplementation(() => Promise.resolve(mockRepositoryResults));
await setUp();
// Display all repositories on one page
screen.getByRole('button', { name: /items per page/i }).click();
screen.getByRole('menuitem', { name: /100 per page/i }).click();
// gnome-shell-extensions should not be present
const table = await screen.findByTestId('repositories-table');
const { getAllByRole } = within(table);
const rows = getAllByRole('row');
// remove first row from list since it is just header labels
rows.shift();
// mockRepositoryResults has 21 repositories, gnome-shell-extensions status is
// 'Invalid' and it should not appear in table
expect(rows).toHaveLength(20);
expect(table).not.toHaveTextContent('gnome-shell-extensions');
});
test('selected packages stored in and retrieved from form state', async () => {
jest
.spyOn(api, 'getRepositories')
.mockImplementation(() => Promise.resolve(mockRepositoryResults));
test('selected repositories stored in and retrieved from form state', async () => {
await setUp();
const getFirstRepoCheckbox = () =>
screen.getByRole('checkbox', {
screen.findByRole('checkbox', {
name: /select row 0/i,
});
let firstRepoCheckbox = getFirstRepoCheckbox();
let firstRepoCheckbox = await getFirstRepoCheckbox();
expect(firstRepoCheckbox.checked).toEqual(false);
await user.click(firstRepoCheckbox);
@ -678,39 +582,29 @@ describe('Step Custom repositories', () => {
getNextButton().click();
getBackButton().click();
firstRepoCheckbox = getFirstRepoCheckbox();
firstRepoCheckbox = await getFirstRepoCheckbox();
expect(firstRepoCheckbox.checked).toEqual(true);
});
test('all repositories are fetched when number of repositories is greater than API limit', async () => {
jest.spyOn(api, 'getRepositories').mockImplementation((limit) => {
return limit
? Promise.resolve(mockRepositoryResponseAll)
: Promise.resolve(mockRepositoryResponsePartial);
});
test('correct number of repositories is fetched', async () => {
await setUp();
screen
.getByRole('button', {
name: /select/i,
})
.click();
screen.getByText(/select all \(132 items\)/i);
const selectButton = await screen.findByRole('button', {
name: /select/i,
});
await user.click(selectButton);
screen.getByText(/select all \(1011 items\)/i);
});
test('filter works', async () => {
jest
.spyOn(api, 'getRepositories')
.mockImplementation(() => Promise.resolve(mockRepositoryResults));
await setUp();
await user.type(
screen.getByRole('textbox', { name: /search repositories/i }),
'2'
await screen.findByRole('textbox', { name: /search repositories/i }),
'2zmya'
);
// gnome-shell-extensions is invalid and should not be present
const table = await screen.findByTestId('repositories-table');
const { getAllByRole } = within(table);
const getRows = () => getAllByRole('row');
@ -719,7 +613,7 @@ describe('Step Custom repositories', () => {
// remove first row from list since it is just header labels
rows.shift();
expect(rows).toHaveLength(4);
expect(rows).toHaveLength(1);
// clear filter
screen.getByRole('button', { name: /reset/i }).click();
@ -735,10 +629,6 @@ describe('Step Custom repositories', () => {
describe('Click through all steps', () => {
const user = userEvent.setup();
jest
.spyOn(api, 'getRepositories')
.mockImplementation(() => Promise.resolve(mockRepositoryResults));
const setUp = async () => {
({ router, store } = renderWithReduxRouter('imagewizard', {}));
};
@ -852,8 +742,12 @@ describe('Click through all steps', () => {
getNextButton().click();
// Custom repositories
await user.click(screen.getByRole('checkbox', { name: /select row 0/i }));
await user.click(screen.getByRole('checkbox', { name: /select row 1/i }));
await user.click(
await screen.findByRole('checkbox', { name: /select row 0/i })
);
await user.click(
await screen.findByRole('checkbox', { name: /select row 1/i })
);
getNextButton().click();
// Custom packages
@ -924,7 +818,7 @@ describe('Click through all steps', () => {
},
{
baseurl: [
'http://mirror.stream.centos.org/SIGs/9/kmods/x86_64/packages-main/',
'http://mirror.stream.centos.org/SIGs/8/kmods/x86_64/packages-main/',
],
id: '9cf1d45d-aa06-46fe-87ea-121845cc6bbb',
name: '2lmdtj',
@ -941,7 +835,7 @@ describe('Click through all steps', () => {
},
{
baseurl:
'http://mirror.stream.centos.org/SIGs/9/kmods/x86_64/packages-main/',
'http://mirror.stream.centos.org/SIGs/8/kmods/x86_64/packages-main/',
rhsm: false,
},
],
@ -1091,7 +985,7 @@ describe('Click through all steps', () => {
});
const create = screen.getByRole('button', { name: /Create/ });
create.click();
await user.click(create);
// API request sent to backend
expect(composeImage).toHaveBeenCalledTimes(6);

View file

@ -1,27 +1,424 @@
export const mockRepositoryResults = {
data: [
{
uuid: 'dbad4dfc-1547-45f8-b5af-1d7fec0476c6',
name: '13lk3',
url: 'http://yum.theforeman.org/releases/3.4/el8/x86_64/',
distribution_versions: ['7'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:54:00.962352 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:54:00.962352 +0000 UTC',
last_update_introspection_time: '2022-10-04 00:18:12.123607 +0000 UTC',
last_introspection_error: '',
package_count: 605,
status: 'Valid',
gpg_key:
'-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBGN9300BEAC1FLODu0cL6saMMHa7yJY1JZUc+jQUI/HdECQrrsTaPXlcc7nM\nykYMMv6amPqbnhH/R5BW2Ano+OMse+PXtUr0NXU4OcvxbnnXkrVBVUf8mXI9DzLZ\njw8KoD+4/s0BuzO78zAJF5uhuyHMAK0ll9v0r92kK45Fas9iZTfRFcqFAzvgjScf\n5jeBnbRs5U3UTz9mtDy802mk357o1A8BD0qlu3kANDpjLbORGWdAj21A6sMJDYXy\nHS9FBNV54daNcr+weky2L9gaF2yFjeu2rSEHCSfkbWfpSiVUx/bDTj7XS6XDOuJT\nJqvGS8jHqjHAIFBirhCA4cY/jLKxWyMr5N6IbXpPAYgt8/YYz2aOYVvdyB8tZ1u1\nkVsMYSGcvTBexZCn1cDkbO6I+waIlsc0uxGqUGBKF83AVYCQqOkBjF1uNnu9qefE\nkEc9obr4JZsAgnisboU25ss5ZJddKlmFMKSi66g4S5ChLEPFq7MB06PhLFioaD3L\nEXza7XitoW5VBwr0BSVKAHMC0T2xbm70zY06a6gQRlvr9a10lPmv4Tptc7xgQReg\nu1TlFPbrkGJ0d8O6vHQRAd3zdsNaVr4gX0Tg7UYiqT9ZUkP7hOc8PYXQ28hHrHTB\nA63MTq0aiPlJ/ivTuX8M6+Bi25dIV6N6IOUi/NQKIYxgovJCDSdCAAM0fQARAQAB\ntCFMdWNhcyBHYXJmaWVsZCA8bHVjYXNAcmVkaGF0LmNvbT6JAlcEEwEIAEEWIQTO\nQZeiHnXqdjmfUURc6PeuecS2PAUCY33fTQIbAwUJA8JnAAULCQgHAgIiAgYVCgkI\nCwIEFgIDAQIeBwIXgAAKCRBc6PeuecS2PCk3D/9jW7xrBB/2MQFKd5l+mNMFyKwc\nL9M/M5RFI9GaQRo55CwnPb0nnxOJR1V5GzZ/YGii53H2ose65CfBOE2L/F/RvKF0\nH9S9MInixlahzzKtV3TpDoZGk5oZIHEMuPmPS4XaHggolrzExY0ib0mQuBBE/uEV\n/HlyHEunBKPhTkAe+6Q+2dl22SUuVfWr4Uzlp65+DkdN3M37WI1a3Suhnef3rOSM\nV6puUzWRR7qcYs5C2In87AcYPn92P5ur1y/C32r8Ftg3fRWnEzI9QfRG52ojNOLK\nyGQ8ZC9PGe0q7VFcF7ridT/uzRU+NVKldbJg+rvBnszb1MjNuR7rUQHyvGmbsUVQ\nRCsgdovkee3lP4gfZHzk2SSLVSo0+NJRNaM90EmPk14Pgi/yfRSDGBVvLBbEanYI\nv1ZtdIPRyKi+/IaMOu/l7nayM/8RzghdU+0f1FAif5qf9nXuI13P8fqcqfu67gNd\nkh0UUF1XyR5UHHEZQQDqCuKEkZJ/+27jYlsG1ZiLb1odlIWoR44RP6k5OJl0raZb\nyLXbAfpITsXiJJBpCam9P9+XR5VSfgkqp5hIa7J8piN3DoMpoExg4PPQr6PbLAJy\nOUCOnuB7yYVbj0wYuMXTuyrcBHh/UymQnS8AMpQoEkCLWS/A/Hze/pD23LgiBoLY\nXIn5A2EOAf7t2IMSlA==\n=OanT\n-----END PGP PUBLIC KEY BLOCK-----',
metadata_verification: false,
},
{
export const mockRepositoryResults = (args) => {
const data = generateData(args);
const meta = generateMeta(args.limit, data.length);
const links = generateLinks(args.limit);
return {
data: data,
meta: meta,
links: links,
};
};
const generateData = (args) => {
let repos = testingRepos;
args.available_for_arch &&
(repos = repos.filter(
(repo) =>
repo.distribution_arch === 'any' ||
repo.distribution_arch === args.available_for_arch
));
args.available_for_version &&
(repos = repos.filter((repo) => {
return (
repo.distribution_versions.includes(args.available_for_version) ||
repo.distribution_versions.includes('any')
);
}));
repos = repos.slice(0, args.limit);
// Filler repos will always appear in response as they have distribution_versions
// and distribution_arch of 'any'. High count is useful for testing pagination.
const fillerRepos = generateFillerRepos(1000);
return [...repos, ...fillerRepos];
};
const testingRepos = [
{
uuid: 'dbad4dfc-1547-45f8-b5af-1d7fec0476c6',
name: '13lk3',
url: 'http://yum.theforeman.org/releases/3.4/el8/x86_64/',
distribution_versions: ['8'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:54:00.962352 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:54:00.962352 +0000 UTC',
last_update_introspection_time: '2022-10-04 00:18:12.123607 +0000 UTC',
last_introspection_error: '',
package_count: 605,
status: 'Valid',
gpg_key:
'-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBGN9300BEAC1FLODu0cL6saMMHa7yJY1JZUc+jQUI/HdECQrrsTaPXlcc7nM\nykYMMv6amPqbnhH/R5BW2Ano+OMse+PXtUr0NXU4OcvxbnnXkrVBVUf8mXI9DzLZ\njw8KoD+4/s0BuzO78zAJF5uhuyHMAK0ll9v0r92kK45Fas9iZTfRFcqFAzvgjScf\n5jeBnbRs5U3UTz9mtDy802mk357o1A8BD0qlu3kANDpjLbORGWdAj21A6sMJDYXy\nHS9FBNV54daNcr+weky2L9gaF2yFjeu2rSEHCSfkbWfpSiVUx/bDTj7XS6XDOuJT\nJqvGS8jHqjHAIFBirhCA4cY/jLKxWyMr5N6IbXpPAYgt8/YYz2aOYVvdyB8tZ1u1\nkVsMYSGcvTBexZCn1cDkbO6I+waIlsc0uxGqUGBKF83AVYCQqOkBjF1uNnu9qefE\nkEc9obr4JZsAgnisboU25ss5ZJddKlmFMKSi66g4S5ChLEPFq7MB06PhLFioaD3L\nEXza7XitoW5VBwr0BSVKAHMC0T2xbm70zY06a6gQRlvr9a10lPmv4Tptc7xgQReg\nu1TlFPbrkGJ0d8O6vHQRAd3zdsNaVr4gX0Tg7UYiqT9ZUkP7hOc8PYXQ28hHrHTB\nA63MTq0aiPlJ/ivTuX8M6+Bi25dIV6N6IOUi/NQKIYxgovJCDSdCAAM0fQARAQAB\ntCFMdWNhcyBHYXJmaWVsZCA8bHVjYXNAcmVkaGF0LmNvbT6JAlcEEwEIAEEWIQTO\nQZeiHnXqdjmfUURc6PeuecS2PAUCY33fTQIbAwUJA8JnAAULCQgHAgIiAgYVCgkI\nCwIEFgIDAQIeBwIXgAAKCRBc6PeuecS2PCk3D/9jW7xrBB/2MQFKd5l+mNMFyKwc\nL9M/M5RFI9GaQRo55CwnPb0nnxOJR1V5GzZ/YGii53H2ose65CfBOE2L/F/RvKF0\nH9S9MInixlahzzKtV3TpDoZGk5oZIHEMuPmPS4XaHggolrzExY0ib0mQuBBE/uEV\n/HlyHEunBKPhTkAe+6Q+2dl22SUuVfWr4Uzlp65+DkdN3M37WI1a3Suhnef3rOSM\nV6puUzWRR7qcYs5C2In87AcYPn92P5ur1y/C32r8Ftg3fRWnEzI9QfRG52ojNOLK\nyGQ8ZC9PGe0q7VFcF7ridT/uzRU+NVKldbJg+rvBnszb1MjNuR7rUQHyvGmbsUVQ\nRCsgdovkee3lP4gfZHzk2SSLVSo0+NJRNaM90EmPk14Pgi/yfRSDGBVvLBbEanYI\nv1ZtdIPRyKi+/IaMOu/l7nayM/8RzghdU+0f1FAif5qf9nXuI13P8fqcqfu67gNd\nkh0UUF1XyR5UHHEZQQDqCuKEkZJ/+27jYlsG1ZiLb1odlIWoR44RP6k5OJl0raZb\nyLXbAfpITsXiJJBpCam9P9+XR5VSfgkqp5hIa7J8piN3DoMpoExg4PPQr6PbLAJy\nOUCOnuB7yYVbj0wYuMXTuyrcBHh/UymQnS8AMpQoEkCLWS/A/Hze/pD23LgiBoLY\nXIn5A2EOAf7t2IMSlA==\n=OanT\n-----END PGP PUBLIC KEY BLOCK-----',
metadata_verification: false,
},
{
uuid: '9cf1d45d-aa06-46fe-87ea-121845cc6bbb',
name: '2lmdtj',
url: 'http://mirror.stream.centos.org/SIGs/8/kmods/x86_64/packages-main/',
distribution_versions: ['8'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 00:00:12.714873 +0000 UTC',
last_success_introspection_time: '2022-11-23 00:00:12.714873 +0000 UTC',
last_update_introspection_time: '2022-11-18 08:00:10.119093 +0000 UTC',
last_introspection_error: '',
package_count: 21,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: '828e7db8-c0d4-48fc-a887-9070e0e75c45',
name: '2zmya',
url: 'https://download-i2.fedoraproject.org/pub/epel/9/Everything/x86_64/',
distribution_versions: ['9'],
distribution_arch: 'x86_64',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:18.111405 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:18.111405 +0000 UTC',
last_update_introspection_time: '2022-11-23 08:00:18.111405 +0000 UTC',
last_introspection_error: '',
package_count: 11526,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: 'ffe90892-6e6c-43c0-a284-df78977d8e37',
name: '4tnt6f',
url: 'https://mirror.linux.duke.edu/pub/centos/8-stream/BaseOS/x86_64/os/',
distribution_versions: ['9'],
distribution_arch: 'aarch64',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-22 16:00:06.455684 +0000 UTC',
last_success_introspection_time: '2022-11-22 16:00:06.455684 +0000 UTC',
last_update_introspection_time: '2022-10-04 00:06:03.021973 +0000 UTC',
last_introspection_error: '',
package_count: 11908,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: '744000a5-fde5-481d-a1ae-07f27e7f4db9',
name: '76nlti',
url: 'https://download-i2.fedoraproject.org/pub/epel/7/x86_64/',
distribution_versions: ['8', '9'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:01:28.74002 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:01:28.74002 +0000 UTC',
last_update_introspection_time: '2022-11-23 08:01:28.74002 +0000 UTC',
last_introspection_error: '',
package_count: 13739,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: '45068247-67b9-4f6d-8f19-1718ab56586e',
name: '938l0k',
url: 'http://yum.theforeman.org/client/3.4/el8/x86_64/',
distribution_versions: ['7'],
distribution_arch: 'x86_64',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:20.911292 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:20.911292 +0000 UTC',
last_update_introspection_time: '2022-10-04 00:18:10.148583 +0000 UTC',
last_introspection_error: '',
package_count: 17,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: '60887c35-ce7a-4abc-8c57-1cb8a596f63d',
name: 'a6vac',
url: 'http://mirror.stream.centos.org/9-stream/AppStream/x86_64/os/',
distribution_versions: ['7'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:21.719974 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:21.719974 +0000 UTC',
last_update_introspection_time: '2022-09-20 00:21:01.891526 +0000 UTC',
last_introspection_error: '',
package_count: 0,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: 'f033a5af-ae00-4c26-8bb9-7329d4f17180',
name: 'abi7n',
url: 'http://yum.theforeman.org/katello/4.6/katello/el8/x86_64/',
distribution_versions: ['7'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:01:31.52995 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:01:31.52995 +0000 UTC',
last_update_introspection_time: '2022-10-04 00:11:04.043452 +0000 UTC',
last_introspection_error: '',
package_count: 102,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: 'be0fd64b-b7d0-48f1-b671-4c74b93a42d2',
name: 'g2ikq',
url: 'http://yum.theforeman.org/client/3.4/el9/x86_64/',
distribution_versions: ['any'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:21.465594 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:21.465594 +0000 UTC',
last_update_introspection_time: '2022-10-04 00:18:10.830524 +0000 UTC',
last_introspection_error: '',
package_count: 11,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: 'bf5270e6-0559-469b-a4bd-9c881f603813',
name: 'gnome-shell-extensions',
url: 'https://gitlab.gnome.org/GNOME/gnome-shell-extensions/',
distribution_versions: ['any'],
distribution_arch: 'x86_64',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:01:33.91888 +0000 UTC',
last_success_introspection_time: '',
last_update_introspection_time: '',
last_introspection_error:
'error parsing repomd.xml: xml.Unmarshal failure: expected element type <repomd> but have <html>',
package_count: 0,
status: 'Invalid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: '31ae1b1c-0a14-46df-a6d4-4170f88abeee',
name: 'i9arb',
url: 'http://yum.theforeman.org/pulpcore/3.18/el8/x86_64/',
distribution_versions: ['7'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 00:00:12.263236 +0000 UTC',
last_success_introspection_time: '2022-11-23 00:00:12.263236 +0000 UTC',
last_update_introspection_time: '2022-11-12 00:00:18.375292 +0000 UTC',
last_introspection_error: '',
package_count: 340,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: 'ea375230-32f7-490d-82b6-501f0a8c2932',
name: 'ixgwo',
url: 'http://yum.theforeman.org/client/3.3/el7/x86_64/',
distribution_versions: ['7'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:37.091305 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:37.091305 +0000 UTC',
last_update_introspection_time: '2022-10-10 16:11:35.690955 +0000 UTC',
last_introspection_error: '',
package_count: 14,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: 'aa9506b1-e5dd-42be-b5b0-a674f4db915f',
name: 'k64ic',
url: 'http://yum.theforeman.org/pulpcore/3.18/el9/x86_64/',
distribution_versions: ['any'],
distribution_arch: 'x86_64',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:18.671713 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:18.671713 +0000 UTC',
last_update_introspection_time: '2022-11-12 00:00:08.970966 +0000 UTC',
last_introspection_error: '',
package_count: 338,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: '3cce24d2-41e2-481d-8f01-2b043c72fd6f',
name: 'lrqm',
url: 'http://yum.theforeman.org/client/3.3/el8/x86_64/',
distribution_versions: ['any'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:11.11247 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:11.11247 +0000 UTC',
last_update_introspection_time: '2022-10-10 16:01:36.465549 +0000 UTC',
last_introspection_error: '',
package_count: 16,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: 'c988934a-87e2-482f-b887-d9ba677a037a',
name: 'mo1qy',
url: 'https://download-i2.fedoraproject.org/pub/epel/8/Everything/x86_64/',
distribution_versions: ['any'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:09.394253 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:09.394253 +0000 UTC',
last_update_introspection_time: '2022-11-23 08:00:09.394253 +0000 UTC',
last_introspection_error: '',
package_count: 9452,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: 'bbc2bba5-9d7d-4726-b96f-a48408e130b5',
name: 's2h9z',
url: 'http://mirror.stream.centos.org/9-stream/BaseOS/x86_64/os/',
distribution_versions: ['7'],
distribution_arch: 'x86_64',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-22 16:00:06.224391 +0000 UTC',
last_success_introspection_time: '2022-11-22 16:00:06.224391 +0000 UTC',
last_update_introspection_time: '2022-09-20 00:27:02.197045 +0000 UTC',
last_introspection_error: '',
package_count: 0,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: '593a973b-715f-4867-ae9c-fa791b59b92d',
name: 'v9h0m',
url: 'http://yum.theforeman.org/pulpcore/3.18/el7/x86_64/',
distribution_versions: ['any'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:19.586273 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:19.586273 +0000 UTC',
last_update_introspection_time: '2022-11-13 00:00:25.156398 +0000 UTC',
last_introspection_error: '',
package_count: 259,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: 'd08a74ef-589b-486f-aae0-60c6abe25768',
name: 'vbazm',
url: 'http://yum.theforeman.org/client/3.4/el7/x86_64/',
distribution_versions: ['any'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:37.944592 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:37.944592 +0000 UTC',
last_update_introspection_time: '2022-10-04 00:18:09.561151 +0000 UTC',
last_introspection_error: '',
package_count: 15,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: '0a12a77d-c3fa-4cd7-958b-ecbec1fd1494',
name: 'vv5jk',
url: 'http://yum.theforeman.org/client/3.2/el7/x86_64/',
distribution_versions: ['any'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 00:00:20.495629 +0000 UTC',
last_success_introspection_time: '2022-11-23 00:00:20.495629 +0000 UTC',
last_update_introspection_time: '2022-10-04 00:20:17.587417 +0000 UTC',
last_introspection_error: '',
package_count: 14,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: '5288c386-274c-4598-8f09-0e2f65346e0d',
name: 'ycxvp',
url: 'https://dl.google.com/linux/chrome/rpm/stable/x86_64/',
distribution_versions: ['any'],
distribution_arch: 'x86_64',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:09.595446 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:09.595446 +0000 UTC',
last_update_introspection_time: '2022-11-18 08:00:13.259506 +0000 UTC',
last_introspection_error: '',
package_count: 3,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: 'f087f9ad-dfe6-4627-9d53-336c09886cd4',
name: 'yzfsx',
url: 'http://yum.theforeman.org/client/3.3/el9/x86_64/',
distribution_versions: ['7'],
distribution_arch: 'x86_64',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:22.137451 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:22.137451 +0000 UTC',
last_update_introspection_time: '2022-10-10 16:00:18.041568 +0000 UTC',
last_introspection_error: '',
package_count: 11,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
];
const generateMeta = (limit, count) => {
return {
limit: limit,
offset: 0,
count: count,
};
};
const generateLinks = (limit) => {
return {
first: `/api/content-sources/v1/repositories/?limit=${limit}&offset=0`,
last: `/api/content-sources/v1/repositories/?limit=${limit}&offset=0`,
};
};
const generateFillerRepos = (num) => {
const repos = new Array(num).fill().map((_, i) => {
return {
uuid: '9cf1d45d-aa06-46fe-87ea-121845cc6bbb',
name: '2lmdtj',
url: 'http://mirror.stream.centos.org/SIGs/9/kmods/x86_64/packages-main/',
name: `filler repo ${i}`,
url: `http://fillerRepos.org/9/x86_64/packages/${i}`,
distribution_versions: ['any'],
distribution_arch: 'any',
account_id: '6416440',
@ -34,339 +431,7 @@ export const mockRepositoryResults = {
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: '828e7db8-c0d4-48fc-a887-9070e0e75c45',
name: '2zmya',
url: 'https://download-i2.fedoraproject.org/pub/epel/9/Everything/x86_64/',
distribution_versions: ['7'],
distribution_arch: 'x86_64',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:18.111405 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:18.111405 +0000 UTC',
last_update_introspection_time: '2022-11-23 08:00:18.111405 +0000 UTC',
last_introspection_error: '',
package_count: 11526,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: 'ffe90892-6e6c-43c0-a284-df78977d8e37',
name: '4tnt6f',
url: 'https://mirror.linux.duke.edu/pub/centos/8-stream/BaseOS/x86_64/os/',
distribution_versions: ['any'],
distribution_arch: 'x86_64',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-22 16:00:06.455684 +0000 UTC',
last_success_introspection_time: '2022-11-22 16:00:06.455684 +0000 UTC',
last_update_introspection_time: '2022-10-04 00:06:03.021973 +0000 UTC',
last_introspection_error: '',
package_count: 11908,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: '744000a5-fde5-481d-a1ae-07f27e7f4db9',
name: '76nlti',
url: 'https://download-i2.fedoraproject.org/pub/epel/7/x86_64/',
distribution_versions: ['7'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:01:28.74002 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:01:28.74002 +0000 UTC',
last_update_introspection_time: '2022-11-23 08:01:28.74002 +0000 UTC',
last_introspection_error: '',
package_count: 13739,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: '45068247-67b9-4f6d-8f19-1718ab56586e',
name: '938l0k',
url: 'http://yum.theforeman.org/client/3.4/el8/x86_64/',
distribution_versions: ['7'],
distribution_arch: 'x86_64',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:20.911292 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:20.911292 +0000 UTC',
last_update_introspection_time: '2022-10-04 00:18:10.148583 +0000 UTC',
last_introspection_error: '',
package_count: 17,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: '60887c35-ce7a-4abc-8c57-1cb8a596f63d',
name: 'a6vac',
url: 'http://mirror.stream.centos.org/9-stream/AppStream/x86_64/os/',
distribution_versions: ['7'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:21.719974 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:21.719974 +0000 UTC',
last_update_introspection_time: '2022-09-20 00:21:01.891526 +0000 UTC',
last_introspection_error: '',
package_count: 0,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: 'f033a5af-ae00-4c26-8bb9-7329d4f17180',
name: 'abi7n',
url: 'http://yum.theforeman.org/katello/4.6/katello/el8/x86_64/',
distribution_versions: ['7'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:01:31.52995 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:01:31.52995 +0000 UTC',
last_update_introspection_time: '2022-10-04 00:11:04.043452 +0000 UTC',
last_introspection_error: '',
package_count: 102,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: 'be0fd64b-b7d0-48f1-b671-4c74b93a42d2',
name: 'g2ikq',
url: 'http://yum.theforeman.org/client/3.4/el9/x86_64/',
distribution_versions: ['any'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:21.465594 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:21.465594 +0000 UTC',
last_update_introspection_time: '2022-10-04 00:18:10.830524 +0000 UTC',
last_introspection_error: '',
package_count: 11,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: 'bf5270e6-0559-469b-a4bd-9c881f603813',
name: 'gnome-shell-extensions',
url: 'https://gitlab.gnome.org/GNOME/gnome-shell-extensions/',
distribution_versions: ['any'],
distribution_arch: 'x86_64',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:01:33.91888 +0000 UTC',
last_success_introspection_time: '',
last_update_introspection_time: '',
last_introspection_error:
'error parsing repomd.xml: xml.Unmarshal failure: expected element type <repomd> but have <html>',
package_count: 0,
status: 'Invalid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: '31ae1b1c-0a14-46df-a6d4-4170f88abeee',
name: 'i9arb',
url: 'http://yum.theforeman.org/pulpcore/3.18/el8/x86_64/',
distribution_versions: ['7'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 00:00:12.263236 +0000 UTC',
last_success_introspection_time: '2022-11-23 00:00:12.263236 +0000 UTC',
last_update_introspection_time: '2022-11-12 00:00:18.375292 +0000 UTC',
last_introspection_error: '',
package_count: 340,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: 'ea375230-32f7-490d-82b6-501f0a8c2932',
name: 'ixgwo',
url: 'http://yum.theforeman.org/client/3.3/el7/x86_64/',
distribution_versions: ['7'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:37.091305 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:37.091305 +0000 UTC',
last_update_introspection_time: '2022-10-10 16:11:35.690955 +0000 UTC',
last_introspection_error: '',
package_count: 14,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: 'aa9506b1-e5dd-42be-b5b0-a674f4db915f',
name: 'k64ic',
url: 'http://yum.theforeman.org/pulpcore/3.18/el9/x86_64/',
distribution_versions: ['any'],
distribution_arch: 'x86_64',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:18.671713 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:18.671713 +0000 UTC',
last_update_introspection_time: '2022-11-12 00:00:08.970966 +0000 UTC',
last_introspection_error: '',
package_count: 338,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: '3cce24d2-41e2-481d-8f01-2b043c72fd6f',
name: 'lrqm',
url: 'http://yum.theforeman.org/client/3.3/el8/x86_64/',
distribution_versions: ['any'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:11.11247 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:11.11247 +0000 UTC',
last_update_introspection_time: '2022-10-10 16:01:36.465549 +0000 UTC',
last_introspection_error: '',
package_count: 16,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: 'c988934a-87e2-482f-b887-d9ba677a037a',
name: 'mo1qy',
url: 'https://download-i2.fedoraproject.org/pub/epel/8/Everything/x86_64/',
distribution_versions: ['any'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:09.394253 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:09.394253 +0000 UTC',
last_update_introspection_time: '2022-11-23 08:00:09.394253 +0000 UTC',
last_introspection_error: '',
package_count: 9452,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: 'bbc2bba5-9d7d-4726-b96f-a48408e130b5',
name: 's2h9z',
url: 'http://mirror.stream.centos.org/9-stream/BaseOS/x86_64/os/',
distribution_versions: ['7'],
distribution_arch: 'x86_64',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-22 16:00:06.224391 +0000 UTC',
last_success_introspection_time: '2022-11-22 16:00:06.224391 +0000 UTC',
last_update_introspection_time: '2022-09-20 00:27:02.197045 +0000 UTC',
last_introspection_error: '',
package_count: 0,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: '593a973b-715f-4867-ae9c-fa791b59b92d',
name: 'v9h0m',
url: 'http://yum.theforeman.org/pulpcore/3.18/el7/x86_64/',
distribution_versions: ['any'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:19.586273 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:19.586273 +0000 UTC',
last_update_introspection_time: '2022-11-13 00:00:25.156398 +0000 UTC',
last_introspection_error: '',
package_count: 259,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: 'd08a74ef-589b-486f-aae0-60c6abe25768',
name: 'vbazm',
url: 'http://yum.theforeman.org/client/3.4/el7/x86_64/',
distribution_versions: ['any'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:37.944592 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:37.944592 +0000 UTC',
last_update_introspection_time: '2022-10-04 00:18:09.561151 +0000 UTC',
last_introspection_error: '',
package_count: 15,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: '0a12a77d-c3fa-4cd7-958b-ecbec1fd1494',
name: 'vv5jk',
url: 'http://yum.theforeman.org/client/3.2/el7/x86_64/',
distribution_versions: ['any'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 00:00:20.495629 +0000 UTC',
last_success_introspection_time: '2022-11-23 00:00:20.495629 +0000 UTC',
last_update_introspection_time: '2022-10-04 00:20:17.587417 +0000 UTC',
last_introspection_error: '',
package_count: 14,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: '5288c386-274c-4598-8f09-0e2f65346e0d',
name: 'ycxvp',
url: 'https://dl.google.com/linux/chrome/rpm/stable/x86_64/',
distribution_versions: ['any'],
distribution_arch: 'x86_64',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:09.595446 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:09.595446 +0000 UTC',
last_update_introspection_time: '2022-11-18 08:00:13.259506 +0000 UTC',
last_introspection_error: '',
package_count: 3,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: 'f087f9ad-dfe6-4627-9d53-336c09886cd4',
name: 'yzfsx',
url: 'http://yum.theforeman.org/client/3.3/el9/x86_64/',
distribution_versions: ['7'],
distribution_arch: 'x86_64',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:22.137451 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:22.137451 +0000 UTC',
last_update_introspection_time: '2022-10-10 16:00:18.041568 +0000 UTC',
last_introspection_error: '',
package_count: 11,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
],
meta: {
limit: 100,
offset: 0,
count: 21,
},
links: {
first: '/api/content-sources/v1/repositories/?limit=100&offset=0',
last: '/api/content-sources/v1/repositories/?limit=100&offset=0',
},
};
});
return repos;
};

View file

@ -1,6 +1,11 @@
import { rest } from 'msw';
import { PROVISIONING_SOURCES_ENDPOINT, RHSM_API } from '../../constants';
import {
CONTENT_SOURCES,
PROVISIONING_SOURCES_ENDPOINT,
RHSM_API,
} from '../../constants';
import { mockRepositoryResults } from '../fixtures/repositories';
const baseURL = 'http://localhost';
@ -319,4 +324,16 @@ export const handlers = [
}
}
),
rest.get(
baseURL.concat(`${CONTENT_SOURCES}/repositories/`),
(req, res, ctx) => {
const available_for_arch = req.url.searchParams.get('available_for_arch');
const available_for_version = req.url.searchParams.get(
'available_for_version'
);
const limit = req.url.searchParams.get('limit');
const args = { available_for_arch, available_for_version, limit };
return res(ctx.status(200), ctx.json(mockRepositoryResults(args)));
}
),
];