Skip to content

test(e2e): the browser journey of the sign-in by code, and a second e2e suite for the screens that need mail - #238

Merged
aRustyDev merged 7 commits into
mainfrom
feat/e2e-email-code
Nov 16, 2026
Merged

aRustyDev merged 7 commits into
mainfrom
feat/e2e-email-code

Conversation

@aRustyDev

Copy link
Copy Markdown
Owner

What

The browser journey of the sign-in by code (D-042, F-A04, issue #46), and the second e2e suite it needed.

e2e/journeys-mail/m2-sign-in-by-code.spec.ts, in a real Chromium against a Worker that serves the stock app and has a mail service: a person signs up and makes a workspace; in a new visit they give their email and take "Sign in with unique code" at the password step; the app asks for the code itself; the code is read from the mail the Worker was asked to send; a wrong code is a 302 to /?error_code=5090 and the app shows the code step again with its banner and the address filled in; Resend mails a second code; the first code, posted after that, is refused; the second signs in, and a reload stays in the workspace on a HttpOnly, Secure __Host-thrust_session cookie. The network log holds two 200s for the request and three 302s for the form, and no 404 or 5xx.

These are the things that only a browser shows and that the contract suite, the parity fixtures and the generated models cannot: the form's hidden csrfmiddlewaretoken and the __Host-thrust_csrf cookie agreeing in a real page, the app's own step after a refusal, and the session cookie being the one the app goes on with.

Why a suite of its own

The first suite holds that its target has no mail: m2-sign-in-methods asserts the button is absent and that the page calls no magic route, the pinned Plane has no mail either, and the count guard holds every file of e2e/journeys/ to a pass on every run (a skip is refused), so a journey that needs mail would fail every run without it. So the journeys that need mail are in e2e/journeys-mail/, run by a pass of its own (scripts/contract.sh <target> e2e-mail, the worker-cf e2e-mail cell, scripts/e2e.sh <target> mail). Its Worker gets the mail pass's mail service (the send_email binding as wrangler dev simulates it) and the path of the simulator's log, THRUST_MAIL_WRANGLER_LOG, which the browser run inherits.

e2e/support/mail.ts reads that log the way simulated_mails in the contract suite does (colours stripped, the lines after the announce line) and polls until the message it needs is there, because the lines reach the log a few milliseconds after the response. The code is the last word of the subject.

How it was checked

  • The journey: 5 of 5 runs, each on a fresh Worker (the first took 7 s).
  • Controls, each of which must make the journey fail, by its words (scripts/e2e.sh worker-cf mail controls is VERDICT: PASS):
    • smtp-off (the browser says no mail is configured) fails it at "ask for a code";
    • code-dropped (the browser changes the code in the form to 000000, and the real server refuses it) fails it at "the code signs in";
    • mail-unread (the journey looks for the mail of an address that was never mailed) fails it at "read the code from the mail";
    • wrong-target fails it at TARGET GUARD (plane); slow-page (CPU 6x) passes it; the count guard refuses a skipped journey ("0 journeys passed, and there are 1; skipped is 1").
  • The first suite is unchanged: scripts/e2e.sh worker-cf controls is 3 of 3 journeys, its six controls and its count guard.
  • The edited harness: scripts/contract.sh worker-cf mail 7 of 7 and main 71 of 71.
  • The planner and the registration: test_plan_ci.py (5,024 checks; its new cases fail 5 ways with the rule that routes the mail cell taken out), test-check-flake-hunt-cell.sh (133), and all 52 script steps of the deps and ci-scripts jobs, run on the tree with main merged in; the book builds.

CI

  • The cell is registered in scripts/contract-all.sh (26 cells), so this PR runs it and the gate holds it. plan-ci.py runs both e2e passes for e2e/, web/, scripts/e2e.sh and the e2e tools (the suites share e2e/support/ and the runner), contract-pass-tools prepares Node, the app and the browser for it, flake-hunt.yml offers it, and e2e-schedule.yml runs it daily as a second job.
  • docs/src/architecture/cicd.md: 26 cells (23 contract and 3 oracle), and its examples table re-run on this repository: a change of thrust-adapters-cloudflare keeps 16 worker cells (the table said 13; it was 15 before this cell) and a change everything depends on keeps all 26 (it said 23).

Not covered (G-44 says the same)

  • The pinned Plane: it writes its code to its Valkey and its oracle stack has no mail sink, so a leg means an oracle with EMAIL_HOST set, the magic switch on and a way to read its code. The journeys table says "not run, by design".
  • A code mailed from a deployed Worker (the simulator sends nothing); the cell on worker-memory (by hand, as e2e); a browser on localhost (the journey's origin is http://127.0.0.1, where the __Host- cookies are shown to work).
  • The cap of four codes and five tries in a browser (the Rust models hold them; the journey asks for two codes and makes two wrong tries); the forgot-password and reset pages in a browser (G-37; support/mail.ts is what a journey of them would use).
  • A committed HAR: E2E_RECORD_HAR is refused for this suite, because it would hold a live code.

Refs: #46

🤖 Generated with Claude Code

aRustyDev and others added 7 commits November 16, 2026 16:57
… the journey of the sign-in by code

D-042's code form had every proof but a browser's: the app draws "Sign in with unique code"
only where the instance says mail is on, and the first e2e suite holds that its target has
none (m2-sign-in-methods asserts the button is absent, the pinned Plane has no mail, and the
count guard holds every file of e2e/journeys/ to a pass on every run). So the journeys that
need mail are a suite of their own, e2e/journeys-mail/, run by a pass of its own.

- scripts/contract.sh: the `e2e-mail` pass (Worker targets): the e2e pass's app and CSRF
  default, the `mail` pass's mail service (the send_email binding as wrangler dev simulates
  it, THRUST_PUBLIC_BASE_URL, THRUST_MAIL_WRANGLER_LOG for the browser run to inherit), the
  vacuity guard (is_smtp_configured must be true here and false everywhere else), and an arm
  that runs scripts/e2e.sh with E2E_SUITE=mail.
- scripts/e2e.sh: `<target> [mail] [controls]`; the count guard counts the suite's directory;
  E2E_RECORD_HAR and plane-oracle are refused for the mail suite (a HAR would hold a live
  code; the pin writes its code to its Valkey and has no mail sink); the mail suite's controls.
- e2e/support/mail.ts reads the simulator's log (colours stripped, polled until the message
  is there: the lines reach the log after the response) and takes the code from the subject;
  account.ts is the sign-up and onboarding the journey starts with; assertMailTarget refuses
  a target without mail; controls.ts gains smtp-off, code-dropped and mail-unread.
- The journey: sign up, new visit, "Sign in with unique code", read the mailed code, a wrong
  code (302 to 5090, the banner, the code step again), Resend (a second code), the first code
  refused, the second signs in, a reload stays in the workspace on a HttpOnly Secure
  __Host-thrust_session cookie; the network log holds two 200s and three 302s, no 404, no 5xx.

Measured: `scripts/e2e.sh worker-cf mail controls` is VERDICT: PASS (the journey 5 of 5 runs;
each control fails it by its words; slow-page passes; the count guard refuses a skip);
`scripts/e2e.sh worker-cf controls` (the first suite) is unchanged and green; contract.sh
worker-cf mail 7/7 and main 71/71 with the edited script.

Refs: #46
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Registers the mail suite's pass as a cell of the matrix, so a pull request runs it and the
gate holds it.

- scripts/contract-all.sh: `run worker-cf e2e-mail` (26 cells; plan-cells.sh reads the list).
- plan-ci.py: the rules that run the e2e pass (e2e/, web/, scripts/e2e.sh, the e2e tools and
  the compat recorder) run both e2e passes; the two suites share e2e/support/ and the runner,
  so a change to either is not told apart. A change of the Worker's crates already selects
  every cell of worker-cf. test_plan_ci.py: the cell is in its CELLS, its named cases and its
  command-line cases; with the rule's extra pass taken out, 5 of its checks fail.
- .github/actions/contract-pass-tools: Node, the built app, the browser and the preflight
  tools for e2e-mail as for e2e.
- contract-cell.yml and flake-hunt.yml name the pass; test-check-flake-hunt-cell.sh holds
  flake-hunt.yml's list equal to the matrix's (133 checks).
- e2e-schedule.yml: a second job for the cell, so one suite failing does not hide the other.

Refs: #46
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
- app-and-e2e.md: the mail suite (why it is a suite of its own, what reads the mail, what
  it does not have) and its three controls; running.md: the pass; infra.md: the form has a
  browser journey on Thrust now, and none on the pin.
- status.md: G-44 (what was measured and what is not covered); G-37's and G-42's "not
  covered: a browser journey" sentences say what changed.
- TRACEABILITY.md: F-A04's evidence, the journeys table's new row (the pinned-Plane column
  says "not run, by design"), and the rule that a journey that needs mail is in
  e2e/journeys-mail/.
- cicd.md: 26 cells (23 contract and 3 oracle), the planner's rules, and the examples table
  re-run on this repository: a change of thrust-adapters-cloudflare keeps 16 worker cells
  (the table said 13: it was 15 before this cell) and a change that everything depends on
  keeps all 26 (it said 23).

Refs: #46
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@aRustyDev
aRustyDev merged commit 6052120 into main Nov 16, 2026
41 checks passed
@aRustyDev
aRustyDev deleted the feat/e2e-email-code branch November 16, 2026 22:56
aRustyDev added a commit that referenced this pull request Nov 16, 2026
…ants by pattern

main moved again while CI ran on the last merge: #238, a second e2e suite, adds the pass
`e2e-mail` to four planner rules. Two of this branch's mutants named those rules by the
exact text of their pass list, so in CI mutate_gate.py reported 2 BROKEN (the text to
replace was found 0 times) and ci-scripts failed, as it should when a mutant tests nothing.

This merge carries the fix, which is why it is more than a merge: the four mutants of a rule's
effect (web/, the CA root, e2e.sh, the oracle) now find the rule by its pattern and change its
effect, so a rule that gains a pass or a job no longer breaks them. Each regex was checked to
match exactly once in the planner before #238 and after it. A rule that is renamed or removed
still breaks its mutant, which is the signal.

Tested on the merged tree before this commit:
- test_plan_ci.py: 6,763 checks pass
- test-ci-scripts.sh under dash: 173 cases pass
- mutate_gate.py: 53 of 53 mutants killed, none broken, both equivalent mutants survive
- lint-all-workflows.sh exits 0

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant