Repository navigation
tests: end-to-end coverage, and the token-field bug it found - #4
Merged
Merged
Conversation
The console had no tests. The routing work made them tractable — every view has
an address now — so this adds 38 Playwright specs across the read paths, the
MCP session, and the invariants this page is actually held to.
They run against the BUILT bundle through `pnpm preview`, not the dev server.
That is the whole point: preview replays fold's exact response headers, so the
suite exercises the Content-Security-Policy a shipped binary sends rather than
reasoning about it. One test walks the app and asserts no
securitypolicyviolation fired — CI's greps catch an inline <script> in the HTML
and a `style={{}}` in the source, but neither would notice a dependency
injecting a style tag at runtime.
WHAT IT FOUND
The Bearer-token field never applied its value. preact/compat aliases React's
onChange onto the input event, so declaring both onInput and onChange left one
handler clobbering the other: keystrokes were swallowed, the draft never
advanced past empty, and a pasted token authenticated nothing. Against a
gateway with auth on — the only configuration where the field is shown — the
console was unusable.
Nothing caught it. Typecheck, lint and every CI grep passed; the browser looked
correct because the local gateway runs with auth disabled and hides the field.
Fixed by dropping onChange and committing on blur and Enter, which is also what
the hand-written console did before the rewrite.
WHAT IS COVERED
- Overview renders from a snapshot, and omits cards for absent facts rather
than printing a row of em dashes.
- A deep link into an upstream detail page renders on a COLD load. That is
the test for hash routing, which exists because fold's file server has no
SPA fallback.
- Filter and sort state round-trips through the URL, including a filtered URL
opened fresh — the property that makes "the broken upstream" a link.
- The MCP session survives navigation between routes, argument skeletons come
from the tool's inputSchema, and a method-not-found answer to prompts/list
reads as an empty capability rather than an error.
- 401 stops the poll loop instead of minting audit events; 403 names
server.introspection.groups and not the retired server.console.groups.
- Version skew: an old gateway warns, a current one is silent, a "dev" build
is not treated as stale.
- Untrusted strings, with real payloads. A federated tool named
`<img src=x onerror=...>`, an upstream error, a label, a tool result: each
asserted to render as text, leaving no element and no side effect. These
pages render attacker-influenced strings on the gateway's own origin next
to a live Bearer token, so this is the invariant that matters most.
- The token reaches no storage and no cookie, a reload signs you out, and the
same credential goes to both /api/federation and /mcp.
- Every asset the page requests is same-origin.
The gateway is mocked, deliberately. It buys the states a real one will not
produce on demand — 401, 403, skew, an empty federation, an open breaker, a
hostile tool name. It does not buy contract fidelity, and tests/gateway.ts says
so at the top and names what covers that instead, because a suite that mocked
its way to green while the real endpoint renamed a field would be worse than no
suite.
Two components gained accessible names along the way (CardGroup and JsonPane
are now named regions). That began as a way to disambiguate locators, but a
scrollable pane of output a screen-reader user can identify is worth having on
its own — and there are two of them on the test console.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This was referenced Aug 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the largest gap in
docs/design.md. 38 Playwright specs across the readpaths, the MCP session, and the invariants this page is actually held to.
They run against the built bundle through
pnpm preview, not the devserver — that server replays fold's exact response headers, so the suite
exercises the real Content-Security-Policy instead of reasoning about it.
The Bearer-token field never applied its value.
preact/compataliases React'sonChangeonto the input event, so declaringboth
onInputandonChangeleft one handler clobbering the other. Keystrokeswere swallowed,
draftnever advanced past empty, and a pasted tokenauthenticated nothing:
Against a gateway with auth on — the only configuration where that field is
even shown — the console was unusable. It shipped in #1 and is live in fold
maintoday.Nothing caught it. Typecheck, lint and every CI grep passed, and the browser
looked correct because the local dev gateway runs with auth disabled and hides
the field. Fixed by dropping
onChangeand committing on blur and Enter, whichis what the hand-written console did before the rewrite.
What is covered
securitypolicyviolationfired. CI's greps catch an inline<script>in theHTML and a
style={{}}in the source; neither would notice a dependencyinjecting a style tag at runtime.
<img src=x onerror=...>, plus an upstream error, a label, and a tool result— each asserted to render as text, leaving no element and no side effect.
This is the invariant that matters most: these pages render
attacker-influenced strings on the gateway's own origin, next to a live
Bearer token.
the same credential goes to both
/api/federationand/mcp.exists because fold's file server has no SPA fallback.
opened fresh. That property is what makes "the broken upstream" a link.
tool's
inputSchema, and a method-not-found answer toprompts/listreadsas an empty capability rather than an error.
server.introspection.groups, not the retiredserver.console.groups.devbuild is not treated as stale.
The gateway is mocked, deliberately
It buys the states a real gateway will not produce on demand: 401, 403, skew,
an empty federation, an open breaker, a server answering method-not-found, a
hostile tool name.
It does not buy contract fidelity.
tests/gateway.tssays so at the top andnames what covers that instead (
src/lib/federation.tstyped against fold'sintrospection.go, and fold's own suite grepping the vendored bundle) — becausea suite that mocked its way to green while the real endpoint renamed a field
would be worse than no suite.
Incidental
CardGroupandJsonPaneare now named regions. That started as a way todisambiguate test locators, but a scrollable pane of output that a screen-reader
user can identify is worth having on its own, and there are two of them on the
test console.
CI gets a separate
e2ejob — it needs a Chromium download the static checksdo not, and a typo should not wait on that. Runs in ~8s locally.
🤖 Generated with Claude Code