Skip to content

Commit

Permalink
fix: e2e date locale problem
Browse files Browse the repository at this point in the history
  • Loading branch information
kiremitrov123 committed Mar 14, 2023
1 parent d69bfed commit 08dff6a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,4 @@
"flat": "^5.0.1",
"json5": "^2.2.2"
}
}
}
5 changes: 3 additions & 2 deletions test-e2e/codecept.desktop.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
8 changes: 4 additions & 4 deletions test-e2e/tests/payments/subscription_test.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -159,15 +159,15 @@ 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);
});

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);
Expand All @@ -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));
});
2 changes: 1 addition & 1 deletion test-e2e/utils/payments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 08dff6a

Please sign in to comment.