Skip to content

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

Closed

Description

@mstomar125

Symptom

src/tests/services/navigation-service.test.ts — the "Entity node navigation (Issue #915)" tests ("primitive text node under date still resolves to date ancestor", "deeply nested primitive walks up to nearest viewer-owning ancestor") fail intermittently only in the full bun run test run, never in isolation (39/39 pass alone). Observed blocking the pre-push gate non-deterministically; passes on retry.

Root cause

The test uses the singleton sharedNodeStore (imported real, not mocked) and its beforeEach only calls resetTabState() — it never clears the store. Under vitest's pool: 'forks', multiple test files share a worker process, so nodes/structure-tree edges other files setNode into the shared store persist into navigation-service's fork. The #915 ancestor-walk resolves against that polluted structure and can land on the wrong ancestor. Which files share its fork is non-deterministic, so adding any unrelated test file can surface it (this is how it was noticed — an unrelated new test file in a different PR flipped the ordering).

Fix

Clear the shared store (and structure tree) in navigation-service.test.ts's beforeEach (e.g. sharedNodeStore.clear() / the store's reset API) so each case starts from a known-empty graph, independent of sibling files. Audit other suites that use the real sharedNodeStore for the same gap.

Impact

Test-only; no product bug. But it flakes the pre-push gate for everyone (this device + Michael), costing retries.

Found while implementing #1996.

Activity

  1. added a commit that references this issue on Aug 10, 2026
    90e4c4e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions