richie-education 2.29.2 → 2.29.3-dev48
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/i18n/locales/ar-SA.json +193 -125
- package/i18n/locales/es-ES.json +193 -125
- package/i18n/locales/fa-IR.json +193 -125
- package/i18n/locales/fr-CA.json +193 -125
- package/i18n/locales/fr-FR.json +193 -125
- package/i18n/locales/ko-KR.json +193 -125
- package/i18n/locales/pt-PT.json +193 -125
- package/i18n/locales/ru-RU.json +193 -125
- package/i18n/locales/vi-VN.json +193 -125
- package/js/api/joanie.ts +42 -17
- package/js/api/lms/dummy.ts +1 -12
- package/js/components/ContractFrame/AbstractContractFrame.spec.tsx +16 -9
- package/js/components/ContractFrame/AbstractContractFrame.tsx +28 -23
- package/js/components/ContractFrame/LearnerContractFrame.tsx +2 -2
- package/js/components/ContractFrame/_styles.scss +6 -14
- package/js/components/ContractStatus/index.spec.tsx +1 -1
- package/js/components/ContractStatus/index.tsx +1 -1
- package/js/components/{SaleTunnel/CreditCardSelector → CreditCardSelector}/index.spec.tsx +15 -45
- package/js/components/{SaleTunnel/CreditCardSelector → CreditCardSelector}/index.tsx +19 -26
- package/js/components/DownloadContractButton/index.spec.tsx +1 -1
- package/js/components/Form/utils.ts +2 -1
- package/js/components/OpenEdxFullNameForm/index.spec.tsx +229 -0
- package/js/components/OpenEdxFullNameForm/index.tsx +7 -7
- package/js/components/PaymentInterfaces/LyraPopIn.tsx +2 -2
- package/js/components/PaymentInterfaces/PayplugLightbox.tsx +1 -1
- package/js/components/PaymentInterfaces/__mocks__/index.tsx +1 -4
- package/js/components/PaymentInterfaces/types.ts +5 -2
- package/js/components/PaymentScheduleGrid/_styles.scss +13 -0
- package/js/components/PaymentScheduleGrid/index.tsx +50 -70
- package/js/components/PurchaseButton/index.spec.tsx +84 -37
- package/js/components/PurchaseButton/index.tsx +9 -27
- package/js/components/SaleTunnel/AddressSelector/index.spec.tsx +2 -2
- package/js/components/SaleTunnel/CertificateSaleTunnel/index.tsx +2 -2
- package/js/components/SaleTunnel/CredentialSaleTunnel/index.tsx +6 -10
- package/js/components/SaleTunnel/GenericSaleTunnel.tsx +105 -48
- package/js/components/SaleTunnel/SaleTunnelInformation/index.tsx +16 -20
- package/js/components/SaleTunnel/SaleTunnelSavePaymentMethod/_styles.scss +12 -0
- package/js/components/SaleTunnel/SaleTunnelSavePaymentMethod/index.tsx +157 -0
- package/js/components/SaleTunnel/SaleTunnelSuccess/index.tsx +15 -29
- package/js/components/SaleTunnel/Sponsors/SaleTunnelSponsors.scss +4 -5
- package/js/components/SaleTunnel/Sponsors/SaleTunnelSponsors.tsx +39 -11
- package/js/components/SaleTunnel/SubscriptionButton/_styles.scss +7 -0
- package/js/components/SaleTunnel/SubscriptionButton/index.tsx +202 -0
- package/js/components/SaleTunnel/_styles.scss +16 -5
- package/js/components/SaleTunnel/hooks/useTerms.tsx +0 -77
- package/js/components/SaleTunnel/index.credential.spec.tsx +14 -25
- package/js/components/SaleTunnel/index.full-process.spec.tsx +114 -48
- package/js/components/SaleTunnel/index.spec.tsx +333 -717
- package/js/components/SaleTunnel/index.tsx +2 -1
- package/js/components/SignContractButton/index.omniscientOrders.spec.tsx +16 -11
- package/js/components/SignContractButton/index.spec.tsx +16 -20
- package/js/components/SignContractButton/index.tsx +3 -1
- package/js/hooks/useCreditCards/index.spec.tsx +70 -6
- package/js/hooks/useCreditCards/index.ts +49 -11
- package/js/hooks/useOrders/index.spec.tsx +322 -0
- package/js/hooks/{useOrders.ts → useOrders/index.ts} +40 -14
- package/js/hooks/usePaymentSchedule.tsx +23 -0
- package/js/hooks/useProductOrder/index.spec.tsx +77 -60
- package/js/hooks/useProductOrder/index.tsx +2 -2
- package/js/hooks/useResources/useResourcesRoot.ts +4 -3
- package/js/index.tsx +2 -0
- package/js/pages/DashboardCreditCardsManagement/CreditCardBrandLogo.spec.tsx +1 -1
- package/js/pages/DashboardCreditCardsManagement/CreditCardBrandLogo.tsx +4 -2
- package/js/pages/DashboardOrderLayout/index.spec.tsx +10 -1
- package/js/pages/TeacherDashboardContractsLayout/components/ContractActionsBar/index.spec.tsx +8 -5
- package/js/pages/TeacherDashboardContractsLayout/components/SignOrganizationContractButton/index.spec.tsx +8 -9
- package/js/pages/TeacherDashboardCourseLearnersLayout/components/CourseLearnerDataGrid/index.spec.tsx +1 -1
- package/js/pages/TeacherDashboardCourseLearnersLayout/components/CourseLearnerDataGrid/index.tsx +1 -6
- package/js/settings/settings.prod.ts +0 -2
- package/js/settings/settings.test.ts +16 -2
- package/js/translations/ar-SA.json +1 -1
- package/js/translations/es-ES.json +1 -1
- package/js/translations/fa-IR.json +1 -1
- package/js/translations/fr-CA.json +1 -1
- package/js/translations/fr-FR.json +1 -1
- package/js/translations/ko-KR.json +1 -1
- package/js/translations/pt-PT.json +1 -1
- package/js/translations/ru-RU.json +1 -1
- package/js/translations/vi-VN.json +1 -1
- package/js/types/Joanie.ts +81 -32
- package/js/utils/OrderHelper/index.ts +46 -38
- package/js/utils/PaymentScheduleHelper/index.spec.tsx +78 -0
- package/js/utils/PaymentScheduleHelper/index.ts +30 -0
- package/js/utils/ProductHelper/index.spec.ts +322 -166
- package/js/utils/ProductHelper/index.ts +32 -0
- package/js/utils/test/factories/joanie.ts +72 -69
- package/js/widgets/Dashboard/components/DashboardItem/Contract/index.spec.tsx +2 -2
- package/js/widgets/Dashboard/components/DashboardItem/CourseEnrolling/index.tsx +8 -18
- package/js/widgets/Dashboard/components/DashboardItem/Enrollment/DashboardItemEnrollment.spec.tsx +23 -0
- package/js/widgets/Dashboard/components/DashboardItem/Enrollment/DashboardItemEnrollment.tsx +23 -1
- package/js/widgets/Dashboard/components/DashboardItem/Enrollment/ProductCertificateFooter/index.spec.tsx +145 -34
- package/js/widgets/Dashboard/components/DashboardItem/Enrollment/ProductCertificateFooter/index.tsx +175 -37
- package/js/widgets/Dashboard/components/DashboardItem/Order/CertificateItem/index.tsx +51 -0
- package/js/widgets/Dashboard/components/DashboardItem/Order/ContractItem/index.tsx +52 -0
- package/js/widgets/Dashboard/components/DashboardItem/Order/DashboardItemNotResumable.spec.tsx +109 -0
- package/js/widgets/Dashboard/components/DashboardItem/Order/DashboardItemOrder.spec.tsx +219 -5
- package/js/widgets/Dashboard/components/DashboardItem/Order/DashboardItemOrder.tsx +111 -245
- package/js/widgets/Dashboard/components/DashboardItem/Order/DashboardItemOrderContract.spec.tsx +61 -8
- package/js/widgets/Dashboard/components/DashboardItem/Order/DashboardItemOrderContract.useUnionResource.cache.spec.tsx +17 -7
- package/js/widgets/Dashboard/components/DashboardItem/Order/DashboardItemSavePaymentMethod.spec.tsx +116 -0
- package/js/widgets/Dashboard/components/DashboardItem/Order/Installment/index.tsx +175 -0
- package/js/widgets/Dashboard/components/DashboardItem/Order/OrderPaymentDetailsModal/_styles.scss +7 -0
- package/js/widgets/Dashboard/components/DashboardItem/Order/OrderPaymentDetailsModal/index.tsx +127 -0
- package/js/widgets/Dashboard/components/DashboardItem/Order/OrderPaymentRetryModal/index.tsx +216 -0
- package/js/widgets/Dashboard/components/DashboardItem/Order/OrderStateLearnerMessage/index.spec.tsx +18 -71
- package/js/widgets/Dashboard/components/DashboardItem/Order/OrderStateLearnerMessage/index.tsx +40 -25
- package/js/widgets/Dashboard/components/DashboardItem/Order/OrderStateMessage/index.tsx +28 -22
- package/js/widgets/Dashboard/components/DashboardItem/Order/OrderStateTeacherMessage/index.spec.tsx +18 -73
- package/js/widgets/Dashboard/components/DashboardItem/Order/OrderStateTeacherMessage/index.tsx +32 -16
- package/js/widgets/Dashboard/components/DashboardItem/Order/OrganizationBlock/index.tsx +150 -0
- package/js/widgets/Dashboard/components/DashboardOrderLoader/index.tsx +32 -14
- package/js/widgets/Dashboard/components/Signature/SignatureDummy.tsx +25 -3
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/components/CourseProductCourseRuns/EnrollableCourseRunList.tsx +2 -6
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/components/CourseProductCourseRuns/index.spec.tsx +7 -14
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/components/CourseRunItem/index.spec.tsx +7 -5
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/components/CourseRunItem/index.tsx +5 -7
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/index.spec.tsx +242 -332
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/index.stories.tsx +12 -13
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/index.tsx +10 -21
- package/js/widgets/SyllabusCourseRunsList/components/CourseRunEnrollment/index.joanie.spec.tsx +2 -2
- package/package.json +45 -44
- package/scss/components/_index.scss +4 -2
- package/js/components/PaymentButton/_styles.scss +0 -27
- package/js/components/SaleTunnel/GenericPaymentButton/index.tsx +0 -340
- package/js/components/SaleTunnel/SaleTunnelNotValidated/index.tsx +0 -70
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/components/ProductSignatureHeader/index.tsx +0 -41
- /package/js/components/{SaleTunnel/CreditCardSelector → CreditCardSelector}/_styles.scss +0 -0
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
import { faker } from '@faker-js/faker';
|
|
13
13
|
import fetchMock from 'fetch-mock';
|
|
14
14
|
import userEvent from '@testing-library/user-event';
|
|
15
|
+
import queryString from 'query-string';
|
|
15
16
|
import { DEFAULT_DATE_FORMAT } from 'hooks/useDateFormat';
|
|
16
17
|
import {
|
|
17
18
|
CourseStateFactory,
|
|
@@ -21,11 +22,20 @@ import {
|
|
|
21
22
|
CertificateFactory,
|
|
22
23
|
CourseLightFactory,
|
|
23
24
|
CourseRunFactory,
|
|
24
|
-
EnrollmentFactory,
|
|
25
25
|
CredentialOrderFactory,
|
|
26
|
+
EnrollmentFactory,
|
|
27
|
+
PaymentFactory,
|
|
26
28
|
TargetCourseFactory,
|
|
27
29
|
} from 'utils/test/factories/joanie';
|
|
28
|
-
import {
|
|
30
|
+
import {
|
|
31
|
+
Certificate,
|
|
32
|
+
CourseLight,
|
|
33
|
+
CourseRun,
|
|
34
|
+
CredentialOrder,
|
|
35
|
+
NOT_CANCELED_ORDER_STATES,
|
|
36
|
+
OrderState,
|
|
37
|
+
PaymentScheduleState,
|
|
38
|
+
} from 'types/Joanie';
|
|
29
39
|
import { resolveAll } from 'utils/resolveAll';
|
|
30
40
|
import { confirm } from 'utils/indirection/window';
|
|
31
41
|
import { Priority } from 'types';
|
|
@@ -40,6 +50,7 @@ import { setupJoanieSession } from 'utils/test/wrappers/JoanieAppWrapper';
|
|
|
40
50
|
import { render } from 'utils/test/render';
|
|
41
51
|
import { BaseJoanieAppWrapper } from 'utils/test/wrappers/BaseJoanieAppWrapper';
|
|
42
52
|
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRoutesPaths';
|
|
53
|
+
import PaymentScheduleHelper from 'utils/PaymentScheduleHelper';
|
|
43
54
|
import { DashboardTest } from '../../DashboardTest';
|
|
44
55
|
import { DashboardItemOrder } from './DashboardItemOrder';
|
|
45
56
|
|
|
@@ -53,8 +64,15 @@ jest.mock('utils/context', () => ({
|
|
|
53
64
|
|
|
54
65
|
jest.mock('utils/indirection/window', () => ({
|
|
55
66
|
confirm: jest.fn(() => true),
|
|
67
|
+
matchMedia: () => ({
|
|
68
|
+
matches: true,
|
|
69
|
+
addListener: jest.fn(),
|
|
70
|
+
removeListener: jest.fn(),
|
|
71
|
+
}),
|
|
56
72
|
}));
|
|
57
73
|
|
|
74
|
+
jest.mock('../../../../../components/PaymentInterfaces');
|
|
75
|
+
|
|
58
76
|
describe('<DashboardItemOrder/>', () => {
|
|
59
77
|
setupJoanieSession();
|
|
60
78
|
|
|
@@ -75,7 +93,7 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
75
93
|
|
|
76
94
|
await screen.findByRole('heading', { level: 5, name: product.title });
|
|
77
95
|
await screen.findByText('Ref. ' + (order.course as CourseLight).code);
|
|
78
|
-
await screen.findByText('Pending');
|
|
96
|
+
await screen.findByText('Pending for the first direct debit');
|
|
79
97
|
await screen.findByRole('link', { name: 'View details' });
|
|
80
98
|
});
|
|
81
99
|
|
|
@@ -103,7 +121,7 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
103
121
|
|
|
104
122
|
await screen.findByRole('heading', { level: 5, name: product.title });
|
|
105
123
|
await screen.findByText('Ref. ' + (order.course as CourseLight).code);
|
|
106
|
-
await screen.findByText('
|
|
124
|
+
await screen.findByText('Successfully completed');
|
|
107
125
|
await screen.findByRole('link', { name: 'View details' });
|
|
108
126
|
await expectSpinner('Loading certificate...');
|
|
109
127
|
deferred.resolve(certificate);
|
|
@@ -122,7 +140,7 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
122
140
|
|
|
123
141
|
await screen.findByRole('heading', { level: 5, name: product.title });
|
|
124
142
|
await screen.findByText('Ref. ' + (order.course as CourseLight).code);
|
|
125
|
-
await screen.findByText('
|
|
143
|
+
await screen.findByText('Successfully completed');
|
|
126
144
|
await screen.findByRole('link', { name: 'View details' });
|
|
127
145
|
await expectNoSpinner('Loading certificate ...');
|
|
128
146
|
});
|
|
@@ -241,6 +259,15 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
241
259
|
order.target_courses = [];
|
|
242
260
|
const { product } = mockCourseProductWithOrder(order);
|
|
243
261
|
|
|
262
|
+
const orderQueryParameters = {
|
|
263
|
+
course_code: order.course.code,
|
|
264
|
+
product_id: order.product_id,
|
|
265
|
+
state: NOT_CANCELED_ORDER_STATES,
|
|
266
|
+
};
|
|
267
|
+
const queryParams = queryString.stringify(orderQueryParameters);
|
|
268
|
+
const url = `https://joanie.endpoint/api/v1.0/orders/?${queryParams}`;
|
|
269
|
+
fetchMock.get(url, [order]);
|
|
270
|
+
|
|
244
271
|
render(<DashboardItemOrder order={order} writable={true} showDetailsButton={false} />);
|
|
245
272
|
|
|
246
273
|
await screen.findByRole('heading', { level: 5, name: product.title });
|
|
@@ -268,6 +295,15 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
268
295
|
|
|
269
296
|
const { product } = mockCourseProductWithOrder(order);
|
|
270
297
|
|
|
298
|
+
const orderQueryParameters = {
|
|
299
|
+
course_code: order.course.code,
|
|
300
|
+
product_id: order.product_id,
|
|
301
|
+
state: NOT_CANCELED_ORDER_STATES,
|
|
302
|
+
};
|
|
303
|
+
const queryParams = queryString.stringify(orderQueryParameters);
|
|
304
|
+
const url = `https://joanie.endpoint/api/v1.0/orders/?${queryParams}`;
|
|
305
|
+
fetchMock.get(url, [order]);
|
|
306
|
+
|
|
271
307
|
render(<DashboardItemOrder order={order} writable={true} showDetailsButton={false} />);
|
|
272
308
|
|
|
273
309
|
await screen.findByRole('heading', { level: 5, name: product.title });
|
|
@@ -333,6 +369,14 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
333
369
|
{ results: [order], next: null, previous: null, count: null },
|
|
334
370
|
{ overwriteRoutes: true },
|
|
335
371
|
);
|
|
372
|
+
const orderQueryParameters = {
|
|
373
|
+
course_code: order.course.code,
|
|
374
|
+
product_id: order.product_id,
|
|
375
|
+
state: NOT_CANCELED_ORDER_STATES,
|
|
376
|
+
};
|
|
377
|
+
const queryParams = queryString.stringify(orderQueryParameters);
|
|
378
|
+
const url = `https://joanie.endpoint/api/v1.0/orders/?${queryParams}`;
|
|
379
|
+
fetchMock.get(url, [order]);
|
|
336
380
|
|
|
337
381
|
// The order with an enrollment that will be returned from the API when the orders will be
|
|
338
382
|
// invalided after the click on the Enroll button.
|
|
@@ -416,6 +460,15 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
416
460
|
{ overwriteRoutes: true },
|
|
417
461
|
);
|
|
418
462
|
|
|
463
|
+
const orderQueryParameters = {
|
|
464
|
+
course_code: order.course.code,
|
|
465
|
+
product_id: order.product_id,
|
|
466
|
+
state: NOT_CANCELED_ORDER_STATES,
|
|
467
|
+
};
|
|
468
|
+
const queryParams = queryString.stringify(orderQueryParameters);
|
|
469
|
+
const url = `https://joanie.endpoint/api/v1.0/orders/?${queryParams}`;
|
|
470
|
+
fetchMock.get(url, [order]);
|
|
471
|
+
|
|
419
472
|
fetchMock.post('https://joanie.endpoint/api/v1.0/enrollments/', {
|
|
420
473
|
status: HttpStatusCode.INTERNAL_SERVER_ERROR,
|
|
421
474
|
body: 'Internal Server Error',
|
|
@@ -486,6 +539,14 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
486
539
|
{ results: [order], next: null, previous: null, count: null },
|
|
487
540
|
{ overwriteRoutes: true },
|
|
488
541
|
);
|
|
542
|
+
const orderQueryParameters = {
|
|
543
|
+
course_code: order.course.code,
|
|
544
|
+
product_id: order.product_id,
|
|
545
|
+
state: NOT_CANCELED_ORDER_STATES,
|
|
546
|
+
};
|
|
547
|
+
const queryParams = queryString.stringify(orderQueryParameters);
|
|
548
|
+
const url = `https://joanie.endpoint/api/v1.0/orders/?${queryParams}`;
|
|
549
|
+
fetchMock.get(url, [order]);
|
|
489
550
|
|
|
490
551
|
// The order with new enrollment that will be returned from the API when the orders will be
|
|
491
552
|
// invalided after the click on the Enroll button.
|
|
@@ -592,6 +653,14 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
592
653
|
{ results: [order], next: null, previous: null, count: null },
|
|
593
654
|
{ overwriteRoutes: true },
|
|
594
655
|
);
|
|
656
|
+
const orderQueryParameters = {
|
|
657
|
+
course_code: order.course.code,
|
|
658
|
+
product_id: order.product_id,
|
|
659
|
+
state: NOT_CANCELED_ORDER_STATES,
|
|
660
|
+
};
|
|
661
|
+
const queryParams = queryString.stringify(orderQueryParameters);
|
|
662
|
+
const url = `https://joanie.endpoint/api/v1.0/orders/?${queryParams}`;
|
|
663
|
+
fetchMock.get(url, [order]);
|
|
595
664
|
|
|
596
665
|
const courseRun = order.target_courses[0].course_runs[0];
|
|
597
666
|
const newEnrolledCourseRun = order.target_courses[0].course_runs[1];
|
|
@@ -677,6 +746,14 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
677
746
|
{ results: [order], next: null, previous: null, count: null },
|
|
678
747
|
{ overwriteRoutes: true },
|
|
679
748
|
);
|
|
749
|
+
const orderQueryParameters = {
|
|
750
|
+
course_code: order.course.code,
|
|
751
|
+
product_id: order.product_id,
|
|
752
|
+
state: NOT_CANCELED_ORDER_STATES,
|
|
753
|
+
};
|
|
754
|
+
const queryParams = queryString.stringify(orderQueryParameters);
|
|
755
|
+
const url = `https://joanie.endpoint/api/v1.0/orders/?${queryParams}`;
|
|
756
|
+
fetchMock.get(url, [order]);
|
|
680
757
|
|
|
681
758
|
// The order with new enrollment that will be returned from the API when the orders will be
|
|
682
759
|
// invalided after the click on the Enroll button.
|
|
@@ -756,6 +833,14 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
756
833
|
}).many(1),
|
|
757
834
|
}).one();
|
|
758
835
|
const { product } = mockCourseProductWithOrder(order);
|
|
836
|
+
const orderQueryParameters = {
|
|
837
|
+
course_code: order.course.code,
|
|
838
|
+
product_id: order.product_id,
|
|
839
|
+
state: NOT_CANCELED_ORDER_STATES,
|
|
840
|
+
};
|
|
841
|
+
const queryParams = queryString.stringify(orderQueryParameters);
|
|
842
|
+
const url = `https://joanie.endpoint/api/v1.0/orders/?${queryParams}`;
|
|
843
|
+
fetchMock.get(url, [order]);
|
|
759
844
|
|
|
760
845
|
render(<DashboardItemOrder order={order} writable={true} showDetailsButton={false} />);
|
|
761
846
|
|
|
@@ -792,6 +877,15 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
792
877
|
|
|
793
878
|
const { product } = mockCourseProductWithOrder(order);
|
|
794
879
|
|
|
880
|
+
const orderQueryParameters = {
|
|
881
|
+
course_code: order.course.code,
|
|
882
|
+
product_id: order.product_id,
|
|
883
|
+
state: NOT_CANCELED_ORDER_STATES,
|
|
884
|
+
};
|
|
885
|
+
const queryParams = queryString.stringify(orderQueryParameters);
|
|
886
|
+
const url = `https://joanie.endpoint/api/v1.0/orders/?${queryParams}`;
|
|
887
|
+
fetchMock.get(url, [order]);
|
|
888
|
+
|
|
795
889
|
render(<DashboardItemOrder order={order} writable={true} showDetailsButton={false} />);
|
|
796
890
|
|
|
797
891
|
await screen.findByRole('heading', { level: 5, name: product.title });
|
|
@@ -820,6 +914,15 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
820
914
|
|
|
821
915
|
const { product } = mockCourseProductWithOrder(order);
|
|
822
916
|
|
|
917
|
+
const orderQueryParameters = {
|
|
918
|
+
course_code: order.course.code,
|
|
919
|
+
product_id: order.product_id,
|
|
920
|
+
state: NOT_CANCELED_ORDER_STATES,
|
|
921
|
+
};
|
|
922
|
+
const queryParams = queryString.stringify(orderQueryParameters);
|
|
923
|
+
const url = `https://joanie.endpoint/api/v1.0/orders/?${queryParams}`;
|
|
924
|
+
fetchMock.get(url, [order]);
|
|
925
|
+
|
|
823
926
|
render(<DashboardItemOrder order={order} writable={true} showDetailsButton={false} />);
|
|
824
927
|
|
|
825
928
|
await screen.findByRole('heading', { level: 5, name: product.title });
|
|
@@ -836,6 +939,15 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
836
939
|
const order: CredentialOrder = CredentialOrderFactory().one();
|
|
837
940
|
const { product } = mockCourseProductWithOrder(order);
|
|
838
941
|
|
|
942
|
+
const orderQueryParameters = {
|
|
943
|
+
course_code: order.course.code,
|
|
944
|
+
product_id: order.product_id,
|
|
945
|
+
state: NOT_CANCELED_ORDER_STATES,
|
|
946
|
+
};
|
|
947
|
+
const queryParams = queryString.stringify(orderQueryParameters);
|
|
948
|
+
const url = `https://joanie.endpoint/api/v1.0/orders/?${queryParams}`;
|
|
949
|
+
fetchMock.get(url, [order]);
|
|
950
|
+
|
|
839
951
|
render(<DashboardItemOrder order={order} writable={true} showDetailsButton={false} />);
|
|
840
952
|
|
|
841
953
|
await screen.findByRole('heading', { level: 5, name: product.title });
|
|
@@ -852,4 +964,106 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
852
964
|
within(block).getByText(new RegExp(order.organization?.address?.postcode!));
|
|
853
965
|
within(block).getByText(new RegExp(order.organization?.address?.country!));
|
|
854
966
|
});
|
|
967
|
+
|
|
968
|
+
it('renders a writable order with failed payment and retry it successfully', async () => {
|
|
969
|
+
const order = CredentialOrderFactory().one();
|
|
970
|
+
const paymentInfo = PaymentFactory().one();
|
|
971
|
+
|
|
972
|
+
const validOrder = { ...order };
|
|
973
|
+
validOrder.payment_schedule = [
|
|
974
|
+
{ ...order.payment_schedule![0] },
|
|
975
|
+
{ ...order.payment_schedule![1] },
|
|
976
|
+
{ ...order.payment_schedule![2] },
|
|
977
|
+
];
|
|
978
|
+
fetchMock
|
|
979
|
+
.post(
|
|
980
|
+
`https://joanie.endpoint/api/v1.0/orders/${order.id}/submit-installment-payment/`,
|
|
981
|
+
paymentInfo,
|
|
982
|
+
)
|
|
983
|
+
.get(`https://joanie.endpoint/api/v1.0/orders/${order.id}/`, validOrder);
|
|
984
|
+
|
|
985
|
+
const orderQueryParameters = {
|
|
986
|
+
course_code: order.course.code,
|
|
987
|
+
product_id: order.product_id,
|
|
988
|
+
state: NOT_CANCELED_ORDER_STATES,
|
|
989
|
+
};
|
|
990
|
+
const queryParams = queryString.stringify(orderQueryParameters);
|
|
991
|
+
const url = `https://joanie.endpoint/api/v1.0/orders/?${queryParams}`;
|
|
992
|
+
fetchMock.get(url, [order]);
|
|
993
|
+
|
|
994
|
+
order.state = OrderState.FAILED_PAYMENT;
|
|
995
|
+
order.payment_schedule![1].state = PaymentScheduleState.REFUSED;
|
|
996
|
+
|
|
997
|
+
const formatPrice = (price: number, currency: string) =>
|
|
998
|
+
new Intl.NumberFormat('en', {
|
|
999
|
+
currency,
|
|
1000
|
+
style: 'currency',
|
|
1001
|
+
}).format(price);
|
|
1002
|
+
|
|
1003
|
+
const { product } = mockCourseProductWithOrder(order);
|
|
1004
|
+
fetchMock.get(
|
|
1005
|
+
'https://joanie.endpoint/api/v1.0/orders/',
|
|
1006
|
+
{ results: [order], next: null, previous: null, count: null },
|
|
1007
|
+
{ overwriteRoutes: true },
|
|
1008
|
+
);
|
|
1009
|
+
|
|
1010
|
+
render(
|
|
1011
|
+
<DashboardTest initialRoute={LearnerDashboardPaths.ORDER.replace(':orderId', order.id)} />,
|
|
1012
|
+
{ wrapper: BaseJoanieAppWrapper },
|
|
1013
|
+
);
|
|
1014
|
+
|
|
1015
|
+
await screen.findByRole('heading', { level: 5, name: product.title });
|
|
1016
|
+
screen.getByText(/a payment failed, please update your payment method/i);
|
|
1017
|
+
const failedInstallment = PaymentScheduleHelper.getFailedInstallment(order.payment_schedule)!;
|
|
1018
|
+
const button = screen.getByRole('button', {
|
|
1019
|
+
name: 'Pay ' + formatPrice(failedInstallment.amount, failedInstallment.currency),
|
|
1020
|
+
});
|
|
1021
|
+
const user = userEvent.setup();
|
|
1022
|
+
|
|
1023
|
+
await user.click(button);
|
|
1024
|
+
|
|
1025
|
+
// Retry modal is shown.
|
|
1026
|
+
screen.getByText('Retry payment');
|
|
1027
|
+
screen.getByText(
|
|
1028
|
+
/The payment failed, please choose another payment method or add a new one during the payment/,
|
|
1029
|
+
);
|
|
1030
|
+
screen.getByText('Use another credit card');
|
|
1031
|
+
|
|
1032
|
+
// Prepare for cache invalidation.
|
|
1033
|
+
fetchMock.get(
|
|
1034
|
+
'https://joanie.endpoint/api/v1.0/orders/',
|
|
1035
|
+
{ results: [validOrder], next: null, previous: null, count: null },
|
|
1036
|
+
{ overwriteRoutes: true },
|
|
1037
|
+
);
|
|
1038
|
+
|
|
1039
|
+
// Click on pay button.
|
|
1040
|
+
const payButton = screen.getByTestId('order-payment-retry-modal-submit-button');
|
|
1041
|
+
expect(payButton.innerHTML.replace(' ', ' ')).toEqual(
|
|
1042
|
+
'Pay ' +
|
|
1043
|
+
formatPrice(failedInstallment.amount, failedInstallment.currency).replace(
|
|
1044
|
+
/(\u202F|\u00a0)/g,
|
|
1045
|
+
' ',
|
|
1046
|
+
),
|
|
1047
|
+
);
|
|
1048
|
+
await user.click(payButton);
|
|
1049
|
+
// Pay via mocked payment interface
|
|
1050
|
+
screen.getByText('Payment interface component');
|
|
1051
|
+
await user.click(screen.getByTestId('payment-success'));
|
|
1052
|
+
|
|
1053
|
+
// Make sure retry modal is closed.
|
|
1054
|
+
expect(screen.queryByText('Retry payment')).not.toBeInTheDocument();
|
|
1055
|
+
|
|
1056
|
+
// Success modal is shown, close it.
|
|
1057
|
+
screen.getByText('Payment successful');
|
|
1058
|
+
screen.getByText('The payment was successful');
|
|
1059
|
+
const okButton = screen.getByRole('button', { name: 'Ok' });
|
|
1060
|
+
await user.click(okButton);
|
|
1061
|
+
|
|
1062
|
+
// Warning alert is not shown anymore.
|
|
1063
|
+
await waitFor(() => {
|
|
1064
|
+
expect(
|
|
1065
|
+
screen.queryByText(/a payment failed, please update your payment method/i),
|
|
1066
|
+
).not.toBeInTheDocument();
|
|
1067
|
+
});
|
|
1068
|
+
});
|
|
855
1069
|
});
|