From 2f4dd9dd2047e2f263c618f733eeef5a62571813 Mon Sep 17 00:00:00 2001 From: Vincent Date: Wed, 10 Sep 2025 22:16:46 +0200 Subject: [PATCH 1/2] Delete Mozilla account at end of functional tests --- functional-tests/tests/global-teardown.ts | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/functional-tests/tests/global-teardown.ts b/functional-tests/tests/global-teardown.ts index a61dbfd7aa0..144dcb9099b 100644 --- a/functional-tests/tests/global-teardown.ts +++ b/functional-tests/tests/global-teardown.ts @@ -29,6 +29,16 @@ async function deleteTestUserAccounts(browser: Browser) { const page = await context.newPage(); await page.goto(`${getBaseTestEnvUrl()}/user/settings/manage-account`); + + await page.getByRole("button", { name: "Open user menu" }).click(); + const manageAccountLink = page.getByRole("link", { + name: "Manage your ⁨Mozilla account⁩", + exact: false, + }); + const manageFxaAccountUrl = await manageAccountLink.getAttribute("href"); + // Close the user menu + await manageAccountLink.press("Escape"); + await page.getByRole("button", { name: "Delete account" }).click(); const deleteDialog = page.getByRole("dialog", { name: "Your ⁨Monitor⁩ account will be permanently deleted", @@ -39,11 +49,29 @@ async function deleteTestUserAccounts(browser: Browser) { await deleteButtonConfirm.click(); await page.waitForURL(`${getBaseTestEnvUrl()}/`); + await page.goto(manageFxaAccountUrl!); + await page.getByRole("link", { name: "Delete Account" }).click(); + const consequenceAcknowledgements = await page + .getByTestId("checkbox-container") + .all(); + for (const acknowledgement of consequenceAcknowledgements) { + await acknowledgement.click(); + } + await page.getByRole("button", { name: "Continue" }).click(); + + await page + .getByLabel("Enter password") + .fill(process.env.E2E_TEST_ACCOUNT_BASE_PASSWORD as string); + await page.getByRole("button", { name: "Delete" }).click(); + await context.close(); } } teardown("Delete test user accounts", async ({ browser }) => { + // Going through both the Monitor and the FxA delete flow for + // every account takes relatively long: + teardown.slow(); await deleteTestUserAccounts(browser); removeTestStorage(); }); From b89a44e566ffd7104c3a32b4b36736fe788c5d6d Mon Sep 17 00:00:00 2001 From: Vincent Date: Thu, 11 Sep 2025 15:58:01 +0200 Subject: [PATCH 2/2] Preserve traces/videos on first (failing) test run Some tests can't be retried (in this case, deleting the account at the end of a test run), so having only a trace/video of the retry is not going to be useful to debug the actual cause of the failure. --- functional-tests/playwright.config.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/functional-tests/playwright.config.ts b/functional-tests/playwright.config.ts index fad77c684ae..250a176e309 100644 --- a/functional-tests/playwright.config.ts +++ b/functional-tests/playwright.config.ts @@ -154,10 +154,10 @@ export default defineConfig({ baseURL: getBaseTestEnvUrl(), /* Automatically take screenshot only on failures */ screenshot: "only-on-failure", - /* Automatically record video only on retries */ - video: "retry-with-video", - /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ - trace: "on-first-retry", + /* Automatically record video when tests fail */ + video: "retain-on-failure", + /* Collect trace when tests fail. See https://playwright.dev/docs/trace-viewer */ + trace: "retain-on-failure", }, /* Configure projects for major browsers */ projects: [