Repository navigation
test(browser): add a hermetic Playwright lane that blocks in CI - #444
Conversation
…e real fetchers The mocks under src/mocks are view models: what a fetcher returns, with Date objects, view routes and no Payload envelopes. A browser that is answered with them skips the very parse it should exercise. wire.ts derives each response from those mocks in the shape SahajCloud sends over HTTP, plus the router that answers a request with one of them. wire.test.ts runs every fixture through the real fetchers and the real SDK, with only fetch swapped for that router, so a fixture cannot drift from the schemas the app reads. Each of its assertions was watched failing against a deliberately broken fixture. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVeNzer8ue5c7JRsZk
`pnpm review:embed` hard-coded port 5174, `dist/` and the key from `.env.local`. The browser lane needs the same host pages over its own build, on its own port, with its fixtures' key, and a second copy of the pages would drift from the one reviewers open. `--port`, `--dist` and `--key` override each default; with none of them the server behaves exactly as before, trap 4 included. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVeNzer8ue5c7JRsZk
Nothing exercised the widget in a real browser. This lane builds it with the lane's own origins and a dummy Mapbox token, serves that build on the review server's host pages, and drives it in Chromium with @playwright/test 1.65.1. Hermetic: SahajCloud is answered from src/mocks/wire.ts, Mapbox from a minimal style and empty glyphs, the IP lookup from a refusal. An auto fixture aborts and records every request no fixture answered and fails the test that made it; --host-resolver-rules leaves nothing else resolvable. The map draws through SwiftShader, so its WebGL context is real. Seven scenarios: the full-map boot, browsing in and back out, a deep link, a map-less embed, the compact card, hostile host CSS, and registration accepted and failed. Each was watched failing against a deliberate break in the code it guards. The lane found a defect on its first run: a map=false embed downloads the mapbox-gl chunk, because react-map-gl imports it at module load. That check runs under test.fail, so it turns red the moment the defect is fixed. Vitest excludes tests/browser; tsc and eslint cover it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVeNzer8ue5c7JRsZk
`Browser lane` builds the widget for the lane, installs the Chromium the pinned Playwright expects (cached on that version, system libraries reinstalled on a hit), runs every scenario, and uploads the report and the failures' traces when it goes red. It needs no secret, so forks and the merge queue run it as pull requests do. Every action is pinned by commit SHA, resolved with git ls-remote, peeled for annotated tags. ci-workflows.test.ts pins what would make it fail silently: the check name, recorded in the ruleset table in docs/testing.md; that it runs on pull_request and merge_group with no `if:` to skip it; no continue-on-error and no retries; and the SHA pins. Each was watched failing. The ruleset still needs the check added by hand, which the table now says. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVeNzer8ue5c7JRsZk
… one docs/testing.md and the smoke lane's own note left real-browser checks to local Playwright verification; both now point at the browser lane. A new section says why the lane is hermetic (the widget needs a SahajCloud that accepts its key before it renders anything, and no CI run has one), why its fixtures are wire shape, how the map renders without a GPU, the known map=false defect it keeps running, how to run it locally and how to read a failure from CI's artifact, and the stability runs it was measured with. The root AGENTS.md Testing section, Essential commands and the README list the third lane. Three stale claims follow it: that tests/ holds only smoke specs (twice), and that stubbing clients/me is the only way to see a rendered interface. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVeNzer8ue5c7JRsZk
`rendered` resolved on the embed report alone, but a lazy import an effect
starts can leave after it. With a compact-card prefetch of FullInterface
injected, the "no mapbox-gl chunk" assertion missed it in 1 run of 20. It
now also waits for 500 ms with nothing in flight, and caught the same
regression in 40 of 40 runs. `waitForLoadState('networkidle')` would not
do: Playwright fires it once per navigation and never re-arms it.
`context.route` never sees a WebSocket, so a socket to any host passed the
lane. Every socket is now recorded off each page's `websocket` event,
which also reports a dedicated Worker's (`routeWebSocket` does not), and
fails the test at teardown, naming it. Watched failing for both.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVeNzer8ue5c7JRsZk
…ot test.fail `test.fail` takes ANY failure inside the test for the expected one. With an unrouted fetch injected, the other tests failed at teardown and this one was reported green, as it would be for a widget that never boots. The chunk half of the map=false scenario now asserts the known defect directly, polled after the quiet-network barrier. A boot, hermetic or crash failure fails it like any other test (watched, with an unrouted fetch), and a fix turns it red with a message saying to flip it to `toEqual([])` (watched, with the chunk pattern made unmatchable). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVeNzer8ue5c7JRsZk
…else The lane listed the `VITE_*` values it pinned, and the list missed VITE_WEMEDITATE_MAP_URL. A value for it in `.env.local` or the shell was inlined into dist-browser (watched, with a sentinel URL), so the claim that the build pins every `VITE_*` was false. Any variable added later would leak the same way. The build now drops every `VITE_*` from its environment and reads no env file (`envDir: false`, Vite 8.3.8), then sets only the lane's two values. Sentinels set in `.env.local` and in the shell for the fallback URL, the Sentry DSN and Fathom no longer reach the build. The lane's origin, token and the default fallback URL do, and the lane stays green. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVeNzer8ue5c7JRsZk
The pin checked ci.yml and playwright.config.ts, but CI runs `pnpm test:browser`, so `--retries=2` added to that script stayed green (watched: 19/19). Every package script that runs `playwright test` is now checked, which also covers a retry moved behind another script. The same edit now fails the pin. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVeNzer8ue5c7JRsZk
The readiness URL named `localhost`, so the runner asked the system resolver. In a container whose /etc/hosts has no `::1` line, that sent four AAAA queries to 8.8.8.8 per run (strace of connect). These were the lane's only packets off loopback. The server binds 127.0.0.1, and probing that address leaves no DNS traffic (re-traced: zero). `baseURL` stays on `localhost`, which Chromium resolves itself. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVeNzer8ue5c7JRsZk
The body and the root AGENTS.md describe three lanes, but the front-matter description the rule loader shows still said two. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVeNzer8ue5c7JRsZk
…he lane ci.yml runs only on pull_request and merge_group. A cache a pull request saves is scoped to its merge ref and read by that pull request alone, and a merge-queue entry's is read by nothing (GitHub's dependency-caching docs, "Restrictions for accessing a cache"). So every first run and every queue entry missed, then uploaded about 170 MB into a scope that would never be read, inside the repo's 10 GB cache quota. The lane job now only restores (`actions/cache/restore`). The new browser-cache.yml saves the browser on each push to `main`, the scope every lane run can read. It looks the key up without downloading (`lookup-only`) and saves only on a miss. ci-workflows.test.ts pins that both workflows use the same version step, key and path, that the lane job never saves, that the warm-up runs only on `main`, and that every action is pinned by SHA. Eight drifts were watched failing. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVeNzer8ue5c7JRsZk
|
🤖 no session running recent dispatchesWritten by the sydevs dispatcher. Sessions never edit this comment. |
Four of main's five new commits merged clean. Three files conflicted, and #435 (the accessibility gate) is behind all three — it added a second browser-driving lane while this branch added the first. scripts/serve-embed-review.mjs: #435 moved the MIME table out to scripts/_mime.mjs, shared with check-a11y.mjs; this branch replaced the module-scope DIST and env read with parseArgs and moved the env read to its one use. Both kept — the shared table is imported, the flags stay. package.json / pnpm-lock.yaml: both sides pinned Playwright, at different versions. #435 takes `playwright` 1.63.0 for the a11y gate, this branch `@playwright/test` 1.65.1 for the lane, and `pnpm exec playwright install` in both CI jobs resolves the root `playwright` bin — so one job would have installed a Chromium revision the other's runner could not use. Aligned on 1.65.1, the version @playwright/test 1.65.1 depends on anyway. Nothing pins either literal; ci.yml checks only the version's shape. docs/testing.md: both sides added a lane section and renumbered the intro. Both sections kept, the intro reads four lanes, and the browser-driving two are introduced together because they now share one installed Chromium. Flip scenario d, as this PR's body said whichever landed second must. #445 upgraded react-map-gl to 8, which starts the mapbox-gl download from the map's first render instead of module load, so the pinned defect is fixed: tests/browser/embed.spec.ts asserts toEqual([]) and the section is rewritten as a gate rather than a pin. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZBc3RqqBmGH541EK8
|
Merged
Scenario d is flipped, as this PR's body says whichever landed second must: #445 landed first. Lean gate green: 181 files / 2173 tests. The lane is 9/9 on local Chromium 1243, and the flipped assertion was watched failing against a module-scope 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
sydevs-bot
left a comment
There was a problem hiding this comment.
One hunk of the main merge wants confirming — the thread on package.json.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
sahajatlas-design | a9854fc | Nov 21 2026, 12:34 AM |
|
@sydevs-bot address |
The wire fixtures reached the region tree four ways: `pathOf(node)` beside `regionPath(id)`, and an unchecked `nodeById.get(id) as RegionNode` in `regionRef`. One checked `regionNode(id)` now backs both, and `regionPath` recurses on the id, so a missing region throws where it is read rather than yielding `undefined` fields. `eventPath` had one caller left once `WIRE_EVENT` read `webPath` off the feed feature it names, which also drops `as GeoFeature` and `as string`. The `eventDoc` tuple helper and its `(typeof features)[number]` annotation fold into `Object.fromEntries`, and the two spellings of the title fallback become `title(id)`. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjY1NN3aQxWtxiS2Kc1
The `lane` fixture did four jobs in one body: tracking unanswered requests, tracking uncaught errors, watching for WebSockets, and registering routes. `laneGuards(context)` now owns the first three and hands back `routeTo`, the one way to answer a request — so the `answered` set it consults is reachable only from the two places that need it, and the fixture body reads as the route table it is. No behaviour change. Watched failing: with the Mapbox style answer removed, the lane still reds with `requests no fixture answered` naming that request. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjY1NN3aQxWtxiS2Kc1
|
Merged Adopted
Answered
Gate green: lint, typecheck, 2179 tests, build, size in budget. Lane 9/9; the guard watched failing. Body refreshed: it still described the pre-#445 scenario d. 🤖 Written by the sydevs autonomous loop — see what this is 🤖 Generated with Claude Code Generated by Claude Code |
#442 landed on main and conflicted with the browser lane in three files. Each hunk is a union: both sides added in the same place, and both additions are wanted. - AGENTS.md: keep `pnpm test:browser` and `pnpm test:coverage` in Essential commands. - tsconfig.test.json: include both sides' entries, and keep main's ⚠ note that the app tsconfig's ".ladle" entry matches no file. - scripts/ci-workflows.test.ts: keep all four describe blocks — the lane's own pins, the browser cache, main's gate-job coverage pins and main's every-workflow SHA pin. main's new every-workflow pin requires a `# vN` comment beside every third-party action SHA; browser-cache.yml and the lane's steps in ci.yml already carry one, so the pin holds over the new workflows. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjYCEUSEG2LZ8qNZTg1
|
Merged
Lean gate green: lint, typecheck, 185 files / 2309 tests. Ran the size budget too, since #442 moved the bundle: standalone 291.0 / 336 KiB, embed 292.1 / 336 KiB, loader 3.3 / 3.6 KiB shipped. #442 freed about 44 KiB, so the body's headroom figures are stale. The browser lane was not re-run here. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Only pnpm-lock.yaml conflicted. Resolved by taking main's lockfile and re-resolving, so the three dependency upgrades on main (#446 React 19, #448 i18next 27, #449 framer-motion 14) keep their resolutions and this branch adds only its own entries. package.json auto-merged correctly: main's upgrades plus this branch's build:browser/test:browser scripts and the single Playwright pin at 1.65.1 across both @playwright/test and playwright. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjYUjf4QdPM7uur9eRg
|
Merged Took
Checked at the merge commit
This run resolved the conflict only. The open review is not addressed. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Summary
Nothing exercised the widget in a real browser:
docs/testing.mdandtests/smoke/embed.smoke.test.tsleft that to manual "local Playwright verification". This adds a browser lane.pnpm test:browserbuilds the widget intodist-browser/, serves it on the real host pages fromscripts/serve-embed-review.mjs, and drives it in Chromium with@playwright/test1.65.1. Every SahajCloud and Mapbox request is answered from fixtures. CI runs it as theBrowser lanejob, which blocks: no retries, noif:, nocontinue-on-error.The lane found a real defect on its first run: a
map=falseembed downloaded the 1.9 MB mapbox-gl chunk and never used it. #445 (react-map-gl 8) has since landed and fixed it, so the scenario that pinned the defect is now an ordinary gate — see "A map-less embed must not download mapbox-gl" below.What changed and why it matters
src/mocks/wire.ts). These are SahajCloud's responses as they arrive over HTTP, derived fromsrc/mocks/*.src/mocks/wire.test.ts, in the unit lane, runs every fixture through the real fetchers, zod schemas and SDK, with onlyfetchreplaced, so fixtures cannot drift from the contract.scripts/serve-embed-review.mjsgains--port,--distand--key, and behaves as before with no flags. The lane starts it as Playwright'swebServer, so reviewers and CI use the same pages.tests/browser/fixtures.ts,playwright.config.ts,tests/browser/build.mjs):websocketevent, whichcontext.routenever sees.--host-resolver-rulesresolves onlylocalhost.https://sahajcloud.invalid.VITE_*from its environment and reads no env file (envDir: false). It sees exactly two values, the lane's origin and a dummypk.token, so nothing from a developer's.env.localor shell can leak in.127.0.0.1, so a run makes no DNS query.laneGuards(context)owns the three trackers and hands backrouteTo, the only way to answer a request — so a request a fixture answered cannot also be reported as unanswered.--use-angle=swiftshaderand--enable-unsafe-swiftshadergive a live WebGL2 context, and the map loads a minimal style served from fixtures.map=falserenders the list, with no canvas, no Mapbox host and no mapbox-gl chunk.rendered: the embed report, then 500 ms with nothing in flight. The report alone did not order a later lazy import, and that let an injected regression through 1 run in 20.Browser lanejob:contents: read) and every action pinned by SHA;playwright install --with-deps --no-shell chromium, orinstall-depswhen the cache hits;main, by the newbrowser-cache.yml. A cache a PR run saves is scoped to that PR's merge ref, and a merge-queue entry's to its throwaway branch. Saving from the lane would only have filled the cache quota.scripts/ci-workflows.test.ts:docs/testing.md;pull_requestandmerge_group;if:and nocontinue-on-error;--retriesin the job, in any package script that runsplaywright test, or in the config;tests/browser/**. The specs are linted and typechecked.docs/testing.md§ "The browser lane" covers why it is hermetic (it answers the missing-backend-key problem), the wire fixtures, the map, the map-less gate, running it locally and debugging it. The rootAGENTS.mdTesting section and Essential commands, and the README, are updated.Nothing here is visible to a host or a visitor, so there is no CHANGELOG or
docs/embedding.mdentry. The lane builds intodist-browser/from its own entry, and no file the production bundle reaches is touched:pnpm sizeis within budget on every graph (figures below).A map-less embed must not download mapbox-gl
Scenario d asserted the defect until #445 landed, so that the fix would turn it red. #445 starts the mapbox-gl download from the map's first render, so the scenario is now an ordinary gate: a
map=falseembed contacts no Mapbox origin, which isdocs/embedding.md's promise, and fetches no mapbox-gl chunk. Nothing but the browser holds the second half —FullInterfaceimportsMap.tsxwhichever wayhasMapreads, so aloadMapLibcall moved back to module scope would download the library again with every other gate green.Base and lockfile
main, twice: at af2cf80 (which brought chore(deps): upgrade react-map-gl to 8 through its Mapbox entry #445 and resolved three conflicts) and at 8439d4c (mainat 55b89e2 — chore(deps): upgrade Schedule-X to 4.9.1 with Temporal dates #450 Schedule-X 4.9.1, ci(contracts): fail only a PR's own change to a copied contract #451, docs(guides): keep intent and gotchas, point at code for the rest #453, docs(components): describe the Schedule-X patch by what it does, not hunk by hunk #454). Neither merge conflicted this round.package.jsonandpnpm-lock.yaml. Againstmain, the lockfile only adds the@playwright/test1.65.1 importer entry and the packages@playwright/test,playwrightandplaywright-core, all at 1.65.1. Nothing is removed or changed.pnpm exec playwright installresolves the rootplaywrightbin, so two pins would leave one CI job installing a revision the other could not use. feat(a11y): the atlas widget can be used with a keyboard and a screen reader #435's accessibility gate shares the installed browser.pnpm install --frozen-lockfilepasses at the tip.Verification
On the tip (bb27c47), after merging
mainat 55b89e2:.claude/skills/pr-prep/check.sh --full: lint, typecheck, unit lane (182 files, 2179 tests), build and size all pass.pnpm size, shipped against budget: standalone 335.1 / 336 KiB, embed 336.2 / 338 KiB, loader 3.3 / 3.6 KiB. Measured figures are 333.9 / 335.0 / 2.8.pnpm test:browser: 9 passed, on the sandbox's preinstalled Chromium (Playwright build 1243) throughPLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH.laneGuardsextraction was watched failing: with the Mapbox style answer removed, the lane reds withrequests no fixture answerednaming that request.In CI, on af2cf80:
Lint, Typecheck & Build,Smoke,Browser laneandDependency Review / reviewall green. TheBrowser lanejob took 65 s, so the CI path — the pinned Chromium,install --with-deps, the cache restore and SwiftShader on a GitHub runner — is exercised rather than assumed.Earlier rounds, on the same scenarios before the two merges
--repeat-each=2with 4 extra CPU busy-loops, 18/18 green at load average 13; oneCI=1run green. Earlier reviews ran 10 sequential runs and repeat-stress up to 150 runs at load average 29 with no flake.navigate(-1)at depth 0.hasMap; and, after the flip, a module-scopeimport('mapbox-gl').letter-spacingreset removed.ci-workflows.test.tsandwire.test.tsassertion was watched failing against its drift.straceof a lane run: everyAF_INETconnect goes to 127.0.0.1, with no DNS.None of the deliberate-break checks, the long stability runs or the
stracecheck was repeated after the two merges.Not done / not verified
browser-cache.ymlwas parsed as YAML, and its inputs and outputs were checked againstactions/cachev6.1.0'saction.ymland source. It has not run — it fires on push tomain, so the first run is after this merges. actionlint was not available.Follow-ups for the maintainer
Browser laneto the main ruleset's required status checks (Settings → Rules). Until then it reports but blocks nothing.docs/testing.mdlists it in the target row andscripts/ci-workflows.test.tspins the name against that row.browser-cache.ymland the restore step leaves the lane working..claude/edits I could not make (optional):.claude/skills/pr-prep/check.sh: its header lists CI as "lint + typecheck + test:run + build + size" and omits the Browser lane..claude/workflow.json: add.github/workflows/orplaywright.config.tsto the security-review trigger if network-routing test infrastructure should be reviewed.package.jsonandpnpm-lock.yamlalready trigger a review for this PR.pnpm-lock.yamlmay need a re-resolve after this lands.Browser cacherun on each push tomain.Notes for reviewer
refactor(…)commits at the tip answer the review's two "streamline and simplify" threads, one commit each. Neither changes behaviour.rendered()intests/browser/fixtures.tswas left alone on purpose: its two-condition wait (the embed report, then 500 ms quiet) is the measured fix for a lazy import that escaped the report, and rewriting it would re-open that flake.🤖 Generated with Claude Code
https://claude.ai/code/session_01Mg9rjY1NN3aQxWtxiS2Kc1