diff --git a/tests/e2e/events.test.ts b/tests/e2e/events.test.ts index d033c7b94f320..4c1c525cf54e9 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');