Skip to content

fix: three flaky tests: Find's late selection in the long document, tracked typing across a second, the big CSV's time - #59

Open
pierreneter wants to merge 4 commits into
mainfrom
fix/flaky-tests
Open

pierreneter wants to merge 4 commits into
mainfrom
fix/flaky-tests

Conversation

@pierreneter

@pierreneter pierreneter commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Three tests failed now and then without a change that touched them. Each is found and fixed at the cause.

1. e2e/plain.spec.ts: the long document's last page (test only)

Seen: waitForFunction timed out at plain.spec.ts:69 in 2 of 13 CI runs (#57 on Nov 25, #54 on Nov 27), on commits that have nothing to do with it.

Cause: Find scrolls to the match and selects it a few frames later, once the scroll has come to rest (gotoMatch → afterScroll → editor.input.restore). The test went on as soon as the paragraph was in view. When frames come late, that selection lands after the test has put its own caret behind END_MARKER:

  • the match is selected again and the ! replaces it (the page reads !), or
  • the key press goes by the caret of before the search, the ! goes into page 1 and the view follows it.

Either way page 200 never reads END_MARKER!.

Fix: the test waits until the match is selected before it closes the Find bar.

Checked: with every animation frame made 20 to 250 ms late, 8 of 15 runs failed before and 0 of 24 with the wait. Not slowed down, it passed before and passes now.

2. e2e/docx-track.spec.ts: typing with Track changes on (product fix)

Seen: Expected "…tea[+ms][-m]", Received "…tea[+m][+s][-m]" on #55's run.

Cause: every tracked edit is stamped with its own time, to the second (DocxEditor.replace), and two runs join only when their marks are equal. m and s typed across the end of a second were two insertions. Not only in the test: text typed with Track changes on was saved as one w:ins per second of typing.

Fix: in trackEdit, what is typed or struck out right next to a change of the same kind by the same author takes that change's mark: one insertion (or deletion), dated when it began, as Word does. Not continued: a change of the other kind, someone else's change, a move. Text taken out of what someone else inserted still carries their insertion.

Checked:

  • unit test with edits a second apart (test/track.test.ts): tea[+m][+s] before, tea[+ms] now; also Backspace twice, typing before an insertion, next to a deletion, next to someone else's change;
  • the browser test with the page's clock moved on a second at every reading: fails without the fix with exactly CI's message, passes with it.

3. test/convert-service.test.ts: the big CSV written to stdout (test only)

Seen: office-convert › to stdout, whole timed out on the test VM every time, and passed on #56's CI run in 4.49 s.

Cause: the 600,000-row CSV takes the engine 4.5 s on CI and 5.3 s on the VM; a test has 5 s by default.

Fix: the test has a minute of its own. It passes on the VM in 6.7 s.

Tests

On the test VM (Bun 1.4.4, Chromium), on main with #54, #57 and #56: bun test 1752 pass, 0 fail; e2e/docx-track.spec.ts 2 of 2; e2e/plain.spec.ts 4 of 4, three times; bun run typecheck clean.

Not in here

  • The pool tests of test/convert-service.test.ts also lean on the same CSV taking longer than a fixed time (1.5 s, 100 ms). They have not failed; they would on a much faster machine.
  • A reader who presses Enter in Find and clicks into the text within the same few frames can have the caret taken back to the match the same way as in 1. Left as it is: it needs a machine slow enough to click between two frames.

🤖 Generated with Claude Code

pierreneter and others added 4 commits November 27, 2026 16:34
… selected what it found

Find scrolls to the match, and selects it a few frames later, once the
scroll has come to rest. The test went on as soon as the paragraph was in
view: on a busy machine the selection then came after the test's own
caret, and the "!" replaced the word, or went by the caret of before and
took the view to page 1. The test timed out on its last page (2 of the
last 13 runs on CI). It now waits for the selection. With animation frames
made 20 to 250 ms late: 8 of 15 runs failed before, 0 of 24 now.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ever the clock says

Every tracked edit is stamped with its own time, to the second, and two
runs join only under the same mark. A word typed across the end of a
second was two insertions ("tea[+m][+s]"), as was every second of typing
in the saved file; e2e/docx-track.spec.ts failed on CI whenever "ms" was
typed across one.

What is typed or struck out right next to a change of the same kind by
the same author now takes that change's mark: one insertion (or deletion)
of when it began, as in Word. A change of another kind, someone else's
change and a move are not gone on with; text taken out of what someone
inserted still carries their insertion.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The 600,000-row CSV takes the engine 4.5 s on CI and more than 5 s on a
slower machine, and a test has 5 s by default: there it always timed out,
on CI it passed by half a second. The test now has a minute of its own.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@pierreneter pierreneter changed the title fix: two flaky browser tests: Find's late selection in the long document, tracked typing across a second fix: three flaky tests: Find's late selection in the long document, tracked typing across a second, the big CSV's time Nov 27, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant