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:
onopencallback is never fired- No events are received
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
- Mock SSE via
page.route()- Does not intercept EventSource requests - Inject state via localStorage - Store doesn't use persistence middleware
- 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:
- Use Playwright MCP which may handle SSE differently
- Use the exposed
window.__onboardingStoreto inject discovery results - Add a test mode flag that bypasses SSE and uses polling or direct state injection
Files Modified
tests/onboarding-flow.spec.ts- Playwright test fileplaywright.config.ts- Playwright configurationlib/stores/onboarding-store.ts- Addedwindow.__onboardingStoreexposure
Test File Location
/tests/onboarding-flow.spec.ts
Next Steps
- Install Playwright MCP and test if it handles SSE properly
- If not, use the window-exposed store to inject mock discovery results
- Complete the full flow test: Intake → Discovery → Mapping → Cloud Access → Validation
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗