# test\(navigation-menu\): make arrow-traversal tests hermetic · versecafe/quoin

[View on GitCafe](https://git.cafe/versecafe/quoin/commit/c82331737574f8357b294aef369468aeb8525de9)

Repository: [versecafe/quoin](https://git.cafe/versecafe/quoin)

Visibility: public

Requested revision: c82331737574f8357b294aef369468aeb8525de9

Requested commit: c82331737574f8357b294aef369468aeb8525de9

Commit: c82331737574f8357b294aef369468aeb8525de9

Tree: 3fdf59f0ac172b22e8bb94da4d7bf6de2fe1e963

Author: Battery Bot

Committer: Battery Bot

## Message

```
test(navigation-menu): make arrow-traversal tests hermetic

The NavigationMenu arrow-key tests queried `document` globally for their
triggers/links. Portalled popup content renders into `document.body`
outside the mounted root, so any residue — from this file or another suite
sharing the single happy-dom `document` — inflated the counts. That made
the tests order-dependent: green locally and in a stock-bun container, but
red on CI (where the test-file execution order differs), where `btns()`
returned 9 buttons (3 tests × 3) instead of 3 and focus assertions landed
on the wrong element. One test then wedged the whole run for ~168s because
`settleFocus()` only awaited a microtask, starving bun's 5s timeout timer.

Fixes:
- `makeRoots`: clear `document.body` on the first mount of each test and in
  cleanup, so every test starts from a pristine document regardless of what
  another suite leaked.
- arrow-navigation: scope trigger queries to the mounted root; make
  `settleFocus` yield a real macrotask so a stuck test fails fast at the 5s
  deadline instead of hanging.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

```

## Parents

- [722b24e5dce30321af8a36da647ad0886a56539e](https://git.cafe/versecafe/quoin/commit/722b24e5dce30321af8a36da647ad0886a56539e?format=markdown)

[Source at this commit](https://git.cafe/versecafe/quoin/tree/c82331737574f8357b294aef369468aeb8525de9?format=markdown)
