Skip to content

Commit

Permalink
fix: add per-provider flag for subscription change tests
Browse files Browse the repository at this point in the history
  • Loading branch information
naumovski-filip committed Jul 24, 2023
1 parent 1435d0d commit 19cd475
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion test-e2e/tests/payments/coupons_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const jwProps: ProviderProps = {
locale: undefined,
shouldMakePayment: true,
canRenewSubscription: false,
hasInlineOfferSwitch: true,
};

const cleengProps: ProviderProps = {
Expand All @@ -26,6 +27,7 @@ const cleengProps: ProviderProps = {
locale: 'NL',
shouldMakePayment: false,
canRenewSubscription: true,
hasInlineOfferSwitch: false,
};

runTestSuite(jwProps, 'JW Player');
Expand Down Expand Up @@ -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 }) => {
Expand Down
4 changes: 3 additions & 1 deletion test-e2e/tests/payments/subscription_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const jwProps: ProviderProps = {
applicableTax: 0,
canRenewSubscription: false,
fieldWrapper: '',
hasInlineOfferSwitch: true,
};

const cleengProps: ProviderProps = {
Expand All @@ -24,6 +25,7 @@ const cleengProps: ProviderProps = {
applicableTax: 21,
canRenewSubscription: true,
fieldWrapper: 'iframe',
hasInlineOfferSwitch: false,
};

runTestSuite(jwProps, 'JW Player');
Expand Down Expand Up @@ -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);
});
Expand Down
4 changes: 2 additions & 2 deletions test-e2e/utils/payments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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"]');
}
Expand Down
1 change: 1 addition & 0 deletions test/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ export type ProviderProps = {
shouldMakePayment?: boolean;
locale?: string | undefined;
fieldWrapper?: string;
hasInlineOfferSwitch: boolean;
};

0 comments on commit 19cd475

Please sign in to comment.