Repository navigation
test(studio): a failed copy test waits for each copy's read, not 10 ms - #8964
Merged
Merged
Conversation
jrusso1020
approved these changes
Nov 27, 2026
jrusso1020
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed at 5db25d6. Approving.
Read whole: useClipboard.source.test.ts. Read in part: useClipboard.ts (the copy and paste paths, lines 243-380). Nothing was run.
What I checked:
- The stand-in reads
fail.onafter its delay, so the old fixed 10 ms wait could flip the switch before the first read was answered. That matches the reported failure (expected [] to have a length of 1). answered(n)waits for the nth call and then for that call's own answer, sofail.onis settled for read 1 before it is turned on, and for read 2 before it is turned off. The paste then awaits the clipboard's own chain, so no further wait is needed.- The 15 ms first read pins the slow-then-quick order on every machine, and the delay is reset before the second copy.
- Test-only: the clipboard code is unchanged.
Notes, not blockers:
toHaveBeenCalledTimes(n)is exact. If a copy ever makes a second read, this test stops with a wait timeout instead of a clear message. Fine today since each copy reads one file.- The body has no literal "fails without the fix:" line. Since this changes only a test, I took the Test plan line (old waits plus the slow first read fail 3 of 3) as that statement.
Need: yes, removes a timing flake · Size: 11/3, one file · Reuse: uses the file's existing delayMs · Simpler: no · Structure: fine
Risk: low, test-only.
— Rames
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.
What
useClipboard.source.test.ts, "a copy that fails > leaves the previous copy on the clipboard", now waits for each copy's file read to be answered instead of waiting a fixed 10 ms after each copy.Why
The test copies, turns on read failures, copies again, then pastes and expects the first copy. It gave each copy 10 ms of real time to finish its read. When the first read took longer (a busy Windows runner), the read was answered after failures were turned on, so the first copy failed as well and the paste had nothing:
expected [] to have a length of 1 but got +0on Windows in the merge queue.Related work
Test-only change; the clipboard code is unchanged.
How
answered(n)waits until the test's fetch stand-in has been calledntimes, then for that call's answer.Test plan
On Linux (vitest,
packages/studio):Not run: the Windows job itself; its CI run on this PR is the check.