richie-education 2.25.0-b2.dev148 → 2.25.0-b2.dev152
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/js/contexts/JoanieApiContext/index.spec.tsx +1 -1
- package/js/contexts/SessionContext/JoanieSessionProvider.spec.tsx +44 -37
- package/js/contexts/SessionContext/index.spec.tsx +42 -21
- package/js/contexts/SessionContext/no-authentication.spec.tsx +3 -2
- package/js/hooks/useCourseSearchParams/index.spec.tsx +0 -1
- package/js/hooks/useUnionResource/index.spec.tsx +11 -9
- package/js/utils/test/render.tsx +5 -1
- package/js/utils/test/wrappers/BaseAppWrapper.tsx +5 -8
- package/js/utils/test/wrappers/BaseJoanieAppWrapper.tsx +4 -7
- package/js/utils/test/wrappers/IntlWrapper.tsx +4 -2
- package/js/utils/test/wrappers/PresentationalAppWrapper.tsx +1 -1
- package/js/utils/test/wrappers/ReactQueryAppWrapper.tsx +16 -0
- package/js/widgets/Dashboard/components/DashboardAvatar/index.spec.tsx +8 -5
- package/js/widgets/Dashboard/components/DashboardBox/index.spec.tsx +3 -1
- package/js/widgets/Dashboard/components/DashboardItem/Certificate/index.spec.tsx +19 -39
- package/js/widgets/Dashboard/components/DashboardItem/CertificateStatus/index.spec.tsx +14 -12
- package/js/widgets/Dashboard/components/DashboardItem/Contract/index.spec.tsx +5 -43
- package/js/widgets/Dashboard/components/DashboardItem/CourseEnrolling/index.spec.tsx +16 -15
- package/js/widgets/Dashboard/components/DashboardItem/Enrollment/DashboardItemEnrollment.spec.tsx +8 -18
- package/js/widgets/Dashboard/components/DashboardItem/Enrollment/ProductCertificateFooter/index.spec.tsx +19 -51
- package/js/widgets/Dashboard/components/DashboardItem/Order/DashboardItemOrder.spec.tsx +40 -70
- package/js/widgets/Dashboard/components/DashboardItem/Order/DashboardItemOrderContract.spec.tsx +31 -32
- package/js/widgets/Dashboard/components/DashboardItem/Order/OrderStateLearnerMessage/index.spec.tsx +19 -31
- package/js/widgets/Dashboard/components/DashboardItem/Order/OrderStateTeacherMessage/index.spec.tsx +26 -37
- package/js/widgets/Dashboard/components/DashboardItem/index.spec.tsx +28 -23
- package/js/widgets/Dashboard/components/DashboardLayoutRoute/index.spec.tsx +53 -51
- package/js/widgets/Dashboard/components/DashboardSidebar/components/ContractNavLink/index.spec.tsx +24 -49
- package/js/widgets/Dashboard/components/DashboardSidebar/components/MenuNavLink/index.spec.tsx +5 -14
- package/js/widgets/Dashboard/components/ProtectedOutlet/AuthenticatedOutlet.spec.tsx +62 -54
- package/js/widgets/Dashboard/components/ProtectedOutlet/ProtectedOutlet.spec.tsx +67 -42
- package/js/widgets/Dashboard/components/RouterButton/index.spec.tsx +12 -14
- package/js/widgets/Dashboard/components/TeacherDashboardOrganizationSidebar/index.spec.tsx +14 -39
- package/js/widgets/Dashboard/hooks/useDashboardRouter/index.spec.tsx +2 -4
- package/js/widgets/Dashboard/hooks/useEnroll/index.spec.tsx +7 -28
- package/js/widgets/Dashboard/hooks/useRouteInfo/index.spec.tsx +25 -33
- package/js/widgets/Dashboard/index.spec.tsx +49 -43
- package/js/widgets/LanguageSelector/index.spec.tsx +7 -7
- package/js/widgets/LtiConsumer/index.spec.tsx +46 -48
- package/js/widgets/RootSearchSuggestField/index.spec.tsx +8 -6
- package/js/widgets/Search/components/PaginateCourseSearch/index.spec.tsx +10 -3
- package/js/widgets/Search/components/SearchFilterGroup/index.spec.tsx +5 -3
- package/js/widgets/Search/components/SearchFilterGroupModal/index.spec.tsx +8 -4
- package/js/widgets/Search/components/SearchFilterValueLeaf/index.spec.tsx +7 -3
- package/js/widgets/Search/components/SearchFilterValueParent/index.spec.tsx +12 -7
- package/js/widgets/Search/components/SearchFiltersPane/index.spec.tsx +5 -1
- package/js/widgets/Search/hooks/useCourseSearch/index.spec.tsx +4 -12
- package/js/widgets/Search/hooks/useFilterValue/index.spec.tsx +0 -2
- package/js/widgets/Search/index.spec.tsx +14 -6
- package/js/widgets/SearchSuggestField/index.spec.tsx +14 -1
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/components/CourseProductCertificateItem/index.spec.tsx +16 -31
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/components/CourseProductCourseRuns/index.spec.tsx +46 -72
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/components/CourseRunItem/index.spec.tsx +5 -2
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/index.spec.tsx +147 -162
- package/js/widgets/SyllabusCourseRunsList/components/CourseRunEnrollment/CourseRunUnenrollmentButton/index.spec.tsx +6 -4
- package/js/widgets/SyllabusCourseRunsList/components/CourseRunEnrollment/index.joanie.spec.tsx +22 -99
- package/js/widgets/SyllabusCourseRunsList/components/CourseRunEnrollment/index.openedx.spec.tsx +27 -83
- package/js/widgets/SyllabusCourseRunsList/components/CourseRunItem/index.spec.tsx +4 -1
- package/js/widgets/SyllabusCourseRunsList/components/CourseRunItemWithEnrollment/index.spec.tsx +28 -35
- package/js/widgets/SyllabusCourseRunsList/components/CourseWishButton/hooks/useCourseWish/index.spec.tsx +9 -28
- package/js/widgets/SyllabusCourseRunsList/components/CourseWishButton/index.login.spec.tsx +23 -48
- package/js/widgets/SyllabusCourseRunsList/components/CourseWishButton/index.logout.spec.tsx +20 -29
- package/js/widgets/SyllabusCourseRunsList/components/SyllabusSimpleCourseRunsList/index.spec.tsx +9 -4
- package/js/widgets/SyllabusCourseRunsList/hooks/useCourseEnrollment/index.spec.tsx +8 -10
- package/js/widgets/SyllabusCourseRunsList/index.spec.tsx +28 -39
- package/js/widgets/UserLogin/components/UserMenu/index.spec.tsx +9 -6
- package/js/widgets/UserLogin/index.not.isJoanieEnabled.spec.tsx +21 -32
- package/js/widgets/UserLogin/index.spec.tsx +15 -37
- package/js/widgets/index.spec.tsx +12 -17
- package/package.json +1 -1
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { type PropsWithChildren } from 'react';
|
|
2
|
-
import { act,
|
|
3
|
-
import { IntlProvider } from 'react-intl';
|
|
2
|
+
import { act, renderHook, waitFor } from '@testing-library/react';
|
|
4
3
|
import fetchMock from 'fetch-mock';
|
|
5
|
-
import {
|
|
4
|
+
import { QueryObserverOptions } from '@tanstack/react-query';
|
|
6
5
|
import {
|
|
7
6
|
RichieContextFactory as mockRichieContextFactory,
|
|
8
7
|
UserFactory,
|
|
9
8
|
} from 'utils/test/factories/richie';
|
|
10
9
|
import { Deferred } from 'utils/test/deferred';
|
|
11
|
-
import BaseSessionProvider from 'contexts/SessionContext/BaseSessionProvider';
|
|
12
10
|
import { RICHIE_LTI_ANONYMOUS_USER_ID_CACHE_KEY } from 'settings';
|
|
13
11
|
import { handle } from 'utils/errors/handle';
|
|
14
12
|
import { resolveAll } from 'utils/resolveAll';
|
|
@@ -16,6 +14,8 @@ import { createTestQueryClient } from 'utils/test/createTestQueryClient';
|
|
|
16
14
|
import { noop } from 'utils';
|
|
17
15
|
import { useSession } from 'contexts/SessionContext';
|
|
18
16
|
import { HttpError, HttpStatusCode } from 'utils/errors/HttpError';
|
|
17
|
+
import { render } from 'utils/test/render';
|
|
18
|
+
import { BaseAppWrapper } from 'utils/test/wrappers/BaseAppWrapper';
|
|
19
19
|
import {
|
|
20
20
|
LtiConsumerContentParameters,
|
|
21
21
|
LtiConsumerContext,
|
|
@@ -35,8 +35,6 @@ jest.mock('uuid', () => ({
|
|
|
35
35
|
|
|
36
36
|
describe('widgets/LtiConsumer', () => {
|
|
37
37
|
afterEach(() => {
|
|
38
|
-
fetchMock.restore();
|
|
39
|
-
jest.resetAllMocks();
|
|
40
38
|
sessionStorage.clear();
|
|
41
39
|
delete window.CMS;
|
|
42
40
|
});
|
|
@@ -55,13 +53,13 @@ describe('widgets/LtiConsumer', () => {
|
|
|
55
53
|
});
|
|
56
54
|
HTMLFormElement.prototype.submit = mockSubmit;
|
|
57
55
|
|
|
58
|
-
const Wrapper = ({ client, children }: PropsWithChildren<{ client: QueryClient }>) => (
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
);
|
|
56
|
+
// const Wrapper = ({ client, children }: PropsWithChildren<{ client: QueryClient }>) => (
|
|
57
|
+
// <IntlProvider locale="en">
|
|
58
|
+
// <QueryClientProvider client={client}>
|
|
59
|
+
// <BaseSessionProvider>{children}</BaseSessionProvider>
|
|
60
|
+
// </QueryClientProvider>
|
|
61
|
+
// </IntlProvider>
|
|
62
|
+
// );
|
|
65
63
|
|
|
66
64
|
it('renders an auto-resized iframe with a LTI content', async () => {
|
|
67
65
|
const contentParameters = {
|
|
@@ -96,11 +94,10 @@ describe('widgets/LtiConsumer', () => {
|
|
|
96
94
|
ltiContextDeferred.promise,
|
|
97
95
|
);
|
|
98
96
|
|
|
99
|
-
const { container } = render(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
);
|
|
97
|
+
const { container } = render(<LtiConsumer {...ltiConsumerProps} />, {
|
|
98
|
+
wrapper: BaseAppWrapper,
|
|
99
|
+
queryOptions: { client: createTestQueryClient({ user: null }) },
|
|
100
|
+
});
|
|
104
101
|
|
|
105
102
|
await act(async () => ltiContextDeferred.resolve(ltiContextResponse));
|
|
106
103
|
|
|
@@ -163,11 +160,10 @@ describe('widgets/LtiConsumer', () => {
|
|
|
163
160
|
ltiContextDeferred.promise,
|
|
164
161
|
);
|
|
165
162
|
|
|
166
|
-
const { container } = render(
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
);
|
|
163
|
+
const { container } = render(<LtiConsumer {...ltiConsumerProps} />, {
|
|
164
|
+
wrapper: BaseAppWrapper,
|
|
165
|
+
queryOptions: { client: createTestQueryClient({ user: null }) },
|
|
166
|
+
});
|
|
171
167
|
|
|
172
168
|
await act(async () => ltiContextDeferred.resolve(ltiContextResponse));
|
|
173
169
|
|
|
@@ -205,11 +201,10 @@ describe('widgets/LtiConsumer', () => {
|
|
|
205
201
|
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
|
206
202
|
);
|
|
207
203
|
|
|
208
|
-
const { container } = render(
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
);
|
|
204
|
+
const { container } = render(<LtiConsumer {...ltiConsumerProps} />, {
|
|
205
|
+
wrapper: BaseAppWrapper,
|
|
206
|
+
queryOptions: { client: createTestQueryClient({ user: null }) },
|
|
207
|
+
});
|
|
213
208
|
|
|
214
209
|
await waitFor(() =>
|
|
215
210
|
expect(mockHandle).toHaveBeenCalledWith(new HttpError(500, 'Internal Server Error')),
|
|
@@ -233,15 +228,14 @@ describe('widgets/LtiConsumer', () => {
|
|
|
233
228
|
},
|
|
234
229
|
});
|
|
235
230
|
|
|
236
|
-
render(
|
|
237
|
-
|
|
238
|
-
|
|
231
|
+
render(<LtiConsumer id={1337} />, {
|
|
232
|
+
wrapper: BaseAppWrapper,
|
|
233
|
+
queryOptions: {
|
|
234
|
+
client: createTestQueryClient({
|
|
239
235
|
user: { username: 'johndoe', email: 'johndoe@example.com' },
|
|
240
|
-
})
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
</Wrapper>,
|
|
244
|
-
);
|
|
236
|
+
}),
|
|
237
|
+
},
|
|
238
|
+
});
|
|
245
239
|
|
|
246
240
|
expect(fetchMock.calls()).toHaveLength(1);
|
|
247
241
|
expect(
|
|
@@ -265,11 +259,14 @@ describe('widgets/LtiConsumer', () => {
|
|
|
265
259
|
ltiContextDeferred.promise,
|
|
266
260
|
);
|
|
267
261
|
|
|
268
|
-
render(
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
262
|
+
render(<LtiConsumer id={1337} />, {
|
|
263
|
+
wrapper: BaseAppWrapper,
|
|
264
|
+
queryOptions: {
|
|
265
|
+
client: createTestQueryClient({
|
|
266
|
+
user: null,
|
|
267
|
+
}),
|
|
268
|
+
},
|
|
269
|
+
});
|
|
273
270
|
|
|
274
271
|
expect(fetchMock.calls()).toHaveLength(1);
|
|
275
272
|
expect(
|
|
@@ -300,11 +297,12 @@ describe('widgets/LtiConsumer', () => {
|
|
|
300
297
|
);
|
|
301
298
|
const client = createTestQueryClient({ user: null });
|
|
302
299
|
|
|
303
|
-
render(
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
300
|
+
render(<LtiConsumer id={1337} />, {
|
|
301
|
+
wrapper: BaseAppWrapper,
|
|
302
|
+
queryOptions: {
|
|
303
|
+
client,
|
|
304
|
+
},
|
|
305
|
+
});
|
|
308
306
|
|
|
309
307
|
await act(async () =>
|
|
310
308
|
ltiContextDeferred.resolve({
|
|
@@ -368,10 +366,10 @@ describe('widgets/LtiConsumer', () => {
|
|
|
368
366
|
|
|
369
367
|
const { result } = renderHook(useSession, {
|
|
370
368
|
wrapper: ({ children }: PropsWithChildren) => (
|
|
371
|
-
<
|
|
369
|
+
<BaseAppWrapper queryOptions={{ client }}>
|
|
372
370
|
<LtiConsumer id={1337} />
|
|
373
371
|
{children}
|
|
374
|
-
</
|
|
372
|
+
</BaseAppWrapper>
|
|
375
373
|
),
|
|
376
374
|
});
|
|
377
375
|
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { fireEvent,
|
|
1
|
+
import { fireEvent, screen, waitFor } from '@testing-library/react';
|
|
2
2
|
import fetchMock from 'fetch-mock';
|
|
3
3
|
import { IntlProvider } from 'react-intl';
|
|
4
4
|
|
|
5
5
|
import { location } from 'utils/indirection/window';
|
|
6
6
|
import { RichieContextFactory as mockRichieContextFactory } from 'utils/test/factories/richie';
|
|
7
7
|
import context from 'utils/context';
|
|
8
|
+
import { render } from 'utils/test/render';
|
|
8
9
|
import RootSearchSuggestField from '.';
|
|
9
10
|
|
|
10
11
|
jest.mock('settings', () => ({
|
|
@@ -33,11 +34,6 @@ describe('<RootSearchSuggestField />', () => {
|
|
|
33
34
|
values: [],
|
|
34
35
|
};
|
|
35
36
|
|
|
36
|
-
afterEach(() => {
|
|
37
|
-
fetchMock.restore();
|
|
38
|
-
jest.resetAllMocks();
|
|
39
|
-
});
|
|
40
|
-
|
|
41
37
|
it('renders', () => {
|
|
42
38
|
fetchMock.get('/api/v1.0/filter-definitions/', {
|
|
43
39
|
subjects,
|
|
@@ -47,6 +43,7 @@ describe('<RootSearchSuggestField />', () => {
|
|
|
47
43
|
<IntlProvider locale="en">
|
|
48
44
|
<RootSearchSuggestField courseSearchPageUrl="/en/courses/" context={context} />
|
|
49
45
|
</IntlProvider>,
|
|
46
|
+
{ wrapper: null },
|
|
50
47
|
);
|
|
51
48
|
|
|
52
49
|
// The placeholder text is shown in the input
|
|
@@ -74,6 +71,7 @@ describe('<RootSearchSuggestField />', () => {
|
|
|
74
71
|
<IntlProvider locale="en">
|
|
75
72
|
<RootSearchSuggestField courseSearchPageUrl="/en/courses/" context={context} />
|
|
76
73
|
</IntlProvider>,
|
|
74
|
+
{ wrapper: null },
|
|
77
75
|
);
|
|
78
76
|
|
|
79
77
|
const field = screen.getByPlaceholderText('Search for courses');
|
|
@@ -118,6 +116,7 @@ describe('<RootSearchSuggestField />', () => {
|
|
|
118
116
|
<IntlProvider locale="en">
|
|
119
117
|
<RootSearchSuggestField courseSearchPageUrl="/en/courses/" context={context} />
|
|
120
118
|
</IntlProvider>,
|
|
119
|
+
{ wrapper: null },
|
|
121
120
|
);
|
|
122
121
|
|
|
123
122
|
const field = screen.getByPlaceholderText('Search for courses');
|
|
@@ -158,6 +157,7 @@ describe('<RootSearchSuggestField />', () => {
|
|
|
158
157
|
<IntlProvider locale="en">
|
|
159
158
|
<RootSearchSuggestField courseSearchPageUrl="/en/courses/" context={context} />
|
|
160
159
|
</IntlProvider>,
|
|
160
|
+
{ wrapper: null },
|
|
161
161
|
);
|
|
162
162
|
|
|
163
163
|
const field = screen.getByPlaceholderText('Search for courses');
|
|
@@ -195,6 +195,7 @@ describe('<RootSearchSuggestField />', () => {
|
|
|
195
195
|
<IntlProvider locale="en">
|
|
196
196
|
<RootSearchSuggestField courseSearchPageUrl="/en/courses/" context={context} />
|
|
197
197
|
</IntlProvider>,
|
|
198
|
+
{ wrapper: null },
|
|
198
199
|
);
|
|
199
200
|
|
|
200
201
|
const field = screen.getByPlaceholderText('Search for courses');
|
|
@@ -231,6 +232,7 @@ describe('<RootSearchSuggestField />', () => {
|
|
|
231
232
|
<IntlProvider locale="en">
|
|
232
233
|
<RootSearchSuggestField courseSearchPageUrl="/en/courses/" context={context} />
|
|
233
234
|
</IntlProvider>,
|
|
235
|
+
{ wrapper: null },
|
|
234
236
|
);
|
|
235
237
|
|
|
236
238
|
const field = screen.getByPlaceholderText('Search for courses');
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { fireEvent,
|
|
1
|
+
import { fireEvent, screen } from '@testing-library/react';
|
|
2
2
|
import queryString from 'query-string';
|
|
3
3
|
import { IntlProvider } from 'react-intl';
|
|
4
4
|
|
|
5
5
|
import { History, HistoryContext } from 'hooks/useHistory';
|
|
6
|
+
import { render } from 'utils/test/render';
|
|
6
7
|
import { PaginateCourseSearch } from '.';
|
|
7
8
|
|
|
8
9
|
describe('<PaginateCourseSearch />', () => {
|
|
@@ -18,8 +19,6 @@ describe('<PaginateCourseSearch />', () => {
|
|
|
18
19
|
historyReplaceState,
|
|
19
20
|
];
|
|
20
21
|
|
|
21
|
-
beforeEach(jest.resetAllMocks);
|
|
22
|
-
|
|
23
22
|
it('shows a pagination for course search (when on page 1)', () => {
|
|
24
23
|
render(
|
|
25
24
|
<IntlProvider locale="en">
|
|
@@ -27,6 +26,7 @@ describe('<PaginateCourseSearch />', () => {
|
|
|
27
26
|
<PaginateCourseSearch courseSearchTotalCount={200} />
|
|
28
27
|
</HistoryContext.Provider>
|
|
29
28
|
</IntlProvider>,
|
|
29
|
+
{ wrapper: null },
|
|
30
30
|
);
|
|
31
31
|
|
|
32
32
|
screen.getByRole('navigation', { name: 'Pagination' });
|
|
@@ -49,6 +49,7 @@ describe('<PaginateCourseSearch />', () => {
|
|
|
49
49
|
<PaginateCourseSearch courseSearchTotalCount={211} />
|
|
50
50
|
</HistoryContext.Provider>
|
|
51
51
|
</IntlProvider>,
|
|
52
|
+
{ wrapper: null },
|
|
52
53
|
);
|
|
53
54
|
|
|
54
55
|
screen.getByRole('navigation', { name: 'Pagination' });
|
|
@@ -71,6 +72,7 @@ describe('<PaginateCourseSearch />', () => {
|
|
|
71
72
|
<PaginateCourseSearch courseSearchTotalCount={40} />
|
|
72
73
|
</HistoryContext.Provider>
|
|
73
74
|
</IntlProvider>,
|
|
75
|
+
{ wrapper: null },
|
|
74
76
|
);
|
|
75
77
|
expect(screen.queryByRole('button')).toBeNull();
|
|
76
78
|
const nextPageAnchor = screen.getByRole('link');
|
|
@@ -84,6 +86,7 @@ describe('<PaginateCourseSearch />', () => {
|
|
|
84
86
|
<PaginateCourseSearch courseSearchTotalCount={345} />
|
|
85
87
|
</HistoryContext.Provider>
|
|
86
88
|
</IntlProvider>,
|
|
89
|
+
{ wrapper: null },
|
|
87
90
|
);
|
|
88
91
|
|
|
89
92
|
screen.getByRole('navigation', { name: 'Pagination' });
|
|
@@ -113,6 +116,7 @@ describe('<PaginateCourseSearch />', () => {
|
|
|
113
116
|
<PaginateCourseSearch courseSearchTotalCount={101} />
|
|
114
117
|
</HistoryContext.Provider>
|
|
115
118
|
</IntlProvider>,
|
|
119
|
+
{ wrapper: null },
|
|
116
120
|
);
|
|
117
121
|
|
|
118
122
|
screen.getByRole('navigation', { name: 'Pagination' });
|
|
@@ -141,6 +145,7 @@ describe('<PaginateCourseSearch />', () => {
|
|
|
141
145
|
<PaginateCourseSearch courseSearchTotalCount={14} />
|
|
142
146
|
</HistoryContext.Provider>
|
|
143
147
|
</IntlProvider>,
|
|
148
|
+
{ wrapper: null },
|
|
144
149
|
);
|
|
145
150
|
|
|
146
151
|
expect(screen.queryByRole('pagination', { name: 'Pagination' })).toEqual(null);
|
|
@@ -153,6 +158,7 @@ describe('<PaginateCourseSearch />', () => {
|
|
|
153
158
|
<PaginateCourseSearch courseSearchTotalCount={200} />
|
|
154
159
|
</HistoryContext.Provider>
|
|
155
160
|
</IntlProvider>,
|
|
161
|
+
{ wrapper: null },
|
|
156
162
|
);
|
|
157
163
|
|
|
158
164
|
screen.getByRole('navigation', { name: 'Pagination' });
|
|
@@ -183,6 +189,7 @@ describe('<PaginateCourseSearch />', () => {
|
|
|
183
189
|
<PaginateCourseSearch courseSearchTotalCount={200} />
|
|
184
190
|
</HistoryContext.Provider>
|
|
185
191
|
</IntlProvider>,
|
|
192
|
+
{ wrapper: null },
|
|
186
193
|
);
|
|
187
194
|
|
|
188
195
|
screen.getByRole('navigation', { name: 'Pagination' });
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { screen } from '@testing-library/react';
|
|
2
2
|
import queryString from 'query-string';
|
|
3
3
|
import { IntlProvider } from 'react-intl';
|
|
4
4
|
|
|
5
5
|
import { History, HistoryContext } from 'hooks/useHistory';
|
|
6
|
+
import { render } from 'utils/test/render';
|
|
6
7
|
import { SearchFilterGroup } from '.';
|
|
7
8
|
|
|
8
9
|
jest.mock('../SearchFilterValueLeaf', () => ({
|
|
@@ -52,8 +53,6 @@ describe('widgets/Search/components/SearchFilterGroup', () => {
|
|
|
52
53
|
],
|
|
53
54
|
};
|
|
54
55
|
|
|
55
|
-
beforeEach(jest.resetAllMocks);
|
|
56
|
-
|
|
57
56
|
it('renders the name of the filter with the values as SearchFilters', () => {
|
|
58
57
|
render(
|
|
59
58
|
<IntlProvider locale="en">
|
|
@@ -61,6 +60,7 @@ describe('widgets/Search/components/SearchFilterGroup', () => {
|
|
|
61
60
|
<SearchFilterGroup filter={filter} />
|
|
62
61
|
</HistoryContext.Provider>
|
|
63
62
|
</IntlProvider>,
|
|
63
|
+
{ wrapper: null },
|
|
64
64
|
);
|
|
65
65
|
// The filter group title and all filters are shown
|
|
66
66
|
screen.getByRole('group', { name: 'Organizations' });
|
|
@@ -76,6 +76,7 @@ describe('widgets/Search/components/SearchFilterGroup', () => {
|
|
|
76
76
|
<SearchFilterGroup filter={{ ...filter, is_searchable: false }} />
|
|
77
77
|
</HistoryContext.Provider>
|
|
78
78
|
</IntlProvider>,
|
|
79
|
+
{ wrapper: null },
|
|
79
80
|
);
|
|
80
81
|
|
|
81
82
|
expect(screen.queryByRole('button', { name: 'More options' })).toEqual(null);
|
|
@@ -88,6 +89,7 @@ describe('widgets/Search/components/SearchFilterGroup', () => {
|
|
|
88
89
|
<SearchFilterGroup filter={{ ...filter, has_more_values: false }} />
|
|
89
90
|
</HistoryContext.Provider>
|
|
90
91
|
</IntlProvider>,
|
|
92
|
+
{ wrapper: null },
|
|
91
93
|
);
|
|
92
94
|
|
|
93
95
|
expect(screen.queryByRole('button', { name: 'More options' })).toEqual(null);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { act, fireEvent,
|
|
1
|
+
import { act, fireEvent, screen, waitFor } from '@testing-library/react';
|
|
2
2
|
import userEvent from '@testing-library/user-event';
|
|
3
3
|
import fetchMock from 'fetch-mock';
|
|
4
4
|
import { range } from 'lodash-es';
|
|
@@ -9,6 +9,7 @@ import { History, HistoryContext } from 'hooks/useHistory';
|
|
|
9
9
|
import { Deferred } from 'utils/test/deferred';
|
|
10
10
|
import { resolveAll } from 'utils/resolveAll';
|
|
11
11
|
import { createTestQueryClient } from 'utils/test/createTestQueryClient';
|
|
12
|
+
import { render } from 'utils/test/render';
|
|
12
13
|
import { SearchFilterGroupModal } from '.';
|
|
13
14
|
|
|
14
15
|
jest.mock('utils/errors/handle', () => ({ handle: jest.fn() }));
|
|
@@ -61,9 +62,6 @@ describe('<SearchFilterGroupModal />', () => {
|
|
|
61
62
|
historyReplaceState,
|
|
62
63
|
];
|
|
63
64
|
|
|
64
|
-
beforeEach(() => fetchMock.restore());
|
|
65
|
-
beforeEach(jest.resetAllMocks);
|
|
66
|
-
|
|
67
65
|
it('renders a button with a modal to search values for a given filter', async () => {
|
|
68
66
|
{
|
|
69
67
|
const universitiesDeferred = new Deferred();
|
|
@@ -83,6 +81,7 @@ describe('<SearchFilterGroupModal />', () => {
|
|
|
83
81
|
</QueryClientProvider>
|
|
84
82
|
</HistoryContext.Provider>
|
|
85
83
|
</IntlProvider>,
|
|
84
|
+
{ wrapper: null },
|
|
86
85
|
);
|
|
87
86
|
|
|
88
87
|
// The modal is not rendered
|
|
@@ -242,6 +241,7 @@ describe('<SearchFilterGroupModal />', () => {
|
|
|
242
241
|
</QueryClientProvider>
|
|
243
242
|
</HistoryContext.Provider>
|
|
244
243
|
</IntlProvider>,
|
|
244
|
+
{ wrapper: null },
|
|
245
245
|
);
|
|
246
246
|
|
|
247
247
|
// The modal is rendered
|
|
@@ -419,6 +419,7 @@ describe('<SearchFilterGroupModal />', () => {
|
|
|
419
419
|
</QueryClientProvider>
|
|
420
420
|
</HistoryContext.Provider>
|
|
421
421
|
</IntlProvider>,
|
|
422
|
+
{ wrapper: null },
|
|
422
423
|
);
|
|
423
424
|
|
|
424
425
|
// The modal is not rendered
|
|
@@ -477,6 +478,7 @@ describe('<SearchFilterGroupModal />', () => {
|
|
|
477
478
|
</QueryClientProvider>
|
|
478
479
|
</HistoryContext.Provider>
|
|
479
480
|
</IntlProvider>,
|
|
481
|
+
{ wrapper: null },
|
|
480
482
|
);
|
|
481
483
|
|
|
482
484
|
// The modal is not rendered
|
|
@@ -559,6 +561,7 @@ describe('<SearchFilterGroupModal />', () => {
|
|
|
559
561
|
</QueryClientProvider>
|
|
560
562
|
</HistoryContext.Provider>
|
|
561
563
|
</IntlProvider>,
|
|
564
|
+
{ wrapper: null },
|
|
562
565
|
);
|
|
563
566
|
|
|
564
567
|
// The modal is not rendered
|
|
@@ -592,6 +595,7 @@ describe('<SearchFilterGroupModal />', () => {
|
|
|
592
595
|
</QueryClientProvider>
|
|
593
596
|
</HistoryContext.Provider>
|
|
594
597
|
</IntlProvider>,
|
|
598
|
+
{ wrapper: null },
|
|
595
599
|
);
|
|
596
600
|
|
|
597
601
|
// The modal is not rendered
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { fireEvent
|
|
1
|
+
import { fireEvent } from '@testing-library/react';
|
|
2
2
|
import queryString from 'query-string';
|
|
3
3
|
import { IntlProvider } from 'react-intl';
|
|
4
4
|
|
|
5
5
|
import { History, HistoryContext } from 'hooks/useHistory';
|
|
6
|
+
import { render } from 'utils/test/render';
|
|
6
7
|
import { SearchFilterValueLeaf } from '.';
|
|
7
8
|
|
|
8
9
|
describe('widgets/Search/components/SearchFilterValueLeaf', () => {
|
|
@@ -18,8 +19,6 @@ describe('widgets/Search/components/SearchFilterValueLeaf', () => {
|
|
|
18
19
|
historyReplaceState,
|
|
19
20
|
];
|
|
20
21
|
|
|
21
|
-
beforeEach(jest.resetAllMocks);
|
|
22
|
-
|
|
23
22
|
it('renders the name of the filter value', () => {
|
|
24
23
|
const { getByLabelText } = render(
|
|
25
24
|
<IntlProvider locale="en">
|
|
@@ -43,6 +42,7 @@ describe('widgets/Search/components/SearchFilterValueLeaf', () => {
|
|
|
43
42
|
/>
|
|
44
43
|
</HistoryContext.Provider>
|
|
45
44
|
</IntlProvider>,
|
|
45
|
+
{ wrapper: null },
|
|
46
46
|
);
|
|
47
47
|
|
|
48
48
|
// The filter value is displayed with its facet count
|
|
@@ -82,6 +82,7 @@ describe('widgets/Search/components/SearchFilterValueLeaf', () => {
|
|
|
82
82
|
/>
|
|
83
83
|
</HistoryContext.Provider>
|
|
84
84
|
</IntlProvider>,
|
|
85
|
+
{ wrapper: null },
|
|
85
86
|
);
|
|
86
87
|
|
|
87
88
|
// The filter shows its active state
|
|
@@ -113,6 +114,7 @@ describe('widgets/Search/components/SearchFilterValueLeaf', () => {
|
|
|
113
114
|
/>
|
|
114
115
|
</HistoryContext.Provider>
|
|
115
116
|
</IntlProvider>,
|
|
117
|
+
{ wrapper: null },
|
|
116
118
|
);
|
|
117
119
|
|
|
118
120
|
// The filter shows its active state
|
|
@@ -145,6 +147,7 @@ describe('widgets/Search/components/SearchFilterValueLeaf', () => {
|
|
|
145
147
|
/>
|
|
146
148
|
</HistoryContext.Provider>
|
|
147
149
|
</IntlProvider>,
|
|
150
|
+
{ wrapper: null },
|
|
148
151
|
);
|
|
149
152
|
|
|
150
153
|
fireEvent.click(getByLabelText((content) => content.includes('Human name')));
|
|
@@ -190,6 +193,7 @@ describe('widgets/Search/components/SearchFilterValueLeaf', () => {
|
|
|
190
193
|
/>
|
|
191
194
|
</HistoryContext.Provider>
|
|
192
195
|
</IntlProvider>,
|
|
196
|
+
{ wrapper: null },
|
|
193
197
|
);
|
|
194
198
|
|
|
195
199
|
fireEvent.click(getByLabelText((content) => content.includes('Human name')));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { fireEvent,
|
|
1
|
+
import { fireEvent, screen } from '@testing-library/react';
|
|
2
2
|
import queryString from 'query-string';
|
|
3
3
|
import { IntlProvider } from 'react-intl';
|
|
4
4
|
import { QueryClientProvider } from '@tanstack/react-query';
|
|
@@ -6,6 +6,7 @@ import { QueryClientProvider } from '@tanstack/react-query';
|
|
|
6
6
|
import { History, HistoryContext } from 'hooks/useHistory';
|
|
7
7
|
import { APIListRequestParams } from 'types/api';
|
|
8
8
|
import { createTestQueryClient } from 'utils/test/createTestQueryClient';
|
|
9
|
+
import { render } from 'utils/test/render';
|
|
9
10
|
import { fetchList } from '../../utils/getResourceList';
|
|
10
11
|
import { RequestStatus } from '../../types/api';
|
|
11
12
|
|
|
@@ -31,10 +32,6 @@ describe('<SearchFilterValueParent />', () => {
|
|
|
31
32
|
historyReplaceState,
|
|
32
33
|
];
|
|
33
34
|
|
|
34
|
-
afterEach(() => {
|
|
35
|
-
jest.resetAllMocks();
|
|
36
|
-
});
|
|
37
|
-
|
|
38
35
|
it('renders the parent filter value and a button to show the children', () => {
|
|
39
36
|
const { getByLabelText, queryByLabelText } = render(
|
|
40
37
|
<QueryClientProvider client={createTestQueryClient()}>
|
|
@@ -60,6 +57,7 @@ describe('<SearchFilterValueParent />', () => {
|
|
|
60
57
|
</HistoryContext.Provider>
|
|
61
58
|
</IntlProvider>
|
|
62
59
|
</QueryClientProvider>,
|
|
60
|
+
{ wrapper: null },
|
|
63
61
|
);
|
|
64
62
|
|
|
65
63
|
getByLabelText((content) => content.startsWith('Literature'));
|
|
@@ -122,13 +120,14 @@ describe('<SearchFilterValueParent />', () => {
|
|
|
122
120
|
);
|
|
123
121
|
const { getByLabelText, queryByLabelText, rerender } = render(
|
|
124
122
|
getElement({ limit: '999', offset: '0', subjects: [] }),
|
|
123
|
+
{ wrapper: null },
|
|
125
124
|
);
|
|
126
125
|
|
|
127
126
|
// Children filters are not shown
|
|
128
127
|
getByLabelText((content) => content.startsWith('Literature'));
|
|
129
128
|
expect(queryByLabelText('Hide additional filters for Literature')).toEqual(null);
|
|
130
|
-
queryByLabelText((content) => content.startsWith('Classical Literature'));
|
|
131
|
-
queryByLabelText((content) => content.startsWith('Modern Literature'));
|
|
129
|
+
expect(queryByLabelText((content) => content.startsWith('Classical Literature'))).toEqual(null);
|
|
130
|
+
expect(queryByLabelText((content) => content.startsWith('Modern Literature'))).toEqual(null);
|
|
132
131
|
|
|
133
132
|
// The params are updated, now include a child filter of Literature
|
|
134
133
|
rerender(getElement({ limit: '999', offset: '0', subjects: ['L-000400050004'] }));
|
|
@@ -194,6 +193,7 @@ describe('<SearchFilterValueParent />', () => {
|
|
|
194
193
|
</HistoryContext.Provider>
|
|
195
194
|
</IntlProvider>
|
|
196
195
|
</QueryClientProvider>,
|
|
196
|
+
{ wrapper: null },
|
|
197
197
|
);
|
|
198
198
|
|
|
199
199
|
getByLabelText((content) => content.startsWith('Literature'));
|
|
@@ -268,6 +268,7 @@ describe('<SearchFilterValueParent />', () => {
|
|
|
268
268
|
</HistoryContext.Provider>
|
|
269
269
|
</IntlProvider>
|
|
270
270
|
</QueryClientProvider>,
|
|
271
|
+
{ wrapper: null },
|
|
271
272
|
);
|
|
272
273
|
|
|
273
274
|
// The filter value is displayed with its facet count
|
|
@@ -303,6 +304,7 @@ describe('<SearchFilterValueParent />', () => {
|
|
|
303
304
|
</HistoryContext.Provider>
|
|
304
305
|
</IntlProvider>
|
|
305
306
|
</QueryClientProvider>,
|
|
307
|
+
{ wrapper: null },
|
|
306
308
|
);
|
|
307
309
|
|
|
308
310
|
// The filter shows its active state
|
|
@@ -342,6 +344,7 @@ describe('<SearchFilterValueParent />', () => {
|
|
|
342
344
|
</HistoryContext.Provider>
|
|
343
345
|
</IntlProvider>
|
|
344
346
|
</QueryClientProvider>,
|
|
347
|
+
{ wrapper: null },
|
|
345
348
|
);
|
|
346
349
|
|
|
347
350
|
const checkbox = getByLabelText((content) => content.startsWith('Human name'));
|
|
@@ -375,6 +378,7 @@ describe('<SearchFilterValueParent />', () => {
|
|
|
375
378
|
</HistoryContext.Provider>
|
|
376
379
|
</IntlProvider>
|
|
377
380
|
</QueryClientProvider>,
|
|
381
|
+
{ wrapper: null },
|
|
378
382
|
);
|
|
379
383
|
|
|
380
384
|
fireEvent.click(getByLabelText((content) => content.startsWith('Human name')));
|
|
@@ -422,6 +426,7 @@ describe('<SearchFilterValueParent />', () => {
|
|
|
422
426
|
</HistoryContext.Provider>
|
|
423
427
|
</IntlProvider>
|
|
424
428
|
</QueryClientProvider>,
|
|
429
|
+
{ wrapper: null },
|
|
425
430
|
);
|
|
426
431
|
|
|
427
432
|
fireEvent.click(getByLabelText((content) => content.startsWith('Human name')));
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { fireEvent
|
|
1
|
+
import { fireEvent } from '@testing-library/react';
|
|
2
2
|
import queryString from 'query-string';
|
|
3
3
|
import { IntlProvider } from 'react-intl';
|
|
4
4
|
|
|
5
5
|
import { History, HistoryContext } from 'hooks/useHistory';
|
|
6
|
+
import { render } from 'utils/test/render';
|
|
6
7
|
import { SearchFiltersPane } from '.';
|
|
7
8
|
|
|
8
9
|
jest.mock('../SearchFilterGroup', () => ({
|
|
@@ -68,6 +69,7 @@ describe('widgets/Search/components/SearchFiltersPane', () => {
|
|
|
68
69
|
/>
|
|
69
70
|
</HistoryContext.Provider>
|
|
70
71
|
</IntlProvider>,
|
|
72
|
+
{ wrapper: null },
|
|
71
73
|
);
|
|
72
74
|
|
|
73
75
|
// The pane's title is shown along with filter groups in the order defined by their position
|
|
@@ -87,6 +89,7 @@ describe('widgets/Search/components/SearchFiltersPane', () => {
|
|
|
87
89
|
<SearchFiltersPane filters={null} />
|
|
88
90
|
</HistoryContext.Provider>
|
|
89
91
|
</IntlProvider>,
|
|
92
|
+
{ wrapper: null },
|
|
90
93
|
);
|
|
91
94
|
getByText('Filter courses');
|
|
92
95
|
});
|
|
@@ -140,6 +143,7 @@ describe('widgets/Search/components/SearchFiltersPane', () => {
|
|
|
140
143
|
/>
|
|
141
144
|
</HistoryContext.Provider>
|
|
142
145
|
</IntlProvider>,
|
|
146
|
+
{ wrapper: null },
|
|
143
147
|
);
|
|
144
148
|
|
|
145
149
|
const clearButton = getByText('Clear 2 active filters');
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { act, renderHook, waitFor } from '@testing-library/react';
|
|
2
|
-
import { PropsWithChildren } from 'react';
|
|
3
|
-
import { IntlProvider } from 'react-intl';
|
|
4
|
-
import { QueryClientProvider } from '@tanstack/react-query';
|
|
5
2
|
|
|
3
|
+
import { PropsWithChildren } from 'react';
|
|
6
4
|
import { APIListRequestParams } from 'types/api';
|
|
7
5
|
import { Deferred } from 'utils/test/deferred';
|
|
8
|
-
import {
|
|
6
|
+
import { ReactQueryAppWrapper } from 'utils/test/wrappers/ReactQueryAppWrapper';
|
|
9
7
|
import { fetchList } from '../../utils/getResourceList';
|
|
10
8
|
import { useCourseSearch } from '.';
|
|
11
9
|
|
|
@@ -17,16 +15,10 @@ const mockFetchList = fetchList as jest.MockedFunction<typeof fetchList>;
|
|
|
17
15
|
|
|
18
16
|
describe('widgets/Search/hooks/useCourseSearch', () => {
|
|
19
17
|
let locale: string;
|
|
20
|
-
const wrapper = ({ children }: PropsWithChildren
|
|
21
|
-
<
|
|
22
|
-
<QueryClientProvider client={createTestQueryClient()}>{children}</QueryClientProvider>
|
|
23
|
-
</IntlProvider>
|
|
18
|
+
const wrapper = ({ children }: PropsWithChildren) => (
|
|
19
|
+
<ReactQueryAppWrapper intlOptions={{ locale }}>{children}</ReactQueryAppWrapper>
|
|
24
20
|
);
|
|
25
21
|
|
|
26
|
-
afterEach(() => {
|
|
27
|
-
jest.resetAllMocks();
|
|
28
|
-
});
|
|
29
|
-
|
|
30
22
|
it('gets the courses with the passed params', async () => {
|
|
31
23
|
const deferred = new Deferred<any>();
|
|
32
24
|
let params: APIListRequestParams = { limit: '999', offset: '0' };
|
|
@@ -24,8 +24,6 @@ describe('widgets/Search/hooks/useFilterValue', () => {
|
|
|
24
24
|
<HistoryContext.Provider value={history}>{children}</HistoryContext.Provider>
|
|
25
25
|
);
|
|
26
26
|
|
|
27
|
-
beforeEach(jest.resetAllMocks);
|
|
28
|
-
|
|
29
27
|
it('returns the active [false] status of the filter value and a function to toggle it', () => {
|
|
30
28
|
const props: [FacetedFilterDefinition, FilterValue] = [
|
|
31
29
|
// filter: FacetedFilterDefinition
|