mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
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>