Repository navigation
test: wait for the next row's draft read in the code block slot test - #33343
Conversation
The out-of-range test drags twice in one view. Its first drag fires two mouseups, and each schedules a selection check 50 ms later. When the second check lands after Escape, it re-opens the box over the first drag, filed under the fallback slot. The next drag's findByLabelText then resolves on that box before the next row's own check has run, so the draft key the test reads is still -1. Wait for the next row's draft read before asserting on it. Delaying the first drag's second check turns the test red on the parent every run with the CI assertion and leaves it green here; with the per-row draft key removed from the toolbar it still fails by name. Closes #32131
First Principles Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: this is a test-only change that waits on the second drag's own draft read, so the test can no longer read too early. If the next row is filed under the fallback slot, the test still fails. [DESIGN-REVIEWED] 889a04a Description read[DESCRIPTION-READ] 1229f51975cd6d9fbcec93c60059b50490722ad764f320740fa0bf3a8c44bb2b That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing to check. The PR only changes one test file and adds or changes no user-visible control, so no screenshot is needed. [UX-REVIEWED] 889a04a Description read[DESCRIPTION-READ] 42acb25157b6aef955861fbd0fb01702912b40f88cadc6595ccb87d6a01e52db That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: test (1 file). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: test-only change that adds one wait in the code block selection toolbar test so a late check from the first drag cannot reopen the comment box.
Problem / Motivation
Goal: The code block test "keeps an out-of-range passage in the fallback slot and the next row in its own slot" stops failing at random on CI, and still fails when the next row's draft is filed under the fallback slot.
website/src/test/SelectionToolbar.codeBlock.test.tsx> "keeps an out-of-range passage in the fallback slot and the next row in its own slot" failed on a Frontend Tests shard of a PR that never touched the toolbar (#31792), withAssertionError: expected -1 to be less than -1atexpect(nextStart).toBeLessThan(-1). The same file passes when run alone.Why it matters
A random red on a frontend shard lands on whoever pushed last. They rerun the shard and spend time proving the red is not theirs, while the test guards a real behaviour: a draft typed over one code row must not come back over another row.
Not a goal
SelectionToolbaritself: it files the next row's draft under that row's own slot; only the test read the slot too early.draftStore.read.mock.lastCall: each of their drags fires one mouseup, and the view unmounts between drags, which cancels any check still pending (see Sibling sweep).What changed (motivation → approach → change)
The test drags twice in one view. Its first drag fires two mouseups (one from the
dragInCodehelper, one from the test after it swaps in the out-of-range range), and each mouseup makes the toolbar look at the selection 50 ms later. On a busy CI worker the second look can come after the test has typed a draft and pressed Escape. It then re-opens the box over the first drag, filed under the fallback slot (-1). The second drag'sfindByLabelTextfinds that box straight away, before the second drag's own look has run, so the draft key the test reads is still-1.The test now waits for the second drag's draft read before it looks at the box:
await waitFor(() => expect(draftStore.read.mock.lastCall![1]).toBeLessThan(-1)). Every assertion stays. If the toolbar filed the next row under the fallback slot, the wait would give up after one second and the test would fail by name.Backwards compatibility
Compatible: test-only change; no product code, API or stored data changes.
Removes nothing: one test gains a wait before its existing assertions.
Tests
Changed: "keeps an out-of-range passage in the fallback slot and the next row in its own slot" in
website/src/test/SelectionToolbar.codeBlock.test.tsxwaits for the next row's draft read.Determinism proof (all from
website/). The test andSelectionToolbar.tsxare byte-identical at this PR's base, atd1a9a812d7(unmarked rows) and at2caa69b7a6(rows marked *):expect(nextStart).toBeLessThan(-1),expected -1 to be less than -1, the CI assertion{ repeats: 49 }on the test (50 runs){ repeats: 49 }on the test (50 runs)--maxWorkers=1SelectionToolbar.composer.test.tsx+MarkdownPanelCodeBlock.test.tsx, shuffled,--maxWorkers=3KIROCREW_ACT_STRICT=1, whole file-1inSelectionToolbar.tsx:457)The forced condition is a throwaway edit to the test, never committed. It delays the check that the first drag's second mouseup schedules, then pauses after Escape so that check lands before the second drag, as it did on CI:
The repeat runs above were taken on a heavily loaded shared host; the forced condition, not host load, is what reproduces the race.
Proof: not provable -- frontend test (prove.py runs Python only)
Manual verification
N/A: test-only change; the forced-condition runs above are the verification.
Screenshots / video
Why no screenshot: nothing renders differently; this change touches one test file only.
Related Issues
Closes #32131
Sibling sweep
Swept: git grep -n "draftStore.read.mock.lastCall" -- website/src/test/
Sibling: website/src/test/SelectionToolbar.codeBlock.test.tsx:457 -- changed here: the new wait, before the read at :459
Sibling: website/src/test/SelectionToolbar.codeBlock.test.tsx:171 -- not affected -- one mouseup per drag, and the view unmounts between drags
Sibling: website/src/test/SelectionToolbar.codeBlock.test.tsx:182 -- not affected -- one mouseup per drag, and the view unmounts between drags
Sibling: website/src/test/SelectionToolbar.codeBlock.test.tsx:206 -- not affected -- one mouseup per drag, and the view unmounts between drags
Sibling: website/src/test/SelectionToolbar.codeBlock.test.tsx:221 -- not affected -- one mouseup per drag, and the view unmounts between drags
Sibling: website/src/test/SelectionToolbar.codeBlock.test.tsx:230 -- not affected -- one mouseup per drag, and the view unmounts between drags
Sibling: website/src/test/SelectionToolbar.codeBlock.test.tsx:241 -- not affected -- one mouseup per drag, and the view unmounts between drags
Sibling: website/src/test/SelectionToolbar.codeBlock.test.tsx:250 -- not affected -- one mouseup per drag, and the view unmounts between drags
Sibling: website/src/test/SelectionToolbar.codeBlock.test.tsx:374 -- not affected -- one mouseup per drag, and the view unmounts between drags
Sibling: website/src/test/SelectionToolbar.codeBlock.test.tsx:411 -- not affected -- one mouseup per drag, and the view unmounts between drags
Sibling: website/src/test/SelectionToolbar.codeBlock.test.tsx:424 -- not affected -- two mouseups, but the test makes no second drag after them
Sibling: website/src/test/MarkdownPanelCodeBlock.test.tsx -- not affected -- each test makes one drag through
dragInCodealonePattern harvest
Rule candidate: review-prompt
Pattern: a
findBy*used as the barrier for a mock call that a deferred handler makes, when an earlier gesture in the same render can still have a deferred handler pending that renders the same elementChecklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributed under the project's Apache-2.0 license.