Skip to content

Commit 4781687

Browse files
committed
♻️(frontend) Joanie api client load in test
Joanie's api client shouldn't be loaded on test that don't use it.
1 parent 596f6e8 commit 4781687

File tree

5 files changed

+9
-6
lines changed

5 files changed

+9
-6
lines changed

src/frontend/js/components/TeacherDashboardCourseList/index.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ describe('components/TeacherDashboardCourseList', () => {
6767

6868
await expectNoSpinner('Loading courses...');
6969
expect(
70-
screen.getByRole('heading', { name: /TeacherDashboardCourseList test title/ }),
70+
await screen.findByRole('heading', { name: /TeacherDashboardCourseList test title/ }),
7171
).toBeInTheDocument();
7272

7373
const calledUrls = fetchMock.calls().map((call) => call[0]);

src/frontend/js/hooks/useDefaultOrganizationId/index.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import fetchMock from 'fetch-mock';
33
import { RichieContextFactory as mockRichieContextFactory } from 'utils/test/factories/richie';
44
import { OrganizationFactory } from 'utils/test/factories/joanieLegacy';
55
import { Organization } from 'types/Joanie';
6-
import { JoanieAppWrapper, setupJoanieSession } from 'utils/test/wrappers/JoanieAppWrapper';
6+
import JoanieAppWrapper, { setupJoanieSession } from 'utils/test/wrappers/JoanieAppWrapper';
77
import useDefaultOrganizationId from '.';
88

99
jest.mock('utils/context', () => ({

src/frontend/js/pages/TeacherDashboardCourseLearnersLayout/hooks/useCourseLearnersFilters/index.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
CourseProductRelationFactory,
77
OrganizationFactory,
88
} from 'utils/test/factories/joanieLegacy';
9-
import { JoanieAppWrapper, setupJoanieSession } from 'utils/test/wrappers/JoanieAppWrapper';
9+
import JoanieAppWrapper, { setupJoanieSession } from 'utils/test/wrappers/JoanieAppWrapper';
1010
import useCourseLearnersFilters from '.';
1111

1212
jest.mock('utils/context', () => ({

src/frontend/js/utils/test/render.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { RenderResult, screen, render as testingLibraryRender } from '@testing-library/react';
2-
import React, { ReactElement } from 'react';
2+
import React, { ReactElement, lazy } from 'react';
33
import { Nullable } from 'types/utils';
44
import { AppWrapperProps } from './wrappers/types';
5-
import { JoanieAppWrapper } from './wrappers/JoanieAppWrapper';
5+
6+
const JoanieAppWrapper = lazy(() => import('./wrappers/JoanieAppWrapper'));
67

78
// ------- setup -------
89

src/frontend/js/utils/test/wrappers/JoanieAppWrapper.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const setupJoanieSession = () => {
1919
};
2020
};
2121

22-
export const JoanieAppWrapper = ({
22+
const JoanieAppWrapper = ({
2323
children,
2424
intlOptions,
2525
queryOptions,
@@ -35,3 +35,5 @@ export const JoanieAppWrapper = ({
3535
</BaseJoanieAppWrapper>
3636
);
3737
};
38+
39+
export default JoanieAppWrapper;

0 commit comments

Comments
 (0)