Repository navigation
Fix flaky CKEditor caret placement in e2e tests (Firefox mid-word failure on master) - #473
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Three CKEditor tests put the caret with a DOM selection and then typed at once. CKEditor 5 copies a DOM selection into its model only on the next "selectionchange" event. When the key came first (a slow Firefox runner), CKEditor typed at the old model caret: "rThe dog walked the street" in place of "Thre dog walked the street". The mid-word test then saw no preview and failed on master. setCkEditorCaret now sets the selection with model.change and focuses the editing view, so the model and the DOM agree before the key. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bartekplus
marked this pull request as ready for review
October 5, 2026 09:11
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
Summary
Master failed in E2E Full (firefox, 2/2):
CKEditor inline preview hides trailing word chars when caret is mid-wordtimed out waiting for the inline preview.Root cause
The test seeds "The dog walked the street", sets the caret with a DOM selection at "Th|e", and types "r" at once.
CKEditor 5 copies a DOM selection into its model only when the next
selectionchangeevent arrives, which is asynchronous. If the key arrives first (a slow runner), CKEditor inserts the "r" at its old model caret, offset 0 aftersetData. The new failure dump shows exactly this:"rThe" is not the mid-word case, so FluentTyper correctly shows no preview, and the test times out. This is a race in the test, not a product bug. It is also not caused by #472: this test runs in the same shard, after the same tests, as before. It failed 1 time in the last 24 runs of that shard.
Fix
setCkEditorCaret(page, paragraph, offset | "end"). It focuses the editing view and sets the caret witheditor.model.change(writer => writer.setSelection(...)). CKEditor renders the model selection to the DOM, so the model and the DOM agree before the key is typed.CKEditor inline preview hides trailing word chars when caret is mid-wordCKEditor preserves paragraph break when accepting suggestion at line endCKEditor grammar/text-edit replacement applies in active second paragraphEvidence
A temporary probe workflow ran on this PR (it is removed in the last commit):
"dom":"rThe dog…"Locally: all CKEditor e2e tests pass in Chrome, and
bun run checkpasses. Firefox does not start on my machine (Firefox 156 cannot create a profile on this macOS version), so CI is the Firefox check.🤖 Generated with Claude Code