Skip to content

fix(frontend): stop the heading-focus wait once the document is gone - #848

Merged
viethqb merged 1 commit into
mainfrom
fix/focus-arrival-teardown
Nov 10, 2026
Merged

viethqb merged 1 commit into
mainfrom
fix/focus-arrival-teardown

Conversation

@viethqb

@viethqb viethqb commented Nov 10, 2026

Copy link
Copy Markdown
Member

Summary

focusHeadingOnArrival polls every 50 ms for up to 10 s. When a test finishes before that, the next tick runs after jsdom has torn down document and throws ReferenceError: document is not defined. Vitest counts that as an unhandled error and fails the run even though every test passed.

Test

  • New test in focusArrival.test.ts: it stubs document as undefined mid-wait and asserts that the timers neither throw nor reschedule. It fails without the guard (Cannot read properties of undefined (reading 'querySelectorAll')) and passes with it.
  • focusArrival, RulePageDelete and the classifications tests pass (166 tests). eslint is clean.

Docs

  • No user-visible change: test-environment robustness only.

🤖 Generated with Claude Code

focusHeadingOnArrival polls for up to 10 s. When a test ends first, its next
tick ran after jsdom tore down document and threw an uncaught ReferenceError,
which fails the whole vitest run (seen on main 1418484 and PR #847, from
RulePageDelete.test.tsx).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@viethqb
viethqb merged commit 16c0e97 into main Nov 10, 2026
9 checks passed
@viethqb
viethqb deleted the fix/focus-arrival-teardown branch November 10, 2026 12:27
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.

1 participant