Repository navigation
Keep the UI tests off the real WebSocket - #56
Merged
Merged
Conversation
useSocket() is a page-wide singleton that reconnects forever, and many component tests open it without asking: useAdminStore() subscribes to the config channel and useHealth() to the health one. Under jsdom that dialled ws://localhost:3000/ws, was refused, and armed a retry timer the test never knew about. One CI run on main saw that timer fire after marketplace-modal.test.ts's environment was torn down, with `location` gone, and fail the job with an unhandled ReferenceError although every test had passed. Each close also sent the session check through whatever fetch the test had stubbed. Fourteen jsdom test files reached the real socket this way, so the fix is one setup file rather than a vi.mock in each: a WebSocket that stays connecting, never opens and never closes, so the reconnect loop never starts. The two tests that drive the wire still stub their own with vi.stubGlobal, and vi.unstubAllGlobals() brings the silent one back. useSocket() itself is left as it is: it belongs to the page, not to a component scope, so there is no owner whose disposal should stop it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Deploying fremkit with
|
| Latest commit: |
074c795
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://0a814b14.fremkit.pages.dev |
| Branch Preview URL: | https://hotfix-flaky-socket-timer.fremkit.pages.dev |
fdussert
added a commit
that referenced
this pull request
Nov 18, 2026
The kiosk window becomes a non-activating panel that never turns key, so a tap on the Edge no longer takes the keyboard (or the ⌘Tab switcher) away from the app on the primary display. Tested on a real Edge with real touches. The merge also brings origin/main's #55 (clipboard one-time codes, private pasteboard markers) and #56 (UI tests off the real WebSocket), which local main did not have yet; CHANGELOG entries from both sides are kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
CI on main (19ed0ba) failed once on
ReferenceError: location is not definedatui/src/shared/socket.ts:50, reported as an unhandled error fromtest/marketplace-modal.test.ts, then passed on rerun.Cause.
useSocket()is a page-wide singleton that reconnects forever. Component tests open it without meaning to:useAdminStore()subscribes toconfig, anduseHealth()(throughHealthMenuinTopBar) subscribes to the health channel. Under jsdom the socket dialsws://localhost:3000/ws, is refused, and armssetTimeout(connect, 500). That timer can outlive the test environment and fire oncelocationis gone. Each close also sent the session check through whateverfetchthe test had stubbed. Fourteen jsdom test files reached the real socket this way.Fix.
ui/test/setup.ts, loaded throughsetupFiles, installs aWebSocketthat stays connecting: it never opens and never closes, so the reconnect loop never starts. The two tests that drive the wire (socket-cache-invalidation,socket-remote-session) still stub their own withvi.stubGlobal, andvi.unstubAllGlobals()restores the silent one.useSocket()is unchanged. It belongs to the page, not to a component scope, so there is no owner whose disposal should stop it.Verification.
connect()/onclosetemporarily instrumented over the whole UI suite: before, about 25 real sockets were opened and refused, each arming a retry; after, none (21 silent, 4 test-owned fakes).pnpm typecheckandpnpm testare green (ui 874/874, server 2679 passed, 2 skipped).No user-visible change, so no changelog line.
🤖 Generated with Claude Code