The dismissal test waits for the frame, not the popup - #430
Open
serenakeyitan wants to merge 1 commit into
Open
Conversation
`dismissal spares the drag and the artifact pill` failed about one run in four, always on its own first assertion: `precondition: a word click did not open the composer`. The frame decides whether a click dismisses or acts, from its own `shellUiOpen` copy of the state — and the shell only sends that in an effect, after React has already unmounted the card. The preceding test closes the composer with the X button and this one clicks a word a few milliseconds later; when that mousedown lands in the gap, the frame still believes something is open, reads the click as a dismissal, and posts `tdoc:cleared` instead of a word selection. `openCount()` was watching the shell's half of a two-part state change. Mirror `shellUiOpen` onto `<html>` as `data-tdoc-ui-open`, next to `data-tdoc-selecting`, `data-tdoc-editing` and `data-tdoc-interaction-mode` which are already there, and gate the test on the frame's own copy instead of on a timeout. Also: step 2 never clicked the pill. `boundingBox()` is already in main-frame coordinates for an element inside an iframe, and the test added the doc-frame offset to it a second time, putting the click 48px low, on prose. Prose dismisses too, so the assertion passed without exercising the path it is named after. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
PreviewOpen this: https://pr-430-tdoc-preview.jyshi1107.workers.dev/ — the homepage, this PR's code This link is unique to this PR. New commits update the same URL. It is not tdoc.dev. Preview has no Durable Object — concurrent comments use the KV fallback. Data expires in 14 days. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #429. Flagged as an unrelated flake in #428; this is its own issue and its own PR.
dismissal spares the drag and the artifact pillfailed about one run in four. It was never the drag or the pill — every failure was the test's own first assertion:The race
Closing a card lands in two steps. React unmounts
.tdoc-popupat commit; the frame — which is what actually decides whether a click dismisses or acts — hears about it oneuseEffectand onepostMessagelater:The preceding test ends by clicking
.tdoc-popup button.x. This one measures geometry and clicks a word a few milliseconds after that. When the mousedown lands inside the gap,shellUiOpeninserver/frame-probe.jsis stilltrue, so the frame reads the click as a dismissal —swallowClick = true, mousedown returns early, mouseup poststdoc:clearedinstead of reporting a word selection. No composer, failed precondition.openCount()only ever watched the shell's half of a two-part state change. Same shape as the Move anchor test, where the banner renders before the frame has been told it is re-anchoring.The fix
data-tdoc-selecting,data-tdoc-editinganddata-tdoc-interaction-modeare already mirrored onto<html>in the frame, and tests already wait on them.shellUiOpenwas the one piece of frame state that was not, so nothing could wait for it. Mirror it asdata-tdoc-ui-openand gate the test on the frame's own copy:Three gates: before the opening click, after it, and after the close between step 1 and step 2 (replacing a 200ms sleep). No blanket waits added.
A second defect in the same test
Step 2 never clicked the pill.
boundingBox()is already in main-frame coordinates for an element inside an iframe; the test added the doc-frame offset a second time. Measured live:48px below the pill, on prose. A click on prose while a card is open also dismisses, so
openCount() === 0passed and the assertion has been vacuous since #403 — the pill path it is named after was never exercised. Dropping the doubled offset puts the click on the pill centre, and the newframeKnows(true)gate is what keeps that real click deterministic.Testing
Baseline on clean
origin/main, 10 runs: 2 failures, both the same assertion.After, 8 consecutive runs of
node test/browser-editing.test.js: 8/8 green, 18 passed 0 failed each.node test/run.js(the offline merge gate): PASS — all 75 suites green, includingdismiss-rule.test.js, whose four source-shape guards still hold.🤖 Generated with Claude Code