test: make memory graph integration deterministic - #6898
Conversation
d2963e0 to
7080e27
Compare
Design Review (Fable 5, fork) —
|
UX Review (Fable 5, fork) — ✅ PASSUX-level review of The patch touches exactly one file — a headless integration test ( UX-Verdict: PASS Test-only change: no production UI, strings, or rendered behavior touched — nothing a user experiences differs. [UX-REVIEWED] 7080e27 |
GPT 5.6 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Opus 4.8 Review (fork) — ✅ no blocking findingsReviewed |
iamwhatever
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: test (1 file, integration test only). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, SAST annotations clean, security checklist all-NO, AI reviewers green. Category: make MemoryGraphTab.integration.test.tsx deterministic by mocking the api.memoryGraph boundary, replacing d3 at its module boundary with a synchronous force contract, and using a constructable Sigma class fake, so it stops timing out at 15s in the full 1654-file run; no production, MSW server, shared setup, timeout or retry behaviour changed. CodeQL is not applicable on this fork PR (default-setup emits no check-run); SAST coverage is Semgrep only, latest run success with 0 annotations.
Problem / Motivation
MemoryGraphTab.integration.test.tsxpassed alone but its first graph-count test timed out at 15 seconds in the 1,654-file Vitest run. The file mixed a real MSW request, a real dynamic d3 force layout, and a Sigma mock that Vitest 4 cannot construct withnew. ## Why it matters A test that only passes in isolation can hide a broken renderer contract and can fail unrelated full-suite shards under load. Deterministic API, layout, constructor, and teardown boundaries make the test prove the production integration it claims to cover without extending its time budget. ## Root cause The component caught the Sigma constructorTypeError, so the tests never proved that the graph renderer initialized. At the same time, network scheduling and the real force pass made readiness depend on loaded-worker timing. The loading case also installed an MSW handler whose request promise never settled, leaking request lifecycle beyond the assertion. ## What changed - mock theapi.memoryGraphboundary directly with the existing graph fixture - reset and explicitly control the API result for every test - replace d3 only at its module boundary with a synchronous fluent force contract; layout physics are not the UI-shell integration subject - replace the non-constructable Sigma function mock with a real class fake that implements every method the component uses - use onegraphReadycontract that waits for both API-rendered DOM and an actual Sigma mount - assert graphology received 7 nodes and 2 edges - make the loading case use a controlled deferred promise and settle it before teardown - prove Refresh performs a second API call No production, MSW server, shared setup, timeout, retry, or warning behavior changed. ## Global overlap audit All open PRs were checked across this test,MemoryGraphTab, API, setup, MSW helpers, Vite config, and dependency manifests. No pending PR owns this test or the Sigma/d3 behavior. #6895 fixes the complementary global happy-dom teardown race and its combined merge-tree is clean; #5983 changes only the backend memory handler. ## Tests - focused: 11 passed - five consecutive focused runs after the coverage assertion was added: 55/55 passed - coverage mode: 11/11 passed; MemoryGraphTab line coverage 67.62% (gate floor 66.3%) - related Memory/Overview/Knowledge matrix: 8 files, 117/117 passed - negative mutation proved the renderer assertion fails when no Sigma instance mounts -npm run typecheck- full unfilterednpm run lint: 0 errors - jscpd: 2,425 files, 0 clones -git diff --checkand clean merge-tree ## Screenshot evidence Why no screenshot: This changes only headless integration-test doubles and synchronization; production rendering, layout, styles, motion, and interaction behavior are unchanged. ## Checklist - [x] One Conventional Commit - [x] No retry, sleep, timeout increase, tolerance, or warning filter - [x] No existing PR changes overwritten - [x] No secrets or generated artifacts