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
|
@@ -4,45 +4,48 @@ import {
|
|
|
4
4
|
Address,
|
|
5
5
|
Certificate,
|
|
6
6
|
CertificateDefinition,
|
|
7
|
-
|
|
7
|
+
CertificateOrder,
|
|
8
|
+
CertificateProduct,
|
|
9
|
+
Contract,
|
|
10
|
+
ContractDefinition,
|
|
11
|
+
ContractLight,
|
|
8
12
|
CourseLight,
|
|
13
|
+
CourseListItem,
|
|
9
14
|
CourseProduct,
|
|
10
15
|
CourseProductRelation,
|
|
11
16
|
CourseRun,
|
|
17
|
+
CredentialOrder,
|
|
18
|
+
CredentialProduct,
|
|
12
19
|
CreditCard,
|
|
13
20
|
CreditCardBrand,
|
|
21
|
+
DefinitionResourcesProduct,
|
|
14
22
|
Enrollment,
|
|
23
|
+
EnrollmentLight,
|
|
15
24
|
EnrollmentState,
|
|
25
|
+
JoanieFile,
|
|
26
|
+
NestedCertificateOrder,
|
|
27
|
+
NestedCourseOrder,
|
|
28
|
+
NestedCredentialOrder,
|
|
29
|
+
Order,
|
|
30
|
+
OrderEnrollment,
|
|
31
|
+
OrderGroup,
|
|
32
|
+
PaymentInstallment,
|
|
16
33
|
OrderLite,
|
|
17
34
|
OrderState,
|
|
18
35
|
Organization,
|
|
19
36
|
OrganizationLight,
|
|
37
|
+
PaymentScheduleState,
|
|
20
38
|
ProductType,
|
|
21
39
|
TargetCourse,
|
|
22
|
-
JoanieFile,
|
|
23
|
-
Contract,
|
|
24
|
-
OrderEnrollment,
|
|
25
|
-
ContractDefinition,
|
|
26
|
-
NestedCredentialOrder,
|
|
27
|
-
NestedCertificateOrder,
|
|
28
|
-
Order,
|
|
29
|
-
CertificateOrder,
|
|
30
|
-
CredentialOrder,
|
|
31
|
-
CertificateOrderWithPaymentInfo,
|
|
32
|
-
CredentialOrderWithPaymentInfo,
|
|
33
|
-
EnrollmentLight,
|
|
34
|
-
OrderGroup,
|
|
35
|
-
CertificateProduct,
|
|
36
|
-
CredentialProduct,
|
|
37
|
-
NestedCourseOrder,
|
|
38
40
|
UserLight,
|
|
39
|
-
ContractLight,
|
|
40
|
-
DefinitionResourcesProduct,
|
|
41
41
|
} from 'types/Joanie';
|
|
42
42
|
import { Payment, PaymentProviders } from 'components/PaymentInterfaces/types';
|
|
43
43
|
import { CourseStateFactory } from 'utils/test/factories/richie';
|
|
44
44
|
import { FactoryHelper } from 'utils/test/factories/helper';
|
|
45
45
|
import { JoanieUserApiAbilityActions, JoanieUserProfile } from 'types/User';
|
|
46
|
+
import { SaleTunnelContextType, SaleTunnelStep } from 'components/SaleTunnel/GenericSaleTunnel';
|
|
47
|
+
import { SaleTunnelProps } from 'components/SaleTunnel';
|
|
48
|
+
import { noop } from 'utils/index';
|
|
46
49
|
import { factory } from './factories';
|
|
47
50
|
|
|
48
51
|
export const UserLightFactory = factory((): UserLight => {
|
|
@@ -138,7 +141,7 @@ export const ContractFactory = factory((): Contract => {
|
|
|
138
141
|
organization_signatory: null,
|
|
139
142
|
created_on: faker.date.past().toISOString(),
|
|
140
143
|
definition: ContractDefinitionFactory().one(),
|
|
141
|
-
order: NestedCredentialOrderFactory().one(),
|
|
144
|
+
order: NestedCredentialOrderFactory({ state: OrderState.TO_SIGN }).one(),
|
|
142
145
|
};
|
|
143
146
|
});
|
|
144
147
|
|
|
@@ -251,7 +254,12 @@ export const CourseRunFactory = factory((): CourseRun => {
|
|
|
251
254
|
call_to_action: 'enroll now',
|
|
252
255
|
text: CourseStateTextEnum.ENROLLMENT_OPENED,
|
|
253
256
|
}).one(),
|
|
254
|
-
languages: faker.helpers.multiple(faker.location.countryCode, {
|
|
257
|
+
languages: faker.helpers.multiple(() => faker.location.countryCode(), {
|
|
258
|
+
count: {
|
|
259
|
+
min: 1,
|
|
260
|
+
max: 5,
|
|
261
|
+
},
|
|
262
|
+
}),
|
|
255
263
|
};
|
|
256
264
|
});
|
|
257
265
|
|
|
@@ -312,7 +320,7 @@ export const NestedCourseOrderFactory = factory((): NestedCourseOrder => {
|
|
|
312
320
|
owner: UserLightFactory().one(),
|
|
313
321
|
course_id: faker.string.uuid(),
|
|
314
322
|
product_id: faker.string.uuid(),
|
|
315
|
-
state: OrderState.
|
|
323
|
+
state: OrderState.COMPLETED,
|
|
316
324
|
enrollment_id: faker.string.uuid(),
|
|
317
325
|
organization: OrganizationFactory().one(),
|
|
318
326
|
certificate_id: faker.string.uuid(),
|
|
@@ -347,11 +355,22 @@ export const CourseListItemFactory = factory((): CourseListItem => {
|
|
|
347
355
|
};
|
|
348
356
|
});
|
|
349
357
|
|
|
358
|
+
export const PaymentInstallmentFactory = factory((): PaymentInstallment => {
|
|
359
|
+
return {
|
|
360
|
+
id: faker.string.uuid(),
|
|
361
|
+
currency: faker.finance.currencyCode(),
|
|
362
|
+
amount: faker.number.int(),
|
|
363
|
+
due_date: faker.date.future().toISOString(),
|
|
364
|
+
state: PaymentScheduleState.PAID,
|
|
365
|
+
};
|
|
366
|
+
});
|
|
367
|
+
|
|
350
368
|
export const OrderEnrollmentFactory = factory((): OrderEnrollment => {
|
|
351
369
|
return {
|
|
352
370
|
id: faker.string.uuid(),
|
|
353
371
|
product_id: faker.string.uuid(),
|
|
354
|
-
state: OrderState.
|
|
372
|
+
state: OrderState.COMPLETED,
|
|
373
|
+
payment_schedule: PaymentInstallmentFactory().many(1),
|
|
355
374
|
};
|
|
356
375
|
});
|
|
357
376
|
|
|
@@ -363,19 +382,19 @@ export const OrderLiteFactory = factory((): OrderLite => {
|
|
|
363
382
|
main_invoice_reference: faker.string.uuid(),
|
|
364
383
|
total: faker.number.int(),
|
|
365
384
|
product_id: faker.string.uuid(),
|
|
366
|
-
state: OrderState.
|
|
385
|
+
state: OrderState.COMPLETED,
|
|
367
386
|
};
|
|
368
387
|
});
|
|
369
388
|
|
|
370
389
|
export const NestedCertificateOrderFactory = factory((): NestedCertificateOrder => {
|
|
371
390
|
return {
|
|
372
391
|
id: faker.string.uuid(),
|
|
373
|
-
course:
|
|
392
|
+
course: null,
|
|
374
393
|
enrollment: EnrollmentLightFactory().one(),
|
|
375
394
|
organization: OrganizationFactory().one(),
|
|
376
395
|
product_title: FactoryHelper.unique(faker.lorem.words, { args: [1] }),
|
|
377
396
|
owner_name: faker.internet.userName(),
|
|
378
|
-
state: OrderState.
|
|
397
|
+
state: OrderState.COMPLETED,
|
|
379
398
|
};
|
|
380
399
|
});
|
|
381
400
|
|
|
@@ -383,11 +402,11 @@ export const NestedCredentialOrderFactory = factory((): NestedCredentialOrder =>
|
|
|
383
402
|
return {
|
|
384
403
|
id: faker.string.uuid(),
|
|
385
404
|
course: CourseLightFactory().one(),
|
|
386
|
-
enrollment:
|
|
405
|
+
enrollment: null,
|
|
387
406
|
organization: OrganizationFactory().one(),
|
|
388
407
|
product_title: FactoryHelper.unique(faker.lorem.words, { args: [1] }),
|
|
389
408
|
owner_name: faker.internet.userName(),
|
|
390
|
-
state: OrderState.
|
|
409
|
+
state: OrderState.COMPLETED,
|
|
391
410
|
};
|
|
392
411
|
});
|
|
393
412
|
|
|
@@ -399,7 +418,7 @@ const AbstractOrderFactory = factory((): Order => {
|
|
|
399
418
|
total: faker.number.int(),
|
|
400
419
|
total_currency: faker.finance.currencyCode(),
|
|
401
420
|
main_invoice_reference: faker.string.uuid(),
|
|
402
|
-
state: OrderState.
|
|
421
|
+
state: OrderState.COMPLETED,
|
|
403
422
|
product_id: faker.string.uuid(),
|
|
404
423
|
target_courses: TargetCourseFactory().many(5),
|
|
405
424
|
target_enrollments: [],
|
|
@@ -410,55 +429,22 @@ const AbstractOrderFactory = factory((): Order => {
|
|
|
410
429
|
};
|
|
411
430
|
});
|
|
412
431
|
|
|
413
|
-
export const CredentialOrderFactory = factory(
|
|
414
|
-
|
|
432
|
+
export const CredentialOrderFactory = factory(
|
|
433
|
+
(): CredentialOrder => ({
|
|
415
434
|
...AbstractOrderFactory().one(),
|
|
416
435
|
course: CourseLightFactory().one(),
|
|
417
436
|
enrollment: null,
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
});
|
|
421
|
-
|
|
422
|
-
export const CredentialOrderWithPaymentFactory = factory((): CredentialOrderWithPaymentInfo => {
|
|
423
|
-
return {
|
|
424
|
-
...CredentialOrderFactory().one(),
|
|
425
|
-
payment_info: PaymentFactory().one(),
|
|
426
|
-
};
|
|
427
|
-
});
|
|
428
|
-
|
|
429
|
-
export const CredentialOrderWithOneClickPaymentFactory = factory(
|
|
430
|
-
(): CredentialOrderWithPaymentInfo => {
|
|
431
|
-
return {
|
|
432
|
-
...CredentialOrderFactory().one(),
|
|
433
|
-
payment_info: PaymentFactory().one(),
|
|
434
|
-
};
|
|
435
|
-
},
|
|
437
|
+
payment_schedule: PaymentInstallmentFactory().many(3),
|
|
438
|
+
}),
|
|
436
439
|
);
|
|
437
440
|
|
|
438
|
-
export const CertificateOrderFactory = factory(
|
|
439
|
-
|
|
441
|
+
export const CertificateOrderFactory = factory(
|
|
442
|
+
(): CertificateOrder => ({
|
|
440
443
|
...AbstractOrderFactory().one(),
|
|
441
444
|
course: null,
|
|
442
445
|
target_courses: [],
|
|
443
446
|
enrollment: EnrollmentLightFactory().one(),
|
|
444
|
-
}
|
|
445
|
-
return order;
|
|
446
|
-
});
|
|
447
|
-
|
|
448
|
-
export const CertificateOrderWithPaymentFactory = factory((): CertificateOrderWithPaymentInfo => {
|
|
449
|
-
return {
|
|
450
|
-
...CertificateOrderFactory().one(),
|
|
451
|
-
payment_info: PaymentFactory().one(),
|
|
452
|
-
};
|
|
453
|
-
});
|
|
454
|
-
|
|
455
|
-
export const CertificateOrderWithOneClickPaymentFactory = factory(
|
|
456
|
-
(): CertificateOrderWithPaymentInfo => {
|
|
457
|
-
return {
|
|
458
|
-
...CertificateOrderFactory().one(),
|
|
459
|
-
payment_info: PaymentFactory().one(),
|
|
460
|
-
};
|
|
461
|
-
},
|
|
447
|
+
}),
|
|
462
448
|
);
|
|
463
449
|
|
|
464
450
|
export const AddressFactory = factory((): Address => {
|
|
@@ -494,3 +480,20 @@ export const PaymentFactory = factory((): Payment => {
|
|
|
494
480
|
url: faker.internet.url(),
|
|
495
481
|
};
|
|
496
482
|
});
|
|
483
|
+
|
|
484
|
+
export const SaleTunnelContextFactory = factory(
|
|
485
|
+
(): SaleTunnelContextType => ({
|
|
486
|
+
webAnalyticsEventKey: 'eventKey',
|
|
487
|
+
order: CredentialOrderFactory().one(),
|
|
488
|
+
product: ProductFactory().one(),
|
|
489
|
+
props: {} as SaleTunnelProps,
|
|
490
|
+
billingAddress: undefined,
|
|
491
|
+
setBillingAddress: noop,
|
|
492
|
+
setCreditCard: noop,
|
|
493
|
+
step: SaleTunnelStep.IDLE,
|
|
494
|
+
registerSubmitCallback: noop,
|
|
495
|
+
unregisterSubmitCallback: noop,
|
|
496
|
+
runSubmitCallbacks: () => new Promise((resolve) => resolve()),
|
|
497
|
+
nextStep: noop,
|
|
498
|
+
}),
|
|
499
|
+
);
|
|
@@ -122,7 +122,7 @@ describe.each([
|
|
|
122
122
|
expect(await screen.findByText(contract.definition.title)).toBeInTheDocument();
|
|
123
123
|
expect(screen.getByText(contract.order.product_title)).toBeInTheDocument();
|
|
124
124
|
expect(
|
|
125
|
-
screen.getByText('You have to sign this training contract to
|
|
125
|
+
screen.getByText('You have to sign this training contract to finalize your subscription.'),
|
|
126
126
|
).toBeInTheDocument();
|
|
127
127
|
|
|
128
128
|
expect(screen.queryByRole('button', { name: 'Sign' })).toBeInTheDocument();
|
|
@@ -149,7 +149,7 @@ describe.each([
|
|
|
149
149
|
expect(await screen.findByText(contract.definition.title)).toBeInTheDocument();
|
|
150
150
|
expect(screen.getByText(contract.order.product_title)).toBeInTheDocument();
|
|
151
151
|
expect(
|
|
152
|
-
screen.getByText('You have to sign this training contract to
|
|
152
|
+
screen.getByText('You have to sign this training contract to finalize your subscription.'),
|
|
153
153
|
).toBeInTheDocument();
|
|
154
154
|
|
|
155
155
|
expect(screen.queryByRole('link', { name: 'Sign' })).toBeInTheDocument();
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
CourseRun,
|
|
10
10
|
CredentialOrder,
|
|
11
11
|
Enrollment,
|
|
12
|
-
Product,
|
|
13
12
|
} from 'types/Joanie';
|
|
14
13
|
import { Spinner } from 'components/Spinner';
|
|
15
14
|
import Banner, { BannerType } from 'components/Banner';
|
|
@@ -68,10 +67,11 @@ const messages = defineMessages({
|
|
|
68
67
|
description: 'Text displayed when course runs list is loading',
|
|
69
68
|
id: 'components.DashboardItemCourseEnrollingRun.courseRunsLoading',
|
|
70
69
|
},
|
|
71
|
-
|
|
72
|
-
id: 'components.DashboardItemCourseEnrollingRun.
|
|
73
|
-
description:
|
|
74
|
-
|
|
70
|
+
cannotEnroll: {
|
|
71
|
+
id: 'components.DashboardItemCourseEnrollingRun.cannotEnroll',
|
|
72
|
+
description:
|
|
73
|
+
'Message displayed as disabled button title when the order state does not allow enrollment.',
|
|
74
|
+
defaultMessage: 'You cannot enroll yet to this training.',
|
|
75
75
|
},
|
|
76
76
|
});
|
|
77
77
|
|
|
@@ -81,7 +81,6 @@ interface DashboardItemCourseEnrollingProps {
|
|
|
81
81
|
course: AbstractCourse;
|
|
82
82
|
activeEnrollment?: Enrollment;
|
|
83
83
|
order?: CredentialOrder;
|
|
84
|
-
product?: Product;
|
|
85
84
|
writable: boolean;
|
|
86
85
|
hideEnrollButtons?: boolean;
|
|
87
86
|
icon?: boolean;
|
|
@@ -93,7 +92,6 @@ export const DashboardItemCourseEnrolling = ({
|
|
|
93
92
|
activeEnrollment,
|
|
94
93
|
writable,
|
|
95
94
|
order,
|
|
96
|
-
product,
|
|
97
95
|
icon = false,
|
|
98
96
|
notEnrolledUrl = '#',
|
|
99
97
|
hideEnrollButtons,
|
|
@@ -121,7 +119,6 @@ export const DashboardItemCourseEnrolling = ({
|
|
|
121
119
|
course={course}
|
|
122
120
|
enrollments={CoursesHelper.findCourseEnrollmentsInOrder(course, order)}
|
|
123
121
|
order={order}
|
|
124
|
-
product={product}
|
|
125
122
|
/>
|
|
126
123
|
)}
|
|
127
124
|
</div>
|
|
@@ -132,14 +129,12 @@ interface DashboardItemCourseEnrollingRunsProps {
|
|
|
132
129
|
course: AbstractCourse;
|
|
133
130
|
enrollments: Enrollment[];
|
|
134
131
|
order?: CredentialOrder;
|
|
135
|
-
product?: Product;
|
|
136
132
|
}
|
|
137
133
|
|
|
138
134
|
const DashboardItemCourseEnrollingRuns = ({
|
|
139
135
|
course,
|
|
140
136
|
enrollments,
|
|
141
137
|
order,
|
|
142
|
-
product,
|
|
143
138
|
}: DashboardItemCourseEnrollingRunsProps) => {
|
|
144
139
|
const { enroll, isLoading, error } = useEnroll(enrollments, order);
|
|
145
140
|
|
|
@@ -176,7 +171,6 @@ const DashboardItemCourseEnrollingRuns = ({
|
|
|
176
171
|
selected={data.selected}
|
|
177
172
|
enroll={() => enroll(data.courseRun)}
|
|
178
173
|
order={order}
|
|
179
|
-
product={product}
|
|
180
174
|
/>
|
|
181
175
|
))}
|
|
182
176
|
{isLoading && (
|
|
@@ -200,7 +194,6 @@ interface DashboardItemCourseEnrollingRunProps {
|
|
|
200
194
|
selected: boolean;
|
|
201
195
|
enroll: () => void;
|
|
202
196
|
order?: CredentialOrder | CertificateOrder;
|
|
203
|
-
product?: Product;
|
|
204
197
|
}
|
|
205
198
|
|
|
206
199
|
export const DashboardItemCourseEnrollingRun = ({
|
|
@@ -208,14 +201,11 @@ export const DashboardItemCourseEnrollingRun = ({
|
|
|
208
201
|
selected,
|
|
209
202
|
enroll,
|
|
210
203
|
order,
|
|
211
|
-
product,
|
|
212
204
|
}: DashboardItemCourseEnrollingRunProps) => {
|
|
213
205
|
const intl = useIntl();
|
|
214
206
|
const formatDate = useDateFormat();
|
|
215
207
|
const courseRunPeriodMessage = useCourseRunPeriodMessage(courseRun, selected);
|
|
216
|
-
const
|
|
217
|
-
? OrderHelper.orderNeedsSignature(order, product?.contract_definition)
|
|
218
|
-
: false;
|
|
208
|
+
const canEnroll = OrderHelper.allowEnrollment(order);
|
|
219
209
|
const isOpenedForEnrollment = useMemo(
|
|
220
210
|
() => courseRun.state.priority < Priority.FUTURE_NOT_YET_OPEN,
|
|
221
211
|
[courseRun],
|
|
@@ -266,11 +256,11 @@ export const DashboardItemCourseEnrollingRun = ({
|
|
|
266
256
|
) : (
|
|
267
257
|
<div>
|
|
268
258
|
<Button
|
|
269
|
-
disabled={!isOpenedForEnrollment ||
|
|
259
|
+
disabled={!isOpenedForEnrollment || !canEnroll}
|
|
270
260
|
color="tertiary"
|
|
271
261
|
size="small"
|
|
272
262
|
onClick={enroll}
|
|
273
|
-
title={
|
|
263
|
+
title={!canEnroll ? intl.formatMessage(messages.cannotEnroll) : ''}
|
|
274
264
|
>
|
|
275
265
|
<FormattedMessage {...messages.enrollRun} />
|
|
276
266
|
</Button>
|
package/js/widgets/Dashboard/components/DashboardItem/Enrollment/DashboardItemEnrollment.spec.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { screen } from '@testing-library/react';
|
|
2
2
|
import { faker } from '@faker-js/faker';
|
|
3
|
+
import { userEvent } from '@testing-library/user-event';
|
|
3
4
|
import { Enrollment } from 'types/Joanie';
|
|
4
5
|
import {
|
|
5
6
|
CourseStateFactory,
|
|
@@ -81,4 +82,26 @@ describe('<DashboardItemEnrollment/>', () => {
|
|
|
81
82
|
screen.getByText('Ref. ' + enrollment.course_run.course!.code);
|
|
82
83
|
screen.getByText('Not enrolled');
|
|
83
84
|
});
|
|
85
|
+
|
|
86
|
+
it('renders a link to go to the syllabus', async () => {
|
|
87
|
+
const enrollment: Enrollment = EnrollmentFactory({
|
|
88
|
+
is_active: false,
|
|
89
|
+
course_run: CourseRunWithCourseFactory().one(),
|
|
90
|
+
}).one();
|
|
91
|
+
|
|
92
|
+
render(<DashboardItemEnrollment enrollment={enrollment} />);
|
|
93
|
+
screen.getByRole('heading', { level: 5, name: enrollment.course_run.course!.title });
|
|
94
|
+
|
|
95
|
+
const moreButton = screen.getByRole('combobox', {
|
|
96
|
+
name: 'See additional options',
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const user = userEvent.setup();
|
|
100
|
+
await user.click(moreButton);
|
|
101
|
+
|
|
102
|
+
const link = screen.getByRole('link', { name: 'Go to syllabus' });
|
|
103
|
+
expect(link.getAttribute('href')).toBe(
|
|
104
|
+
'/redirects/courses/' + enrollment.course_run.course.code,
|
|
105
|
+
);
|
|
106
|
+
});
|
|
84
107
|
});
|
package/js/widgets/Dashboard/components/DashboardItem/Enrollment/DashboardItemEnrollment.tsx
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
|
+
import { defineMessages, FormattedMessage } from 'react-intl';
|
|
2
3
|
import { Enrollment, isCertificateProduct } from 'types/Joanie';
|
|
3
4
|
import { Enrolled } from '../CourseEnrolling';
|
|
4
5
|
import { DashboardItem } from '..';
|
|
5
6
|
import ProductCertificateFooter from './ProductCertificateFooter';
|
|
6
7
|
|
|
8
|
+
const messages = defineMessages({
|
|
9
|
+
syllabusLinkLabel: {
|
|
10
|
+
id: 'components.DashboardItemEnrollment.syllabusLinkLabel',
|
|
11
|
+
description: 'Syllabus link label on order details',
|
|
12
|
+
defaultMessage: 'Go to syllabus',
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
|
|
7
16
|
interface DashboardItemCourseRunProps {
|
|
8
17
|
enrollment: Enrollment;
|
|
9
18
|
}
|
|
@@ -38,5 +47,18 @@ export const DashboardItemEnrollment = ({ enrollment }: DashboardItemCourseRunPr
|
|
|
38
47
|
return partialFooterList;
|
|
39
48
|
}, [enrollment, course]);
|
|
40
49
|
|
|
41
|
-
return
|
|
50
|
+
return (
|
|
51
|
+
<DashboardItem
|
|
52
|
+
title={course.title}
|
|
53
|
+
code={'Ref. ' + course.code}
|
|
54
|
+
more={
|
|
55
|
+
<li>
|
|
56
|
+
<a className="selector__list__link" href={`/redirects/courses/${course.code}`}>
|
|
57
|
+
<FormattedMessage {...messages.syllabusLinkLabel} />
|
|
58
|
+
</a>
|
|
59
|
+
</li>
|
|
60
|
+
}
|
|
61
|
+
footer={footerList}
|
|
62
|
+
/>
|
|
63
|
+
);
|
|
42
64
|
};
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
import { screen, waitForElementToBeRemoved } from '@testing-library/react';
|
|
1
|
+
import { screen, waitForElementToBeRemoved, within } from '@testing-library/react';
|
|
2
2
|
import fetchMock from 'fetch-mock';
|
|
3
3
|
import userEvent from '@testing-library/user-event';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
CertificateProduct,
|
|
6
|
+
CourseLight,
|
|
7
|
+
OrderState,
|
|
8
|
+
PaymentScheduleState,
|
|
9
|
+
ProductType,
|
|
10
|
+
PURCHASABLE_ORDER_STATES,
|
|
11
|
+
} from 'types/Joanie';
|
|
5
12
|
import {
|
|
6
13
|
CourseStateFactory,
|
|
7
14
|
RichieContextFactory as mockRichieContextFactory,
|
|
@@ -13,6 +20,7 @@ import {
|
|
|
13
20
|
OrderEnrollmentFactory,
|
|
14
21
|
EnrollmentFactory,
|
|
15
22
|
CertificateProductFactory,
|
|
23
|
+
PaymentInstallmentFactory,
|
|
16
24
|
} from 'utils/test/factories/joanie';
|
|
17
25
|
import { Priority } from 'types';
|
|
18
26
|
import { DashboardTest } from 'widgets/Dashboard/components/DashboardTest';
|
|
@@ -43,18 +51,40 @@ jest.mock('components/SaleTunnel', () => ({
|
|
|
43
51
|
return;
|
|
44
52
|
}
|
|
45
53
|
setTimeout(() => {
|
|
46
|
-
const order = Factories.
|
|
54
|
+
const order = Factories.CertificateOrderFactory().one();
|
|
47
55
|
onFinish?.(order);
|
|
48
56
|
}, 100);
|
|
49
57
|
}, [isOpen]);
|
|
50
58
|
return <div data-testid="SaleTunnelMock" />;
|
|
51
59
|
},
|
|
52
60
|
}));
|
|
61
|
+
jest.mock('widgets/Dashboard/components/DashboardItem/Order/OrderPaymentRetryModal', () => ({
|
|
62
|
+
__esModule: true,
|
|
63
|
+
OrderPaymentRetryModal: ({ isOpen, onClose }: { isOpen: boolean; onClose: () => void }) => {
|
|
64
|
+
if (!isOpen) return null;
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<div data-testid="OrderPaymentRetryModalMock">
|
|
68
|
+
<button onClick={onClose}>Trigger Close</button>
|
|
69
|
+
</div>
|
|
70
|
+
);
|
|
71
|
+
},
|
|
72
|
+
}));
|
|
53
73
|
|
|
54
74
|
describe('<ProductCertificateFooter/>', () => {
|
|
55
75
|
let product: CertificateProduct;
|
|
56
76
|
let course: CourseLight;
|
|
57
77
|
setupJoanieSession();
|
|
78
|
+
const dateFormatter = Intl.DateTimeFormat('en', {
|
|
79
|
+
day: '2-digit',
|
|
80
|
+
month: 'short',
|
|
81
|
+
year: 'numeric',
|
|
82
|
+
});
|
|
83
|
+
const priceFormatter = (currency: string, price: number) =>
|
|
84
|
+
new Intl.NumberFormat('en', {
|
|
85
|
+
currency,
|
|
86
|
+
style: 'currency',
|
|
87
|
+
}).format(price);
|
|
58
88
|
|
|
59
89
|
beforeEach(() => {
|
|
60
90
|
product = CertificateProductFactory({ type: ProductType.CERTIFICATE }).one();
|
|
@@ -135,7 +165,7 @@ describe('<ProductCertificateFooter/>', () => {
|
|
|
135
165
|
it('should display download button for a course run with certificate.', () => {
|
|
136
166
|
const order = OrderEnrollmentFactory({
|
|
137
167
|
certificate_id: 'FAKE_CERTIFICATE_ID',
|
|
138
|
-
state: OrderState.
|
|
168
|
+
state: OrderState.COMPLETED,
|
|
139
169
|
product_id: product.id,
|
|
140
170
|
}).one();
|
|
141
171
|
const enrollment = EnrollmentFactory({
|
|
@@ -151,35 +181,23 @@ describe('<ProductCertificateFooter/>', () => {
|
|
|
151
181
|
expect(screen.queryByTestId('PurchaseButton__cta')).not.toBeInTheDocument();
|
|
152
182
|
});
|
|
153
183
|
|
|
154
|
-
it
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
certificate_id: undefined,
|
|
172
|
-
product_id: product.id,
|
|
173
|
-
state: OrderState.PENDING,
|
|
174
|
-
}).one();
|
|
175
|
-
const enrollment = EnrollmentFactory({
|
|
176
|
-
orders: [order],
|
|
177
|
-
course_run: CourseRunFactory({ course }).one(),
|
|
178
|
-
}).one();
|
|
179
|
-
render(<ProductCertificateFooter product={product} enrollment={enrollment} />);
|
|
180
|
-
expect(screen.queryByRole('button', { name: 'Download' })).not.toBeInTheDocument();
|
|
181
|
-
expect(screen.getByTestId('PurchaseButton__cta')).toBeInTheDocument();
|
|
182
|
-
});
|
|
184
|
+
it.each(PURCHASABLE_ORDER_STATES)(
|
|
185
|
+
'should display purchase button for a course run with %s order.',
|
|
186
|
+
(state) => {
|
|
187
|
+
const order = OrderEnrollmentFactory({
|
|
188
|
+
certificate_id: undefined,
|
|
189
|
+
product_id: product.id,
|
|
190
|
+
state,
|
|
191
|
+
}).one();
|
|
192
|
+
const enrollment = EnrollmentFactory({
|
|
193
|
+
orders: [order],
|
|
194
|
+
course_run: CourseRunFactory({ course }).one(),
|
|
195
|
+
}).one();
|
|
196
|
+
render(<ProductCertificateFooter product={product} enrollment={enrollment} />);
|
|
197
|
+
expect(screen.queryByRole('button', { name: 'Download' })).not.toBeInTheDocument();
|
|
198
|
+
expect(screen.getByTestId('PurchaseButton__cta')).toBeInTheDocument();
|
|
199
|
+
},
|
|
200
|
+
);
|
|
183
201
|
|
|
184
202
|
it('should not display button (download or purchase) for a course run with order but without certificate.', () => {
|
|
185
203
|
const order = OrderEnrollmentFactory({
|
|
@@ -228,7 +246,7 @@ describe('<ProductCertificateFooter/>', () => {
|
|
|
228
246
|
render(<DashboardTest initialRoute={LearnerDashboardPaths.COURSES} />, {
|
|
229
247
|
wrapper: BaseJoanieAppWrapper,
|
|
230
248
|
});
|
|
231
|
-
|
|
249
|
+
|
|
232
250
|
const user = userEvent.setup();
|
|
233
251
|
await expectNoSpinner('Loading orders and enrollments...');
|
|
234
252
|
await screen.findByRole('heading', {
|
|
@@ -243,4 +261,97 @@ describe('<ProductCertificateFooter/>', () => {
|
|
|
243
261
|
// Then the onFinish() callback of the SaleTunnel is automatically called via the mock.
|
|
244
262
|
await waitForElementToBeRemoved(screen.queryByTestId('PurchaseButton__cta'));
|
|
245
263
|
});
|
|
264
|
+
|
|
265
|
+
it.each([OrderState.PENDING, OrderState.PENDING_PAYMENT])(
|
|
266
|
+
'should display upcoming installment information if there is one (%s)',
|
|
267
|
+
(state) => {
|
|
268
|
+
const installment = PaymentInstallmentFactory({ state: PaymentScheduleState.PENDING }).one();
|
|
269
|
+
const order = OrderEnrollmentFactory({
|
|
270
|
+
certificate_id: undefined,
|
|
271
|
+
product_id: product.id,
|
|
272
|
+
state,
|
|
273
|
+
payment_schedule: [installment],
|
|
274
|
+
}).one();
|
|
275
|
+
const enrollment = EnrollmentFactory({ orders: [order] }).one();
|
|
276
|
+
|
|
277
|
+
render(<ProductCertificateFooter product={product} enrollment={enrollment} />);
|
|
278
|
+
|
|
279
|
+
if (order.state === OrderState.PENDING) {
|
|
280
|
+
// As the order is in pending state, the user should see the following message.
|
|
281
|
+
screen.getByText('You will be able to pass the exam once the installment has been paid.', {
|
|
282
|
+
exact: false,
|
|
283
|
+
});
|
|
284
|
+
} else if (order.state === OrderState.PENDING_PAYMENT) {
|
|
285
|
+
expect(
|
|
286
|
+
screen.queryByText(
|
|
287
|
+
'You will be able to pass the exam once the installment has been paid.',
|
|
288
|
+
{
|
|
289
|
+
exact: false,
|
|
290
|
+
},
|
|
291
|
+
),
|
|
292
|
+
).toBeNull();
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
const amount = priceFormatter(installment.currency, installment.amount);
|
|
296
|
+
const dueDate = dateFormatter.format(new Date(installment.due_date));
|
|
297
|
+
screen.getByText(`The next installment (${amount}) will be withdrawn on the ${dueDate}.`, {
|
|
298
|
+
exact: false,
|
|
299
|
+
collapseWhitespace: false,
|
|
300
|
+
});
|
|
301
|
+
},
|
|
302
|
+
);
|
|
303
|
+
|
|
304
|
+
it.each([OrderState.NO_PAYMENT, OrderState.FAILED_PAYMENT])(
|
|
305
|
+
'should display installment refused information if the order has one (%s)',
|
|
306
|
+
async (state) => {
|
|
307
|
+
const installment = PaymentInstallmentFactory({ state: PaymentScheduleState.REFUSED }).one();
|
|
308
|
+
const order = OrderEnrollmentFactory({
|
|
309
|
+
certificate_id: undefined,
|
|
310
|
+
product_id: product.id,
|
|
311
|
+
state,
|
|
312
|
+
payment_schedule: [installment],
|
|
313
|
+
}).one();
|
|
314
|
+
const enrollment = EnrollmentFactory({ orders: [order] }).one();
|
|
315
|
+
|
|
316
|
+
fetchMock.get(`https://joanie.endpoint/api/v1.0/orders/${order.id}/`, order);
|
|
317
|
+
|
|
318
|
+
render(<ProductCertificateFooter product={product} enrollment={enrollment} />);
|
|
319
|
+
|
|
320
|
+
if (order.state === OrderState.NO_PAYMENT) {
|
|
321
|
+
// As the order is in no_payment state, the user should see the following message.
|
|
322
|
+
screen.getByText('You will be able to pass the exam once the installment has been paid.', {
|
|
323
|
+
exact: false,
|
|
324
|
+
});
|
|
325
|
+
} else if (order.state === OrderState.FAILED_PAYMENT) {
|
|
326
|
+
expect(
|
|
327
|
+
screen.queryByText(
|
|
328
|
+
'You will be able to pass the exam once the installment has been paid.',
|
|
329
|
+
{
|
|
330
|
+
exact: false,
|
|
331
|
+
},
|
|
332
|
+
),
|
|
333
|
+
).toBeNull();
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
const amount = priceFormatter(installment.currency, installment.amount);
|
|
337
|
+
|
|
338
|
+
screen.getByText(
|
|
339
|
+
`Last direct debit has failed. Please resolve your situation as soon as possible.`,
|
|
340
|
+
);
|
|
341
|
+
const button = screen.getByRole('button', { name: `Pay ${amount}` });
|
|
342
|
+
|
|
343
|
+
expect(screen.queryByTestId('OrderPaymentRetryModalMock')).not.toBeInTheDocument();
|
|
344
|
+
const user = userEvent.setup();
|
|
345
|
+
await user.click(button);
|
|
346
|
+
|
|
347
|
+
const retryModal = screen.getByTestId('OrderPaymentRetryModalMock');
|
|
348
|
+
const closeButton = within(retryModal).getByRole('button', { name: 'Trigger Close' });
|
|
349
|
+
|
|
350
|
+
fetchMock.resetHistory();
|
|
351
|
+
// Closing the retry modal should invalidate order query.
|
|
352
|
+
await user.click(closeButton);
|
|
353
|
+
expect(fetchMock.calls()).toHaveLength(1);
|
|
354
|
+
expect(fetchMock.lastUrl()).toBe(`https://joanie.endpoint/api/v1.0/orders/${order.id}/`);
|
|
355
|
+
},
|
|
356
|
+
);
|
|
246
357
|
});
|