11import { expect , type Page , test } from "@playwright/test" ;
22
33// WebSocket tests need more headroom than basic tests because Firefox's WS
4- // handshake can occasionally hang (~20s browser timeout + 1s reconnect delay).
5- // 45s gives enough room for one reconnect cycle within a single test.
6- test . setTimeout ( 45_000 ) ;
4+ // handshake can occasionally hang (~20s browser timeout + reconnect delay).
5+ // 30s gives enough room for multiple reconnect cycles (2s timeout + 0.25–5s
6+ // backoff each) within a single test.
7+ test . setTimeout ( 30_000 ) ;
78
89/**
910 * WebSocket & Collab E2E tests for the id web UI.
@@ -98,12 +99,12 @@ async function createFileWithUniqueContent(page: Page, name: string, baseURL: st
9899 expect ( saveResp . ok ( ) ) . toBeTruthy ( ) ;
99100
100101 // Navigate directly to file — tests that direct URL access works (bookmarks,
101- // link sharing, page refresh). The 5s connect timeout in collab.ts handles
102+ // link sharing, page refresh). The 2s connect timeout in collab.ts handles
102103 // any WS init race on full page load.
103104 //
104105 // NOTE: Do NOT use waitForLoadState("networkidle") here. The WS upgrade
105106 // request counts as a pending connection; if Firefox's handshake hangs,
106- // the 5s connect timeout fires → scheduleReconnect → new pending request,
107+ // the 2s connect timeout fires → scheduleReconnect → new pending request,
107108 // resetting networkidle's 500ms idle counter. This loop eats 30s+ of test
108109 // budget before networkidle gives up. waitForEditorReady() handles all the
109110 // real waiting by polling JS/DOM state directly.
@@ -119,11 +120,10 @@ test.describe("WebSocket Connection + Editor Ready", () => {
119120 test ( "editor status shows connected after WS handshake" , async ( { page, baseURL } ) => {
120121 // This is the first WS test in the full suite (~test #129). In Firefox,
121122 // the browser process accumulates state from ~128 prior tests that can
122- // cause the first WS upgrade request to hang in CONNECTING state. The 5s
123- // connect timeout + reconnect mechanism in collab.ts handles recovery,
124- // but may need multiple cycles. Mark slow (3x timeout = 135s) to allow
125- // up to ~5 reconnect attempts without timing out.
126- test . slow ( ) ;
123+ // cause the first WS upgrade request to hang in CONNECTING state. The 2s
124+ // connect timeout + fast reconnect (250ms base backoff) in collab.ts
125+ // recovers in ~2.5s per attempt, so default 20s waitForEditorReady
126+ // easily handles 5+ reconnect cycles without needing test.slow().
127127
128128 const fileName = `ws-connect-${ Date . now ( ) } .txt` ;
129129
@@ -138,10 +138,8 @@ test.describe("WebSocket Connection + Editor Ready", () => {
138138 // Use unique content to avoid shared collab document under Firefox load
139139 await createFileWithUniqueContent ( page , fileName , baseURL ! ) ;
140140
141- // Wait for editor to be fully ready — generous timeout for first WS
142- // connection which may need multiple reconnect cycles in Firefox.
143- // 5s connect timeout + 1-8s backoff per attempt × up to 5 attempts ≈ 55s
144- await waitForEditorReady ( page , 60_000 ) ;
141+ // Wait for editor to be fully ready
142+ await waitForEditorReady ( page ) ;
145143
146144 // Verify WebSocket is connected
147145 const wsConnected = await page . evaluate ( ( ) => {
0 commit comments