E2E Test: EventSource SSE not working in Playwright for onboarding flow

Resolved 💬 2 comments Opened Jan 23, 2026 by talatiamops Closed Feb 28, 2026

Summary

When testing the full onboarding flow with Playwright, EventSource connections to the SSE discovery endpoint (/api/discovery/progress) do not receive events, causing the discovery step to hang at 0% progress.

Environment

  • Playwright: @playwright/test (latest)
  • Next.js: 16.x
  • Browser: Chromium

Problem

The discovery page uses Server-Sent Events (SSE) via EventSource to receive real-time progress updates. While the SSE endpoint works correctly when tested with curl:

curl -s -N "http://localhost:3000/api/discovery/progress?url=https://example.com"
# Returns proper SSE events

In Playwright, the EventSource connection is created but:

  1. onopen callback is never fired
  2. No events are received
  3. page.route() does not intercept EventSource requests (only XHR/fetch)

Console Logs from Test

[Discovery Hook] Creating EventSource connection to: /api/discovery/progress?url=...
[Discovery Page] useEffect check: {isRunning: true, isCompleted: false}
# No "EventSource connection opened" log ever appears

Attempted Solutions

  1. Mock SSE via page.route() - Does not intercept EventSource requests
  2. Inject state via localStorage - Store doesn't use persistence middleware
  3. Expose Zustand store to window - Partially implemented in lib/stores/onboarding-store.ts

Workaround Needed

To properly test the onboarding flow, one of these approaches should work:

  1. Use Playwright MCP which may handle SSE differently
  2. Use the exposed window.__onboardingStore to inject discovery results
  3. Add a test mode flag that bypasses SSE and uses polling or direct state injection

Files Modified

  • tests/onboarding-flow.spec.ts - Playwright test file
  • playwright.config.ts - Playwright configuration
  • lib/stores/onboarding-store.ts - Added window.__onboardingStore exposure

Test File Location

/tests/onboarding-flow.spec.ts

Next Steps

  1. Install Playwright MCP and test if it handles SSE properly
  2. If not, use the window-exposed store to inject mock discovery results
  3. Complete the full flow test: Intake → Discovery → Mapping → Cloud Access → Validation

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗