Skip to content

Isolate navigation-service tests from sibling-file store pollution - #2022

Merged
mstomar125 merged 1 commit into
mainfrom
issue-2020-nav-test-isolation
Aug 10, 2026
Merged

mstomar125 merged 1 commit into
mainfrom
issue-2020-nav-test-isolation

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

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-service resolves a target by reading both singletons: sharedNodeStore.getNode and structureTree.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's forks pool, 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).
  • Full frontend suite green (193 files / 4463 tests); eslint + svelte-check clean; pre-push gate passed (navigation tests green in-context).

🤖 Generated with Claude Code

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]>
@mstomar125

Copy link
Copy Markdown
Contributor Author

Pragmatic Code Review + /address-review

Test-only change. Adversarial check — the only way a beforeEach that clears both singletons could break something is if a test relied on state persisting from a prior test in the same describe; that would be a test-smell anyway, and it's empirically ruled out: all 39 navigation-service tests pass with the clears, since each sets up its own fixtures after the reset. The clears run before the per-describe beforeEach hooks (outer-before-inner), so fixture setup is unaffected. Full frontend suite green (193 files / 4463); eslint + svelte-check clean.

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.

@mstomar125
mstomar125 merged commit 90e4c4e into main Aug 10, 2026
@mstomar125
mstomar125 deleted the issue-2020-nav-test-isolation branch August 10, 2026 11:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky: navigation-service #915 ancestor tests fail intermittently in the full suite (singleton sharedNodeStore not cleared)

1 participant