From a80f8f9d01a20cd719cedb7c21ee82cc6b000efd Mon Sep 17 00:00:00 2001 From: Mathieu Fenniak Date: Mon, 13 Oct 2025 01:01:42 +0200 Subject: [PATCH] chore(e2e): test flakiness in webauthn.test.e2e.ts (#9662) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test failure: ``` 1) [chromium] › tests/e2e/webauthn.test.e2e.ts:14:1 › WebAuthn register & login flow ───────────── Error: page.goto: Navigation to "http://localhost:3003/user/login" is interrupted by another navigation to "http://localhost:3003/" Call log: - navigating to "http://localhost:3003/user/login", waiting until "load" 46 | 47 | // Login. > 48 | response = await page.goto('/user/login'); | ^ 49 | expect(response?.status()).toBe(200); 50 | 51 | await page.getByLabel('Username or email address').fill(username); at /workspace/forgejo/forgejo/tests/e2e/webauthn.test.e2e.ts:48:25 ``` I have not been able to reproduce this locally. What seems to be happening is that the current code is clicking the "Sign out" menu option, and then while the browser is busy (navigating to `/logout`, redirecting to `/`), the test attempts to navigate directly to `/user/login`. The two navigations are racey, depending on how fast they work they may result in this error. The proposed fix is to wait for the sign-out operation to complete by waiting for the URL to land on `/`, before then proceeding with the rest of the test with the second login. Normally this would be *just* a `waitForURL` call. But because of the redirect on logout, I've encountered the below error if the code is just invoking `waitForURL`. So I put the `waitForURL` invocation into an `expect(...).toPass()`. This isn't technically the correct usage of `toPass` which is intended for *assertions* which will eventually become successful, whereas this is attempting to retry a wait... but... a wait shouldn't need a retry. (I'd argue this is a Playwright bug.) ``` Error: page.waitForURL: net::ERR_ABORTED; maybe frame was detached? ``` Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9662 Reviewed-by: Otto Co-authored-by: Mathieu Fenniak Co-committed-by: Mathieu Fenniak --- tests/e2e/webauthn.test.e2e.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/e2e/webauthn.test.e2e.ts b/tests/e2e/webauthn.test.e2e.ts index 1e83c409dc..e66d1e2bb4 100644 --- a/tests/e2e/webauthn.test.e2e.ts +++ b/tests/e2e/webauthn.test.e2e.ts @@ -39,9 +39,10 @@ test('WebAuthn register & login flow', async ({browser, request}, workerInfo) => await page.getByText('Add security key').click(); // Logout. + await page.locator('div[aria-label="Profile and settings…"]').click(); + await page.getByText('Sign out').click(); await expect(async () => { - await page.locator('div[aria-label="Profile and settings…"]').click(); - await page.getByText('Sign out').click(); + await page.waitForURL(`${workerInfo.project.use.baseURL}/`); }).toPass(); // Login.