Skip to content

fix(test): update tracked-replace assertion to match word-diff behavior#2851

Merged
caio-pizzol merged 1 commit into
mainfrom
caio/fix-tracked-replace
Apr 16, 2026
Merged

fix(test): update tracked-replace assertion to match word-diff behavior#2851
caio-pizzol merged 1 commit into
mainfrom
caio/fix-tracked-replace

Conversation

@caio-pizzol

Copy link
Copy Markdown
Contributor

The `tracked replace via document-api` behavior test has been red on main across all three browsers since #2817 (word-level diffing) landed. Word-diff intentionally fragments multi-word tracked replacements into per-word insert/delete pairs, so "new fancy" is no longer a contiguous substring in the document β€” the test just wasn't updated alongside the feature.

  • Replace the `.toContain('new fancy')` assertion with individual `.toContain('new')` and `.toContain('fancy')` checks, matching the new per-word change shape.
  • Leave a short comment pointing at feat(word-diff): implement word-level diffing for granular text changesΒ #2817 so future readers don't have to dig through history.
  • Other tests in the file (`tracked delete`, `direct insert`, `tracked insert at cursor`, `addToHistory:false`) all still pass β€” ran the whole file in chromium locally.

Rejected: changing word-diff itself (splits multi-word replacements on purpose for granular tracked changes β€” behaviour feels right, test was stale).

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.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

βœ… All modified and coverable lines are covered by tests.

πŸ“’ Thoughts on this report? Let us know!

@caio-pizzol
caio-pizzol added this pull request to the merge queue Apr 16, 2026
Merged via the queue into main with commit 4a01c92 Apr 16, 2026
15 checks passed
@caio-pizzol
caio-pizzol deleted the caio/fix-tracked-replace branch April 16, 2026 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants