Skip to content

fix(e2e): let the page settle before the journey answers the welcome tour - #144

Merged
aRustyDev merged 4 commits into
mainfrom
fix/e2e-tour-dismiss-race
Nov 13, 2026
Merged

aRustyDev merged 4 commits into
mainfrom
fix/e2e-tour-dismiss-race

Conversation

@aRustyDev

@aRustyDev aRustyDev commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

Refs #45 (closed). The journey had a race that the first run of e2e-schedule.yml exposed. This fixes the journey, adds the control that reproduces the race, and records what is and is not known.

What was wrong

The worker-cf e2e cell failed now and then at create a project: the click on Add project timed out because the welcome tour's backdrop (bg-backdrop) was still in front of the page, although the tour's own PATCH /api/users/me/tour-completed/ was answered 200.

Run What failed
43166258556, the push to main after #140 the main journey
43297020745, another branch's pull request the empty-list control (same line)
43296974643, the first dispatch of e2e-schedule.yml the empty-list control

4 of the 13 runs of the cell I could find failed, 3 of them at that line. I had called the cell green from its pull-request runs alone and had not looked at the pushes to main. The cell is a gate, so this was also blocking other branches' pull requests.

The cause, reproduced

WorkspaceHomeView shows the tour while is_tour_completed is false. updateTourCompleted sets it true in the store before its PATCH, and fetchUserProfile replaces the whole profile with what its GET returned. The home page fetches the profile as it mounts, so an answer made before the click and landing between it and the next click puts the tour back for good, and the click on Add project is blocked. That code is the pin's, unchanged (web/ALLOWED-CHANGES), so the same race exists on Plane; the journey clicks within milliseconds of the page appearing, which a person does not.

Measured locally on worker-cf, each run 8 times against one Worker, with the slow-page control (the browser's CPU slowed, and the first profile fetch from inside the workspace held until the tour's PATCH leaves the browser, 2 s at most, then released unchanged):

Journey CPU slowdown Result
unfixed 6x 8 of 8 failed at the Add project click, with CI's error text
first version of the fix (wait for quiet, click, wait, assert) 12x 8 of 8 failed, at its assertion
this PR's journey 12x 8 of 8 passed, each needing its second answer

Three weaker controls did not reproduce it, which is why slow-page is built as it is (details in G-31): a late profile answer on a fast machine (the page makes no profile fetch before the click there), a CPU slowdown alone (the answer arrived 800 ms before the click), and both with a fixed 2 s hold (the answer landed 1.3 s after the click).

The first version of this fix was not enough, and CI said so

It waited for the page to go quiet (500 ms with nothing in flight) before the click and asserted afterwards that the tour was gone. It passed slow-page 8 of 8 locally and three dispatches of e2e-schedule.yml on that version of the fix succeeded, and then this PR's own run 43317382522 failed at the assertion. The HAR from that run: the held profile fetch began 1070 ms before the click, and GET /api/users/me/ and the profile fetch the app chains to it were about 930 ms apart under the slowdown, longer than the 500 ms of quiet, so the wait returned inside the gap. A longer pause is no answer: how long the app's own code waits between the two depends on the machine. (The lint failure on that run was unrelated: the branch lacked #143's clippy fix, and main is merged in.)

What this changes

  • The journey lets what the page asked for be answered, answers the tour, waits for what was in flight at that moment, and looks that the tour's button is gone. If it is back it answers it again, three answers at most, as a person would, and records tour-came-back in the report. A stale answer cannot come twice: nothing is in flight by then. The wait is watchPending(page).quiet(); waitForLoadState("networkidle") resolves at once on a single-page app past its first load, so it cannot stand in.
  • slow-page, a control that must pass, the only one that does: scripts/e2e.sh controls runs it through a new must_pass, held to the exit status and then the count guard. It fails as CONTROL INERT if it held no profile answer.
  • Docs: G-31 (the whole account, including the controls that did not reproduce it, and the first version), X18, the technique page.

Checked

  • The whole cell, locally: journey passed 1 of 1, the four must-fail controls fire, slow-page passes, VERDICT: PASS.
  • must_pass run on a stub in its three cases (journey fails; journey passes and the count guard refuses; both pass) under sh and under dash in ubuntu:24.04; a mutant of it that ignores the journey's status fails the test.
  • The e2e sources type-check under tsc --strict (the package has no check of its own; the same invocation reports a planted error).

Seen in CI (head a5bf65b)

  • The pull request's own run: 32 jobs succeeded, 1 skipped (web); lint, the e2e cell and gate are success.
  • Five dispatches of e2e-schedule.yml on the branch, one after the other (43322146663, 43322945396, 43323732660, 43324516416, 43325211639): all VERDICT: PASS, journey 1 of 1, slow-page ok, nothing skipped but the oracle-only uv install.
  • In those five, the main run never had to answer the tour twice; the slow-page run did in two of them, so the race fired in CI under the control and was absorbed.

Not seen

  • That the flake is gone from the real cell. Before the fix 3 of the 13 runs of the cell that I could find failed at that step, so six clean runs would come by chance about one time in five (an estimate from few counts), and the wait-only first version passed 3 of 4 runs in CI before it failed. main is red at the cell on 3 of its last 5 pushes until this lands (130c1e9, 84dcafa, 594365d).
  • Why a fast machine does not make the mount-time profile fetch is not established. No such fetch appeared in the unthrottled local HARs before the click; it did in CI's and under the CPU slowdown. A 2 s dedupe of the SWR fetch in AuthenticationWrapper is the guess; nothing here tested it.
  • The Plane leg was not re-run with the changed journey: it is local only and takes the oracle's stack down (down -v drops the seeded snapshot). Say if you want it.

🤖 Generated with Claude Code

aRustyDev and others added 4 commits November 12, 2026 17:01
…tour

The worker-cf e2e cell failed now and then at "create a project": the click
on "Add project" timed out because the welcome tour's backdrop was still in
front of the page, although the tour's own PATCH had been answered 200. It
failed the main journey on the push to main after #140 (run 43166258556), and
the empty-list control on another branch's pull request (43297020745) and on
the first dispatch of e2e-schedule.yml (43296974643).

The app marks the tour as done in its store at the click and keeps whatever a
profile fetch returns after that. The home page fetches the profile as it
mounts, so an answer made before the click and landing after it puts the tour
back for good. A fast machine does not make that fetch before the click; a CI
runner does.

- e2e/journeys: the journey waits for what the page asked for to be answered
  before it answers the tour, and again after, and requires that the tour's
  button is gone. The wait is watchPending(page).quiet() in support/network.ts,
  because waitForLoadState("networkidle") resolves at once on a single-page
  app past its first load.
- e2e/support/controls.ts: a new control, slow-page, the one run that must
  PASS: the browser's CPU slowed 6x and the profile answer of the home page
  held until the tour's PATCH leaves the browser (2 s at most), then answered
  as it was before. It fails CONTROL INERT if it held nothing.
- scripts/e2e.sh: must_pass, the runner of a control that must pass, held to
  the exit status and then the count guard; `controls` runs slow-page with it.
- docs: G-31, X18 and the technique page say what the race was, what
  reproduced it and what did not, and what is still not seen.

Measured locally on worker-cf: the unfixed journey failed 8 of 8 under
slow-page, all at the Add project click and with CI's error text; two weaker
controls (a CPU slowdown alone, and a fixed 2 s hold on top of it) passed it 8
of 8, so they are not what slow-page is built from. The fixed journey passed
slow-page 8 of 8, and the whole cell passed with all its controls. must_pass
was run on a stub in its three cases under sh and dash, and a mutant that
ignores the journey's status failed that test.

Not seen: CI itself after this, and the Plane leg with the changed journey
(local only).

Refs: #45
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The first version of this fix, which waited for the page to go quiet before
the click and asserted after it that the tour was gone, was not enough. It
passed the slow-page control 8 of 8 locally, and two dispatches of
e2e-schedule.yml on that head succeeded, and then the pull request's own run
failed at the assertion (run 43317382522).

Its HAR shows why: the held profile fetch began 1070 ms before the click, and
GET /api/users/me/ and the profile fetch the app chains to it were about 930
ms apart under the slowdown, which is longer than the 500 ms of quiet the wait
asks for, so the wait returned inside the gap and the click was made with the
fetch still in flight. A longer pause is no answer: how long the app's own code
waits between the two depends on the machine.

- e2e/journeys: the journey waits for what the page asked for, answers the
  tour, waits again for what was in flight at that moment, and looks that the
  tour's button is gone. If it is back, it answers it again, three answers at
  most, as a person would, and records `tour-came-back` in the report. A stale
  answer cannot come twice: nothing is in flight by then.
- e2e/support/controls.ts: slow-page hands back the server's own held answer.
  It had rewritten the held answer to is_tour_completed: false, which also made
  stale an answer fetched after the click, one a server would not give.
- docs: G-31 and the technique page say what the first version missed and how
  it was found.

Measured locally on worker-cf, 8 runs each, slow-page and no other control:
the unfixed journey at 6x CPU slowdown failed 8 of 8 at the Add project click
(the changed control still discriminates); the wait-only version at 12x failed
8 of 8 at its assertion; this journey at 12x passed 8 of 8, each of them
needing its second answer. The whole cell then passed at the default 6x.

Refs: #45
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
G-31's "Not seen" said that CI itself had not been looked at. It has now:
the pull request's own run and five dispatches of e2e-schedule.yml on head
a5bf65b all passed (journey 1 of 1, slow-page ok). The main run never had to
answer the tour twice; the slow-page run did in two of the five, so the race
fired in CI under the control and was absorbed.

It also says what this does not show: before the fix 3 of the 13 runs of the
cell that I could find failed at that step, so six clean runs would come by
chance about one time in five (an estimate from few counts), and the wait-only
first version passed 3 of 4 runs in CI before it failed.

Refs: #45
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@aRustyDev
aRustyDev merged commit 72da790 into main Nov 13, 2026
35 checks passed
@aRustyDev
aRustyDev deleted the fix/e2e-tour-dismiss-race branch November 13, 2026 17:40
aRustyDev added a commit that referenced this pull request Nov 13, 2026
cargo deny failed on main's push run for #144 (43475094189), and the gate
with it, on this advisory (mutation XSS through embedded SVG and MathML,
dated 2026-11-12, patched in ammonia >= 4.2.5 for the 4.2 line).

ammonia is the sanitiser behind thrust-editor-doc's description_html;
thrust-api-v1, thrust-compat-plane and thrust-editor-worker reach it through
the `sanitize` feature. The manifest already allows 4, so this is a lockfile
change only: ammonia 4.2.4 -> 4.2.5, its version and checksum, nothing else.
`cargo update` also moved tempfile's getrandom from 0.4.3 to 0.3.4; that hunk
is not part of this change and was put back by hand (`cargo metadata
--locked` accepts the result).

Checked:
- cargo deny 0.20.2 (CI's version, `--locked check`): the lockfile on main
  fails on RUSTSEC-2026-0533 alone; this one passes advisories, bans,
  licenses and sources.
- cargo nextest run --workspace --profile ci: 3564 passed, 4 skipped (the
  oracle_ tests the profile excludes), the three sanitiser tests among them.
- examples/sanitize_check over the 125 XSS payloads and the editor corpus
  (431 inputs): the sanitiser's output (plain, stripped and hardened) is
  byte-identical on 4.2.4 and 4.2.5. Control: 4.0.0 (probes/ammonia-400)
  differs from 4.2.4 on 7 of the same inputs, so the comparison can see this
  kind of change.

Not shown: that the fix does anything for this configuration. The output
does not change on any corpus input, so the corpus does not exercise it; the
allow-list adds no math, svg or raw-text tag to ammonia's defaults, so by the
advisory's own text this code should not have been affected. Not tested with
the advisory's payload. The doctests were not run locally; CI runs them.
probes/ammonia-400 still pins =4.0.0 on purpose: a separate workspace with its
own lock, never shipped, outside cargo deny's reach.

Co-authored-by: Claude Sonnet 5.5 <[email protected]>
aRustyDev added a commit that referenced this pull request Nov 13, 2026
… again (#148)

* test(e2e): print a line when a journey had to answer the welcome tour again

Since #144 the journey answers the welcome tour again if the page brings it
back (three answers at most), so a green run no longer says whether the race
fired. The only trace was the `tour-came-back` annotation in the run's JSON
report, which the console reporter does not print: the cell's log of the push
run for ec37114 (43494469506) has no trace of it, though that run's slow-page
report holds one.

- e2e/support/check-report.mjs: after the count line of a run, it prints one
  `e2e: NOTE: tour-came-back in <report>, "<journey>": <what it recorded> ...`
  line for each journey that recorded it. It is not a verdict and changes no
  exit status; the line names the report, so main.json (the race happening on
  the real run) is told from control-slow-page.json (expected there).
- docs: G-31 says where the annotation is, what the line looks like, what it
  means in each report, and what was counted.

Measured on the saved reports of the three main runs after #144 (ec37114,
76347e2, af9e97e): the main run recorded it in none and slow-page in two of
the three; with the five dispatches G-31 already counts, 0 of 8 and 4 of 8.
The checker prints a line for exactly those reports that hold the annotation.
Three synthetic reports (a nested suite whose other annotation type must not
print; a skipped journey that holds a note, which the count guard still
refuses, the refusal being the last line; a report with no suites) behave as
intended, and two broken copies fail the first of them: one that ignores the
annotation's type printed 3 lines where 1 is right, one that does not descend
into nested suites printed none.

Not shown: that the line prints in the cell's own log (it was run on saved
reports, not by scripts/e2e.sh), and that a real user meets the race (it was
reproduced only in the Thrust build, under a slowed CPU and a held profile
answer, and not on the pinned Plane).

Refs: #45
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

* docs(testing): record that the tour-came-back line printed in the cell's own log

The previous commit said it was not shown that the line prints in the cell's
log, because it had only been run on saved reports. It has now been seen in a
real cell: a dispatch of e2e-schedule.yml on that head (run 43502938868) has
the line after the count line of control-slow-page.json and not after that of
main.json. The pull request's own run (43501853057) had none, and its reports
hold no annotation, so nothing was due there.

With these two runs the main run has needed a second answer in 0 of 10 runs
and slow-page in 5 of 10. The sentence that a real user meets the race is not
shown stays as it was.

Refs: #45
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

---------

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