From b53278a7f7d810b850dce69e13c86b8cf93620e0 Mon Sep 17 00:00:00 2001 From: Caio Pizzol Date: Thu, 16 Apr 2026 12:54:58 -0700 Subject: [PATCH] fix(test): update tracked-replace assertion to match word-diff behavior MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR #2817 added word-level diffing so multi-word tracked replacements fragment into per-word insert/delete pairs — "a tracked style" → "new fancy" becomes two tracked changes ("a" → "new" around a preserved space, then "tracked style" → "fancy"). The `getDocumentText()` assertion in programmatic-tracked-change.spec.ts still expected the pre-word-diff behaviour where "new fancy" appeared as one contiguous string, which produced this on all three browsers: Expected substring: "new fancy" Received string: "Here is anew tracked stylefancy change" Assert the inserted words "new" and "fancy" each appear in the document text instead, and leave a comment explaining the new semantics so the next reader doesn't have to retrace this. Ran tests/comments/programmatic-tracked-change.spec.ts in chromium locally — all 5 cases pass. --- .../tests/comments/programmatic-tracked-change.spec.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/behavior/tests/comments/programmatic-tracked-change.spec.ts b/tests/behavior/tests/comments/programmatic-tracked-change.spec.ts index a70299bac7..5bb8420cb4 100644 --- a/tests/behavior/tests/comments/programmatic-tracked-change.spec.ts +++ b/tests/behavior/tests/comments/programmatic-tracked-change.spec.ts @@ -60,7 +60,12 @@ test('tracked replace via document-api', async ({ superdoc }) => { assertMutationSucceeded('replaceText', receipt); await superdoc.waitForStable(); - await expect.poll(() => getDocumentText(superdoc.page)).toContain('new fancy'); + // word-diff (PR #2817) fragments multi-word tracked replacements into per-word + // insert/delete pairs, so "new fancy" appears as two separate inserts around + // the surviving space token. Assert both inserted words are present rather + // than a contiguous substring, which was the pre-word-diff assumption. + await expect.poll(() => getDocumentText(superdoc.page)).toContain('new'); + await expect.poll(() => getDocumentText(superdoc.page)).toContain('fancy'); await assertTrackChangeTypeCount(superdoc, 'insert'); await superdoc.snapshot('programmatic-tc-replaced');