From 19cd4752177a0c816e257a1192337b41664af37b Mon Sep 17 00:00:00 2001 From: Filip Naumovski Date: Mon, 24 Jul 2023 16:28:22 +0200 Subject: [PATCH] fix: add per-provider flag for subscription change tests --- test-e2e/tests/payments/coupons_test.ts | 4 +++- test-e2e/tests/payments/subscription_test.ts | 4 +++- test-e2e/utils/payments.ts | 4 ++-- test/types.ts | 1 + 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/test-e2e/tests/payments/coupons_test.ts b/test-e2e/tests/payments/coupons_test.ts index 9a5ebed0a..c05cbfbe6 100644 --- a/test-e2e/tests/payments/coupons_test.ts +++ b/test-e2e/tests/payments/coupons_test.ts @@ -14,6 +14,7 @@ const jwProps: ProviderProps = { locale: undefined, shouldMakePayment: true, canRenewSubscription: false, + hasInlineOfferSwitch: true, }; const cleengProps: ProviderProps = { @@ -26,6 +27,7 @@ const cleengProps: ProviderProps = { locale: 'NL', shouldMakePayment: false, canRenewSubscription: true, + hasInlineOfferSwitch: false, }; runTestSuite(jwProps, 'JW Player'); @@ -86,7 +88,7 @@ function runTestSuite(props: ProviderProps, providerName: string) { ); } - await finishAndCheckSubscription(I, addYear(today), today, props.yearlyOffer.price, providerName); + await finishAndCheckSubscription(I, addYear(today), today, props.yearlyOffer.price, props.hasInlineOfferSwitch); }); Scenario(`I can cancel a free subscription - ${providerName}`, async ({ I }) => { diff --git a/test-e2e/tests/payments/subscription_test.ts b/test-e2e/tests/payments/subscription_test.ts index 8671d5a57..3b3291ea8 100644 --- a/test-e2e/tests/payments/subscription_test.ts +++ b/test-e2e/tests/payments/subscription_test.ts @@ -13,6 +13,7 @@ const jwProps: ProviderProps = { applicableTax: 0, canRenewSubscription: false, fieldWrapper: '', + hasInlineOfferSwitch: true, }; const cleengProps: ProviderProps = { @@ -24,6 +25,7 @@ const cleengProps: ProviderProps = { applicableTax: 21, canRenewSubscription: true, fieldWrapper: 'iframe', + hasInlineOfferSwitch: false, }; runTestSuite(jwProps, 'JW Player'); @@ -170,7 +172,7 @@ function runTestSuite(props: ProviderProps, providerName: string) { props.fieldWrapper, ); - await finishAndCheckSubscription(I, addYear(today), today, props.yearlyOffer.price, providerName); + await finishAndCheckSubscription(I, addYear(today), today, props.yearlyOffer.price, props.hasInlineOfferSwitch); I.seeAll(cardInfo); }); diff --git a/test-e2e/utils/payments.ts b/test-e2e/utils/payments.ts index f1f0e7c52..8732da225 100644 --- a/test-e2e/utils/payments.ts +++ b/test-e2e/utils/payments.ts @@ -35,7 +35,7 @@ export function formatDate(date: Date) { return new Intl.DateTimeFormat('en-US', { day: 'numeric', month: 'long', year: 'numeric' }).format(date); } -export async function finishAndCheckSubscription(I: CodeceptJS.I, billingDate: Date, today: Date, yearlyPrice: string, providerName?: string) { +export async function finishAndCheckSubscription(I: CodeceptJS.I, billingDate: Date, today: Date, yearlyPrice: string, hasInlineOfferSwitch: boolean) { I.click('Continue'); I.waitForLoaderDone(longTimeout); I.wait(2); @@ -64,7 +64,7 @@ export async function finishAndCheckSubscription(I: CodeceptJS.I, billingDate: D I.see('/year'); I.see('Next billing date is on ' + formatDate(billingDate)); - if (providerName?.includes('JW')) { + if (hasInlineOfferSwitch) { I.waitForElement('[data-testid="change-subscription-button"]', 10); I.click('[data-testid="change-subscription-button"]'); } diff --git a/test/types.ts b/test/types.ts index 544188650..14532ef98 100644 --- a/test/types.ts +++ b/test/types.ts @@ -27,4 +27,5 @@ export type ProviderProps = { shouldMakePayment?: boolean; locale?: string | undefined; fieldWrapper?: string; + hasInlineOfferSwitch: boolean; };