Skip to content

Commit

Permalink
chore: Gate expiration subs modal by license state as well as feature…
Browse files Browse the repository at this point in the history
… toggle. (#1216)
  • Loading branch information
macdiesel authored Oct 30, 2024
1 parent 96970cf commit 72ff986
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/components/expired-subscription-modal/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import DOMPurify from 'dompurify';
import { useSubscriptions } from '../app/data';

const ExpiredSubscriptionModal = () => {
const { data: { customerAgreement } } = useSubscriptions();
const { data: { customerAgreement, subscriptionLicense } } = useSubscriptions();
const [isOpen] = useToggle(true);
if (!customerAgreement?.hasCustomLicenseExpirationMessaging) {
const displaySubscriptionExpirationModal = customerAgreement?.hasCustomLicenseExpirationMessaging
&& !subscriptionLicense?.subscriptionPlan.isCurrent;
if (!displaySubscriptionExpirationModal) {
return null;
}
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ describe('<ExpiredSubscriptionModal />', () => {
expiredSubscriptionModalMessaging: null,
urlForButtonInModal: null,
},
subscriptionLicense: {
subscriptionPlan: {
isCurrent: true,
},
},
},
});
});
Expand All @@ -30,7 +35,7 @@ describe('<ExpiredSubscriptionModal />', () => {
expect(container).toBeEmptyDOMElement();
});

test('renderwithrouters modal with messaging when `hasCustomLicenseExpirationMessaging` is true', () => {
test('does not renderwithrouter if learner has a current license', () => {
useSubscriptions.mockReturnValue({
data: {
customerAgreement: {
Expand All @@ -40,6 +45,33 @@ describe('<ExpiredSubscriptionModal />', () => {
expiredSubscriptionModalMessaging: '<p>Your subscription has expired.</p>',
urlForButtonInModal: '/renew',
},
subscriptionLicense: {
subscriptionPlan: {
isCurrent: true,
},
},
},
});

const { container } = renderWithRouter(<ExpiredSubscriptionModal />);
expect(container).toBeEmptyDOMElement();
});

test('renderwithrouters modal with messaging when `hasCustomLicenseExpirationMessaging` 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',
},
subscriptionLicense: {
subscriptionPlan: {
isCurrent: false,
},
},
},
});

Expand Down

0 comments on commit 72ff986

Please sign in to comment.