Skip to content

Commit

Permalink
fix: vsf expired messaging issue (#1218)
Browse files Browse the repository at this point in the history
  • Loading branch information
jajjibhai008 authored Oct 31, 2024
1 parent 0c14daf commit 66a5d34
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions src/components/app/data/services/subsidies/subscriptions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
{
Expand All @@ -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,
},
{
Expand All @@ -89,7 +89,7 @@ describe('fetchSubscriptions', () => {
startDate: dayjs().subtract(15, 'days').toISOString(),
expirationDate: dayjs().toISOString(),
disableExpirationNotifications: false,
hasCustomLicenseExpirationMessaging: false,
hasCustomLicenseExpirationMessagingV2: false,
expectedShowExpirationNotifications: true,
},
{
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 ({
Expand All @@ -147,7 +147,7 @@ describe('fetchSubscriptions', () => {
startDate,
expirationDate,
disableExpirationNotifications,
hasCustomLicenseExpirationMessaging,
hasCustomLicenseExpirationMessagingV2,
expectedShowExpirationNotifications,
}) => {
const mockSubscriptionLicense = {
Expand All @@ -166,7 +166,7 @@ describe('fetchSubscriptions', () => {
customerAgreement: {
uuid: 'test-customer-agreement-uuid',
disableExpirationNotifications,
hasCustomLicenseExpirationMessaging,
hasCustomLicenseExpirationMessagingV2,
},
results: [mockSubscriptionLicense],
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const CourseRunCardStatus = ({
return null;
}
return (
customerAgreement?.hasCustomLicenseExpirationMessaging ? (
customerAgreement?.hasCustomLicenseExpirationMessagingV2 ? (
<Card.Status
data-testid="custom-license-expiration-message-id"
variant="primary"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('<CourseRunCardStatus />', () => {
useSubscriptions.mockReturnValue({
data: {
customerAgreement: {
hasCustomLicenseExpirationMessaging: false,
hasCustomLicenseExpirationMessagingV2: false,
expiredSubscriptionModalMessaging: null,
urlForExpiredModal: null,
hyperLinkTextForExpiredModal: null,
Expand Down Expand Up @@ -82,7 +82,7 @@ describe('<CourseRunCardStatus />', () => {
useSubscriptions.mockReturnValue({
data: {
customerAgreement: {
hasCustomLicenseExpirationMessaging: true,
hasCustomLicenseExpirationMessagingV2: true,
},
},
});
Expand Down
2 changes: 1 addition & 1 deletion src/components/course/routes/tests/CourseAbout.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe('CourseAbout', () => {
useSubscriptions.mockReturnValue({
data: {
customerAgreement: {
hasCustomLicenseExpirationMessaging: false,
hasCustomLicenseExpirationMessagingV2: false,
expiredSubscriptionModalMessaging: null,
urlForExpiredModal: null,
hyperLinkTextForExpiredModal: null,
Expand Down
2 changes: 1 addition & 1 deletion src/components/dashboard/DashboardPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const DashboardPage = () => {
</Tabs>
<IntegrationWarningModal isEnabled={enterpriseCustomer.showIntegrationWarning} />
{/* 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.
Expand Down
10 changes: 5 additions & 5 deletions src/components/expired-subscription-modal/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
);

Expand All @@ -18,21 +18,21 @@ const ExpiredSubscriptionModal = () => {

return (
<AlertModal
title={<h3 className="mb-2">{customerAgreement.modalHeaderText}</h3>}
title={<h3 className="mb-2">{customerAgreement.modalHeaderTextV2}</h3>}
isOpen={isOpen}
isBlocking
footerNode={(
<ActionRow>
<Button href={customerAgreement.urlForButtonInModal}>
{customerAgreement.buttonLabelInModal}
<Button href={customerAgreement.urlForButtonInModalV2}>
{customerAgreement.buttonLabelInModalV2}
</Button>
</ActionRow>
)}
>
{/* eslint-disable-next-line react/no-danger */}
<div dangerouslySetInnerHTML={{
__html: DOMPurify.sanitize(
customerAgreement.expiredSubscriptionModalMessaging,
customerAgreement.expiredSubscriptionModalMessagingV2,
{ USE_PROFILES: { html: true } },
),
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ describe('<ExpiredSubscriptionModal />', () => {
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',
Expand All @@ -31,7 +31,7 @@ describe('<ExpiredSubscriptionModal />', () => {
});
});

test('does not renderwithrouter if `hasCustomLicenseExpirationMessaging` is false', () => {
test('does not renderwithrouter if `hasCustomLicenseExpirationMessagingV2` is false', () => {
const { container } = renderWithRouter(<ExpiredSubscriptionModal />);
expect(container).toBeEmptyDOMElement();
});
Expand All @@ -40,11 +40,11 @@ describe('<ExpiredSubscriptionModal />', () => {
useSubscriptions.mockReturnValue({
data: {
customerAgreement: {
hasCustomLicenseExpirationMessaging: true,
modalHeaderText: 'Expired Subscription',
buttonLabelInModal: 'Continue Learning',
expiredSubscriptionModalMessaging: '<p>Your subscription has expired.</p>',
urlForButtonInModal: '/renew',
hasCustomLicenseExpirationMessagingV2: true,
modalHeaderTextV2: 'Expired Subscription',
buttonLabelInModalV2: 'Continue Learning',
expiredSubscriptionModalMessagingV2: '<p>Your subscription has expired.</p>',
urlForButtonInModalV2: '/renew',
},
subscriptionLicense: {
uuid: '123',
Expand All @@ -63,11 +63,11 @@ describe('<ExpiredSubscriptionModal />', () => {
useSubscriptions.mockReturnValue({
data: {
customerAgreement: {
hasCustomLicenseExpirationMessaging: true,
modalHeaderText: 'Expired Subscription',
buttonLabelInModal: 'Continue Learning',
expiredSubscriptionModalMessaging: '<p>Your subscription has expired.</p>',
urlForButtonInModal: '/renew',
hasCustomLicenseExpirationMessagingV2: true,
modalHeaderTextV2: 'Expired Subscription',
buttonLabelInModalV2: 'Continue Learning',
expiredSubscriptionModalMessagingV2: '<p>Your subscription has expired.</p>',
urlForButtonInModalV2: '/renew',
},
subscriptionLicense: null,
subscriptionPlan: null,
Expand All @@ -78,15 +78,15 @@ describe('<ExpiredSubscriptionModal />', () => {
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: '<p>Your subscription has expired.</p>',
urlForButtonInModal: '/renew',
hasCustomLicenseExpirationMessagingV2: true,
modalHeaderTextV2: 'Expired Subscription',
buttonLabelInModalV2: 'Continue Learning',
expiredSubscriptionModalMessagingV2: '<p>Your subscription has expired.</p>',
urlForButtonInModalV2: '/renew',
},
subscriptionLicense: {
uuid: '123',
Expand All @@ -113,11 +113,11 @@ describe('<ExpiredSubscriptionModal />', () => {
useSubscriptions.mockReturnValue({
data: {
customerAgreement: {
hasCustomLicenseExpirationMessaging: true,
modalHeaderText: 'Expired Subscription',
buttonLabelInModal: 'Continue Learning',
expiredSubscriptionModalMessaging: '<p>Your subscription has expired.</p>',
urlForButtonInModal: '/renew',
hasCustomLicenseExpirationMessagingV2: true,
modalHeaderTextV2: 'Expired Subscription',
buttonLabelInModalV2: 'Continue Learning',
expiredSubscriptionModalMessagingV2: '<p>Your subscription has expired.</p>',
urlForButtonInModalV2: '/renew',
},
subscriptionLicense: {
uuid: '123',
Expand All @@ -136,11 +136,11 @@ describe('<ExpiredSubscriptionModal />', () => {
useSubscriptions.mockReturnValue({
data: {
customerAgreement: {
hasCustomLicenseExpirationMessaging: true,
modalHeaderText: 'Expired Subscription',
buttonLabelInModal: 'Continue Learning',
expiredSubscriptionModalMessaging: '<p>Your subscription has expired.</p>',
urlForButtonInModal: 'https://example.com',
hasCustomLicenseExpirationMessagingV2: true,
modalHeaderTextV2: 'Expired Subscription',
buttonLabelInModalV2: 'Continue Learning',
expiredSubscriptionModalMessagingV2: '<p>Your subscription has expired.</p>',
urlForButtonInModalV2: 'https://example.com',
},
subscriptionLicense: {
uuid: '123',
Expand Down

0 comments on commit 66a5d34

Please sign in to comment.