Repository navigation
[lexical-playground] Chore: Stabilize the collab dangling-text e2e tests - #8933
Merged
Merged
Conversation
## Description
`Collaboration.spec.mjs` has been intermittently failing on
`collab-mac (24.x, webkit)`, at "Remove dangling text from YJS when there is no
preceding text node".
Both "dangling text" tests end by reloading the left iframe and asserting that
the content survived the refresh:
await page.evaluate(() => {
document
.querySelector('iframe[name="left"]')
.contentDocument.location.reload();
});
await assertHTML(page, html`...`);
`location.reload()` returns as soon as the navigation is *scheduled*, so
`assertHTML`'s 5s polling budget also had to cover the bundle fetch, editor
mount, websocket connect and initial Yjs sync. When that overran, the assertion
failed while the frame was still booting and its contenteditable was not yet in
the DOM -- an intermittent failure unrelated to what the test checks.
This adds a `reloadCollabFrame(page, name)` helper that registers a
`framenavigated` listener, triggers the reload, then waits for the frame to
navigate and come back up, so the assertion that follows measures the restored
document rather than the page load. The readiness wait is extracted from the
collab startup path in `exposeLexicalEditor` as `waitForCollabFrame`, now
scoped with `.first()` since a reloaded frame can already hold several
paragraphs where startup only ever saw one.
Both tests also undo a burst of typing and expect the whole burst to revert as
a unit, without freezing the Yjs `UndoManager`'s 500ms wall-clock capture
window. A stall between two keystrokes splits the burst across stack items and
leaves a partial revert behind, so they now call `freezeCollabUndoGrouping` as
the other tests in this file already do.
The agent-facing docs are adjusted too, because the rules in `AGENTS.md` were
reachable but not actually reaching agents. `CLAUDE.md` described `AGENTS.md`
in prose and linked to it, which lets a reader judge the file's relevance from
a one-line summary and skip it; its contents are now just `@AGENTS.md`, the
import form that inlines the file rather than pointing at it. Within
`AGENTS.md`, the existing requirement that commit messages match
`.github/pull_request_template.md` was a single bullet separated from the
related hygiene section by "Build System"; it is expanded into a per-section
breakdown -- how to build the subject line, what belongs under `## Description`,
and that `## Test plan` needs real Before/After command output rather than a
description of it -- and "Commit and PR Hygiene for Agents" moves up beneath
"Commits and Pull Requests" so every commit-message rule lives in one place.
## Test plan
Run the spec against the collab playground:
CI=true E2E_PORT=4000 E2E_EDITOR_MODE=rich-text-with-collab \
pnpm exec concurrently -k -s first "pnpm run collab" \
"pnpm exec cross-env E2E_BROWSER=chromium \
E2E_EDITOR_MODE=rich-text-with-collab playwright test \
--project=chromium --workers=4 --retries=0 --repeat-each=3 \
packages/lexical-playground/__tests__/e2e/Collaboration.spec.mjs"
### Before
"Remove dangling text from YJS when there is no preceding text node" failed on
every run, at the post-reload assertion (`Collaboration.spec.mjs:297`):
Error: Timeout 5000ms exceeded while waiting on the predicate
at packages/lexical-playground/__tests__/utils/index.mjs:394
> 394 | }).toPass({intervals: [100, 250, 500], timeout: 5000});
| ^
at assertHTMLOnPageOrFrame (packages/.../utils/index.mjs:394:6)
at assertHTML (packages/.../utils/index.mjs:426:5)
at packages/.../e2e/Collaboration.spec.mjs:297:5
`CLAUDE.md` summarized `AGENTS.md` instead of importing it:
$ cat CLAUDE.md
# CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Agent Instructions
For detailed architectural guidance, build commands, and development workflows, see **[AGENTS.md](./AGENTS.md)**.
### After
The full spec passes, 6 tests x 3 repeats, 4 workers, no retries:
Running 18 tests using 4 workers
...
18 passed (2.9m)
`AGENTS.md` is imported rather than described:
$ cat CLAUDE.md
@AGENTS.md
WebKit could not be exercised here (Playwright downloads it, but the Linux
system libraries it needs are unavailable), so the runs above are Chromium
only; the reload race is not browser specific.
Co-Authored-By: Claude Opus 5 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
etrepum
marked this pull request as ready for review
August 5, 2026 23:15
etrepum
requested review from
acywatson,
fantactuka,
ivailop7,
potatowagon and
zurfyx
as code owners
August 5, 2026 23:15
zurfyx
approved these changes
Aug 6, 2026
Merged
This branch was successfully deployed
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.
Description
Collaboration.spec.mjshas been intermittently failing oncollab-mac (24.x, webkit), at "Remove dangling text from YJS when there is no preceding text node".Both "dangling text" tests end by reloading the left iframe and asserting that the content survived the refresh:
location.reload()returns as soon as the navigation is scheduled, soassertHTML's 5s polling budget also had to cover the bundle fetch, editor mount, websocket connect and initial Yjs sync. When that overran, the assertion failed while the frame was still booting and its contenteditable was not yet in the DOM -- an intermittent failure unrelated to what the test checks.This adds a
reloadCollabFrame(page, name)helper that registers aframenavigatedlistener, triggers the reload, then waits for the frame to navigate and come back up, so the assertion that follows measures the restored document rather than the page load. The readiness wait is extracted from the collab startup path inexposeLexicalEditoraswaitForCollabFrame, now scoped with.first()since a reloaded frame can already hold several paragraphs where startup only ever saw one.Both tests also undo a burst of typing and expect the whole burst to revert as a unit, without freezing the Yjs
UndoManager's 500ms wall-clock capture window. A stall between two keystrokes splits the burst across stack items and leaves a partial revert behind, so they now callfreezeCollabUndoGroupingas the other tests in this file already do.The agent-facing docs are adjusted too, because the rules in
AGENTS.mdwere reachable but not actually reaching agents.CLAUDE.mddescribedAGENTS.mdin prose and linked to it, which lets a reader judge the file's relevance from a one-line summary and skip it; its contents are now just@AGENTS.md, the import form that inlines the file rather than pointing at it. WithinAGENTS.md, the existing requirement that commit messages match.github/pull_request_template.mdwas a single bullet separated from the related hygiene section by "Build System"; it is expanded into a per-section breakdown -- how to build the subject line, what belongs under## Description, and that## Test planneeds real Before/After command output rather than a description of it -- and "Commit and PR Hygiene for Agents" moves up beneath "Commits and Pull Requests" so every commit-message rule lives in one place.Test plan
Run the spec against the collab playground:
Before
"Remove dangling text from YJS when there is no preceding text node" failed on every run, at the post-reload assertion (
Collaboration.spec.mjs:297):CLAUDE.mdsummarizedAGENTS.mdinstead of importing it:After
The full spec passes, 6 tests x 3 repeats, 4 workers, no retries:
AGENTS.mdis imported rather than described:WebKit could not be exercised here (Playwright downloads it, but the Linux system libraries it needs are unavailable), so the runs above are Chromium only; the reload race is not browser specific.