Skip to content

Commit 1a38c6f

Browse files
committed
♻️(frontend) missing richie context
To instanciate our generated api client, we need to build joanie's endpoint. Even if no api call are made on theses test, they need to mock richie context.
1 parent e1c5394 commit 1a38c6f

File tree

3 files changed

+36
-7
lines changed

3 files changed

+36
-7
lines changed

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
1-
import { render, screen } from '@testing-library/react';
21
import { IntlProvider } from 'react-intl';
3-
4-
import { RichieContextFactory, CourseLightFactory } from 'utils/test/factories/richie';
5-
import { CommonDataProps } from 'types/commonDataProps';
2+
import { render, screen } from '@testing-library/react';
63
import { CourseStateTextEnum, Priority } from 'types';
4+
import { CommonDataProps } from 'types/commonDataProps';
5+
import {
6+
CourseLightFactory,
7+
RichieContextFactory as mockRichieContextFactory,
8+
} from 'utils/test/factories/richie';
9+
710
import { CourseGlimpseList, getCourseGlimpseListProps } from '.';
811

12+
jest.mock('utils/context', () => ({
13+
__esModule: true,
14+
default: mockRichieContextFactory({
15+
joanie_backend: { endpoint: 'https://joanie.endpoint' },
16+
}).one(),
17+
}));
18+
919
describe('widgets/Search/components/CourseGlimpseList', () => {
10-
const contextProps: CommonDataProps['context'] = RichieContextFactory().one();
20+
const contextProps: CommonDataProps['context'] = mockRichieContextFactory().one();
1121

1222
it('renders a list of Courses into a list of CourseGlimpses', () => {
1323
const courses = [

src/frontend/js/pages/TeacherDashboardCourseLearnersLayout/components/CourseLearnerDataGrid/index.spec.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
11
import { createIntl } from 'react-intl';
2-
import { screen } from '@testing-library/react';
3-
import { getAllByRole, within } from '@testing-library/dom';
42
import { faker } from '@faker-js/faker';
3+
import { getAllByRole, within } from '@testing-library/dom';
4+
import { screen } from '@testing-library/react';
55
import { NestedCourseOrderFactory } from 'utils/test/factories/joanieLegacy';
66
import { expectNoSpinner } from 'utils/test/expectSpinner';
77
import { PaginationFactory } from 'utils/test/factories/cunningham';
88
import { DEFAULT_DATE_FORMAT } from 'hooks/useDateFormat';
9+
import { RichieContextFactory as mockRichieContextFactory } from 'utils/test/factories/richie';
910
import { OrderState } from 'types/Joanie';
1011
import { render } from 'utils/test/render';
1112
import { PresentationalAppWrapper } from 'utils/test/wrappers/PresentationalAppWrapper';
13+
1214
import CourseLearnerDataGrid from '.';
1315

16+
jest.mock('utils/context', () => ({
17+
__esModule: true,
18+
default: mockRichieContextFactory({
19+
joanie_backend: { endpoint: 'https://joanie.endpoint' },
20+
}).one(),
21+
}));
22+
1423
describe('pages/CourseLearnerDataGrid', () => {
1524
it('should render a list of user', async () => {
1625
const courseOrderList = NestedCourseOrderFactory({

src/frontend/js/widgets/Dashboard/hooks/useDashboardRouter/index.spec.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
import { PropsWithChildren } from 'react';
2+
23
import { IntlProvider } from 'react-intl';
34
import { renderHook } from '@testing-library/react';
5+
import { RichieContextFactory as mockRichieContextFactory } from 'utils/test/factories/richie';
6+
47
import useDashboardRoutes from '.';
58

9+
jest.mock('utils/context', () => ({
10+
__esModule: true,
11+
default: mockRichieContextFactory({
12+
joanie_backend: { endpoint: 'https://joanie.endpoint' },
13+
}).one(),
14+
}));
15+
616
describe('useDashboardRouter', () => {
717
const Wrapper = ({ children }: PropsWithChildren<{}>) => (
818
<IntlProvider locale="en">{children}</IntlProvider>

0 commit comments

Comments
 (0)