@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,34 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
|
|
4
|
+
import useCreditRequestFormData from './hooks';
|
|
5
|
+
import CreditRequestForm from '.';
|
|
6
|
+
|
|
7
|
+
jest.unmock('@openedx/paragon');
|
|
8
|
+
jest.unmock('react');
|
|
9
|
+
|
|
10
|
+
jest.mock('./hooks', () => ({
|
|
11
|
+
__esModule: true,
|
|
12
|
+
default: jest.fn(),
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
const ref = { current: { click: jest.fn() }, useRef: jest.fn() };
|
|
16
|
+
const requestData = {
|
|
17
|
+
url: 'test-request-data-url',
|
|
18
|
+
parameters: {
|
|
19
|
+
key1: 'val1',
|
|
20
|
+
key2: 'val2',
|
|
21
|
+
key3: 'val3',
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
useCreditRequestFormData.mockReturnValue({ ref });
|
|
26
|
+
|
|
27
|
+
let el;
|
|
28
|
+
describe('CreditRequestForm component ref behavior', () => {
|
|
29
|
+
it('loads submit button with ref from hook', () => {
|
|
30
|
+
el = render(<CreditRequestForm requestData={requestData} />);
|
|
31
|
+
const button = el.getByRole('button');
|
|
32
|
+
expect(ref.current).toEqual(button);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/* eslint-disable max-len */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
|
|
5
|
+
import { reduxHooks } from '../../../../../../../hooks';
|
|
6
|
+
import { Hyperlink } from '@openedx/paragon';
|
|
7
|
+
|
|
8
|
+
export const ProviderLink = ({ cardId }) => {
|
|
9
|
+
const credit = reduxHooks.useCardCreditData(cardId);
|
|
10
|
+
return (
|
|
11
|
+
<Hyperlink
|
|
12
|
+
href={credit.providerStatusUrl}
|
|
13
|
+
rel="noopener"
|
|
14
|
+
target="_blank"
|
|
15
|
+
>
|
|
16
|
+
{credit.providerName}
|
|
17
|
+
</Hyperlink>
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
ProviderLink.propTypes = {
|
|
21
|
+
cardId: PropTypes.string.isRequired,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default ProviderLink;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { shallow } from '@edx/react-unit-test-utils';
|
|
3
|
+
|
|
4
|
+
import { reduxHooks } from 'hooks';
|
|
5
|
+
|
|
6
|
+
import ProviderLink from './ProviderLink';
|
|
7
|
+
|
|
8
|
+
jest.mock('hooks', () => ({
|
|
9
|
+
reduxHooks: {
|
|
10
|
+
useCardCreditData: jest.fn(),
|
|
11
|
+
},
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
const cardId = 'test-card-id';
|
|
15
|
+
const credit = {
|
|
16
|
+
providerStatusUrl: 'test-credit-provider-status-url',
|
|
17
|
+
providerName: 'test-credit-provider-name',
|
|
18
|
+
};
|
|
19
|
+
let el;
|
|
20
|
+
|
|
21
|
+
describe('ProviderLink component', () => {
|
|
22
|
+
beforeEach(() => {
|
|
23
|
+
reduxHooks.useCardCreditData.mockReturnValue(credit);
|
|
24
|
+
el = shallow(<ProviderLink cardId={cardId} />);
|
|
25
|
+
});
|
|
26
|
+
describe('behavior', () => {
|
|
27
|
+
it('initializes credit hook with cardId', () => {
|
|
28
|
+
expect(reduxHooks.useCardCreditData).toHaveBeenCalledWith(cardId);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
describe('render', () => {
|
|
32
|
+
test('snapshot', () => {
|
|
33
|
+
expect(el.snapshot).toMatchSnapshot();
|
|
34
|
+
});
|
|
35
|
+
it('passes credit.providerStatusUrl to the hyperlink href', () => {
|
|
36
|
+
expect(el.instance.findByType('Hyperlink')[0].props.href).toEqual(credit.providerStatusUrl);
|
|
37
|
+
});
|
|
38
|
+
it('passes providerName for the link message', () => {
|
|
39
|
+
expect(el.instance.findByType('Hyperlink')[0].children[0].el).toEqual(credit.providerName);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`CreditContent component render with action snapshot 1`] = `
|
|
4
|
+
<Fragment>
|
|
5
|
+
<div
|
|
6
|
+
className="message-copy credit-msg"
|
|
7
|
+
data-testid="credit-msg"
|
|
8
|
+
>
|
|
9
|
+
test-message
|
|
10
|
+
</div>
|
|
11
|
+
<ActionRow
|
|
12
|
+
className="mt-4"
|
|
13
|
+
>
|
|
14
|
+
<Button
|
|
15
|
+
as="a"
|
|
16
|
+
className="border-gray-400"
|
|
17
|
+
data-testid="action-row-btn"
|
|
18
|
+
disabled={false}
|
|
19
|
+
href="test-action-href"
|
|
20
|
+
onClick={[MockFunction test-action-onClick]}
|
|
21
|
+
rel="noopener"
|
|
22
|
+
target="_blank"
|
|
23
|
+
variant="outline-primary"
|
|
24
|
+
>
|
|
25
|
+
test-action-message
|
|
26
|
+
</Button>
|
|
27
|
+
</ActionRow>
|
|
28
|
+
<CreditRequestForm
|
|
29
|
+
requestData={
|
|
30
|
+
{
|
|
31
|
+
"parameters": {
|
|
32
|
+
"key1": "val1",
|
|
33
|
+
},
|
|
34
|
+
"url": "test-request-data-url",
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/>
|
|
38
|
+
</Fragment>
|
|
39
|
+
`;
|
|
40
|
+
|
|
41
|
+
exports[`CreditContent component render without action snapshot 1`] = `
|
|
42
|
+
<Fragment>
|
|
43
|
+
<div
|
|
44
|
+
className="message-copy credit-msg"
|
|
45
|
+
data-testid="credit-msg"
|
|
46
|
+
>
|
|
47
|
+
test-message
|
|
48
|
+
</div>
|
|
49
|
+
<CreditRequestForm
|
|
50
|
+
requestData={
|
|
51
|
+
{
|
|
52
|
+
"parameters": {
|
|
53
|
+
"key1": "val1",
|
|
54
|
+
},
|
|
55
|
+
"url": "test-request-data-url",
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/>
|
|
59
|
+
</Fragment>
|
|
60
|
+
`;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { StrictDict } from '../../../../../../utils';
|
|
4
|
+
import { apiHooks } from '../../../../../../hooks';
|
|
5
|
+
|
|
6
|
+
import * as module from './hooks';
|
|
7
|
+
|
|
8
|
+
export const state = StrictDict({
|
|
9
|
+
creditRequestData: (val) => React.useState(val), // eslint-disable-line
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export const useCreditRequestData = (cardId) => {
|
|
13
|
+
const [requestData, setRequestData] = module.state.creditRequestData(null);
|
|
14
|
+
const createCreditApiRequest = apiHooks.useCreateCreditRequest(cardId);
|
|
15
|
+
const createCreditRequest = (e) => {
|
|
16
|
+
e.preventDefault();
|
|
17
|
+
createCreditApiRequest()
|
|
18
|
+
.then((request) => {
|
|
19
|
+
setRequestData(request.data);
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
return { requestData, createCreditRequest };
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default {
|
|
26
|
+
useCreditRequestData,
|
|
27
|
+
};
|
package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/hooks.test.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { MockUseState } from 'testUtils';
|
|
2
|
+
import { apiHooks } from 'hooks';
|
|
3
|
+
import * as hooks from './hooks';
|
|
4
|
+
|
|
5
|
+
jest.mock('hooks', () => ({
|
|
6
|
+
apiHooks: {
|
|
7
|
+
useCreateCreditRequest: jest.fn(),
|
|
8
|
+
},
|
|
9
|
+
}));
|
|
10
|
+
|
|
11
|
+
const state = new MockUseState(hooks);
|
|
12
|
+
|
|
13
|
+
const cardId = 'test-card-id';
|
|
14
|
+
const requestData = { data: 'request data' };
|
|
15
|
+
const creditRequest = jest.fn().mockReturnValue(Promise.resolve(requestData));
|
|
16
|
+
apiHooks.useCreateCreditRequest.mockReturnValue(creditRequest);
|
|
17
|
+
const event = { preventDefault: jest.fn() };
|
|
18
|
+
|
|
19
|
+
let out;
|
|
20
|
+
describe('Credit Banner view hooks', () => {
|
|
21
|
+
describe('state', () => {
|
|
22
|
+
state.testGetter(state.keys.creditRequestData);
|
|
23
|
+
});
|
|
24
|
+
describe('useCreditRequestData', () => {
|
|
25
|
+
beforeEach(() => {
|
|
26
|
+
state.mock();
|
|
27
|
+
out = hooks.useCreditRequestData(cardId);
|
|
28
|
+
});
|
|
29
|
+
describe('behavior', () => {
|
|
30
|
+
it('initializes creditRequestData state field with null value', () => {
|
|
31
|
+
state.expectInitializedWith(state.keys.creditRequestData, null);
|
|
32
|
+
});
|
|
33
|
+
it('calls useCreateCreditRequest with passed cardID', () => {
|
|
34
|
+
expect(apiHooks.useCreateCreditRequest).toHaveBeenCalledWith(cardId);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
describe('output', () => {
|
|
38
|
+
it('returns requestData state value', () => {
|
|
39
|
+
state.mockVal(state.keys.creditRequestData, requestData);
|
|
40
|
+
out = hooks.useCreditRequestData(cardId);
|
|
41
|
+
expect(out.requestData).toEqual(requestData);
|
|
42
|
+
});
|
|
43
|
+
describe('createCreditRequest', () => {
|
|
44
|
+
it('returns an event handler that prevents default click behavior', () => {
|
|
45
|
+
out.createCreditRequest(event);
|
|
46
|
+
expect(event.preventDefault).toHaveBeenCalled();
|
|
47
|
+
});
|
|
48
|
+
it('calls api.createCreditRequest and sets requestData with the response', async () => {
|
|
49
|
+
await out.createCreditRequest(event);
|
|
50
|
+
expect(creditRequest).toHaveBeenCalledWith();
|
|
51
|
+
expect(state.setState.creditRequestData).toHaveBeenCalledWith(requestData.data);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { defineMessages } from '@openedx/frontend-base';
|
|
2
|
+
|
|
3
|
+
const messages = defineMessages({
|
|
4
|
+
approved: {
|
|
5
|
+
id: 'learner-dash.courseCard.banners.credit.approved',
|
|
6
|
+
description: 'Message shown when credit request has been approved',
|
|
7
|
+
defaultMessage: '{congratulations} {providerName} has approved your request for course credit. To see your course credit, visit the {linkToProviderSite} website.',
|
|
8
|
+
},
|
|
9
|
+
congratulations: {
|
|
10
|
+
id: 'learner-dash.courseCard.banners.credit.congratulations',
|
|
11
|
+
description: 'Congratulatory message for credit approval',
|
|
12
|
+
defaultMessage: 'Congratulations!',
|
|
13
|
+
},
|
|
14
|
+
eligible: {
|
|
15
|
+
id: 'learner-dash.courseCard.banners.credit.eligible',
|
|
16
|
+
description: 'Message shown when user is eligible to purchase course credit',
|
|
17
|
+
defaultMessage: 'You have completed this course and are eligible to purchase course credit. Select {getCredit} to get started.',
|
|
18
|
+
},
|
|
19
|
+
eligibleFromProvider: {
|
|
20
|
+
id: 'learner-dash.courseCard.banners.credit.eligibleFromProvider',
|
|
21
|
+
description: 'Message shown when user is eligible for credit from a specific provider',
|
|
22
|
+
defaultMessage: 'You are now eligible for credit from {providerName}. Congratulations!',
|
|
23
|
+
},
|
|
24
|
+
getCredit: {
|
|
25
|
+
id: 'learner-dash.courseCard.banners.credit.getCredit',
|
|
26
|
+
description: 'Button text for initiating the credit process',
|
|
27
|
+
defaultMessage: 'Get Credit',
|
|
28
|
+
},
|
|
29
|
+
mustRequest: {
|
|
30
|
+
id: 'learner-dash.courseCard.banners.credit.mustRequest',
|
|
31
|
+
description: 'Message shown after payment to instruct user to request credit',
|
|
32
|
+
defaultMessage: 'Thank you for your payment. To receive course credit, you must request credit at the {linkToProviderSite} website. Select {requestCredit} to get started',
|
|
33
|
+
},
|
|
34
|
+
received: {
|
|
35
|
+
id: 'learner-dash.courseCard.banners.credit.received',
|
|
36
|
+
description: 'Message shown when credit request has been received',
|
|
37
|
+
defaultMessage: '{providerName} has received your course credit request. We will update you when credit processing is complete.',
|
|
38
|
+
},
|
|
39
|
+
rejected: {
|
|
40
|
+
id: 'learner-dash.courseCard.banners.credit.rejected',
|
|
41
|
+
description: 'Message shown when credit request has been rejected',
|
|
42
|
+
defaultMessage: '{providerName} did not approve your request for course credit. For more information, contact {linkToProviderSite} directly.',
|
|
43
|
+
},
|
|
44
|
+
requestCredit: {
|
|
45
|
+
id: 'learner-dash.courseCard.banners.credit.requestCredit',
|
|
46
|
+
description: 'Button text for requesting credit',
|
|
47
|
+
defaultMessage: 'Request Credit',
|
|
48
|
+
},
|
|
49
|
+
viewCredit: {
|
|
50
|
+
id: 'learner-dash.courseCard.banners.credit.viewCredit',
|
|
51
|
+
description: 'Button text for viewing credit details',
|
|
52
|
+
defaultMessage: 'View Credit',
|
|
53
|
+
},
|
|
54
|
+
viewDetails: {
|
|
55
|
+
id: 'learner-dash.courseCard.banners.credit.viewDetails',
|
|
56
|
+
description: 'Button text for viewing credit request details',
|
|
57
|
+
defaultMessage: 'View Details',
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export default messages;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
import { useIntl } from '@openedx/frontend-base';
|
|
5
|
+
import { Button, MailtoLink } from '@openedx/paragon';
|
|
6
|
+
|
|
7
|
+
import { utilHooks, reduxHooks } from '../../../../hooks';
|
|
8
|
+
import Banner from '../../../../components/Banner';
|
|
9
|
+
|
|
10
|
+
import messages from './messages';
|
|
11
|
+
|
|
12
|
+
export const EntitlementBanner = ({ cardId }) => {
|
|
13
|
+
const { formatMessage } = useIntl();
|
|
14
|
+
const {
|
|
15
|
+
isEntitlement,
|
|
16
|
+
hasSessions,
|
|
17
|
+
isFulfilled,
|
|
18
|
+
changeDeadline,
|
|
19
|
+
showExpirationWarning,
|
|
20
|
+
isExpired,
|
|
21
|
+
} = reduxHooks.useCardEntitlementData(cardId);
|
|
22
|
+
const { supportEmail } = reduxHooks.usePlatformSettingsData();
|
|
23
|
+
const openSessionModal = reduxHooks.useUpdateSelectSessionModalCallback(cardId);
|
|
24
|
+
const formatDate = utilHooks.useFormatDate();
|
|
25
|
+
|
|
26
|
+
if (!isEntitlement) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (!hasSessions && !isFulfilled) {
|
|
31
|
+
return (
|
|
32
|
+
<Banner variant="warning">
|
|
33
|
+
{formatMessage(messages.entitlementUnavailable, {
|
|
34
|
+
emailLink: supportEmail && <MailtoLink to={supportEmail}>{supportEmail}</MailtoLink>,
|
|
35
|
+
})}
|
|
36
|
+
</Banner>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
if (showExpirationWarning) {
|
|
40
|
+
return (
|
|
41
|
+
<Banner>
|
|
42
|
+
{formatMessage(messages.entitlementExpiringSoon, {
|
|
43
|
+
changeDeadline: formatDate(changeDeadline),
|
|
44
|
+
selectSessionButton: (
|
|
45
|
+
<Button variant="link" size="inline" className="m-0 p-0" onClick={openSessionModal}>
|
|
46
|
+
{formatMessage(messages.selectSession)}
|
|
47
|
+
</Button>
|
|
48
|
+
),
|
|
49
|
+
})}
|
|
50
|
+
</Banner>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
if (isExpired) {
|
|
54
|
+
return (
|
|
55
|
+
<Banner>
|
|
56
|
+
{formatMessage(messages.entitlementExpired)}
|
|
57
|
+
</Banner>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
};
|
|
62
|
+
EntitlementBanner.propTypes = {
|
|
63
|
+
cardId: PropTypes.string.isRequired,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export default EntitlementBanner;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { shallow } from '@edx/react-unit-test-utils';
|
|
3
|
+
|
|
4
|
+
import { reduxHooks } from 'hooks';
|
|
5
|
+
import EntitlementBanner from './EntitlementBanner';
|
|
6
|
+
|
|
7
|
+
jest.mock('components/Banner', () => 'Banner');
|
|
8
|
+
jest.mock('hooks', () => ({
|
|
9
|
+
utilHooks: {
|
|
10
|
+
useFormatDate: () => date => date,
|
|
11
|
+
},
|
|
12
|
+
reduxHooks: {
|
|
13
|
+
usePlatformSettingsData: jest.fn(),
|
|
14
|
+
useCardEntitlementData: jest.fn(),
|
|
15
|
+
useUpdateSelectSessionModalCallback: jest.fn(
|
|
16
|
+
(cardId) => jest.fn().mockName(`updateSelectSessionModalCallback(${cardId})`),
|
|
17
|
+
),
|
|
18
|
+
},
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
const cardId = 'my-test-course-number';
|
|
22
|
+
|
|
23
|
+
let el;
|
|
24
|
+
|
|
25
|
+
const entitlementData = {
|
|
26
|
+
isEntitlement: true,
|
|
27
|
+
hasSessions: true,
|
|
28
|
+
isFulfilled: false,
|
|
29
|
+
changeDeadline: '11/11/2022',
|
|
30
|
+
showExpirationWarning: false,
|
|
31
|
+
};
|
|
32
|
+
const platformData = { supportEmail: 'test-support-email' };
|
|
33
|
+
|
|
34
|
+
const render = (overrides = {}) => {
|
|
35
|
+
const { entitlement = {} } = overrides;
|
|
36
|
+
reduxHooks.useCardEntitlementData.mockReturnValueOnce({ ...entitlementData, ...entitlement });
|
|
37
|
+
reduxHooks.usePlatformSettingsData.mockReturnValueOnce(platformData);
|
|
38
|
+
el = shallow(<EntitlementBanner cardId={cardId} />);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
describe('EntitlementBanner', () => {
|
|
42
|
+
test('initializes data with course number from entitlement', () => {
|
|
43
|
+
render();
|
|
44
|
+
expect(reduxHooks.useCardEntitlementData).toHaveBeenCalledWith(cardId);
|
|
45
|
+
expect(reduxHooks.useUpdateSelectSessionModalCallback).toHaveBeenCalledWith(cardId);
|
|
46
|
+
});
|
|
47
|
+
test('no display if not an entitlement', () => {
|
|
48
|
+
render({ entitlement: { isEntitlement: false } });
|
|
49
|
+
expect(el.isEmptyRender()).toEqual(true);
|
|
50
|
+
});
|
|
51
|
+
test('snapshot: no sessions available', () => {
|
|
52
|
+
render({ entitlement: { isFulfilled: false, hasSessions: false } });
|
|
53
|
+
expect(el.snapshot).toMatchSnapshot();
|
|
54
|
+
});
|
|
55
|
+
test('snapshot: expiration warning', () => {
|
|
56
|
+
render({ entitlement: { showExpirationWarning: true } });
|
|
57
|
+
expect(el.snapshot).toMatchSnapshot();
|
|
58
|
+
});
|
|
59
|
+
test('no display if sessions available and not displaying warning', () => {
|
|
60
|
+
render();
|
|
61
|
+
expect(el.isEmptyRender()).toEqual(true);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
export const ProgramsList = ({ programs }) => (
|
|
5
|
+
<ul className="related-programs-list-container">
|
|
6
|
+
{programs.map((program) => (
|
|
7
|
+
<li key={program.programUrl} className="my-2">
|
|
8
|
+
<a href={program.programUrl}>{program.title}</a>
|
|
9
|
+
</li>
|
|
10
|
+
))}
|
|
11
|
+
</ul>
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
ProgramsList.propTypes = {
|
|
15
|
+
programs: PropTypes.arrayOf(
|
|
16
|
+
PropTypes.shape({
|
|
17
|
+
programUrl: PropTypes.string,
|
|
18
|
+
title: PropTypes.string,
|
|
19
|
+
}),
|
|
20
|
+
).isRequired,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default ProgramsList;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { shallow } from '@edx/react-unit-test-utils';
|
|
2
|
+
|
|
3
|
+
import { ProgramsList } from './ProgramsList';
|
|
4
|
+
|
|
5
|
+
describe('ProgramsList', () => {
|
|
6
|
+
const programs = [
|
|
7
|
+
{
|
|
8
|
+
programUrl: 'http://example.com',
|
|
9
|
+
title: 'Example Program 1',
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
programUrl: 'http://example.com',
|
|
13
|
+
title: 'Example Program 2',
|
|
14
|
+
},
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
it('renders correctly', () => {
|
|
18
|
+
const wrapper = shallow(<ProgramsList programs={programs} />);
|
|
19
|
+
expect(wrapper.snapshot).toMatchSnapshot();
|
|
20
|
+
|
|
21
|
+
expect(wrapper.instance.findByType('li').length).toEqual(programs.length);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`ProgramsList renders correctly 1`] = `
|
|
4
|
+
<ul
|
|
5
|
+
className="related-programs-list-container"
|
|
6
|
+
>
|
|
7
|
+
<li
|
|
8
|
+
className="my-2"
|
|
9
|
+
key="http://example.com"
|
|
10
|
+
>
|
|
11
|
+
<a
|
|
12
|
+
href="http://example.com"
|
|
13
|
+
>
|
|
14
|
+
Example Program 1
|
|
15
|
+
</a>
|
|
16
|
+
</li>
|
|
17
|
+
<li
|
|
18
|
+
className="my-2"
|
|
19
|
+
key="http://example.com"
|
|
20
|
+
>
|
|
21
|
+
<a
|
|
22
|
+
href="http://example.com"
|
|
23
|
+
>
|
|
24
|
+
Example Program 2
|
|
25
|
+
</a>
|
|
26
|
+
</li>
|
|
27
|
+
</ul>
|
|
28
|
+
`;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`RelatedProgramsBanner render with programs 1`] = `
|
|
4
|
+
<Banner
|
|
5
|
+
className="bg-white border-top border-bottom mb-0 related-programs-banner"
|
|
6
|
+
icon={[MockFunction icons.Program]}
|
|
7
|
+
variant="info"
|
|
8
|
+
>
|
|
9
|
+
<span
|
|
10
|
+
className="font-weight-bolder"
|
|
11
|
+
>
|
|
12
|
+
Related Programs:
|
|
13
|
+
</span>
|
|
14
|
+
<ProgramsList
|
|
15
|
+
programs={
|
|
16
|
+
[
|
|
17
|
+
{
|
|
18
|
+
"title": "Program 1",
|
|
19
|
+
"url": "http://example.com/program1",
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"title": "Program 2",
|
|
23
|
+
"url": "http://example.com/program2",
|
|
24
|
+
},
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
/>
|
|
28
|
+
</Banner>
|
|
29
|
+
`;
|
package/src/containers/CourseCard/components/CourseCardBanners/RelatedProgramsBanner/index.jsx
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
import { Program } from '@openedx/paragon/icons';
|
|
5
|
+
import { useIntl } from '@openedx/frontend-base';
|
|
6
|
+
|
|
7
|
+
import { reduxHooks } from '../../../../../hooks';
|
|
8
|
+
import Banner from '../../../../../components/Banner';
|
|
9
|
+
|
|
10
|
+
import ProgramList from './ProgramsList';
|
|
11
|
+
import messages from './messages';
|
|
12
|
+
|
|
13
|
+
export const RelatedProgramsBanner = ({ cardId }) => {
|
|
14
|
+
const { formatMessage } = useIntl();
|
|
15
|
+
|
|
16
|
+
const programData = reduxHooks.useCardRelatedProgramsData(cardId);
|
|
17
|
+
|
|
18
|
+
if (!programData?.length) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<Banner
|
|
24
|
+
icon={Program}
|
|
25
|
+
className="bg-white border-top border-bottom mb-0 related-programs-banner"
|
|
26
|
+
>
|
|
27
|
+
<span className="font-weight-bolder">
|
|
28
|
+
{formatMessage(messages.relatedPrograms)}
|
|
29
|
+
</span>
|
|
30
|
+
<ProgramList programs={programData.list} />
|
|
31
|
+
</Banner>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
RelatedProgramsBanner.propTypes = {
|
|
35
|
+
cardId: PropTypes.string.isRequired,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default RelatedProgramsBanner;
|
package/src/containers/CourseCard/components/CourseCardBanners/RelatedProgramsBanner/index.test.jsx
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { shallow } from '@edx/react-unit-test-utils';
|
|
2
|
+
|
|
3
|
+
import { reduxHooks } from '../../../../../hooks';
|
|
4
|
+
import RelatedProgramsBanner from '.';
|
|
5
|
+
|
|
6
|
+
jest.mock('./ProgramsList', () => 'ProgramsList');
|
|
7
|
+
|
|
8
|
+
jest.mock('hooks', () => ({
|
|
9
|
+
reduxHooks: {
|
|
10
|
+
useCardRelatedProgramsData: jest.fn(),
|
|
11
|
+
},
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
const cardId = 'test-card-id';
|
|
15
|
+
|
|
16
|
+
describe('RelatedProgramsBanner', () => {
|
|
17
|
+
test('render empty', () => {
|
|
18
|
+
reduxHooks.useCardRelatedProgramsData.mockReturnValue({
|
|
19
|
+
length: 0,
|
|
20
|
+
});
|
|
21
|
+
const el = shallow(<RelatedProgramsBanner cardId={cardId} />);
|
|
22
|
+
expect(el.isEmptyRender()).toEqual(true);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test('render with programs', () => {
|
|
26
|
+
reduxHooks.useCardRelatedProgramsData.mockReturnValue({
|
|
27
|
+
list: [
|
|
28
|
+
{
|
|
29
|
+
title: 'Program 1',
|
|
30
|
+
url: 'http://example.com/program1',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
title: 'Program 2',
|
|
34
|
+
url: 'http://example.com/program2',
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
length: 2,
|
|
38
|
+
});
|
|
39
|
+
const el = shallow(<RelatedProgramsBanner cardId={cardId} />);
|
|
40
|
+
expect(el.snapshot).toMatchSnapshot();
|
|
41
|
+
});
|
|
42
|
+
});
|
package/src/containers/CourseCard/components/CourseCardBanners/RelatedProgramsBanner/messages.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { defineMessages } from '@openedx/frontend-base';
|
|
2
|
+
|
|
3
|
+
const messages = defineMessages({
|
|
4
|
+
relatedPrograms: {
|
|
5
|
+
id: 'learner-dash.courseCard.banners.relatedPrograms',
|
|
6
|
+
description: 'title for related programs banner',
|
|
7
|
+
defaultMessage: 'Related Programs: ',
|
|
8
|
+
},
|
|
9
|
+
expandBanner: {
|
|
10
|
+
id: 'learner-dash.courseCard.banners.expandBanner',
|
|
11
|
+
description: 'expand banner button text',
|
|
12
|
+
defaultMessage: 'More',
|
|
13
|
+
},
|
|
14
|
+
expandBannerAlt: {
|
|
15
|
+
id: 'learner-dash.courseCard.banners.expandBannerAlt',
|
|
16
|
+
description: 'expand banner button alt text',
|
|
17
|
+
defaultMessage: 'Expand banner icon',
|
|
18
|
+
},
|
|
19
|
+
collapseBanner: {
|
|
20
|
+
id: 'learner-dash.courseCard.banners.collapseBanner',
|
|
21
|
+
description: 'collapse banner button text',
|
|
22
|
+
defaultMessage: 'Less',
|
|
23
|
+
},
|
|
24
|
+
collapseBannerAlt: {
|
|
25
|
+
id: 'learner-dash.courseCard.banners.collapseBannerAlt',
|
|
26
|
+
description: 'collapse banner button alt text',
|
|
27
|
+
defaultMessage: 'Collapse banner icon',
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export default messages;
|