From 66a5d34d36130a5825b74e97152e28b5004ec13b Mon Sep 17 00:00:00 2001 From: Ejaz Ahmad <86868918+jajjibhai008@users.noreply.github.com> Date: Thu, 31 Oct 2024 19:38:52 +0500 Subject: [PATCH] fix: vsf expired messaging issue (#1218) --- .../data/services/subsidies/subscriptions.js | 2 +- .../services/subsidies/subscriptions.test.js | 18 +++--- .../course-header/CourseRunCardStatus.jsx | 2 +- .../tests/CourseRunCardStatus.test.jsx | 4 +- .../course/routes/tests/CourseAbout.test.jsx | 2 +- src/components/dashboard/DashboardPage.jsx | 2 +- .../expired-subscription-modal/index.jsx | 10 +-- .../tests/ExpiredSubscriptionModal.test.jsx | 64 +++++++++---------- 8 files changed, 52 insertions(+), 52 deletions(-) diff --git a/src/components/app/data/services/subsidies/subscriptions.js b/src/components/app/data/services/subsidies/subscriptions.js index be36c5d739..f480a8430d 100644 --- a/src/components/app/data/services/subsidies/subscriptions.js +++ b/src/components/app/data/services/subsidies/subscriptions.js @@ -237,7 +237,7 @@ export async function fetchSubscriptions(enterpriseUUID) { subscriptionsData.customerAgreement = customerAgreement; } subscriptionsData.showExpirationNotifications = ( - !customerAgreement?.disableExpirationNotifications && !customerAgreement?.hasCustomLicenseExpirationMessaging + !customerAgreement?.disableExpirationNotifications && !customerAgreement?.hasCustomLicenseExpirationMessagingV2 ); // Sort licenses within each license status by whether the associated subscription plans diff --git a/src/components/app/data/services/subsidies/subscriptions.test.js b/src/components/app/data/services/subsidies/subscriptions.test.js index c622835805..d653e8fdbb 100644 --- a/src/components/app/data/services/subsidies/subscriptions.test.js +++ b/src/components/app/data/services/subsidies/subscriptions.test.js @@ -67,7 +67,7 @@ describe('fetchSubscriptions', () => { startDate: dayjs().subtract(15, 'days').toISOString(), expirationDate: dayjs().add(30, 'days').toISOString(), disableExpirationNotifications: false, - hasCustomLicenseExpirationMessaging: false, + hasCustomLicenseExpirationMessagingV2: false, expectedShowExpirationNotifications: true, }, { @@ -78,7 +78,7 @@ describe('fetchSubscriptions', () => { startDate: dayjs().subtract(15, 'days').toISOString(), expirationDate: dayjs().add(30, 'days').toISOString(), disableExpirationNotifications: false, - hasCustomLicenseExpirationMessaging: false, + hasCustomLicenseExpirationMessagingV2: false, expectedShowExpirationNotifications: true, }, { @@ -89,7 +89,7 @@ describe('fetchSubscriptions', () => { startDate: dayjs().subtract(15, 'days').toISOString(), expirationDate: dayjs().toISOString(), disableExpirationNotifications: false, - hasCustomLicenseExpirationMessaging: false, + hasCustomLicenseExpirationMessagingV2: false, expectedShowExpirationNotifications: true, }, { @@ -100,7 +100,7 @@ describe('fetchSubscriptions', () => { startDate: dayjs().subtract(15, 'days').toISOString(), expirationDate: dayjs().add(30, 'days').toISOString(), disableExpirationNotifications: false, - hasCustomLicenseExpirationMessaging: false, + hasCustomLicenseExpirationMessagingV2: false, expectedShowExpirationNotifications: true, }, // Custom subs messaging with standard expiration still enabled @@ -112,7 +112,7 @@ describe('fetchSubscriptions', () => { startDate: dayjs().subtract(15, 'days').toISOString(), expirationDate: dayjs().subtract(10, 'days').toISOString(), disableExpirationNotifications: false, - hasCustomLicenseExpirationMessaging: true, + hasCustomLicenseExpirationMessagingV2: true, expectedShowExpirationNotifications: false, }, // Disabled standard expiration, with custom subs expiration enabled @@ -124,7 +124,7 @@ describe('fetchSubscriptions', () => { startDate: dayjs().subtract(15, 'days').toISOString(), expirationDate: dayjs().subtract(10, 'days').toISOString(), disableExpirationNotifications: true, - hasCustomLicenseExpirationMessaging: true, + hasCustomLicenseExpirationMessagingV2: true, expectedShowExpirationNotifications: false, }, // Disabled standard expiration, no custom subs expiration @@ -136,7 +136,7 @@ describe('fetchSubscriptions', () => { startDate: dayjs().subtract(15, 'days').toISOString(), expirationDate: dayjs().subtract(10, 'days').toISOString(), disableExpirationNotifications: true, - hasCustomLicenseExpirationMessaging: false, + hasCustomLicenseExpirationMessagingV2: false, expectedShowExpirationNotifications: false, }, ])('returns subscriptions (%s)', async ({ @@ -147,7 +147,7 @@ describe('fetchSubscriptions', () => { startDate, expirationDate, disableExpirationNotifications, - hasCustomLicenseExpirationMessaging, + hasCustomLicenseExpirationMessagingV2, expectedShowExpirationNotifications, }) => { const mockSubscriptionLicense = { @@ -166,7 +166,7 @@ describe('fetchSubscriptions', () => { customerAgreement: { uuid: 'test-customer-agreement-uuid', disableExpirationNotifications, - hasCustomLicenseExpirationMessaging, + hasCustomLicenseExpirationMessagingV2, }, results: [mockSubscriptionLicense], }; diff --git a/src/components/course/course-header/CourseRunCardStatus.jsx b/src/components/course/course-header/CourseRunCardStatus.jsx index 1c4030ac7a..76f338032c 100644 --- a/src/components/course/course-header/CourseRunCardStatus.jsx +++ b/src/components/course/course-header/CourseRunCardStatus.jsx @@ -38,7 +38,7 @@ const CourseRunCardStatus = ({ return null; } return ( - customerAgreement?.hasCustomLicenseExpirationMessaging ? ( + customerAgreement?.hasCustomLicenseExpirationMessagingV2 ? ( ', () => { useSubscriptions.mockReturnValue({ data: { customerAgreement: { - hasCustomLicenseExpirationMessaging: false, + hasCustomLicenseExpirationMessagingV2: false, expiredSubscriptionModalMessaging: null, urlForExpiredModal: null, hyperLinkTextForExpiredModal: null, @@ -82,7 +82,7 @@ describe('', () => { useSubscriptions.mockReturnValue({ data: { customerAgreement: { - hasCustomLicenseExpirationMessaging: true, + hasCustomLicenseExpirationMessagingV2: true, }, }, }); diff --git a/src/components/course/routes/tests/CourseAbout.test.jsx b/src/components/course/routes/tests/CourseAbout.test.jsx index d1d7c88f1b..f14c5de07a 100644 --- a/src/components/course/routes/tests/CourseAbout.test.jsx +++ b/src/components/course/routes/tests/CourseAbout.test.jsx @@ -71,7 +71,7 @@ describe('CourseAbout', () => { useSubscriptions.mockReturnValue({ data: { customerAgreement: { - hasCustomLicenseExpirationMessaging: false, + hasCustomLicenseExpirationMessagingV2: false, expiredSubscriptionModalMessaging: null, urlForExpiredModal: null, hyperLinkTextForExpiredModal: null, diff --git a/src/components/dashboard/DashboardPage.jsx b/src/components/dashboard/DashboardPage.jsx index 35174dd85a..4d0adca20b 100644 --- a/src/components/dashboard/DashboardPage.jsx +++ b/src/components/dashboard/DashboardPage.jsx @@ -97,7 +97,7 @@ const DashboardPage = () => { {/* ExpiredSubscriptionModal is specifically tailored for learners with an expired license and is - triggered when the learner has hasCustomLicenseExpirationMessaging enabled. + triggered when the learner has hasCustomLicenseExpirationMessagingV2 enabled. Ideally, the existing SubscriptionExpirationModal should be extended or repurposed to incorporate this logic and support the custom messaging. This is noted as a TO-DO, and a ticket will be created to address this enhancement. diff --git a/src/components/expired-subscription-modal/index.jsx b/src/components/expired-subscription-modal/index.jsx index d37054eaa9..86c38d5e50 100644 --- a/src/components/expired-subscription-modal/index.jsx +++ b/src/components/expired-subscription-modal/index.jsx @@ -8,7 +8,7 @@ const ExpiredSubscriptionModal = () => { const { data: { customerAgreement, subscriptionLicense, subscriptionPlan } } = useSubscriptions(); const [isOpen] = useToggle(true); const displaySubscriptionExpirationModal = ( - customerAgreement?.hasCustomLicenseExpirationMessaging + customerAgreement?.hasCustomLicenseExpirationMessagingV2 && subscriptionLicense && !subscriptionPlan.isCurrent ); @@ -18,13 +18,13 @@ const ExpiredSubscriptionModal = () => { return ( {customerAgreement.modalHeaderText}} + title={

{customerAgreement.modalHeaderTextV2}

} isOpen={isOpen} isBlocking footerNode={( - )} @@ -32,7 +32,7 @@ const ExpiredSubscriptionModal = () => { {/* eslint-disable-next-line react/no-danger */}
', () => { useSubscriptions.mockReturnValue({ data: { customerAgreement: { - hasCustomLicenseExpirationMessaging: false, - modalHeaderText: null, - buttonLabelInModal: null, - expiredSubscriptionModalMessaging: null, - urlForButtonInModal: null, + hasCustomLicenseExpirationMessagingV2: false, + modalHeaderTextV2: null, + buttonLabelInModalV2: null, + expiredSubscriptionModalMessagingV2: null, + urlForButtonInModalV2: null, }, subscriptionLicense: { uuid: '123', @@ -31,7 +31,7 @@ describe('', () => { }); }); - test('does not renderwithrouter if `hasCustomLicenseExpirationMessaging` is false', () => { + test('does not renderwithrouter if `hasCustomLicenseExpirationMessagingV2` is false', () => { const { container } = renderWithRouter(); expect(container).toBeEmptyDOMElement(); }); @@ -40,11 +40,11 @@ describe('', () => { useSubscriptions.mockReturnValue({ data: { customerAgreement: { - hasCustomLicenseExpirationMessaging: true, - modalHeaderText: 'Expired Subscription', - buttonLabelInModal: 'Continue Learning', - expiredSubscriptionModalMessaging: '

Your subscription has expired.

', - urlForButtonInModal: '/renew', + hasCustomLicenseExpirationMessagingV2: true, + modalHeaderTextV2: 'Expired Subscription', + buttonLabelInModalV2: 'Continue Learning', + expiredSubscriptionModalMessagingV2: '

Your subscription has expired.

', + urlForButtonInModalV2: '/renew', }, subscriptionLicense: { uuid: '123', @@ -63,11 +63,11 @@ describe('', () => { useSubscriptions.mockReturnValue({ data: { customerAgreement: { - hasCustomLicenseExpirationMessaging: true, - modalHeaderText: 'Expired Subscription', - buttonLabelInModal: 'Continue Learning', - expiredSubscriptionModalMessaging: '

Your subscription has expired.

', - urlForButtonInModal: '/renew', + hasCustomLicenseExpirationMessagingV2: true, + modalHeaderTextV2: 'Expired Subscription', + buttonLabelInModalV2: 'Continue Learning', + expiredSubscriptionModalMessagingV2: '

Your subscription has expired.

', + urlForButtonInModalV2: '/renew', }, subscriptionLicense: null, subscriptionPlan: null, @@ -78,15 +78,15 @@ describe('', () => { expect(container).toBeEmptyDOMElement(); }); - test('renderwithrouters modal with messaging when `hasCustomLicenseExpirationMessaging` is true and license is expired', () => { + test('renderwithrouters modal with messaging when `hasCustomLicenseExpirationMessagingV2` is true and license is expired', () => { useSubscriptions.mockReturnValue({ data: { customerAgreement: { - hasCustomLicenseExpirationMessaging: true, - modalHeaderText: 'Expired Subscription', - buttonLabelInModal: 'Continue Learning', - expiredSubscriptionModalMessaging: '

Your subscription has expired.

', - urlForButtonInModal: '/renew', + hasCustomLicenseExpirationMessagingV2: true, + modalHeaderTextV2: 'Expired Subscription', + buttonLabelInModalV2: 'Continue Learning', + expiredSubscriptionModalMessagingV2: '

Your subscription has expired.

', + urlForButtonInModalV2: '/renew', }, subscriptionLicense: { uuid: '123', @@ -113,11 +113,11 @@ describe('', () => { useSubscriptions.mockReturnValue({ data: { customerAgreement: { - hasCustomLicenseExpirationMessaging: true, - modalHeaderText: 'Expired Subscription', - buttonLabelInModal: 'Continue Learning', - expiredSubscriptionModalMessaging: '

Your subscription has expired.

', - urlForButtonInModal: '/renew', + hasCustomLicenseExpirationMessagingV2: true, + modalHeaderTextV2: 'Expired Subscription', + buttonLabelInModalV2: 'Continue Learning', + expiredSubscriptionModalMessagingV2: '

Your subscription has expired.

', + urlForButtonInModalV2: '/renew', }, subscriptionLicense: { uuid: '123', @@ -136,11 +136,11 @@ describe('', () => { useSubscriptions.mockReturnValue({ data: { customerAgreement: { - hasCustomLicenseExpirationMessaging: true, - modalHeaderText: 'Expired Subscription', - buttonLabelInModal: 'Continue Learning', - expiredSubscriptionModalMessaging: '

Your subscription has expired.

', - urlForButtonInModal: 'https://example.com', + hasCustomLicenseExpirationMessagingV2: true, + modalHeaderTextV2: 'Expired Subscription', + buttonLabelInModalV2: 'Continue Learning', + expiredSubscriptionModalMessagingV2: '

Your subscription has expired.

', + urlForButtonInModalV2: 'https://example.com', }, subscriptionLicense: { uuid: '123',