richie-education 2.24.0 → 2.25.0-b2.dev101
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/.eslintignore +2 -0
- package/.nvmrc +1 -1
- package/.prettierignore +2 -0
- package/.storybook/preview-body.html +1 -1
- package/.storybook/preview.tsx +5 -2
- package/cunningham.cjs +52 -43
- package/i18n/locales/ar-SA.json +500 -100
- package/i18n/locales/es-ES.json +500 -100
- package/i18n/locales/fa-IR.json +500 -100
- package/i18n/locales/fr-CA.json +564 -164
- package/i18n/locales/fr-FR.json +517 -117
- package/i18n/locales/ko-KR.json +500 -100
- package/i18n/locales/pt-PT.json +526 -126
- package/i18n/locales/ru-RU.json +500 -100
- package/i18n/locales/vi-VN.json +1734 -0
- package/jest/setup.ts +11 -1
- package/js/api/enrollment.ts +1 -1
- package/js/api/joanie.spec.ts +63 -2
- package/js/api/joanie.ts +218 -141
- package/js/api/lms/dummy.spec.ts +9 -1
- package/js/api/lms/dummy.ts +63 -10
- package/js/api/lms/joanie.spec.ts +49 -31
- package/js/api/lms/joanie.ts +53 -35
- package/js/api/lms/openedx-hawthorn.spec.ts +27 -11
- package/js/api/lms/openedx-hawthorn.ts +7 -6
- package/js/components/AddressesManagement/AddressForm/index.spec.tsx +157 -0
- package/js/components/AddressesManagement/AddressForm/index.stories.tsx +36 -0
- package/js/components/AddressesManagement/AddressForm/index.tsx +163 -0
- package/js/components/AddressesManagement/{validationSchema.ts → AddressForm/validationSchema.ts} +1 -23
- package/js/components/AddressesManagement/_styles.scss +1 -1
- package/js/components/AddressesManagement/index.spec.tsx +171 -202
- package/js/components/AddressesManagement/index.stories.tsx +29 -0
- package/js/components/AddressesManagement/index.tsx +11 -3
- package/js/components/Badge/index.spec.tsx +17 -0
- package/js/components/Badge/index.stories.tsx +22 -0
- package/js/components/Badge/index.tsx +18 -0
- package/js/components/Banner/index.tsx +6 -1
- package/js/components/ContractFrame/AbstractContractFrame.spec.tsx +332 -0
- package/js/components/ContractFrame/AbstractContractFrame.tsx +289 -0
- package/js/components/ContractFrame/LearnerContractFrame.spec.tsx +125 -0
- package/js/components/ContractFrame/LearnerContractFrame.tsx +42 -0
- package/js/components/ContractFrame/OrganizationContractFrame.spec.tsx +167 -0
- package/js/components/ContractFrame/OrganizationContractFrame.tsx +70 -0
- package/js/components/ContractFrame/_styles.scss +62 -0
- package/js/components/ContractFrame/iframe-manager.js +158 -0
- package/js/components/ContractFrame/index.ts +5 -0
- package/js/components/ContractStatus/index.spec.tsx +120 -0
- package/js/components/ContractStatus/index.tsx +67 -0
- package/js/components/CourseGlimpse/CourseGlimpseFooter.tsx +7 -7
- package/js/components/CourseGlimpse/index.tsx +5 -1
- package/js/components/CourseGlimpse/utils.ts +24 -16
- package/js/components/CourseGlimpseList/index.spec.tsx +1 -1
- package/js/components/CourseGlimpseList/index.tsx +1 -1
- package/js/components/CourseGlimpseList/utils.ts +3 -2
- package/js/components/DjangoCMSTemplate/index.spec.tsx +2 -2
- package/js/components/DownloadCertificateButton/index.tsx +58 -0
- package/js/components/DownloadContractButton/index.spec.tsx +155 -0
- package/js/components/DownloadContractButton/index.tsx +48 -0
- package/js/components/Form/CountrySelectField.tsx +28 -16
- package/js/components/Form/Input/index.spec.tsx +76 -0
- package/js/components/Form/Input/index.tsx +47 -0
- package/js/components/Form/Select/index.spec.tsx +99 -0
- package/js/components/Form/Select/index.tsx +43 -0
- package/js/components/{AddressesManagement → Form}/ValidationErrors.ts +10 -5
- package/js/components/Form/index.ts +5 -1
- package/js/components/Form/messages.ts +14 -0
- package/js/components/Form/test-utils.ts +19 -0
- package/js/components/Form/utils.spec.ts +72 -0
- package/js/components/Form/utils.ts +37 -0
- package/js/components/Icon/index.stories.tsx +2 -1
- package/js/components/Modal/_styles.scss +0 -8
- package/js/components/Modal/index.spec.tsx +0 -6
- package/js/components/Modal/index.tsx +23 -17
- package/js/components/PaymentButton/_styles.scss +26 -0
- package/js/{widgets/CourseProductItem → components/PaymentButton}/components/PaymentInterfaces/Dummy.tsx +1 -1
- package/js/{widgets/CourseProductItem → components/PaymentButton}/components/PaymentInterfaces/PayplugLightbox.tsx +30 -7
- package/js/{widgets/CourseProductItem → components/PaymentButton}/components/PaymentInterfaces/__mocks__/index.tsx +1 -1
- package/js/{widgets/CourseProductItem → components/PaymentButton}/components/PaymentInterfaces/index.spec.tsx +5 -3
- package/js/{widgets/CourseProductItem → components/PaymentButton}/components/PaymentInterfaces/index.tsx +7 -5
- package/js/components/PaymentButton/hooks/useTerms.tsx +74 -0
- package/js/components/PaymentButton/index.spec.tsx +1038 -0
- package/js/{widgets/CourseProductItem/components → components}/PaymentButton/index.tsx +94 -41
- package/js/components/PurchaseButton/index.spec.tsx +377 -0
- package/js/components/PurchaseButton/index.stories.tsx +15 -0
- package/js/{widgets/CourseProductItem/components → components}/PurchaseButton/index.tsx +72 -23
- package/js/components/PurchaseButton/styles.scss +7 -0
- package/js/components/RegisteredAddress/_styles.scss +1 -3
- package/js/components/RegisteredAddress/index.spec.tsx +1 -1
- package/js/components/RegisteredAddress/index.stories.tsx +40 -0
- package/js/components/RegisteredAddress/index.tsx +17 -19
- package/js/components/SaleTunnel/_styles.scss +11 -0
- package/js/{widgets/CourseProductItem → components/SaleTunnel}/components/RegisteredCreditCard/index.tsx +4 -10
- package/js/{widgets/CourseProductItem → components/SaleTunnel}/components/SaleTunnelStepPayment/_styles.scss +7 -0
- package/js/{widgets/CourseProductItem → components/SaleTunnel}/components/SaleTunnelStepPayment/index.spec.tsx +85 -61
- package/js/{widgets/CourseProductItem → components/SaleTunnel}/components/SaleTunnelStepPayment/index.tsx +55 -57
- package/js/components/SaleTunnel/components/SaleTunnelStepResume/_styles.scss +63 -0
- package/js/components/SaleTunnel/components/SaleTunnelStepResume/index.spec.tsx +80 -0
- package/js/components/SaleTunnel/components/SaleTunnelStepResume/index.tsx +88 -0
- package/js/{widgets/CourseProductItem → components/SaleTunnel}/components/SaleTunnelStepValidation/CourseRunsList.tsx +6 -2
- package/js/{widgets/CourseProductItem → components/SaleTunnel}/components/SaleTunnelStepValidation/_styles.scss +5 -0
- package/js/components/SaleTunnel/components/SaleTunnelStepValidation/index.spec.tsx +170 -0
- package/js/{widgets/CourseProductItem → components/SaleTunnel}/components/SaleTunnelStepValidation/index.tsx +41 -10
- package/js/{widgets/CourseProductItem → components/SaleTunnel}/components/StepBreadcrumb/index.spec.tsx +1 -1
- package/js/{widgets/CourseProductItem → components/SaleTunnel}/components/StepBreadcrumb/index.tsx +1 -1
- package/js/components/SaleTunnel/context.tsx +44 -0
- package/js/{widgets/CourseProductItem/components → components}/SaleTunnel/index.spec.tsx +27 -22
- package/js/{widgets/CourseProductItem/components → components}/SaleTunnel/index.tsx +96 -24
- package/js/components/SignContractButton/index.omniscientOrders.spec.tsx +135 -0
- package/js/components/SignContractButton/index.spec.tsx +213 -0
- package/js/components/SignContractButton/index.tsx +97 -0
- package/js/components/SuccessIcon/_styles.scss +66 -0
- package/js/components/SuccessIcon/index.tsx +10 -0
- package/js/components/TeacherDashboardCourseList/_styles.scss +0 -1
- package/js/components/TeacherDashboardCourseList/index.spec.tsx +9 -9
- package/js/components/TeacherDashboardCourseList/index.tsx +25 -31
- package/js/contexts/JoanieApiContext/index.spec.tsx +1 -1
- package/js/contexts/SessionContext/BaseSessionProvider.tsx +12 -22
- package/js/contexts/SessionContext/JoanieSessionProvider.spec.tsx +14 -0
- package/js/contexts/SessionContext/JoanieSessionProvider.tsx +33 -34
- package/js/contexts/SessionContext/index.spec.tsx +6 -7
- package/js/hooks/useBreadcrumbsPlaceholders.tsx +1 -1
- package/js/hooks/useContractAbilities/index.spec.ts +27 -0
- package/js/hooks/useContractAbilities/index.ts +8 -0
- package/js/hooks/useContractArchive/index.download.spec.tsx +126 -0
- package/js/hooks/useContractArchive/index.spec.tsx +91 -0
- package/js/hooks/useContractArchive/index.ts +64 -0
- package/js/hooks/useContracts/index.tsx +68 -0
- package/js/hooks/useCourseProductRelation/index.ts +8 -5
- package/js/hooks/useCourseProductUnion/index.spec.tsx +14 -10
- package/js/hooks/useCourseProductUnion/index.ts +6 -2
- package/js/hooks/useCourseProducts.ts +45 -0
- package/js/hooks/useCourseSearchParams/computeNewFilterValue.ts +3 -3
- package/js/hooks/useCourses/index.spec.tsx +2 -2
- package/js/hooks/useCourses/index.ts +4 -4
- package/js/hooks/useCreditCards/index.spec.tsx +4 -4
- package/js/hooks/useDashboardAddressForm.tsx +85 -87
- package/js/hooks/useDownloadCertificate/index.spec.tsx +19 -6
- package/js/hooks/useDownloadCertificate/index.tsx +2 -20
- package/js/hooks/useEnrollments.ts +1 -1
- package/js/hooks/useJoanieUserAbilities/index.not.isJoanieEnabled.spec.tsx +17 -0
- package/js/hooks/useJoanieUserAbilities/index.spec.tsx +68 -0
- package/js/hooks/useJoanieUserAbilities/index.tsx +11 -0
- package/js/hooks/useJoanieUserProfile.tsx +34 -0
- package/js/hooks/useOrders.ts +69 -26
- package/js/hooks/useOrganizations/index.ts +1 -1
- package/js/hooks/useProductOrder/index.spec.tsx +113 -0
- package/js/hooks/useProductOrder/index.tsx +33 -0
- package/js/hooks/useQueryKeyInvalidateListener.tsx +16 -0
- package/js/hooks/useResources/index.spec.tsx +30 -29
- package/js/hooks/useResources/index.tsx +11 -4
- package/js/hooks/useResources/useResourcesOmniscient.ts +2 -2
- package/js/hooks/useResources/useResourcesRoot.ts +21 -17
- package/js/hooks/useTeacherPendingContractsCount/index.ts +34 -0
- package/js/hooks/useUnionResource/index.spec.tsx +5 -2
- package/js/hooks/useUnionResource/index.ts +20 -3
- package/js/hooks/useUnionResource/utils/fetchEntity.ts +5 -4
- package/js/index.tsx +2 -2
- package/js/pages/DashboardAddressesManagement/DashboardAddressBox.tsx +1 -1
- package/js/pages/DashboardAddressesManagement/DashboardCreateAddress.spec.tsx +79 -72
- package/js/pages/DashboardAddressesManagement/DashboardCreateAddress.tsx +4 -4
- package/js/pages/DashboardAddressesManagement/DashboardEditAddress.spec.tsx +32 -23
- package/js/pages/DashboardAddressesManagement/DashboardEditAddress.tsx +6 -6
- package/js/pages/DashboardAddressesManagement/DashboardEditAddressLoader.tsx +2 -2
- package/js/pages/DashboardAddressesManagement/index.spec.tsx +4 -3
- package/js/pages/DashboardAddressesManagement/index.tsx +5 -5
- package/js/pages/DashboardCertificates/index.spec.tsx +3 -2
- package/js/pages/DashboardCertificates/index.tsx +2 -1
- package/js/pages/DashboardContracts/_styles.scss +8 -0
- package/js/pages/DashboardContracts/index.spec.tsx +147 -0
- package/js/pages/DashboardContracts/index.tsx +76 -0
- package/js/pages/DashboardCourses/index.spec.tsx +81 -61
- package/js/pages/DashboardCourses/index.tsx +15 -12
- package/js/pages/DashboardCourses/useOrdersEnrollments.tsx +34 -8
- package/js/pages/DashboardCreditCardsManagement/DashboardCreditCardBox.tsx +1 -1
- package/js/pages/DashboardCreditCardsManagement/DashboardEditCreditCard.spec.tsx +7 -6
- package/js/pages/DashboardCreditCardsManagement/DashboardEditCreditCard.tsx +43 -45
- package/js/pages/DashboardCreditCardsManagement/DashboardEditCreditCardLoader.tsx +2 -2
- package/js/pages/DashboardCreditCardsManagement/index.spec.tsx +13 -12
- package/js/pages/DashboardCreditCardsManagement/index.tsx +3 -3
- package/js/pages/DashboardOrderLayout/_styles.scss +5 -0
- package/js/pages/DashboardOrderLayout/index.spec.tsx +8 -8
- package/js/pages/DashboardOrderLayout/index.tsx +11 -6
- package/js/pages/TeacherDashboardContractsLayout/TeacherDashboardContracts/index.spec.tsx +358 -0
- package/js/pages/TeacherDashboardContractsLayout/TeacherDashboardContracts/index.tsx +129 -0
- package/js/pages/TeacherDashboardContractsLayout/TeacherDashboardCourseContractsLayout/index.tsx +26 -0
- package/js/pages/TeacherDashboardContractsLayout/TeacherDashboardOrganizationContractsLayout/index.tsx +26 -0
- package/js/pages/TeacherDashboardContractsLayout/components/BulkDownloadContractButton/index.spec.tsx +136 -0
- package/js/pages/TeacherDashboardContractsLayout/components/BulkDownloadContractButton/index.timer.spec.tsx +144 -0
- package/js/pages/TeacherDashboardContractsLayout/components/BulkDownloadContractButton/index.tsx +73 -0
- package/js/pages/TeacherDashboardContractsLayout/components/ContractActionsBar/index.spec.tsx +185 -0
- package/js/pages/TeacherDashboardContractsLayout/components/ContractActionsBar/index.tsx +47 -0
- package/js/pages/TeacherDashboardContractsLayout/components/ContractFiltersBar/index.spec.tsx +179 -0
- package/js/pages/TeacherDashboardContractsLayout/components/ContractFiltersBar/index.tsx +86 -0
- package/js/pages/TeacherDashboardContractsLayout/components/SignOrganizationContractButton/index.spec.tsx +109 -0
- package/js/pages/TeacherDashboardContractsLayout/components/SignOrganizationContractButton/index.tsx +60 -0
- package/js/pages/TeacherDashboardContractsLayout/hooks/useCheckContractArchiveExists/index.spec.tsx +124 -0
- package/js/pages/TeacherDashboardContractsLayout/hooks/useCheckContractArchiveExists/index.tsx +73 -0
- package/js/pages/TeacherDashboardContractsLayout/hooks/useDefaultOrganizationId/index.spec.tsx +134 -0
- package/js/pages/TeacherDashboardContractsLayout/hooks/useDefaultOrganizationId/index.tsx +28 -0
- package/js/pages/TeacherDashboardContractsLayout/hooks/useDownloadContractArchive/contractArchiveLocalStorage.spec.ts +85 -0
- package/js/pages/TeacherDashboardContractsLayout/hooks/useDownloadContractArchive/contractArchiveLocalStorage.ts +50 -0
- package/js/pages/TeacherDashboardContractsLayout/hooks/useDownloadContractArchive/index.spec.tsx +266 -0
- package/js/pages/TeacherDashboardContractsLayout/hooks/useDownloadContractArchive/index.tsx +153 -0
- package/js/pages/TeacherDashboardContractsLayout/hooks/useHasContractToDownload/index.spec.tsx +100 -0
- package/js/pages/TeacherDashboardContractsLayout/hooks/useHasContractToDownload/index.tsx +27 -0
- package/js/pages/TeacherDashboardContractsLayout/hooks/useTeacherContractFilters/index.spec.tsx +193 -0
- package/js/pages/TeacherDashboardContractsLayout/hooks/useTeacherContractFilters/index.tsx +44 -0
- package/js/pages/TeacherDashboardContractsLayout/hooks/useTeacherContractsToSign.tsx +32 -0
- package/js/pages/TeacherDashboardContractsLayout/index.ts +2 -0
- package/js/pages/TeacherDashboardContractsLayout/styles.scss +15 -0
- package/js/pages/{TeacherCourseDashboardLoader → TeacherDashboardCourseLoader}/CourseRunList/CourseRunListCell/index.spec.tsx +1 -1
- package/js/pages/{TeacherCourseDashboardLoader → TeacherDashboardCourseLoader}/CourseRunList/_styles.scss +1 -2
- package/js/pages/{TeacherCourseDashboardLoader → TeacherDashboardCourseLoader}/CourseRunList/index.spec.tsx +2 -2
- package/js/pages/{TeacherCourseDashboardLoader → TeacherDashboardCourseLoader}/CourseRunList/utils.spec.tsx +1 -1
- package/js/pages/{TeacherCourseDashboardLoader → TeacherDashboardCourseLoader}/CourseRunList/utils.tsx +11 -10
- package/js/pages/{TeacherCourseDashboardLoader → TeacherDashboardCourseLoader}/index.tsx +9 -8
- package/js/pages/{TeacherCoursesDashboardLoader → TeacherDashboardCoursesLoader}/index.spec.tsx +17 -17
- package/js/pages/{TeacherCoursesDashboardLoader → TeacherDashboardCoursesLoader}/index.tsx +7 -7
- package/js/pages/{TeacherOrganizationCourseDashboardLoader → TeacherDashboardOrganizationCourseLoader}/index.tsx +5 -5
- package/js/pages/{TeacherTrainingDashboard/TeacherTrainingDashboardLoader.tsx → TeacherDashboardTraining/TeacherDashboardTrainingLoader.tsx} +10 -9
- package/js/pages/{TeacherTrainingDashboard → TeacherDashboardTraining}/index.spec.tsx +76 -6
- package/js/pages/{TeacherTrainingDashboard → TeacherDashboardTraining}/index.tsx +6 -6
- package/js/settings.dev.dist.ts +3 -0
- package/js/settings.ts +29 -1
- 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 -0
- package/js/types/Joanie.ts +263 -80
- package/js/types/Suggestion.ts +2 -2
- package/js/types/User.ts +19 -1
- package/js/types/commonDataProps.ts +3 -0
- package/js/types/index.ts +1 -1
- package/js/utils/AbilitiesHelper/contractAbilities.spec.ts +35 -0
- package/js/utils/AbilitiesHelper/contractAbilities.ts +14 -0
- package/js/utils/AbilitiesHelper/index.ts +71 -0
- package/js/utils/AbilitiesHelper/joanieUserProfileAbilities.spec.ts +55 -0
- package/js/utils/AbilitiesHelper/joanieUserProfileAbilities.ts +16 -0
- package/js/utils/AbilitiesHelper/types.ts +36 -0
- package/js/utils/ContractHelper/index.spec.ts +73 -0
- package/js/utils/ContractHelper/index.ts +72 -0
- package/js/utils/CourseRuns/index.spec.tsx +20 -1
- package/js/utils/CourseRuns/index.ts +14 -2
- package/js/utils/CoursesHelper/index.spec.ts +45 -55
- package/js/utils/CoursesHelper/index.ts +6 -7
- package/js/utils/CreditCardHelper/index.spec.tsx +26 -22
- package/js/utils/CreditCardHelper/index.tsx +19 -6
- package/js/utils/ObjectHelper/index.spec.ts +18 -10
- package/js/utils/ObjectHelper/index.ts +9 -0
- package/js/utils/OrderHelper/index.ts +32 -0
- package/js/utils/ProductHelper/index.ts +5 -1
- package/js/utils/StringHelper/index.spec.tsx +11 -0
- package/js/utils/StringHelper/index.ts +8 -0
- package/js/utils/UserHelper/index.spec.ts +18 -0
- package/js/utils/UserHelper/index.ts +8 -0
- package/js/utils/download.ts +43 -0
- package/js/utils/errors/HttpError.ts +10 -0
- package/js/utils/indirection/window.ts +1 -1
- package/js/utils/react-query/createQueryClient.ts +12 -21
- package/js/utils/react-query/useLocalizedQueryKey.ts +1 -1
- package/js/utils/react-query/useSessionMutation/index.spec.tsx +8 -8
- package/js/utils/react-query/useSessionMutation/index.ts +6 -11
- package/js/utils/react-query/useSessionQuery/index.spec.tsx +36 -8
- package/js/utils/react-query/useSessionQuery/index.ts +14 -21
- package/js/utils/search/getSuggestionsSection/index.spec.ts +4 -3
- package/js/utils/search/getSuggestionsSection/index.ts +4 -1
- package/js/utils/search/index.tsx +8 -3
- package/js/utils/test/createTestQueryClient.ts +7 -7
- package/js/utils/test/expectBanner.ts +16 -3
- package/js/utils/test/factories/factories.ts +4 -4
- package/js/utils/test/factories/joanie.spec.ts +7 -0
- package/js/utils/test/factories/joanie.ts +214 -63
- package/js/utils/test/factories/reactQuery.ts +1 -1
- package/js/utils/test/factories/richie.ts +4 -2
- package/js/utils/test/mockCourseProductWithOrder.ts +28 -0
- package/js/utils/test/mockPaginatedResponse.ts +1 -1
- package/js/utils/test/render.tsx +72 -0
- package/js/utils/test/wrappers/IntlWrapper.tsx +23 -0
- package/js/utils/test/wrappers/JoanieAppWrapper.tsx +42 -0
- package/js/utils/test/wrappers/PresentationalAppWrapper.tsx +18 -0
- package/js/utils/test/wrappers/ReactQueryWrapper.tsx +16 -0
- package/js/utils/test/wrappers/RouterWrapper.tsx +29 -0
- package/js/utils/test/wrappers/types.ts +26 -0
- package/js/widgets/Dashboard/components/DashboardAvatar/_styles.scss +17 -5
- package/js/widgets/Dashboard/components/DashboardAvatar/index.spec.tsx +9 -2
- package/js/widgets/Dashboard/components/DashboardAvatar/index.tsx +16 -5
- package/js/widgets/Dashboard/components/DashboardBox/index.stories.tsx +1 -1
- package/js/widgets/Dashboard/components/DashboardBreadcrumbs/_styles.scss +1 -0
- package/js/widgets/Dashboard/components/DashboardBreadcrumbs/index.tsx +7 -4
- package/js/widgets/Dashboard/components/DashboardCard/index.spec.tsx +1 -1
- package/js/widgets/Dashboard/components/DashboardCard/index.stories.tsx +3 -3
- package/js/widgets/Dashboard/components/DashboardCard/index.tsx +2 -2
- package/js/widgets/Dashboard/components/DashboardItem/Certificate/index.spec.tsx +49 -9
- package/js/widgets/Dashboard/components/DashboardItem/Certificate/index.tsx +27 -73
- package/js/widgets/Dashboard/components/DashboardItem/CertificateStatus/index.spec.tsx +65 -0
- package/js/widgets/Dashboard/components/DashboardItem/CertificateStatus/index.tsx +59 -0
- package/js/widgets/Dashboard/components/DashboardItem/Contract/_styles.scss +29 -0
- package/js/widgets/Dashboard/components/DashboardItem/Contract/index.spec.tsx +197 -0
- package/js/widgets/Dashboard/components/DashboardItem/Contract/index.stories.tsx +34 -0
- package/js/widgets/Dashboard/components/DashboardItem/Contract/index.tsx +53 -0
- package/js/widgets/Dashboard/components/DashboardItem/CourseEnrolling/hooks/useCourseRunPeriodMessage.ts +76 -0
- package/js/widgets/Dashboard/components/DashboardItem/CourseEnrolling/index.spec.tsx +158 -0
- package/js/widgets/Dashboard/components/DashboardItem/{DashboardItemCourseEnrolling.stories.tsx → CourseEnrolling/index.stories.tsx} +6 -6
- package/js/widgets/Dashboard/components/DashboardItem/{DashboardItemCourseEnrolling.tsx → CourseEnrolling/index.tsx} +141 -84
- package/js/widgets/Dashboard/components/DashboardItem/Enrollment/DashboardItemEnrollment.spec.tsx +40 -37
- package/js/widgets/Dashboard/components/DashboardItem/Enrollment/DashboardItemEnrollment.tsx +29 -11
- package/js/widgets/Dashboard/components/DashboardItem/Enrollment/ProductCertificateFooter/index.spec.tsx +248 -0
- package/js/widgets/Dashboard/components/DashboardItem/Enrollment/ProductCertificateFooter/index.tsx +89 -0
- package/js/widgets/Dashboard/components/DashboardItem/Order/DashboardItemOrder.spec.tsx +188 -117
- package/js/widgets/Dashboard/components/DashboardItem/Order/DashboardItemOrder.tsx +124 -78
- package/js/widgets/Dashboard/components/DashboardItem/Order/DashboardItemOrderContract.spec.tsx +299 -0
- package/js/widgets/Dashboard/components/DashboardItem/Order/DashboardItemOrderContract.useUnionResource.cache.spec.tsx +286 -0
- package/js/widgets/Dashboard/components/DashboardItem/Order/DashboardItemOrderReadonly.stories.tsx +9 -5
- package/js/widgets/Dashboard/components/DashboardItem/Order/DashboardItemOrderWritable.stories.tsx +10 -6
- package/js/widgets/Dashboard/components/DashboardItem/Order/OrderStateMessage/index.spec.tsx +121 -0
- package/js/widgets/Dashboard/components/DashboardItem/Order/OrderStateMessage/index.tsx +98 -0
- package/js/widgets/Dashboard/components/DashboardItem/Order/_styles.scss +43 -0
- package/js/widgets/Dashboard/components/DashboardItem/_styles.scss +34 -37
- package/js/widgets/Dashboard/components/DashboardItem/index.spec.tsx +74 -4
- package/js/widgets/Dashboard/components/DashboardItem/index.stories.tsx +18 -0
- package/js/widgets/Dashboard/components/DashboardItem/index.tsx +91 -26
- package/js/widgets/Dashboard/components/DashboardItem/stories.mock.ts +4 -8
- package/js/widgets/Dashboard/components/DashboardLayout/_styles.scss +14 -5
- package/js/widgets/Dashboard/components/DashboardLayout/index.tsx +10 -3
- package/js/widgets/Dashboard/components/DashboardListAvatar/_styles.scss +8 -0
- package/js/widgets/Dashboard/components/DashboardListAvatar/index.tsx +11 -0
- package/js/widgets/Dashboard/components/DashboardOrderLoader/_styles.scss +5 -0
- package/js/widgets/Dashboard/components/DashboardOrderLoader/index.tsx +50 -14
- package/js/widgets/Dashboard/components/DashboardSidebar/_styles.scss +37 -24
- package/js/widgets/Dashboard/components/DashboardSidebar/components/ContractNavLink/index.spec.tsx +244 -0
- package/js/widgets/Dashboard/components/DashboardSidebar/components/ContractNavLink/index.tsx +49 -0
- package/js/widgets/Dashboard/components/DashboardSidebar/components/MenuNavLink/index.spec.tsx +40 -0
- package/js/widgets/Dashboard/components/DashboardSidebar/components/MenuNavLink/index.tsx +28 -0
- package/js/widgets/Dashboard/components/DashboardSidebar/components/NavigationSelect.tsx +58 -0
- package/js/widgets/Dashboard/components/DashboardSidebar/index.stories.tsx +11 -1
- package/js/widgets/Dashboard/components/DashboardSidebar/index.tsx +18 -69
- package/js/widgets/Dashboard/components/DashboardSidebar/utils.ts +6 -0
- package/js/widgets/Dashboard/components/FilterOrganization/index.tsx +58 -0
- package/js/widgets/Dashboard/components/FiltersBar/index.tsx +9 -0
- package/js/widgets/Dashboard/components/LearnerDashboardSidebar/index.tsx +4 -2
- package/js/widgets/Dashboard/components/NavigateWithParams/index.spec.tsx +31 -40
- package/js/widgets/Dashboard/components/RouterButton/index.tsx +2 -1
- package/js/widgets/Dashboard/components/Signature/DummyContractPlaceholder.tsx +25 -0
- package/js/widgets/Dashboard/components/Signature/SignatureDummy.tsx +58 -0
- package/js/widgets/Dashboard/components/Signature/SignatureLexPersona.tsx +72 -0
- package/js/widgets/Dashboard/components/TeacherDashboardCourseSidebar/index.spec.tsx +215 -0
- package/js/widgets/Dashboard/components/{TeacherCourseDashboardSidebar → TeacherDashboardCourseSidebar}/index.tsx +75 -31
- package/js/widgets/Dashboard/components/TeacherDashboardCourseSidebar/utils.ts +23 -0
- package/js/widgets/Dashboard/components/TeacherDashboardOrganizationSidebar/index.spec.tsx +154 -0
- package/js/widgets/Dashboard/components/TeacherDashboardOrganizationSidebar/index.stories.tsx +42 -0
- package/js/widgets/Dashboard/components/{TeacherOrganizationDashboardSidebar → TeacherDashboardOrganizationSidebar}/index.tsx +40 -29
- package/js/widgets/Dashboard/components/{TeacherProfileDashboardSidebar → TeacherDashboardProfileSidebar}/components/OrganizationLinks/_styles.scss +27 -10
- package/js/widgets/Dashboard/components/TeacherDashboardProfileSidebar/components/OrganizationLinks/index.spec.tsx +49 -0
- package/js/widgets/Dashboard/components/{TeacherProfileDashboardSidebar → TeacherDashboardProfileSidebar}/components/OrganizationLinks/index.tsx +18 -7
- package/js/widgets/Dashboard/components/{TeacherProfileDashboardSidebar → TeacherDashboardProfileSidebar}/index.spec.tsx +13 -39
- package/js/widgets/Dashboard/components/{TeacherProfileDashboardSidebar → TeacherDashboardProfileSidebar}/index.stories.tsx +5 -5
- package/js/widgets/Dashboard/components/{TeacherProfileDashboardSidebar → TeacherDashboardProfileSidebar}/index.tsx +4 -3
- package/js/widgets/Dashboard/hooks/useEnroll/index.ts +8 -8
- package/js/widgets/Dashboard/index.spec.tsx +22 -12
- package/js/widgets/Dashboard/utils/learnerRouteMessages.tsx +12 -1
- package/js/widgets/Dashboard/utils/learnerRoutes.tsx +6 -0
- package/js/widgets/Dashboard/utils/teacherRouteMessages.tsx +60 -4
- package/js/widgets/Dashboard/utils/teacherRoutes.tsx +87 -13
- package/js/widgets/LtiConsumer/index.spec.tsx +44 -33
- package/js/widgets/LtiConsumer/index.tsx +11 -15
- package/js/widgets/Search/components/SearchFilterGroup/index.spec.tsx +0 -5
- package/js/widgets/Search/components/SearchFilterGroupModal/_styles.scss +0 -9
- package/js/widgets/Search/components/SearchFilterGroupModal/index.spec.tsx +0 -5
- package/js/widgets/Search/components/SearchFilterGroupModal/index.tsx +86 -60
- package/js/widgets/Search/components/SearchFilterValueParent/index.stories.tsx +51 -0
- package/js/widgets/Search/components/SearchFilterValueParent/index.tsx +7 -7
- package/js/widgets/Search/components/SearchFiltersPane/_styles.scss +2 -16
- package/js/widgets/Search/components/SearchFiltersPane/index.tsx +9 -6
- package/js/widgets/Search/hooks/useCourseSearch/index.ts +13 -7
- package/js/widgets/Search/index.spec.tsx +3 -2
- package/js/widgets/Search/utils/getResourceList/index.spec.ts +12 -5
- package/js/widgets/Search/utils/getResourceList/index.ts +6 -2
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/CourseProductItemFooter/index.tsx +74 -0
- package/js/widgets/{CourseProductItem → SyllabusCourseRunsList/components/CourseProductItem}/_styles.scss +11 -14
- package/js/widgets/{CourseProductItem → SyllabusCourseRunsList/components/CourseProductItem}/components/CourseProductCertificateItem/_styles.scss +1 -1
- package/js/widgets/{CourseProductItem → SyllabusCourseRunsList/components/CourseProductItem}/components/CourseProductCertificateItem/index.spec.tsx +13 -2
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/components/CourseProductCertificateItem/index.stories.tsx +33 -0
- package/js/widgets/{CourseProductItem → SyllabusCourseRunsList/components/CourseProductItem}/components/CourseProductCertificateItem/index.tsx +5 -8
- package/js/widgets/{CourseProductItem → SyllabusCourseRunsList/components/CourseProductItem}/components/CourseProductCourseRuns/CourseRunList.tsx +1 -1
- package/js/widgets/{CourseProductItem → SyllabusCourseRunsList/components/CourseProductItem}/components/CourseProductCourseRuns/EnrollableCourseRunList.tsx +16 -8
- package/js/widgets/{CourseProductItem → SyllabusCourseRunsList/components/CourseProductItem}/components/CourseProductCourseRuns/EnrolledCourseRun.tsx +5 -3
- package/js/widgets/{CourseProductItem → SyllabusCourseRunsList/components/CourseProductItem}/components/CourseProductCourseRuns/_styles.scss +1 -0
- package/js/widgets/{CourseProductItem → SyllabusCourseRunsList/components/CourseProductItem}/components/CourseProductCourseRuns/index.spec.tsx +100 -35
- package/js/widgets/{CourseProductItem → SyllabusCourseRunsList/components/CourseProductItem}/components/CourseRunItem/index.spec.tsx +7 -4
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/components/CourseRunItem/index.stories.tsx +36 -0
- package/js/widgets/{CourseProductItem → SyllabusCourseRunsList/components/CourseProductItem}/components/CourseRunItem/index.tsx +5 -3
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/components/ProductSignatureHeader/index.tsx +40 -0
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/index.spec.tsx +898 -0
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/index.stories.tsx +83 -0
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/index.tsx +253 -0
- package/js/widgets/SyllabusCourseRunsList/components/CourseRunEnrollment/CourseRunUnenrollmentButton/index.tsx +3 -2
- package/js/widgets/SyllabusCourseRunsList/components/CourseRunEnrollment/_styles.scss +0 -25
- package/js/widgets/SyllabusCourseRunsList/components/CourseRunEnrollment/index.joanie.spec.tsx +73 -30
- package/js/widgets/SyllabusCourseRunsList/components/CourseRunEnrollment/index.openedx.spec.tsx +10 -5
- package/js/widgets/SyllabusCourseRunsList/components/CourseRunEnrollment/index.tsx +54 -26
- package/js/widgets/SyllabusCourseRunsList/components/CourseRunItemWithEnrollment/index.tsx +1 -0
- package/js/widgets/SyllabusCourseRunsList/components/CourseWishButton/_styles.scss +0 -3
- package/js/widgets/SyllabusCourseRunsList/components/CourseWishButton/hooks/useCourseWish/index.spec.tsx +12 -9
- package/js/widgets/SyllabusCourseRunsList/components/CourseWishButton/index.login.spec.tsx +14 -12
- package/js/widgets/SyllabusCourseRunsList/components/CourseWishButton/index.logout.spec.tsx +4 -6
- package/js/widgets/SyllabusCourseRunsList/components/CourseWishButton/index.tsx +5 -5
- package/js/widgets/SyllabusCourseRunsList/components/SyllabusAsideList/index.tsx +2 -2
- package/js/widgets/SyllabusCourseRunsList/components/SyllabusCourseRun/index.tsx +19 -13
- package/js/widgets/SyllabusCourseRunsList/components/SyllabusSimpleCourseRunsList/index.tsx +1 -0
- package/js/widgets/SyllabusCourseRunsList/hooks/useCourseEnrollment/index.spec.tsx +2 -1
- package/js/widgets/SyllabusCourseRunsList/hooks/useCourseEnrollment/index.ts +14 -19
- package/js/widgets/SyllabusCourseRunsList/index.spec.tsx +54 -14
- package/js/widgets/SyllabusCourseRunsList/index.tsx +5 -8
- package/js/widgets/UserLogin/components/UserMenu/DesktopUserMenu.tsx +2 -1
- package/js/widgets/UserLogin/components/UserMenu/MobileUserMenu.tsx +2 -1
- package/js/widgets/UserLogin/components/UserMenu/index.tsx +6 -5
- package/js/widgets/UserLogin/index.not.isJoanieEnabled.spec.tsx +120 -0
- package/js/widgets/UserLogin/index.spec.tsx +108 -43
- package/js/widgets/UserLogin/index.stories.tsx +29 -0
- package/js/widgets/UserLogin/index.tsx +33 -15
- package/js/widgets/index.tsx +3 -6
- package/mocks/browser.ts +1 -1
- package/mocks/handlers/contracts.ts +16 -0
- package/mocks/handlers.ts +3 -1
- package/package.json +82 -78
- package/scss/_main.scss +2 -0
- package/scss/colors/_palette.scss +2 -2
- package/scss/colors/_theme.scss +6 -16
- package/scss/components/_content.scss +1 -1
- package/scss/components/_index.scss +24 -14
- package/scss/generic/_type.scss +1 -1
- package/scss/objects/_characteristics.scss +7 -14
- package/scss/objects/_course_glimpses.scss +3 -7
- package/scss/objects/_dashboard.scss +28 -0
- package/scss/objects/_form.scss +14 -355
- package/scss/objects/_index.scss +1 -0
- package/scss/objects/_list.scss +8 -0
- package/scss/objects/_organization_glimpses.scss +2 -8
- package/scss/objects/_selector.scss +1 -0
- package/scss/trumps/_bootstrap.scss +4 -0
- package/scss/vendors/css/cunningham-tokens.css +89 -25
- package/scss/vendors/cunningham-tokens.scss +208 -128
- package/js/components/AddressesManagement/AddressForm.spec.tsx +0 -206
- package/js/components/AddressesManagement/AddressForm.tsx +0 -169
- package/js/components/Button/index.spec.tsx +0 -36
- package/js/components/Button/index.stories.tsx +0 -26
- package/js/components/Button/index.tsx +0 -38
- package/js/components/Form/CheckboxField.stories.tsx +0 -12
- package/js/components/Form/Field.stories.config.tsx +0 -24
- package/js/components/Form/Inputs.tsx +0 -295
- package/js/components/Form/RadioField.stories.tsx +0 -18
- package/js/components/Form/SelectField.stories.tsx +0 -27
- package/js/components/Form/TextAreaField.stories.tsx +0 -12
- package/js/components/Form/TextField.stories.tsx +0 -12
- package/js/components/Form/index.spec.tsx +0 -297
- package/js/hooks/useProduct.ts +0 -28
- package/js/utils/test/mockProductWithOrder.ts +0 -17
- package/js/widgets/CourseProductItem/components/PaymentButton/_styles.scss +0 -12
- package/js/widgets/CourseProductItem/components/PaymentButton/index.spec.tsx +0 -473
- package/js/widgets/CourseProductItem/components/PurchaseButton/index.spec.tsx +0 -259
- package/js/widgets/CourseProductItem/components/SaleTunnel/_styles.scss +0 -41
- package/js/widgets/CourseProductItem/components/SaleTunnelStepResume/_styles.scss +0 -130
- package/js/widgets/CourseProductItem/components/SaleTunnelStepResume/index.spec.tsx +0 -29
- package/js/widgets/CourseProductItem/components/SaleTunnelStepResume/index.tsx +0 -59
- package/js/widgets/CourseProductItem/components/SaleTunnelStepValidation/index.spec.tsx +0 -71
- package/js/widgets/CourseProductItem/contexts/CourseProductContext/index.spec.tsx +0 -35
- package/js/widgets/CourseProductItem/contexts/CourseProductContext/index.tsx +0 -45
- package/js/widgets/CourseProductItem/index.spec.tsx +0 -486
- package/js/widgets/CourseProductItem/index.tsx +0 -205
- package/js/widgets/Dashboard/components/DashboardItem/DashboardItemCourseEnrolling.spec.tsx +0 -64
- package/js/widgets/Dashboard/components/TeacherCourseDashboardSidebar/index.spec.tsx +0 -105
- package/js/widgets/Dashboard/components/TeacherOrganizationDashboardSidebar/index.stories.tsx +0 -28
- /package/js/components/AddressesManagement/{validationSchema.spec.ts → AddressForm/validationSchema.spec.ts} +0 -0
- /package/js/{widgets/CourseProductItem/components → components}/EnrollmentDate/index.tsx +0 -0
- /package/js/{widgets/CourseProductItem → components/SaleTunnel}/components/RegisteredCreditCard/_styles.scss +0 -0
- /package/js/{widgets/CourseProductItem → components/SaleTunnel}/components/RegisteredCreditCard/index.spec.tsx +0 -0
- /package/js/{widgets/CourseProductItem → components/SaleTunnel}/components/SaleTunnelStepValidation/TargetCourseDetail.tsx +0 -0
- /package/js/{widgets/CourseProductItem → components/SaleTunnel}/components/StepBreadcrumb/_styles.scss +0 -0
- /package/js/{widgets/CourseProductItem/hooks → hooks}/useStepManager/index.spec.ts +0 -0
- /package/js/{widgets/CourseProductItem/hooks → hooks}/useStepManager/index.ts +0 -0
- /package/js/pages/{TeacherCourseDashboardLoader → TeacherDashboardCourseLoader}/CourseRunList/CourseRunListCell/index.tsx +0 -0
- /package/js/pages/{TeacherCourseDashboardLoader → TeacherDashboardCourseLoader}/CourseRunList/index.tsx +0 -0
- /package/js/pages/{TeacherTrainingDashboard → TeacherDashboardTraining}/_styles.scss +0 -0
- /package/js/widgets/Dashboard/components/{TeacherCourseDashboardSidebar → TeacherDashboardCourseSidebar}/_styles.scss +0 -0
- /package/js/widgets/{CourseProductItem → SyllabusCourseRunsList/components/CourseProductItem}/components/CourseProductCourseRuns/CourseRunSection.tsx +0 -0
- /package/js/widgets/{CourseProductItem → SyllabusCourseRunsList/components/CourseProductItem}/components/CourseProductCourseRuns/index.tsx +0 -0
- /package/js/widgets/{CourseProductItem → SyllabusCourseRunsList/components/CourseProductItem}/types/payments/payplug.d.ts +0 -0
|
@@ -15,29 +15,33 @@ import { QueryClientProvider } from '@tanstack/react-query';
|
|
|
15
15
|
import { PropsWithChildren } from 'react';
|
|
16
16
|
import fetchMock from 'fetch-mock';
|
|
17
17
|
import { createMemoryRouter, RouterProvider } from 'react-router-dom';
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
18
|
+
import { userEvent } from '@storybook/testing-library';
|
|
19
|
+
import { DEFAULT_DATE_FORMAT } from 'hooks/useDateFormat';
|
|
20
|
+
import {
|
|
21
|
+
CourseStateFactory,
|
|
22
|
+
RichieContextFactory as mockRichieContextFactory,
|
|
23
|
+
} from 'utils/test/factories/richie';
|
|
20
24
|
import {
|
|
21
25
|
CertificateFactory,
|
|
22
26
|
CourseLightFactory,
|
|
23
27
|
CourseRunFactory,
|
|
24
28
|
EnrollmentFactory,
|
|
25
|
-
|
|
29
|
+
CredentialOrderFactory,
|
|
26
30
|
TargetCourseFactory,
|
|
27
31
|
} from 'utils/test/factories/joanie';
|
|
28
|
-
import { Certificate, CourseLight, CourseRun,
|
|
32
|
+
import { Certificate, CourseLight, CourseRun, CredentialOrder, OrderState } from 'types/Joanie';
|
|
29
33
|
import { createTestQueryClient } from 'utils/test/createTestQueryClient';
|
|
30
34
|
import { SessionProvider } from 'contexts/SessionContext';
|
|
31
35
|
import { resolveAll } from 'utils/resolveAll';
|
|
32
36
|
import { confirm } from 'utils/indirection/window';
|
|
33
37
|
import { Priority } from 'types';
|
|
34
38
|
import { sleep } from 'utils/sleep';
|
|
35
|
-
import { noop } from 'utils';
|
|
36
39
|
import { expectBannerError } from 'utils/test/expectBanner';
|
|
37
40
|
import { expectNoSpinner, expectSpinner } from 'utils/test/expectSpinner';
|
|
38
41
|
import { Deferred } from 'utils/test/deferred';
|
|
39
42
|
import { expectBreadcrumbsToEqualParts } from 'utils/test/expectBreadcrumbsToEqualParts';
|
|
40
|
-
import {
|
|
43
|
+
import { mockCourseProductWithOrder } from 'utils/test/mockCourseProductWithOrder';
|
|
44
|
+
import { HttpStatusCode } from 'utils/errors/HttpError';
|
|
41
45
|
import { LearnerDashboardPaths } from '../../../utils/learnerRouteMessages';
|
|
42
46
|
import { DashboardTest } from '../../DashboardTest';
|
|
43
47
|
import { DashboardItemOrder } from './DashboardItemOrder';
|
|
@@ -96,19 +100,10 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
96
100
|
* Global
|
|
97
101
|
*/
|
|
98
102
|
|
|
99
|
-
it('crashes if no course is provided', async () => {
|
|
100
|
-
const order: Order = { ...OrderFactory().one(), course: undefined };
|
|
101
|
-
// Hide console.error ( https://stackoverflow.com/questions/66328549/testing-an-error-thrown-by-a-react-component-using-testing-library-and-jest )
|
|
102
|
-
jest.spyOn(console, 'error').mockImplementation(noop);
|
|
103
|
-
expect(() => render(<DashboardItemOrder order={order} />)).toThrow(
|
|
104
|
-
'Order must provide course object attribute',
|
|
105
|
-
);
|
|
106
|
-
});
|
|
107
|
-
|
|
108
103
|
it('renders a pending order', async () => {
|
|
109
|
-
const order:
|
|
104
|
+
const order: CredentialOrder = CredentialOrderFactory({ state: OrderState.PENDING }).one();
|
|
110
105
|
order.target_courses = [];
|
|
111
|
-
const product =
|
|
106
|
+
const { product } = mockCourseProductWithOrder(order);
|
|
112
107
|
|
|
113
108
|
render(<DashboardItemOrder order={order} />, { wrapper });
|
|
114
109
|
|
|
@@ -119,20 +114,22 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
119
114
|
});
|
|
120
115
|
|
|
121
116
|
it('renders an order with certificate', async () => {
|
|
122
|
-
const order:
|
|
117
|
+
const order: CredentialOrder = CredentialOrderFactory({
|
|
118
|
+
certificate_id: faker.string.uuid(),
|
|
119
|
+
}).one();
|
|
123
120
|
order.target_courses = [];
|
|
124
|
-
const product =
|
|
121
|
+
const { product } = mockCourseProductWithOrder(order);
|
|
125
122
|
|
|
126
123
|
const certificate: Certificate = {
|
|
127
124
|
...CertificateFactory({
|
|
128
|
-
id: order.
|
|
125
|
+
id: order.certificate_id,
|
|
129
126
|
order: { ...order, course: CourseLightFactory().one() },
|
|
130
127
|
}).one(),
|
|
131
128
|
};
|
|
132
129
|
|
|
133
130
|
const deferred = new Deferred();
|
|
134
131
|
fetchMock.get(
|
|
135
|
-
`https://joanie.endpoint/api/v1.0/certificates/${order.
|
|
132
|
+
`https://joanie.endpoint/api/v1.0/certificates/${order.certificate_id}/`,
|
|
136
133
|
deferred.promise,
|
|
137
134
|
);
|
|
138
135
|
|
|
@@ -149,9 +146,11 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
149
146
|
});
|
|
150
147
|
|
|
151
148
|
it('does not render an order with certificate', async () => {
|
|
152
|
-
const order:
|
|
149
|
+
const order: CredentialOrder = CredentialOrderFactory({
|
|
150
|
+
certificate_id: faker.string.uuid(),
|
|
151
|
+
}).one();
|
|
153
152
|
order.target_courses = [];
|
|
154
|
-
const product =
|
|
153
|
+
const { product } = mockCourseProductWithOrder(order);
|
|
155
154
|
|
|
156
155
|
render(<DashboardItemOrder order={order} />, { wrapper });
|
|
157
156
|
|
|
@@ -162,14 +161,33 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
162
161
|
await expectNoSpinner('Loading certificate ...');
|
|
163
162
|
});
|
|
164
163
|
|
|
164
|
+
it('renders an order with a valid "Go to syllabus" link', async () => {
|
|
165
|
+
const order: CredentialOrder = CredentialOrderFactory().one();
|
|
166
|
+
order.target_courses = [];
|
|
167
|
+
const { product } = mockCourseProductWithOrder(order);
|
|
168
|
+
|
|
169
|
+
render(<DashboardItemOrder order={order} />, { wrapper });
|
|
170
|
+
|
|
171
|
+
await screen.findByRole('heading', { level: 5, name: product.title });
|
|
172
|
+
const moreButton = screen.getByRole('combobox', {
|
|
173
|
+
name: 'See additional options',
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
const user = userEvent.setup();
|
|
177
|
+
await user.click(moreButton);
|
|
178
|
+
|
|
179
|
+
const link = screen.getByRole('link', { name: 'Go to syllabus' });
|
|
180
|
+
expect(link.getAttribute('href')).toBe('/redirects/courses/' + order.course.code);
|
|
181
|
+
});
|
|
182
|
+
|
|
165
183
|
/**
|
|
166
184
|
* Non-Writable.
|
|
167
185
|
*/
|
|
168
186
|
|
|
169
187
|
it('renders a non-writable order without target courses without certificate', async () => {
|
|
170
|
-
const order:
|
|
188
|
+
const order: CredentialOrder = CredentialOrderFactory().one();
|
|
171
189
|
order.target_courses = [];
|
|
172
|
-
const product =
|
|
190
|
+
const { product } = mockCourseProductWithOrder(order);
|
|
173
191
|
|
|
174
192
|
render(<DashboardItemOrder order={order} />, { wrapper });
|
|
175
193
|
|
|
@@ -180,8 +198,8 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
180
198
|
});
|
|
181
199
|
|
|
182
200
|
it('renders a non-writable order with target courses', async () => {
|
|
183
|
-
const order:
|
|
184
|
-
const product =
|
|
201
|
+
const order: CredentialOrder = CredentialOrderFactory().one();
|
|
202
|
+
const { product } = mockCourseProductWithOrder(order);
|
|
185
203
|
|
|
186
204
|
render(<DashboardItemOrder order={order} />, { wrapper });
|
|
187
205
|
|
|
@@ -194,54 +212,55 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
194
212
|
});
|
|
195
213
|
|
|
196
214
|
it('renders a non-writable order with enrolled target course ', async () => {
|
|
197
|
-
const order:
|
|
215
|
+
const order: CredentialOrder = CredentialOrderFactory({
|
|
198
216
|
target_courses: TargetCourseFactory().many(1),
|
|
199
217
|
}).one();
|
|
200
218
|
|
|
201
219
|
// Make target course enrolled.
|
|
202
|
-
order.
|
|
220
|
+
order.target_enrollments = EnrollmentFactory({
|
|
203
221
|
course_run: order.target_courses[0].course_runs[0],
|
|
204
222
|
}).many(1);
|
|
205
223
|
|
|
206
|
-
order.
|
|
224
|
+
order.target_enrollments[0].course_run.state.priority = Priority.ONGOING_OPEN;
|
|
207
225
|
|
|
208
|
-
const product =
|
|
226
|
+
const { product } = mockCourseProductWithOrder(order);
|
|
209
227
|
|
|
210
228
|
render(<DashboardItemOrder order={order} />, { wrapper });
|
|
211
229
|
|
|
212
230
|
await screen.findByRole('heading', { level: 5, name: product.title });
|
|
213
231
|
await screen.findByText('Ref. ' + (order.course as CourseLight).code);
|
|
214
232
|
await screen.findByText('On going');
|
|
233
|
+
const fromDate = new Intl.DateTimeFormat('en', DEFAULT_DATE_FORMAT).format(
|
|
234
|
+
new Date(order.target_enrollments[0].course_run.start),
|
|
235
|
+
);
|
|
236
|
+
const toDate = new Intl.DateTimeFormat('en', DEFAULT_DATE_FORMAT).format(
|
|
237
|
+
new Date(order.target_enrollments[0].course_run.end),
|
|
238
|
+
);
|
|
215
239
|
await resolveAll(order.target_courses, async (course) => {
|
|
216
240
|
await screen.findByRole('heading', { level: 6, name: course.title });
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
new Intl.DateTimeFormat('en', DATETIME_FORMAT).format(
|
|
224
|
-
new Date(order.enrollments[0].course_run.end),
|
|
225
|
-
),
|
|
226
|
-
);
|
|
227
|
-
screen.getByRole('link', { name: 'Access course' });
|
|
241
|
+
expect(
|
|
242
|
+
screen.getByText(
|
|
243
|
+
`You are enrolled for this session. It's open from ${fromDate} to ${toDate}`,
|
|
244
|
+
),
|
|
245
|
+
).toBeInTheDocument();
|
|
246
|
+
screen.getByRole('link', { name: 'Access to course' });
|
|
228
247
|
});
|
|
229
248
|
});
|
|
230
249
|
it('renders a non-writable order with not enrolled target course', async () => {
|
|
231
|
-
const order:
|
|
250
|
+
const order: CredentialOrder = CredentialOrderFactory({
|
|
232
251
|
target_courses: TargetCourseFactory().many(1),
|
|
233
|
-
|
|
252
|
+
target_enrollments: [],
|
|
234
253
|
}).one();
|
|
235
254
|
|
|
236
|
-
const product =
|
|
255
|
+
const { product } = mockCourseProductWithOrder(order);
|
|
237
256
|
|
|
238
257
|
render(<DashboardItemOrder order={order} />, { wrapper });
|
|
239
258
|
|
|
240
259
|
await screen.findByRole('heading', { level: 5, name: product.title });
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
260
|
+
screen.getByText('Ref. ' + (order.course as CourseLight).code);
|
|
261
|
+
screen.getByText('On going');
|
|
262
|
+
order.target_courses.forEach((course) => {
|
|
263
|
+
screen.getByRole('heading', { level: 6, name: course.title });
|
|
245
264
|
screen.getByText('You are not enrolled in this course');
|
|
246
265
|
screen.getByRole('link', { name: 'Enroll' });
|
|
247
266
|
});
|
|
@@ -252,9 +271,9 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
252
271
|
*/
|
|
253
272
|
|
|
254
273
|
it('renders a writable order with no target courses', async () => {
|
|
255
|
-
const order:
|
|
274
|
+
const order: CredentialOrder = CredentialOrderFactory().one();
|
|
256
275
|
order.target_courses = [];
|
|
257
|
-
const product =
|
|
276
|
+
const { product } = mockCourseProductWithOrder(order);
|
|
258
277
|
|
|
259
278
|
render(<DashboardItemOrder order={order} writable={true} showDetailsButton={false} />, {
|
|
260
279
|
wrapper,
|
|
@@ -267,16 +286,23 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
267
286
|
});
|
|
268
287
|
|
|
269
288
|
it('renders a writable order with enrolled target course', async () => {
|
|
270
|
-
const order:
|
|
289
|
+
const order: CredentialOrder = CredentialOrderFactory({
|
|
290
|
+
target_courses: [
|
|
291
|
+
TargetCourseFactory({
|
|
292
|
+
course_runs: [
|
|
293
|
+
CourseRunFactory({
|
|
294
|
+
state: CourseStateFactory({ priority: Priority.ONGOING_OPEN }).one(),
|
|
295
|
+
}).one(),
|
|
296
|
+
],
|
|
297
|
+
}).one(),
|
|
298
|
+
],
|
|
299
|
+
}).one();
|
|
271
300
|
// Make target course enrolled.
|
|
272
|
-
order.
|
|
273
|
-
{
|
|
274
|
-
...EnrollmentFactory().one(),
|
|
275
|
-
course_run: order.target_courses[0].course_runs[0],
|
|
276
|
-
},
|
|
301
|
+
order.target_enrollments = [
|
|
302
|
+
EnrollmentFactory({ course_run: order.target_courses[0].course_runs[0] }).one(),
|
|
277
303
|
];
|
|
278
304
|
|
|
279
|
-
const product =
|
|
305
|
+
const { product } = mockCourseProductWithOrder(order);
|
|
280
306
|
|
|
281
307
|
render(<DashboardItemOrder order={order} writable={true} showDetailsButton={false} />, {
|
|
282
308
|
wrapper,
|
|
@@ -293,19 +319,31 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
293
319
|
container,
|
|
294
320
|
'dashboard-item__course-enrolling__run__' + courseRun.id,
|
|
295
321
|
);
|
|
296
|
-
getByText(
|
|
297
|
-
runElement,
|
|
298
|
-
'From ' +
|
|
299
|
-
new Intl.DateTimeFormat('en', DATETIME_FORMAT).format(new Date(courseRun.start)) +
|
|
300
|
-
' to ' +
|
|
301
|
-
new Intl.DateTimeFormat('en', DATETIME_FORMAT).format(new Date(courseRun.end)),
|
|
302
|
-
);
|
|
322
|
+
getByText(runElement, courseRun.title);
|
|
303
323
|
// Expect the first courseRun to be enrolled but not the others.
|
|
304
324
|
if (i === 0) {
|
|
305
|
-
getByText(runElement, 'Enrolled');
|
|
306
325
|
expect(queryByRole(runElement, 'button', { name: 'Enroll' })).toBeNull();
|
|
326
|
+
const fromDate = new Intl.DateTimeFormat('en', DEFAULT_DATE_FORMAT).format(
|
|
327
|
+
new Date(courseRun.start),
|
|
328
|
+
);
|
|
329
|
+
const toDate = new Intl.DateTimeFormat('en', DEFAULT_DATE_FORMAT).format(
|
|
330
|
+
new Date(courseRun.end),
|
|
331
|
+
);
|
|
332
|
+
expect(
|
|
333
|
+
screen.getByText(
|
|
334
|
+
`You are enrolled for this session. It's open from ${fromDate} to ${toDate}`,
|
|
335
|
+
),
|
|
336
|
+
).toBeInTheDocument();
|
|
337
|
+
const button = getByRole(runElement, 'link', { name: 'Access to course' });
|
|
338
|
+
expect(button).toHaveAttribute('href', courseRun.resource_link);
|
|
307
339
|
} else {
|
|
308
|
-
|
|
340
|
+
getByText(
|
|
341
|
+
runElement,
|
|
342
|
+
'From ' +
|
|
343
|
+
new Intl.DateTimeFormat('en', DEFAULT_DATE_FORMAT).format(new Date(courseRun.start)) +
|
|
344
|
+
' to ' +
|
|
345
|
+
new Intl.DateTimeFormat('en', DEFAULT_DATE_FORMAT).format(new Date(courseRun.end)),
|
|
346
|
+
);
|
|
309
347
|
getByRole(runElement, 'button', { name: 'Enroll' });
|
|
310
348
|
}
|
|
311
349
|
});
|
|
@@ -314,11 +352,19 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
314
352
|
|
|
315
353
|
it('renders a writable order with not enrolled target course and enrolls it', async () => {
|
|
316
354
|
// Initial order without enrollment.
|
|
317
|
-
const order:
|
|
318
|
-
target_courses:
|
|
319
|
-
|
|
355
|
+
const order: CredentialOrder = CredentialOrderFactory({
|
|
356
|
+
target_courses: [
|
|
357
|
+
TargetCourseFactory({
|
|
358
|
+
course_runs: [
|
|
359
|
+
CourseRunFactory({
|
|
360
|
+
state: CourseStateFactory({ priority: Priority.ONGOING_OPEN }).one(),
|
|
361
|
+
}).one(),
|
|
362
|
+
],
|
|
363
|
+
}).one(),
|
|
364
|
+
],
|
|
365
|
+
target_enrollments: [],
|
|
320
366
|
}).one();
|
|
321
|
-
const product =
|
|
367
|
+
const { product } = mockCourseProductWithOrder(order);
|
|
322
368
|
fetchMock.post('https://joanie.endpoint/api/v1.0/enrollments/', []);
|
|
323
369
|
fetchMock.get(
|
|
324
370
|
'https://joanie.endpoint/api/v1.0/orders/',
|
|
@@ -330,9 +376,9 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
330
376
|
// invalided after the click on the Enroll button.
|
|
331
377
|
const orderWithEnrollment = {
|
|
332
378
|
...order,
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
),
|
|
379
|
+
target_enrollments: EnrollmentFactory({
|
|
380
|
+
course_run: order.target_courses[0].course_runs[0],
|
|
381
|
+
}).many(1),
|
|
336
382
|
};
|
|
337
383
|
|
|
338
384
|
render(WrapperWithDashboard(LearnerDashboardPaths.ORDER.replace(':orderId', order.id)));
|
|
@@ -384,7 +430,7 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
384
430
|
runElement = await screen.findByTestId(
|
|
385
431
|
'dashboard-item__course-enrolling__run__' + courseRun.id,
|
|
386
432
|
);
|
|
387
|
-
|
|
433
|
+
getByRole(runElement, 'link', { name: 'Access to course' });
|
|
388
434
|
});
|
|
389
435
|
|
|
390
436
|
expect(queryByRole(runElement, 'button', { name: 'Enroll' })).toBeNull();
|
|
@@ -392,12 +438,12 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
392
438
|
|
|
393
439
|
it('renders a writable order with not enrolled target course and try to enroll it, but the API returns an error and it is shown', async () => {
|
|
394
440
|
// Initial order without enrollment.
|
|
395
|
-
const order:
|
|
441
|
+
const order: CredentialOrder = CredentialOrderFactory({
|
|
396
442
|
target_courses: TargetCourseFactory().many(1),
|
|
397
|
-
|
|
443
|
+
target_enrollments: [],
|
|
398
444
|
}).one();
|
|
399
445
|
|
|
400
|
-
const product =
|
|
446
|
+
const { product } = mockCourseProductWithOrder(order);
|
|
401
447
|
fetchMock.get(
|
|
402
448
|
'https://joanie.endpoint/api/v1.0/orders/',
|
|
403
449
|
{ results: [order], next: null, previous: null, count: null },
|
|
@@ -405,15 +451,15 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
405
451
|
);
|
|
406
452
|
|
|
407
453
|
fetchMock.post('https://joanie.endpoint/api/v1.0/enrollments/', {
|
|
408
|
-
status:
|
|
409
|
-
body: '
|
|
454
|
+
status: HttpStatusCode.INTERNAL_SERVER_ERROR,
|
|
455
|
+
body: 'Internal Server Error',
|
|
410
456
|
});
|
|
411
457
|
|
|
412
458
|
render(WrapperWithDashboard(LearnerDashboardPaths.ORDER.replace(':orderId', order.id)));
|
|
413
459
|
// Wait for the order to be rendered.
|
|
414
460
|
await screen.findByRole('heading', { level: 5, name: product.title });
|
|
415
461
|
|
|
416
|
-
await expectBreadcrumbsToEqualParts(['
|
|
462
|
+
await expectBreadcrumbsToEqualParts(['chevron_leftBack', 'My courses', product.title]);
|
|
417
463
|
|
|
418
464
|
const courseRun = order.target_courses[0].course_runs[0];
|
|
419
465
|
const runElement = await screen.findByTestId(
|
|
@@ -442,17 +488,28 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
442
488
|
|
|
443
489
|
it('renders a writable order with enrolled target course and changes the enrollment', async () => {
|
|
444
490
|
// Initial order with first course run enrolled.
|
|
445
|
-
const order:
|
|
491
|
+
const order: CredentialOrder = CredentialOrderFactory({
|
|
492
|
+
target_courses: [
|
|
493
|
+
TargetCourseFactory({
|
|
494
|
+
course_runs: [
|
|
495
|
+
CourseRunFactory().one(),
|
|
496
|
+
CourseRunFactory({
|
|
497
|
+
state: CourseStateFactory({ priority: Priority.ONGOING_OPEN }).one(),
|
|
498
|
+
}).one(),
|
|
499
|
+
],
|
|
500
|
+
}).one(),
|
|
501
|
+
],
|
|
502
|
+
}).one();
|
|
446
503
|
const initialEnrolledCourseRun = order.target_courses[0].course_runs[0];
|
|
447
|
-
order.
|
|
504
|
+
order.target_enrollments = EnrollmentFactory({ course_run: initialEnrolledCourseRun }).many(1);
|
|
448
505
|
|
|
449
506
|
// When the existing enrollment will be set as is_active: false.
|
|
450
507
|
fetchMock.put(
|
|
451
|
-
'https://joanie.endpoint/api/v1.0/enrollments/' + order.
|
|
508
|
+
'https://joanie.endpoint/api/v1.0/enrollments/' + order.target_enrollments[0].id + '/',
|
|
452
509
|
[],
|
|
453
510
|
);
|
|
454
511
|
|
|
455
|
-
const product =
|
|
512
|
+
const { product } = mockCourseProductWithOrder(order);
|
|
456
513
|
fetchMock.post('https://joanie.endpoint/api/v1.0/enrollments/', []);
|
|
457
514
|
fetchMock.get(
|
|
458
515
|
'https://joanie.endpoint/api/v1.0/orders/',
|
|
@@ -465,7 +522,7 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
465
522
|
const newEnrolledCourseRun = order.target_courses[0].course_runs[1];
|
|
466
523
|
const orderWithNewEnrollment = {
|
|
467
524
|
...order,
|
|
468
|
-
|
|
525
|
+
target_enrollments: EnrollmentFactory({ course_run: newEnrolledCourseRun }).many(1),
|
|
469
526
|
};
|
|
470
527
|
|
|
471
528
|
render(WrapperWithDashboard(LearnerDashboardPaths.ORDER.replace(':orderId', order.id)));
|
|
@@ -513,7 +570,7 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
513
570
|
|
|
514
571
|
// Expect the existing enrollment to be set as is_active: false.
|
|
515
572
|
const calls = fetchMock.calls(
|
|
516
|
-
'https://joanie.endpoint/api/v1.0/enrollments/' + order.
|
|
573
|
+
'https://joanie.endpoint/api/v1.0/enrollments/' + order.target_enrollments[0].id + '/',
|
|
517
574
|
{ method: 'put' },
|
|
518
575
|
);
|
|
519
576
|
expect(calls.length).toBe(1);
|
|
@@ -521,7 +578,7 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
521
578
|
|
|
522
579
|
expect(
|
|
523
580
|
fetchMock.called(
|
|
524
|
-
'https://joanie.endpoint/api/v1.0/enrollments/' + order.
|
|
581
|
+
'https://joanie.endpoint/api/v1.0/enrollments/' + order.target_enrollments[0].id + '/',
|
|
525
582
|
{ method: 'put' },
|
|
526
583
|
),
|
|
527
584
|
).toBe(true);
|
|
@@ -531,7 +588,7 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
531
588
|
runElement = await screen.findByTestId(
|
|
532
589
|
'dashboard-item__course-enrolling__run__' + newEnrolledCourseRun.id,
|
|
533
590
|
);
|
|
534
|
-
|
|
591
|
+
getByRole(runElement, 'link', { name: 'Access to course' });
|
|
535
592
|
});
|
|
536
593
|
|
|
537
594
|
expect(queryByRole(runElement, 'button', { name: 'Enroll' })).toBeNull();
|
|
@@ -539,17 +596,23 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
539
596
|
|
|
540
597
|
it('renders a writable order with enrolled target course and refuse the confirm message when enrolling', async () => {
|
|
541
598
|
// Initial order without enrollment.
|
|
542
|
-
const order:
|
|
599
|
+
const order: CredentialOrder = CredentialOrderFactory({
|
|
600
|
+
target_courses: [
|
|
601
|
+
TargetCourseFactory({
|
|
602
|
+
course_runs: [
|
|
603
|
+
CourseRunFactory({
|
|
604
|
+
state: CourseStateFactory({ priority: Priority.ONGOING_OPEN }).one(),
|
|
605
|
+
}).one(),
|
|
606
|
+
CourseRunFactory().one(),
|
|
607
|
+
],
|
|
608
|
+
}).one(),
|
|
609
|
+
],
|
|
610
|
+
}).one();
|
|
543
611
|
|
|
544
612
|
const initialEnrolledCourseRun = order.target_courses[0].course_runs[0];
|
|
545
|
-
order.
|
|
546
|
-
{
|
|
547
|
-
...EnrollmentFactory().one(),
|
|
548
|
-
course_run: initialEnrolledCourseRun,
|
|
549
|
-
},
|
|
550
|
-
];
|
|
613
|
+
order.target_enrollments = [EnrollmentFactory({ course_run: initialEnrolledCourseRun }).one()];
|
|
551
614
|
|
|
552
|
-
const product =
|
|
615
|
+
const { product } = mockCourseProductWithOrder(order);
|
|
553
616
|
fetchMock.post('https://joanie.endpoint/api/v1.0/enrollments/', []);
|
|
554
617
|
fetchMock.get(
|
|
555
618
|
'https://joanie.endpoint/api/v1.0/orders/',
|
|
@@ -569,14 +632,14 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
569
632
|
let runElement = await screen.findByTestId(
|
|
570
633
|
'dashboard-item__course-enrolling__run__' + courseRun.id,
|
|
571
634
|
);
|
|
572
|
-
|
|
635
|
+
getByRole(runElement, 'link', { name: 'Access to course' });
|
|
573
636
|
|
|
574
637
|
// Make sure the new courseRun is not enrolled.
|
|
575
638
|
const newRunElement = await screen.findByTestId(
|
|
576
639
|
'dashboard-item__course-enrolling__run__' + newEnrolledCourseRun.id,
|
|
577
640
|
);
|
|
578
641
|
const enrollButton = getByRole(newRunElement, 'button', { name: 'Enroll' });
|
|
579
|
-
expect(
|
|
642
|
+
expect(queryByRole(runElement, 'button', { name: 'Access to course' })).toBeNull();
|
|
580
643
|
|
|
581
644
|
expect(
|
|
582
645
|
fetchMock.called('https://joanie.endpoint/api/v1.0/enrollments/', { method: 'post' }),
|
|
@@ -601,7 +664,7 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
601
664
|
runElement = await screen.findByTestId(
|
|
602
665
|
'dashboard-item__course-enrolling__run__' + courseRun.id,
|
|
603
666
|
);
|
|
604
|
-
|
|
667
|
+
getByRole(runElement, 'link', { name: 'Access to course' });
|
|
605
668
|
|
|
606
669
|
// Expect the enrollment to not be created and orders not invalided.
|
|
607
670
|
expect(
|
|
@@ -612,20 +675,27 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
612
675
|
|
|
613
676
|
it('renders a writable order with non-enrolled (is_active=false) target course and changes the enrollment', async () => {
|
|
614
677
|
// Initial order with first course run enrolled.
|
|
615
|
-
const order:
|
|
678
|
+
const order: CredentialOrder = CredentialOrderFactory({
|
|
679
|
+
target_courses: TargetCourseFactory({
|
|
680
|
+
course_runs: [
|
|
681
|
+
CourseRunFactory({
|
|
682
|
+
state: CourseStateFactory({ priority: Priority.ONGOING_OPEN }).one(),
|
|
683
|
+
}).one(),
|
|
684
|
+
],
|
|
685
|
+
}).many(1),
|
|
686
|
+
}).one();
|
|
616
687
|
|
|
617
688
|
const courseRun = order.target_courses[0].course_runs[0];
|
|
618
|
-
const enrollment = {
|
|
619
|
-
...EnrollmentFactory().one(),
|
|
689
|
+
const enrollment = EnrollmentFactory({
|
|
620
690
|
course_run: courseRun,
|
|
621
691
|
is_active: false,
|
|
622
|
-
};
|
|
623
|
-
order.
|
|
692
|
+
}).one();
|
|
693
|
+
order.target_enrollments = [enrollment];
|
|
624
694
|
|
|
625
695
|
// When the existing enrollment will be set as is_active: true.
|
|
626
696
|
fetchMock.put('https://joanie.endpoint/api/v1.0/enrollments/' + enrollment.id + '/', []);
|
|
627
697
|
|
|
628
|
-
const product =
|
|
698
|
+
const { product } = mockCourseProductWithOrder(order);
|
|
629
699
|
fetchMock.get(
|
|
630
700
|
'https://joanie.endpoint/api/v1.0/orders/',
|
|
631
701
|
{ results: [order], next: null, previous: null, count: null },
|
|
@@ -636,7 +706,7 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
636
706
|
// invalided after the click on the Enroll button.
|
|
637
707
|
const orderWithActiveEnrollment = {
|
|
638
708
|
...order,
|
|
639
|
-
|
|
709
|
+
target_enrollments: [
|
|
640
710
|
{
|
|
641
711
|
...enrollment,
|
|
642
712
|
is_active: true,
|
|
@@ -689,13 +759,13 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
689
759
|
runElement = await screen.findByTestId(
|
|
690
760
|
'dashboard-item__course-enrolling__run__' + courseRun.id,
|
|
691
761
|
);
|
|
692
|
-
|
|
762
|
+
getByRole(runElement, 'link', { name: 'Access to course' });
|
|
693
763
|
});
|
|
694
764
|
|
|
695
765
|
expect(queryByRole(runElement, 'button', { name: 'Enroll' })).toBeNull();
|
|
696
766
|
});
|
|
697
767
|
it('renders a writable order with not yet-opened course runs', async () => {
|
|
698
|
-
const order:
|
|
768
|
+
const order: CredentialOrder = CredentialOrderFactory({
|
|
699
769
|
target_courses: TargetCourseFactory({
|
|
700
770
|
course_runs: CourseRunFactory({
|
|
701
771
|
enrollment_start: faker.date.past({ years: 0.5 }).toISOString(),
|
|
@@ -706,7 +776,7 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
706
776
|
}).many(1),
|
|
707
777
|
}).many(1),
|
|
708
778
|
}).one();
|
|
709
|
-
const product =
|
|
779
|
+
const { product } = mockCourseProductWithOrder(order);
|
|
710
780
|
|
|
711
781
|
render(<DashboardItemOrder order={order} writable={true} showDetailsButton={false} />, {
|
|
712
782
|
wrapper,
|
|
@@ -720,6 +790,7 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
720
790
|
new Intl.DateTimeFormat('en', DEFAULT_DATE_FORMAT).format(
|
|
721
791
|
new Date(order.target_courses[0].course_runs[0].enrollment_start),
|
|
722
792
|
),
|
|
793
|
+
{ exact: false },
|
|
723
794
|
);
|
|
724
795
|
|
|
725
796
|
// Enroll button should be disabled.
|
|
@@ -735,14 +806,14 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
735
806
|
priority: Priority.FUTURE_CLOSED,
|
|
736
807
|
},
|
|
737
808
|
}).one();
|
|
738
|
-
const order:
|
|
809
|
+
const order: CredentialOrder = CredentialOrderFactory({
|
|
739
810
|
target_courses: TargetCourseFactory({ course_runs: [courseRun] }).many(1),
|
|
740
811
|
}).one();
|
|
741
812
|
|
|
742
813
|
// Make target course enrolled.
|
|
743
|
-
order.
|
|
814
|
+
order.target_enrollments = EnrollmentFactory({ course_run: courseRun }).many(1);
|
|
744
815
|
|
|
745
|
-
const product =
|
|
816
|
+
const { product } = mockCourseProductWithOrder(order);
|
|
746
817
|
|
|
747
818
|
render(<DashboardItemOrder order={order} writable={true} showDetailsButton={false} />, {
|
|
748
819
|
wrapper,
|
|
@@ -754,7 +825,7 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
754
825
|
|
|
755
826
|
// The course run should be shown as enrolled even if is it past.
|
|
756
827
|
const runElement = screen.getByTestId('dashboard-item__course-enrolling__run__' + courseRun.id);
|
|
757
|
-
|
|
828
|
+
expect(screen.queryByRole('link', { name: 'Access to course' })).not.toBeInTheDocument();
|
|
758
829
|
expect(queryByRole(runElement, 'button', { name: 'Enroll' })).toBeNull();
|
|
759
830
|
});
|
|
760
831
|
|
|
@@ -767,12 +838,12 @@ describe('<DashboardItemOrder/>', () => {
|
|
|
767
838
|
},
|
|
768
839
|
}).one();
|
|
769
840
|
|
|
770
|
-
const order:
|
|
841
|
+
const order: CredentialOrder = CredentialOrderFactory({
|
|
771
842
|
target_courses: TargetCourseFactory({ course_runs: [courseRun] }).many(1),
|
|
772
|
-
|
|
843
|
+
target_enrollments: [],
|
|
773
844
|
}).one();
|
|
774
845
|
|
|
775
|
-
const product =
|
|
846
|
+
const { product } = mockCourseProductWithOrder(order);
|
|
776
847
|
|
|
777
848
|
render(<DashboardItemOrder order={order} writable={true} showDetailsButton={false} />, {
|
|
778
849
|
wrapper,
|