test(onboarding): force controller into phase 3 to prove reconnect card success path#1475
Closed
wpfleger96 wants to merge 1 commit into
Closed
test(onboarding): force controller into phase 3 to prove reconnect card success path#1475wpfleger96 wants to merge 1 commit into
wpfleger96 wants to merge 1 commit into
Conversation
…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>
Collaborator
Author
|
Closing per Will — the production work from #1456 is merged and this test-only follow-up is waived. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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 toe2eBridge.tsand replaces two onboarding E2E reconnect specs with three that provably exercise the phase-3 code path inOnboardingRelayConnectionErrorCard.The gap this closes: prior specs drove the state emitter to
disconnectedbefore clicking, but the mock socket remained alive (wsId !== null), soensureConnected()always fast-pathed —reconnect()returnedtrueandmarkSuccess()fired from the phase-1 click path, never from the phase-3 connection-state effect atProfileStep.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 nextconnectMockSocketcall throw before assigningwsId. Wired into the bridge reset (mockConnectFailCount = 0) and the installer block. E2E-only surface — no production code touched.desktop/tests/e2e/onboarding.spec.ts—forcePhase3(page, failCount)helper + 3 tests:Connecting(phase-3 proof, fails if phase 1 wins) → driveconnected→ assertConnected+ auto-dismissConnectedconnectedwithout clicking →hadActiveReconnectRefguard blocksmarkSuccess()(kept from previous)forcePhase3closes the mock socket, arms the fail counter, and drives the emitter todisconnected(bypassesuseRelayConnection's 2s transient-state debounce) before the click.