feat: overlap renders stacked author marks (insert + delete) in both panes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
BenStullsBets
2026-06-26 17:50:39 -07:00
parent 7b59c324d5
commit ae19df78fb
2 changed files with 23 additions and 0 deletions
+15
View File
@@ -246,6 +246,21 @@ describe("wordDiffByAuthor", () => {
expect(html).not.toContain("cw-del-human");
expect(html).not.toContain("cw-del-claude");
});
test("emits SIBLING ins/del elements, never nested — CSS overlap rule in preview.css is a defensive forward guarantee", () => {
// The engine assigns the cluster's insertion author to all deletions in the same
// cluster (adjacency heuristic), so <del> and <ins> always carry the SAME author
// as siblings. Cross-author nesting (<del class="cw-del-X"><ins class="cw-ins-Y">)
// is never produced today. The CSS rule `.cw-del-claude .cw-ins-human { text-decoration: inherit }`
// guards against a future regression where such nesting appears.
const spans: AuthorSpan[] = [{ start: 0, end: 100, author: "human" }];
const html = wordDiffByAuthor("old text", "new text", 0, spans);
expect(html).toContain('<del class="cw-del-human">');
expect(html).toContain('<ins class="cw-ins-human">');
// Structural check: no <del> immediately wraps an <ins> (sibling, not nested).
// /<del[^>]*>[^<]*<ins/ would match a nested case but not a sibling case
// because [^<]* stops before the closing </del> tag.
expect(html).not.toMatch(/<del[^>]*>[^<]*<ins/);
});
});
import { renderPlain } from "../src/trackChangesModel";