Repository navigation
Commit 6bbfb4b
authored
Wait for every blanket-answer round trip before asserting the control is hidden (#160)
## Problem
`ci` on
[72be4be](https://github.com/max-sixty/leaf/actions/runs/33345068975)
failed with 35 nightly tests red. Rerunning all 35 node ids against
`c0a5b65` leaves four: the catalog digest (#156), the two page-map chord
reads (#157), and this one, which nothing owns.
```
FAILED tests/test_render_controls.py::test_a_wide_banner_spends_status_copy_before_action_reach
AssertionError: Locator expected to be hidden
6 × resolved to <button ... class="lf-btn lf-answer-all ...">✓ Accept all (3)</button>
3 × resolved to ... ✓ Accept all (2)
4 × resolved to ... ✓ Accept all (1)
```
The count is walking down and running out of budget. The blanket answer
[decides its decisions one at a
time](https://github.com/max-sixty/leaf/blob/8683b9b1d2b9d408506c9f88bf3baf5a4f84685c/skills/leaf/assets/runtime/decisions/view.js#L68-L71)
— `await source[verb]?.()` per decision — so the press owes one round
trip per decision, and the test released the held first answer straight
into `expect(answer_all).to_be_hidden()`. That single 5s budget was
covering three sequential server trips, not the repaint it is for.
`tests/CLAUDE.md` names this exactly: "Letting `expect` absorb the
page's next read hides which mechanism supplied the wait and spends its
timeout budget on transport rather than on the assertion."
Instrumenting the sequence on an idle runner gives `event → state →
event → state → event`, 1.89s end to end. Three trips at ~0.6s each fit
inside 5s on an idle machine and do not on a loaded one, which is why
this is nightly-and-under-load only.
`test_accept_all_decides_every_pending_suggestion` drives the same
control and does not have the bug: it waits for each widget's own settle
first, so its `to_be_hidden` only has to cover the last repaint, and
[its comment says
why](https://github.com/max-sixty/leaf/blob/8683b9b1d2b9d408506c9f88bf3baf5a4f84685c/tests/test_render_widgets.py#L1541-L1543).
This site was the one that skipped the staging.
## Solution
State the transport with `_until` on the `Traffic` counters — the same
causal helper this test already uses eight lines above to hold the
answer in the wire — then let `to_be_hidden` assert only the repaint it
is about. The number of trips owed is read off the control's own face
(`✓ Accept all (3)`) rather than written out, so the fixture's
arithmetic stays in one place, and an `owed > 1` guard fails loudly if a
fixture change ever leaves this test a single trip and stops it
exercising the sequence at all.
This is not a raised timeout. `_until` is bounded at 30s with the
counters in its failure message, so a genuinely stuck answer now fails
naming the missing evidence instead of pointing at a control that "never
went".
## Testing
Playwright driving real Chromium on this runner, at `8683b9b`:
- `uv run pytest tests` — **740 passed, 6 skipped**. This is the gate
`ci` runs on the PR; the test fixed here is nightly-only and not
exercised by it.
- `uv run pytest tests/test_render_controls.py --run-nightly -n4` — **64
passed**, three times consecutively on an otherwise-idle machine.
- `ruff check` and `ruff format --check` on the changed file, at the
`v0.16.1` `.pre-commit-config.yaml` pin — clean.
<details><summary>Reproducing the failure, and the mutation
checks</summary>
The test passes 6/6 at `-n0` on `c0a5b65` unmodified, so `-n0` alone
leaves it unclassified. Stalling the driver for 300ms between
`held[0].continue_()` and the hide assertion reproduces the CI shape
exactly on the unfixed test — the button walks `(3) → (2) → (1)` and the
expect runs out:
```
5 × ... ✓ Accept all (3)
5 × ... ✓ Accept all (2)
3 × ... ✓ Accept all (1)
```
With this change in place the same stall passes. Two mutations confirm
the new wait bites rather than just returning:
| mutation | result |
| --- | --- |
| `traffic.sends == owed` → `owed + 1` | fails: `the page never settled
every one of the 3 answers the blanket press owed: the wait began on
sends=1 acked=0 pending=1 asked=3 heard=3 and gave up on sends=3 acked=3
pending=0 asked=6 heard=6` — and this also confirms `owed` reads 3 and
that the predicate's own terms are what carry it |
| driver stall re-applied to the fixed test | passes in 8.55s |
Timed trace of the released sequence on an idle runner, seconds from
`continue_()`:
```
0.38 FIN event 0.66 FIN state
1.17 FIN event 1.38 FIN state
1.81 FIN event → hidden at 1.89
```
The other `.lf-answer-all` sites were checked for the same shape and do
not have it: `test_render_gate.py` navigates away,
`test_render_startup.py` puts `wait_for_function(BOTH_STAMPS)` between
the release and the hide assertion and has one decision rather than
three, and `test_render_projection.py` asserts the control is absent.
</details>
---
Automated fix for [failed
run](https://github.com/max-sixty/leaf/actions/runs/33345068975)
Co-authored-by: leaf-agent <[email protected]>1 parent 053d6d5 commit 6bbfb4b
1 file changed
Lines changed: 20 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
693 | 693 | | |
694 | 694 | | |
695 | 695 | | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
696 | 703 | | |
697 | 704 | | |
698 | 705 | | |
| |||
706 | 713 | | |
707 | 714 | | |
708 | 715 | | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
709 | 729 | | |
710 | 730 | | |
711 | 731 | | |
| |||
0 commit comments