Skip to content

test(preview): check the gallery page writeIndex writes - #280

Merged
juancguerrerodev merged 11 commits into
DojoCodingLabs:mainfrom
mir-ashiq:test/preview-gallery-index
Dec 6, 2026
Merged

juancguerrerodev merged 11 commits into
DojoCodingLabs:mainfrom
mir-ashiq:test/preview-gallery-index

Conversation

@mir-ashiq

Copy link
Copy Markdown
Contributor

What and why

Closes #268

Adds apps/mobile/preview/gallery.test.mjs (node:test, like browser.test.mjs and pick.test.mjs) and adds it to the test script in apps/mobile/preview/package.json. Each test calls writeIndex with made-up shots (with id, name, route, variant, theme, lang, file and errors) on a path in a fresh folder from mkdtempSync(join(tmpdir(), "hermit-gallery-")), reads index.html back, and removes the folder at the end. gallery.mjs is unchanged. No Chromium and no build: writeIndex only writes a file, and the four test files import only node built-ins and local files.

What the tests cover:

  • Shots with the same id, name and variant share one <section> (one figure each, under one heading); a shot with a different variant gets its own section, with the state named.
  • A name and a note with <, >, & and " come out escaped in the heading, the meta line and the alt text, and no raw <script> from a shot's text reaches the page.
  • "console errors" appears only for a shot whose errors is not empty, carrying the errors in its title attribute.
  • A "full length" link appears only when the shot has full, pointing at the full picture.
  • A mockup figure appears only when mockups/<mockup> exists next to the index file: one case creates it in the temp folder, another leaves it out.

Vision fit

Contributor tools that work (AGENTS.md, "Screenshots for a UI change"): the page people use to look through the shots after a preview run is now checked without a browser, so a regression in grouping, escaping, the error badge or the mockup is caught by pnpm test in seconds.

Non-negotiables

  • This keeps every non-negotiable in AGENTS.md as it is.
  • Or it changes one, and this is the accepted RFC: n/a

Checklist

  • It closes one issue, linked above, or it's a small fix (a typo, a broken link, a wrong comment). A feature has an accepted proposal.
  • I wrote the failing test first. It fails without this change and passes with it.
  • These pass: pnpm check:privacy, pnpm typecheck, pnpm lint, pnpm test and node scripts/guard/check.mjs --patterns scripts/guard/patterns.txt.
  • No new network call, telemetry, analytics, ads or crash reporting. (A new request in an app adapter is explained below, with host, skill and risk.)
  • No new dependency, or the reason for each one is below.
  • Every UI string is in packages/copy, in es-419 and en, with matching keys and placeholders, and no em or en dashes.
  • Tests, fixtures and screenshots use made-up data only.

On the gates: this is a test-only change to apps/mobile/preview, and I could not run the whole workspace's gates on this machine (the disk is nearly full, so a full pnpm install of every workspace package was not possible). What I did run, exactly:

  • cd apps/mobile/preview && pnpm install --ignore-workspace (pnpm 10.15.1 through Corepack; the lockfile is untouched, and the test files import no dependencies)
  • node --test gallery.test.mjs — the new file, 5 tests, all passing
  • pnpm test in apps/mobile/preview — 31 tests across device-lab.test.mjs, browser.test.mjs, pick.test.mjs and the new gallery.test.mjs, all passing
  • node scripts/check-privacy.mjs — "privacy: no analytics, crash reporting or login brokers found"
  • node scripts/guard/check.mjs --patterns scripts/guard/patterns.txt — "guard: ok"

Each of the five tests was broken on purpose to watch it fail before being put back (expecting three sections, expecting a raw <script> on the page, expecting two "console errors" badges, expecting two "full length" links, and expecting the mockup figure with no mockup file): each broken expectation failed exactly its own test, and the restored file passes. What I did not run: the full-workspace pnpm typecheck, pnpm lint and pnpm test for the other packages, which this change doesn't touch (apps/mobile isn't linted yet per CONTRIBUTING.md; the change adds one file and one line in package.json under apps/mobile/preview).

On #227: it landed before this pull request, so pick.test.mjs was already in the test script and both files stay in the list.

Model path

  • This doesn't touch the model path: packages/model, agent, skills or eval, the prompt, the router, tool descriptions, normalizers, examples or the model file.
  • It does. The eval numbers from before and after are below, run as docs/evals.md says. No held-out case was tuned on.

Screenshots

  • No UI change.
  • UI change. Each changed screen is below, in both themes and both languages, with made-up data.
Light Deep sea
es-419 n/a n/a
en n/a n/a

New dependencies and network calls

n/a

AI agents

  • No AI agent wrote any part of this.
  • An AI agent helped. Which one, and what it did: Claude (Anthropic) wrote the test file after reading the issue, AGENTS.md, gallery.mjs and the neighbouring browser.test.mjs/pick.test.mjs, ran the package's tests, broke each expectation to watch it fail, and put it back. The claim comment on the issue was posted from the mir-ashiq account this branch is pushed from.
  • I read and ran everything in this pull request, and I can explain it.

Copilot AI balanced review requested due to automatic review settings December 6, 2026 08:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@juancguerrerodev
juancguerrerodev force-pushed the test/preview-gallery-index branch from 75da32b to d991a54 Compare December 6, 2026 09:11
@juancguerrerodev
juancguerrerodev merged commit d991a54 into DojoCodingLabs:main Dec 6, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Preview: test the gallery page that writeIndex makes

6 participants