From e41d7b45f9a87ab8052a49cb671d3fde22579dc3 Mon Sep 17 00:00:00 2001 From: Nirmal Kumar R Date: Fri, 15 May 2026 00:18:53 +0200 Subject: [PATCH] fix(e2e): Race condition in dialog modal test (#12554) The race condition on the test is happening because, we are immediately calling `page.goto()` after the `Commit changes` button is clicked without waiting for the previous redirect to finish. This interruption leads to the error: `Error: page.goto: Target page, context or browser has been closed`. By adding the `await expect(page).toHaveURL`, Playwright waits for the redirection and verifies the URL and then finally go to the next `await page.goto()` to go to the `edit` page of the file. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/12554 Reviewed-by: Gusted --- tests/e2e/modal.test.e2e.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/e2e/modal.test.e2e.ts b/tests/e2e/modal.test.e2e.ts index 28161a2012..0f1d85455d 100644 --- a/tests/e2e/modal.test.e2e.ts +++ b/tests/e2e/modal.test.e2e.ts @@ -28,6 +28,7 @@ test('Dialog modal', async ({page}) => { await page.locator('.quick-pull-choice input[value="direct"]').click(); await page.getByRole('button', {name: 'Commit changes'}).click(); + await expect(page).toHaveURL(`/user2/repo1/src/branch/master/${filename}`); response = await page.goto(`/user2/repo1/_edit/master/${filename}`, {waitUntil: 'domcontentloaded'}); expect(response?.status()).toBe(200);