Commit cd33964
test(internal): address Gemini + pr-review-toolkit findings on JS test infrastructure
Outcome of going through all 60 findings from Gemini Code Assist +
pr-review-toolkit (code-reviewer, pr-test-analyzer, silent-failure-
hunter, comment-analyzer). 3 wrong (skipped: PATH-resolved node binary
mis-flagged as hardcoded; project-relative esbuild path mis-flagged
as hardcoded; theoretical FakeBroadcastChannel constructor-throw).
Remaining real items addressed:
Harness:
- vm.runInContext replaces window.eval / indirect eval to clear the
"no eval()" style-guide flag (Gemini #1, #2).
- Timer-callback and broadcast-listener throws now record into the
errors list instead of being silently swallowed (homeassistant-ai#30, homeassistant-ai#32).
- SAFETY_CAP exhaustion records a clear "runaway setInterval" error
instead of breaking silently (#4, homeassistant-ai#31).
- Non-navigation jsdomErrors route to errors (not console) so tests
asserting `not result.errors` catch them (homeassistant-ai#38).
- Transpile failure short-circuits init eval to avoid cascading
syntax errors from un-transpiled TS (homeassistant-ai#34).
- FakeBroadcastChannel.postMessage now delivers to peer same-name
channels in the same context per spec (#5).
- Time-faked surface documented accurately (Date.now / setTimeout /
setInterval only; new Date / performance.now still wall-time) (homeassistant-ai#46).
- New broadcastChannelUnavailable param simulates the
`typeof BroadcastChannel === 'undefined'` browsing context so the
production null-guard branch is exercised (homeassistant-ai#15).
- Dead comments and rot-prone duplications removed (homeassistant-ai#47, homeassistant-ai#49, homeassistant-ai#51,
homeassistant-ai#56, homeassistant-ai#57, homeassistant-ai#58, homeassistant-ai#59, homeassistant-ai#66).
extract_astro_vars.mjs:
- vm.runInContext replaces (0, eval) (Gemini #2).
- Multi-line `import { a, b } from 'x';` now stripped robustly (#7).
- Eval errors wrapped with the source path for actionable failures (homeassistant-ai#35).
_js_harness.py:
- Wrong test file name and workflow path in docstring fixed (homeassistant-ai#41, homeassistant-ai#42).
- _strip_astro_frontmatter raises ValueError when frontmatter opens but
never closes (homeassistant-ai#36).
- discover_script_surfaces raises when site/src/ is missing instead of
silently producing partial results (homeassistant-ai#37).
- extract_script_body accepts source_label for actionable errors (homeassistant-ai#40).
- Astro `<script lang="js">` is no longer mis-tagged as TypeScript (#9).
- Inert chr(92) Windows backslash replace removed (homeassistant-ai#14).
- Field docstrings on ScriptSurface trimmed to the one that earns its
keep (homeassistant-ai#52).
- _PY_RENDERERS registry refactor + accurate enumeration comment (homeassistant-ai#45).
test_settings_ui_js_behavior.py:
- Rot-bait PR/issue numbers removed from module docstring (homeassistant-ai#43).
- _TOP_LEVEL_ELEMENT_IDS + import-time drift check replaces the
"refresh this manually" comment (homeassistant-ai#55).
- _assert_clean_init helper called at the top of every test so init
failures surface as init errors, not as misleading
"side effect didn't fire" failures (homeassistant-ai#33).
- 4xx restartBtn assertion now reads disabled state via JS and snaps
to body.dataset instead of OR-shortcircuiting against a wiped DOM (homeassistant-ai#27).
- New test_script_boots_without_broadcastchannel_global covers the
null-guard branch (homeassistant-ai#15).
- Assertion-restating comments removed (homeassistant-ai#60).
test_astro_setup_js_behavior.py:
- Rot-bait homeassistant-ai#1422 reference removed from module docstring (homeassistant-ai#44).
- _section_has_hidden_class replaces fragile substring slicing (#6).
- test_initial_state_only_client_section_visible now asserts on the
promised visibility, not just absence of errors (homeassistant-ai#26).
- Per-client smoke now captures config-output text AND instructions
HTML into body.dataset and asserts on non-empty content, catching a
typo that drops the whole per-client branch (homeassistant-ai#21).
test_astro_tools_js_behavior.py:
- _card_class helper replaces ±200-char substring slicing (#12).
- test_design_mode_toggle now asserts design-only elements lose
'hidden' class, not just the button label flip (homeassistant-ai#25).
- New tests cover .filter-btn / .cat-btn / .size-filter-btn /
group-category|file|none / sort-alpha / expand-all wiring (homeassistant-ai#22, homeassistant-ai#23,
homeassistant-ai#24) — the adjacent coverage gaps issue homeassistant-ai#1422 didn't name but that
fit the harness's same regression-class.
test_consent_form_js_behavior.py:
- _build_form_dom docstring fixed (said "three", listed four) (homeassistant-ai#54).
test_rendered_scripts_parse.py:
- Missing-dependency skip flips to fail when CI=true so a workflow
drift that drops the install step doesn't silently lose parse
coverage (homeassistant-ai#29).
- Subsumed-test-class reference removed from module docstring.
AGENTS.md:
- "60s probe windows take milliseconds" wording fixed; time-faked
surface documented (homeassistant-ai#13).
- Per-surface module naming guidance updated; reflects actual files (#10).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent a893e00 commit cd33964
9 files changed
Lines changed: 1076 additions & 561 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
570 | 570 | | |
571 | 571 | | |
572 | 572 | | |
573 | | - | |
574 | | - | |
575 | | - | |
576 | | - | |
577 | | - | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
578 | 581 | | |
579 | 582 | | |
580 | 583 | | |
| |||
592 | 595 | | |
593 | 596 | | |
594 | 597 | | |
595 | | - | |
596 | | - | |
597 | | - | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
598 | 609 | | |
599 | 610 | | |
600 | 611 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
37 | 48 | | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
46 | 54 | | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
55 | 61 | | |
56 | 62 | | |
57 | 63 | | |
| |||
61 | 67 | | |
62 | 68 | | |
63 | 69 | | |
64 | | - | |
65 | | - | |
| 70 | + | |
| 71 | + | |
66 | 72 | | |
67 | | - | |
68 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
69 | 77 | | |
70 | 78 | | |
71 | 79 | | |
72 | 80 | | |
73 | 81 | | |
74 | 82 | | |
75 | 83 | | |
76 | | - | |
77 | | - | |
78 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
79 | 96 | | |
80 | 97 | | |
81 | 98 | | |
| |||
0 commit comments