Skip to content

Commit 6257cb4

Browse files
ruzniaievdmruzniaievdm
andauthored
refactor: Replace PDF course certificate view code (#946)
Co-authored-by: ruzniaievdm <[email protected]>
1 parent 792d9eb commit 6257cb4

File tree

17 files changed

+4
-179
lines changed

17 files changed

+4
-179
lines changed

src/course-home/data/__factories__/outlineTabData.factory.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ Factory.define('outlineTabData')
3535
cert_status: null,
3636
cert_web_view_url: null,
3737
certificate_available_date: null,
38-
download_url: null,
3938
},
4039
course_goals: {
4140
goal_options: [],

src/course-home/data/__snapshots__/redux.test.js.snap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,6 @@ Object {
411411
"certStatus": null,
412412
"certWebViewUrl": null,
413413
"certificateAvailableDate": null,
414-
"downloadUrl": null,
415414
},
416415
"courseBlocks": Object {
417416
"courses": Object {

src/course-home/outline-tab/OutlineTab.test.jsx

Lines changed: 1 addition & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,6 @@ describe('Outline Tab', () => {
642642
cert_status: CERT_STATUS_TYPE.EARNED_NOT_AVAILABLE,
643643
cert_web_view_url: null,
644644
certificate_available_date: tomorrow.toISOString(),
645-
download_url: null,
646645
},
647646
}, {
648647
date_blocks: [
@@ -670,7 +669,6 @@ describe('Outline Tab', () => {
670669
cert_data: {
671670
cert_status: CERT_STATUS_TYPE.UNVERIFIED,
672671
cert_web_view_url: null,
673-
download_url: null,
674672
},
675673
}, {
676674
date_blocks: [
@@ -739,7 +737,6 @@ describe('Outline Tab', () => {
739737
cert_data: {
740738
cert_status: CERT_STATUS_TYPE.REQUESTING,
741739
cert_web_view_url: null,
742-
download_url: null,
743740
},
744741
}, {
745742
date_blocks: [
@@ -773,50 +770,7 @@ describe('Outline Tab', () => {
773770
org_key: 'edX',
774771
});
775772
});
776-
it('tracks download cert button', async () => {
777-
sendTrackEvent.mockClear();
778-
const now = new Date();
779-
const yesterday = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1);
780-
const tomorrow = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1);
781-
setMetadata({ is_enrolled: true });
782-
setTabData({
783-
cert_data: {
784-
cert_status: CERT_STATUS_TYPE.DOWNLOADABLE,
785-
cert_web_view_url: null,
786-
download_url: null,
787-
},
788-
}, {
789-
date_blocks: [
790-
{
791-
date_type: 'course-end-date',
792-
date: yesterday.toISOString(),
793-
title: 'End',
794-
},
795-
{
796-
date_type: 'certificate-available-date',
797-
date: tomorrow.toISOString(),
798-
title: 'Cert Available',
799-
},
800-
{
801-
date_type: 'verification-deadline-date',
802-
date: tomorrow.toISOString(),
803-
link_text: 'Verify',
804-
title: 'Verification Upgrade Deadline',
805-
},
806-
],
807-
});
808-
await fetchAndRender();
809-
sendTrackEvent.mockClear();
810-
const requestingButton = screen.getByRole('button', { name: 'View my certificate' });
811-
fireEvent.click(requestingButton);
812-
expect(sendTrackEvent).toHaveBeenCalledTimes(1);
813-
expect(sendTrackEvent).toHaveBeenCalledWith('edx.ui.lms.course_outline.certificate_alert_downloadable_button.clicked',
814-
{
815-
courserun_key: courseId,
816-
is_staff: false,
817-
org_key: 'edX',
818-
});
819-
});
773+
820774
it('tracks unverified cert button', async () => {
821775
sendTrackEvent.mockClear();
822776
const now = new Date();
@@ -827,7 +781,6 @@ describe('Outline Tab', () => {
827781
cert_data: {
828782
cert_status: CERT_STATUS_TYPE.UNVERIFIED,
829783
cert_web_view_url: null,
830-
download_url: null,
831784
},
832785
}, {
833786
date_blocks: [
@@ -915,7 +868,6 @@ describe('Outline Tab', () => {
915868
cert_status: CERT_STATUS_TYPE.DOWNLOADABLE,
916869
cert_web_view_url: 'certificate/testuuid',
917870
certificate_available_date: null,
918-
download_url: null,
919871
},
920872
}, {
921873
date_blocks: [
@@ -941,7 +893,6 @@ describe('Outline Tab', () => {
941893
cert_status: CERT_STATUS_TYPE.REQUESTING,
942894
cert_web_view_url: null,
943895
certificate_available_date: null,
944-
download_url: null,
945896
},
946897
}, {
947898
date_blocks: [
@@ -958,33 +909,6 @@ describe('Outline Tab', () => {
958909
});
959910
});
960911

961-
describe('Certificate (pdf) Complete Alert', () => {
962-
it('appears', async () => {
963-
const now = new Date();
964-
const yesterday = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1);
965-
setMetadata({ is_enrolled: true });
966-
setTabData({
967-
cert_data: {
968-
cert_status: CERT_STATUS_TYPE.DOWNLOADABLE,
969-
cert_web_view_url: null,
970-
certificate_available_date: null,
971-
download_url: 'download/url',
972-
},
973-
}, {
974-
date_blocks: [
975-
{
976-
date_type: 'course-end-date',
977-
date: yesterday.toISOString(),
978-
title: 'End',
979-
},
980-
],
981-
});
982-
await fetchAndRender();
983-
expect(screen.queryByText('Congratulations! Your certificate is ready.')).toBeInTheDocument();
984-
expect(screen.queryByRole('link', { name: 'Download my certificate' })).toBeInTheDocument();
985-
});
986-
});
987-
988912
describe('Proctoring Info Panel', () => {
989913
const onboardingReleaseDate = new Date();
990914
onboardingReleaseDate.setDate(new Date().getDate() - 7);

src/course-home/outline-tab/alerts/certificate-status-alert/CertificateStatusAlert.jsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ function CertificateStatusAlert({ intl, payload }) {
3333
courseEndDate,
3434
courseId,
3535
certURL,
36-
isWebCert,
3736
userTimezone,
3837
org,
3938
notPassingCourseEnded,
@@ -79,11 +78,7 @@ function CertificateStatusAlert({ intl, payload }) {
7978
);
8079
} else if (certStatus === CERT_STATUS_TYPE.DOWNLOADABLE) {
8180
alertProps.header = intl.formatMessage(certMessages.certStatusDownloadableHeader);
82-
if (isWebCert) {
83-
alertProps.buttonMessage = intl.formatMessage(certStatusMessages.viewableButton);
84-
} else {
85-
alertProps.buttonMessage = intl.formatMessage(certStatusMessages.downloadableButton);
86-
}
81+
alertProps.buttonMessage = intl.formatMessage(certStatusMessages.viewableButton);
8782
alertProps.buttonVisible = true;
8883
alertProps.buttonLink = certURL;
8984
alertProps.buttonAction = () => {
@@ -204,7 +199,6 @@ CertificateStatusAlert.propTypes = {
204199
courseEndDate: PropTypes.string,
205200
courseId: PropTypes.string,
206201
certURL: PropTypes.string,
207-
isWebCert: PropTypes.bool,
208202
userTimezone: PropTypes.string,
209203
org: PropTypes.string,
210204
notPassingCourseEnded: PropTypes.bool,

src/course-home/outline-tab/alerts/certificate-status-alert/hooks.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,8 @@ function useCertificateStatusAlert(courseId) {
5151
certStatus,
5252
certWebViewUrl,
5353
certificateAvailableDate,
54-
downloadUrl,
5554
} = certData || {};
5655
const endBlock = courseDateBlocks.find(b => b.dateType === 'course-end-date');
57-
const isWebCert = downloadUrl === null;
5856
const isVerifiedEnrollmentMode = (
5957
enrollmentMode !== null
6058
&& enrollmentMode !== undefined
@@ -63,9 +61,6 @@ function useCertificateStatusAlert(courseId) {
6361
let certURL = '';
6462
if (certWebViewUrl) {
6563
certURL = `${getConfig().LMS_BASE_URL}${certWebViewUrl}`;
66-
} else if (downloadUrl) {
67-
// PDF Certificate
68-
certURL = downloadUrl;
6964
}
7065
const hasAlertingCertStatus = verifyCertStatusType(certStatus);
7166

@@ -87,7 +82,6 @@ function useCertificateStatusAlert(courseId) {
8782
courseId,
8883
courseEndDate: endBlock && endBlock.date,
8984
userTimezone,
90-
isWebCert,
9185
org,
9286
notPassingCourseEnded,
9387
tabs,

src/course-home/progress-tab/ProgressTab.test.jsx

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -959,49 +959,6 @@ describe('Progress Tab', () => {
959959
});
960960
});
961961

962-
it('Displays download link', async () => {
963-
setTabData({
964-
certificate_data: {
965-
cert_status: 'downloadable',
966-
download_url: 'fake.download.url',
967-
},
968-
user_has_passing_grade: true,
969-
});
970-
await fetchAndRender();
971-
expect(screen.getByRole('link', { name: 'Download my certificate' })).toBeInTheDocument();
972-
});
973-
974-
it('sends events on view of progress tab and on click of downloadable certificate link', async () => {
975-
setTabData({
976-
certificate_data: {
977-
cert_status: 'downloadable',
978-
download_url: 'fake.download.url',
979-
},
980-
user_has_passing_grade: true,
981-
});
982-
await fetchAndRender();
983-
expect(sendTrackEvent).toHaveBeenCalledTimes(1);
984-
expect(sendTrackEvent).toHaveBeenCalledWith('edx.ui.lms.course_progress.visited', {
985-
org_key: 'edX',
986-
courserun_key: courseId,
987-
is_staff: false,
988-
track_variant: 'audit',
989-
grade_variant: 'passing',
990-
certificate_status_variant: 'earned_downloadable',
991-
});
992-
993-
const downloadCertificateLink = screen.getByRole('link', { name: 'Download my certificate' });
994-
fireEvent.click(downloadCertificateLink);
995-
996-
expect(sendTrackEvent).toHaveBeenCalledTimes(2);
997-
expect(sendTrackEvent).toHaveBeenNthCalledWith(2, 'edx.ui.lms.course_progress.certificate_status.clicked', {
998-
org_key: 'edX',
999-
courserun_key: courseId,
1000-
is_staff: false,
1001-
certificate_status_variant: 'earned_downloadable',
1002-
});
1003-
});
1004-
1005962
it('Displays webview link', async () => {
1006963
setTabData({
1007964
certificate_data: {

src/course-home/progress-tab/certificate-status/CertificateStatus.jsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,11 @@ function CertificateStatus({ intl }) {
6161

6262
let certStatus;
6363
let certWebViewUrl;
64-
let downloadUrl;
6564
const timezoneFormatArgs = userTimezone ? { timeZone: userTimezone } : {};
6665

6766
if (certificateData) {
6867
certStatus = certificateData.certStatus;
6968
certWebViewUrl = certificateData.certWebViewUrl;
70-
downloadUrl = certificateData.downloadUrl;
7169
}
7270

7371
let certCase;
@@ -143,15 +141,10 @@ function CertificateStatus({ intl }) {
143141
values={{ dashboardLink, profileLink }}
144142
/>
145143
);
146-
147144
if (certWebViewUrl) {
148145
certEventName = 'earned_viewable';
149146
buttonLocation = `${getConfig().LMS_BASE_URL}${certWebViewUrl}`;
150147
buttonText = intl.formatMessage(messages.viewableButton);
151-
} else if (downloadUrl) {
152-
certEventName = 'earned_downloadable';
153-
buttonLocation = downloadUrl;
154-
buttonText = intl.formatMessage(messages.downloadableButton);
155148
}
156149
break;
157150

src/course-home/progress-tab/certificate-status/messages.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,6 @@ const messages = defineMessages({
6161
defaultMessage: 'Showcase your accomplishment on LinkedIn or your resumé today. You can download your certificate now and access it any time from your Dashboard and Profile.',
6262
description: 'Recommending an action for learner when course certificate is available',
6363
},
64-
downloadableButton: {
65-
id: 'progress.certificateStatus.downloadableButton',
66-
defaultMessage: 'Download my certificate',
67-
description: 'Button text when learner certifcate status is downloadable',
68-
},
6964
viewableButton: {
7065
id: 'progress.certificateStatus.viewableButton',
7166
defaultMessage: 'View my certificate',

src/courseware/course/course-exit/CourseCelebration.jsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ function CourseCelebration({ intl }) {
6262
const {
6363
certStatus,
6464
certWebViewUrl,
65-
downloadUrl,
6665
certificateAvailableDate,
6766
} = certificateData || {};
6867

@@ -104,9 +103,6 @@ function CourseCelebration({ intl }) {
104103
if (certWebViewUrl) {
105104
buttonLocation = `${getConfig().LMS_BASE_URL}${certWebViewUrl}`;
106105
buttonText = intl.formatMessage(messages.viewCertificateButton);
107-
} else if (downloadUrl) {
108-
buttonLocation = downloadUrl;
109-
buttonText = intl.formatMessage(messages.downloadButton);
110106
}
111107
if (linkedinAddToProfileUrl) {
112108
buttonPrefix = (

src/courseware/course/course-exit/CourseExit.test.jsx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,6 @@ describe('Course Exit Pages', () => {
108108
});
109109

110110
describe('Course Celebration Experience', () => {
111-
it('Displays download link', async () => {
112-
setMetadata({
113-
certificate_data: {
114-
cert_status: 'downloadable',
115-
download_url: 'fake.download.url',
116-
},
117-
});
118-
await fetchAndRender(<CourseCelebration />);
119-
expect(screen.getByRole('link', { name: 'Download my certificate' })).toBeInTheDocument();
120-
});
121-
122111
it('Displays webview link', async () => {
123112
setMetadata({
124113
certificate_data: {

0 commit comments

Comments
 (0)