Repository navigation
Isolate navigation-service tests from sibling-file store pollution - #2022
Conversation
The Entity-node-navigation tests intermittently failed only in the full suite: navigation-service resolves targets by reading the singleton sharedNodeStore AND the singleton structureTree, but the tests only reset tab state (and one describe cleared the structure tree), never the node store. Under vitest's forks pool, nodes/parent-edges left by whichever sibling file shares the worker skewed the ancestor walk, non-deterministically. Add a top-level beforeEach that clears both singletons before every test, so each starts from an empty graph regardless of sibling files. Closes #2020. Co-Authored-By: Claude <[email protected]>
Pragmatic Code Review + /address-reviewTest-only change. Adversarial check — the only way a Correctly targets the real root cause (both singletons read by the ancestor walk; only the tree was being cleared, not the store) rather than papering over it with a retry or a skip. Verdict: APPROVE. Re-Review Decision: NO RE-REVIEW NEEDED — single test-isolation hook. |
Summary
Fixes the intermittent full-suite-only failures of the
navigation-service"Entity node navigation (Issue #915)" tests ("resolves to date ancestor", "walks up to nearest viewer-owning ancestor"). Closes #2020.Root cause
navigation-serviceresolves a target by reading both singletons:sharedNodeStore.getNodeandstructureTree.getParent. The test file only reset tab state per-describe (and the #915 describe cleared the structure tree but not the node store). Under vitest'sforkspool, whichever sibling file shares the worker leaves nodes/parent-edges in those singletons, and the ancestor walk picks them up — non-deterministically, depending on file→worker assignment (so adding any unrelated test file could flip it, which is how it surfaced across #1996/#278).Fix
A top-level
beforeEach(before the per-describe hooks) clears both singletons —sharedNodeStore.clearAll()+structureTree.clear()— so every test starts from an empty graph regardless of sibling files. Test-only change.Validation
navigation-service.test.ts— 39/39 pass with the clears (each test sets up its own fixtures after the reset).🤖 Generated with Claude Code