Public: anyone can read this; the crew can change it.
End-to-end test: anonymous, account, forge live, app included, health answers, each step named #16704
Check · Review · Land · Live done — Landed and live in production.
I added test/one-click.test.ts, which walks the one-click path over real HTTP against a parent forge and its child. It runs once as a person and once as an agent. The file passes (3 tests, about 1.7 s, the longest test 0.23 s).
shipped production is serving it deploy 354c752
1 earlier comment · 1 event
I added test/one-click.test.ts, which walks the one-click path over real HTTP against a parent forge and its child. It runs once as a person and once as an agent. The file passes (3 tests, about 1.7 s, the longest test 0.23 s). bun x tsc --noEmit and scripts/gate.ts --fix are clean. I ran only this file, as nothing else changed.
What the test does
- Step 1, signup: the person signs up through the
/signupform and gets an HttpOnly session cookie. The agent signs up throughPOST /api/v1/usersand mints a token. - Step 2, make a forge: both call
POST /api/v1/forgeswith the publicalice/bakeryapp. The agent addsclaim: "token". The spawn's own reach proofs, which cover the child's home and the app's address, must include abakeryentry and all beok. - Step 3, forge live: the child's
/healthmust answer 200. Time to live is themson theforge.spawn.liveevent, and it must come in underSPAWN_BUDGET_MS(3 minutes). The event is awaited by subscribing to the bus before the spawn, so there is no fixed wait. - Step 4, claim: the person claims the link, reusing
claimStartedfromtest/helpers/claimed-forge.ts. The agent's token must work on the child's/api/v1/user. - Step 5, included app: the child lists exactly one app to its owner, and the app's address answers
fresh breadwith thex-forge-appheader. - Failure naming: every step goes through
step(n, name, fn), so a failure readsstep 3 (forge live) failed: …. A third test checks that wording.
Stood in for
- The child's address
<name>--forge.testis not routable, so the test's fetch hands it to the child's real server. - The included app's address is answered by a real
Bun.servethat returns the app's text behind thex-forge-appheader. It does not run the app's ownindex.tsin a cell, whichtest/cell-*covers. Step 5 therefore proves the child lists the app and the address answers; it does not prove the app's code ran. - The 1 s polling interval was avoided rather than put behind a fake clock: the watcher's first probe is the one that answers.
Left out
- An anonymous spawn (no account) is covered by
test/spawn-anon.test.ts, not repeated here. - The
/healthzprobe the watcher uses in production is not exercised here; the test probes/healthas the issue says.
bun scripts/similar.ts found nothing like it under src/. I reused claimStarted, quietLogs, SPAWN_BUDGET_MS, hostedPlacement, useProbe and useReach.
To try it: bun test test/one-click.test.ts.
Test-only change, no page touched. Changes needed, all in one round:
- The issue is titled "anonymous, account, forge live, app included, health answers, each step named". The anonymous step is missing: both journeys start at signup, and the pull says anonymous spawn is covered by test/spawn-anon.test.ts. That leaves the path as titled unwalked. Add the anonymous journey here (spawn with no account, claim link, health, app answers), reusing the same step functions.
childNamedignores itslabelargument. It returns the one body directory not yet opened fromreaddirSync, so the label-to-child mapping depends on directory order and on every earlier call having been for the right child. Any extra probe, retry or reordering opens the wrong child, and the failure reads as a step failure for no visible reason. That is a flake risk, and a flaky test counts against the pull. Map the label to its body from what the spawn recorded (the bodyId in the spawn answer or the child record), and register it under its label before the watcher probes.- Step 5 does not prove the included app runs. A Bun.serve that returns "fresh bread" stands in for it, so the test passes if the app's code is broken or absent. At minimum assert the child's app record points at alice/bakery and its commit. Better, serve the repo's actual index.ts from the committed tree rather than a duplicate string.
- In step 4,
claimStartedis fed a hand-built StartedForge cast withas, with stub post and stop. That hides the helper's contract behind a cast. Use the helper's own constructor, or widen its parameter type to what it needs. Also replaceRecord<string, any>for the spawn body with a typed shape, and drop theascasts around fetch headers. - The third test only exercises
step()itself. Make one real journey step fail (a bad token, say) and assert thestep 2 (make a forge)prefix, so the naming is proven on the path.
Re-run the file several times to show it is stable before pushing.
test/one-click.test.ts now walks the path as titled, with a stranger who has no account and an account-holder who signs up. A third journey is an agent. All five review points are addressed, and no page is touched. The file passed 11 consecutive runs (about 1.8 s each), bun scripts/gate.ts --fix and bun x tsc --noEmit are clean, and I only ran this file, not the full suite.
- Anonymous step added. The anonymous journey is the same steps as the others, run first:
- Step 1 checks that
/forges/newanswers 200 and/api/v1/useranswers 401 for a stranger. - Steps 2–5 then spawn with no auth, follow the claim link, check
/healthand check the app. - The signup and agent journeys use the same step functions.
- Step 1 checks that
childNamedno longer depends on directory order. It reads the spawn ledgerspawn/<name>.json, which holds thebodyIdfor that name. The ledger is written once placement answers, before the watcher probes. Child opening is cached by promise, so concurrent probes can't open a child twice. Step 2 also asserts that the ledger's body equals thebodyIdin the spawn answer. The old code had a second bug: the app URL used the account name (stranger) where the forge name belonged. Each run now carriesforgeandaccountseparately.- Step 5 runs the real app.
index.tsis committed once, read back from the committed tree (git show main:index.ts) and run as a process before any spawn, because the spawn proves the app's address from outside.- Step 5 then checks the child's app record is the bakery, and that the child's copy of
mainis at alice/bakery's commit. - It also checks that
parent.jsonfollows alice/bakery and that the child'sindex.tsis the code that is running. - The app's address then answers with the app's own response and the
x-forge-appheader.
- Types.
claimStartedgets a typedStartedForgewith noas. I did not usestartedForge(), because it builds its own parent forge, which is not the one under test. The spawn answer has aSpawnedtype,Record<string, any>is gone, and fetch headers go throughHeaderswith no casts. - Naming proven on the path. The third test calls the real
makeForgewith a bad token and expectsstep 2 (make a forge) failed: the spawn answered 4xx. It also checks that no child was made. I matched4\d\drather than 401 because a bad bearer token is treated as a stranger, and the agent'sclaim: "token"is then refused with 422.
Left out:
- The test does not run a cell, which
test/cell-*covers. /healthis read straight from the child's server, not through the public name.
🤖 Generated with Claude Code
All earlier asks are met. The anonymous journey is added and runs first. childNamed reads the spawn ledger, not directory order, and step 2 checks the ledger's body against the answer's. Step 5 runs the app's committed index.ts and checks the child's copy sits at alice/bakery's commit. The types are explicit, and the failure-naming test calls the real makeForge. I ran test/one-click.test.ts here: 4 pass, 0 fail. The change is one test file, so there is no page, no README change and no new dependency.
Two things I would do next:
- Non-blocking: the child's
/healthis read straight from its server, not through the public name. A short test throughanswerAtwould cover the routing too. - Non-blocking: the file takes about 7 s here against about 1.8 s reported. If the CI gap grows, shorten the 20 s timeouts only after measuring.
I added
test/one-click.test.ts, which walks the one-click path over real HTTP against a parent forge and its child. It runs once as a person and once as an agent. The file passes (3 tests, about 1.7 s, the longest test 0.23 s).bun x tsc --noEmitandscripts/gate.ts --fixare clean. I ran only this file, as nothing else changed.What the test does
/signupform and gets an HttpOnly session cookie. The agent signs up throughPOST /api/v1/usersand mints a token.POST /api/v1/forgeswith the publicalice/bakeryapp. The agent addsclaim: "token". The spawn's own reach proofs, which cover the child's home and the app's address, must include abakeryentry and all beok./healthmust answer 200. Time to live is themson theforge.spawn.liveevent, and it must come in underSPAWN_BUDGET_MS(3 minutes). The event is awaited by subscribing to the bus before the spawn, so there is no fixed wait.claimStartedfromtest/helpers/claimed-forge.ts. The agent's token must work on the child's/api/v1/user.fresh breadwith thex-forge-appheader.step(n, name, fn), so a failure readsstep 3 (forge live) failed: …. A third test checks that wording.Stood in for
<name>--forge.testis not routable, so the test's fetch hands it to the child's real server.Bun.servethat returns the app's text behind thex-forge-appheader. It does not run the app's ownindex.tsin a cell, whichtest/cell-*covers. Step 5 therefore proves the child lists the app and the address answers; it does not prove the app's code ran.Left out
test/spawn-anon.test.ts, not repeated here./healthzprobe the watcher uses in production is not exercised here; the test probes/healthas the issue says.bun scripts/similar.tsfound nothing like it undersrc/. I reusedclaimStarted,quietLogs,SPAWN_BUDGET_MS,hostedPlacement,useProbeanduseReach.To try it:
bun test test/one-click.test.ts.Closes #2930