test(acpmux): start-mode answers don't leak between test files

Merged
TE
17d ago
+12-3

new-tab-composer-first-frame.test.tsx fails whenever access-chip-pending-warning.test.tsx runs before it in the same bun process. Whether a shard goes red then depends on file order.

startMode.ts keeps acpmux's start-mode answers in module memory, which it reads from storage once per page. Both test files cleared localStorage after each test but not that memory. So the first-frame test inherited an earlier file's answer that this folder starts with no mode, and its access chip never drew. The first-frame file's own cleanup also wrote that same answer for the next file. Both files now reset the module through resetStartModesForTests(), a test seam like modelCatalogHost's resetModelCatalogForTests(). App behavior doesn't change.

Testing

On huge-blue with bun 1.4.2, from webviews/:

  • bun test test/access-chip-pending-warning.test.tsx test/new-tab-composer-first-frame.test.tsx
    • Base 4b5c7ad9: 11 pass, 1 fail ("a new chat paints its last effort and its kept start mode on the first frame…").
    • Head 14da28ca: 12 pass. The reverse order also passes 12/12.
  • bunx tsc --noEmit -p . is clean.

Observed / Not run

  • I ran the commands above. CI's web react-apps-check currently stops at the eager-JS-budget step before it reaches the webview tests (#22127 changes that), so CI doesn't run these yet.

Changelog

none

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.


Summary by cubic

Fixes a test-ordering flake where new-tab-composer-first-frame.test.tsx failed when access-chip-pending-warning.test.tsx ran first in the same bun process.

startMode.ts keeps acpmux start-mode answers in module memory, read from storage once per page. Both test files cleared localStorage but not that memory, so the first-frame test inherited the earlier file's answer and its access chip never drew. Both files now reset the module through resetStartModesForTests(), a test seam like resetModelCatalogForTests(). App behavior doesn't change.

Testing

  • Both file orders pass 12/12.
  • bunx tsc --noEmit -p . is clean.