From 88e21b04e2cb4fc2d242f2496b86b89badbdb1c4 Mon Sep 17 00:00:00 2001 From: Maxwell Frank Date: Fri, 20 Dec 2024 13:53:44 +0000 Subject: [PATCH 1/4] feat: remove UpgradeButton --- .../BeginCourseButton.test.jsx | 2 +- .../CourseCardActions/ResumeButton.test.jsx | 2 +- .../CourseCardActions/UpgradeButton.test.jsx | 49 ------------------- .../ViewCourseButton.test.jsx | 2 +- .../components/CourseCardActions/messages.js | 5 -- .../components/CourseCardImage.test.jsx | 4 +- .../components/CourseCardTitle.test.jsx | 4 +- src/containers/CourseCard/components/hooks.js | 6 +-- .../CourseCard/components/hooks.test.js | 18 ------- src/data/redux/app/selectors/courseCard.js | 2 +- .../redux/app/selectors/courseCard.test.js | 4 +- src/data/services/lms/api.js | 7 --- src/data/services/lms/api.test.js | 7 --- src/data/services/lms/fakeData/courses.js | 3 -- .../CourseCardActionSlot/index.jsx | 29 +++-------- src/tracking/constants.js | 7 --- src/tracking/trackers/course.js | 24 --------- src/tracking/trackers/course.test.js | 45 ----------------- 18 files changed, 19 insertions(+), 201 deletions(-) delete mode 100644 src/containers/CourseCard/components/CourseCardActions/UpgradeButton.test.jsx diff --git a/src/containers/CourseCard/components/CourseCardActions/BeginCourseButton.test.jsx b/src/containers/CourseCard/components/CourseCardActions/BeginCourseButton.test.jsx index f34a534c..1559d4ed 100644 --- a/src/containers/CourseCard/components/CourseCardActions/BeginCourseButton.test.jsx +++ b/src/containers/CourseCard/components/CourseCardActions/BeginCourseButton.test.jsx @@ -27,7 +27,7 @@ reduxHooks.useCardCourseRunData.mockReturnValue({ homeUrl }); const execEdPath = (cardId) => `exec-ed-tracking-path=${cardId}`; reduxHooks.useCardExecEdTrackingParam.mockImplementation(execEdPath); reduxHooks.useTrackCourseEvent.mockImplementation( - (eventName, cardId, upgradeUrl) => ({ trackCourseEvent: { eventName, cardId, upgradeUrl } }), + (eventName, cardId, url) => ({ trackCourseEvent: { eventName, cardId, url } }), ); describe('BeginCourseButton', () => { diff --git a/src/containers/CourseCard/components/CourseCardActions/ResumeButton.test.jsx b/src/containers/CourseCard/components/CourseCardActions/ResumeButton.test.jsx index c4ca41e5..a96fc1aa 100644 --- a/src/containers/CourseCard/components/CourseCardActions/ResumeButton.test.jsx +++ b/src/containers/CourseCard/components/CourseCardActions/ResumeButton.test.jsx @@ -26,7 +26,7 @@ reduxHooks.useCardCourseRunData.mockReturnValue({ resumeUrl }); const execEdPath = (cardId) => `exec-ed-tracking-path=${cardId}`; reduxHooks.useCardExecEdTrackingParam.mockImplementation(execEdPath); reduxHooks.useTrackCourseEvent.mockImplementation( - (eventName, cardId, upgradeUrl) => ({ trackCourseEvent: { eventName, cardId, upgradeUrl } }), + (eventName, cardId, url) => ({ trackCourseEvent: { eventName, cardId, url } }), ); let wrapper; diff --git a/src/containers/CourseCard/components/CourseCardActions/UpgradeButton.test.jsx b/src/containers/CourseCard/components/CourseCardActions/UpgradeButton.test.jsx deleted file mode 100644 index a539278c..00000000 --- a/src/containers/CourseCard/components/CourseCardActions/UpgradeButton.test.jsx +++ /dev/null @@ -1,49 +0,0 @@ -import { shallow } from '@edx/react-unit-test-utils'; - -import track from 'tracking'; -import { reduxHooks } from 'hooks'; -import useActionDisabledState from '../hooks'; -import UpgradeButton from './UpgradeButton'; - -jest.mock('tracking', () => ({ - course: { - upgradeClicked: jest.fn().mockName('segment.trackUpgradeClicked'), - }, -})); - -jest.mock('hooks', () => ({ - reduxHooks: { - useCardCourseRunData: jest.fn(), - useTrackCourseEvent: jest.fn( - (eventName, cardId, upgradeUrl) => ({ trackCourseEvent: { eventName, cardId, upgradeUrl } }), - ), - }, -})); -jest.mock('../hooks', () => jest.fn(() => ({ disableUpgradeCourse: false }))); -jest.mock('./ActionButton', () => 'ActionButton'); - -describe('UpgradeButton', () => { - const props = { - cardId: 'cardId', - }; - const upgradeUrl = 'upgradeUrl'; - reduxHooks.useCardCourseRunData.mockReturnValue({ upgradeUrl }); - describe('snapshot', () => { - test('can upgrade', () => { - const wrapper = shallow(); - expect(wrapper.snapshot).toMatchSnapshot(); - expect(wrapper.instance.props.disabled).toEqual(false); - expect(wrapper.instance.props.onClick).toEqual(reduxHooks.useTrackCourseEvent( - track.course.upgradeClicked, - props.cardId, - upgradeUrl, - )); - }); - test('cannot upgrade', () => { - useActionDisabledState.mockReturnValueOnce({ disableUpgradeCourse: true }); - const wrapper = shallow(); - expect(wrapper.snapshot).toMatchSnapshot(); - expect(wrapper.instance.props.disabled).toEqual(true); - }); - }); -}); diff --git a/src/containers/CourseCard/components/CourseCardActions/ViewCourseButton.test.jsx b/src/containers/CourseCard/components/CourseCardActions/ViewCourseButton.test.jsx index 712f8103..186f40bd 100644 --- a/src/containers/CourseCard/components/CourseCardActions/ViewCourseButton.test.jsx +++ b/src/containers/CourseCard/components/CourseCardActions/ViewCourseButton.test.jsx @@ -15,7 +15,7 @@ jest.mock('hooks', () => ({ reduxHooks: { useCardCourseRunData: jest.fn(() => ({ homeUrl: 'homeUrl' })), useTrackCourseEvent: jest.fn( - (eventName, cardId, upgradeUrl) => ({ trackCourseEvent: { eventName, cardId, upgradeUrl } }), + (eventName, cardId, url) => ({ trackCourseEvent: { eventName, cardId, url } }), ), }, })); diff --git a/src/containers/CourseCard/components/CourseCardActions/messages.js b/src/containers/CourseCard/components/CourseCardActions/messages.js index 6c14f9b0..30984297 100644 --- a/src/containers/CourseCard/components/CourseCardActions/messages.js +++ b/src/containers/CourseCard/components/CourseCardActions/messages.js @@ -1,11 +1,6 @@ import { defineMessages } from '@edx/frontend-platform/i18n'; const messages = defineMessages({ - upgrade: { - id: 'learner-dash.courseCard.actions.upgrade', - description: 'Course card upgrade button text', - defaultMessage: 'Upgrade', - }, beginCourse: { id: 'learner-dash.courseCard.actions.beginCourse', description: 'Course card begin-course button text', diff --git a/src/containers/CourseCard/components/CourseCardImage.test.jsx b/src/containers/CourseCard/components/CourseCardImage.test.jsx index 278b20d0..05d0636e 100644 --- a/src/containers/CourseCard/components/CourseCardImage.test.jsx +++ b/src/containers/CourseCard/components/CourseCardImage.test.jsx @@ -18,8 +18,8 @@ jest.mock('hooks', () => ({ useCardCourseData: jest.fn(() => ({ bannerImgSrc: 'banner-img-src' })), useCardCourseRunData: jest.fn(() => ({ homeUrl })), useCardEnrollmentData: jest.fn(() => ({ isVerified: true })), - useTrackCourseEvent: jest.fn((eventName, cardId, upgradeUrl) => ({ - trackCourseEvent: { eventName, cardId, upgradeUrl }, + useTrackCourseEvent: jest.fn((eventName, cardId, url) => ({ + trackCourseEvent: { eventName, cardId, url }, })), }, })); diff --git a/src/containers/CourseCard/components/CourseCardTitle.test.jsx b/src/containers/CourseCard/components/CourseCardTitle.test.jsx index a71dd7e7..aa3dcdd3 100644 --- a/src/containers/CourseCard/components/CourseCardTitle.test.jsx +++ b/src/containers/CourseCard/components/CourseCardTitle.test.jsx @@ -17,8 +17,8 @@ jest.mock('hooks', () => ({ reduxHooks: { useCardCourseData: jest.fn(() => ({ courseName: 'course-name' })), useCardCourseRunData: jest.fn(() => ({ homeUrl })), - useTrackCourseEvent: jest.fn((eventName, cardId, upgradeUrl) => ({ - trackCourseEvent: { eventName, cardId, upgradeUrl }, + useTrackCourseEvent: jest.fn((eventName, cardId, url) => ({ + trackCourseEvent: { eventName, cardId, url }, })), }, })); diff --git a/src/containers/CourseCard/components/hooks.js b/src/containers/CourseCard/components/hooks.js index 2a302014..9d80c0ae 100644 --- a/src/containers/CourseCard/components/hooks.js +++ b/src/containers/CourseCard/components/hooks.js @@ -3,19 +3,18 @@ import { reduxHooks } from 'hooks'; export const useActionDisabledState = (cardId) => { const { isMasquerading } = reduxHooks.useMasqueradeData(); const { - canUpgrade, hasAccess, isAudit, isAuditAccessExpired, + hasAccess, isAudit, isAuditAccessExpired, } = reduxHooks.useCardEnrollmentData(cardId); const { isEntitlement, isFulfilled, canChange, hasSessions, } = reduxHooks.useCardEntitlementData(cardId); - const { resumeUrl, homeUrl, upgradeUrl } = reduxHooks.useCardCourseRunData(cardId); + const { resumeUrl, homeUrl } = reduxHooks.useCardCourseRunData(cardId); const disableBeginCourse = !homeUrl || (isMasquerading || !hasAccess || (isAudit && isAuditAccessExpired)); const disableResumeCourse = !resumeUrl || (isMasquerading || !hasAccess || (isAudit && isAuditAccessExpired)); const disableViewCourse = !hasAccess || (isAudit && isAuditAccessExpired); const disableSelectSession = !isEntitlement || isMasquerading || !hasAccess || (!canChange || !hasSessions); - const disableUpgradeCourse = !upgradeUrl || (isMasquerading && !canUpgrade); const disableCourseTitle = (isEntitlement && !isFulfilled) || disableViewCourse; @@ -23,7 +22,6 @@ export const useActionDisabledState = (cardId) => { disableBeginCourse, disableResumeCourse, disableViewCourse, - disableUpgradeCourse, disableSelectSession, disableCourseTitle, }; diff --git a/src/containers/CourseCard/components/hooks.test.js b/src/containers/CourseCard/components/hooks.test.js index f389ef40..b1011ccd 100644 --- a/src/containers/CourseCard/components/hooks.test.js +++ b/src/containers/CourseCard/components/hooks.test.js @@ -26,7 +26,6 @@ describe('useActionDisabledState', () => { isAuditAccessExpired: false, resumeUrl: 'resume.url', homeUrl: 'home.url', - upgradeUrl: 'upgrade.url', }; const mockHooksData = (args) => { const { @@ -41,7 +40,6 @@ describe('useActionDisabledState', () => { isAuditAccessExpired, resumeUrl, homeUrl, - upgradeUrl, } = { ...defaultData, ...args }; reduxHooks.useMasqueradeData.mockReturnValueOnce({ isMasquerading }); reduxHooks.useCardEnrollmentData.mockReturnValueOnce({ @@ -59,7 +57,6 @@ describe('useActionDisabledState', () => { reduxHooks.useCardCourseRunData.mockReturnValueOnce({ resumeUrl, homeUrl, - upgradeUrl, }); }; @@ -121,21 +118,6 @@ describe('useActionDisabledState', () => { testDisabled({ hasAccess: true }, false); }); }); - describe('disableUpgradeCourse', () => { - const testDisabled = (data, expected) => { - mockHooksData(data); - expect(runHook().disableUpgradeCourse).toBe(expected); - }; - it('disable when upgradeUrl is invalid', () => { - testDisabled({ upgradeUrl: null }, true); - }); - it('disable when isMasquerading is true and canUpgrade is false', () => { - testDisabled({ isMasquerading: true, canUpgrade: false }, true); - }); - it('enable when all conditions are met', () => { - testDisabled({ canUpgrade: true }, false); - }); - }); describe('disableSelectSession', () => { const testDisabled = (data, expected) => { mockHooksData(data); diff --git a/src/data/redux/app/selectors/courseCard.js b/src/data/redux/app/selectors/courseCard.js index 742c5f00..ec6c1c7a 100644 --- a/src/data/redux/app/selectors/courseCard.js +++ b/src/data/redux/app/selectors/courseCard.js @@ -52,7 +52,6 @@ export const courseCard = StrictDict({ homeUrl: courseRun.homeUrl, marketingUrl: courseRun.marketingUrl, - upgradeUrl: courseRun.upgradeUrl, progressUrl: baseAppUrl(courseRun.progressUrl), resumeUrl: baseAppUrl(courseRun.resumeUrl), // resume will route this to learning mfe. @@ -91,6 +90,7 @@ export const courseCard = StrictDict({ hasStarted: enrollment.hasStarted, accessExpirationDate: module.loadDateVal(enrollment.accessExpirationDate), + // TODO: find out where "canUpgrade" comes from and if it's still needed by other components (see CourseBanner) canUpgrade: enrollment.canUpgrade, isAudit: enrollment.isAudit, isAuditAccessExpired: enrollment.isAuditAccessExpired, diff --git a/src/data/redux/app/selectors/courseCard.test.js b/src/data/redux/app/selectors/courseCard.test.js index 5f042c53..84c6da65 100644 --- a/src/data/redux/app/selectors/courseCard.test.js +++ b/src/data/redux/app/selectors/courseCard.test.js @@ -156,7 +156,6 @@ describe('courseCard selectors module', () => { homeUrl: 'test-home-url', marketingUrl: 'test-marketing-url', - upgradeUrl: 'test-upgrade-url', progressUrl: 'test-progress-url', resumeUrl: 'test-resume-url', @@ -181,10 +180,9 @@ describe('courseCard selectors module', () => { it('passes minPassingGrade floored from float to a percentage value', () => { expect(selected.minPassingGrade).toEqual(93); }); - it('passes [homeUrl, marketingUrl, upgradeUrl]', () => { + it('passes [homeUrl, marketingUrl]', () => { expect(selected.homeUrl).toEqual(testData.homeUrl); expect(selected.marketingUrl).toEqual(testData.marketingUrl); - expect(selected.upgradeUrl).toEqual(testData.upgradeUrl); }); it('passes [progressUrl, unenrollUrl, resumeUrl], converted to baseAppUrl', () => { expect(selected.progressUrl).toEqual(baseAppUrl(testData.progressUrl)); diff --git a/src/data/services/lms/api.js b/src/data/services/lms/api.js index 6f9acd56..e2d47718 100644 --- a/src/data/services/lms/api.js +++ b/src/data/services/lms/api.js @@ -50,12 +50,6 @@ export const logEvent = ({ eventName, data, courseId }) => post(urls.event(), { event: JSON.stringify(data), }); -export const logUpgrade = ({ courseId }) => module.logEvent({ - eventName: eventNames.upgradeButtonClickedEnrollment, - courseId, - data: { location: 'learner-dashboard' }, -}); - export const logShare = ({ courseId, site }) => module.logEvent({ eventName: eventNames.shareClicked, courseId, @@ -78,7 +72,6 @@ export default { updateEntitlementEnrollment, deleteEntitlementEnrollment, logEvent, - logUpgrade, logShare, createCreditRequest, }; diff --git a/src/data/services/lms/api.test.js b/src/data/services/lms/api.test.js index 8f83a379..af24aad9 100644 --- a/src/data/services/lms/api.test.js +++ b/src/data/services/lms/api.test.js @@ -130,13 +130,6 @@ describe('lms api methods', () => { beforeEach(() => { jest.spyOn(api, moduleKeys.logEvent).mockImplementation(logEvent); }); - test('logUpgrade sends enrollment upgrade click event with learner dashboard location', () => { - expect(api.logUpgrade({ courseId })).toEqual(logEvent({ - eventName: eventNames.upgradeButtonClickedEnrollment, - courseId, - data: { location: 'learner-dashboard' }, - })); - }); test('logShare sends share clicke vent with course id, side and location', () => { const site = 'test-site'; expect(api.logShare({ courseId, site })).toEqual(logEvent({ diff --git a/src/data/services/lms/fakeData/courses.js b/src/data/services/lms/fakeData/courses.js index 0fec065b..31911a96 100644 --- a/src/data/services/lms/fakeData/courses.js +++ b/src/data/services/lms/fakeData/courses.js @@ -779,9 +779,6 @@ export const compileCourseRunData = ({ courseName, ...data }, index) => { courseProvider: getOption(providerOptions, index), programs: getOption(programsOptions, index), }; - if (out.enrollment.canUpgrade) { - out.courseRun.upgradeUrl = 'test-upgrade-url'; - } return out; }; diff --git a/src/plugin-slots/CourseCardActionSlot/index.jsx b/src/plugin-slots/CourseCardActionSlot/index.jsx index 6747ee18..7a95b675 100644 --- a/src/plugin-slots/CourseCardActionSlot/index.jsx +++ b/src/plugin-slots/CourseCardActionSlot/index.jsx @@ -2,27 +2,14 @@ import React from 'react'; import PropTypes from 'prop-types'; import { PluginSlot } from '@openedx/frontend-plugin-framework'; -import { reduxHooks } from 'hooks'; -import UpgradeButton from 'containers/CourseCard/components/CourseCardActions/UpgradeButton'; - -const CourseCardActionSlot = ({ cardId }) => { - const { isEntitlement } = reduxHooks.useCardEntitlementData(cardId); - const { - isVerified, - isExecEd2UCourse, - } = reduxHooks.useCardEnrollmentData(cardId); - - return ( - - {!(isEntitlement || isVerified || isExecEd2UCourse) && } - - ); -}; +const CourseCardActionSlot = ({ cardId }) => ( + +); CourseCardActionSlot.propTypes = { cardId: PropTypes.string.isRequired, diff --git a/src/tracking/constants.js b/src/tracking/constants.js index 8c439a9b..4683019c 100644 --- a/src/tracking/constants.js +++ b/src/tracking/constants.js @@ -2,7 +2,6 @@ import { StrictDict } from 'utils'; export const categories = StrictDict({ dashboard: 'dashboard', - upgrade: 'upgrade', userEngagement: 'user-engagement', searchButton: 'search_button', credit: 'credit', @@ -14,9 +13,6 @@ export const events = StrictDict({ courseImageClicked: 'courseImageClicked', courseTitleClicked: 'courseTitleClicked', courseOptionsDropdownClicked: 'courseOptionsDropdownClicked', - upgradeButtonClicked: 'upgradeButtonClicked', - upgradeButtonClickedEnrollment: 'upgradeButtonClickedEnrollment', - upgradeButtonClickedUpsell: 'upgradeButtonClickedUpsell', shareClicked: 'shareClicked', userSettingsChanged: 'userSettingsChanged', newSession: 'newSession', @@ -36,9 +32,6 @@ export const eventNames = StrictDict({ courseImageClicked: 'edx.bi.dashboard.course_image.clicked', courseTitleClicked: 'edx.bi.dashboard.course_title.clicked', courseOptionsDropdownClicked: 'edx.bi.dashboard.course_options_dropdown.clicked', - upgradeButtonClicked: 'edx.bi.dashboard.upgrade_button.clicked', - upgradeButtonClickedEnrollment: 'edx.course.enrollment.upgrade.clicked', - upgradeButtonClickedUpsell: 'edx.bi.ecommerce.upsell_links_clicked', shareClicked: 'edx.course.share_clicked', userSettingsChanged: 'edx.user.settings.changed', newSession: 'course-dashboard.new-session', diff --git a/src/tracking/trackers/course.js b/src/tracking/trackers/course.js index aa5262c5..1edba267 100644 --- a/src/tracking/trackers/course.js +++ b/src/tracking/trackers/course.js @@ -1,4 +1,3 @@ -import api from 'data/services/lms/api'; import { createEventTracker, createLinkTracker } from 'data/services/segment/utils'; import { categories, eventNames } from '../constants'; import * as module from './course'; @@ -31,20 +30,6 @@ export const courseLinkTracker = (eventName) => (courseId, href) => ( createLinkTracker(module.courseEventTracker(eventName, courseId), href) ); -// Upgrade Events -/** - * There are currently multiple tracked api events for the upgrade event, with different targets. - * Goal here is to split out the tracked events for easier testing. - */ -export const upgradeButtonClicked = (courseId) => createEventTracker( - eventNames.upgradeButtonClicked, - { category: categories.upgrade, label: courseId }, -); -export const upgradeButtonClickedUpsell = (courseId) => createEventTracker( - eventNames.upgradeButtonClickedUpsell, - { ...upsellOptions, courseId }, -); - // Non-Link events export const courseOptionsDropdownClicked = (courseId) => ( module.courseEventTracker(eventNames.courseOptionsDropdownClicked, courseId) @@ -57,19 +42,10 @@ export const courseTitleClicked = (...args) => ( module.courseLinkTracker(eventNames.courseTitleClicked)(...args)); export const enterCourseClicked = (...args) => ( module.courseLinkTracker(eventNames.enterCourseClicked)(...args)); -export const upgradeClicked = (courseId, href) => createLinkTracker( - () => { - module.upgradeButtonClicked(courseId)(); - module.upgradeButtonClickedUpsell(courseId)(); - api.logUpgrade({ courseId }); - }, - href, -); export default { courseImageClicked, courseOptionsDropdownClicked, courseTitleClicked, enterCourseClicked, - upgradeClicked, }; diff --git a/src/tracking/trackers/course.test.js b/src/tracking/trackers/course.test.js index a8c8c391..7715b113 100644 --- a/src/tracking/trackers/course.test.js +++ b/src/tracking/trackers/course.test.js @@ -1,13 +1,8 @@ import { keyStore } from 'utils'; -import api from 'data/services/lms/api'; import { createEventTracker, createLinkTracker } from 'data/services/segment/utils'; import { categories, eventNames } from '../constants'; import * as trackers from './course'; -jest.mock('data/services/lms/api', () => ({ - logUpgrade: jest.fn(), -})); - jest.mock('data/services/segment/utils', () => ({ createEventTracker: jest.fn(args => ({ createEventTracker: args })), createLinkTracker: jest.fn((cb, href) => ({ createLinkTracker: { cb, href } })), @@ -44,26 +39,6 @@ describe('course trackers', () => { }); }); }); - describe('Upgrade Events', () => { - describe('upgradeButtonClicked', () => { - it('creates an event tracker for upgradeButtonClicked event with category and label', () => { - expect(trackers.upgradeButtonClicked(courseId)).toEqual(createEventTracker( - eventNames.upgradeButtonClicked, - { category: categories.upgrade, label: courseId }, - )); - }); - }); - describe('upgradeButtonClickedUpsell', () => { - it('creates an event tracker for upgradeButtonClickedUpsell eventwith upsellOptions', () => { - expect(trackers.upgradeButtonClickedUpsell(courseId)).toEqual( - createEventTracker( - eventNames.upgradeButtonClickedUpsell, - { ...trackers.upsellOptions, courseId }, - ), - ); - }); - }); - }); describe('Non-link events', () => { describe('courseOptionsDropdownClicked', () => { it('creates course event tracker for courseOptionsDropdownClicked event', () => { @@ -101,25 +76,5 @@ describe('course trackers', () => { ); }); }); - describe('upgradeClicked', () => { - it('triggers upgrade actions and api.logUpgrade with courseId', () => { - const upgradeButtonClicked = jest.fn(); - const upgradeButtonClickedUpsell = jest.fn(); - const trackUpgradeButtonClicked = jest.fn(() => upgradeButtonClicked); - const trackUpgradeButtonClickedUpsell = jest.fn(() => upgradeButtonClickedUpsell); - jest.spyOn(trackers, moduleKeys.upgradeButtonClicked) - .mockImplementationOnce(trackUpgradeButtonClicked); - jest.spyOn(trackers, moduleKeys.upgradeButtonClickedUpsell) - .mockImplementationOnce(trackUpgradeButtonClickedUpsell); - const out = trackers.upgradeClicked(courseId, href).createLinkTracker; - expect(out.href).toEqual(href); - out.cb(); - expect(trackUpgradeButtonClicked).toHaveBeenCalledWith(courseId); - expect(trackUpgradeButtonClickedUpsell).toHaveBeenCalledWith(courseId); - expect(upgradeButtonClicked).toHaveBeenCalledWith(); - expect(upgradeButtonClickedUpsell).toHaveBeenCalledWith(); - expect(api.logUpgrade).toHaveBeenCalledWith({ courseId }); - }); - }); }); }); From 3a97a76b7d93d43d1f99b137607c249c00c73496 Mon Sep 17 00:00:00 2001 From: Maxwell Frank Date: Fri, 20 Dec 2024 14:04:46 +0000 Subject: [PATCH 2/4] fix: typo --- src/data/redux/app/selectors/courseCard.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/data/redux/app/selectors/courseCard.js b/src/data/redux/app/selectors/courseCard.js index ec6c1c7a..080ad37e 100644 --- a/src/data/redux/app/selectors/courseCard.js +++ b/src/data/redux/app/selectors/courseCard.js @@ -90,7 +90,6 @@ export const courseCard = StrictDict({ hasStarted: enrollment.hasStarted, accessExpirationDate: module.loadDateVal(enrollment.accessExpirationDate), - // TODO: find out where "canUpgrade" comes from and if it's still needed by other components (see CourseBanner) canUpgrade: enrollment.canUpgrade, isAudit: enrollment.isAudit, isAuditAccessExpired: enrollment.isAuditAccessExpired, From 9529da854d24fae22ce1bc6e2015c035cd281ead Mon Sep 17 00:00:00 2001 From: Maxwell Frank Date: Fri, 20 Dec 2024 14:37:08 +0000 Subject: [PATCH 3/4] fix: snapshots --- .../BeginCourseButton.test.jsx.snap | 4 +-- .../__snapshots__/ResumeButton.test.jsx.snap | 4 +-- .../__snapshots__/UpgradeButton.test.jsx.snap | 32 ------------------- .../ViewCourseButton.test.jsx.snap | 4 +-- .../CourseCardImage.test.jsx.snap | 2 +- .../CourseCardTitle.test.jsx.snap | 2 +- 6 files changed, 8 insertions(+), 40 deletions(-) delete mode 100644 src/containers/CourseCard/components/CourseCardActions/__snapshots__/UpgradeButton.test.jsx.snap diff --git a/src/containers/CourseCard/components/CourseCardActions/__snapshots__/BeginCourseButton.test.jsx.snap b/src/containers/CourseCard/components/CourseCardActions/__snapshots__/BeginCourseButton.test.jsx.snap index 4604ab60..0cbfdb62 100644 --- a/src/containers/CourseCard/components/CourseCardActions/__snapshots__/BeginCourseButton.test.jsx.snap +++ b/src/containers/CourseCard/components/CourseCardActions/__snapshots__/BeginCourseButton.test.jsx.snap @@ -10,7 +10,7 @@ exports[`BeginCourseButton snapshot disabled snapshot 1`] = ` "trackCourseEvent": { "cardId": "cardId", "eventName": [MockFunction segment.enterCourseClicked], - "upgradeUrl": "home-urlexec-ed-tracking-path=cardId", + "url": "home-urlexec-ed-tracking-path=cardId", }, } } @@ -29,7 +29,7 @@ exports[`BeginCourseButton snapshot enabled snapshot 1`] = ` "trackCourseEvent": { "cardId": "cardId", "eventName": [MockFunction segment.enterCourseClicked], - "upgradeUrl": "home-urlexec-ed-tracking-path=cardId", + "url": "home-urlexec-ed-tracking-path=cardId", }, } } diff --git a/src/containers/CourseCard/components/CourseCardActions/__snapshots__/ResumeButton.test.jsx.snap b/src/containers/CourseCard/components/CourseCardActions/__snapshots__/ResumeButton.test.jsx.snap index e0c34840..c9c7e5e6 100644 --- a/src/containers/CourseCard/components/CourseCardActions/__snapshots__/ResumeButton.test.jsx.snap +++ b/src/containers/CourseCard/components/CourseCardActions/__snapshots__/ResumeButton.test.jsx.snap @@ -10,7 +10,7 @@ exports[`ResumeButton snapshot disabled snapshot 1`] = ` "trackCourseEvent": { "cardId": "cardId", "eventName": [MockFunction segment.enterCourseClicked], - "upgradeUrl": "resume-urlexec-ed-tracking-path=cardId", + "url": "resume-urlexec-ed-tracking-path=cardId", }, } } @@ -29,7 +29,7 @@ exports[`ResumeButton snapshot enabled snapshot 1`] = ` "trackCourseEvent": { "cardId": "cardId", "eventName": [MockFunction segment.enterCourseClicked], - "upgradeUrl": "resume-urlexec-ed-tracking-path=cardId", + "url": "resume-urlexec-ed-tracking-path=cardId", }, } } diff --git a/src/containers/CourseCard/components/CourseCardActions/__snapshots__/UpgradeButton.test.jsx.snap b/src/containers/CourseCard/components/CourseCardActions/__snapshots__/UpgradeButton.test.jsx.snap deleted file mode 100644 index d6718302..00000000 --- a/src/containers/CourseCard/components/CourseCardActions/__snapshots__/UpgradeButton.test.jsx.snap +++ /dev/null @@ -1,32 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`UpgradeButton snapshot can upgrade 1`] = ` - - Upgrade - -`; - -exports[`UpgradeButton snapshot cannot upgrade 1`] = ` - - Upgrade - -`; diff --git a/src/containers/CourseCard/components/CourseCardActions/__snapshots__/ViewCourseButton.test.jsx.snap b/src/containers/CourseCard/components/CourseCardActions/__snapshots__/ViewCourseButton.test.jsx.snap index d777595e..3274270f 100644 --- a/src/containers/CourseCard/components/CourseCardActions/__snapshots__/ViewCourseButton.test.jsx.snap +++ b/src/containers/CourseCard/components/CourseCardActions/__snapshots__/ViewCourseButton.test.jsx.snap @@ -10,7 +10,7 @@ exports[`ViewCourseButton learner can view course 1`] = ` "trackCourseEvent": { "cardId": "cardId", "eventName": [MockFunction segment.enterCourseClicked], - "upgradeUrl": "homeUrl", + "url": "homeUrl", }, } } @@ -29,7 +29,7 @@ exports[`ViewCourseButton learner cannot view course 1`] = ` "trackCourseEvent": { "cardId": "cardId", "eventName": [MockFunction segment.enterCourseClicked], - "upgradeUrl": "homeUrl", + "url": "homeUrl", }, } } diff --git a/src/containers/CourseCard/components/__snapshots__/CourseCardImage.test.jsx.snap b/src/containers/CourseCard/components/__snapshots__/CourseCardImage.test.jsx.snap index 2a0bc925..a0d357c7 100644 --- a/src/containers/CourseCard/components/__snapshots__/CourseCardImage.test.jsx.snap +++ b/src/containers/CourseCard/components/__snapshots__/CourseCardImage.test.jsx.snap @@ -9,7 +9,7 @@ exports[`CourseCardImage snapshot renders clickable link course Image 1`] = ` "trackCourseEvent": { "cardId": "cardId", "eventName": [MockFunction segment.courseImageClicked], - "upgradeUrl": "home-url", + "url": "home-url", }, } } diff --git a/src/containers/CourseCard/components/__snapshots__/CourseCardTitle.test.jsx.snap b/src/containers/CourseCard/components/__snapshots__/CourseCardTitle.test.jsx.snap index c35f852c..34446ade 100644 --- a/src/containers/CourseCard/components/__snapshots__/CourseCardTitle.test.jsx.snap +++ b/src/containers/CourseCard/components/__snapshots__/CourseCardTitle.test.jsx.snap @@ -11,7 +11,7 @@ exports[`CourseCardTitle snapshot renders clickable link course title 1`] = ` "trackCourseEvent": { "cardId": "cardId", "eventName": [MockFunction segment.courseTitleClicked], - "upgradeUrl": "home-url", + "url": "home-url", }, } } From 7ebaa2c39b8c9c0b3fe7bf7afcf7920720e08f8f Mon Sep 17 00:00:00 2001 From: Maxwell Frank Date: Mon, 13 Jan 2025 17:24:33 +0000 Subject: [PATCH 4/4] fix: remove canUpgrade in hooks test --- src/containers/CourseCard/components/hooks.test.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/containers/CourseCard/components/hooks.test.js b/src/containers/CourseCard/components/hooks.test.js index b1011ccd..50d2ccc2 100644 --- a/src/containers/CourseCard/components/hooks.test.js +++ b/src/containers/CourseCard/components/hooks.test.js @@ -16,7 +16,6 @@ const cardId = 'my-test-course-number'; describe('useActionDisabledState', () => { const defaultData = { isMasquerading: false, - canUpgrade: false, isEntitlement: false, isFulfilled: false, canChange: false, @@ -30,7 +29,6 @@ describe('useActionDisabledState', () => { const mockHooksData = (args) => { const { isMasquerading, - canUpgrade, isEntitlement, isFulfilled, canChange, @@ -43,7 +41,6 @@ describe('useActionDisabledState', () => { } = { ...defaultData, ...args }; reduxHooks.useMasqueradeData.mockReturnValueOnce({ isMasquerading }); reduxHooks.useCardEnrollmentData.mockReturnValueOnce({ - canUpgrade, hasAccess, isAudit, isAuditAccessExpired,