import { describe, expect, it } from "bun:test";
import { renderToStaticMarkup } from "react-dom/server";
import { Markdown } from "../src/components/transcript/Markdown";
function renderMarkdown(text: string): string {
return renderToStaticMarkup();
}
describe("Transcript Markdown", () => {
it("preserves assistant soft line breaks for tree-shaped prose", () => {
const html = renderMarkdown("요청 요지\n├── 현재 collab guest는 텍스트 prompt는 보낼 수 있음\n└── 빠진 것은 guest → host 방향의 이미지 업로드/첨부 입력 경로임");
expect(html).toContain("요청 요지
");
expect(html).toContain("있음
");
expect(html).toContain("├── 현재 collab guest는");
expect(html).toContain("└── 빠진 것은 guest → host 방향");
});
it("preserves soft line breaks inside tight list items", () => {
const html = renderMarkdown("- Decision:\n │ └── detail");
expect(html).toContain("
Decision:
│ └── detail");
});
it("continues escaping raw HTML", () => {
const html = renderMarkdown("safe\n
");
expect(html).toContain("safe
");
expect(html).toContain("<img src=x onerror=alert(1)>");
expect(html).not.toContain("
{
const html = renderMarkdown("▃");
expect(html).toContain("▃");
expect(html).not.toContain("<span>");
expect(html).not.toContain("<text>");
});
it("unescapes HTML entities inside span and text HTML tags safely", () => {
const html = renderMarkdown("<▃> & "test" 😀 😀");
expect(html).toContain("<▃> & "test" 😀 😀");
});
it("strips advisory wrapper tags but renders their content", () => {
const html = renderMarkdown('\nKeep this advice.\n');
expect(html).toContain("Keep this advice.");
expect(html).not.toContain("<advisory");
expect(html).not.toContain("</advisory>");
});
});