Skip to content

test(onboarding): force controller into phase 3 to prove reconnect card success path#1475

Closed
wpfleger96 wants to merge 1 commit into
mainfrom
duncan/onboarding-phase3-e2e
Closed

test(onboarding): force controller into phase 3 to prove reconnect card success path#1475
wpfleger96 wants to merge 1 commit into
mainfrom
duncan/onboarding-phase3-e2e

Conversation

@wpfleger96

@wpfleger96 wpfleger96 commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Follow-up to #1456: the final E2E test commit on that branch missed the squash merge, so main carries onboarding reconnect specs that can pass via the phase-1 fast path. This PR cherry-picks that commit onto main.

What

Adds a __BUZZ_E2E_FAIL_NEXT_MOCK_CONNECT__ seam to e2eBridge.ts and replaces two onboarding E2E reconnect specs with three that provably exercise the phase-3 code path in OnboardingRelayConnectionErrorCard.

The gap this closes: prior specs drove the state emitter to disconnected before clicking, but the mock socket remained alive (wsId !== null), so ensureConnected() always fast-pathed — reconnect() returned true and markSuccess() fired from the phase-1 click path, never from the phase-3 connection-state effect at ProfileStep.tsx:89-94. The tests passed while the phase-3 contract went untested.

Changes (2 files)

desktop/src/testing/e2eBridge.ts — new __BUZZ_E2E_FAIL_NEXT_MOCK_CONNECT__ seam: arms a counter making the next connectMockSocket call throw before assigning wsId. Wired into the bridge reset (mockConnectFailCount = 0) and the installer block. E2E-only surface — no production code touched.

desktop/tests/e2e/onboarding.spec.tsforcePhase3(page, failCount) helper + 3 tests:

  • Phase-3 positive — click → assert Connecting (phase-3 proof, fails if phase 1 wins) → drive connected → assert Connected + auto-dismiss
  • Phase-3 negative — same setup with 5 fail slots → hold disconnected → assert no Connected
  • No-click negative — drive connected without clicking → hadActiveReconnectRef guard blocks markSuccess() (kept from previous)

forcePhase3 closes the mock socket, arms the fail counter, and drives the emitter to disconnected (bypasses useRelayConnection's 2s transient-state debounce) before the click.

…rd success path

Previous E2E tests used setRelayConnectionState() before the click but left
the mock socket alive (wsId !== null), so ensureConnected() always fast-pathed
and reconnect() returned true — the phase-3 connection-state effect in
ProfileStep.tsx was never exercised.

Add __BUZZ_E2E_FAIL_NEXT_MOCK_CONNECT__ seam to e2eBridge.ts: arms a counter
that makes the next connectMockSocket call throw before assigning wsId. This
forces connect() to reject, withDeadline to race-reject, the fast-path catch
to fire, and the controller to enter phase 3.

forcePhase3() helper:
- Arms the fail counter N times
- Closes all live sockets (disconnectMockSocket, sets wsId=null)
- Drives emitter to 'disconnected' immediately so useRelayConnection()
  commits a non-connected state (bypasses the 2s debounce on transient
  states); without this the hook never transitions away from 'connected'
  and the ProfileStep effect doesn't re-fire when we later drive success

Tests (3 total):
1. Phase-3 positive: click -> assert 'Connecting' (phase-3 proof) ->
   drive connected -> assert 'Connected' + auto-dismiss
2. Phase-3 negative: click -> assert 'Connecting' -> hold disconnected ->
   assert no 'Connected' (5 fail slots block retries for 15+ seconds)
3. No-click negative: drive connected without clicking -> assert
   hadActiveReconnectRef guard blocks markSuccess() (unchanged)

Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
@wpfleger96

Copy link
Copy Markdown
Collaborator Author

Closing per Will — the production work from #1456 is merged and this test-only follow-up is waived.

@wpfleger96 wpfleger96 closed this Jul 2, 2026
@wpfleger96 wpfleger96 deleted the duncan/onboarding-phase3-e2e branch July 2, 2026 20:02
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.

1 participant