@openedx/frontend-app-learner-dashboard 1.0.0-alpha.4 → 1.0.0-alpha.5
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/package.json +4 -5
- package/src/app.scss +2 -5
- package/src/components/Banner.test.jsx +21 -21
- package/src/containers/CourseCard/CourseCard.scss +4 -6
- package/src/containers/CourseCard/components/CourseCardActions/ActionButton/hooks.test.js +27 -0
- package/src/containers/CourseCard/components/CourseCardActions/ActionButton/index.test.jsx +17 -14
- package/src/containers/CourseCard/components/CourseCardActions/BeginCourseButton.test.jsx +37 -34
- package/src/containers/CourseCard/components/CourseCardActions/ResumeButton.test.jsx +28 -28
- package/src/containers/CourseCard/components/CourseCardActions/SelectSessionButton.test.jsx +26 -17
- package/src/containers/CourseCard/components/CourseCardActions/ViewCourseButton.test.jsx +29 -19
- package/src/containers/CourseCard/components/CourseCardActions/index.test.jsx +32 -34
- package/src/containers/CourseCard/components/CourseCardBanners/CertificateBanner.test.jsx +205 -190
- package/src/containers/CourseCard/components/CourseCardBanners/CourseBanner.test.jsx +35 -62
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/hooks.test.js +3 -3
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/index.test.jsx +49 -79
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/ApprovedContent.jsx +1 -2
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/ApprovedContent.test.jsx +51 -34
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/EligibleContent.test.jsx +36 -44
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/MustRequestContent.jsx +1 -2
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/MustRequestContent.test.jsx +74 -44
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/PendingContent.jsx +1 -2
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/PendingContent.test.jsx +40 -34
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/RejectedContent.test.jsx +16 -26
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/components/CreditContent.test.jsx +38 -28
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/components/CreditRequestForm/hooks.test.js +6 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/components/CreditRequestForm/index.test.jsx +25 -24
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/components/CreditRequestForm/ref.test.jsx +0 -3
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/components/ProviderLink.test.jsx +15 -13
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/hooks.test.js +3 -3
- package/src/containers/CourseCard/components/CourseCardBanners/EntitlementBanner.test.jsx +33 -24
- package/src/containers/CourseCard/components/CourseCardBanners/RelatedProgramsBanner/ProgramsList.test.jsx +13 -5
- package/src/containers/CourseCard/components/CourseCardBanners/RelatedProgramsBanner/index.test.jsx +34 -27
- package/src/containers/CourseCard/components/CourseCardBanners/index.test.jsx +44 -15
- package/src/containers/CourseCard/components/CourseCardDetails/hooks.test.js +19 -9
- package/src/containers/CourseCard/components/CourseCardDetails/index.scss +1 -5
- package/src/containers/CourseCard/components/CourseCardDetails/index.test.jsx +20 -8
- package/src/containers/CourseCard/components/CourseCardImage.test.jsx +48 -41
- package/src/containers/CourseCard/components/CourseCardMenu/SocialShareMenu.jsx +3 -4
- package/src/containers/CourseCard/components/CourseCardMenu/SocialShareMenu.test.jsx +62 -92
- package/src/containers/CourseCard/components/CourseCardMenu/hooks.js +8 -7
- package/src/containers/CourseCard/components/CourseCardMenu/hooks.test.js +8 -15
- package/src/containers/CourseCard/components/CourseCardMenu/index.jsx +2 -3
- package/src/containers/CourseCard/components/CourseCardMenu/index.test.jsx +78 -112
- package/src/containers/CourseCard/components/CourseCardTitle.test.jsx +51 -45
- package/src/containers/CourseCard/components/RelatedProgramsBadge/hooks.jsx +2 -2
- package/src/containers/CourseCard/components/RelatedProgramsBadge/hooks.test.js +18 -4
- package/src/containers/CourseCard/components/RelatedProgramsBadge/index.jsx +1 -1
- package/src/containers/CourseCard/components/RelatedProgramsBadge/index.test.jsx +17 -13
- package/src/containers/CourseCard/components/hooks.test.js +19 -8
- package/src/containers/CourseCard/hooks.test.js +12 -2
- package/src/containers/CourseCard/index.test.jsx +33 -12
- package/src/containers/CourseFilterControls/ActiveCourseFilters.test.jsx +19 -8
- package/src/containers/CourseFilterControls/CourseFilterControls.test.jsx +51 -36
- package/src/containers/CourseFilterControls/components/Checkbox.test.jsx +8 -5
- package/src/containers/CourseFilterControls/components/FilterForm.test.jsx +45 -20
- package/src/containers/CourseFilterControls/components/SortForm.test.jsx +19 -9
- package/src/containers/CourseFilterControls/hooks.test.js +25 -13
- package/src/containers/CoursesPanel/CourseList/index.test.jsx +39 -22
- package/src/containers/CoursesPanel/NoCoursesView/index.scss +5 -7
- package/src/containers/CoursesPanel/NoCoursesView/index.test.jsx +26 -6
- package/src/containers/CoursesPanel/hooks.test.js +4 -4
- package/src/containers/CoursesPanel/index.scss +5 -7
- package/src/containers/CoursesPanel/index.test.jsx +55 -21
- package/src/containers/Dashboard/DashboardLayout.test.jsx +43 -52
- package/src/containers/Dashboard/LoadingView.test.jsx +5 -10
- package/src/containers/Dashboard/hooks.test.js +21 -19
- package/src/containers/Dashboard/index.scss +8 -10
- package/src/containers/Dashboard/index.test.jsx +51 -92
- package/src/containers/EmailSettingsModal/hooks.test.js +3 -3
- package/src/containers/EmailSettingsModal/index.test.jsx +27 -10
- package/src/containers/RelatedProgramsModal/components/ProgramCard.test.jsx +31 -11
- package/src/containers/RelatedProgramsModal/index.test.jsx +27 -15
- package/src/containers/SelectSessionModal/constants.js +0 -1
- package/src/containers/SelectSessionModal/hooks.test.js +15 -5
- package/src/containers/SelectSessionModal/index.test.jsx +24 -11
- package/src/containers/UnenrollConfirmModal/components/ConfirmPane.test.jsx +24 -8
- package/src/containers/UnenrollConfirmModal/components/FinishedPane.test.jsx +39 -14
- package/src/containers/UnenrollConfirmModal/components/ReasonPane.test.jsx +23 -6
- package/src/containers/UnenrollConfirmModal/hooks/index.test.js +74 -26
- package/src/containers/UnenrollConfirmModal/hooks/reasons.test.js +4 -4
- package/src/containers/UnenrollConfirmModal/index.test.jsx +34 -17
- package/src/data/constants/app.js +0 -3
- package/src/data/constants/app.test.js +0 -12
- package/src/data/redux/app/selectors/courseCard.test.js +4 -4
- package/src/data/redux/app/selectors/currentList.test.js +5 -3
- package/src/data/redux/app/selectors/simpleSelectors.test.js +1 -1
- package/src/data/redux/requests/reducer.test.js +1 -1
- package/src/data/redux/requests/selectors.js +1 -2
- package/src/data/redux/requests/selectors.test.js +1 -29
- package/src/data/services/lms/api.test.js +6 -6
- package/src/data/services/lms/urls.test.js +1 -1
- package/src/data/services/segment/utils.test.js +1 -1
- package/src/data/store.test.js +2 -2
- package/src/hooks/api.test.js +59 -64
- package/src/hooks/utils.test.js +4 -0
- package/src/segment.js +1 -2
- package/src/setupTest.jsx +0 -206
- package/src/slots/WidgetSidebarSlot/index.test.jsx +21 -11
- package/src/test/app.test.jsx +65 -75
- package/src/test/inspector.js +0 -6
- package/src/test/messages.js +1 -1
- package/src/testUtils.js +1 -1
- package/src/tracking/trackers/course.test.js +4 -4
- package/src/tracking/trackers/credit.test.js +5 -5
- package/src/tracking/trackers/engagement.test.js +3 -3
- package/src/tracking/trackers/entitlements.test.js +3 -3
- package/src/tracking/trackers/filter.test.js +3 -3
- package/src/tracking/trackers/findCourses.test.js +3 -3
- package/src/tracking/trackers/socialShare.test.js +2 -2
- package/src/utils/StrictDict.test.js +4 -12
- package/src/widgets/LearnerDashboardHeader/ConfirmEmailBanner/messages.js +1 -1
- package/src/widgets/LearnerDashboardHeader/MasqueradeBar/index.scss +10 -12
- package/src/widgets/LearnerDashboardHeader/hooks.js +1 -1
- package/src/widgets/LookingForChallengeWidget/index.test.jsx +22 -8
- package/src/__snapshots__/App.test.jsx.snap +0 -83
- package/src/__snapshots__/index.test.jsx.snap +0 -43
- package/src/components/__snapshots__/Banner.test.jsx.snap +0 -31
- package/src/containers/CourseCard/__snapshots__/index.test.jsx.snap +0 -111
- package/src/containers/CourseCard/components/CourseCardActions/ActionButton/__snapshots__/index.test.jsx.snap +0 -14
- package/src/containers/CourseCard/components/CourseCardActions/__snapshots__/BeginCourseButton.test.jsx.snap +0 -39
- package/src/containers/CourseCard/components/CourseCardActions/__snapshots__/ResumeButton.test.jsx.snap +0 -39
- package/src/containers/CourseCard/components/CourseCardActions/__snapshots__/SelectSessionButton.test.jsx.snap +0 -19
- package/src/containers/CourseCard/components/CourseCardActions/__snapshots__/ViewCourseButton.test.jsx.snap +0 -39
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/__snapshots__/index.test.jsx.snap +0 -58
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/components/CreditRequestForm/__snapshots__/index.test.jsx.snap +0 -32
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/components/__snapshots__/CreditContent.test.jsx.snap +0 -60
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/components/__snapshots__/ProviderLink.test.jsx.snap +0 -11
- package/src/containers/CourseCard/components/CourseCardBanners/RelatedProgramsBanner/__snapshots__/ProgramsList.test.jsx.snap +0 -28
- package/src/containers/CourseCard/components/CourseCardBanners/RelatedProgramsBanner/__snapshots__/index.test.jsx.snap +0 -29
- package/src/containers/CourseCard/components/CourseCardBanners/__snapshots__/CertificateBanner.test.jsx.snap +0 -205
- package/src/containers/CourseCard/components/CourseCardBanners/__snapshots__/CourseBanner.test.jsx.snap +0 -38
- package/src/containers/CourseCard/components/CourseCardBanners/__snapshots__/EntitlementBanner.test.jsx.snap +0 -53
- package/src/containers/CourseCard/components/CourseCardBanners/__snapshots__/index.test.jsx.snap +0 -41
- package/src/containers/CourseCard/components/CourseCardDetails/__snapshots__/index.test.jsx.snap +0 -56
- package/src/containers/CourseCard/components/CourseCardMenu/__snapshots__/index.test.jsx.snap +0 -81
- package/src/containers/CourseCard/components/RelatedProgramsBadge/__snapshots__/index.test.jsx.snap +0 -25
- package/src/containers/CourseCard/components/__snapshots__/CourseCardImage.test.jsx.snap +0 -72
- package/src/containers/CourseCard/components/__snapshots__/CourseCardTitle.test.jsx.snap +0 -33
- package/src/containers/CourseFilterControls/__snapshots__/ActiveCourseFilters.test.jsx.snap +0 -39
- package/src/containers/CourseFilterControls/__snapshots__/CourseFilterControls.test.jsx.snap +0 -169
- package/src/containers/CourseFilterControls/components/__snapshots__/Checkbox.test.jsx.snap +0 -46
- package/src/containers/CourseFilterControls/components/__snapshots__/FilterForm.test.jsx.snap +0 -41
- package/src/containers/CourseFilterControls/components/__snapshots__/SortForm.test.jsx.snap +0 -29
- package/src/containers/CoursesPanel/CourseList/__snapshots__/index.test.jsx.snap +0 -70
- package/src/containers/CoursesPanel/NoCoursesView/__snapshots__/index.test.jsx.snap +0 -29
- package/src/containers/CoursesPanel/__snapshots__/index.test.jsx.snap +0 -55
- package/src/containers/Dashboard/__snapshots__/DashboardLayout.test.jsx.snap +0 -197
- package/src/containers/Dashboard/__snapshots__/LoadingView.test.jsx.snap +0 -13
- package/src/containers/Dashboard/__snapshots__/index.test.jsx.snap +0 -69
- package/src/containers/EmailSettingsModal/__snapshots__/index.test.jsx.snap +0 -133
- package/src/containers/RelatedProgramsModal/__snapshots__/index.test.jsx.snap +0 -169
- package/src/containers/RelatedProgramsModal/components/__snapshots__/ProgramCard.test.jsx.snap +0 -60
- package/src/containers/SelectSessionModal/__snapshots__/index.test.jsx.snap +0 -176
- package/src/containers/UnenrollConfirmModal/__snapshots__/index.test.jsx.snap +0 -101
- package/src/containers/UnenrollConfirmModal/components/__snapshots__/ConfirmPane.test.jsx.snap +0 -22
- package/src/containers/UnenrollConfirmModal/components/__snapshots__/FinishedPane.test.jsx.snap +0 -38
- package/src/containers/UnenrollConfirmModal/components/__snapshots__/ReasonPane.test.jsx.snap +0 -183
- package/src/slots/WidgetSidebarSlot/__snapshots__/index.test.jsx.snap +0 -14
- package/src/widgets/LookingForChallengeWidget/__snapshots__/index.test.jsx.snap +0 -45
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
import {
|
|
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';
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import { reduxHooks } from '@src/hooks';
|
|
10
3
|
|
|
11
4
|
import CourseCardActions from '.';
|
|
12
5
|
|
|
13
|
-
jest.mock('hooks', () => ({
|
|
6
|
+
jest.mock('@src/hooks', () => ({
|
|
14
7
|
reduxHooks: {
|
|
15
8
|
useCardCourseRunData: jest.fn(),
|
|
16
9
|
useCardEnrollmentData: jest.fn(),
|
|
@@ -19,16 +12,15 @@ jest.mock('hooks', () => ({
|
|
|
19
12
|
},
|
|
20
13
|
}));
|
|
21
14
|
|
|
22
|
-
jest.mock('slots/CourseCardActionSlot', () =>
|
|
23
|
-
jest.mock('./SelectSessionButton', () =>
|
|
24
|
-
jest.mock('./ViewCourseButton', () =>
|
|
25
|
-
jest.mock('./BeginCourseButton', () =>
|
|
26
|
-
jest.mock('./ResumeButton', () =>
|
|
15
|
+
jest.mock('@src/slots/CourseCardActionSlot', () => jest.fn(() => <div>CourseCardActionSlot</div>));
|
|
16
|
+
jest.mock('./SelectSessionButton', () => jest.fn(() => <div>SelectSessionButton</div>));
|
|
17
|
+
jest.mock('./ViewCourseButton', () => jest.fn(() => <div>ViewCourseButton</div>));
|
|
18
|
+
jest.mock('./BeginCourseButton', () => jest.fn(() => <div>BeginCourseButton</div>));
|
|
19
|
+
jest.mock('./ResumeButton', () => jest.fn(() => <div>ResumeButton</div>));
|
|
27
20
|
|
|
28
21
|
const cardId = 'test-card-id';
|
|
29
22
|
const props = { cardId };
|
|
30
23
|
|
|
31
|
-
let el;
|
|
32
24
|
describe('CourseCardActions', () => {
|
|
33
25
|
const mockHooks = ({
|
|
34
26
|
isEntitlement = false,
|
|
@@ -44,13 +36,11 @@ describe('CourseCardActions', () => {
|
|
|
44
36
|
reduxHooks.useCardEnrollmentData.mockReturnValueOnce({ isExecEd2UCourse, isVerified, hasStarted });
|
|
45
37
|
reduxHooks.useMasqueradeData.mockReturnValueOnce({ isMasquerading });
|
|
46
38
|
};
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
};
|
|
50
|
-
describe('behavior', () => {
|
|
39
|
+
const renderComponent = () => render(<CourseCardActions {...props} />);
|
|
40
|
+
describe('hooks', () => {
|
|
51
41
|
it('initializes redux hooks', () => {
|
|
52
42
|
mockHooks();
|
|
53
|
-
|
|
43
|
+
renderComponent();
|
|
54
44
|
expect(reduxHooks.useCardEntitlementData).toHaveBeenCalledWith(cardId);
|
|
55
45
|
expect(reduxHooks.useCardEnrollmentData).toHaveBeenCalledWith(cardId);
|
|
56
46
|
expect(reduxHooks.useCardCourseRunData).toHaveBeenCalledWith(cardId);
|
|
@@ -60,36 +50,44 @@ describe('CourseCardActions', () => {
|
|
|
60
50
|
describe('entitlement course', () => {
|
|
61
51
|
it('renders ViewCourseButton if fulfilled', () => {
|
|
62
52
|
mockHooks({ isEntitlement: true, isFulfilled: true });
|
|
63
|
-
|
|
64
|
-
|
|
53
|
+
renderComponent();
|
|
54
|
+
const ViewCourseButton = screen.getByText('ViewCourseButton');
|
|
55
|
+
expect(ViewCourseButton).toBeInTheDocument();
|
|
65
56
|
});
|
|
66
57
|
it('renders SelectSessionButton if not fulfilled', () => {
|
|
67
58
|
mockHooks({ isEntitlement: true });
|
|
68
|
-
|
|
69
|
-
|
|
59
|
+
renderComponent();
|
|
60
|
+
const SelectSessionButton = screen.getByText('SelectSessionButton');
|
|
61
|
+
expect(SelectSessionButton).toBeInTheDocument();
|
|
70
62
|
});
|
|
71
63
|
});
|
|
72
64
|
describe('not entitlement, verified, or exec ed', () => {
|
|
73
65
|
it('renders CourseCardActionSlot and ViewCourseButton for archived courses', () => {
|
|
74
66
|
mockHooks({ isArchived: true });
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
expect(
|
|
67
|
+
renderComponent();
|
|
68
|
+
const CourseCardActionSlot = screen.getByText('CourseCardActionSlot');
|
|
69
|
+
expect(CourseCardActionSlot).toBeInTheDocument();
|
|
70
|
+
const ViewCourseButton = screen.getByText('ViewCourseButton');
|
|
71
|
+
expect(ViewCourseButton).toBeInTheDocument();
|
|
78
72
|
});
|
|
79
73
|
describe('unstarted courses', () => {
|
|
80
74
|
it('renders CourseCardActionSlot and BeginCourseButton', () => {
|
|
81
75
|
mockHooks();
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
expect(
|
|
76
|
+
renderComponent();
|
|
77
|
+
const CourseCardActionSlot = screen.getByText('CourseCardActionSlot');
|
|
78
|
+
expect(CourseCardActionSlot).toBeInTheDocument();
|
|
79
|
+
const BeginCourseButton = screen.getByText('BeginCourseButton');
|
|
80
|
+
expect(BeginCourseButton).toBeInTheDocument();
|
|
85
81
|
});
|
|
86
82
|
});
|
|
87
83
|
describe('active courses (started, and not archived)', () => {
|
|
88
84
|
it('renders CourseCardActionSlot and ResumeButton', () => {
|
|
89
85
|
mockHooks({ hasStarted: true });
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
expect(
|
|
86
|
+
renderComponent();
|
|
87
|
+
const CourseCardActionSlot = screen.getByText('CourseCardActionSlot');
|
|
88
|
+
expect(CourseCardActionSlot).toBeInTheDocument();
|
|
89
|
+
const ResumeButton = screen.getByText('ResumeButton');
|
|
90
|
+
expect(ResumeButton).toBeInTheDocument();
|
|
93
91
|
});
|
|
94
92
|
});
|
|
95
93
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import { IntlProvider } from '@openedx/frontend-base';
|
|
2
3
|
|
|
3
|
-
import { reduxHooks } from 'hooks';
|
|
4
|
+
import { reduxHooks } from '@src/hooks';
|
|
4
5
|
import CertificateBanner from './CertificateBanner';
|
|
5
|
-
import messages from './messages';
|
|
6
6
|
|
|
7
|
-
jest.mock('hooks', () => ({
|
|
7
|
+
jest.mock('@src/hooks', () => ({
|
|
8
8
|
utilHooks: {
|
|
9
9
|
useFormatDate: jest.fn(() => date => date),
|
|
10
10
|
},
|
|
@@ -17,28 +17,28 @@ jest.mock('hooks', () => ({
|
|
|
17
17
|
},
|
|
18
18
|
}));
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
const defaultCertificate = {
|
|
21
|
+
availableDate: '10/20/3030',
|
|
22
|
+
isRestricted: false,
|
|
23
|
+
isDownloadable: false,
|
|
24
|
+
isEarnedButUnavailable: false,
|
|
25
|
+
};
|
|
26
|
+
const defaultEnrollment = {
|
|
27
|
+
isAudit: false,
|
|
28
|
+
isVerified: false,
|
|
29
|
+
};
|
|
30
|
+
const defaultCourseRun = { isArchived: false };
|
|
31
|
+
const defaultGrade = { isPassing: false };
|
|
32
|
+
const defaultPlatformSettings = {};
|
|
33
|
+
const props = { cardId: 'cardId' };
|
|
34
|
+
const supportEmail = 'suport@email.com';
|
|
35
|
+
const billingEmail = 'billing@email.com';
|
|
21
36
|
|
|
22
37
|
describe('CertificateBanner', () => {
|
|
23
|
-
const props = { cardId: 'cardId' };
|
|
24
38
|
reduxHooks.useCardCourseRunData.mockReturnValue({
|
|
25
39
|
minPassingGrade: 0.8,
|
|
26
40
|
progressUrl: 'progressUrl',
|
|
27
41
|
});
|
|
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
42
|
const createWrapper = ({
|
|
43
43
|
certificate = {},
|
|
44
44
|
enrollment = {},
|
|
@@ -51,177 +51,192 @@ describe('CertificateBanner', () => {
|
|
|
51
51
|
reduxHooks.useCardEnrollmentData.mockReturnValueOnce({ ...defaultEnrollment, ...enrollment });
|
|
52
52
|
reduxHooks.useCardCourseRunData.mockReturnValueOnce({ ...defaultCourseRun, ...courseRun });
|
|
53
53
|
reduxHooks.usePlatformSettingsData.mockReturnValueOnce({ ...defaultPlatformSettings, ...platformSettings });
|
|
54
|
-
return
|
|
54
|
+
return render(<IntlProvider locale="en"><CertificateBanner {...props} /></IntlProvider>);
|
|
55
55
|
};
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
});
|
|
56
|
+
beforeEach(() => {
|
|
57
|
+
jest.clearAllMocks();
|
|
193
58
|
});
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
59
|
+
it('is restricted', () => {
|
|
60
|
+
createWrapper({
|
|
61
|
+
certificate: {
|
|
62
|
+
isRestricted: true,
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
const banner = screen.getByRole('alert');
|
|
66
|
+
expect(banner).toBeInTheDocument();
|
|
67
|
+
const msg = screen.getByText((text) => text.includes('please let us know.'));
|
|
68
|
+
expect(msg).toBeInTheDocument();
|
|
69
|
+
expect(msg).not.toContain(supportEmail);
|
|
70
|
+
});
|
|
71
|
+
it('is restricted with support email', () => {
|
|
72
|
+
createWrapper({
|
|
73
|
+
certificate: {
|
|
74
|
+
isRestricted: true,
|
|
75
|
+
},
|
|
76
|
+
platformSettings: {
|
|
77
|
+
supportEmail,
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
const banner = screen.getByRole('alert');
|
|
81
|
+
expect(banner).toBeInTheDocument();
|
|
82
|
+
const msg = screen.getByText((text) => text.includes(supportEmail));
|
|
83
|
+
expect(msg).toBeInTheDocument();
|
|
84
|
+
});
|
|
85
|
+
it('is restricted with billing email but not verified', () => {
|
|
86
|
+
createWrapper({
|
|
87
|
+
certificate: {
|
|
88
|
+
isRestricted: true,
|
|
89
|
+
},
|
|
90
|
+
platformSettings: {
|
|
91
|
+
billingEmail,
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
const banner = screen.getByRole('alert');
|
|
95
|
+
expect(banner).toBeInTheDocument();
|
|
96
|
+
expect(banner).toHaveClass('alert-danger');
|
|
97
|
+
const msg = screen.queryByText((text) => text.includes(billingEmail));
|
|
98
|
+
expect(msg).not.toBeInTheDocument();
|
|
99
|
+
});
|
|
100
|
+
it('is restricted and verified', () => {
|
|
101
|
+
createWrapper({
|
|
102
|
+
certificate: {
|
|
103
|
+
isRestricted: true,
|
|
104
|
+
},
|
|
105
|
+
enrollment: {
|
|
106
|
+
isVerified: true,
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
const banner = screen.getByRole('alert');
|
|
110
|
+
expect(banner).toBeInTheDocument();
|
|
111
|
+
const restrictedMsg = screen.getByText((text) => text.includes('please let us know.'));
|
|
112
|
+
expect(restrictedMsg).toBeInTheDocument();
|
|
113
|
+
const refundMsg = screen.getByText((text) => text.includes('If you would like a refund'));
|
|
114
|
+
expect(refundMsg).toBeInTheDocument();
|
|
115
|
+
});
|
|
116
|
+
it('is restricted and verified with support email', () => {
|
|
117
|
+
createWrapper({
|
|
118
|
+
certificate: {
|
|
119
|
+
isRestricted: true,
|
|
120
|
+
},
|
|
121
|
+
enrollment: {
|
|
122
|
+
isVerified: true,
|
|
123
|
+
},
|
|
124
|
+
platformSettings: {
|
|
125
|
+
supportEmail,
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
const restrictedMsg = screen.getByText((text) => text.includes(supportEmail));
|
|
129
|
+
expect(restrictedMsg).toBeInTheDocument();
|
|
130
|
+
const refundMsg = screen.getByText((text) => text.includes('If you would like a refund'));
|
|
131
|
+
expect(refundMsg).toBeInTheDocument();
|
|
132
|
+
expect(refundMsg.innerHTML).not.toContain(billingEmail);
|
|
133
|
+
});
|
|
134
|
+
it('is restricted and verified with billing email', () => {
|
|
135
|
+
createWrapper({
|
|
136
|
+
certificate: {
|
|
137
|
+
isRestricted: true,
|
|
138
|
+
},
|
|
139
|
+
enrollment: {
|
|
140
|
+
isVerified: true,
|
|
141
|
+
},
|
|
142
|
+
platformSettings: {
|
|
143
|
+
billingEmail,
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
const restrictedMsg = screen.queryByText((text) => text.includes('please let us know.'));
|
|
147
|
+
expect(restrictedMsg).toBeInTheDocument();
|
|
148
|
+
expect(restrictedMsg.innerHTML).not.toContain(supportEmail);
|
|
149
|
+
const refundMsg = screen.getByText((text) => text.includes(billingEmail));
|
|
150
|
+
expect(refundMsg).toBeInTheDocument();
|
|
151
|
+
});
|
|
152
|
+
it('is restricted and verified with support and billing email', () => {
|
|
153
|
+
createWrapper({
|
|
154
|
+
certificate: {
|
|
155
|
+
isRestricted: true,
|
|
156
|
+
},
|
|
157
|
+
enrollment: {
|
|
158
|
+
isVerified: true,
|
|
159
|
+
},
|
|
160
|
+
platformSettings: {
|
|
161
|
+
supportEmail,
|
|
162
|
+
billingEmail,
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
const restrictedMsg = screen.getByText((text) => text.includes(supportEmail));
|
|
166
|
+
expect(restrictedMsg).toBeInTheDocument();
|
|
167
|
+
const refundMsg = screen.getByText((text) => text.includes(billingEmail));
|
|
168
|
+
expect(refundMsg).toBeInTheDocument();
|
|
169
|
+
});
|
|
170
|
+
it('is passing and is downloadable', () => {
|
|
171
|
+
createWrapper({
|
|
172
|
+
grade: { isPassing: true },
|
|
173
|
+
certificate: { isDownloadable: true },
|
|
174
|
+
});
|
|
175
|
+
const banner = screen.getByRole('alert');
|
|
176
|
+
expect(banner).toBeInTheDocument();
|
|
177
|
+
expect(banner).toHaveClass('alert-success');
|
|
178
|
+
const readyMsg = screen.getByText((text) => text.includes('Congratulations.'));
|
|
179
|
+
expect(readyMsg).toBeInTheDocument();
|
|
180
|
+
});
|
|
181
|
+
it('not passing and is downloadable', () => {
|
|
182
|
+
createWrapper({
|
|
183
|
+
grade: { isPassing: false },
|
|
184
|
+
certificate: { isDownloadable: true },
|
|
185
|
+
});
|
|
186
|
+
const banner = screen.getByRole('alert');
|
|
187
|
+
expect(banner).toBeInTheDocument();
|
|
188
|
+
expect(banner).toHaveClass('alert-success');
|
|
189
|
+
const readyMsg = screen.getByText((text) => text.includes('Congratulations.'));
|
|
190
|
+
expect(readyMsg).toBeInTheDocument();
|
|
191
|
+
});
|
|
192
|
+
it('not passing and audit', () => {
|
|
193
|
+
createWrapper({
|
|
194
|
+
enrollment: {
|
|
195
|
+
isAudit: true,
|
|
196
|
+
},
|
|
197
|
+
});
|
|
198
|
+
const banner = screen.getByRole('alert');
|
|
199
|
+
expect(banner).toHaveClass('alert-info');
|
|
200
|
+
const auditMsg = screen.getByText((text) => text.includes('Grade required to pass the course:'));
|
|
201
|
+
expect(auditMsg).toBeInTheDocument();
|
|
202
|
+
});
|
|
203
|
+
it('not passing and has finished', () => {
|
|
204
|
+
createWrapper({
|
|
205
|
+
courseRun: { isArchived: true },
|
|
206
|
+
});
|
|
207
|
+
const banner = screen.getByRole('alert');
|
|
208
|
+
expect(banner).toHaveClass('alert-warning');
|
|
209
|
+
const archivedMsg = screen.getByText('You are not eligible for a certificate.');
|
|
210
|
+
expect(archivedMsg).toBeInTheDocument();
|
|
211
|
+
});
|
|
212
|
+
it('not passing and not audit and not finished', () => {
|
|
213
|
+
createWrapper({});
|
|
214
|
+
const banner = screen.getByRole('alert');
|
|
215
|
+
expect(banner).toHaveClass('alert-warning');
|
|
216
|
+
const msg = screen.getByText((text) => text.includes('Grade required for a certificate'));
|
|
217
|
+
expect(msg).toBeInTheDocument();
|
|
218
|
+
});
|
|
219
|
+
it('is passing and is earned but unavailable', () => {
|
|
220
|
+
createWrapper({
|
|
221
|
+
grade: {
|
|
222
|
+
isPassing: true,
|
|
223
|
+
},
|
|
224
|
+
certificate: {
|
|
225
|
+
isEarnedButUnavailable: true,
|
|
226
|
+
},
|
|
227
|
+
});
|
|
228
|
+
const banner = screen.getByRole('alert');
|
|
229
|
+
expect(banner).toHaveClass('alert-info');
|
|
230
|
+
const earnedMsg = screen.getByText((text) => text.includes('Your grade and certificate will be ready after'));
|
|
231
|
+
expect(earnedMsg).toBeInTheDocument();
|
|
232
|
+
});
|
|
233
|
+
it('is passing and not downloadable render empty', () => {
|
|
234
|
+
createWrapper({
|
|
235
|
+
grade: {
|
|
236
|
+
isPassing: true,
|
|
237
|
+
},
|
|
238
|
+
});
|
|
239
|
+
const banner = screen.queryByRole('alert');
|
|
240
|
+
expect(banner).toBeNull();
|
|
226
241
|
});
|
|
227
242
|
});
|