F10 SLICE-2: add ProposalView + renderReview combined on-state render (#29)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ben Stull
2026-06-12 00:09:45 -07:00
parent 0311ad89ba
commit d59f22b22f
2 changed files with 110 additions and 0 deletions
+40
View File
@@ -257,6 +257,46 @@ describe("renderPlain", () => {
});
});
import { renderReview, type ProposalView } from "../src/trackChangesModel";
describe("renderReview", () => {
test("renderReview: human addition since baseline renders green ins / cw-by-human", () => {
const html = renderReview("hello", "hello world", [{ start: 6, end: 11, author: "human" }], []);
expect(html).toMatch(/<ins>[^<]*world[^<]*<\/ins>|cw-by-human/);
});
test("renderReview: deletion since baseline renders struck del/cw-del", () => {
const html = renderReview("hello world", "hello", [], []);
expect(html).toMatch(/<del>|cw-del/);
});
test("renderReview: a pending proposal renders a blue block with data-proposal-id and ✓/✗ actions", () => {
const proposals: ProposalView[] = [{ id: "p1", anchorStart: 0, anchorEnd: 5, replaced: "hello", replacement: "goodbye" }];
const html = renderReview("hello", "hello", [], proposals);
expect(html).toContain('class="cw-proposal"');
expect(html).toContain('data-proposal-id="p1"');
expect(html).toContain("cw-actions");
expect(html).toContain("goodbye");
expect(html).toMatch(/<del[^>]*>[^<]*hello[^<]*<\/del>|cw-del/);
});
test("renderReview: an unresolved proposal renders as a trailing block (never dropped)", () => {
const proposals: ProposalView[] = [{ id: "p2", anchorStart: null, anchorEnd: null, replaced: "x", replacement: "y" }];
const html = renderReview("a", "a", [], proposals);
expect(html).toContain('data-proposal-id="p2"');
expect(html).toContain("cw-proposal-unanchored");
});
test("renderReview is deterministic (same inputs → identical HTML)", () => {
const a = renderReview("hello", "hello world", [{ start: 6, end: 11, author: "human" }], []);
const b = renderReview("hello", "hello world", [{ start: 6, end: 11, author: "human" }], []);
expect(a).toBe(b);
});
test("renderReview: an atomic mermaid change is diffed whole (no inner author sentinels)", () => {
const base = "```mermaid\nflowchart LR\n A --> B\n```";
const cur = "```mermaid\nflowchart LR\n A --> C\n```";
const html = renderReview(base, cur, [], []);
expect(html).toContain("mermaid");
expect(html).not.toContain("cw-by-");
});
});
import { renderTrackChanges as rtc2 } from "../src/trackChangesModel";
describe("renderTrackChanges — intra-diagram mermaid (#22)", () => {