testenv: a docs page edited without its site index fails the package run

site/public/llms-full.txt and search/*.json are built from the docs
pages and committed. A Go change that edited a docs page and ran only Go
tests left them stale on main five times from 11-13 to 11-17
(459d668b3, 256910f17, 9dcec6751, dbbb2f26b, 00b2c11a6), each caught by
CI's node tests after the push.

site/docs-index.mjs now writes all three: llms-full.txt, search/*.json,
and docs-index.sums, a sha256sum line per page they are built from.
`node llms-full.mjs` and `node search-index.mjs` each run all of it, so
running either one is enough. After a package's tests, testenv checks the
pages against the sums the way it checks eagerHere, and fails the run
when any page is edited, added or gone, naming each page. That covers
the 64 packages that use testenv, a -run of one test included.
search.test.mjs checks that the sums are current. The code standards'
criterion 3 and LESSONS say so.

Generating at this base changed neither llms-full.txt nor the search
indexes, so they were current.

Run:
- mote: go vet ./internal/testenv; go test ./internal/testenv
  (TestDocsIndexStaleNamesEachChangedPage, TestDocsIndexCurrent) and
  internal/agent's TestEveryFieldLabelHasTUIZh: ok.
- mote: node --test site/search.test.mjs site/worker.test.mjs: 47 pass.
- Linux (wsl-run) and Windows (win-run): go test ./internal/testenv ok.
- mote: GOOS=windows/linux go vet ./internal/testenv: ok. gofmt -l:
  clean.

Broken by hand: appending a <p> to docs/alma.html without regenerating
made `go test -run TestEveryFieldLabelHasTUIZh ./internal/agent` fail
("testenv: docs pages changed … docs/alma.html") with its test passing.
search.test.mjs went red too.

Not run: the full Go suite. It starts after the push.
This commit is contained in:
yetone
2026-11-17 15:17:35 +08:00
parent c9e8422fa8
commit 31dcfcc336
10 changed files with 626 additions and 13 deletions
+8 -6
View File
@@ -79,12 +79,14 @@ listed as not run, never left out.
internal/agent's TestEveryAgentNamedForTheLibrary for a new agent
(red on main four times before it, last at 00b2c11a6, 11-17), and
its TestEveryFieldLabelHasTUIZh for a new field's label (618bfc1a9).
A change under `site/public/docs` ends with `node llms-full.mjs` and
`node search-index.mjs` in site/, then `node --test site/*.test.mjs`
from the repo root: both files are built from those pages and
committed, and a Go change that adds a docs row left them stale on
main five times from 11-13 to 11-17 (459d668b3, 256910f17,
9dcec6751, dbbb2f26b, 00b2c11a6).
A change under `site/public/docs` ends with `node search-index.mjs`
in site/ (it writes llms-full.txt, search/*.json and
docs-index.sums), then `node --test site/*.test.mjs` from the repo
root: those files are built from the pages and committed, and a Go
change that adds a docs row left them stale on main five times from
11-13 to 11-17 (459d668b3, 256910f17, 9dcec6751, dbbb2f26b,
00b2c11a6). Every package using testenv now fails its run while a
page differs from docs-index.sums.
4. **GUI tests in both engines.** A change to `internal/gui/assets` runs the
Playwright tests it touches in Chromium and WebKit (`make test-ui`, or
`BROWSER=webkit node --test …`). The suite must also pass in Chinese,