Skip to content

[lexical-y] Chore: Add the tests of the parked keep-ends pull request, with main's failures as expected failures - #9631

Merged
zurfyx merged 2 commits into
mainfrom
zurfyx/y-keep-ends-tests
Oct 31, 2026
Merged

zurfyx merged 2 commits into
mainfrom
zurfyx/y-keep-ends-tests

Conversation

@zurfyx

@zurfyx zurfyx commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Description

#9617 (keep each key's run end in Cursor#collapseGap, for #9609) is parked: every version of it changed what other code does with the kept item, and a few randomized sessions came out wrong where main is right (see its Parked section). Its tests move to main here, as #9605 did for #9562:

Test plan

Before

The files do not exist on main.

After

pnpm exec vitest run --project unit packages/lexical-y/src/__tests__/unit/regressions/TypedTextAfterDeletedSpace.test.ts packages/lexical-y/src/__tests__/unit/regressions/CollapseKeepsEnds.test.ts packages/lexical-y/src/__tests__/unit/CollapseKeepsEndsProperty.test.ts packages/lexical-y/src/__tests__/unit/regressions/KeepEndsSessions.test.ts packages/lexical-y/src/__tests__/unit/regressions/KeepEndsUndoPlainWord.test.ts on main (1853707):

 ✓ |unit| packages/lexical-y/src/__tests__/unit/regressions/TypedTextAfterDeletedSpace.test.ts (1 test)
 ✓ |unit| packages/lexical-y/src/__tests__/unit/regressions/KeepEndsUndoPlainWord.test.ts (2 tests)
 ✓ |unit| packages/lexical-y/src/__tests__/unit/regressions/KeepEndsSessions.test.ts (4 tests)
 ✓ |unit| packages/lexical-y/src/__tests__/unit/regressions/CollapseKeepsEnds.test.ts (18 tests)
 ✓ |unit| packages/lexical-y/src/__tests__/unit/CollapseKeepsEndsProperty.test.ts (6 tests)
 Test Files  5 passed (5)
      Tests  15 passed | 16 expected fail (31)

npx tsc -p tsconfig.test.json --noEmit and eslint pass.

…, with main's failures as expected failures

## Description

#9617 (keep each key's run end in `Cursor#collapseGap`, for #9609) is parked: every version of it changed what other code does with the kept item, and a few randomized sessions came out wrong where main is right (see its Parked section). Its tests move to main here, as #9605 did for #9562:

- `regressions/CollapseKeepsEnds.test.ts`: #9609 with a real collapse (12 cases, `test.fails` on main: the collapse deletes the comment's end), and controls that pass on main (a kept end must leave the value after the run; bold and style).
- `CollapseKeepsEndsProperty.test.ts`: random sessions compared with the same session without any collapse; taking turns passes on main, the concurrent case is `test.fails` (#9609).
- `regressions/KeepEndsSessions.test.ts`: four reduced randomized sessions. 2725 and 1861 (restored text takes no comment it never had) pass on main and failed with #9617's first rule; 4694 and 3645 (a comment main's collapse drops from text no delete touched) are `test.fails`.
- `regressions/KeepEndsUndoPlainWord.test.ts` and `regressions/TypedTextAfterDeletedSpace.test.ts`: sequential and concurrent sessions where a kept end gave text a comment it never had; both pass on main and guard any later design.

## Test plan

### Before

The files do not exist on main.

### After

`pnpm exec vitest run --project unit packages/lexical-y/src/__tests__/unit/regressions/TypedTextAfterDeletedSpace.test.ts packages/lexical-y/src/__tests__/unit/regressions/CollapseKeepsEnds.test.ts packages/lexical-y/src/__tests__/unit/CollapseKeepsEndsProperty.test.ts packages/lexical-y/src/__tests__/unit/regressions/KeepEndsSessions.test.ts packages/lexical-y/src/__tests__/unit/regressions/KeepEndsUndoPlainWord.test.ts` on main (1853707):

```
 ✓ |unit| packages/lexical-y/src/__tests__/unit/regressions/TypedTextAfterDeletedSpace.test.ts (1 test)
 ✓ |unit| packages/lexical-y/src/__tests__/unit/regressions/KeepEndsUndoPlainWord.test.ts (2 tests)
 ✓ |unit| packages/lexical-y/src/__tests__/unit/regressions/KeepEndsSessions.test.ts (4 tests)
 ✓ |unit| packages/lexical-y/src/__tests__/unit/regressions/CollapseKeepsEnds.test.ts (18 tests)
 ✓ |unit| packages/lexical-y/src/__tests__/unit/CollapseKeepsEndsProperty.test.ts (4 tests)
 Test Files  5 passed (5)
      Tests  13 passed | 16 expected fail (29)
```

`npx tsc -p tsconfig.test.json --noEmit` and eslint pass.
@vercel

vercel Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
lexical Ready Ready Preview Oct 31, 2026 12:59am UTC
lexical-playground Ready Ready Preview Oct 31, 2026 12:59am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 30, 2026
@meta-code-review

meta-code-review Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 31, 2026, 1:09 AM UTC

@pkg-pr-new

pkg-pr-new Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
lexical

npm i https://pkg.pr.new/lexical@9631

@lexical/a11y

npm i https://pkg.pr.new/@lexical/a11y@9631

@lexical/clipboard

npm i https://pkg.pr.new/@lexical/clipboard@9631

@lexical/code

npm i https://pkg.pr.new/@lexical/code@9631

@lexical/code-core

npm i https://pkg.pr.new/@lexical/code-core@9631

@lexical/code-prism

npm i https://pkg.pr.new/@lexical/code-prism@9631

@lexical/code-shiki

npm i https://pkg.pr.new/@lexical/code-shiki@9631

@lexical/compiler

npm i https://pkg.pr.new/@lexical/compiler@9631

@lexical/devtools-core

npm i https://pkg.pr.new/@lexical/devtools-core@9631

@lexical/dragon

npm i https://pkg.pr.new/@lexical/dragon@9631

@lexical/eslint-plugin

npm i https://pkg.pr.new/@lexical/eslint-plugin@9631

@lexical/extension

npm i https://pkg.pr.new/@lexical/extension@9631

@lexical/fast-check

npm i https://pkg.pr.new/@lexical/fast-check@9631

@lexical/file

npm i https://pkg.pr.new/@lexical/file@9631

@lexical/hashtag

npm i https://pkg.pr.new/@lexical/hashtag@9631

@lexical/headless

npm i https://pkg.pr.new/@lexical/headless@9631

@lexical/history

npm i https://pkg.pr.new/@lexical/history@9631

@lexical/html

npm i https://pkg.pr.new/@lexical/html@9631

@lexical/internal

npm i https://pkg.pr.new/@lexical/internal@9631

@lexical/link

npm i https://pkg.pr.new/@lexical/link@9631

@lexical/list

npm i https://pkg.pr.new/@lexical/list@9631

@lexical/mark

npm i https://pkg.pr.new/@lexical/mark@9631

@lexical/markdown

npm i https://pkg.pr.new/@lexical/markdown@9631

@lexical/mdast

npm i https://pkg.pr.new/@lexical/mdast@9631

@lexical/offset

npm i https://pkg.pr.new/@lexical/offset@9631

@lexical/overflow

npm i https://pkg.pr.new/@lexical/overflow@9631

@lexical/plain-text

npm i https://pkg.pr.new/@lexical/plain-text@9631

@lexical/react

npm i https://pkg.pr.new/@lexical/react@9631

@lexical/rich-text

npm i https://pkg.pr.new/@lexical/rich-text@9631

@lexical/selection

npm i https://pkg.pr.new/@lexical/selection@9631

@lexical/table

npm i https://pkg.pr.new/@lexical/table@9631

@lexical/tailwind

npm i https://pkg.pr.new/@lexical/tailwind@9631

@lexical/text

npm i https://pkg.pr.new/@lexical/text@9631

@lexical/utils

npm i https://pkg.pr.new/@lexical/utils@9631

@lexical/y

npm i https://pkg.pr.new/@lexical/y@9631

@lexical/yjs

npm i https://pkg.pr.new/@lexical/yjs@9631

commit: 303354b

@meta-code-review meta-code-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me: moving #9617's cases onto main, with main's failures as test.fails, keeps #9609 and the cases its variants broke pinned whatever design lands next. The expected failures fail on main at their final assertions (the comment spreading onto cc and dd, c2 missing from wk75, c9 missing in 3645), and each plain guard fails against at least one of #9617's variants, so they discriminate.

A few optional, non-blocking suggestions:

  1. The concurrent property rests on one seed (packages/lexical-y/src/__tests__/unit/CollapseKeepsEndsProperty.test.ts:301). Of seeds 1-60 only seed 53 fails on main, in both client orders (the next is 69). As one test.fails, the other 59 concurrent sessions per order do not guard main: a regression in any of them stays green, and a change that alters seed 53 alone turns CI red with just "Expect test to fail". Consider a plain test over the seeds minus a known-failing list, plus a test.fails for seed 53 that names #9609.
  2. Name the fix on 4694 and 3645 (packages/lexical-y/src/__tests__/unit/regressions/KeepEndsSessions.test.ts:330 and :342). packages/lexical-y/AGENTS.md (Testing) asks that a known failure be a test.fails naming the issue or pull request that fixes it. 3645 matters most: it differs from the no-collapse document only after its last step, ['undo', 2] (line 134), and applying #9630's Binding.ts change makes it report "Expect test to fail" with the collapse unchanged. Naming #9617 and #9630 there, and rewording "now" in the comment at lines 340-341, tells whoever lands #9630 why it flips.
  3. Check self-check warnings in the property test (CollapseKeepsEndsProperty.test.ts:274). run collects errors but not warnings, so a binding self-check mismatch would not fail it, although the harness turns the self-check on so that a mismatch fails tests and the other property suites assert warnings is empty. No warnings occur on main in these sessions, so it costs nothing.
  4. Nit: comments that read as main's behavior (regressions/CollapseKeepsEnds.test.ts:45-47, the describe title at line 116, and CollapseKeepsEndsProperty.test.ts:51). "It keeps the end now" and "Before the collapse kept ends" describe #9617; on main the collapse still deletes the end, which is why those cases are test.fails.

No changeset is needed for a tests-only change (AGENTS.md, Changesets).

}
}, 600_000);

test.fails(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: of seeds 1-60 only seed 53 fails on main (both client orders; the next failing seed is 69), so this test.fails rests on that one session and the other 59 per order guard nothing. A plain test over the seeds minus a known-failing list, plus a test.fails for seed 53 that names #9609, would keep them as a live guard.

const fresh = await freshReader(t.a);
return {
clocks: [t.a, t.b].map(p => p.doc.store.getClock(p.doc.clientID)),
errors: [...t.a.errors, ...t.b.errors, ...fresh.errors],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: the peers' warnings (where the binding's self-check reports a mismatch) are not collected, so a self-check failure would not fail this property, unlike expectConverged. Adding the three peers' warnings costs nothing: none occur on main in these sessions.

// Main's collapse dropped c9 from "wxq4xq56abcd" (3645), where a document
// read without any collapse keeps it. (With every undo press changing what
// the document shows, the session's last undo now also removes c9.)
test.fails(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: packages/lexical-y/AGENTS.md (Testing) asks that a known failure name the issue or pull request that fixes it, and neither this case nor 4694 above does. This one differs from the no-collapse document only after the final ['undo', 2] (line 134), and #9630's undo-press change alone makes it report "Expect test to fail"; naming #9617 and #9630 here would explain the flip when either lands.

// comments' value, nor the run's last items, and for the collaborator they
// bracket deleted content only. The collapse used to delete both, and once
// merged the restore had no end: the comment covered every later word and
// line. It keeps the end now.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: "It keeps the end now" describes #9617; on main the collapse still deletes the end, which is why the cases below are test.fails. Something like "#9617 (parked) keeps the end" reads correctly on main.

… exact

## Description

Review of the test-only change found two expected failures that a real behaviour change could slip past:

- The concurrent property test was one `test.fails` over 60 seeds. Since seed 53 fails on main, a change that broke a seed passing on main kept the whole test failing, so nothing noticed. Now one regular test runs every seed and checks everything (no errors, no more writes, the same characters, peers and a fresh reader agreeing); it skips the own-text comparison only on the seeds where main lets a comment spread (53). A `test.fails` per such seed checks only that comparison (#9609).
- KeepEndsSessions 3645 shows main's drop of c9 only after the session's last undo. It also flips with #9630 (every undo press changes what the document shows), with no collapse change. Its name and comment now say so.

## Test plan

### Before

`CollapseKeepsEndsProperty.test.ts` on main: 2 passed, 2 expected fail; one aggregate `test.fails` per id order.

### After

`pnpm exec vitest run --project unit packages/lexical-y/src/__tests__/unit/CollapseKeepsEndsProperty.test.ts packages/lexical-y/src/__tests__/unit/regressions/KeepEndsSessions.test.ts` on main (1853707):

```
     ✓ taking turns: every character shows as with no collapse (ids 1,2)
     ✓ typing ‖ deletes: the document's own text shows as with no collapse (ids 1,2)
     ✓ taking turns: every character shows as with no collapse (ids 2,1)
     ✓ typing ‖ deletes: the document's own text shows as with no collapse (ids 2,1)
      Tests  6 passed | 4 expected fail (10)
```

Seed 53 is the only one of 60 that fails on main, in both id orders, and only on the own text (its other checks pass). `npx tsc -p tsconfig.test.json --noEmit` and eslint pass.

@meta-code-review meta-code-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. The new @lexical/y tests record main's known failures as test.fails, and each one fails at its final assertion: for #9609, the comment runs past its end; for sessions 4694 and 3645, a comment drops from text no delete touched. The 15 regular tests pass on main and guard whatever collapse design comes next.

Optional, non-blocking suggestions:

  1. Name the tracking issue in the 4694 expected failure (packages/lexical-y/src/__tests__/unit/regressions/KeepEndsSessions.test.ts:331). packages/lexical-y/AGENTS.md (Testing) asks that "a known failure is a test.fails that names the issue or pull request that fixes it". The bare (4694) is a session seed, but on GitHub it reads like issue #4694. The comment drop in 4694 and 3645 is a different symptom from the #9609 spread, and no issue or DECISIONS.md row tracks it yet. Opening one (or naming #9617), writing seed 4694 as the property test writes seed 53, and adding #9617 and #9631 to D65's links would keep it findable when a fix lands.
  2. Reword two comments that describe the parked design as current behaviour: regressions/CollapseKeepsEnds.test.ts:45-47 ("It keeps the end now.") and CollapseKeepsEndsProperty.test.ts:51-53 ("Before the collapse kept ends, …"). On main the collapse still deletes the end, which is why those cases are test.fails. Something like "#9617 (parked) kept the end; main still deletes it" would say that.

No changeset is needed: AGENTS.md exempts test-only changes.

// stays where a document read without any collapse has it: main's
// collapse dropped c2 from "wk75" (4694).
test.fails(
'a comment stays on text that deletes around it never touched (4694)',

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: packages/lexical-y/AGENTS.md (Testing) asks that a known failure be a test.fails that names the issue or pull request that fixes it. This title names neither, and the bare (4694) (a session seed) reads like issue #4694 on GitHub. Consider seed 4694 plus the issue that tracks the comment drop, or #9617 if that stays the fix vehicle.

// comments' value, nor the run's last items, and for the collaborator they
// bracket deleted content only. The collapse used to delete both, and once
// merged the restore had no end: the comment covered every later word and
// line. It keeps the end now.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: "It keeps the end now." describes #9617, which is parked. On main the collapse still deletes the end, which is why the cases below are test.fails. Something like "#9617 (parked) kept the end; main still deletes it" would avoid confusion. CollapseKeepsEndsProperty.test.ts:51-53 has the same wording.

@zurfyx
zurfyx added this pull request to the merge queue Oct 31, 2026
Merged via the queue into main with commit 17154c2 Oct 31, 2026
57 checks passed
zurfyx added a commit that referenced this pull request Oct 31, 2026
## Description

Merges main at f59f74d (#9631, #9642 and #9641). There were no conflicts.

## Test plan

### Before

The branch was on main 2e2acb7.

### After

```
$ pnpm exec vitest run --project unit --project scripts-unit
      Tests  30437 passed | 282 expected fail | 135 skipped (30854)
$ MATRIX_FULL=1 pnpm exec vitest run --project unit packages/lexical-y/src/__tests__/unit/regressions/WrapperTextFields.test.ts
      Tests  9062 passed | 206 expected fail (9268)
$ pnpm run ci-check
Found 0 errors
```

This branch was successfully deployed

2 active deployments
Preview – lexical — 303354b9 Deployed Oct 31, 2026 by vercel[bot]
Preview – lexical-playground — 303354b9 Deployed Oct 31, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant