@openedx/frontend-app-learner-dashboard 1.0.0-alpha.0
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/LICENSE +661 -0
- package/README.rst +86 -0
- package/package.json +84 -0
- package/src/Main.jsx +20 -0
- package/src/__mocks__/file.js +1 -0
- package/src/__mocks__/svg.js +1 -0
- package/src/__snapshots__/App.test.jsx.snap +83 -0
- package/src/__snapshots__/index.test.jsx.snap +43 -0
- package/src/app.scss +41 -0
- package/src/app.ts +23 -0
- package/src/assets/empty-course.svg +49 -0
- package/src/assets/more-courses-sidewidget.svg +52 -0
- package/src/assets/verified-ribbon.png +0 -0
- package/src/components/Banner.jsx +26 -0
- package/src/components/Banner.test.jsx +27 -0
- package/src/components/__snapshots__/Banner.test.jsx.snap +31 -0
- package/src/constants.ts +1 -0
- package/src/containers/CourseCard/CourseCard.scss +75 -0
- package/src/containers/CourseCard/__snapshots__/index.test.jsx.snap +111 -0
- package/src/containers/CourseCard/components/CourseCardActions/ActionButton/__snapshots__/index.test.jsx.snap +14 -0
- package/src/containers/CourseCard/components/CourseCardActions/ActionButton/hooks.js +8 -0
- package/src/containers/CourseCard/components/CourseCardActions/ActionButton/hooks.test.js +21 -0
- package/src/containers/CourseCard/components/CourseCardActions/ActionButton/index.jsx +16 -0
- package/src/containers/CourseCard/components/CourseCardActions/ActionButton/index.test.jsx +25 -0
- package/src/containers/CourseCard/components/CourseCardActions/BeginCourseButton.jsx +38 -0
- package/src/containers/CourseCard/components/CourseCardActions/BeginCourseButton.test.jsx +86 -0
- package/src/containers/CourseCard/components/CourseCardActions/ResumeButton.jsx +38 -0
- package/src/containers/CourseCard/components/CourseCardActions/ResumeButton.test.jsx +84 -0
- package/src/containers/CourseCard/components/CourseCardActions/SelectSessionButton.jsx +28 -0
- package/src/containers/CourseCard/components/CourseCardActions/SelectSessionButton.test.jsx +34 -0
- package/src/containers/CourseCard/components/CourseCardActions/ViewCourseButton.jsx +37 -0
- package/src/containers/CourseCard/components/CourseCardActions/ViewCourseButton.test.jsx +45 -0
- package/src/containers/CourseCard/components/CourseCardActions/__snapshots__/BeginCourseButton.test.jsx.snap +39 -0
- package/src/containers/CourseCard/components/CourseCardActions/__snapshots__/ResumeButton.test.jsx.snap +39 -0
- package/src/containers/CourseCard/components/CourseCardActions/__snapshots__/SelectSessionButton.test.jsx.snap +19 -0
- package/src/containers/CourseCard/components/CourseCardActions/__snapshots__/ViewCourseButton.test.jsx.snap +39 -0
- package/src/containers/CourseCard/components/CourseCardActions/index.jsx +42 -0
- package/src/containers/CourseCard/components/CourseCardActions/index.test.jsx +97 -0
- package/src/containers/CourseCard/components/CourseCardActions/messages.js +26 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CertificateBanner.jsx +95 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CertificateBanner.test.jsx +227 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CourseBanner.jsx +57 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CourseBanner.test.jsx +131 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/__snapshots__/index.test.jsx.snap +58 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/hooks.js +42 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/hooks.test.js +90 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/index.jsx +36 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/index.test.jsx +95 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/messages.js +16 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/ApprovedContent.jsx +35 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/ApprovedContent.test.jsx +64 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/EligibleContent.jsx +34 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/EligibleContent.test.jsx +82 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/MustRequestContent.jsx +36 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/MustRequestContent.test.jsx +74 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/PendingContent.jsx +30 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/PendingContent.test.jsx +63 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/RejectedContent.jsx +27 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/RejectedContent.test.jsx +54 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/components/CreditContent.jsx +51 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/components/CreditContent.test.jsx +60 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/components/CreditRequestForm/__snapshots__/index.test.jsx.snap +32 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/components/CreditRequestForm/hooks.js +13 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/components/CreditRequestForm/hooks.test.js +45 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/components/CreditRequestForm/index.jsx +43 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/components/CreditRequestForm/index.test.jsx +65 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/components/CreditRequestForm/ref.test.jsx +34 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/components/ProviderLink.jsx +24 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/components/ProviderLink.test.jsx +42 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/components/__snapshots__/CreditContent.test.jsx.snap +60 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/components/__snapshots__/ProviderLink.test.jsx.snap +11 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/hooks.js +27 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/hooks.test.js +56 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/messages.js +61 -0
- package/src/containers/CourseCard/components/CourseCardBanners/EntitlementBanner.jsx +66 -0
- package/src/containers/CourseCard/components/CourseCardBanners/EntitlementBanner.test.jsx +63 -0
- package/src/containers/CourseCard/components/CourseCardBanners/RelatedProgramsBanner/ProgramsList.jsx +23 -0
- package/src/containers/CourseCard/components/CourseCardBanners/RelatedProgramsBanner/ProgramsList.test.jsx +23 -0
- package/src/containers/CourseCard/components/CourseCardBanners/RelatedProgramsBanner/__snapshots__/ProgramsList.test.jsx.snap +28 -0
- package/src/containers/CourseCard/components/CourseCardBanners/RelatedProgramsBanner/__snapshots__/index.test.jsx.snap +29 -0
- package/src/containers/CourseCard/components/CourseCardBanners/RelatedProgramsBanner/index.jsx +38 -0
- package/src/containers/CourseCard/components/CourseCardBanners/RelatedProgramsBanner/index.test.jsx +42 -0
- package/src/containers/CourseCard/components/CourseCardBanners/RelatedProgramsBanner/messages.js +31 -0
- package/src/containers/CourseCard/components/CourseCardBanners/__snapshots__/CertificateBanner.test.jsx.snap +205 -0
- package/src/containers/CourseCard/components/CourseCardBanners/__snapshots__/CourseBanner.test.jsx.snap +38 -0
- package/src/containers/CourseCard/components/CourseCardBanners/__snapshots__/EntitlementBanner.test.jsx.snap +53 -0
- package/src/containers/CourseCard/components/CourseCardBanners/__snapshots__/index.test.jsx.snap +41 -0
- package/src/containers/CourseCard/components/CourseCardBanners/index.jsx +28 -0
- package/src/containers/CourseCard/components/CourseCardBanners/index.test.jsx +32 -0
- package/src/containers/CourseCard/components/CourseCardBanners/messages.js +106 -0
- package/src/containers/CourseCard/components/CourseCardDetails/__snapshots__/index.test.jsx.snap +56 -0
- package/src/containers/CourseCard/components/CourseCardDetails/hooks.js +67 -0
- package/src/containers/CourseCard/components/CourseCardDetails/hooks.test.js +186 -0
- package/src/containers/CourseCard/components/CourseCardDetails/index.jsx +45 -0
- package/src/containers/CourseCard/components/CourseCardDetails/index.scss +7 -0
- package/src/containers/CourseCard/components/CourseCardDetails/index.test.jsx +71 -0
- package/src/containers/CourseCard/components/CourseCardDetails/messages.js +41 -0
- package/src/containers/CourseCard/components/CourseCardImage.jsx +68 -0
- package/src/containers/CourseCard/components/CourseCardImage.test.jsx +66 -0
- package/src/containers/CourseCard/components/CourseCardMenu/SocialShareMenu.jsx +83 -0
- package/src/containers/CourseCard/components/CourseCardMenu/SocialShareMenu.test.jsx +236 -0
- package/src/containers/CourseCard/components/CourseCardMenu/__snapshots__/index.test.jsx.snap +81 -0
- package/src/containers/CourseCard/components/CourseCardMenu/hooks.js +58 -0
- package/src/containers/CourseCard/components/CourseCardMenu/hooks.test.js +153 -0
- package/src/containers/CourseCard/components/CourseCardMenu/index.jsx +85 -0
- package/src/containers/CourseCard/components/CourseCardMenu/index.test.jsx +214 -0
- package/src/containers/CourseCard/components/CourseCardMenu/messages.js +36 -0
- package/src/containers/CourseCard/components/CourseCardTitle.jsx +43 -0
- package/src/containers/CourseCard/components/CourseCardTitle.test.jsx +67 -0
- package/src/containers/CourseCard/components/RelatedProgramsBadge/__snapshots__/index.test.jsx.snap +25 -0
- package/src/containers/CourseCard/components/RelatedProgramsBadge/hooks.jsx +35 -0
- package/src/containers/CourseCard/components/RelatedProgramsBadge/hooks.test.js +76 -0
- package/src/containers/CourseCard/components/RelatedProgramsBadge/index.jsx +39 -0
- package/src/containers/CourseCard/components/RelatedProgramsBadge/index.test.jsx +30 -0
- package/src/containers/CourseCard/components/RelatedProgramsBadge/messages.js +13 -0
- package/src/containers/CourseCard/components/__snapshots__/CourseCardImage.test.jsx.snap +72 -0
- package/src/containers/CourseCard/components/__snapshots__/CourseCardTitle.test.jsx.snap +33 -0
- package/src/containers/CourseCard/components/hooks.js +33 -0
- package/src/containers/CourseCard/components/hooks.test.js +165 -0
- package/src/containers/CourseCard/hooks.js +23 -0
- package/src/containers/CourseCard/hooks.test.js +48 -0
- package/src/containers/CourseCard/index.jsx +50 -0
- package/src/containers/CourseCard/index.test.jsx +29 -0
- package/src/containers/CourseCard/messages.js +26 -0
- package/src/containers/CourseFilterControls/ActiveCourseFilters.jsx +40 -0
- package/src/containers/CourseFilterControls/ActiveCourseFilters.test.jsx +17 -0
- package/src/containers/CourseFilterControls/CourseFilterControls.jsx +115 -0
- package/src/containers/CourseFilterControls/CourseFilterControls.test.jsx +60 -0
- package/src/containers/CourseFilterControls/__snapshots__/ActiveCourseFilters.test.jsx.snap +39 -0
- package/src/containers/CourseFilterControls/__snapshots__/CourseFilterControls.test.jsx.snap +169 -0
- package/src/containers/CourseFilterControls/components/Checkbox.jsx +21 -0
- package/src/containers/CourseFilterControls/components/Checkbox.test.jsx +15 -0
- package/src/containers/CourseFilterControls/components/FilterForm.jsx +45 -0
- package/src/containers/CourseFilterControls/components/FilterForm.test.jsx +29 -0
- package/src/containers/CourseFilterControls/components/SortForm.jsx +39 -0
- package/src/containers/CourseFilterControls/components/SortForm.test.jsx +19 -0
- package/src/containers/CourseFilterControls/components/__snapshots__/Checkbox.test.jsx.snap +46 -0
- package/src/containers/CourseFilterControls/components/__snapshots__/FilterForm.test.jsx.snap +41 -0
- package/src/containers/CourseFilterControls/components/__snapshots__/SortForm.test.jsx.snap +29 -0
- package/src/containers/CourseFilterControls/hooks.js +60 -0
- package/src/containers/CourseFilterControls/hooks.test.js +113 -0
- package/src/containers/CourseFilterControls/index.jsx +6 -0
- package/src/containers/CourseFilterControls/index.scss +29 -0
- package/src/containers/CourseFilterControls/messages.js +61 -0
- package/src/containers/CoursesPanel/CourseList/__snapshots__/index.test.jsx.snap +70 -0
- package/src/containers/CoursesPanel/CourseList/hooks.js +8 -0
- package/src/containers/CoursesPanel/CourseList/index.jsx +54 -0
- package/src/containers/CoursesPanel/CourseList/index.test.jsx +64 -0
- package/src/containers/CoursesPanel/NoCoursesView/__snapshots__/index.test.jsx.snap +29 -0
- package/src/containers/CoursesPanel/NoCoursesView/index.jsx +40 -0
- package/src/containers/CoursesPanel/NoCoursesView/index.scss +15 -0
- package/src/containers/CoursesPanel/NoCoursesView/index.test.jsx +18 -0
- package/src/containers/CoursesPanel/NoCoursesView/messages.js +26 -0
- package/src/containers/CoursesPanel/__snapshots__/index.test.jsx.snap +55 -0
- package/src/containers/CoursesPanel/hooks.js +54 -0
- package/src/containers/CoursesPanel/hooks.test.js +115 -0
- package/src/containers/CoursesPanel/index.jsx +40 -0
- package/src/containers/CoursesPanel/index.scss +42 -0
- package/src/containers/CoursesPanel/index.test.jsx +58 -0
- package/src/containers/CoursesPanel/messages.js +11 -0
- package/src/containers/Dashboard/DashboardLayout.jsx +54 -0
- package/src/containers/Dashboard/DashboardLayout.test.jsx +115 -0
- package/src/containers/Dashboard/LoadingView.jsx +20 -0
- package/src/containers/Dashboard/LoadingView.test.jsx +23 -0
- package/src/containers/Dashboard/__snapshots__/DashboardLayout.test.jsx.snap +197 -0
- package/src/containers/Dashboard/__snapshots__/LoadingView.test.jsx.snap +13 -0
- package/src/containers/Dashboard/__snapshots__/index.test.jsx.snap +69 -0
- package/src/containers/Dashboard/hooks.js +34 -0
- package/src/containers/Dashboard/hooks.test.js +88 -0
- package/src/containers/Dashboard/index.jsx +43 -0
- package/src/containers/Dashboard/index.scss +29 -0
- package/src/containers/Dashboard/index.test.jsx +122 -0
- package/src/containers/EmailSettingsModal/__snapshots__/index.test.jsx.snap +133 -0
- package/src/containers/EmailSettingsModal/hooks.js +32 -0
- package/src/containers/EmailSettingsModal/hooks.test.js +71 -0
- package/src/containers/EmailSettingsModal/index.jsx +58 -0
- package/src/containers/EmailSettingsModal/index.test.jsx +57 -0
- package/src/containers/EmailSettingsModal/messages.js +37 -0
- package/src/containers/RelatedProgramsModal/__snapshots__/index.test.jsx.snap +169 -0
- package/src/containers/RelatedProgramsModal/components/ProgramCard.jsx +66 -0
- package/src/containers/RelatedProgramsModal/components/ProgramCard.test.jsx +23 -0
- package/src/containers/RelatedProgramsModal/components/__snapshots__/ProgramCard.test.jsx.snap +60 -0
- package/src/containers/RelatedProgramsModal/components/index.scss +23 -0
- package/src/containers/RelatedProgramsModal/components/messages.js +24 -0
- package/src/containers/RelatedProgramsModal/hooks.js +10 -0
- package/src/containers/RelatedProgramsModal/index.jsx +62 -0
- package/src/containers/RelatedProgramsModal/index.scss +5 -0
- package/src/containers/RelatedProgramsModal/index.test.jsx +60 -0
- package/src/containers/RelatedProgramsModal/messages.js +16 -0
- package/src/containers/SelectSessionModal/__snapshots__/index.test.jsx.snap +176 -0
- package/src/containers/SelectSessionModal/constants.js +2 -0
- package/src/containers/SelectSessionModal/hooks.js +77 -0
- package/src/containers/SelectSessionModal/hooks.test.js +194 -0
- package/src/containers/SelectSessionModal/index.jsx +75 -0
- package/src/containers/SelectSessionModal/index.test.jsx +53 -0
- package/src/containers/SelectSessionModal/messages.js +41 -0
- package/src/containers/UnenrollConfirmModal/__snapshots__/index.test.jsx.snap +101 -0
- package/src/containers/UnenrollConfirmModal/components/ConfirmPane.jsx +36 -0
- package/src/containers/UnenrollConfirmModal/components/ConfirmPane.test.jsx +14 -0
- package/src/containers/UnenrollConfirmModal/components/FinishedPane.jsx +35 -0
- package/src/containers/UnenrollConfirmModal/components/FinishedPane.test.jsx +21 -0
- package/src/containers/UnenrollConfirmModal/components/ReasonPane.jsx +65 -0
- package/src/containers/UnenrollConfirmModal/components/ReasonPane.test.jsx +26 -0
- package/src/containers/UnenrollConfirmModal/components/__snapshots__/ConfirmPane.test.jsx.snap +22 -0
- package/src/containers/UnenrollConfirmModal/components/__snapshots__/FinishedPane.test.jsx.snap +38 -0
- package/src/containers/UnenrollConfirmModal/components/__snapshots__/ReasonPane.test.jsx.snap +183 -0
- package/src/containers/UnenrollConfirmModal/components/messages.js +56 -0
- package/src/containers/UnenrollConfirmModal/constants.js +86 -0
- package/src/containers/UnenrollConfirmModal/hooks/index.js +55 -0
- package/src/containers/UnenrollConfirmModal/hooks/index.test.js +101 -0
- package/src/containers/UnenrollConfirmModal/hooks/reasons.js +79 -0
- package/src/containers/UnenrollConfirmModal/hooks/reasons.test.js +192 -0
- package/src/containers/UnenrollConfirmModal/index.jsx +59 -0
- package/src/containers/UnenrollConfirmModal/index.test.jsx +61 -0
- package/src/data/constants/app.js +20 -0
- package/src/data/constants/app.test.js +24 -0
- package/src/data/constants/course.js +17 -0
- package/src/data/constants/credit.js +9 -0
- package/src/data/constants/files.js +20 -0
- package/src/data/constants/htmlKeys.js +21 -0
- package/src/data/constants/requests.js +34 -0
- package/src/data/contexts/GlobalDataContext.jsx +15 -0
- package/src/data/contexts/GlobalDataProvider.jsx +23 -0
- package/src/data/contexts/MasqueradeUserContext.jsx +16 -0
- package/src/data/contexts/MasqueradeUserProvider.jsx +31 -0
- package/src/data/redux/app/index.js +2 -0
- package/src/data/redux/app/reducer.js +81 -0
- package/src/data/redux/app/reducer.test.js +124 -0
- package/src/data/redux/app/selectors/appSelectors.js +23 -0
- package/src/data/redux/app/selectors/appSelectors.test.js +28 -0
- package/src/data/redux/app/selectors/courseCard.js +155 -0
- package/src/data/redux/app/selectors/courseCard.test.js +398 -0
- package/src/data/redux/app/selectors/currentList.js +60 -0
- package/src/data/redux/app/selectors/currentList.test.js +185 -0
- package/src/data/redux/app/selectors/index.js +13 -0
- package/src/data/redux/app/selectors/simpleSelectors.js +38 -0
- package/src/data/redux/app/selectors/simpleSelectors.test.js +75 -0
- package/src/data/redux/hooks/app.js +106 -0
- package/src/data/redux/hooks/index.js +2 -0
- package/src/data/redux/hooks/requests.js +47 -0
- package/src/data/redux/index.js +37 -0
- package/src/data/redux/requests/index.js +2 -0
- package/src/data/redux/requests/reducer.js +53 -0
- package/src/data/redux/requests/reducer.test.js +62 -0
- package/src/data/redux/requests/selectors.js +29 -0
- package/src/data/redux/requests/selectors.test.js +110 -0
- package/src/data/services/lms/api.js +77 -0
- package/src/data/services/lms/api.test.js +156 -0
- package/src/data/services/lms/constants.js +18 -0
- package/src/data/services/lms/fakeData/courses.js +828 -0
- package/src/data/services/lms/fakeData/testUtils.js +40 -0
- package/src/data/services/lms/index.js +8 -0
- package/src/data/services/lms/urls.js +43 -0
- package/src/data/services/lms/urls.test.js +51 -0
- package/src/data/services/lms/utils.js +60 -0
- package/src/data/services/lms/utils.test.js +40 -0
- package/src/data/services/segment/utils.js +17 -0
- package/src/data/services/segment/utils.test.js +36 -0
- package/src/data/store.js +25 -0
- package/src/data/store.test.js +47 -0
- package/src/data/utils.js +19 -0
- package/src/data/utils.test.js +29 -0
- package/src/hooks/api.js +123 -0
- package/src/hooks/api.test.js +273 -0
- package/src/hooks/index.js +7 -0
- package/src/hooks/utils.js +17 -0
- package/src/hooks/utils.test.js +16 -0
- package/src/i18n/index.js +25 -0
- package/src/index.ts +3 -0
- package/src/messages.js +16 -0
- package/src/providers.ts +11 -0
- package/src/routes.jsx +14 -0
- package/src/segment.js +85 -0
- package/src/setupTest.jsx +251 -0
- package/src/slots/CourseBannerSlot/README.md +44 -0
- package/src/slots/CourseBannerSlot/images/course_banner_slot_default.png +0 -0
- package/src/slots/CourseBannerSlot/images/custom_course_banner.png +0 -0
- package/src/slots/CourseBannerSlot/index.jsx +18 -0
- package/src/slots/CourseCardActionSlot/README.md +53 -0
- package/src/slots/CourseCardActionSlot/images/post_course_card_action.png +0 -0
- package/src/slots/CourseCardActionSlot/index.jsx +15 -0
- package/src/slots/CourseListSlot/README.md +54 -0
- package/src/slots/CourseListSlot/images/course_list_slot.png +0 -0
- package/src/slots/CourseListSlot/images/readme_custom_course_list.png +0 -0
- package/src/slots/CourseListSlot/index.jsx +17 -0
- package/src/slots/DashboardModalSlot/README.md +30 -0
- package/src/slots/DashboardModalSlot/images/dashboard_modal_slot.png +0 -0
- package/src/slots/DashboardModalSlot/index.jsx +7 -0
- package/src/slots/NoCoursesViewSlot/README.md +34 -0
- package/src/slots/NoCoursesViewSlot/images/no_course_view_slot.png +0 -0
- package/src/slots/NoCoursesViewSlot/images/readme_custom_no_courses.png +0 -0
- package/src/slots/NoCoursesViewSlot/index.jsx +11 -0
- package/src/slots/README.md +8 -0
- package/src/slots/WidgetSidebarSlot/README.md +51 -0
- package/src/slots/WidgetSidebarSlot/__snapshots__/index.test.jsx.snap +14 -0
- package/src/slots/WidgetSidebarSlot/images/readme_custom_sidebar.png +0 -0
- package/src/slots/WidgetSidebarSlot/images/widget_sidebar_slot.png +0 -0
- package/src/slots/WidgetSidebarSlot/index.jsx +10 -0
- package/src/slots/WidgetSidebarSlot/index.test.jsx +18 -0
- package/src/slots.tsx +9 -0
- package/src/test/app.test.jsx +255 -0
- package/src/test/inspector.js +50 -0
- package/src/test/messages.js +29 -0
- package/src/test/utils.js +3 -0
- package/src/testUtils.js +211 -0
- package/src/tracking/constants.js +50 -0
- package/src/tracking/index.js +17 -0
- package/src/tracking/trackers/course.js +44 -0
- package/src/tracking/trackers/course.test.js +80 -0
- package/src/tracking/trackers/credit.js +20 -0
- package/src/tracking/trackers/credit.test.js +38 -0
- package/src/tracking/trackers/engagement.js +23 -0
- package/src/tracking/trackers/engagement.test.js +31 -0
- package/src/tracking/trackers/entitlements.js +34 -0
- package/src/tracking/trackers/entitlements.test.js +34 -0
- package/src/tracking/trackers/filter.js +21 -0
- package/src/tracking/trackers/filter.test.js +45 -0
- package/src/tracking/trackers/findCourses.js +16 -0
- package/src/tracking/trackers/findCourses.test.js +45 -0
- package/src/tracking/trackers/socialShare.js +11 -0
- package/src/tracking/trackers/socialShare.test.js +17 -0
- package/src/utils/StrictDict.js +19 -0
- package/src/utils/StrictDict.test.js +66 -0
- package/src/utils/dateFormatter.js +9 -0
- package/src/utils/hooks.js +12 -0
- package/src/utils/index.js +5 -0
- package/src/utils/keyStore.js +10 -0
- package/src/widgets/LearnerDashboardHeader/ConfirmEmailBanner/ConfirmEmailBanner.scss +3 -0
- package/src/widgets/LearnerDashboardHeader/ConfirmEmailBanner/assets/confirm-email.svg +76 -0
- package/src/widgets/LearnerDashboardHeader/ConfirmEmailBanner/hooks.js +45 -0
- package/src/widgets/LearnerDashboardHeader/ConfirmEmailBanner/index.jsx +66 -0
- package/src/widgets/LearnerDashboardHeader/ConfirmEmailBanner/messages.js +36 -0
- package/src/widgets/LearnerDashboardHeader/CoursesLink.jsx +14 -0
- package/src/widgets/LearnerDashboardHeader/DiscoverLinkMenuItem.jsx +30 -0
- package/src/widgets/LearnerDashboardHeader/MasqueradeBar/hooks.js +69 -0
- package/src/widgets/LearnerDashboardHeader/MasqueradeBar/index.jsx +92 -0
- package/src/widgets/LearnerDashboardHeader/MasqueradeBar/index.scss +38 -0
- package/src/widgets/LearnerDashboardHeader/MasqueradeBar/messages.js +36 -0
- package/src/widgets/LearnerDashboardHeader/OrderHistoryLinkMenuItem.jsx +29 -0
- package/src/widgets/LearnerDashboardHeader/ProgramsLinkMenuItem.jsx +26 -0
- package/src/widgets/LearnerDashboardHeader/SupportLinkMenuItem.jsx +29 -0
- package/src/widgets/LearnerDashboardHeader/app.tsx +93 -0
- package/src/widgets/LearnerDashboardHeader/hooks.js +20 -0
- package/src/widgets/LearnerDashboardHeader/index.ts +1 -0
- package/src/widgets/LearnerDashboardHeader/messages.js +91 -0
- package/src/widgets/LookingForChallengeWidget/__snapshots__/index.test.jsx.snap +45 -0
- package/src/widgets/LookingForChallengeWidget/index.jsx +47 -0
- package/src/widgets/LookingForChallengeWidget/index.scss +6 -0
- package/src/widgets/LookingForChallengeWidget/index.test.jsx +24 -0
- package/src/widgets/LookingForChallengeWidget/messages.js +16 -0
- package/src/widgets/LookingForChallengeWidget/track.js +15 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { shallow } from '@edx/react-unit-test-utils';
|
|
2
|
+
|
|
3
|
+
import track from 'tracking';
|
|
4
|
+
import { reduxHooks } from 'hooks';
|
|
5
|
+
import useActionDisabledState from '../hooks';
|
|
6
|
+
import ViewCourseButton from './ViewCourseButton';
|
|
7
|
+
|
|
8
|
+
jest.mock('tracking', () => ({
|
|
9
|
+
course: {
|
|
10
|
+
enterCourseClicked: jest.fn().mockName('segment.enterCourseClicked'),
|
|
11
|
+
},
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
jest.mock('hooks', () => ({
|
|
15
|
+
reduxHooks: {
|
|
16
|
+
useCardCourseRunData: jest.fn(() => ({ homeUrl: 'homeUrl' })),
|
|
17
|
+
useTrackCourseEvent: jest.fn(
|
|
18
|
+
(eventName, cardId, url) => ({ trackCourseEvent: { eventName, cardId, url } }),
|
|
19
|
+
),
|
|
20
|
+
},
|
|
21
|
+
}));
|
|
22
|
+
jest.mock('../hooks', () => jest.fn(() => ({ disableViewCourse: false })));
|
|
23
|
+
jest.mock('./ActionButton', () => 'ActionButton');
|
|
24
|
+
|
|
25
|
+
const defaultProps = { cardId: 'cardId' };
|
|
26
|
+
const homeUrl = 'homeUrl';
|
|
27
|
+
|
|
28
|
+
describe('ViewCourseButton', () => {
|
|
29
|
+
test('learner can view course', () => {
|
|
30
|
+
const wrapper = shallow(<ViewCourseButton {...defaultProps} />);
|
|
31
|
+
expect(wrapper.snapshot).toMatchSnapshot();
|
|
32
|
+
expect(wrapper.instance.props.onClick).toEqual(reduxHooks.useTrackCourseEvent(
|
|
33
|
+
track.course.enterCourseClicked,
|
|
34
|
+
defaultProps.cardId,
|
|
35
|
+
homeUrl,
|
|
36
|
+
));
|
|
37
|
+
expect(wrapper.instance.props.disabled).toEqual(false);
|
|
38
|
+
});
|
|
39
|
+
test('learner cannot view course', () => {
|
|
40
|
+
useActionDisabledState.mockReturnValueOnce({ disableViewCourse: true });
|
|
41
|
+
const wrapper = shallow(<ViewCourseButton {...defaultProps} />);
|
|
42
|
+
expect(wrapper.snapshot).toMatchSnapshot();
|
|
43
|
+
expect(wrapper.instance.props.disabled).toEqual(true);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`BeginCourseButton snapshot disabled snapshot 1`] = `
|
|
4
|
+
<ActionButton
|
|
5
|
+
as="a"
|
|
6
|
+
disabled={true}
|
|
7
|
+
href="#"
|
|
8
|
+
onClick={
|
|
9
|
+
{
|
|
10
|
+
"trackCourseEvent": {
|
|
11
|
+
"cardId": "cardId",
|
|
12
|
+
"eventName": [MockFunction segment.enterCourseClicked],
|
|
13
|
+
"url": "home-urlexec-ed-tracking-path=cardId",
|
|
14
|
+
},
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
>
|
|
18
|
+
Begin Course
|
|
19
|
+
</ActionButton>
|
|
20
|
+
`;
|
|
21
|
+
|
|
22
|
+
exports[`BeginCourseButton snapshot enabled snapshot 1`] = `
|
|
23
|
+
<ActionButton
|
|
24
|
+
as="a"
|
|
25
|
+
disabled={false}
|
|
26
|
+
href="#"
|
|
27
|
+
onClick={
|
|
28
|
+
{
|
|
29
|
+
"trackCourseEvent": {
|
|
30
|
+
"cardId": "cardId",
|
|
31
|
+
"eventName": [MockFunction segment.enterCourseClicked],
|
|
32
|
+
"url": "home-urlexec-ed-tracking-path=cardId",
|
|
33
|
+
},
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
>
|
|
37
|
+
Begin Course
|
|
38
|
+
</ActionButton>
|
|
39
|
+
`;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`ResumeButton snapshot disabled snapshot 1`] = `
|
|
4
|
+
<ActionButton
|
|
5
|
+
as="a"
|
|
6
|
+
disabled={true}
|
|
7
|
+
href="#"
|
|
8
|
+
onClick={
|
|
9
|
+
{
|
|
10
|
+
"trackCourseEvent": {
|
|
11
|
+
"cardId": "cardId",
|
|
12
|
+
"eventName": [MockFunction segment.enterCourseClicked],
|
|
13
|
+
"url": "resume-urlexec-ed-tracking-path=cardId",
|
|
14
|
+
},
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
>
|
|
18
|
+
Resume
|
|
19
|
+
</ActionButton>
|
|
20
|
+
`;
|
|
21
|
+
|
|
22
|
+
exports[`ResumeButton snapshot enabled snapshot 1`] = `
|
|
23
|
+
<ActionButton
|
|
24
|
+
as="a"
|
|
25
|
+
disabled={false}
|
|
26
|
+
href="#"
|
|
27
|
+
onClick={
|
|
28
|
+
{
|
|
29
|
+
"trackCourseEvent": {
|
|
30
|
+
"cardId": "cardId",
|
|
31
|
+
"eventName": [MockFunction segment.enterCourseClicked],
|
|
32
|
+
"url": "resume-urlexec-ed-tracking-path=cardId",
|
|
33
|
+
},
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
>
|
|
37
|
+
Resume
|
|
38
|
+
</ActionButton>
|
|
39
|
+
`;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`SelectSessionButton default render 1`] = `
|
|
4
|
+
<ActionButton
|
|
5
|
+
disabled={false}
|
|
6
|
+
onClick={[MockFunction mockOpenSessionModal]}
|
|
7
|
+
>
|
|
8
|
+
Select Session
|
|
9
|
+
</ActionButton>
|
|
10
|
+
`;
|
|
11
|
+
|
|
12
|
+
exports[`SelectSessionButton disabled states 1`] = `
|
|
13
|
+
<ActionButton
|
|
14
|
+
disabled={true}
|
|
15
|
+
onClick={[MockFunction mockOpenSessionModal]}
|
|
16
|
+
>
|
|
17
|
+
Select Session
|
|
18
|
+
</ActionButton>
|
|
19
|
+
`;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`ViewCourseButton learner can view course 1`] = `
|
|
4
|
+
<ActionButton
|
|
5
|
+
as="a"
|
|
6
|
+
disabled={false}
|
|
7
|
+
href="#"
|
|
8
|
+
onClick={
|
|
9
|
+
{
|
|
10
|
+
"trackCourseEvent": {
|
|
11
|
+
"cardId": "cardId",
|
|
12
|
+
"eventName": [MockFunction segment.enterCourseClicked],
|
|
13
|
+
"url": "homeUrl",
|
|
14
|
+
},
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
>
|
|
18
|
+
View Course
|
|
19
|
+
</ActionButton>
|
|
20
|
+
`;
|
|
21
|
+
|
|
22
|
+
exports[`ViewCourseButton learner cannot view course 1`] = `
|
|
23
|
+
<ActionButton
|
|
24
|
+
as="a"
|
|
25
|
+
disabled={true}
|
|
26
|
+
href="#"
|
|
27
|
+
onClick={
|
|
28
|
+
{
|
|
29
|
+
"trackCourseEvent": {
|
|
30
|
+
"cardId": "cardId",
|
|
31
|
+
"eventName": [MockFunction segment.enterCourseClicked],
|
|
32
|
+
"url": "homeUrl",
|
|
33
|
+
},
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
>
|
|
37
|
+
View Course
|
|
38
|
+
</ActionButton>
|
|
39
|
+
`;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
import { ActionRow } from '@openedx/paragon';
|
|
5
|
+
|
|
6
|
+
import { reduxHooks } from '../../../../hooks';
|
|
7
|
+
import CourseCardActionSlot from '../../../../slots/CourseCardActionSlot';
|
|
8
|
+
|
|
9
|
+
import SelectSessionButton from './SelectSessionButton';
|
|
10
|
+
import BeginCourseButton from './BeginCourseButton';
|
|
11
|
+
import ResumeButton from './ResumeButton';
|
|
12
|
+
import ViewCourseButton from './ViewCourseButton';
|
|
13
|
+
|
|
14
|
+
export const CourseCardActions = ({ cardId }) => {
|
|
15
|
+
const { isEntitlement, isFulfilled } = reduxHooks.useCardEntitlementData(cardId);
|
|
16
|
+
const {
|
|
17
|
+
hasStarted,
|
|
18
|
+
} = reduxHooks.useCardEnrollmentData(cardId);
|
|
19
|
+
const { isArchived } = reduxHooks.useCardCourseRunData(cardId);
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<ActionRow data-test-id="CourseCardActions">
|
|
23
|
+
<CourseCardActionSlot cardId={cardId} />
|
|
24
|
+
{isEntitlement && (isFulfilled
|
|
25
|
+
? <ViewCourseButton cardId={cardId} />
|
|
26
|
+
: <SelectSessionButton cardId={cardId} />
|
|
27
|
+
)}
|
|
28
|
+
{(isArchived && !isEntitlement) && (
|
|
29
|
+
<ViewCourseButton cardId={cardId} />
|
|
30
|
+
)}
|
|
31
|
+
{!(isArchived || isEntitlement) && (hasStarted
|
|
32
|
+
? <ResumeButton cardId={cardId} />
|
|
33
|
+
: <BeginCourseButton cardId={cardId} />
|
|
34
|
+
)}
|
|
35
|
+
</ActionRow>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
CourseCardActions.propTypes = {
|
|
39
|
+
cardId: PropTypes.string.isRequired,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default CourseCardActions;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { shallow } from '@edx/react-unit-test-utils';
|
|
2
|
+
|
|
3
|
+
import { reduxHooks } from 'hooks';
|
|
4
|
+
|
|
5
|
+
import CourseCardActionSlot from 'slots/CourseCardActionSlot';
|
|
6
|
+
import SelectSessionButton from './SelectSessionButton';
|
|
7
|
+
import BeginCourseButton from './BeginCourseButton';
|
|
8
|
+
import ResumeButton from './ResumeButton';
|
|
9
|
+
import ViewCourseButton from './ViewCourseButton';
|
|
10
|
+
|
|
11
|
+
import CourseCardActions from '.';
|
|
12
|
+
|
|
13
|
+
jest.mock('hooks', () => ({
|
|
14
|
+
reduxHooks: {
|
|
15
|
+
useCardCourseRunData: jest.fn(),
|
|
16
|
+
useCardEnrollmentData: jest.fn(),
|
|
17
|
+
useCardEntitlementData: jest.fn(),
|
|
18
|
+
useMasqueradeData: jest.fn(),
|
|
19
|
+
},
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
jest.mock('slots/CourseCardActionSlot', () => 'CustomActionButton');
|
|
23
|
+
jest.mock('./SelectSessionButton', () => 'SelectSessionButton');
|
|
24
|
+
jest.mock('./ViewCourseButton', () => 'ViewCourseButton');
|
|
25
|
+
jest.mock('./BeginCourseButton', () => 'BeginCourseButton');
|
|
26
|
+
jest.mock('./ResumeButton', () => 'ResumeButton');
|
|
27
|
+
|
|
28
|
+
const cardId = 'test-card-id';
|
|
29
|
+
const props = { cardId };
|
|
30
|
+
|
|
31
|
+
let el;
|
|
32
|
+
describe('CourseCardActions', () => {
|
|
33
|
+
const mockHooks = ({
|
|
34
|
+
isEntitlement = false,
|
|
35
|
+
isExecEd2UCourse = false,
|
|
36
|
+
isFulfilled = false,
|
|
37
|
+
isArchived = false,
|
|
38
|
+
isVerified = false,
|
|
39
|
+
hasStarted = false,
|
|
40
|
+
isMasquerading = false,
|
|
41
|
+
} = {}) => {
|
|
42
|
+
reduxHooks.useCardEntitlementData.mockReturnValueOnce({ isEntitlement, isFulfilled });
|
|
43
|
+
reduxHooks.useCardCourseRunData.mockReturnValueOnce({ isArchived });
|
|
44
|
+
reduxHooks.useCardEnrollmentData.mockReturnValueOnce({ isExecEd2UCourse, isVerified, hasStarted });
|
|
45
|
+
reduxHooks.useMasqueradeData.mockReturnValueOnce({ isMasquerading });
|
|
46
|
+
};
|
|
47
|
+
const render = () => {
|
|
48
|
+
el = shallow(<CourseCardActions {...props} />);
|
|
49
|
+
};
|
|
50
|
+
describe('behavior', () => {
|
|
51
|
+
it('initializes redux hooks', () => {
|
|
52
|
+
mockHooks();
|
|
53
|
+
render();
|
|
54
|
+
expect(reduxHooks.useCardEntitlementData).toHaveBeenCalledWith(cardId);
|
|
55
|
+
expect(reduxHooks.useCardEnrollmentData).toHaveBeenCalledWith(cardId);
|
|
56
|
+
expect(reduxHooks.useCardCourseRunData).toHaveBeenCalledWith(cardId);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
describe('output', () => {
|
|
60
|
+
describe('entitlement course', () => {
|
|
61
|
+
it('renders ViewCourseButton if fulfilled', () => {
|
|
62
|
+
mockHooks({ isEntitlement: true, isFulfilled: true });
|
|
63
|
+
render();
|
|
64
|
+
expect(el.instance.findByType(ViewCourseButton)[0].props.cardId).toEqual(cardId);
|
|
65
|
+
});
|
|
66
|
+
it('renders SelectSessionButton if not fulfilled', () => {
|
|
67
|
+
mockHooks({ isEntitlement: true });
|
|
68
|
+
render();
|
|
69
|
+
expect(el.instance.findByType(SelectSessionButton)[0].props.cardId).toEqual(cardId);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
describe('not entitlement, verified, or exec ed', () => {
|
|
73
|
+
it('renders CourseCardActionSlot and ViewCourseButton for archived courses', () => {
|
|
74
|
+
mockHooks({ isArchived: true });
|
|
75
|
+
render();
|
|
76
|
+
expect(el.instance.findByType(CourseCardActionSlot)[0].props.cardId).toEqual(cardId);
|
|
77
|
+
expect(el.instance.findByType(ViewCourseButton)[0].props.cardId).toEqual(cardId);
|
|
78
|
+
});
|
|
79
|
+
describe('unstarted courses', () => {
|
|
80
|
+
it('renders CourseCardActionSlot and BeginCourseButton', () => {
|
|
81
|
+
mockHooks();
|
|
82
|
+
render();
|
|
83
|
+
expect(el.instance.findByType(CourseCardActionSlot)[0].props.cardId).toEqual(cardId);
|
|
84
|
+
expect(el.instance.findByType(BeginCourseButton)[0].props.cardId).toEqual(cardId);
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
describe('active courses (started, and not archived)', () => {
|
|
88
|
+
it('renders CourseCardActionSlot and ResumeButton', () => {
|
|
89
|
+
mockHooks({ hasStarted: true });
|
|
90
|
+
render();
|
|
91
|
+
expect(el.instance.findByType(CourseCardActionSlot)[0].props.cardId).toEqual(cardId);
|
|
92
|
+
expect(el.instance.findByType(ResumeButton)[0].props.cardId).toEqual(cardId);
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { defineMessages } from '@openedx/frontend-base';
|
|
2
|
+
|
|
3
|
+
const messages = defineMessages({
|
|
4
|
+
beginCourse: {
|
|
5
|
+
id: 'learner-dash.courseCard.actions.beginCourse',
|
|
6
|
+
description: 'Course card begin-course button text',
|
|
7
|
+
defaultMessage: 'Begin Course',
|
|
8
|
+
},
|
|
9
|
+
resume: {
|
|
10
|
+
id: 'learner-dash.courseCard.actions.resume',
|
|
11
|
+
description: 'Course card resume button text',
|
|
12
|
+
defaultMessage: 'Resume',
|
|
13
|
+
},
|
|
14
|
+
viewCourse: {
|
|
15
|
+
id: 'learner-dash.courseCard.actions.viewCourse',
|
|
16
|
+
description: 'Course card view-course button text',
|
|
17
|
+
defaultMessage: 'View Course',
|
|
18
|
+
},
|
|
19
|
+
selectSession: {
|
|
20
|
+
id: 'learner-dash.courseCard.actions.selectSession',
|
|
21
|
+
description: 'Course card select-session button text',
|
|
22
|
+
defaultMessage: 'Select Session',
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export default messages;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/* eslint-disable max-len */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
|
|
5
|
+
import { MailtoLink, Hyperlink } from '@openedx/paragon';
|
|
6
|
+
import { CheckCircle } from '@openedx/paragon/icons';
|
|
7
|
+
import { useIntl } from '@openedx/frontend-base';
|
|
8
|
+
|
|
9
|
+
import { utilHooks, reduxHooks } from '../../../../hooks';
|
|
10
|
+
import Banner from '../../../../components/Banner';
|
|
11
|
+
|
|
12
|
+
import messages from './messages';
|
|
13
|
+
|
|
14
|
+
const { useFormatDate } = utilHooks;
|
|
15
|
+
|
|
16
|
+
export const CertificateBanner = ({ cardId }) => {
|
|
17
|
+
const certificate = reduxHooks.useCardCertificateData(cardId);
|
|
18
|
+
const {
|
|
19
|
+
isAudit,
|
|
20
|
+
isVerified,
|
|
21
|
+
} = reduxHooks.useCardEnrollmentData(cardId);
|
|
22
|
+
const { isPassing } = reduxHooks.useCardGradeData(cardId);
|
|
23
|
+
const { isArchived } = reduxHooks.useCardCourseRunData(cardId);
|
|
24
|
+
const { minPassingGrade, progressUrl } = reduxHooks.useCardCourseRunData(cardId);
|
|
25
|
+
const { supportEmail, billingEmail } = reduxHooks.usePlatformSettingsData();
|
|
26
|
+
const { formatMessage } = useIntl();
|
|
27
|
+
const formatDate = useFormatDate();
|
|
28
|
+
|
|
29
|
+
const emailLink = address => <MailtoLink to={address}>{address}</MailtoLink>;
|
|
30
|
+
|
|
31
|
+
if (certificate.isRestricted) {
|
|
32
|
+
return (
|
|
33
|
+
<Banner variant="danger">
|
|
34
|
+
{supportEmail ? formatMessage(messages.certRestricted, { supportEmail: emailLink(supportEmail) }) : formatMessage(messages.certRestrictedNoEmail)}
|
|
35
|
+
{isVerified && ' '}
|
|
36
|
+
{isVerified && (billingEmail ? formatMessage(messages.certRefundContactBilling, { billingEmail: emailLink(billingEmail) }) : formatMessage(messages.certRefundContactBillingNoEmail))}
|
|
37
|
+
</Banner>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
if (certificate.isDownloadable) {
|
|
41
|
+
return (
|
|
42
|
+
<Banner variant="success" icon={CheckCircle}>
|
|
43
|
+
{formatMessage(messages.certReady)}
|
|
44
|
+
{certificate.certPreviewUrl && (
|
|
45
|
+
<>
|
|
46
|
+
{' '}
|
|
47
|
+
<Hyperlink isInline destination={certificate.certPreviewUrl}>
|
|
48
|
+
{formatMessage(messages.viewCertificate)}
|
|
49
|
+
</Hyperlink>
|
|
50
|
+
</>
|
|
51
|
+
)}
|
|
52
|
+
</Banner>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
if (!isPassing) {
|
|
56
|
+
if (isAudit) {
|
|
57
|
+
return (
|
|
58
|
+
<Banner>
|
|
59
|
+
{formatMessage(messages.passingGrade, { minPassingGrade })}
|
|
60
|
+
</Banner>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
if (isArchived) {
|
|
64
|
+
return (
|
|
65
|
+
<Banner variant="warning">
|
|
66
|
+
{formatMessage(messages.notEligibleForCert)}
|
|
67
|
+
{' '}
|
|
68
|
+
<Hyperlink isInline destination={progressUrl}>{formatMessage(messages.viewGrades)}</Hyperlink>
|
|
69
|
+
</Banner>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
return (
|
|
73
|
+
<Banner variant="warning">
|
|
74
|
+
{formatMessage(messages.certMinGrade, { minPassingGrade })}
|
|
75
|
+
</Banner>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
if (certificate.isEarnedButUnavailable) {
|
|
79
|
+
return (
|
|
80
|
+
<Banner>
|
|
81
|
+
{formatMessage(
|
|
82
|
+
messages.gradeAndCertReadyAfter,
|
|
83
|
+
{ availableDate: formatDate(certificate.availableDate) },
|
|
84
|
+
)}
|
|
85
|
+
</Banner>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return null;
|
|
90
|
+
};
|
|
91
|
+
CertificateBanner.propTypes = {
|
|
92
|
+
cardId: PropTypes.string.isRequired,
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export default CertificateBanner;
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { shallow } from '@edx/react-unit-test-utils';
|
|
2
|
+
|
|
3
|
+
import { reduxHooks } from 'hooks';
|
|
4
|
+
import CertificateBanner from './CertificateBanner';
|
|
5
|
+
import messages from './messages';
|
|
6
|
+
|
|
7
|
+
jest.mock('hooks', () => ({
|
|
8
|
+
utilHooks: {
|
|
9
|
+
useFormatDate: jest.fn(() => date => date),
|
|
10
|
+
},
|
|
11
|
+
reduxHooks: {
|
|
12
|
+
useCardCertificateData: jest.fn(),
|
|
13
|
+
useCardCourseRunData: jest.fn(),
|
|
14
|
+
useCardEnrollmentData: jest.fn(),
|
|
15
|
+
useCardGradeData: jest.fn(),
|
|
16
|
+
usePlatformSettingsData: jest.fn(),
|
|
17
|
+
},
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
jest.mock('components/Banner', () => 'Banner');
|
|
21
|
+
|
|
22
|
+
describe('CertificateBanner', () => {
|
|
23
|
+
const props = { cardId: 'cardId' };
|
|
24
|
+
reduxHooks.useCardCourseRunData.mockReturnValue({
|
|
25
|
+
minPassingGrade: 0.8,
|
|
26
|
+
progressUrl: 'progressUrl',
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const defaultCertificate = {
|
|
30
|
+
availableDate: '10/20/3030',
|
|
31
|
+
isRestricted: false,
|
|
32
|
+
isDownloadable: false,
|
|
33
|
+
isEarnedButUnavailable: false,
|
|
34
|
+
};
|
|
35
|
+
const defaultEnrollment = {
|
|
36
|
+
isAudit: false,
|
|
37
|
+
isVerified: false,
|
|
38
|
+
};
|
|
39
|
+
const defaultCourseRun = { isArchived: false };
|
|
40
|
+
const defaultGrade = { isPassing: false };
|
|
41
|
+
const defaultPlatformSettings = {};
|
|
42
|
+
const createWrapper = ({
|
|
43
|
+
certificate = {},
|
|
44
|
+
enrollment = {},
|
|
45
|
+
grade = {},
|
|
46
|
+
courseRun = {},
|
|
47
|
+
platformSettings = {},
|
|
48
|
+
}) => {
|
|
49
|
+
reduxHooks.useCardGradeData.mockReturnValueOnce({ ...defaultGrade, ...grade });
|
|
50
|
+
reduxHooks.useCardCertificateData.mockReturnValueOnce({ ...defaultCertificate, ...certificate });
|
|
51
|
+
reduxHooks.useCardEnrollmentData.mockReturnValueOnce({ ...defaultEnrollment, ...enrollment });
|
|
52
|
+
reduxHooks.useCardCourseRunData.mockReturnValueOnce({ ...defaultCourseRun, ...courseRun });
|
|
53
|
+
reduxHooks.usePlatformSettingsData.mockReturnValueOnce({ ...defaultPlatformSettings, ...platformSettings });
|
|
54
|
+
return shallow(<CertificateBanner {...props} />);
|
|
55
|
+
};
|
|
56
|
+
/** TODO: Update tests to validate snapshots **/
|
|
57
|
+
describe('snapshot', () => {
|
|
58
|
+
test('is restricted', () => {
|
|
59
|
+
const wrapper = createWrapper({
|
|
60
|
+
certificate: {
|
|
61
|
+
isRestricted: true,
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
expect(wrapper.snapshot).toMatchSnapshot();
|
|
65
|
+
});
|
|
66
|
+
test('is restricted with support email', () => {
|
|
67
|
+
const wrapper = createWrapper({
|
|
68
|
+
certificate: {
|
|
69
|
+
isRestricted: true,
|
|
70
|
+
},
|
|
71
|
+
platformSettings: {
|
|
72
|
+
supportEmail: 'suport@email',
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
expect(wrapper.snapshot).toMatchSnapshot();
|
|
76
|
+
});
|
|
77
|
+
test('is restricted with billing email', () => {
|
|
78
|
+
const wrapper = createWrapper({
|
|
79
|
+
certificate: {
|
|
80
|
+
isRestricted: true,
|
|
81
|
+
},
|
|
82
|
+
platformSettings: {
|
|
83
|
+
billingEmail: 'billing@email',
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
expect(wrapper.snapshot).toMatchSnapshot();
|
|
87
|
+
});
|
|
88
|
+
test('is restricted and verified', () => {
|
|
89
|
+
const wrapper = createWrapper({
|
|
90
|
+
certificate: {
|
|
91
|
+
isRestricted: true,
|
|
92
|
+
},
|
|
93
|
+
enrollment: {
|
|
94
|
+
isVerified: true,
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
expect(wrapper.snapshot).toMatchSnapshot();
|
|
98
|
+
});
|
|
99
|
+
test('is restricted and verified with support email', () => {
|
|
100
|
+
const wrapper = createWrapper({
|
|
101
|
+
certificate: {
|
|
102
|
+
isRestricted: true,
|
|
103
|
+
},
|
|
104
|
+
enrollment: {
|
|
105
|
+
isVerified: true,
|
|
106
|
+
},
|
|
107
|
+
platformSettings: {
|
|
108
|
+
supportEmail: 'suport@email',
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
expect(wrapper.snapshot).toMatchSnapshot();
|
|
112
|
+
});
|
|
113
|
+
test('is restricted and verified with billing email', () => {
|
|
114
|
+
const wrapper = createWrapper({
|
|
115
|
+
certificate: {
|
|
116
|
+
isRestricted: true,
|
|
117
|
+
},
|
|
118
|
+
enrollment: {
|
|
119
|
+
isVerified: true,
|
|
120
|
+
},
|
|
121
|
+
platformSettings: {
|
|
122
|
+
billingEmail: 'billing@email',
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
expect(wrapper.snapshot).toMatchSnapshot();
|
|
126
|
+
});
|
|
127
|
+
test('is restricted and verified with support and billing email', () => {
|
|
128
|
+
const wrapper = createWrapper({
|
|
129
|
+
certificate: {
|
|
130
|
+
isRestricted: true,
|
|
131
|
+
},
|
|
132
|
+
enrollment: {
|
|
133
|
+
isVerified: true,
|
|
134
|
+
},
|
|
135
|
+
platformSettings: {
|
|
136
|
+
supportEmail: 'suport@email',
|
|
137
|
+
billingEmail: 'billing@email',
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
expect(wrapper.snapshot).toMatchSnapshot();
|
|
141
|
+
});
|
|
142
|
+
test('is passing and is downloadable', () => {
|
|
143
|
+
const wrapper = createWrapper({
|
|
144
|
+
grade: { isPassing: true },
|
|
145
|
+
certificate: { isDownloadable: true },
|
|
146
|
+
});
|
|
147
|
+
expect(wrapper.snapshot).toMatchSnapshot();
|
|
148
|
+
});
|
|
149
|
+
test('not passing and is downloadable', () => {
|
|
150
|
+
const wrapper = createWrapper({
|
|
151
|
+
grade: { isPassing: false },
|
|
152
|
+
certificate: { isDownloadable: true },
|
|
153
|
+
});
|
|
154
|
+
expect(wrapper.snapshot).toMatchSnapshot();
|
|
155
|
+
});
|
|
156
|
+
test('not passing and audit', () => {
|
|
157
|
+
const wrapper = createWrapper({
|
|
158
|
+
enrollment: {
|
|
159
|
+
isAudit: true,
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
expect(wrapper.snapshot).toMatchSnapshot();
|
|
163
|
+
});
|
|
164
|
+
test('not passing and has finished', () => {
|
|
165
|
+
const wrapper = createWrapper({
|
|
166
|
+
courseRun: { isArchived: true },
|
|
167
|
+
});
|
|
168
|
+
expect(wrapper.snapshot).toMatchSnapshot();
|
|
169
|
+
});
|
|
170
|
+
test('not passing and not audit and not finished', () => {
|
|
171
|
+
const wrapper = createWrapper({});
|
|
172
|
+
expect(wrapper.snapshot).toMatchSnapshot();
|
|
173
|
+
});
|
|
174
|
+
test('is passing and is earned but unavailable', () => {
|
|
175
|
+
const wrapper = createWrapper({
|
|
176
|
+
grade: {
|
|
177
|
+
isPassing: true,
|
|
178
|
+
},
|
|
179
|
+
certificate: {
|
|
180
|
+
isEarnedButUnavailable: true,
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
expect(wrapper.snapshot).toMatchSnapshot();
|
|
184
|
+
});
|
|
185
|
+
test('is passing and not downloadable render empty', () => {
|
|
186
|
+
const wrapper = createWrapper({
|
|
187
|
+
grade: {
|
|
188
|
+
isPassing: true,
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
expect(wrapper.snapshot).toMatchSnapshot();
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
describe('behavior', () => {
|
|
195
|
+
it('is restricted', () => {
|
|
196
|
+
const wrapper = createWrapper({
|
|
197
|
+
certificate: {
|
|
198
|
+
isRestricted: true,
|
|
199
|
+
},
|
|
200
|
+
platformSettings: {
|
|
201
|
+
supportEmail: 'suport@email',
|
|
202
|
+
billingEmail: 'billing@email',
|
|
203
|
+
},
|
|
204
|
+
});
|
|
205
|
+
const bannerMessage = wrapper.instance.findByType('format-message-function').map(el => el.props.message.defaultMessage).join('\n');
|
|
206
|
+
expect(bannerMessage).toEqual(messages.certRestricted.defaultMessage);
|
|
207
|
+
expect(bannerMessage).toContain(messages.certRestricted.defaultMessage);
|
|
208
|
+
});
|
|
209
|
+
it('is restricted and verified', () => {
|
|
210
|
+
const wrapper = createWrapper({
|
|
211
|
+
certificate: {
|
|
212
|
+
isRestricted: true,
|
|
213
|
+
},
|
|
214
|
+
enrollment: {
|
|
215
|
+
isVerified: true,
|
|
216
|
+
},
|
|
217
|
+
platformSettings: {
|
|
218
|
+
supportEmail: 'suport@email',
|
|
219
|
+
billingEmail: 'billing@email',
|
|
220
|
+
},
|
|
221
|
+
});
|
|
222
|
+
const bannerMessage = wrapper.instance.findByType('format-message-function').map(el => el.props.message.defaultMessage).join('\n');
|
|
223
|
+
expect(bannerMessage).toContain(messages.certRestricted.defaultMessage);
|
|
224
|
+
expect(bannerMessage).toContain(messages.certRefundContactBilling.defaultMessage);
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
});
|