@lago-morph/create-prototype-app 0.1.1 → 0.2.0-rc02

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,44 @@
1
+ # End-to-end tests
2
+
3
+ Read this when you add or change a flow (something a person or an operator does from start to finish), after a framework upgrade, or when an e2e test fails or must change.
4
+
5
+ ## What e2e covers
6
+
7
+ Every user-facing flow, on its **happy path**, its **expected errors** and its **edge cases**. A flow is not done until all three are covered end to end. When a flow changes, change its e2e tests in the same work; after `npm run upgrade`, run them and fix what the release changed. A change to an e2e test that passed before is listed with its reason like any other ([test-changes.md](test-changes.md)).
8
+
9
+ ## API first, a few UI tests
10
+
11
+ The template ships two Playwright projects (`playwright.config.ts`), against a local `dev` server that Playwright starts and stops:
12
+
13
+ - **`e2e-api`** (`tests/e2e/api/*.spec.ts`): most e2e tests. They drive the app's HTTP API with Playwright's `request` fixture, which needs no browser. `npm run verify` runs this project after the unit tests; `npm run test:e2e:api` runs it alone.
14
+ - **`e2e-ui`** (`tests/e2e/ui/*.spec.ts`): only what a browser alone shows: a page renders the data, the login button signs in, a file uploads or downloads from the page, a cookie is set. At most a few per flow; every other case of the flow is an API test. `npm run test:e2e:ui` runs it; only this project needs Chromium (`npm exec --no -- playwright install chromium` once, when the user agrees). If Chromium cannot be installed, report the UI run as `not-run` with the reason (hard rule 8) and do not declare the page done.
15
+
16
+ The config hides the server's own log. If the server does not start (Playwright times out waiting for it), run `npm run dev` to see why.
17
+
18
+ Write a spec from the flow, not from the code:
19
+
20
+ - Requests go to paths (`/api/notes`); the config sets the base URL and the `Origin` header the framework's forgery check needs.
21
+ - Sign in as a test identity with the authentication mock, which every local server has: `` await request.post("/api/auth/mock-login", { data: { level: "user", id: `e2e-${crypto.randomUUID()}` } }) ``. Use a fresh ID per test: local data is kept between runs, so never assert totals.
22
+ - Check status codes and `(await res.json()).error.code`, never messages.
23
+ - In UI specs, find elements by role and visible text (`page.getByRole("button", { name: "Log in" })`).
24
+ - Never wait in real time, and never test expiry here: use fake timers in-process ([../testing.md](../testing.md)).
25
+ - `playwright.config.ts` is part of the gate: a change to it that could run fewer tests or pass more easily (projects, `testIgnore`, `retries`, timeouts) is listed like a change to a once-green test ([test-changes.md](test-changes.md)).
26
+
27
+ ## Edge cases
28
+
29
+ Before writing a flow's tests, list its edge cases in the spec's header comment, and cover each that applies; for each prompt that does not apply, say why in a few words:
30
+
31
+ - **Boundaries:** empty, one, exactly at a documented limit, one past it. Locally only; on a cloud, keep data small.
32
+ - **Text:** Unicode, case and normalisation; `..`, `/` and percent-encoding in names; one name a prefix of another.
33
+ - **Order and time:** sort order and paging; expiry at and just past the limit (fake `Date`, in-process).
34
+ - **Access:** anonymous, user, admin, and another user's data.
35
+ - **Repetition:** repeated and concurrent requests; reuse of one-time links or tickets.
36
+ - **Failures:** an unavailable capability (in-process with `setUnavailable`); local versus cloud differences.
37
+
38
+ ## Examples
39
+
40
+ - [examples/tests.md](../../examples/tests.md): the template's tests, including its e2e specs.
41
+
42
+ ## Stopping condition
43
+
44
+ Stop reading when every flow you added or changed has API tests for its happy path, expected errors and listed edge cases, at most a few UI tests for what only a browser shows, and `npm run verify` (and `npm run test:e2e:ui` if you changed a page) passes.
@@ -0,0 +1,44 @@
1
+ # Diagnosing a failure
2
+
3
+ Read this when a test, `verify`, an e2e run, a build, a deploy or a smoke test fails, other than a test that is red on purpose during red/green, or when you are asked to diagnose, review or fix such a failure.
4
+
5
+ "Probably", "flaky" and "timing" are not causes without evidence. Never change a test or the code to make the failure go away before its cause is reviewed.
6
+
7
+ ## Who does what
8
+
9
+ Each role is its own subagent. None of them wrote the code that failed, and the reviewer never reviews a cause it found itself. The main session briefs them with file paths, not file contents, and they answer with short summaries; the details go in the record.
10
+
11
+ ## The record
12
+
13
+ One record per failure, in the app's repository: `test-records/root-causes/<yyyy-mm-dd>-<slug>.md`. Its sections, in this order:
14
+
15
+ 1. **Symptom**: the exact command and output.
16
+ 2. **Evidence**: logs (`.logs/`, or the stage's log entry for the `requestId`, [troubleshooting.md](../troubleshooting.md)), requests and responses, state, variations of the test that confirm or rule out each hypothesis, and a minimal reproduction.
17
+ 3. **Causal chain**, with the evidence for each link.
18
+ 4. **Alternatives ruled out.**
19
+ 5. **Proposed fix.**
20
+ 6. **Verification plan.**
21
+ 7. **Review**, which the reviewer writes. Until then the record says `Status: awaiting review`.
22
+
23
+ An unproven link means more evidence, never a guess.
24
+
25
+ ## Steps
26
+
27
+ 1. **Diagnose.** The diagnoser reproduces the failure, gathers the evidence and writes the record.
28
+ 2. **Review.** The reviewer checks that the evidence supports every link, that the alternatives are ruled out, and that the fix addresses the cause, not the symptom. Its verdict is `accepted` or `rejected`, with reasons. A rejected record goes back to step 1.
29
+ 3. **Fix, red then green.** A fixer adds the reproduction test, sees it fail, then fixes the code as the accepted record says, and sees it pass. Where the same defect is plainly in other code it is changing, it fixes and tests that too.
30
+ 4. **Re-check.** A subagent that changed nothing re-runs the affected tests and `npm run verify`, and checks that no test was skipped or weakened. Its verdict is the only pass.
31
+
32
+ ## Limits
33
+
34
+ - At most **3 attempts** (steps 1–4) per failure.
35
+ - Still open after 3 attempts: stop and tell the user, in plain words, what fails, what was tried, and the record's path.
36
+ - A suspected framework defect goes to `FRAMEWORK-ISSUE.md` (`SKILL.md` hard rules 6 and 7), with the record as its evidence.
37
+
38
+ ## Examples
39
+
40
+ - [examples/tests.md](../../examples/tests.md): the tests a reproduction test is added beside.
41
+
42
+ ## Stopping condition
43
+
44
+ Stop reading when the failure has an accepted record and its fix passed the re-check, or when it stopped at the limits and you told the user.
@@ -0,0 +1,28 @@
1
+ # Fuzzing a route input
2
+
3
+ Read this when a route takes input at a trust boundary (a name, a cursor, a return path, a code or token, a request body) and its example tests keep missing cases, or the same route has failed more than once.
4
+
5
+ ## Where it is worth it
6
+
7
+ Fuzzing is **local, limited and targeted**. Use it only where it finds what example tests would miss:
8
+
9
+ - a parser, validator or encoder at a trust boundary;
10
+ - especially a route with repeated failures (see its records under `test-records/root-causes/`).
11
+
12
+ Having a zod schema makes a route eligible, not required. Never fuzz every route, never run long or exhaustive runs, and never fuzz a deployed stage. Fuzzing never replaces the route's example tests ([../testing.md](../testing.md)).
13
+
14
+ ## The template's helper
15
+
16
+ `tests/support/fuzz.ts` drives a route from its zod schema with the `fast-check` package (pinned, hard rule 5): it sends generated bodies, both valid and invalid for the schema, and checks that the route never answers a server error, answers 400 `HTTP.INVALID_INPUT` when the schema rejects the body, and never answers it when the schema accepts the body (the route's own rules may still refuse it, for example with 404 or 409). Each use states its run count and fixed seed, with a one-line reason, so a run is small and repeatable and adds only seconds to `verify`. See `tests/fuzz.test.ts` for the template's one use.
17
+
18
+ ## A finding
19
+
20
+ A failing run prints the seed and the smallest body that fails. Treat it as any failure ([failures.md](failures.md)), and add that body as a plain example test before the fix.
21
+
22
+ ## Examples
23
+
24
+ - [examples/tests.md](../../examples/tests.md): the in-process tests the helper runs beside.
25
+
26
+ ## Stopping condition
27
+
28
+ Stop reading when you have decided the route does not qualify, or its fuzz test states its run count, seed and reason, passes in `npm run verify`, and any finding is a plain regression test.
@@ -0,0 +1,42 @@
1
+ # Test impact and changes to passing tests
2
+
3
+ Read this when a change needs new, changed or removed tests, or you are about to change, remove, skip or loosen a test that has passed before.
4
+
5
+ ## Test impact of every change
6
+
7
+ Before you change code, write down its test impact and then make it, in the same work, without being asked:
8
+
9
+ - the unit and in-process tests to add, change or remove;
10
+ - the e2e tests to add, change or remove ([e2e.md](e2e.md));
11
+ - any fuzz target affected ([fuzzing.md](fuzzing.md)).
12
+
13
+ When you report to the user, list the test impact and each change to an existing test with its reason code (below).
14
+
15
+ ## Changes to a once-green test
16
+
17
+ A test is **once-green** when it passed in this session or is on the app's main branch. This covers every layer: unit, in-process, e2e, smoke and fuzz.
18
+
19
+ - **What to list:** any change to its expected results or assertions, its removal, a skip (`.skip`, `.todo`, a condition that stops it running), a wider tolerance or timeout, or a renamed or merged test that checks less. List each one, grouped by reason code (below), when you report to the user.
20
+ - **Never weaken a test to pass.** A test you think is wrong is a failure to diagnose ([failures.md](failures.md)); the reason code is then `test-was-wrong`, citing the record.
21
+
22
+ ## Reason codes
23
+
24
+ Group the changes and give each group one code:
25
+
26
+ | Code | When | Cite |
27
+ | --- | --- | --- |
28
+ | `code-removed` | the code or feature it tests is gone | the user's request or the change that removed it |
29
+ | `behaviour-changed` | the app's intended behaviour changed | the requirement or the user's request |
30
+ | `test-was-wrong` | the test asserted the wrong thing | its root-cause record |
31
+ | `strengthened` | it now checks more | — |
32
+ | `refactor-only` | same checks, new shape | — |
33
+
34
+ A test weakened while the code it covers stayed the same needs a clear reason in the list; if you can't give one, it is a failure to diagnose ([failures.md](failures.md)).
35
+
36
+ ## Examples
37
+
38
+ - [examples/tests.md](../../examples/tests.md): the template's tests, which a change set extends.
39
+
40
+ ## Stopping condition
41
+
42
+ Stop reading when the change's test impact is written down and done, and every change to a once-green test is listed with its reason.
@@ -1,50 +1,61 @@
1
1
  # Testing
2
2
 
3
- Read this when you write or fix app tests, write the smoke test, test time-dependent behaviour, or need to know what `verify` and `smoke` run.
3
+ Read this when you write or fix app tests, write the smoke test or the e2e tests, test time-dependent behaviour, or need to know what `verify`, the e2e projects and `smoke` run.
4
4
 
5
- ## What runs your tests
5
+ ## How you work on tests
6
6
 
7
- - `npm run verify` runs every `tests/**/*.test.ts` file (PAR-116) with Vitest twice, once on SQLite and once on Postgres, each in its own process, with 60 s test and hook timeouts. It fails if any test fails or if no test passed. Tests must need no network.
8
- - `npm run smoke -- --target <t> --stage <s>` runs only `tests/smoke/**/*.test.ts`, against the running `dev` server (`--target local`) or against a deployed **test** stage (a stage whose name starts with `test-`). It refuses to run when tracked files differ from the last commit (the evidence record names the commit), writes an evidence record to `validation/<target>/<runId>.json` at the top of the git repository that holds the app (the app directory when the app is its own repository; commit the record with the run's commit), and prints the stage's log location for the day.
7
+ These hold for every change, without asking the user technical questions. Explain results to the user in plain words.
8
+
9
+ - **Red, green, refactor.** For app logic, write one failing test first, run it and see it fail for the expected reason, then write the code, then tidy up. Every fix starts with a test that reproduces the failure and fails.
10
+ - **State each change's test impact** and make the test changes in the same work: the unit, integration and e2e tests to add, change or remove, and any fuzz target ([testing/test-changes.md](testing/test-changes.md)).
11
+ - **Keep e2e current.** A flow is not done until its happy path, its expected errors and its edge cases are covered end to end. When a flow changes, and after a framework upgrade, update its e2e tests ([testing/e2e.md](testing/e2e.md)).
12
+ - **A failure is diagnosed before anything changes.** Any failure other than a test that is red on purpose gets an evidence-based root cause from a subagent that did not write the code, an independent review, and only then a red-green fix ([testing/failures.md](testing/failures.md)). "Flaky" or "timing" is not a cause without evidence.
13
+ - **Never skip, delete or weaken a test to get a pass.** Any change to a test that passed once (its expected results, its removal, a skip, a wider tolerance or timeout) is listed with its reason when you report ([testing/test-changes.md](testing/test-changes.md)).
14
+ - **Orchestrate.** The main session briefs subagents, in parallel where they touch different files, and keeps its own context small, unless the user says otherwise. Roles that must be separate: the code's author never diagnoses or reviews its own failure.
15
+ - **CI is the user's.** Installing or upgrading the framework never creates or changes the app's CI. You may suggest a CI change to the user, who decides. Apps have no commit hooks: run the checks yourself.
16
+
17
+ ## The layers
18
+
19
+ | Layer | What | Where | Runs with |
20
+ | --- | --- | --- | --- |
21
+ | Unit and integration | App logic and routes, in process, with real local storage on both SQL dialects | `tests/**/*.test.ts` | `npm run verify` |
22
+ | E2E, API | Each flow through the running app's HTTP API | `tests/e2e/api/*.spec.ts` | `npm run verify` (project `e2e-api`, no browser) |
23
+ | E2E, UI | What only a browser shows: page rendering, the login button, file transfer in the page, cookies; a few per flow | `tests/e2e/ui/*.spec.ts` | `npm run test:e2e:ui` (project `e2e-ui`, needs Chromium) |
24
+ | Fuzz | A route input at a trust boundary, from its zod schema, only where [testing/fuzzing.md](testing/fuzzing.md) says | `tests/**/*.test.ts` | `npm run verify` |
25
+ | Smoke | A short check on a deployed `test-` stage | `tests/smoke/**/*.test.ts` | `npm run smoke` |
26
+
27
+ - `npm run verify` runs every `tests/**/*.test.ts` file (PAR-116) with Vitest twice, once on SQLite and once on Postgres, each in its own process, with 60 s test and hook timeouts, then the `e2e-api` project against a local `dev` server it starts. It fails if any test fails or if no test passed. Tests need no network.
28
+ - `npm run smoke -- --target <t> --stage <s>` runs only `tests/smoke/**/*.test.ts`, against the running `dev` server (`--target local`) or against a deployed **test** stage. It refuses to run when tracked files differ from the last commit, writes an evidence record to `validation/<target>/<runId>.json` at the top of the git repository that holds the app (commit it with the run's commit), and prints the stage's log location for the day.
9
29
  - An app is not done on a cloud until its smoke test has passed on a deployed stage there.
10
- - Your tests and your smoke test reach the app only through its API; behaviour that exists only in the page (how text renders, the clipboard, an image displaying) is checked by the framework's browser tests, not the app's, so keep page text to `textContent` (`no-raw-html`), test the API side, and do not add a browser driver or raise this as a framework issue.
11
30
 
12
31
  ## In-process tests
13
32
 
14
33
  Import from `@lago-morph/prototype-framework/testing` (only in `tests/**`):
15
34
 
16
- - `await createTestApp(app, options?)` starts your app in the test process with fresh, empty storage and migrations applied. Options: `user` (identity for every request, default anonymous), `config` (override declared values; `framework` takes `{ admins?, users? }`), `secrets` (values), `unavailable` (e.g. `["sql"]`: every operation of that capability fails with its `*.UNAVAILABLE` code), `stubLoginProvider` (see [current-user.md](current-user.md)). Failures are simulated per capability, not per operation: `unavailable` holds from creation, and `t.setUnavailable([...])` replaces the set from the next request on (for `t` and every app made from it with `as`; `t.setUnavailable([])` makes everything available again; stored data is kept). So to test that a failed cleanup is logged and the request still succeeds, create the data first (for example a post with a stored photo), then call `t.setUnavailable(["files"])`, run the request that cleans up, and check its status and the `warn` entry in `t.logs()`. With one `try/catch` around the whole cleanup, as in the template-style code, every failure in it takes that path. `setUnavailable` is not available against a deployed stage.
35
+ - `await createTestApp(app, options?)` starts your app in the test process with fresh, empty storage and migrations applied. Options: `user` (identity for every request, default anonymous), `config` (override declared values), `secrets` (values), `unavailable` (e.g. `["sql"]`: every operation of that capability fails with its `*.UNAVAILABLE` code), `authAppLoginProvider` (see [current-user.md](current-user.md)). `t.setUnavailable([...])` replaces the unavailable set from the next request on (`[]` makes everything available again; stored data is kept), so a test can store data, make `files` unavailable, run the request that cleans up, and check its status and the `warn` entry in `t.logs()`. Not available against a deployed stage.
17
36
  - `await t.request("/api/notes", init?)` sends a request and returns a `Response`. Include `/api` in the path. For JSON bodies set `headers: { "content-type": "application/json" }` and `body: JSON.stringify(…)`. State-changing requests get the right `Origin` automatically.
18
- - `t.as(mockUsers.user("alice"))` returns a test app that sends requests as Alice and shares storage with `t`; use two of them to test that one user cannot see another's data. `mockUsers.admin(id?)` and `mockUsers.anonymous` likewise. In-process, `t` and every test app made from it with `as` share one app: disposing any of them disposes all, and later requests through any of them throw. Dispose them only at the end of the test, as the examples do. On a deployed stage, disposing one only logs it out.
19
- - `t.logs()` returns the log entries written so far ([log.md](log.md)).
20
- - `await t.dispose()` after each test (an `afterEach` that disposes every test app the test opened, as in the examples).
37
+ - `t.as(mockUsers.user("alice"))` returns a test app that sends requests as Alice and shares storage with `t`; use two of them to test that one user cannot see another's data. `mockUsers.admin(id?)` and `mockUsers.anonymous` likewise. `t` and every test app made from it share one app: dispose them only at the end of the test.
38
+ - `t.logs()` returns the log entries written so far ([log.md](log.md)). `await t.dispose()` after each test.
21
39
 
22
- What to test for each route: the success case with its body; anonymous (401 `AUTH.UNAUTHENTICATED`) and, for admin routes, a plain user (403 `AUTH.FORBIDDEN`); invalid input (400 `HTTP.INVALID_INPUT`); another user's data (not visible, usually 404 `HTTP.NOT_FOUND` or an empty list); and the error codes your route throws. Check error codes through `(await res.json()).error.code`, never through messages.
23
-
24
- Type response bodies with the shared types: `const body: NoteList = await res.json();`.
40
+ What to test for each route: the success case with its body; anonymous (401 `AUTH.UNAUTHENTICATED`) and, for admin routes, a plain user (403 `AUTH.FORBIDDEN`); invalid input (400 `HTTP.INVALID_INPUT`); another user's data (not visible, usually 404 `HTTP.NOT_FOUND` or an empty list); and the error codes your route throws. Check error codes through `(await res.json()).error.code`, never through messages. Type response bodies with the shared types: `const body: NoteList = await res.json();`.
25
41
 
26
42
  ## Time-dependent behaviour
27
43
 
28
- Expiry and other time checks (share-link expiry, "edited within an hour") are tested in-process with Vitest's fake timers, because the framework's own time checks run in the test process too: `vi.useFakeTimers({ toFake: ["Date"] })`, then `vi.setSystemTime(…)` or `vi.advanceTimersByTime(…)`, and `vi.useRealTimers()` afterwards. Fake only `Date`, as the framework's own session-expiry tests do, so other timers keep running. Never test expiry in the smoke test, and never wait in real time.
44
+ Expiry and other time checks are tested in-process with Vitest's fake timers: `vi.useFakeTimers({ toFake: ["Date"] })`, then `vi.setSystemTime(…)` or `vi.advanceTimersByTime(…)`, and `vi.useRealTimers()` afterwards. Fake only `Date`. Never test expiry in the smoke or e2e tests, and never wait in real time.
29
45
 
30
46
  ## The smoke test
31
47
 
32
- One file under `tests/smoke/` runs both ways:
33
-
34
- - Under `verify`, it is an ordinary in-process test (`createTestApp`).
35
- - Under `smoke`, `inject("prototypeFrameworkSmoke")` is `true` and it uses `connectTestStage()`, which connects to the stage `smoke` targets and logs in through the authentication mock.
48
+ One file under `tests/smoke/` runs both ways: under `verify` it is an ordinary in-process test (`createTestApp`); under `smoke`, `inject("prototypeFrameworkSmoke")` is `true` and it uses `connectTestStage()`, which connects to the stage `smoke` targets and logs in through the authentication mock.
36
49
 
37
50
  Keep it short: the health route (`GET /api/__framework/health` answers 204), one open route, and one write-then-read per capability your app depends on. Use a fresh mock user per run (`` mockUsers.user(`smoke-${crypto.randomUUID()}`) ``) because stage data is kept between runs; do not assert totals that earlier runs would change. `logs()` is not available against a stage. Copy the template's file and change the routes ([examples/tests.md](../examples/tests.md)).
38
51
 
39
- `t.request` sends only to the app: a URL on any other origin is refused before anything is sent, on both test apps, so the stage's session cookie never leaves the stage. An upload or download ticket a route returns is JSON `{ url, method?, headers?, expiresAt }` on every target. Locally and in-process its `url` is a path on the app, sent with `t.request(url, { method, headers, body })`; on a cloud it is an absolute signed storage URL, sent with plain `fetch(url, { method: ticket.method ?? "GET", headers: ticket.headers, body })` and no cookie. Choose with `/^\/(?![\/\\])/.test(ticket.url) ? t.request(…) : fetch(…)`, so `//host` and `/\host` URLs go to `fetch` too. Behind a proxy, `smoke` needs `NODE_USE_ENV_PROXY=1` for that `fetch`.
40
-
41
- To run it on a cloud, deploy a test stage first, for example `npm run deploy -- --target cloudflare --stage test-1`, then `npm run smoke -- --target cloudflare --stage test-1`, and remove the stage afterwards ([deploying.md](deploying.md)). Test stages use `config/<target>/test.json` and the authentication mock and hold no real data.
52
+ `t.request` sends only to the app; a URL on any other origin is refused. A ticket's `url` is a path on the app locally (send it with `t.request`) and an absolute signed storage URL on a cloud (send it with plain `fetch`, no cookie): choose with `/^\/(?![\/\\])/.test(ticket.url)`. Behind a proxy, `smoke` needs `NODE_USE_ENV_PROXY=1` for that `fetch`. To run it on a cloud, deploy a test stage, run `npm run smoke -- --target cloudflare --stage test-1`, then remove the stage ([deploying.md](deploying.md)).
42
53
 
43
54
  ## Failures
44
55
 
45
56
  - A test that passes on SQLite but fails on Postgres (or the reverse) uses something the portable subset does not promise: check ordering (end with the `id` column), NULL handling and text comparison ([sql-and-migrations.md](sql-and-migrations.md)).
46
57
  - A framework `error` entry printed to stderr during a test shows the real cause of a 500 response.
47
- - A failing deployed smoke test prints the method, path, status, error code and request ID; find the request's entry with [troubleshooting.md](troubleshooting.md).
58
+ - A failing deployed smoke test prints the method, path, status, error code and request ID; find the request's entry with [troubleshooting.md](troubleshooting.md). Then follow [testing/failures.md](testing/failures.md).
48
59
 
49
60
  ## Examples
50
61
 
@@ -52,4 +63,4 @@ To run it on a cloud, deploy a test stage first, for example `npm run deploy --
52
63
 
53
64
  ## Stopping condition
54
65
 
55
- Stop reading when each route has tests for success, access level, invalid input and other users' data, the smoke test covers each capability you use, and `npm run verify` passes on both dialects. For deploying and running the smoke test on a cloud, read [deploying.md](deploying.md).
66
+ Stop reading when each route has tests for success, access level, invalid input and other users' data, each flow has its e2e tests, the smoke test covers each capability you use, and `npm run verify` passes on both dialects. For a failure, an e2e test, a test change or fuzzing, read the one file under `testing/` linked above.
@@ -35,7 +35,7 @@ The date and time are UTC. `smoke` prints today's prefix.
35
35
 
36
36
  **Dashboard (no setup; these menu names are not yet verified).** Open Storage & databases → R2 → `prototype-logs`. Then open the folders `<app>` / `<stage>` / year / month / day. The file name ends in the request ID. Open the file and choose Download to read it.
37
37
 
38
- **Command line, only where both values are in the environment.** These commands need `CLOUDFLARE_ACCOUNT_ID` and `CLOUDFLARE_API_TOKEN` in the shell's environment, for example in a cloud session whose environment settings hold them. When the tokens are only in `.env.cloudflare` (the usual case, [owner-tasks.md](owner-tasks.md) §2), the variables are empty and the requests fail: use the dashboard route above instead. Never `source`, `cat` or otherwise read `.env.cloudflare` to fill them in. These two `curl` commands are **verified on Cloudflare**: on a real test stage, the list command found a failed request's key and the read command returned its `CORE.INTERNAL` entry (E2E-011, Cloudflare pass 2–5; the framework repository's `validation/cloudflare/pass-2to5/SUMMARY.md` and `logs/5-trouble.log`). List one day's keys:
38
+ **Command line, only where both values are in the environment.** These commands need `CLOUDFLARE_ACCOUNT_ID` and `CLOUDFLARE_API_TOKEN` in the shell's environment, for example in a cloud session whose environment settings hold them. When the token is only in `~/.secrets/cloudflare` (the usual case on a computer, [owner-tasks.md](owner-tasks.md) §2), the variables are empty and the requests fail: use the dashboard route above instead. Never `source`, `cat` or otherwise read `~/.secrets/cloudflare` (or an old `.env.cloudflare`) to fill them in. These two `curl` commands are **verified on Cloudflare**: on a real test stage, the list command found a failed request's key and the read command returned its `CORE.INTERNAL` entry (E2E-011, Cloudflare pass 2–5; the framework repository's `validation/cloudflare/pass-2to5/SUMMARY.md` and `logs/5-trouble.log`). List one day's keys:
39
39
 
40
40
  ```sh
41
41
  STAGE='<stage>'; DAY=$(date -u +%Y/%m/%d)
@@ -70,7 +70,7 @@ Not yet verified on Cloudflare in this phase.
70
70
  ```sh
71
71
  npx wrangler tail "$APP-$STAGE" --format pretty
72
72
  ```
73
- It needs `CLOUDFLARE_API_TOKEN` and `CLOUDFLARE_ACCOUNT_ID` in the shell's environment, as the `curl` commands above do; with the tokens only in `.env.cloudflare`, use the dashboard instead (Workers & Pages → `<app>-<stage>` → Logs, menu names not yet verified). Not yet verified on Cloudflare in this phase.
73
+ It needs `CLOUDFLARE_API_TOKEN` and `CLOUDFLARE_ACCOUNT_ID` in the shell's environment, as the `curl` commands above do; with the token only in `~/.secrets/cloudflare`, use the dashboard instead (Workers & Pages → `<app>-<stage>` → Logs, menu names not yet verified). Not yet verified on Cloudflare in this phase.
74
74
  - If entries are printed as lines starting `[prototype-framework:log]` in `wrangler tail`, the Worker has no `LOGS` binding. Run `deploy` again.
75
75
  - Locally, entries reach `.logs/` only while `npm run dev` runs. In-process tests write no files.
76
76
 
@@ -93,27 +93,24 @@ Each code's meaning, HTTP status and whether it is retryable are in the framewor
93
93
 
94
94
  ## 3. Login failures
95
95
 
96
- Every stage signs people in with email and password. A failed attempt writes one `warn` entry from `AUTH`, `login failed: <reason>`, never the address (§1):
96
+ Production stages sign people in with Cloudflare, through the account's auth app. A failed sign-in returns to `/?authError=login_failed&requestId=<id>` and writes one `warn` entry from `AUTH`, `login failed: <reason>`, never an address or code (§1):
97
97
 
98
- - `wrong credentials`: unknown address or wrong password (both get the same answer). Use "Forgot your password?" on the sign-in page.
99
- - `not verified`: the address is not confirmed yet. Open the link in the "Confirm your email address" mail, or use "Send a new confirmation link".
100
- - `rate limited`: too many attempts from one network address; wait a minute (sign-in) or five minutes (sign-up, forgot, resend).
101
- - `invalid token`: the mailed link was used already or expired (confirmation 24 hours, reset 1 hour). Ask for a new one.
102
- - `provider unavailable (<code>)`: the database was not reachable; retry.
98
+ - `transaction missing or expired`: the sign-in took too long, or cookies are blocked. Sign in again.
99
+ - `state mismatch`: two sign-ins ran at once in one browser. Sign in again.
100
+ - `provider refused`: Cloudflare or the auth app refused. Most often the person is not a member of the owner's Cloudflare account: invite them (Manage Account → Members, [owner-tasks.md](owner-tasks.md) §6).
101
+ - `code refused`: the one-time code was used, expired, or issued to another app or stage. Sign in again; if it repeats, deploy the stage again so the auth app knows its address.
102
+ - `auth app unavailable`: the auth app or its database was not reachable; retry. If it repeats, check on the admin app's Status page that the auth app is set up.
103
103
 
104
- No mail arrives:
105
- - Locally nothing is sent: read `.mail/` with `npm run mail -- last --to '<address>'`. On a test stage the mail is captured, not sent.
106
- - On a production stage, look for a `MAIL` entry `mail send failed: <code>` (§1). The sender is `no-reply@<domain>`; if `deploy` or setup said the domain is not verified for sending, run `npm run cloudflare-setup` again.
107
- - A test address `sink+<tag>@t.<domain>`: read it with `npm run mail -- last --to '<address>' --target cloudflare`. Only `sink+…` addresses reach the test mailbox. Right after setup created the mailbox rule, a send may be rejected for a minute.
104
+ Signed out after a while, with a `warn` entry `role refresh failed (<code>)`: the app could not confirm the person's role with the auth app, so it ended the session. Sign in again once the auth app answers.
108
105
 
109
- Signed in, but not admin: the `admin` role is granted per stage with `admins grant` ([owner-tasks.md](owner-tasks.md) §7); check with `admins list`.
106
+ Signed in, but not admin (or still admin): the level comes from the person's role in the Cloudflare account ([owner-tasks.md](owner-tasks.md) §7), recorded when they last signed in. Log out and sign in again after the role changes.
110
107
 
111
108
  ## 4. Deploy, remove and setup failures
112
109
 
113
110
  `deploy` prints the failed step, the stage's state and the next action. Follow the next action. Common messages:
114
111
 
115
- - `run setup-account … first`: the account's shared resources are missing. Run `npm run cloudflare-setup` ([owner-tasks.md](owner-tasks.md) §2).
116
- - A missing `CLOUDFLARE_API_TOKEN` or `CLOUDFLARE_ACCOUNT_ID`, a missing permission, or "R2 signing credential … missing": run `npm run cloudflare-setup`, which says what to fix ([owner-tasks.md](owner-tasks.md) §2). "Account API Tokens Write" is the bootstrap token's only.
112
+ - `run npm run cloudflare-setup first` (older releases: `run setup-account … first`), or the account's auth app is missing: run `npm run cloudflare-setup` ([owner-tasks.md](owner-tasks.md) §2). It names what is missing and sets the account up.
113
+ - A missing `CLOUDFLARE_API_TOKEN` or `CLOUDFLARE_ACCOUNT_ID`, a missing permission, or "R2 signing credential … missing": run `npm run cloudflare-setup`, which says what to fix ([owner-tasks.md](owner-tasks.md) §2). Setup names each permission the token lacks; add it to the token in the dashboard, or make a new token from setup's link.
117
114
  - `NODE_USE_ENV_PROXY`: you are behind an HTTPS proxy. Put `NODE_USE_ENV_PROXY=1 ` in front of the command.
118
115
  - `required secrets are not set: …`: this happens on the first deploy of a stage. Set each named secret with `--target cloudflare`, then run `deploy` again.
119
116
  - An error about the number of D1 databases: an account holds at most 10, and a schema-changing deploy briefly holds two per stage. Remove unused test stages ([deploying.md](deploying.md)).
@@ -5,6 +5,6 @@ Files you copy and fill in. The app itself comes from the scaffolder: `skill/scr
5
5
  | File | Copy to | Fill in |
6
6
  | --- | --- | --- |
7
7
  | [FRAMEWORK-ISSUE.md](FRAMEWORK-ISSUE.md) | `FRAMEWORK-ISSUE.md` at the app's root, when you first suspect a framework defect | One numbered entry per defect, every field (router, hard rules 6 and 7) |
8
- | [production-stage.json](production-stage.json) | `config/<target>/<stage>.json` for each production stage, for example `config/cloudflare/prod.json` | `values` for keys without defaults; the email sender's display name (`framework.email.senderName`, or remove `email` to use the app name). No admins: they get the `admin` role with `admins grant` ([configuration.md](../reference/configuration.md), [owner-tasks.md](../reference/owner-tasks.md)) |
8
+ | [production-stage.json](production-stage.json) | `config/<target>/<stage>.json` for each production stage, for example `config/cloudflare/prod.json` | `values` for keys without defaults. No admins: they are the Cloudflare account's administrators ([configuration.md](../reference/configuration.md), [owner-tasks.md](../reference/owner-tasks.md)) |
9
9
 
10
10
  Test stages need no new file: every `test-*` stage uses the template's `config/<target>/test.json`.
@@ -1,6 +1,4 @@
1
1
  {
2
2
  "values": {},
3
- "framework": {
4
- "email": { "senderName": "REPLACE-WITH-THE-SENDER-NAME" }
5
- }
3
+ "framework": {}
6
4
  }
@@ -11,6 +11,15 @@
11
11
  "Bash(more *.env.cloudflare*)",
12
12
  "Bash(source *.env.cloudflare*)",
13
13
  "Bash(. *.env.cloudflare*)",
14
+ "Read(~/.secrets/**)",
15
+ "Edit(~/.secrets/**)",
16
+ "Bash(grep *.secrets/cloudflare*)",
17
+ "Bash(rg *.secrets/cloudflare*)",
18
+ "Bash(awk *.secrets/cloudflare*)",
19
+ "Bash(less *.secrets/cloudflare*)",
20
+ "Bash(more *.secrets/cloudflare*)",
21
+ "Bash(source *.secrets/cloudflare*)",
22
+ "Bash(. *.secrets/cloudflare*)",
14
23
  "Bash(echo *CLOUDFLARE_API_TOKEN*)",
15
24
  "Bash(echo *CLOUDFLARE_BOOTSTRAP_TOKEN*)",
16
25
  "Bash(env)",
@@ -6,7 +6,7 @@ This page lists everything the owner does by hand, as copy-and-paste steps. Run
6
6
 
7
7
  This release runs apps locally (§1) and on Cloudflare (§2 on). The short version of everything here is the framework's [QUICKSTART.md](https://github.com/lago-morph/cloud-app/blob/main/QUICKSTART.md).
8
8
 
9
- People sign in with an email address and a password. **Anyone who signs up and verifies their address is a user.** Admins are users holding the `admin` role, granted with the `admins` command (§8); nothing about people is kept in configuration. `<domain>` below is the account's email domain.
9
+ People sign in with Cloudflare. **Only members of the owner's Cloudflare account can sign in**, and every member is a user. Members with the account role "Super Administrator - All Privileges" or "Administrator" are admins (§8). Nothing about people is kept in configuration.
10
10
 
11
11
  ## 1. Run it on your computer
12
12
 
@@ -31,11 +31,7 @@ People sign in with an email address and a password. **Anyone who signs up and v
31
31
  ```sh
32
32
  npm run dev
33
33
  ```
34
- Press Ctrl-C to stop. The login button opens the sign-in page: create an account with any address. Locally no mail is sent; it is written to `.mail/`. Read the latest message to the address, open its link, and press the button:
35
- ```sh
36
- npm run mail -- last --to '<address>'
37
- ```
38
- To make yourself an admin locally, run `npm run admins -- grant '<address>' --target local` (`revoke` takes it away). Your next request is admin.
34
+ Press Ctrl-C to stop. Locally there is no real sign-in: the login button signs you in as a test user. Tests choose any level with the authentication mock.
39
35
  5. Check everything before you call a change done:
40
36
  ```sh
41
37
  npm run verify
@@ -49,21 +45,27 @@ People sign in with an email address and a password. **Anyone who signs up and v
49
45
 
50
46
  ## 2. Cloudflare setup (once per account)
51
47
 
52
- You need a Cloudflare account on the Workers Paid plan and a domain on it with Cloudflare DNS active (`<domain>` below). Run, in this app's folder (in Claude Code, say "set up Cloudflare"):
48
+ Any Cloudflare account works, on the free Workers plan too; no domain is needed. Run, in this app's folder (in Claude Code, say "set up Cloudflare"):
53
49
 
54
50
  ```sh
55
51
  npm run cloudflare-setup
56
52
  ```
57
53
 
58
- It prints two pre-filled dashboard links, one per token, and where to put the values (`.env.cloudflare` in this folder, or the environment). Make the tokens, put them there, and run it again until it says everything is set up. It never prints a token value, and every later command reads the tokens itself. The steps, and what to do when it stops: [QUICKSTART.md](https://github.com/lago-morph/cloud-app/blob/main/QUICKSTART.md) and the skill's `reference/owner-tasks.md` §2 (in this app, `.claude/skills/prototype-framework/reference/owner-tasks.md`).
54
+ 1. With no token yet, it prints a two-line template (`CLOUDFLARE_API_TOKEN=` and `CLOUDFLARE_ACCOUNT_ID=`), one pre-filled dashboard link for the token, and where the lines go: the file `~/.secrets/cloudflare` in your home directory (shared by every app on the machine), or a cloud session's environment variables. Make the token (any end date, or none; a token you have with more permissions works too), fill in the lines, put them there, and run the command again. Never paste the token into a chat.
55
+ 2. It checks the token and sets the account up in one run: the sign-in clients, the **auth app** that signs people in to every app, the shared buckets and the optional admin app. It never deletes or changes your token.
56
+ 3. It ends with the next step, a deploy of a `test-` stage. Run it again whenever it stops (in Claude Code, "continue prototype setup") until it says everything is set up.
57
+
58
+ Coming from framework 0.1.x or 0.2.0-rc01: `npm run upgrade` says setup needs re-running; move the token and account ID from `.env.cloudflare` to `~/.secrets/cloudflare` (with the permissions setup names), delete `.env.cloudflare`, and do steps 1–3 once per account. Everyone signs in again, with Cloudflare (QUICKSTART, "Coming from 0.1.x?").
59
+
60
+ It never prints a token value, and every later command reads the token itself. The steps, and what to do when it stops: [QUICKSTART.md](https://github.com/lago-morph/cloud-app/blob/main/QUICKSTART.md) and the skill's `reference/owner-tasks.md` §2 (in this app, `.claude/skills/prototype-framework/reference/owner-tasks.md`).
59
61
 
60
62
  ## 3. What the account setup creates
61
63
 
62
- Setup creates the account's shared resources once, including the file-signing credential every stage uses: the log bucket `prototype-logs`, the deploy-state bucket `sst-state`, the backup bucket `prototype-backups` (a removed production stage's data, kept 30 days), the account's `workers.dev` address, sending from `no-reply@<domain>`, and a test mailbox for agents: mail to `sink+<tag>@t.<domain>` is kept for a day. Running it again changes only what is missing. `deploy` never creates these resources; if any is missing, it says to run the setup again.
64
+ `npm run cloudflare-setup` creates the account's shared resources once (the admin app's optional Account setup page does the same): the **auth app**, which signs people in to every app, with its database; the log bucket `prototype-logs`; the deploy-state bucket `sst-state`; the backup bucket `prototype-backups` (a removed production stage's data, kept 30 days); and the file-signing credential every stage uses. `deploy` never creates these resources; if any is missing, it says so and names `npm run cloudflare-setup`.
63
65
 
64
66
  ## 4. Deploy a test stage, test it, remove it
65
67
 
66
- A stage whose name starts with `test-` is a test stage. It uses `config/cloudflare/test.json`, has the mock login for tests, never sends mail, and holds no real data. Stage names are at most 20 lowercase letters, digits and hyphens.
68
+ A stage whose name starts with `test-` is a test stage. It uses `config/cloudflare/test.json`, has only the mock login for tests, and holds no real data. Stage names are at most 20 lowercase letters, digits and hyphens.
67
69
 
68
70
  Set the stage name once, in the first line, and deploy. In a new terminal, set `STAGE` again:
69
71
 
@@ -92,14 +94,12 @@ npm run remove -- --target cloudflare --stage "$STAGE"
92
94
 
93
95
  ## 5. The production stage's values file
94
96
 
95
- Every stage that does not start with `test-` is a production stage, for example `prod`. It needs its own committed values file. Copy the skill's template (in the framework's repository: `skill/templates/production-stage.json`) and set the display name of the sign-up and reset mail in it:
97
+ Every stage that does not start with `test-` is a production stage, for example `prod`. It needs its own committed values file. Copy the skill's template (in the framework's repository: `skill/templates/production-stage.json`):
96
98
 
97
99
  ```sh
98
100
  STAGE=prod
99
101
  mkdir -p config/cloudflare
100
102
  cp ../../skill/templates/production-stage.json "config/cloudflare/$STAGE.json"
101
- SENDER='<the sender name, for example the app name>'
102
- node -e 'const fs=require("fs"),f=process.argv[1],c=JSON.parse(fs.readFileSync(f,"utf8"));c.framework.email.senderName=process.argv[2];fs.writeFileSync(f,JSON.stringify(c,null,2)+"\n")' "config/cloudflare/$STAGE.json" "$SENDER"
103
103
  npm run build -- --target cloudflare --stage "$STAGE"
104
104
  git add "config/cloudflare/$STAGE.json"
105
105
  git commit -m "Add the values file of stage $STAGE"
@@ -116,7 +116,7 @@ npm run secrets -- set apiKey --target cloudflare --stage "$STAGE"
116
116
  npm run deploy -- --target cloudflare --stage "$STAGE"
117
117
  ```
118
118
 
119
- The first `deploy` stops and names the unset secrets. Set them as above, pasting each value and then pressing Ctrl-D, and deploy again. The framework generates its own keys. The second deploy prints the stage's address, its sign-in page and the sender address `no-reply@<domain>`.
119
+ The first `deploy` stops and names the unset secrets. Set them as above, pasting each value and then pressing Ctrl-D, and deploy again. The framework generates its own keys. The second deploy registers the stage with the auth app and prints its address. Without the account's auth app it stops before creating anything: do the admin app's Account setup (§2) first.
120
120
 
121
121
  To change the stage later (code or configuration), commit the change and run the same `deploy` again:
122
122
 
@@ -126,39 +126,17 @@ git commit -m "<what you changed>"
126
126
  npm run deploy -- --target cloudflare --stage "$STAGE"
127
127
  ```
128
128
 
129
- ## 7. Sign up and sign in
130
-
131
- 1. Open the sign-in page `https://template-prod.<subdomain>.workers.dev/api/auth/sign-in` and choose "Create an account". Enter an email address, a password of 12 to 128 characters, and a display name.
132
- 2. Open the link in the "Confirm your email address" mail and press the button.
133
- 3. Sign in. `https://template-prod.<subdomain>.workers.dev/api/auth/me` now shows `"level":"user"`.
134
-
135
- "Forgot your password?" on the sign-in page mails a reset link (valid for one hour); "Send a new confirmation link" mails a new confirmation link.
136
-
137
- **An agent with no mailbox** signs up with a test address, `sink+<tag>@t.<domain>` (`<tag>`: lowercase letters, digits and hyphens), and reads the mail with:
138
-
139
- ```sh
140
- npm run mail -- last --to 'sink+<tag>@t.<domain>' --target cloudflare
141
- ```
142
-
143
- Without a browser, it posts the link's token (the value after `token=`) instead of pressing the button:
129
+ ## 7. Sign in
144
130
 
145
- ```sh
146
- curl -sS -X POST 'https://template-prod.<subdomain>.workers.dev/api/auth/password/verify' -H 'Origin: https://template-prod.<subdomain>.workers.dev' -H 'Content-Type: application/json' -H 'Accept: application/json' -d '{"token":"<token>"}'
147
- ```
131
+ 1. Open `https://template-prod.<subdomain>.workers.dev/` and press the login button.
132
+ 2. Sign in on Cloudflare's page with a member of the account, and allow what it asks.
133
+ 3. Back on the app, `https://template-prod.<subdomain>.workers.dev/api/auth/me` shows `"level":"user"` or `"level":"admin"`.
148
134
 
149
- `npm run check-login -- --target cloudflare --stage "$STAGE"` runs this whole flow automatically on a production stage (with a password reset and the sign-in rate limit) and writes an evidence record under `validation/`.
135
+ To let someone sign in, invite them to the Cloudflare account (Manage Account → Members); a read-only role, for example "HTTP Applications Read", is enough. `npm run check-login -- --target cloudflare --stage "$STAGE"` checks, with no sign-in, that the stage sends people to the auth app with its own address.
150
136
 
151
137
  ## 8. Admins
152
138
 
153
- The `admin` role is stored with the person's account in the stage's database. Granting or revoking it needs no file edit, no commit and no deploy: it applies from the person's next request. The person must have signed up and verified their address on that stage first (§7). On a production stage, repeat the stage's name with `--confirm-production`:
154
-
155
- ```sh
156
- STAGE=prod
157
- npm run admins -- grant '<their address>' --target cloudflare --stage "$STAGE" --confirm-production "$STAGE"
158
- npm run admins -- list --target cloudflare --stage "$STAGE" --confirm-production "$STAGE"
159
- ```
160
-
161
- `grant` prints the person's user ID (as `/api/auth/me` shows it) and roles. To take the role away, run the same command with `revoke`; the person is a user again. On a test stage, leave out `--confirm-production`. An address with no verified account is refused, and nothing changes.
139
+ A member whose Cloudflare account role is "Super Administrator - All Privileges" or "Administrator" is admin; every other member is a user. Change a person's role in the dashboard (Manage Account → Members). No file edit, no commit and no deploy: the change shows when they next sign in (ask them to log out and in again). Removing someone from the account does not end a session they already have; it lasts until it expires (12 hours) or they log out.
162
140
 
163
141
  ## 9. Stop, start and remove
164
142
 
@@ -174,7 +152,7 @@ npm run admins -- list --target cloudflare --stage "$STAGE" --confirm-production
174
152
  Every error response has a `requestId`. A failed login returns to `/?authError=login_failed&requestId=<id>`. Each log entry is a file in the R2 bucket `prototype-logs`, under `template/<stage>/<yyyy>/<mm>/<dd>/`. The date is UTC, and the file name ends in `-<requestId>.json`.
175
153
 
176
154
  - **Dashboard** (menu names not yet verified)**:** open Storage & databases → R2 → `prototype-logs`, then the folders `template` / `<stage>` / year / month / day. Open the file whose name ends in the request ID.
177
- - **Command line, only where both values are in the environment:** these commands need `CLOUDFLARE_ACCOUNT_ID` and `CLOUDFLARE_API_TOKEN` in the shell's environment, for example in a cloud session whose environment settings hold them. With the tokens only in `.env.cloudflare` (§2), the variables are empty and the requests fail: use the dashboard route above. Never `source` or `cat` `.env.cloudflare` to fill them in. List today's entries of a stage, and keep only the line with the request ID. `APP` must be set (§1 step 2):
155
+ - **Command line, only where both values are in the environment:** these commands need `CLOUDFLARE_ACCOUNT_ID` and `CLOUDFLARE_API_TOKEN` in the shell's environment, for example in a cloud session whose environment settings hold them. With the token only in `~/.secrets/cloudflare` (§2), the variables are empty and the requests fail: use the dashboard route above. Never `source` or `cat` `~/.secrets/cloudflare` to fill them in. List today's entries of a stage, and keep only the line with the request ID. `APP` must be set (§1 step 2):
178
156
  ```sh
179
157
  STAGE='<stage>'; DAY=$(date -u +%Y/%m/%d)
180
158
  curl -sS -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
@@ -5,7 +5,9 @@
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "prototype-framework dev",
8
- "verify": "prototype-framework verify",
8
+ "verify": "prototype-framework verify && playwright test --project e2e-api",
9
+ "test:e2e:api": "playwright test --project e2e-api",
10
+ "test:e2e:ui": "playwright test --project e2e-ui",
9
11
  "generate-migration": "prototype-framework generate-migration",
10
12
  "build": "prototype-framework build",
11
13
  "deploy": "prototype-framework deploy",
@@ -18,17 +20,18 @@
18
20
  "cloudflare-setup": "prototype-framework cloudflare-setup",
19
21
  "check-login": "prototype-framework check-login",
20
22
  "reset-local": "prototype-framework reset-local",
21
- "mail": "prototype-framework mail",
22
- "admins": "prototype-framework admins",
23
23
  "version-check": "prototype-framework version-check",
24
24
  "upgrade": "prototype-framework upgrade"
25
25
  },
26
26
  "dependencies": {
27
- "@lago-morph/prototype-framework": "0.1.1",
27
+ "@lago-morph/prototype-framework": "0.2.0-rc02",
28
28
  "hono": "4.13.13",
29
29
  "zod": "4.6.7"
30
30
  },
31
31
  "devDependencies": {
32
+ "@playwright/test": "1.64.1",
33
+ "@vitest/browser-playwright": "5.0.5",
34
+ "fast-check": "4.10.2",
32
35
  "typescript": "6.0.3",
33
36
  "vite": "8.3.4",
34
37
  "vitest": "5.0.5"
@@ -0,0 +1,31 @@
1
+ import { defineConfig } from "@playwright/test";
2
+
3
+ // The app's e2e layer (the skill's reference/testing/e2e.md): two projects against a local `dev`
4
+ // server that Playwright starts and stops.
5
+ // - "e2e-api": most e2e tests, through the HTTP API with the `request` fixture; no browser.
6
+ // `npm run verify` runs it after the unit tests.
7
+ // - "e2e-ui": the few tests of what only a browser shows; the only project that needs Chromium.
8
+ // `dev` binds a free port and prints "… is running at http://localhost:<port>/". `webServer.wait`
9
+ // reads the port into APP_E2E_PORT for the test workers, which load this file again.
10
+ const port = process.env["APP_E2E_PORT"];
11
+ const origin = port === undefined ? "http://localhost" : `http://localhost:${port}`;
12
+
13
+ export default defineConfig({
14
+ testDir: "tests/e2e",
15
+ outputDir: "test-results",
16
+ // One local server and one local database: tests use fresh mock users, not a fresh database.
17
+ workers: 1,
18
+ projects: [
19
+ // State-changing API requests must carry the app's origin (the framework's forgery check).
20
+ { name: "e2e-api", testMatch: "api/**/*.spec.ts", use: { baseURL: origin, extraHTTPHeaders: { Origin: origin } } },
21
+ { name: "e2e-ui", testMatch: "ui/**/*.spec.ts", use: { baseURL: origin, browserName: "chromium" } },
22
+ ],
23
+ webServer: {
24
+ command: "npm run dev",
25
+ wait: { stdout: /is running at http:\/\/localhost:(?<app_e2e_port>\d+)\// },
26
+ // dev's own server log is not test output; its "is running at" line is still read for the port.
27
+ stderr: "ignore",
28
+ timeout: 120_000,
29
+ gracefulShutdown: { signal: "SIGTERM", timeout: 10_000 },
30
+ },
31
+ });
@@ -4,7 +4,7 @@ import type { NoteList } from "../../shared/types";
4
4
  import type { Env } from "../env";
5
5
  import { notes } from "../schema";
6
6
 
7
- const newNote = z.object({ text: z.string().trim().min(1).max(500) });
7
+ export const newNote = z.object({ text: z.string().trim().min(1).max(500) });
8
8
 
9
9
  /** SQL and log: a logged-in user writes notes and lists their own. */
10
10
  export function noteRoutes(api: Hono<Env>): void {