Skip to content

Commit 4a01c92

Browse files
authored
fix(test): update tracked-replace assertion to match word-diff behavior (#2851)
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.
1 parent dd3e04a commit 4a01c92

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

tests/behavior/tests/comments/programmatic-tracked-change.spec.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,12 @@ test('tracked replace via document-api', async ({ superdoc }) => {
6060
assertMutationSucceeded('replaceText', receipt);
6161
await superdoc.waitForStable();
6262

63-
await expect.poll(() => getDocumentText(superdoc.page)).toContain('new fancy');
63+
// word-diff (PR #2817) fragments multi-word tracked replacements into per-word
64+
// insert/delete pairs, so "new fancy" appears as two separate inserts around
65+
// the surviving space token. Assert both inserted words are present rather
66+
// than a contiguous substring, which was the pre-word-diff assumption.
67+
await expect.poll(() => getDocumentText(superdoc.page)).toContain('new');
68+
await expect.poll(() => getDocumentText(superdoc.page)).toContain('fancy');
6469
await assertTrackChangeTypeCount(superdoc, 'insert');
6570

6671
await superdoc.snapshot('programmatic-tc-replaced');

0 commit comments

Comments
 (0)