Repository navigation
Commit 8ccc736
authored
test: add check-ui guards for behaviour a successful build does not demonstrate (#1641)
Fixes #1581. Part of #1578. Step 3 of 3, not required to boot. Depends
on #1616 (the Vite cutover, now
merged into `dev`).
Three checks, wired as `make check-ui`, for properties that a green
build, a working dev server and a compiling binary do not demonstrate.
Each one was observed failing on the failure it guards before being
relied on.
**Asset paths, `make check-ui-assets`.** `script/check-built-assets.sh`
builds the frontend and runs `TestGetStyleResolvesBuiltAssets` from step
1. Under `--self-check` it rewrites the built `index.html` with four
shapes the server cannot use (a stylesheet link but no script `src`, a
script but no stylesheet link, an inline-only script, and a
non-stylesheet `<link rel="manifest">` that must not be miscounted as a
stylesheet), asserts the check fails on each, and restores the real
build afterwards, so a check that quietly stopped asserting anything is
distinguishable from a passing one. It also fails if the Go test it
depends on is ever renamed or removed, instead of silently matching
nothing.
**Non-default locale, `make check-ui-locales`.**
`ui/scripts/check-locale-resolution.js` starts the real dev server from
the real config and imports `ui/scripts/locale-probe.js`, which carries
a copy of the application's own template-literal `@i18n` import, through
the server's module runner. It asserts two separate properties, because
only one of them is about resolution: the module graph resolves the
alias and parses a language file that lives outside the frontend root,
and a browser is allowed to fetch it, which depends on the dev server's
filesystem allow-list. Checking only the first passes while every
language 403s in a browser. It requires `zh_CN` and `en_US` to resolve
to distinct translated content.
**Plugin i18n order, `make check-ui-plugin-i18n`.**
`ui/scripts/check-plugin-i18n-order.js` loads the plugin helper without
touching the application's i18n bootstrap, so `i18next` is guaranteed
uninitialised, registers a bundle, then initialises, and separately
exercises the immediate path where an initialised instance already
exists. Two assertions in each branch, because either alone passes while
the feature is broken: registering must not throw, and the translations
must actually be present afterwards. It also asserts exactly one
`i18next` module is loaded, so the harness cannot silently measure an
object nothing under test writes to.
**All three fail closed.** Each check presets its result to failure and
only reports success once it has proved it. The two Node scripts bound
every server-creation, listen and close call with its own timeout and
add an unreferenced whole-run watchdog, so a hang cannot drain the event
loop into an accidental success instead of a reported failure.
**Small follow-ups.** `src/components/Comment/index.scss` declares its
properties before nested rules, clearing the one app-own Sass
mixed-declarations warning the step 2 build printed; output is
unchanged. `pages/403` is repointed at `pages/404/403`, an existing
component, so that route renders instead of failing through the error
boundary. The comments on `check-built-assets.sh` state the actual
constraint (tag shape does not affect parsing; the check fails when a
build is present but a required tag is missing).
Agentic tooling did the mechanical work in this series; every change was
reviewed by a human before being committed.
### Verification
On `dev` at `6c00c788`, which includes steps 1 and 2, plus these
commits: `pnpm install --frozen-lockfile` under the pinned `pnpm@9.7.0`;
`make check-ui` green on all three targets;
`./script/check-built-assets.sh --self-check` reports all four fixtures
failing as intended and the real build restored, with
`TestGetStyleResolvesBuiltAssets` passing again afterwards. The three
targets print `--- PASS: TestGetStyleResolvesBuiltAssets`, `OK: zh_CN
and en_US resolve at runtime to distinct translated resources, and zh_CN
is fetchable over the dev server`, and `OK: plugin translations
registered before i18next.init (deferred) and after i18next.init
(immediate) both survive and are present`; the self-check reports `check
failed as expected` for each of the four fixtures and ends with `==>
self-check passed`. The build in this tree no longer prints the Sass
mixed-declarations warning that step 2's build printed.
None of this adds a CI job; the constraint for wiring one is in the
tracking issue.
The commits carry `(cherry picked from commit ...)` lines pointing at
the branch behind #1567, where these checks were first reviewed.1 parent f119282 commit 8ccc736
7 files changed
Lines changed: 673 additions & 2 deletions
File tree
- script
- ui
- scripts
- src/router
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
50 | 66 | | |
51 | 67 | | |
52 | 68 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
| |||
0 commit comments