Skip to content

Conversation

@vdimarco
Copy link
Contributor

@vdimarco vdimarco commented Jan 17, 2026

Summary

Fixes flaky E2E test timeouts in chat-critical.spec.ts that were causing CI failures.

Problem

The E2E tests in chat-critical.spec.ts were failing intermittently with errors like:

Error: page.waitForLoadState: Test timeout of 60000ms exceeded.

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's networkidle state.

Changes

  • Replaced all 15 instances of waitForLoadState('networkidle') with 'domcontentloaded' in chat-critical.spec.ts
  • Added a 1000ms waitForTimeout after page load to allow dynamic content to render
  • Added comments explaining the fix for future maintainers

Why domcontentloaded?

  • domcontentloaded fires when the initial HTML document has been completely loaded and parsed
  • It doesn't wait for stylesheets, images, or subframes to finish loading
  • Combined with a short timeout for dynamic content, this provides a reliable and fast test experience
  • This pattern is already used successfully in other tests in this file (e.g., 'chat page loads within reasonable time')

Testing

  • ✅ TypeScript compilation passes
  • ✅ ESLint passes
  • Tests expected to pass in CI (the failing tests were previously using networkidle)

🤖 Generated with Claude Code

Greptile Summary

Replaced all 15 instances of waitForLoadState('networkidle') with 'domcontentloaded' + 1000ms timeout in chat-critical.spec.ts to fix flaky E2E test timeouts.

Key changes:

  • Addresses known Playwright issue where networkidle can hang indefinitely on background requests (analytics, websockets, long-polling)
  • Uses the more reliable domcontentloaded event which fires when the HTML document is parsed
  • Adds a consistent 1000ms timeout after page load to allow dynamic content rendering
  • Includes clear comments explaining the fix for future maintainers
  • Pattern already exists successfully in the same file (line 44: 'chat page loads within reasonable time')
  • Mechanically correct: all 15 replacements are identical in structure

Confidence Score: 5/5

  • This PR is safe to merge with no risk
  • The change addresses a well-documented Playwright issue (networkidle can hang indefinitely on background requests) with a proven solution (domcontentloaded + fixed timeout). The pattern already exists in the same test file ('chat page loads within reasonable time' test at line 44) and across other E2E test files. All 15 replacements are identical, mechanically correct, and include helpful comments explaining the fix for future maintainers.
  • No files require special attention

Important Files Changed

Filename Overview
e2e/chat-critical.spec.ts Replaced 15 instances of 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
Loading

…outs

The E2E tests in chat-critical.spec.ts were failing intermittently due to
page.waitForLoadState('networkidle') timing out in CI environments. This
is a known Playwright issue where networkidle can hang if there are
background requests that never settle.

Changes:
- Replaced all waitForLoadState('networkidle') calls with 'domcontentloaded'
- Added 1000ms waitForTimeout after page load to allow dynamic content to render
- Added comments explaining the fix for future maintainers

This follows the same pattern already used in other tests (e.g.,
'chat page loads within reasonable time') that were previously fixed.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Jan 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
gatewayz-frontend Error Error Jan 17, 2026 8:36pm

@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants