fix(e2e): replace networkidle with domcontentloaded to fix flaky timeouts #823
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes flaky E2E test timeouts in
chat-critical.spec.tsthat were causing CI failures.Problem
The E2E tests in
chat-critical.spec.tswere failing intermittently with errors like:This was happening because
page.waitForLoadState('networkidle')can hang indefinitely if there are background requests that never settle (analytics, websockets, long-polling, etc.). This is a known issue with Playwright'snetworkidlestate.Changes
waitForLoadState('networkidle')with'domcontentloaded'in chat-critical.spec.tswaitForTimeoutafter page load to allow dynamic content to renderWhy domcontentloaded?
domcontentloadedfires when the initial HTML document has been completely loaded and parsedTesting
🤖 Generated with Claude Code
Greptile Summary
Replaced all 15 instances of
waitForLoadState('networkidle')with'domcontentloaded'+ 1000ms timeout inchat-critical.spec.tsto fix flaky E2E test timeouts.Key changes:
networkidlecan hang indefinitely on background requests (analytics, websockets, long-polling)domcontentloadedevent which fires when the HTML document is parsedConfidence Score: 5/5
Important Files Changed
waitForLoadState('networkidle')with'domcontentloaded'+ 1000ms timeout to fix flaky test timeouts. Change is consistent with existing test patterns and addresses known Playwright issue.Sequence Diagram
sequenceDiagram participant Test as E2E Test participant Browser as Playwright Browser participant Page as Chat Page participant API as Backend APIs Test->>Browser: Navigate to /chat Browser->>Page: Load HTML document Page-->>Browser: HTML parsed (domcontentloaded) Note over Browser,Page: OLD: Wait for networkidle<br/>(can hang on background requests) Note over Browser,Page: NEW: Use domcontentloaded<br/>(fires when HTML parsed) Browser->>Test: domcontentloaded event fired Test->>Test: waitForTimeout(1000ms) Note over Test: Allow time for dynamic content<br/>to render (React hydration, etc.) par Background requests (may never settle) Page->>API: Analytics requests Page->>API: WebSocket connections Page->>API: Long-polling end Test->>Page: Continue with test assertions Page-->>Test: Test assertions pass Note over Test: Tests no longer hang<br/>waiting for network idle