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 && ( From 68263cb442d04355171137d9f972d4a879ad9b09 Mon Sep 17 00:00:00 2001 From: Borislav Petrovikj Date: Mon, 1 Jul 2024 13:12:35 +0200 Subject: [PATCH 06/11] feat(project): revert --- .../ui-react/src/components/Payment/Payment.tsx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/ui-react/src/components/Payment/Payment.tsx b/packages/ui-react/src/components/Payment/Payment.tsx index d673dd0bb..9b284af75 100644 --- a/packages/ui-react/src/components/Payment/Payment.tsx +++ b/packages/ui-react/src/components/Payment/Payment.tsx @@ -80,6 +80,7 @@ const Payment = ({ canShowReceipts = false, canUpdatePaymentMethod, offerSwitchesAvailable, + onUpgradeSubscriptionClick, offers = [], pendingDowngradeOfferId = '', changeSubscriptionPlan, @@ -220,11 +221,19 @@ const Payment = ({ ) : ( showChangeSubscriptionButton && ( From 98872d19f2f650ac6eabc00bc7671831e14d17ae Mon Sep 17 00:00:00 2001 From: Borislav Petrovikj Date: Tue, 2 Jul 2024 15:34:24 +0200 Subject: [PATCH 08/11] feat(project): added logic for switch plans --- packages/common/src/constants.ts | 1 + .../services/integrations/AccountService.ts | 1 + .../cleeng/CleengAccountService.ts | 1 + .../integrations/jwp/JWPAccountService.ts | 1 + .../src/components/Payment/Payment.test.tsx | 1 + .../src/components/Payment/Payment.tsx | 47 ++++++++++++------- .../PaymentContainer/PaymentContainer.tsx | 3 +- 7 files changed, 37 insertions(+), 18 deletions(-) diff --git a/packages/common/src/constants.ts b/packages/common/src/constants.ts index b63801922..c7458357a 100644 --- a/packages/common/src/constants.ts +++ b/packages/common/src/constants.ts @@ -79,6 +79,7 @@ export const DEFAULT_FEATURES = { hasSocialURLs: false, hasNotifications: false, watchListSizeLimit: MAX_WATCHLIST_ITEMS_COUNT, + canSwitchSubscription: false, }; export const EPG_TYPE = { diff --git a/packages/common/src/services/integrations/AccountService.ts b/packages/common/src/services/integrations/AccountService.ts index deb186041..6dea9326a 100644 --- a/packages/common/src/services/integrations/AccountService.ts +++ b/packages/common/src/services/integrations/AccountService.ts @@ -36,6 +36,7 @@ export type AccountServiceFeatures = { readonly hasSocialURLs: boolean; readonly hasNotifications: boolean; readonly watchListSizeLimit: number; + readonly canSwitchSubscription: boolean; }; export default abstract class AccountService { diff --git a/packages/common/src/services/integrations/cleeng/CleengAccountService.ts b/packages/common/src/services/integrations/cleeng/CleengAccountService.ts index 045849b54..db99d1261 100644 --- a/packages/common/src/services/integrations/cleeng/CleengAccountService.ts +++ b/packages/common/src/services/integrations/cleeng/CleengAccountService.ts @@ -71,6 +71,7 @@ export default class CleengAccountService extends AccountService { canShowReceipts: false, hasSocialURLs: false, hasNotifications: false, + canSwitchSubscription: true, // The 'externalData' attribute of Cleeng can contain max 4000 characters watchListSizeLimit: 48, }); diff --git a/packages/common/src/services/integrations/jwp/JWPAccountService.ts b/packages/common/src/services/integrations/jwp/JWPAccountService.ts index e8815fffa..a831bdce9 100644 --- a/packages/common/src/services/integrations/jwp/JWPAccountService.ts +++ b/packages/common/src/services/integrations/jwp/JWPAccountService.ts @@ -67,6 +67,7 @@ export default class JWPAccountService extends AccountService { canShowReceipts: true, canDeleteAccount: false, hasNotifications: true, + canSwitchSubscription: false, hasSocialURLs: true, // Limit of media_ids length passed to the /apps/watchlists endpoint watchListSizeLimit: 48, diff --git a/packages/ui-react/src/components/Payment/Payment.test.tsx b/packages/ui-react/src/components/Payment/Payment.test.tsx index a4847043d..f75e62938 100644 --- a/packages/ui-react/src/components/Payment/Payment.test.tsx +++ b/packages/ui-react/src/components/Payment/Payment.test.tsx @@ -23,6 +23,7 @@ describe('', () => { canUpdatePaymentMethod={false} showAllTransactions={false} isLoading={false} + canSwitchSubscription={false} offerSwitchesAvailable={false} onShowReceiptClick={vi.fn()} onUpgradeSubscriptionClick={vi.fn()} diff --git a/packages/ui-react/src/components/Payment/Payment.tsx b/packages/ui-react/src/components/Payment/Payment.tsx index 538e78509..9aa0ba1dd 100644 --- a/packages/ui-react/src/components/Payment/Payment.tsx +++ b/packages/ui-react/src/components/Payment/Payment.tsx @@ -61,6 +61,7 @@ type Props = { isExternalPaymentProvider: boolean; paymentProvider?: string; paymentProviderLink?: string; + canSwitchSubscription: boolean; }; const Payment = ({ @@ -92,6 +93,7 @@ const Payment = ({ isExternalPaymentProvider, paymentProvider, paymentProviderLink, + canSwitchSubscription, }: Props): JSX.Element => { const subscriptionDetailsId = useOpaqueId('subscription-details'); const paymentMethodId = useOpaqueId('payment-method'); @@ -219,23 +221,34 @@ const Payment = ({

) : ( - showChangeSubscriptionButton && ( - 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); } });