import { describe, expect, it } from "vitest"; import { aiMarkdownLinkUrlFromClick, formatAiInlineMarkdown, handleAiMarkdownLinkClick, normalizeAiMarkdownLink } from "@/lib/aiMarkdown"; describe("formatAiInlineMarkdown", () => { it("renders http links for external browser handling", () => { const html = formatAiInlineMarkdown("See [docs](https://example.com/a?x=1&y=2)."); expect(html).toContain('href="https://example.com/a?x=1&y=2"'); expect(html).toContain('target="_blank"'); expect(html).toContain('rel="noopener noreferrer"'); }); it("does not render unsafe link schemes", () => { const html = formatAiInlineMarkdown("[run](javascript:alert(1))"); expect(html).toContain("run"); expect(html).not.toContain("javascript:"); expect(html).not.toContain(" { const html = formatAiInlineMarkdown(""); expect(html).toContain("<script>alert(1)</script>"); expect(html).not.toContain("