test(web): await the theme observer instead of a wall-clock budget
The AppRenderer "live theme flip" test had its inner `waitFor` raised twice (bare assertion -> 1000ms -> 5000ms) and failed a third time at 5032ms under `local:gate` load. The budget was never the problem. Root cause: happy-dom 20.11.1's `MutationObserverListener` stores its dispatch callback as `new WeakRef((record) => this.report(record))` — an arrow function nothing else holds strongly. A GC between `observe()` and the mutation collects it, `callback.deref()` returns undefined in `Node[reportMutation]`, and the mutation is dropped silently and permanently. That is why the failure tracks machine load rather than any wall-clock value, and why no raise ever fixed it. Reproduced directly against 20.11.1: an observer on `documentElement`, three forced `global.gc()` passes, then `setAttribute` — callback count 0. Without the forced GC, 1. Upstream holds the arrow strongly in a private field from 20.11.2 onward; the same probe against the bumped copy reports 1. So: - bump `happy-dom`'s floor to `^20.11.2` (lockfile resolves 20.14.5), which is the actual fix; - replace the 5000ms `waitFor` with `flipThemeAttributeAndAwaitObservers`, an awaited condition per AGENTS.md: a probe MutationObserver registered after the component's is notified after it, so resolving on the probe's callback proves the component's already ran. No polling, no timeout, nothing load-sensitive. - use the same helper in the two negative theme tests, which is what makes their "not called" a real gate rather than a vacuous pass on a flip that was never delivered. The file's 52 tests now run in ~120ms. Closes #2384 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
parent
de2cbaeeaf
commit
eae68f2fc6
1 changed files with 52 additions and 60 deletions
8
clients/web/package-lock.json
generated
8
clients/web/package-lock.json
generated
|
|
@ -46,7 +46,7 @@
|
|||
"eslint-plugin-react-hooks": "^7.1.1",
|
||||
"eslint-plugin-react-refresh": "^0.5.2",
|
||||
"eslint-plugin-storybook": "^10.5.5",
|
||||
"happy-dom": "^20.9.0",
|
||||
"happy-dom": "^20.11.2",
|
||||
"playwright": "^1.58.2",
|
||||
"storybook": "^10.5.5",
|
||||
"tsup": "^8.5.1",
|
||||
|
|
@ -5264,9 +5264,9 @@
|
|||
"optional": true
|
||||
},
|
||||
"node_modules/happy-dom": {
|
||||
"version": "20.11.1",
|
||||
"resolved": "https://registry.npmjs.org/happy-dom/-/happy-dom-20.11.1.tgz",
|
||||
"integrity": "sha512-XSt8tMzbW9ymE7687xztkO1ckR7qJNQ3LywY9vlYGhGi3zXrGBHuUo2Cl1ztZaICW+1eAGdkLbj6iwVqDT33kg==",
|
||||
"version": "20.14.5",
|
||||
"resolved": "https://registry.npmjs.org/happy-dom/-/happy-dom-20.14.5.tgz",
|
||||
"integrity": "sha512-x/RzkpWO40bTjIoT30iQtt64FLLmH/iRcUCN2X//bLx7H3ifkdfPXyqsro/OYtqzIAhiLMMA7mmiOR9C3NOKjQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
|
|
|
|||
Loading…
Reference in a new issue