Skip to content

Commit

Permalink
fix: improve test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielVZ96 committed Dec 14, 2024
1 parent 8889017 commit 6d3db8d
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/library-authoring/LibraryAuthoringPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,49 @@ describe('<LibraryAuthoringPage />', () => {
});
});

it('filters by publish status', async () => {
await renderLibraryPage();

// Open the publish status filter dropdown
const filterButton = screen.getByRole('button', { name: /publish status/i });
fireEvent.click(filterButton);

// Test each publish status filter option
const publishedCheckbox = screen.getByRole('checkbox', { name: /^published \d+$/i });
const modifiedCheckbox = screen.getByRole('checkbox', { name: /^modified since publish \d+$/i });
const neverPublishedCheckbox = screen.getByRole('checkbox', { name: /^never published \d+$/i });

// Test Published filter
fireEvent.click(publishedCheckbox);
await waitFor(() => {
expect(fetchMock).toHaveBeenLastCalledWith(searchEndpoint, {
body: expect.stringContaining('"publish_status = published"'),
method: 'POST',
headers: expect.anything(),
});
});

// Test Modified filter
fireEvent.click(modifiedCheckbox);
await waitFor(() => {
expect(fetchMock).toHaveBeenLastCalledWith(searchEndpoint, {
body: expect.stringContaining('"publish_status = modified"'),
method: 'POST',
headers: expect.anything(),
});
});

// Test Never Published filter
fireEvent.click(neverPublishedCheckbox);
await waitFor(() => {
expect(fetchMock).toHaveBeenLastCalledWith(searchEndpoint, {
body: expect.stringContaining('"publish_status = never"'),
method: 'POST',
headers: expect.anything(),
});
});
});

it('Shows an error if libraries V2 is disabled', async () => {
const { axiosMock } = initializeMocks();
axiosMock.onGet(getStudioHomeApiUrl()).reply(200, {
Expand Down

0 comments on commit 6d3db8d

Please sign in to comment.