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,8 +1,5 @@
|
|
|
1
|
-
import { getByText,
|
|
1
|
+
import { getByText, screen, waitFor } from '@testing-library/react';
|
|
2
2
|
import fetchMock from 'fetch-mock';
|
|
3
|
-
import type { PropsWithChildren } from 'react';
|
|
4
|
-
import { IntlProvider } from 'react-intl';
|
|
5
|
-
import { QueryClientProvider } from '@tanstack/react-query';
|
|
6
3
|
import queryString from 'query-string';
|
|
7
4
|
import { RichieContextFactory as mockRichieContextFactory } from 'utils/test/factories/richie';
|
|
8
5
|
import {
|
|
@@ -14,7 +11,6 @@ import {
|
|
|
14
11
|
OrderGroupFullFactory,
|
|
15
12
|
OrderGroupFactory,
|
|
16
13
|
} from 'utils/test/factories/joanie';
|
|
17
|
-
import JoanieApiProvider from 'contexts/JoanieApiContext';
|
|
18
14
|
import {
|
|
19
15
|
CourseRun,
|
|
20
16
|
Enrollment,
|
|
@@ -24,16 +20,17 @@ import {
|
|
|
24
20
|
} from 'types/Joanie';
|
|
25
21
|
import { createTestQueryClient } from 'utils/test/createTestQueryClient';
|
|
26
22
|
import { Deferred } from 'utils/test/deferred';
|
|
27
|
-
import JoanieSessionProvider from 'contexts/SessionContext/JoanieSessionProvider';
|
|
28
23
|
import { HttpStatusCode } from 'utils/errors/HttpError';
|
|
29
24
|
import { expectNoSpinner, expectSpinner } from 'utils/test/expectSpinner';
|
|
25
|
+
import { setupJoanieSession } from 'utils/test/wrappers/JoanieAppWrapper';
|
|
26
|
+
import { render } from 'utils/test/render';
|
|
30
27
|
import CourseProductItem from '.';
|
|
31
28
|
|
|
32
29
|
jest.mock('utils/context', () => ({
|
|
33
30
|
__esModule: true,
|
|
34
31
|
default: mockRichieContextFactory({
|
|
35
32
|
authentication: { backend: 'fonzie', endpoint: 'https://auth.test' },
|
|
36
|
-
joanie_backend: { endpoint: 'https://joanie.
|
|
33
|
+
joanie_backend: { endpoint: 'https://joanie.endpoint' },
|
|
37
34
|
}).one(),
|
|
38
35
|
}));
|
|
39
36
|
|
|
@@ -65,49 +62,29 @@ jest.mock('./components/CourseProductCourseRuns', () => ({
|
|
|
65
62
|
}));
|
|
66
63
|
|
|
67
64
|
describe('CourseProductItem', () => {
|
|
65
|
+
setupJoanieSession();
|
|
66
|
+
|
|
68
67
|
const priceFormatter = (currency: string, price: number) =>
|
|
69
68
|
new Intl.NumberFormat('en', {
|
|
70
69
|
currency,
|
|
71
70
|
style: 'currency',
|
|
72
71
|
}).format(price);
|
|
73
72
|
|
|
74
|
-
beforeEach(() => {
|
|
75
|
-
// JoanieSessionProvider requests
|
|
76
|
-
fetchMock.get('https://joanie.test/api/v1.0/addresses/', []);
|
|
77
|
-
fetchMock.get('https://joanie.test/api/v1.0/credit-cards/', []);
|
|
78
|
-
fetchMock.get('https://joanie.test/api/v1.0/orders/', []);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
afterEach(() => {
|
|
82
|
-
fetchMock.restore();
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
const Wrapper = ({ withSession, children }: PropsWithChildren<{ withSession?: boolean }>) => (
|
|
86
|
-
<IntlProvider locale="en">
|
|
87
|
-
<JoanieApiProvider>
|
|
88
|
-
<QueryClientProvider client={createTestQueryClient({ user: withSession || null })}>
|
|
89
|
-
<JoanieSessionProvider>{children}</JoanieSessionProvider>
|
|
90
|
-
</QueryClientProvider>
|
|
91
|
-
</JoanieApiProvider>
|
|
92
|
-
</IntlProvider>
|
|
93
|
-
);
|
|
94
|
-
|
|
95
73
|
it('should display a loader until product is loaded', async () => {
|
|
96
74
|
const relation = CourseProductRelationFactory().one();
|
|
97
75
|
const { product } = relation;
|
|
98
76
|
const productDeferred = new Deferred();
|
|
99
77
|
fetchMock.get(
|
|
100
|
-
`https://joanie.
|
|
78
|
+
`https://joanie.endpoint/api/v1.0/courses/00000/products/${product.id}/`,
|
|
101
79
|
productDeferred.promise,
|
|
102
80
|
);
|
|
103
81
|
|
|
104
82
|
render(
|
|
105
|
-
<
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
</Wrapper>,
|
|
83
|
+
<CourseProductItem
|
|
84
|
+
course={CourseLightFactory({ code: '00000' }).one()}
|
|
85
|
+
productId={product.id}
|
|
86
|
+
/>,
|
|
87
|
+
{ queryOptions: { client: createTestQueryClient({ user: null }) } },
|
|
111
88
|
);
|
|
112
89
|
|
|
113
90
|
// - A loader should be displayed while product information are fetching
|
|
@@ -119,15 +96,17 @@ describe('CourseProductItem', () => {
|
|
|
119
96
|
it('renders product information for anonymous user', async () => {
|
|
120
97
|
const relation = CourseProductRelationFactory().one();
|
|
121
98
|
const { product } = relation;
|
|
122
|
-
fetchMock.get(
|
|
99
|
+
fetchMock.get(
|
|
100
|
+
`https://joanie.endpoint/api/v1.0/courses/00000/products/${product.id}/`,
|
|
101
|
+
relation,
|
|
102
|
+
);
|
|
123
103
|
|
|
124
104
|
render(
|
|
125
|
-
<
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
</Wrapper>,
|
|
105
|
+
<CourseProductItem
|
|
106
|
+
course={CourseLightFactory({ code: '00000' }).one()}
|
|
107
|
+
productId={product.id}
|
|
108
|
+
/>,
|
|
109
|
+
{ queryOptions: { client: createTestQueryClient({ user: null }) } },
|
|
131
110
|
);
|
|
132
111
|
|
|
133
112
|
await screen.findByRole('heading', { level: 3, name: product.title });
|
|
@@ -175,15 +154,17 @@ describe('CourseProductItem', () => {
|
|
|
175
154
|
}).one(),
|
|
176
155
|
}).one();
|
|
177
156
|
const { product } = relation;
|
|
178
|
-
fetchMock.get(
|
|
157
|
+
fetchMock.get(
|
|
158
|
+
`https://joanie.endpoint/api/v1.0/courses/00000/products/${product.id}/`,
|
|
159
|
+
relation,
|
|
160
|
+
);
|
|
179
161
|
|
|
180
162
|
render(
|
|
181
|
-
<
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
</Wrapper>,
|
|
163
|
+
<CourseProductItem
|
|
164
|
+
productId={product.id}
|
|
165
|
+
course={CourseLightFactory({ code: '00000' }).one()}
|
|
166
|
+
/>,
|
|
167
|
+
{ queryOptions: { client: createTestQueryClient({ user: null }) } },
|
|
187
168
|
);
|
|
188
169
|
|
|
189
170
|
// Wait for product information to be fetched
|
|
@@ -196,18 +177,17 @@ describe('CourseProductItem', () => {
|
|
|
196
177
|
it('renders product informations in compact mode', async () => {
|
|
197
178
|
const relation = CourseProductRelationFactory().one();
|
|
198
179
|
fetchMock.get(
|
|
199
|
-
`https://joanie.
|
|
180
|
+
`https://joanie.endpoint/api/v1.0/courses/00000/products/${relation.product.id}/`,
|
|
200
181
|
relation,
|
|
201
182
|
);
|
|
202
183
|
|
|
203
184
|
const { container } = render(
|
|
204
|
-
<
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
</Wrapper>,
|
|
185
|
+
<CourseProductItem
|
|
186
|
+
course={CourseLightFactory({ code: '00000' }).one()}
|
|
187
|
+
productId={relation.product.id}
|
|
188
|
+
compact
|
|
189
|
+
/>,
|
|
190
|
+
{ queryOptions: { client: createTestQueryClient({ user: null }) } },
|
|
211
191
|
);
|
|
212
192
|
|
|
213
193
|
// In the header, we should display the product title, the product price
|
|
@@ -258,24 +238,25 @@ describe('CourseProductItem', () => {
|
|
|
258
238
|
target_courses: product.target_courses,
|
|
259
239
|
}).one();
|
|
260
240
|
|
|
261
|
-
fetchMock.get(
|
|
241
|
+
fetchMock.get(
|
|
242
|
+
`https://joanie.endpoint/api/v1.0/courses/00000/products/${product.id}/`,
|
|
243
|
+
relation,
|
|
244
|
+
);
|
|
262
245
|
const orderQueryParameters = {
|
|
263
246
|
product_id: order.product_id,
|
|
264
247
|
course_code: order.course.code,
|
|
265
248
|
state: ACTIVE_ORDER_STATES,
|
|
266
249
|
};
|
|
267
250
|
fetchMock.get(
|
|
268
|
-
`https://joanie.
|
|
251
|
+
`https://joanie.endpoint/api/v1.0/orders/?${queryString.stringify(orderQueryParameters)}`,
|
|
269
252
|
[order],
|
|
270
253
|
);
|
|
271
254
|
|
|
272
255
|
render(
|
|
273
|
-
<
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
/>
|
|
278
|
-
</Wrapper>,
|
|
256
|
+
<CourseProductItem
|
|
257
|
+
productId={product.id}
|
|
258
|
+
course={CourseLightFactory({ code: '00000' }).one()}
|
|
259
|
+
/>,
|
|
279
260
|
);
|
|
280
261
|
|
|
281
262
|
// Wait for product information to be fetched
|
|
@@ -317,7 +298,7 @@ describe('CourseProductItem', () => {
|
|
|
317
298
|
}).one();
|
|
318
299
|
|
|
319
300
|
fetchMock.get(
|
|
320
|
-
`https://joanie.
|
|
301
|
+
`https://joanie.endpoint/api/v1.0/courses/00000/products/${relation.product.id}/`,
|
|
321
302
|
relation,
|
|
322
303
|
);
|
|
323
304
|
const orderQueryParameters = {
|
|
@@ -326,18 +307,16 @@ describe('CourseProductItem', () => {
|
|
|
326
307
|
state: ACTIVE_ORDER_STATES,
|
|
327
308
|
};
|
|
328
309
|
fetchMock.get(
|
|
329
|
-
`https://joanie.
|
|
310
|
+
`https://joanie.endpoint/api/v1.0/orders/?${queryString.stringify(orderQueryParameters)}`,
|
|
330
311
|
[order],
|
|
331
312
|
);
|
|
332
313
|
|
|
333
314
|
render(
|
|
334
|
-
<
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
/>
|
|
340
|
-
</Wrapper>,
|
|
315
|
+
<CourseProductItem
|
|
316
|
+
productId={relation.product.id}
|
|
317
|
+
course={CourseLightFactory({ code: '00000' }).one()}
|
|
318
|
+
compact
|
|
319
|
+
/>,
|
|
341
320
|
);
|
|
342
321
|
|
|
343
322
|
// Wait for product information to be fetched
|
|
@@ -390,24 +369,25 @@ describe('CourseProductItem', () => {
|
|
|
390
369
|
target_enrollments: [enrollment],
|
|
391
370
|
}).one();
|
|
392
371
|
|
|
393
|
-
fetchMock.get(
|
|
372
|
+
fetchMock.get(
|
|
373
|
+
`https://joanie.endpoint/api/v1.0/courses/00000/products/${product.id}/`,
|
|
374
|
+
relation,
|
|
375
|
+
);
|
|
394
376
|
const orderQueryParameters = {
|
|
395
377
|
product_id: order.product_id,
|
|
396
378
|
course_code: order.course?.code,
|
|
397
379
|
state: ACTIVE_ORDER_STATES,
|
|
398
380
|
};
|
|
399
381
|
fetchMock.get(
|
|
400
|
-
`https://joanie.
|
|
382
|
+
`https://joanie.endpoint/api/v1.0/orders/?${queryString.stringify(orderQueryParameters)}`,
|
|
401
383
|
[order],
|
|
402
384
|
);
|
|
403
385
|
|
|
404
386
|
render(
|
|
405
|
-
<
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
/>
|
|
410
|
-
</Wrapper>,
|
|
387
|
+
<CourseProductItem
|
|
388
|
+
productId={product.id}
|
|
389
|
+
course={CourseLightFactory({ code: '00000' }).one()}
|
|
390
|
+
/>,
|
|
411
391
|
);
|
|
412
392
|
|
|
413
393
|
// Wait for product information to be fetched
|
|
@@ -449,24 +429,25 @@ describe('CourseProductItem', () => {
|
|
|
449
429
|
target_courses: product.target_courses,
|
|
450
430
|
state: OrderState.PENDING,
|
|
451
431
|
}).one();
|
|
452
|
-
fetchMock.get(
|
|
432
|
+
fetchMock.get(
|
|
433
|
+
`https://joanie.endpoint/api/v1.0/courses/00000/products/${product.id}/`,
|
|
434
|
+
relation,
|
|
435
|
+
);
|
|
453
436
|
const orderQueryParameters = {
|
|
454
437
|
product_id: order.product_id,
|
|
455
438
|
course_code: order.course?.code,
|
|
456
439
|
state: ACTIVE_ORDER_STATES,
|
|
457
440
|
};
|
|
458
441
|
fetchMock.get(
|
|
459
|
-
`https://joanie.
|
|
442
|
+
`https://joanie.endpoint/api/v1.0/orders/?${queryString.stringify(orderQueryParameters)}`,
|
|
460
443
|
[order],
|
|
461
444
|
);
|
|
462
445
|
|
|
463
446
|
render(
|
|
464
|
-
<
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
/>
|
|
469
|
-
</Wrapper>,
|
|
447
|
+
<CourseProductItem
|
|
448
|
+
productId={product.id}
|
|
449
|
+
course={CourseLightFactory({ code: '00000' }).one()}
|
|
450
|
+
/>,
|
|
470
451
|
);
|
|
471
452
|
|
|
472
453
|
// Wait for product information to be fetched
|
|
@@ -497,24 +478,25 @@ describe('CourseProductItem', () => {
|
|
|
497
478
|
it('renders sale tunnel button if user already has a canceled order', async () => {
|
|
498
479
|
const relation = CourseProductRelationFactory().one();
|
|
499
480
|
const { product } = relation;
|
|
500
|
-
fetchMock.get(
|
|
481
|
+
fetchMock.get(
|
|
482
|
+
`https://joanie.endpoint/api/v1.0/courses/00000/products/${product.id}/`,
|
|
483
|
+
relation,
|
|
484
|
+
);
|
|
501
485
|
const orderQueryParameters = {
|
|
502
486
|
product_id: product.id,
|
|
503
487
|
course_code: '00000',
|
|
504
488
|
state: ACTIVE_ORDER_STATES,
|
|
505
489
|
};
|
|
506
490
|
fetchMock.get(
|
|
507
|
-
`https://joanie.
|
|
491
|
+
`https://joanie.endpoint/api/v1.0/orders/?${queryString.stringify(orderQueryParameters)}`,
|
|
508
492
|
[],
|
|
509
493
|
);
|
|
510
494
|
|
|
511
495
|
render(
|
|
512
|
-
<
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
/>
|
|
517
|
-
</Wrapper>,
|
|
496
|
+
<CourseProductItem
|
|
497
|
+
productId={product.id}
|
|
498
|
+
course={CourseLightFactory({ code: '00000' }).one()}
|
|
499
|
+
/>,
|
|
518
500
|
);
|
|
519
501
|
|
|
520
502
|
// Wait for product information to be fetched
|
|
@@ -551,24 +533,25 @@ describe('CourseProductItem', () => {
|
|
|
551
533
|
target_courses: product.target_courses,
|
|
552
534
|
state: OrderState.SUBMITTED,
|
|
553
535
|
}).one();
|
|
554
|
-
fetchMock.get(
|
|
536
|
+
fetchMock.get(
|
|
537
|
+
`https://joanie.endpoint/api/v1.0/courses/00000/products/${product.id}/`,
|
|
538
|
+
relation,
|
|
539
|
+
);
|
|
555
540
|
const orderQueryParameters = {
|
|
556
541
|
product_id: order.product_id,
|
|
557
542
|
course_code: order.course?.code,
|
|
558
543
|
state: ACTIVE_ORDER_STATES,
|
|
559
544
|
};
|
|
560
545
|
fetchMock.get(
|
|
561
|
-
`https://joanie.
|
|
546
|
+
`https://joanie.endpoint/api/v1.0/orders/?${queryString.stringify(orderQueryParameters)}`,
|
|
562
547
|
[order],
|
|
563
548
|
);
|
|
564
549
|
|
|
565
550
|
render(
|
|
566
|
-
<
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
/>
|
|
571
|
-
</Wrapper>,
|
|
551
|
+
<CourseProductItem
|
|
552
|
+
productId={product.id}
|
|
553
|
+
course={CourseLightFactory({ code: '00000' }).one()}
|
|
554
|
+
/>,
|
|
572
555
|
);
|
|
573
556
|
|
|
574
557
|
// Wait for product information to be fetched
|
|
@@ -620,7 +603,10 @@ describe('CourseProductItem', () => {
|
|
|
620
603
|
course: CourseLightFactory({ code: '00000' }).one(),
|
|
621
604
|
state: orderState,
|
|
622
605
|
}).one();
|
|
623
|
-
fetchMock.get(
|
|
606
|
+
fetchMock.get(
|
|
607
|
+
`https://joanie.endpoint/api/v1.0/courses/00000/products/${product.id}/`,
|
|
608
|
+
relation,
|
|
609
|
+
);
|
|
624
610
|
const orderQueryParameters = {
|
|
625
611
|
product_id: order.product_id,
|
|
626
612
|
course_code: order.course.code,
|
|
@@ -628,17 +614,15 @@ describe('CourseProductItem', () => {
|
|
|
628
614
|
};
|
|
629
615
|
|
|
630
616
|
fetchMock.get(
|
|
631
|
-
`https://joanie.
|
|
617
|
+
`https://joanie.endpoint/api/v1.0/orders/?${queryString.stringify(orderQueryParameters)}`,
|
|
632
618
|
[order],
|
|
633
619
|
);
|
|
634
620
|
|
|
635
621
|
render(
|
|
636
|
-
<
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
/>
|
|
641
|
-
</Wrapper>,
|
|
622
|
+
<CourseProductItem
|
|
623
|
+
productId={product.id}
|
|
624
|
+
course={CourseLightFactory({ code: '00000' }).one()}
|
|
625
|
+
/>,
|
|
642
626
|
);
|
|
643
627
|
|
|
644
628
|
// Wait for product information to be fetched
|
|
@@ -668,7 +652,10 @@ describe('CourseProductItem', () => {
|
|
|
668
652
|
course: CourseLightFactory({ code: '00000' }).one(),
|
|
669
653
|
state: OrderState.VALIDATED,
|
|
670
654
|
}).one();
|
|
671
|
-
fetchMock.get(
|
|
655
|
+
fetchMock.get(
|
|
656
|
+
`https://joanie.endpoint/api/v1.0/courses/00000/products/${product.id}/`,
|
|
657
|
+
relation,
|
|
658
|
+
);
|
|
672
659
|
const orderQueryParameters = {
|
|
673
660
|
product_id: order.product_id,
|
|
674
661
|
course_code: order.course.code,
|
|
@@ -676,17 +663,15 @@ describe('CourseProductItem', () => {
|
|
|
676
663
|
};
|
|
677
664
|
|
|
678
665
|
fetchMock.get(
|
|
679
|
-
`https://joanie.
|
|
666
|
+
`https://joanie.endpoint/api/v1.0/orders/?${queryString.stringify(orderQueryParameters)}`,
|
|
680
667
|
[order],
|
|
681
668
|
);
|
|
682
669
|
|
|
683
670
|
render(
|
|
684
|
-
<
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
/>
|
|
689
|
-
</Wrapper>,
|
|
671
|
+
<CourseProductItem
|
|
672
|
+
productId={product.id}
|
|
673
|
+
course={CourseLightFactory({ code: '00000' }).one()}
|
|
674
|
+
/>,
|
|
690
675
|
);
|
|
691
676
|
|
|
692
677
|
// Wait for product information to be fetched
|
|
@@ -706,7 +691,7 @@ describe('CourseProductItem', () => {
|
|
|
706
691
|
state: OrderState.SUBMITTED,
|
|
707
692
|
}).one();
|
|
708
693
|
fetchMock.get(
|
|
709
|
-
`https://joanie.
|
|
694
|
+
`https://joanie.endpoint/api/v1.0/courses/00000/products/${relation.product.id}/`,
|
|
710
695
|
relation,
|
|
711
696
|
);
|
|
712
697
|
const orderQueryParameters = {
|
|
@@ -715,18 +700,16 @@ describe('CourseProductItem', () => {
|
|
|
715
700
|
state: ACTIVE_ORDER_STATES,
|
|
716
701
|
};
|
|
717
702
|
fetchMock.get(
|
|
718
|
-
`https://joanie.
|
|
703
|
+
`https://joanie.endpoint/api/v1.0/orders/?${queryString.stringify(orderQueryParameters)}`,
|
|
719
704
|
[order],
|
|
720
705
|
);
|
|
721
706
|
|
|
722
707
|
render(
|
|
723
|
-
<
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
/>
|
|
729
|
-
</Wrapper>,
|
|
708
|
+
<CourseProductItem
|
|
709
|
+
productId={relation.product.id}
|
|
710
|
+
course={CourseLightFactory({ code: '00000' }).one()}
|
|
711
|
+
compact={true}
|
|
712
|
+
/>,
|
|
730
713
|
);
|
|
731
714
|
|
|
732
715
|
// Wait for product information to be fetched
|
|
@@ -760,18 +743,17 @@ describe('CourseProductItem', () => {
|
|
|
760
743
|
const { product } = CourseProductRelationFactory().one();
|
|
761
744
|
|
|
762
745
|
fetchMock.get(
|
|
763
|
-
`https://joanie.
|
|
746
|
+
`https://joanie.endpoint/api/v1.0/courses/00000/products/${product.id}/`,
|
|
764
747
|
HttpStatusCode.NOT_FOUND,
|
|
765
748
|
{},
|
|
766
749
|
);
|
|
767
750
|
|
|
768
751
|
render(
|
|
769
|
-
<
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
</Wrapper>,
|
|
752
|
+
<CourseProductItem
|
|
753
|
+
productId={product.id}
|
|
754
|
+
course={CourseLightFactory({ code: '00000' }).one()}
|
|
755
|
+
/>,
|
|
756
|
+
{ queryOptions: { client: createTestQueryClient({ user: null }) } },
|
|
775
757
|
);
|
|
776
758
|
|
|
777
759
|
// - As product fetching has failed, an error message should be displayed
|
|
@@ -789,24 +771,25 @@ describe('CourseProductItem', () => {
|
|
|
789
771
|
target_courses: product.target_courses,
|
|
790
772
|
state: OrderState.PENDING,
|
|
791
773
|
}).one();
|
|
792
|
-
fetchMock.get(
|
|
774
|
+
fetchMock.get(
|
|
775
|
+
`https://joanie.endpoint/api/v1.0/courses/00000/products/${product.id}/`,
|
|
776
|
+
relation,
|
|
777
|
+
);
|
|
793
778
|
const orderQueryParameters = {
|
|
794
779
|
product_id: order.product_id,
|
|
795
780
|
course_code: order.course?.code,
|
|
796
781
|
state: ACTIVE_ORDER_STATES,
|
|
797
782
|
};
|
|
798
783
|
fetchMock.get(
|
|
799
|
-
`https://joanie.
|
|
784
|
+
`https://joanie.endpoint/api/v1.0/orders/?${queryString.stringify(orderQueryParameters)}`,
|
|
800
785
|
[order],
|
|
801
786
|
);
|
|
802
787
|
|
|
803
788
|
render(
|
|
804
|
-
<
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
/>
|
|
809
|
-
</Wrapper>,
|
|
789
|
+
<CourseProductItem
|
|
790
|
+
productId={product.id}
|
|
791
|
+
course={CourseLightFactory({ code: '00000' }).one()}
|
|
792
|
+
/>,
|
|
810
793
|
);
|
|
811
794
|
|
|
812
795
|
// wait for component to be fully loaded
|
|
@@ -827,24 +810,25 @@ describe('CourseProductItem', () => {
|
|
|
827
810
|
target_courses: product.target_courses,
|
|
828
811
|
state: OrderState.PENDING,
|
|
829
812
|
}).one();
|
|
830
|
-
fetchMock.get(
|
|
813
|
+
fetchMock.get(
|
|
814
|
+
`https://joanie.endpoint/api/v1.0/courses/00000/products/${product.id}/`,
|
|
815
|
+
relation,
|
|
816
|
+
);
|
|
831
817
|
const orderQueryParameters = {
|
|
832
818
|
product_id: order.product_id,
|
|
833
819
|
course_code: order.course?.code,
|
|
834
820
|
state: ACTIVE_ORDER_STATES,
|
|
835
821
|
};
|
|
836
822
|
fetchMock.get(
|
|
837
|
-
`https://joanie.
|
|
823
|
+
`https://joanie.endpoint/api/v1.0/orders/?${queryString.stringify(orderQueryParameters)}`,
|
|
838
824
|
[order],
|
|
839
825
|
);
|
|
840
826
|
|
|
841
827
|
render(
|
|
842
|
-
<
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
/>
|
|
847
|
-
</Wrapper>,
|
|
828
|
+
<CourseProductItem
|
|
829
|
+
productId={product.id}
|
|
830
|
+
course={CourseLightFactory({ code: '00000' }).one()}
|
|
831
|
+
/>,
|
|
848
832
|
);
|
|
849
833
|
|
|
850
834
|
// wait for component to be fully loaded
|
|
@@ -866,24 +850,25 @@ describe('CourseProductItem', () => {
|
|
|
866
850
|
target_courses: product.target_courses,
|
|
867
851
|
state: OrderState.PENDING,
|
|
868
852
|
}).one();
|
|
869
|
-
fetchMock.get(
|
|
853
|
+
fetchMock.get(
|
|
854
|
+
`https://joanie.endpoint/api/v1.0/courses/00000/products/${product.id}/`,
|
|
855
|
+
relation,
|
|
856
|
+
);
|
|
870
857
|
const orderQueryParameters = {
|
|
871
858
|
product_id: order.product_id,
|
|
872
859
|
course_code: order.course?.code,
|
|
873
860
|
state: ACTIVE_ORDER_STATES,
|
|
874
861
|
};
|
|
875
862
|
fetchMock.get(
|
|
876
|
-
`https://joanie.
|
|
863
|
+
`https://joanie.endpoint/api/v1.0/orders/?${queryString.stringify(orderQueryParameters)}`,
|
|
877
864
|
[order],
|
|
878
865
|
);
|
|
879
866
|
|
|
880
867
|
render(
|
|
881
|
-
<
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
/>
|
|
886
|
-
</Wrapper>,
|
|
868
|
+
<CourseProductItem
|
|
869
|
+
productId={product.id}
|
|
870
|
+
course={CourseLightFactory({ code: '00000' }).one()}
|
|
871
|
+
/>,
|
|
887
872
|
);
|
|
888
873
|
|
|
889
874
|
// wait for component to be fully loaded
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { screen } from '@testing-library/react';
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
2
3
|
import { IntlProvider } from 'react-intl';
|
|
4
|
+
import { render } from 'utils/test/render';
|
|
3
5
|
import { CourseRunUnenrollButton } from 'widgets/SyllabusCourseRunsList/components/CourseRunEnrollment/CourseRunUnenrollmentButton/index';
|
|
4
6
|
|
|
5
7
|
describe('CourseRunUnenrollmentButton', () => {
|
|
@@ -9,12 +11,12 @@ describe('CourseRunUnenrollmentButton', () => {
|
|
|
9
11
|
<IntlProvider locale="en">
|
|
10
12
|
<CourseRunUnenrollButton onUnenroll={unenroll} />
|
|
11
13
|
</IntlProvider>,
|
|
14
|
+
{ wrapper: null },
|
|
12
15
|
);
|
|
13
16
|
|
|
14
17
|
const button = await screen.findByRole('button', { name: 'Unenroll from this course' });
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
});
|
|
18
|
+
const user = userEvent.setup();
|
|
19
|
+
await user.click(button);
|
|
18
20
|
|
|
19
21
|
expect(unenroll).toHaveBeenCalledTimes(1);
|
|
20
22
|
});
|