From 131b06fae648355f949b477bb476d02bb91f9582 Mon Sep 17 00:00:00 2001 From: giancarlo Date: Sun, 14 Apr 2024 19:34:40 +0800 Subject: [PATCH] Refactor e2e test code and reduce test timeout The end-to-end tests have been refactored for clarity and maintainability. This includes changes in how the 'Billing' link is accessed, addition of comments and small coding improvements. Moreover, the test timeout has been reduced from 2 minutes to 1 for efficiency. Changes were also applied to the text content in locales file and minor fixes in component styling. --- apps/e2e/playwright.config.ts | 4 ++-- apps/e2e/tests/team-billing/team-billing.spec.ts | 1 - apps/e2e/tests/user-billing/user-billing.spec.ts | 10 ++++++---- apps/e2e/tests/utils/billing.po.ts | 3 ++- apps/web/public/locales/en/auth.json | 2 +- .../gateway/src/components/line-item-details.tsx | 2 +- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/apps/e2e/playwright.config.ts b/apps/e2e/playwright.config.ts index f28b9a322..8bdf5c871 100644 --- a/apps/e2e/playwright.config.ts +++ b/apps/e2e/playwright.config.ts @@ -32,8 +32,8 @@ export default defineConfig({ trace: 'on-first-retry' }, - // test timeout set to 2 minutes - timeout: 2 * 60 * 1000, + // test timeout set to 1 minutes + timeout: 60 * 1000, expect: { // expect timeout set to 10 seconds timeout: 10 * 1000 diff --git a/apps/e2e/tests/team-billing/team-billing.spec.ts b/apps/e2e/tests/team-billing/team-billing.spec.ts index 988503d5a..409ae2d66 100644 --- a/apps/e2e/tests/team-billing/team-billing.spec.ts +++ b/apps/e2e/tests/team-billing/team-billing.spec.ts @@ -1,6 +1,5 @@ import { expect, Page, test } from '@playwright/test'; import { TeamBillingPageObject } from './team-billing.po'; -import exp from 'node:constants'; test.describe('Team Billing', () => { let page: Page; diff --git a/apps/e2e/tests/user-billing/user-billing.spec.ts b/apps/e2e/tests/user-billing/user-billing.spec.ts index 4c62c5b5e..78943784e 100644 --- a/apps/e2e/tests/user-billing/user-billing.spec.ts +++ b/apps/e2e/tests/user-billing/user-billing.spec.ts @@ -12,7 +12,7 @@ test.describe('User Billing', () => { await po.setup(); }); - test('user can subscribe to a plan', async ({page}) => { + test('user can subscribe to a plan', async ({ page }) => { await po.billing.selectPlan(0); await po.billing.proceedToCheckout(); @@ -22,9 +22,11 @@ test.describe('User Billing', () => { await expect(po.billing.successStatus()).toBeVisible(); await po.billing.returnToHome(); - await page.locator('a', { - hasText: 'Billing', - }).click(); + const link = page.locator('a', { + hasText: 'Billing' + }); + + await link.click(); await expect(await po.billing.getStatus()).toContainText('Active'); await expect(po.billing.manageBillingButton()).toBeVisible(); diff --git a/apps/e2e/tests/utils/billing.po.ts b/apps/e2e/tests/utils/billing.po.ts index 3612f4f88..c05c38a3f 100644 --- a/apps/e2e/tests/utils/billing.po.ts +++ b/apps/e2e/tests/utils/billing.po.ts @@ -1,4 +1,4 @@ -import { Page } from '@playwright/test'; +import { expect, Page } from '@playwright/test'; import { StripePageObject } from './stripe.po'; export class BillingPageObject { @@ -29,6 +29,7 @@ export class BillingPageObject { } async returnToHome() { + // wait a bit for the webhook to be processed await this.page.waitForTimeout(1000); await this.successStatus().locator('button').click(); diff --git a/apps/web/public/locales/en/auth.json b/apps/web/public/locales/en/auth.json index 6a25d5626..07b1b169c 100644 --- a/apps/web/public/locales/en/auth.json +++ b/apps/web/public/locales/en/auth.json @@ -65,7 +65,7 @@ "resetPasswordError": "Sorry, we could not reset your password. Please try again.", "emailPlaceholder": "your@email.com", "inviteAlertHeading": "You have been invited to join a team", - "inviteAlertBody": "You have been invited to join a team. Please sign in or sign up to accept the invite.", + "inviteAlertBody": "Please sign in or sign up to accept the invite and join the team.", "errors": { "Invalid login credentials": "The credentials entered are invalid", "User already registered": "This credential is already in use. Please try with another one.", diff --git a/packages/billing/gateway/src/components/line-item-details.tsx b/packages/billing/gateway/src/components/line-item-details.tsx index 42e3278bf..6aaa87811 100644 --- a/packages/billing/gateway/src/components/line-item-details.tsx +++ b/packages/billing/gateway/src/components/line-item-details.tsx @@ -17,7 +17,7 @@ export function LineItemDetails( }>, ) { return ( -
+
{props.lineItems.map((item) => { // If the item has a description, we render it as a simple text // and pass the item as values to the translation so we can use