From af03033d2e848a10d55c3959ff38f5eaab216cee Mon Sep 17 00:00:00 2001 From: Udit Takkar Date: Wed, 7 Feb 2024 18:16:15 +0530 Subject: [PATCH 1/3] fix: 2FA OTP flaky test --- apps/web/playwright/login.2fa.e2e.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/apps/web/playwright/login.2fa.e2e.ts b/apps/web/playwright/login.2fa.e2e.ts index 0864f67853014a..c88a3b37b73750 100644 --- a/apps/web/playwright/login.2fa.e2e.ts +++ b/apps/web/playwright/login.2fa.e2e.ts @@ -42,6 +42,8 @@ test.describe("2FA Tests", async () => { await fillOtp({ page, secret: "123456", noRetry: true }); await expect(page.locator('[data-testid="error-submitting-code"]')).toBeVisible(); + await removeOtpInput(page); + await fillOtp({ page, // eslint-disable-next-line @typescript-eslint/no-non-null-assertion @@ -162,6 +164,14 @@ test.describe("2FA Tests", async () => { }); }); +async function removeOtpInput(page: Page) { + await page.locator('input[name="2fa6"]').waitFor({ state: "visible", timeout: 60_000 }); + + // Remove one OTP input + await page.locator('input[name="2fa6"]').focus(); + await page.keyboard.press("Backspace"); +} + async function fillOtp({ page, secret, noRetry }: { page: Page; secret: string; noRetry?: boolean }) { let token = authenticator.generate(secret); if (!noRetry && !totpAuthenticatorCheck(token, secret)) { From 452745e541c4dd103fc78e1832f8a364a5424e91 Mon Sep 17 00:00:00 2001 From: Udit Takkar Date: Wed, 7 Feb 2024 18:36:47 +0530 Subject: [PATCH 2/3] chore: change timeout --- apps/web/playwright/login.2fa.e2e.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/web/playwright/login.2fa.e2e.ts b/apps/web/playwright/login.2fa.e2e.ts index c88a3b37b73750..4013968abf3560 100644 --- a/apps/web/playwright/login.2fa.e2e.ts +++ b/apps/web/playwright/login.2fa.e2e.ts @@ -43,6 +43,7 @@ test.describe("2FA Tests", async () => { await expect(page.locator('[data-testid="error-submitting-code"]')).toBeVisible(); await removeOtpInput(page); + await page.getByTestId("toast-success").waitFor(); await fillOtp({ page, @@ -165,7 +166,7 @@ test.describe("2FA Tests", async () => { }); async function removeOtpInput(page: Page) { - await page.locator('input[name="2fa6"]').waitFor({ state: "visible", timeout: 60_000 }); + await page.locator('input[name="2fa6"]').waitFor({ state: "visible", timeout: 30_000 }); // Remove one OTP input await page.locator('input[name="2fa6"]').focus(); From d83d10aecd0dfe8b82fcf83378922de329489e1a Mon Sep 17 00:00:00 2001 From: Udit Takkar Date: Wed, 7 Feb 2024 19:14:42 +0530 Subject: [PATCH 3/3] chore: remove --- apps/web/playwright/login.2fa.e2e.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/web/playwright/login.2fa.e2e.ts b/apps/web/playwright/login.2fa.e2e.ts index 4013968abf3560..5365aa548e64de 100644 --- a/apps/web/playwright/login.2fa.e2e.ts +++ b/apps/web/playwright/login.2fa.e2e.ts @@ -43,7 +43,6 @@ test.describe("2FA Tests", async () => { await expect(page.locator('[data-testid="error-submitting-code"]')).toBeVisible(); await removeOtpInput(page); - await page.getByTestId("toast-success").waitFor(); await fillOtp({ page,