Repository navigation
fix(ui): prevent mock Gateway tests from leaking into routing tests - #131052
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
Dependency GuardThis PR changes dependency-related files. Maintainers should confirm these changes are intentional. Changed files:
Maintainer follow-up:
|
Dependency graph changes notedThis PR includes dependency graph changes. The dependency guard is informational because the PR author is a repository admin, a member of
Security review is still recommended before merge when the dependency graph change is intentional. |
|
Codex review: needs maintainer review before merge. Reviewed August 27, 2026, 2:13 PM ET / 18:13 UTC. ClawSweeper reviewWhat this changesThe PR runs serialized mock-Gateway tests in a fresh JSDOM page realm per test and closes that realm to prevent globals, storage, listeners, and queued work from leaking into routing tests. Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readinessNo blocking correctness finding. This focused test-isolation repair targets the fixture that writes the shared base-path global; keep the maintainer-owned PR open until its remaining exact-head CI completes. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherControl UI test helpers serialize a mock Gateway script into a browser-like page, where it installs WebSocket behavior and a base-path override. Routing reads that override when choosing resource paths, so the fixture’s page lifetime must end before later tests use Vitest’s shared browser realm. flowchart LR
A[Mock Gateway init script] --> B[JSDOM page realm]
B --> C[Page globals and storage]
C --> D[Mock Gateway tests]
B --> E[Fixture teardown]
E --> F[Shared routing-test realm remains clean]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +30, Tests +47, Config +1, Other +23. Total +101 across 6 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain one fixture-owned JSDOM realm per serialized mock-Gateway test, always close it, and merge after the exact-head CI result confirms the supplied focused regression coverage. Do we have a high-confidence way to reproduce the issue? Yes, at source level: the old tests execute the initializer in Vitest’s shared window, and that initializer writes the value routing reads. The checkout has no node_modules, so this review did not independently rerun the ordered failure. Is this the best way to solve the issue? Yes. Isolating and closing the page realm repairs the lifecycle owner directly; routing-side cleanup would leave other fixture-installed globals, listeners, timers, and storage vulnerable to leakage. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 5890806fbe56. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
…penclaw#131052) * test(ui): isolate serialized mock gateway page lifetimes * test(ui): satisfy fixture lifecycle lint contracts * test(ui): name fixture scripts without lint suppression
What Problem This Solves
Resolves a problem where Control UI routing tests fail depending on which mock-Gateway tests ran first. Running the serialized deferral tests before the browser routing tests on current main reliably leaves an empty base-path override behind, causing the two routing tests to return the wrong path.
Why This Change Was Made
The serialized Gateway fixture installs browser globals, listeners, storage, and timers. Restoring only WebSocket or clearing storage cannot retire that page lifetime. Both serialized transport suites now execute the unchanged initialization script in a fresh JSDOM VM realm supplied by a shared Vitest fixture. A finally block closes that realm, including on assertion failure. Per-test partial cleanup and implied-eval suppressions are removed.
Production routing, the shared Vitest isolation setting, ordinary socket disconnect semantics, and Vite passthrough are unchanged. The fix uses the existing jsdom dependency and its documented outside-only VM/close lifecycle, rather than introducing a production teardown API or compensating in routing consumers. It adds pinned dev-only
@types/jsdomdeclarations; no runtime dependency changes.User Impact
No user-visible product change. Developers get order-independent Control UI checks and deterministic retirement of queued mock-Gateway work. No changelog or screenshots are applicable to this test-only repair.
Evidence
aa0647d06d27e1a9abd0a607abfc3c85649f710d, the original single-worker order (deferral suite, then browser routing suite) reproduces two routing failures; the deferral tests themselves pass.4689d81a2947e01174f58232837bb53cd11c1dcbis green: run 33099198074, attempt 2. Both initially failed jobs passed the single failed-jobs retry on the unchanged head. Build, including the unchanged startup-memory gate, passed; the requiredopenclaw/ci-gatesucceeded. No threshold, assertion, or test environment was weakened.Named follow-up — Gateway place-label ownership, now repaired separately in draft #131118: the failed browser shard reported
Gateway · localinstead of the advertised machine name. All affected product, existing E2E, and browser-fixture paths are byte-identical to this PR's baseline, and this new JSDOM unit fixture is not loaded by Chromium E2E. The original six-test suite passed three focused repetitions, but two controlled Chromium orderings reproduced real baseline defects: recovery-scope initialization can clear a completed name without changing the discovery Task's arguments, and Browse captures an old label before discovery completes. The Task dependency contract was inspected directly. The separate fix makes that Task the canonical name owner and renders the open browser's current label; retries do not fix these races. The hosted log cannot identify which ordering produced its symptom.The other failed job exceeded the pinned old-reader test's 300-second budget after 355 seconds. Its synchronous body returned normally after pinned-reader and reopened-candidate assertions; Vitest's elapsed-time check then rejected it. No SQLite assertion failed. The test is byte-identical to baseline/current main, and the log lacks stage timings to distinguish fetch, worktree, or TypeScript child startup cost. No timeout, test environment, storage, or assertion was changed here. Named follow-up: the hosted Node-shard raw-tsx entry path bypasses the canonical tooling registration, so the later tooling-cache repair does not cover that path; this is a verified bootstrap coverage gap, not proof of the 355-second cause.
Production LOC: +0/-0. Tests/test support: +251/-174. Dev manifest: +1; lockfile: +23. No application code changed.
Provenance: the shared-window installation pattern is present in #107458 (
d6fc3d34e2010997d4f67807b30c336347808f31, July 14), authored and merged by @steipete; #130468 (fc6cf5e6907dd9fde31fcb454002cffcf5d465d4, August 27 UTC), also authored and merged by @steipete, carried it into the deferral suite that reproduces the routing failure. This is a fixture-lifetime defect, not evidence of a production routing regression.Related but distinct: #120554 improves reconnect/catalog E2E deferrals and remains owned by its author. This repair does not copy or replace that work.