From 08dff6a14099b869d8ef082271767b1a8c405daa Mon Sep 17 00:00:00 2001 From: kiremitrov123 Date: Tue, 14 Mar 2023 10:57:33 +0100 Subject: [PATCH] fix: e2e date locale problem --- package.json | 2 +- test-e2e/codecept.desktop.js | 5 +++-- test-e2e/tests/payments/subscription_test.ts | 8 ++++---- test-e2e/utils/payments.ts | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 285db579f..4e5d13e84 100644 --- a/package.json +++ b/package.json @@ -142,4 +142,4 @@ "flat": "^5.0.1", "json5": "^2.2.2" } -} \ No newline at end of file +} diff --git a/test-e2e/codecept.desktop.js b/test-e2e/codecept.desktop.js index 497be178e..d0547cb36 100644 --- a/test-e2e/codecept.desktop.js +++ b/test-e2e/codecept.desktop.js @@ -9,14 +9,15 @@ setHeadlessWhen(process.env.HEADLESS); exports.config = { grep: '(?=.*)^(?!.*@mobile-only)', - tests: ['./tests/**/*.js', './tests/**/*.ts'], + tests: ['./tests/**/*.js', './tests/payments/subscription_test.ts'], output: './output/desktop', timeout: 60, helpers: { Playwright: { url: 'http://localhost:8080', - show: !!process.env.SHOW, + show: true, channel: 'chrome', + locale: 'en-US', }, }, include: { diff --git a/test-e2e/tests/payments/subscription_test.ts b/test-e2e/tests/payments/subscription_test.ts index 4bf7fdfa6..cd64c7547 100644 --- a/test-e2e/tests/payments/subscription_test.ts +++ b/test-e2e/tests/payments/subscription_test.ts @@ -1,6 +1,6 @@ import { LoginContext } from '#utils/password_utils'; import constants, { longTimeout, normalTimeout } from '#utils/constants'; -import { overrideIP, goToCheckout, formatPrice, finishAndCheckSubscription, cancelPlan, renewPlan, addDays } from '#utils/payments'; +import { overrideIP, goToCheckout, formatPrice, finishAndCheckSubscription, cancelPlan, renewPlan, addDays, addYear } from '#utils/payments'; import { testConfigs } from '#test/constants'; let paidLoginContext: LoginContext; @@ -159,7 +159,7 @@ Scenario('I can finish my subscription', async ({ I }) => { // @ts-expect-error I.switchTo(null); // Exit the iframe context back to the main document - await finishAndCheckSubscription(I, addDays(today, 365), today); + await finishAndCheckSubscription(I, addYear(today), today); I.seeAll(cardInfo); }); @@ -167,7 +167,7 @@ Scenario('I can finish my subscription', async ({ I }) => { Scenario('I can cancel my subscription', async ({ I }) => { paidLoginContext = await I.registerOrLogin(paidLoginContext); - cancelPlan(I, addDays(today, 365)); + cancelPlan(I, addYear(today)); // Still see payment info I.seeAll(cardInfo); @@ -176,5 +176,5 @@ Scenario('I can cancel my subscription', async ({ I }) => { Scenario('I can renew my subscription', async ({ I }) => { paidLoginContext = await I.registerOrLogin(paidLoginContext); - renewPlan(I, addDays(today, 365)); + renewPlan(I, addYear(today)); }); diff --git a/test-e2e/utils/payments.ts b/test-e2e/utils/payments.ts index 6df951e0a..29dc262b1 100644 --- a/test-e2e/utils/payments.ts +++ b/test-e2e/utils/payments.ts @@ -32,7 +32,7 @@ export function addYear(date: Date) { } export function formatDate(date: Date) { - return date.toLocaleDateString('en-US'); + return date.toLocaleDateString(); } export async function finishAndCheckSubscription(I: CodeceptJS.I, billingDate: Date, today: Date) {