From 881c7f5df31de07ab8e47781142b5048c3088ce2 Mon Sep 17 00:00:00 2001 From: Vuong Hoang Date: Wed, 23 Sep 2026 09:14:41 -0700 Subject: [PATCH] docs(r2): correct the provenance of the rewritten keyboard-flag test The gallery's POST-303-reload was the no-JS design working, and it still is (the INV-4 golden pins it). The defect was the full-size ejection. The test's docstring and the contract's assertions table now say so (booth-dev review). --- docs/contracts/r2_flow.contract.md | 2 +- tests/test_embed_browser.py | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/contracts/r2_flow.contract.md b/docs/contracts/r2_flow.contract.md index 9481ad6..00bc6c7 100644 --- a/docs/contracts/r2_flow.contract.md +++ b/docs/contracts/r2_flow.contract.md @@ -390,7 +390,7 @@ This applies to image, video and audio items. Docs keep `doc.html`. |---|---|---|---| | test_booth.py L785 | `class="grid kept-grid"` present when a booth is kept | absent; the kept booth appears in its Desk section with the `kept` lifetime line | requirement 8: the lanes sort nothing | | test_booth.py L786 | `class="card card-kept"` present | replaced by the row carrying `data-kept="1"` | same | -| test_embed_browser.py `test_the_keyboard_flag_actually_submits` | pressing `f` causes a NAVIGATION (`page.expect_navigation()`), and the reloaded page shows the flag | pressing `f` causes NO navigation; the flag comes back from the server into the swapped tile. A window marker set before the keypress must survive, proving no reload | requirement 3: the reload IS the defect. The test's real claim — the key reaches the server and the server's state comes back — is kept, and asserted more strictly | +| test_embed_browser.py `test_the_keyboard_flag_actually_submits` | pressing `f` causes a NAVIGATION (`page.expect_navigation()`), and the reloaded page shows the flag | pressing `f` causes NO navigation; the flag comes back from the server into the swapped tile. A window marker set before the keypress must survive, proving no reload | with JS on, the flag now applies in place (requirement 3). The gallery reload was the no-JS design working, not a defect, and the plain-form path is still pinned by the INV-4 golden. The defect R2 fixes is the full-size EJECTION, `view.html`'s flag form carrying no `back`. The test's real claim — the key reaches the server and the server's state comes back — is kept, and asserted more strictly | | test_booth.py L789 | the kept booth renders BEFORE the ephemeral one (`html.index("links") < html.index("scratch")`) | replaced by the Desk's stated order (needs → new → everything, each with its own key) | the kept-first order was the lane's; with no lane there is no kept-first rule, and a second hidden ordering would break INV-2 | | test_booth.py L810-811 | lane absent when nothing is kept | these two SURVIVE unchanged (they assert absence and stay true) | — | diff --git a/tests/test_embed_browser.py b/tests/test_embed_browser.py index a8affea..bc2a8aa 100644 --- a/tests/test_embed_browser.py +++ b/tests/test_embed_browser.py @@ -595,11 +595,13 @@ def test_the_keyboard_flag_actually_submits(browser, live): Asserted end to end: press f, and the flag must come back from the server. R2 C3 (docs/contracts/r2_flow.contract.md, "Assertions that change"): this - used to expect a NAVIGATION — the flag form POSTed and the page reloaded. - That reload is the defect R2 removes. The claim that matters is kept and - tightened: the flag must come back from the SERVER (the swapped tile is - server-rendered), and a marker set on the window before the keypress must - survive, which a reload would wipe.""" + used to expect a NAVIGATION — the flag form POSTed, 303'd and reloaded. That + was the no-JS design working, not a defect, and it still is with scripts + off (tests/golden/r2_mark_303.json replays those responses byte for byte). + What changed is that WITH JS ON the flag now applies in place. The claim + that matters is kept and tightened: the flag must come back from the SERVER + (the swapped tile is server-rendered), and a marker set on the window before + the keypress must survive, which a reload would wipe.""" base, root = live _gallery(root) page = browser.new_page()