import { renderToStaticMarkup } from "react-dom/server"; import { describe, expect, it, vi } from "vite-plus/test"; import { DiffCommentAnnotation } from "./DiffCommentAnnotation"; const callbacks = { onTextChange: vi.fn(), onCancel: vi.fn(), onComment: vi.fn(), onDelete: vi.fn(), }; describe("DiffCommentAnnotation", () => { it("renders the shared draft composer directly in the selected diff", () => { const markup = renderToStaticMarkup( , ); expect(markup).toContain("font-sans"); expect(markup).not.toContain("chat-composer-glass"); expect(markup).not.toContain("font-mono"); expect(markup).not.toContain("Local comment"); expect(markup).not.toContain("on +78"); expect(markup).toContain("⌘/Ctrl Enter to send"); expect(markup).toContain("Add a comment…"); expect(markup).toContain(">Comment"); expect(markup).toContain("autofocus"); const textareaControl = markup.match(/]*data-slot="textarea-control"[^>]*>/)?.[0]; expect(textareaControl).toBeDefined(); expect(textareaControl).not.toContain("ring-ring"); expect(markup).toContain("cursor-text"); }); it("lets a pull-request diff configure actions without replacing the composer", () => { const markup = renderToStaticMarkup( , ); expect(markup).toContain("Add a comment…"); expect(markup).toContain(">Add to review"); expect(markup.match(/]*disabled[^>]*>Add to review<\/button>/)).not.toBeNull(); expect(markup.match(/]*disabled[^>]*>Add to agent<\/button>/)).not.toBeNull(); }); it("renders a saved comment without a nested card or redundant range label", () => { const markup = renderToStaticMarkup( , ); expect(markup).toContain("font-sans"); expect(markup).not.toContain("chat-composer-glass"); expect(markup).not.toContain("on +78"); expect(markup).toContain("Please keep this branch explicit."); expect(markup).toContain('aria-label="Delete comment"'); expect(markup).toContain("border-s-2"); expect(markup).toContain("bg-primary/[0.045]"); expect(markup).toContain("lucide-message-circle"); }); it("renders draft text owned by the annotation wrapper", () => { const markup = renderToStaticMarkup( , ); expect(markup).toContain("Keep this unsaved draft"); }); });