diff --git a/ui/src/ui/markdown.test.ts b/ui/src/ui/markdown.test.ts index 246bffa6192..9794ca8dd6a 100644 --- a/ui/src/ui/markdown.test.ts +++ b/ui/src/ui/markdown.test.ts @@ -1,5 +1,7 @@ +import { render } from "lit"; import { describe, expect, it, vi } from "vitest"; import { md, toSanitizedMarkdownHtml } from "./markdown.ts"; +import { renderMarkdownSidebar } from "./views/markdown-sidebar.ts"; describe("toSanitizedMarkdownHtml", () => { // ── Original tests from before markdown-it migration ── @@ -510,3 +512,21 @@ describe("toSanitizedMarkdownHtml", () => { }); }); }); + +describe("renderMarkdownSidebar", () => { + it("renders sanitized markdown content", () => { + const container = document.createElement("div"); + + render( + renderMarkdownSidebar({ + content: { kind: "markdown", content: "Hello **world**" }, + error: null, + onClose: () => undefined, + onViewRawText: () => undefined, + }), + container, + ); + + expect(container.querySelector(".sidebar-markdown strong")?.textContent).toBe("world"); + }); +}); diff --git a/ui/src/ui/views/chat.test.ts b/ui/src/ui/views/chat.test.ts index 92812ccf21f..2003f3f532d 100644 --- a/ui/src/ui/views/chat.test.ts +++ b/ui/src/ui/views/chat.test.ts @@ -8,6 +8,16 @@ import { normalizeMessage } from "../chat/message-normalizer.ts"; import type { SessionsListResult } from "../types.ts"; import { renderChat, type ChatProps } from "./chat.ts"; +vi.mock("./markdown-sidebar.ts", async () => { + const { html } = await import("lit"); + return { + renderMarkdownSidebar: (props: { content?: { content?: string; title?: string } | null }) => + html`
`, + }; +}); + function createSessions(): SessionsListResult { return { ts: 0, @@ -1516,57 +1526,6 @@ describe("chat view", () => { ); }); - it("renders markdown inside tool output sidebar", async () => { - const container = document.createElement("div"); - let sidebarContent: ChatProps["sidebarContent"] = null; - const messages = [ - { - role: "assistant", - content: [ - { type: "toolcall", name: "noop", arguments: {} }, - { type: "toolresult", name: "noop", text: "Hello **world**" }, - ], - timestamp: Date.now(), - }, - ]; - const renderWithSidebar = () => - render( - renderChat( - createProps({ - messages, - sidebarOpen: sidebarContent !== null, - sidebarContent, - sidebarError: null, - onOpenSidebar: (content) => { - sidebarContent = content; - renderWithSidebar(); - }, - onCloseSidebar: () => { - sidebarContent = null; - renderWithSidebar(); - }, - onRequestUpdate: renderWithSidebar, - }), - ), - container, - ); - - renderWithSidebar(); - - const toolSummary = container.querySelector