Skip to content

Commit

Permalink
Updates tests
Browse files Browse the repository at this point in the history
Some changes introduced post rebase were breaking a test. This commit fixes the failing test.
  • Loading branch information
gagandeepb committed Sep 12, 2024
1 parent 0979183 commit bd7ca7c
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions assets/js/pages/ActivityLogPage/ActivityLogPage.test.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import '@testing-library/jest-dom';

import { networkClient } from '@lib/network';
import { renderWithRouter, withDefaultState, withState } from '@lib/test-utils';
import {
renderWithRouter,
withDefaultState,
withState,
defaultInitialState,
} from '@lib/test-utils';
import { activityLogEntryFactory } from '@lib/test-utils/factories/activityLog';
import { userFactory } from '@lib/test-utils/factories/users';
import { screen } from '@testing-library/react';
Expand Down Expand Up @@ -62,15 +67,20 @@ describe('ActivityLogPage', () => {

it('should render tracked activity log and the users filter with non-default/non-empty state', async () => {
const users = userFactory.buildList(5).map((user) => user.username);
axiosMock.onGet('/api/v1/activity_log');
axiosMock
.onGet('/api/v1/activity_log')
.reply(200, { data: activityLogEntryFactory.buildList(5) });
const [StatefulActivityLogPage, _] = withState(<ActivityLogPage />, {
...defaultInitialState,
activityLog: { users },
});
const { container } = await act(() =>
renderWithRouter(StatefulActivityLogPage)
);

await userEvent.click(screen.getByTestId('filter-User'));
expect(container.querySelectorAll('ul > li')).toHaveLength(users.length);
expect(container.querySelectorAll('ul > li[role="option"]')).toHaveLength(
users.length
);
});
});

0 comments on commit bd7ca7c

Please sign in to comment.