Skip to content

Commit 053d6d5

Browse files
authored
Wait for the accept to reach the log with round_trip, not a wait that returns at once (#158)
`test_accepting_a_suggestion_settles_it_and_reaches_claude` guarded its event-log read with a `wait_for_function` whose predicate fetched `/api/state` and returned a promise resolving to whether the log holds the `accept`. A falsy resolution ends that wait rather than polling again, so it returned `False` on the first poll and the `read_events` assertion under it ran unguarded — a wait that proves nothing, which is the class `tests/CLAUDE.md` opens on. This replaces it with `round_trip(page)`, the boundary that file names for reading the log ("Read the event log only after `round_trip`"), and the one the module's other log reads already use. Verified: `tests/test_render_widgets.py` green (65 passed), and the named test passes at `-n0`. Surfaced by the review on #154; it belongs here rather than in that diff. <details><summary>The falsy-resolution semantics, measured</summary> Not documented, so probed against the pinned Playwright (1.62.0) with the repo's own `.venv`: ```python pg.evaluate("() => { globalThis.flag = false; setTimeout(() => globalThis.flag = true, 800); }") h = pg.wait_for_function("() => Promise.resolve().then(() => globalThis.flag)") # elapsed 0.02s value: False flag now: False ``` The predicate's promise is awaited, but the wait returns on the first resolution whatever its truthiness — it raises nothing and does not poll again. The site here is the only one of this shape left in the suite: the harness's `margins_laid_out` wait resolves `true` explicitly (#154), and no other `wait_for_function` predicate in `tests/` returns a promise. </details> Co-authored-by: leaf-agent <[email protected]>
1 parent 8bf0a0b commit 053d6d5

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎tests/test_render_widgets.py‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,10 +1362,12 @@ def test_accepting_a_suggestion_settles_it_and_reaches_claude(browser, serve):
13621362
# The banner's count follows the page: three pending, one decided.
13631363
expect(page.get_by_role("button", name="Accept all (2)")).to_be_visible()
13641364

1365-
page.wait_for_function(
1366-
"() => fetch('/api/state').then(r => r.json())"
1367-
".then(s => s.events.some(e => e.kind === 'action' && e.action === 'accept'))"
1368-
)
1365+
# The boundary before reading the shared log: what the press sent has to have a
1366+
# definitive outcome first. The fetch this replaced proved nothing —
1367+
# `wait_for_function` awaits the promise a predicate returns, but a falsy
1368+
# resolution ends the wait instead of polling again, so it came back `False` on
1369+
# the first poll and the read below ran unguarded.
1370+
round_trip(page)
13691371
logged = [
13701372
e for e in events_model.read_events(serve.page_dir) if e["kind"] == "action"
13711373
]

0 commit comments

Comments
 (0)