test: drive the Settings screen in a browser and guard every popup element id (closes #229)
This commit was merged in pull request #299.
This commit is contained in:
35
README.md
35
README.md
@@ -165,6 +165,23 @@ fixtures in `tests/e2e/network.js`, so the run is deterministic and fully
|
||||
offline; unrecognised outbound requests are reported as failures rather than
|
||||
silently allowed.
|
||||
|
||||
It also covers the **Settings screen**, which holds the densest run of element
|
||||
id lookups in the codebase and where one wrong id leaves the whole popup blank
|
||||
rather than only degrading Settings: that the screen renders populated — the
|
||||
About well and the wallet list are read back, so a `show()` that stopped early
|
||||
is caught rather than merely a view that failed to appear — that the four Token
|
||||
Spam Protection controls are real checkboxes defaulted on, and that the theme
|
||||
and network selectors offer exactly the choices `src/shared/networks.js` and
|
||||
`index.html` define. What the selectors persist is then driven through the UI to
|
||||
`dark` and `sepolia` and reasserted after a popup reopen before being restored
|
||||
the same way; neither value is its selector's first `<option>`, so neither can
|
||||
be read back from the markup with no JavaScript having run. One spam filter is
|
||||
likewise toggled off and back on across a reopen each way, which exercises the
|
||||
change handler, `saveState()`, `loadState()` and the assignment `init()` makes.
|
||||
Each group of these assertions records a coverage key and a final case demands
|
||||
the exact set, so a section that silently stopped running reddens the suite
|
||||
instead of quietly shrinking it.
|
||||
|
||||
It also covers the confirmation screen, for both a native ETH send and an ERC-20
|
||||
send: Send disabled while the fee estimate is in flight, enabled once it lands,
|
||||
the fee block quoting the expected cost and the reserve separately, the distinct
|
||||
@@ -400,6 +417,24 @@ the one-time pull of the pinned ~800MB Playwright layer, and well under a minute
|
||||
once that layer is cached. `e2e-firefox` about 1m05s cold, and it caches its
|
||||
Firefox and geckodriver downloads the same way.
|
||||
|
||||
### Element id guard (part of `make check`)
|
||||
|
||||
`tests/popupElementIds.test.js` asserts statically that every element id the
|
||||
popup looks up — `$("...")`, `document.getElementById("...")`,
|
||||
`showError()`/`hideError()`, and the `view-<name>` a literal `showView("...")`
|
||||
resolves to — exists in `src/popup/index.html`, and that `index.html` defines no
|
||||
id twice. A wrong id is valid JavaScript naming a defined function, so neither
|
||||
jest (node environment, no DOM) nor a linter objects to it; at runtime `$()`
|
||||
returns `null` and the next property access throws, which inside a view's
|
||||
`init()` aborts the rest of `src/popup/index.js` `init()` and leaves the popup
|
||||
blank.
|
||||
|
||||
It runs with no browser, so unlike the e2e suites it fits inside `make check`,
|
||||
and it covers every view rather than the ones some test happens to open. It only
|
||||
sees literal arguments: a call like `$(containerId)` is invisible to it, and a
|
||||
lookup naming the wrong existing element is valid by construction. Both of those
|
||||
are the browser suites' job.
|
||||
|
||||
## Rationale
|
||||
|
||||
Common popular EVM wallets have become bloated with swap UIs, portfolio
|
||||
|
||||
Reference in New Issue
Block a user