From 0277e3ebaa52783249f9a8d800c3c06807d834a8 Mon Sep 17 00:00:00 2001 From: silverwind Date: Fri, 24 Apr 2026 17:37:01 +0200 Subject: [PATCH] Stabilize e2e logout propagation test (#37403) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `events › logout propagation` e2e test ([example flake](https://github.com/go-gitea/gitea/actions/runs/24878089698/job/72839454932)) was racing the SSE connection setup: if page2's SharedWorker had not finished registering its messenger by the time page1 triggered logout, the event was silently dropped and page2 stayed on the authenticated page. Wait 500ms after verifying page2 is signed in, before triggering the logout from page1, so the SharedWorker has time to register. Comment points at a cleaner future fix (expose a ready attribute on the page) that will also work for the planned WebSocket SharedWorker. --- This PR was written with the help of Claude Opus 4.7 --------- Signed-off-by: wxiaoguang Co-authored-by: Claude (Opus 4.7) Co-authored-by: wxiaoguang --- tests/e2e/events.test.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/e2e/events.test.ts b/tests/e2e/events.test.ts index d033c7b94f3..4c1c525cf54 100644 --- a/tests/e2e/events.test.ts +++ b/tests/e2e/events.test.ts @@ -66,6 +66,13 @@ test.describe('events', () => { // Verify page2 is logged in await expect(page2.getByRole('link', {name: 'Sign In'})).toBeHidden(); + // Give page2's SharedWorker time to register its SSE connection on the + // server — otherwise the logout event can race the connection and be + // silently dropped. See https://github.com/go-gitea/gitea/pull/37403 + // In the future, we can set an attribute to HTML page when the connection is established, + // then here we can just wait for that attribute (it should also work for the planned WebSocket SharedWorker) + await page2.waitForTimeout(500); // eslint-disable-line playwright/no-wait-for-timeout + // Logout from page1 — this sends a logout event to all tabs await page1.goto('/user/logout');