From 7e40cfda8bb3fe2e5010f6d4e4d8354409842394 Mon Sep 17 00:00:00 2001 From: Florian Zia Date: Tue, 3 Sep 2024 13:59:44 +0200 Subject: [PATCH] chore: Run E2E tests in parallel --- src/e2e/pages/dashBoardPage.ts | 2 +- src/e2e/specs/auth.spec.ts | 7 +- src/e2e/specs/landing.spec.ts | 14 +- src/e2e/specs/purchase.spec.ts | 361 +++++++++++++++++---------------- 4 files changed, 187 insertions(+), 197 deletions(-) diff --git a/src/e2e/pages/dashBoardPage.ts b/src/e2e/pages/dashBoardPage.ts index 262d0986fbf..ea9fc14f6eb 100644 --- a/src/e2e/pages/dashBoardPage.ts +++ b/src/e2e/pages/dashBoardPage.ts @@ -122,7 +122,7 @@ export class DashboardPage { '//a[starts-with(@class, "Shell_mozillaLink")]', ); this.allBreachesFooter = page.locator("footer a", { - hasText: "All Breaches", + hasText: "Recent data breaches", }); this.faqsFooter = page.locator("footer a", { hasText: "FAQs" }); this.termsOfServiceFooter = page.locator("footer a", { diff --git a/src/e2e/specs/auth.spec.ts b/src/e2e/specs/auth.spec.ts index 92959b012d7..ee6a098852e 100644 --- a/src/e2e/specs/auth.spec.ts +++ b/src/e2e/specs/auth.spec.ts @@ -27,11 +27,8 @@ test.describe(`${process.env.E2E_TEST_ENV} - Authentication flow verification @s await authPage.signUp(randomEmail, page); // assert successful login - const successUrl = - process.env.E2E_TEST_ENV === "local" - ? "/user/dashboard" - : "/user/welcome"; - expect(page.url()).toBe(`${process.env.E2E_TEST_BASE_URL}${successUrl}`); + const successUrl = `${process.env.E2E_TEST_BASE_URL}/user/welcome`; + expect(page.url()).toBe(successUrl); await testInfo.attach( `${process.env.E2E_TEST_ENV}-signup-monitor-dashboard.png`, diff --git a/src/e2e/specs/landing.spec.ts b/src/e2e/specs/landing.spec.ts index bd453cc7f46..2127ec3a4db 100644 --- a/src/e2e/specs/landing.spec.ts +++ b/src/e2e/specs/landing.spec.ts @@ -348,11 +348,7 @@ test.describe(`${process.env.E2E_TEST_ENV} - Verify the Landing Page Functionali await authPage.enterPassword(); // verify dashboard redirect - const successUrl = - process.env.E2E_TEST_BASE_URL + - (process.env.E2E_TEST_ENV === "local" - ? "/user/welcome" - : "/user/dashboard"); + const successUrl = `${process.env.E2E_TEST_BASE_URL}/user/dashboard`; expect(page.url()).toBe(successUrl); }); @@ -373,13 +369,7 @@ test.describe(`${process.env.E2E_TEST_ENV} - Verify the Landing Page Functionali await authPage.enterPassword(); // verify dashboard redirect - const successUrl = - process.env.E2E_TEST_BASE_URL + - `${ - process.env.E2E_TEST_ENV === "local" - ? "/user/welcome" - : "/user/dashboard" - }`; + const successUrl = `${process.env.E2E_TEST_BASE_URL}/user/dashboard`; expect(page.url()).toBe(successUrl); }); }); diff --git a/src/e2e/specs/purchase.spec.ts b/src/e2e/specs/purchase.spec.ts index d95242622c8..064d8e2c992 100644 --- a/src/e2e/specs/purchase.spec.ts +++ b/src/e2e/specs/purchase.spec.ts @@ -5,197 +5,200 @@ import { test, expect } from "../fixtures/basePage.js"; import { checkAuthState, setEnvVariables } from "../utils/helpers.js"; -test.describe(`${process.env.E2E_TEST_ENV} - Breach Scan, Monitor Plus Purchase Flow`, () => { - test.beforeEach(async ({ page, authPage, landingPage, welcomePage }) => { - test.info().annotations.push({ - type: "testrail id", - description: - "https://testrail.stage.mozaws.net/index.php?/cases/view/2463564", - }); +test.describe.skip( + `${process.env.E2E_TEST_ENV} - Breach Scan, Monitor Plus Purchase Flow`, + () => { + test.beforeEach(async ({ page, authPage, landingPage, welcomePage }) => { + test.info().annotations.push({ + type: "testrail id", + description: + "https://testrail.stage.mozaws.net/index.php?/cases/view/2463564", + }); + + test.slow( + true, + "this test runs through the welcome scan flow, increasing timeout to address it", + ); - test.slow( - true, - "this test runs through the welcome scan flow, increasing timeout to address it", - ); + setEnvVariables(process.env.E2E_TEST_ACCOUNT_EMAIL as string); - setEnvVariables(process.env.E2E_TEST_ACCOUNT_EMAIL as string); + // speed up test by ignoring non necessary requests + await page.route(/(analytics)/, async (route) => { + await route.abort(); + }); - // speed up test by ignoring non necessary requests - await page.route(/(analytics)/, async (route) => { - await route.abort(); - }); + // start authentication flow + await landingPage.open(); + await landingPage.goToSignIn(); + + // Fill out sign up form + const randomEmail = `_${Date.now()}@restmail.net`; + await authPage.signUp(randomEmail, page); - // start authentication flow - await landingPage.open(); - await landingPage.goToSignIn(); - - // Fill out sign up form - const randomEmail = `_${Date.now()}@restmail.net`; - await authPage.signUp(randomEmail, page); - - // wait for welcome page - await page.waitForURL("**/user/welcome"); - await welcomePage.goThroughFirstScan(); - expect(page.url()).toContain("/user/dashboard"); - }); - - test("Verify that the user can purchase the plus subscription with a Stripe card - Yearly", async ({ - dashboardPage, - purchasePage, - page, - }) => { - test.skip( - process.env.E2E_TEST_ENV === "production", - "payment method test not available in production", - ); - // link to testrail case - test.info().annotations.push({ - type: "testrail", - description: - "https://testrail.stage.mozaws.net/index.php?/cases/view/2463627", + // wait for welcome page + await page.waitForURL("**/user/welcome"); + await welcomePage.goThroughFirstScan(); + expect(page.url()).toContain("/user/dashboard"); }); - try { - await checkAuthState(page); - } catch { - console.log( - "[E2E_LOG] - No fxa auth required, proceeding... with stripe yearly", + test("Verify that the user can purchase the plus subscription with a Stripe card - Yearly", async ({ + dashboardPage, + purchasePage, + page, + }) => { + test.skip( + process.env.E2E_TEST_ENV === "production", + "payment method test not available in production", ); - } - - // navigate to subscription - await dashboardPage.open(); - await dashboardPage.subscribeButton.click(); - await dashboardPage.subscribeDialogSelectYearlyPlanLink.click(); - await purchasePage.subscriptionHeader.waitFor(); - - // fill out subscription payment - await purchasePage.authorizationCheckbox.check(); - await purchasePage.fillOutStripeCardInfo(); - await purchasePage.payNowButton.click({ force: true }); - await page.getByText("Subscription confirmation").waitFor(); - // navigate to confirmation - await purchasePage.getStartedButton.click(); - await purchasePage.goToNextStep.waitFor(); - await purchasePage.goToNextStep.click(); - - // confirm successful payment - await dashboardPage.plusSubscription.waitFor(); - await expect(dashboardPage.plusSubscription).toBeVisible(); - }); - - test("Verify that the user can purchase the plus subscription with a Stripe card - Monthly", async ({ - purchasePage, - dashboardPage, - page, - }) => { - test.skip( - process.env.E2E_TEST_ENV === "production", - "payment method test not available in production", - ); - // link to multiple testrail cases - test.info().annotations.push({ - type: "testrail", - description: - "https://testrail.stage.mozaws.net/index.php?/cases/view/2463627", + // link to testrail case + test.info().annotations.push({ + type: "testrail", + description: + "https://testrail.stage.mozaws.net/index.php?/cases/view/2463627", + }); + + try { + await checkAuthState(page); + } catch { + console.log( + "[E2E_LOG] - No fxa auth required, proceeding... with stripe yearly", + ); + } + + // navigate to subscription + await dashboardPage.open(); + await dashboardPage.subscribeButton.click(); + await dashboardPage.subscribeDialogSelectYearlyPlanLink.click(); + await purchasePage.subscriptionHeader.waitFor(); + + // fill out subscription payment + await purchasePage.authorizationCheckbox.check(); + await purchasePage.fillOutStripeCardInfo(); + await purchasePage.payNowButton.click({ force: true }); + await page.getByText("Subscription confirmation").waitFor(); + // navigate to confirmation + await purchasePage.getStartedButton.click(); + await purchasePage.goToNextStep.waitFor(); + await purchasePage.goToNextStep.click(); + + // confirm successful payment + await dashboardPage.plusSubscription.waitFor(); + await expect(dashboardPage.plusSubscription).toBeVisible(); }); - test.info().annotations.push({ - type: "testrail", - description: - "https://testrail.stage.mozaws.net/index.php?/cases/view/2301529", + test("Verify that the user can purchase the plus subscription with a Stripe card - Monthly", async ({ + purchasePage, + dashboardPage, + page, + }) => { + test.skip( + process.env.E2E_TEST_ENV === "production", + "payment method test not available in production", + ); + // link to multiple testrail cases + test.info().annotations.push({ + type: "testrail", + description: + "https://testrail.stage.mozaws.net/index.php?/cases/view/2463627", + }); + + test.info().annotations.push({ + type: "testrail", + description: + "https://testrail.stage.mozaws.net/index.php?/cases/view/2301529", + }); + + try { + await checkAuthState(page); + } catch { + console.log( + "[E2E_LOG] - No fxa auth required, proceeding... with stripe monthly", + ); + } + + // navigate to subscription + await dashboardPage.open(); + await dashboardPage.subscribeButton.click(); + + // verify user purchase choices + await expect(dashboardPage.subscribeDialogCloseButton).toBeVisible(); + await expect(dashboardPage.yearlyMonthlyTablist).toBeVisible(); + await dashboardPage.yearlyTab.click(); + await expect( + dashboardPage.subscribeDialogSelectYearlyPlanLink, + ).toBeVisible(); + + await dashboardPage.monthlyTab.click(); + await expect( + dashboardPage.subscribeDialogSelectMonthlyPlanLink, + ).toBeVisible(); + + await dashboardPage.monthlyTab.click(); + await dashboardPage.subscribeDialogSelectMonthlyPlanLink.click(); + await purchasePage.subscriptionHeader.waitFor(); + + // fill out subscription payment + await purchasePage.authorizationCheckbox.waitFor(); + await purchasePage.authorizationCheckbox.check(); + await purchasePage.fillOutStripeCardInfo(); + await purchasePage.payNowButton.click({ force: true }); + await page.getByText("Subscription confirmation").waitFor(); + // navigate to confirmation + await purchasePage.getStartedButton.click(); + await purchasePage.goToNextStep.click(); + + // confirm successful payment + await dashboardPage.plusSubscription.waitFor({ + state: "attached", + timeout: 5000, + }); + await expect(dashboardPage.plusSubscription).toBeVisible(); }); - try { - await checkAuthState(page); - } catch { - console.log( - "[E2E_LOG] - No fxa auth required, proceeding... with stripe monthly", + test("Verify that the user can purchase the plus subscription with a PayPal account - yearly", async ({ + purchasePage, + dashboardPage, + context, + }) => { + test.skip( + process.env.E2E_TEST_ENV === "production", + "payment method test not available in production", ); - } - - // navigate to subscription - await dashboardPage.open(); - await dashboardPage.subscribeButton.click(); - - // verify user purchase choices - await expect(dashboardPage.subscribeDialogCloseButton).toBeVisible(); - await expect(dashboardPage.yearlyMonthlyTablist).toBeVisible(); - await dashboardPage.yearlyTab.click(); - await expect( - dashboardPage.subscribeDialogSelectYearlyPlanLink, - ).toBeVisible(); - - await dashboardPage.monthlyTab.click(); - await expect( - dashboardPage.subscribeDialogSelectMonthlyPlanLink, - ).toBeVisible(); - - await dashboardPage.monthlyTab.click(); - await dashboardPage.subscribeDialogSelectMonthlyPlanLink.click(); - await purchasePage.subscriptionHeader.waitFor(); - - // fill out subscription payment - await purchasePage.authorizationCheckbox.waitFor(); - await purchasePage.authorizationCheckbox.check(); - await purchasePage.fillOutStripeCardInfo(); - await purchasePage.payNowButton.click({ force: true }); - await page.getByText("Subscription confirmation").waitFor(); - // navigate to confirmation - await purchasePage.getStartedButton.click(); - await purchasePage.goToNextStep.click(); - - // confirm successful payment - await dashboardPage.plusSubscription.waitFor({ - state: "attached", - timeout: 5000, - }); - await expect(dashboardPage.plusSubscription).toBeVisible(); - }); - - test("Verify that the user can purchase the plus subscription with a PayPal account - yearly", async ({ - purchasePage, - dashboardPage, - context, - }) => { - test.skip( - process.env.E2E_TEST_ENV === "production", - "payment method test not available in production", - ); - // link to testrail case - test.info().annotations.push({ - type: "testrail", - description: - "https://testrail.stage.mozaws.net/index.php?/cases/view/2463628", + // link to testrail case + test.info().annotations.push({ + type: "testrail", + description: + "https://testrail.stage.mozaws.net/index.php?/cases/view/2463628", + }); + + await purchasePage.gotoPurchaseFromDashboard(dashboardPage, true); + // fill out subscription payment + await purchasePage.authorizationCheckbox.check(); + await purchasePage.fillOutPaypalInfo(context); + await purchasePage.postPaymentPageCheck(dashboardPage); }); - await purchasePage.gotoPurchaseFromDashboard(dashboardPage, true); - // fill out subscription payment - await purchasePage.authorizationCheckbox.check(); - await purchasePage.fillOutPaypalInfo(context); - await purchasePage.postPaymentPageCheck(dashboardPage); - }); - - test("Verify that the user can purchase the plus subscription with a PayPal account - monthly", async ({ - purchasePage, - dashboardPage, - context, - }) => { - test.skip( - process.env.E2E_TEST_ENV === "production", - "payment method test not available in production", - ); - // link to testrail case - test.info().annotations.push({ - type: "testrail", - description: - "https://testrail.stage.mozaws.net/index.php?/cases/view/2463628", + test("Verify that the user can purchase the plus subscription with a PayPal account - monthly", async ({ + purchasePage, + dashboardPage, + context, + }) => { + test.skip( + process.env.E2E_TEST_ENV === "production", + "payment method test not available in production", + ); + // link to testrail case + test.info().annotations.push({ + type: "testrail", + description: + "https://testrail.stage.mozaws.net/index.php?/cases/view/2463628", + }); + + await purchasePage.gotoPurchaseFromDashboard(dashboardPage, false); + // fill out subscription payment + await purchasePage.authorizationCheckbox.check(); + await purchasePage.fillOutPaypalInfo(context); + await purchasePage.postPaymentPageCheck(dashboardPage); }); - - await purchasePage.gotoPurchaseFromDashboard(dashboardPage, false); - // fill out subscription payment - await purchasePage.authorizationCheckbox.check(); - await purchasePage.fillOutPaypalInfo(context); - await purchasePage.postPaymentPageCheck(dashboardPage); - }); -}); + }, +);