From f458cd64e5dc83a2f903cb84a9ef43e875690f62 Mon Sep 17 00:00:00 2001
From: Borislav Petrovikj
Date: Thu, 27 Jun 2024 17:05:32 +0200
Subject: [PATCH 01/11] feat(project): commented code
---
packages/ui-react/src/components/Account/Account.tsx | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/packages/ui-react/src/components/Account/Account.tsx b/packages/ui-react/src/components/Account/Account.tsx
index 9752b12f9..8ef122d8b 100644
--- a/packages/ui-react/src/components/Account/Account.tsx
+++ b/packages/ui-react/src/components/Account/Account.tsx
@@ -384,7 +384,7 @@ const Account = ({ panelClassName, panelHeaderClassName, canUpdateEmail = true }
),
}),
- canExportAccountData &&
+ !canExportAccountData &&
formSection({
label: t('account.export_data_title'),
content: (section) => (
@@ -405,7 +405,7 @@ const Account = ({ panelClassName, panelHeaderClassName, canUpdateEmail = true }
),
}),
- canDeleteAccount &&
+ !canDeleteAccount &&
formSection({
label: t('account.delete_account.title'),
content: () => (
@@ -426,7 +426,7 @@ const Account = ({ panelClassName, panelHeaderClassName, canUpdateEmail = true }
}),
].filter(isTruthy)}
- {canExportAccountData && (
+ {!canExportAccountData && (
setIsAlertVisible(false)} isSuccess={exportData.isSuccess} />
)}
>
From d0acb5c3245fe61f8e04edc90f91560fa097e25c Mon Sep 17 00:00:00 2001
From: Borislav Petrovikj
Date: Thu, 27 Jun 2024 17:24:20 +0200
Subject: [PATCH 02/11] feat(project): canExportdata and canDeleteAccount false
---
.../src/services/integrations/jwp/JWPAccountService.ts | 4 ++--
packages/ui-react/src/components/Account/Account.tsx | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/packages/common/src/services/integrations/jwp/JWPAccountService.ts b/packages/common/src/services/integrations/jwp/JWPAccountService.ts
index 5daba8d5e..e8815fffa 100644
--- a/packages/common/src/services/integrations/jwp/JWPAccountService.ts
+++ b/packages/common/src/services/integrations/jwp/JWPAccountService.ts
@@ -62,10 +62,10 @@ export default class JWPAccountService extends AccountService {
canSupportEmptyFullName: false,
canChangePasswordWithOldPassword: true,
canRenewSubscription: false,
- canExportAccountData: true,
+ canExportAccountData: false,
canUpdatePaymentMethod: false,
canShowReceipts: true,
- canDeleteAccount: true,
+ canDeleteAccount: false,
hasNotifications: true,
hasSocialURLs: true,
// Limit of media_ids length passed to the /apps/watchlists endpoint
diff --git a/packages/ui-react/src/components/Account/Account.tsx b/packages/ui-react/src/components/Account/Account.tsx
index 8ef122d8b..9752b12f9 100644
--- a/packages/ui-react/src/components/Account/Account.tsx
+++ b/packages/ui-react/src/components/Account/Account.tsx
@@ -384,7 +384,7 @@ const Account = ({ panelClassName, panelHeaderClassName, canUpdateEmail = true }
),
}),
- !canExportAccountData &&
+ canExportAccountData &&
formSection({
label: t('account.export_data_title'),
content: (section) => (
@@ -405,7 +405,7 @@ const Account = ({ panelClassName, panelHeaderClassName, canUpdateEmail = true }
),
}),
- !canDeleteAccount &&
+ canDeleteAccount &&
formSection({
label: t('account.delete_account.title'),
content: () => (
@@ -426,7 +426,7 @@ const Account = ({ panelClassName, panelHeaderClassName, canUpdateEmail = true }
}),
].filter(isTruthy)}
- {!canExportAccountData && (
+ {canExportAccountData && (
setIsAlertVisible(false)} isSuccess={exportData.isSuccess} />
)}
>
From 79d29aa17306f38bb228e77a3b67ee4c5423bb17 Mon Sep 17 00:00:00 2001
From: Borislav Petrovikj
Date: Fri, 28 Jun 2024 15:17:38 +0200
Subject: [PATCH 03/11] feat(project): switch plans disabled
---
.../src/components/Payment/Payment.tsx | 18 +++++-------------
1 file changed, 5 insertions(+), 13 deletions(-)
diff --git a/packages/ui-react/src/components/Payment/Payment.tsx b/packages/ui-react/src/components/Payment/Payment.tsx
index 538e78509..ac2e53da4 100644
--- a/packages/ui-react/src/components/Payment/Payment.tsx
+++ b/packages/ui-react/src/components/Payment/Payment.tsx
@@ -79,7 +79,6 @@ const Payment = ({
canRenewSubscription = false,
canShowReceipts = false,
canUpdatePaymentMethod,
- onUpgradeSubscriptionClick,
offerSwitchesAvailable,
offers = [],
pendingDowngradeOfferId = '',
@@ -221,19 +220,12 @@ const Payment = ({
) : (
showChangeSubscriptionButton && (
) : (
- showChangeSubscriptionButton && (
- {
- if (offers.length > 1 && !canRenewSubscription) {
- setIsChangingOffer(true);
- } else {
- onUpgradeSubscriptionClick?.();
- }
- }}
- fullWidth={isMobile}
- color="primary"
- data-testid="change-subscription-button"
- />
- )
+ <>
+ {canSwitchSubscription && showChangeSubscriptionButton && (
+ {
+ if (offers.length > 1 && !canRenewSubscription) {
+ setIsChangingOffer(true);
+ } else {
+ onUpgradeSubscriptionClick?.();
+ }
+ }}
+ fullWidth={isMobile}
+ color="primary"
+ data-testid="change-subscription-button"
+ />
+ )}
+ {!canSwitchSubscription && activeSubscription?.status !== 'cancelled' && (
+
+ )}
+ >
)}
{(activeSubscription.status === 'active' || activeSubscription.status === 'active_trial') &&
!isGrantedSubscription &&
diff --git a/packages/ui-react/src/containers/PaymentContainer/PaymentContainer.tsx b/packages/ui-react/src/containers/PaymentContainer/PaymentContainer.tsx
index 2aaeb2b87..b58440a0a 100644
--- a/packages/ui-react/src/containers/PaymentContainer/PaymentContainer.tsx
+++ b/packages/ui-react/src/containers/PaymentContainer/PaymentContainer.tsx
@@ -58,7 +58,7 @@ const PaymentContainer = () => {
const { accessModel } = useConfigStore(({ accessModel }) => ({ accessModel }), shallow);
const { user: customer, subscription: activeSubscription, transactions, activePayment, pendingOffer, loading } = useAccountStore();
- const { canUpdatePaymentMethod, canShowReceipts, canRenewSubscription } = accountController.getFeatures();
+ const { canUpdatePaymentMethod, canShowReceipts, canRenewSubscription, canSwitchSubscription } = accountController.getFeatures();
const { subscriptionOffers, switchSubscriptionOffers } = useOffers();
const [showAllTransactions, setShowAllTransactions] = useState(false);
@@ -135,6 +135,7 @@ const PaymentContainer = () => {
isExternalPaymentProvider={isExternalPaymentProvider}
paymentProvider={paymentProvider}
paymentProviderLink={paymentProviderLink}
+ canSwitchSubscription={canSwitchSubscription}
/>
);
};
From cffa8cdd075b435bf270880aaa36cfc0bb31a97f Mon Sep 17 00:00:00 2001
From: Borislav Petrovikj
Date: Tue, 2 Jul 2024 15:41:00 +0200
Subject: [PATCH 09/11] feat(project): added tests
---
.../src/pages/User/__snapshots__/User.test.tsx.snap | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/packages/ui-react/src/pages/User/__snapshots__/User.test.tsx.snap b/packages/ui-react/src/pages/User/__snapshots__/User.test.tsx.snap
index c6c0ec92b..850011167 100644
--- a/packages/ui-react/src/pages/User/__snapshots__/User.test.tsx.snap
+++ b/packages/ui-react/src/pages/User/__snapshots__/User.test.tsx.snap
@@ -690,13 +690,12 @@ exports[`User Component tests > Payments Page 1`] = `
- user:payment.change_subscription
+ user:payment.cancel_subscription
From b74a910a84ff829a16e441c9742df35032197bb1 Mon Sep 17 00:00:00 2001
From: Borislav Petrovikj
Date: Wed, 3 Jul 2024 14:41:32 +0200
Subject: [PATCH 10/11] feat(project): added tests
---
platforms/web/test-e2e/tests/payments/coupons_test.ts | 8 ++++++--
platforms/web/test-e2e/tests/payments/payments_test.ts | 7 +++++--
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/platforms/web/test-e2e/tests/payments/coupons_test.ts b/platforms/web/test-e2e/tests/payments/coupons_test.ts
index 7eafe5d08..8c4e731db 100644
--- a/platforms/web/test-e2e/tests/payments/coupons_test.ts
+++ b/platforms/web/test-e2e/tests/payments/coupons_test.ts
@@ -61,7 +61,7 @@ function runTestSuite(props: ProviderProps, providerName: string) {
I.dontSee('Coupon code');
I.click('Redeem coupon');
- I.fillField('couponCode', 'test75');
+ I.fillField('input[name="couponCode"]', 'test75');
I.click('Apply');
I.waitForLoaderDone();
I.see('Your coupon code has been applied');
@@ -72,7 +72,7 @@ function runTestSuite(props: ProviderProps, providerName: string) {
I.see(formatPrice(props.applicableTax, 'EUR', props.locale));
}
- I.fillField('couponCode', 'test100');
+ I.fillField('input[name="couponCode"]', 'test100');
I.click('Apply');
I.waitForLoaderDone();
I.see(formatPrice(0, 'EUR', props.locale));
@@ -87,6 +87,10 @@ function runTestSuite(props: ProviderProps, providerName: string) {
'',
);
}
+
+ I.waitForElement('[data-testid="complete-subscription-button"]', 10);
+ I.click('[data-testid="complete-subscription-button"]');
+
await finishSubscription(I);
await checkSubscription(I, addYear(today), today, props.yearlyOffer.price, props.hasInlineOfferSwitch);
});
diff --git a/platforms/web/test-e2e/tests/payments/payments_test.ts b/platforms/web/test-e2e/tests/payments/payments_test.ts
index e717954b5..0d0f1e43f 100644
--- a/platforms/web/test-e2e/tests/payments/payments_test.ts
+++ b/platforms/web/test-e2e/tests/payments/payments_test.ts
@@ -66,7 +66,7 @@ function runTestSuite(props: ProviderProps, providerName: string) {
await goToCheckout(I);
const alreadySubscribed = await tryTo(() => {
- I.waitForText('Next billing date is on ' + formatDate(today));
+ I.waitForText('Next billing date is on ' + formatDate(today), 10);
});
if (!alreadySubscribed) {
@@ -79,6 +79,9 @@ function runTestSuite(props: ProviderProps, providerName: string) {
props.fieldWrapper,
);
+ I.waitForElement('[data-testid="change-subscription-button"]', 10);
+ I.click('[data-testid="change-subscription-button"]');
+
await finishSubscription(I);
}
@@ -99,7 +102,7 @@ function runTestSuite(props: ProviderProps, providerName: string) {
Scenario(`I can renew my subscription - ${providerName}`, async ({ I }) => {
if (props.canRenewSubscription) {
paidLoginContext = await I.registerOrLogin(paidLoginContext);
- renewPlan(I, addYear(today), props.yearlyOffer.price);
+ await renewPlan(I, addYear(today), props.yearlyOffer.price);
}
});
From 516b167783e537774397197870d207799ec26082 Mon Sep 17 00:00:00 2001
From: Borislav Petrovikj
Date: Wed, 3 Jul 2024 15:06:59 +0200
Subject: [PATCH 11/11] feat(project): revert tests
---
platforms/web/test-e2e/tests/payments/coupons_test.ts | 8 ++------
platforms/web/test-e2e/tests/payments/payments_test.ts | 7 ++-----
2 files changed, 4 insertions(+), 11 deletions(-)
diff --git a/platforms/web/test-e2e/tests/payments/coupons_test.ts b/platforms/web/test-e2e/tests/payments/coupons_test.ts
index 8c4e731db..7eafe5d08 100644
--- a/platforms/web/test-e2e/tests/payments/coupons_test.ts
+++ b/platforms/web/test-e2e/tests/payments/coupons_test.ts
@@ -61,7 +61,7 @@ function runTestSuite(props: ProviderProps, providerName: string) {
I.dontSee('Coupon code');
I.click('Redeem coupon');
- I.fillField('input[name="couponCode"]', 'test75');
+ I.fillField('couponCode', 'test75');
I.click('Apply');
I.waitForLoaderDone();
I.see('Your coupon code has been applied');
@@ -72,7 +72,7 @@ function runTestSuite(props: ProviderProps, providerName: string) {
I.see(formatPrice(props.applicableTax, 'EUR', props.locale));
}
- I.fillField('input[name="couponCode"]', 'test100');
+ I.fillField('couponCode', 'test100');
I.click('Apply');
I.waitForLoaderDone();
I.see(formatPrice(0, 'EUR', props.locale));
@@ -87,10 +87,6 @@ function runTestSuite(props: ProviderProps, providerName: string) {
'',
);
}
-
- I.waitForElement('[data-testid="complete-subscription-button"]', 10);
- I.click('[data-testid="complete-subscription-button"]');
-
await finishSubscription(I);
await checkSubscription(I, addYear(today), today, props.yearlyOffer.price, props.hasInlineOfferSwitch);
});
diff --git a/platforms/web/test-e2e/tests/payments/payments_test.ts b/platforms/web/test-e2e/tests/payments/payments_test.ts
index 0d0f1e43f..e717954b5 100644
--- a/platforms/web/test-e2e/tests/payments/payments_test.ts
+++ b/platforms/web/test-e2e/tests/payments/payments_test.ts
@@ -66,7 +66,7 @@ function runTestSuite(props: ProviderProps, providerName: string) {
await goToCheckout(I);
const alreadySubscribed = await tryTo(() => {
- I.waitForText('Next billing date is on ' + formatDate(today), 10);
+ I.waitForText('Next billing date is on ' + formatDate(today));
});
if (!alreadySubscribed) {
@@ -79,9 +79,6 @@ function runTestSuite(props: ProviderProps, providerName: string) {
props.fieldWrapper,
);
- I.waitForElement('[data-testid="change-subscription-button"]', 10);
- I.click('[data-testid="change-subscription-button"]');
-
await finishSubscription(I);
}
@@ -102,7 +99,7 @@ function runTestSuite(props: ProviderProps, providerName: string) {
Scenario(`I can renew my subscription - ${providerName}`, async ({ I }) => {
if (props.canRenewSubscription) {
paidLoginContext = await I.registerOrLogin(paidLoginContext);
- await renewPlan(I, addYear(today), props.yearlyOffer.price);
+ renewPlan(I, addYear(today), props.yearlyOffer.price);
}
});