Skip to content

Commit

Permalink
Fixes 2533: Add red hat repositories UI (#156)
Browse files Browse the repository at this point in the history
* Fixes 2613: React 18, Patternfly 5, Node 18 update

* Fixes 2533: Add red hat repositories UI

* Hide row actions kebab if there are no actions

* Fix tests.

* Fix recoccuring formatting string

* Add a test, update toggle ids
  • Loading branch information
Andrewgdewar authored Nov 13, 2023
1 parent c7ae348 commit 6126a64
Show file tree
Hide file tree
Showing 13 changed files with 431 additions and 465 deletions.
207 changes: 0 additions & 207 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 56 additions & 2 deletions src/Pages/ContentListTable/ContentListTable.test.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { render, waitFor } from '@testing-library/react';
import dayjs from 'dayjs';
import {
ReactQueryTestWrapper,
defaultContentItemWithSnapshot,
defaultSnapshotItem,
testRepositoryParamsResponse,
} from '../../testingHelpers';
import { render, waitFor } from '@testing-library/react';
import ContentListTable from './ContentListTable';
import { useContentListQuery, useRepositoryParams } from '../../services/Content/ContentQueries';
import AddContent from './components/AddContent/AddContent';
import { ContentOrigin } from '../../services/Content/ContentApi';

jest.mock('../../services/Content/ContentQueries', () => ({
useRepositoryParams: jest.fn(),
Expand All @@ -22,14 +23,18 @@ jest.mock('../../services/Content/ContentQueries', () => ({
}));

jest.mock('../../middleware/AppContext', () => ({
useAppContext: () => ({}),
useAppContext: () => ({
contentOrigin: ContentOrigin.EXTERNAL,
setContentOrigin: () => {},
}),
}));

jest.mock('./components/AddContent/AddContent');

jest.mock('react-router-dom', () => ({
useNavigate: jest.fn(),
Outlet: () => <></>,
useSearchParams: () => [{ get: () => 'external' }, () => {}],
}));

(AddContent as jest.Mock).mockImplementation(() => 'Add Content');
Expand Down Expand Up @@ -116,3 +121,52 @@ it('Render with a single row', () => {
).toBeInTheDocument(),
);
});

it('Render with a single redhat repository', () => {
jest.mock('react-router-dom', () => ({
useNavigate: jest.fn(),
Outlet: () => <></>,
useSearchParams: () => [{ get: () => 'red_hat' }, () => {}],
}));
jest.mock('../../middleware/AppContext', () => ({
useAppContext: () => ({
contentOrigin: ContentOrigin.REDHAT,
setContentOrigin: () => {},
}),
}));
(useRepositoryParams as jest.Mock).mockImplementation(() => ({
isLoading: false,
data: testRepositoryParamsResponse,
}));
(useContentListQuery as jest.Mock).mockImplementation(() => ({
isLoading: false,
data: {
data: [
{
account_id: 'undefined',
distribution_arch: 'x86_64',
distribution_versions: ['el7'],
name: 'AwesomeNamewwyylse12',
org_id: '-1',
url: 'https://google.ca/wwyylse12/x86_64/el7',
uuid: '2375c35b-a67a-4ac2-a989-21139433c172',
package_count: 0,
},
],
meta: { count: 1, limit: 20, offset: 0 },
},
}));

const { queryByText } = render(
<ReactQueryTestWrapper>
<ContentListTable />
</ReactQueryTestWrapper>,
);

waitFor(() => {
const value = document.getElementById('redhat-repositories-toggle-button');
expect(value?.getAttribute('aria-pressed')).toBe(true);
});
expect(queryByText('AwesomeNamewwyylse12')).toBeInTheDocument();
expect(queryByText('https://google.ca/wwyylse12/x86_64/el7')).toBeInTheDocument();
});
Loading

0 comments on commit 6126a64

Please sign in to comment.