test: drive the Settings screen in a browser and guard every popup element id (closes #229)
All checks were successful
check / check (push) Successful in 29s

Nothing exercised the Settings view in a browser, and jest runs in the
node environment with no DOM, so the densest run of $("...") lookups in
the codebase was unverified at runtime. A wrong id is valid JavaScript
naming a defined function: $() returns null and the next property access
throws, which inside a view's init() aborts the rest of the popup's
init() and leaves every screen blank.

Two halves, because they catch different things.

The e2e suite (tests/e2e/run.js) gains six cases between the address
removal and dust threshold sections. They assert the About well and the
wallet list were actually written — show() populates those last, so
reading them back proves the whole of show() ran rather than just enough
of it to unhide the section — that the four Token Spam Protection
controls are real input[type=checkbox] elements defaulted on, and that
the theme and network selectors offer exactly the choices
src/shared/networks.js and index.html define while carrying the
persisted value. One filter is then toggled off and back on across a
popup reopen each way, which runs the change handler, saveState(),
loadState() and the init() assignment rather than only looking at the
screen. Each group records a coverage key and a final case demands the
exact set, so a section that silently stopped running reddens the suite
instead of shrinking it.

tests/popupElementIds.test.js is the general half and needs no browser,
so jest picks it up and it runs in make check: every literal id reached
through $(), document.getElementById(), showError()/hideError() and
showView() must exist in src/popup/index.html, no id in index.html may
be defined twice, and the scan asserts it found the code and the markup
so it cannot pass by covering nothing. Only literal arguments are
resolvable statically; $(containerId) and a lookup naming the wrong
existing element are the browser suites' job, and README says so.

Demonstrated against three deliberate breaks. A typo'd id in
settings.js reddens both halves, the e2e run reporting
"pageerror: Cannot set properties of null (setting 'checked')" against
its first test. A handler bound to the wrong but existing element passes
the static guard and reddens only the new functional case. A typo in a
view no browser suite opens reddens only the static guard.
This commit is contained in:
2026-08-17 06:21:00 +00:00
parent d9d50f05d2
commit ae4d211c11
4 changed files with 477 additions and 0 deletions

21
TODO.md
View File

@@ -45,6 +45,27 @@ undefined identifiers, which is how
# Completed Steps
- 2026-08-17: The Settings screen is driven in a browser, and every element id
the popup looks up is checked statically. Nothing exercised Settings in the
e2e suite, and jest runs with no DOM, so the densest run of `$("...")` lookups
in the codebase was unverified at runtime. Six new cases in `tests/e2e/run.js`
reach Settings, assert the About well and the wallet list were actually
written, assert the four Token Spam Protection checkboxes are real checkboxes
defaulted on, assert the theme and network selectors offer the choices
`src/shared/networks.js` defines and carry the persisted value, and toggle one
filter off and back on across a popup reopen each way — which runs the change
handler, `saveState()`, `loadState()` and the `init()` assignment rather than
just looking at the screen. Each group records a coverage key and a final case
demands the exact set, so a shortened or skipped section reddens the run
instead of shrinking it. `tests/popupElementIds.test.js` is the general half
and runs in `make check` with no browser: every literal id reached through
`$()`, `document.getElementById()`, `showError()`/`hideError()` and
`showView()` must exist in `src/popup/index.html`, which no id in `index.html`
may define twice. Demonstrated on three deliberate breaks — a typo'd id (both
halves red), a handler bound to the wrong but existing element (only the
functional e2e case red), and a typo in a view no browser suite opens (only
the static guard red)
([#229](https://git.eeqj.de/sneak/AutistMask/issues/229)).
- 2026-08-17: `README.md` no longer advertises a defect the wallet does not
have. The End-to-End Tests section listed the EIP-1193 code being dropped in
the last hop into the page as a standing limit of the dApp coverage; that