From 1a3a040cc3d86f790011aace9403d36ed316cce5 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 17 Apr 2026 18:49:04 +0100 Subject: [PATCH] test: move chat markdown sidebar to direct render --- ui/src/ui/chat-markdown.browser.test.ts | 40 ------------------- ui/src/ui/views/chat.test.ts | 51 +++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 40 deletions(-) delete mode 100644 ui/src/ui/chat-markdown.browser.test.ts diff --git a/ui/src/ui/chat-markdown.browser.test.ts b/ui/src/ui/chat-markdown.browser.test.ts deleted file mode 100644 index 6306bcd93ab..00000000000 --- a/ui/src/ui/chat-markdown.browser.test.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { describe, expect, it } from "vitest"; -import { mountApp, registerAppMountHooks } from "./test-helpers/app-mount.ts"; - -registerAppMountHooks(); - -describe("chat markdown rendering", () => { - it("renders markdown inside tool output sidebar", async () => { - const app = mountApp("/chat"); - await app.updateComplete; - - const timestamp = Date.now(); - app.chatMessages = [ - { - role: "assistant", - content: [ - { type: "toolcall", name: "noop", arguments: {} }, - { type: "toolresult", name: "noop", text: "Hello **world**" }, - ], - timestamp, - }, - ]; - - await app.updateComplete; - - const toolSummary = app.querySelector(".chat-tool-msg-summary"); - expect(toolSummary).not.toBeNull(); - toolSummary?.click(); - - await app.updateComplete; - - const openSidebarButton = app.querySelector(".chat-tool-card__action-btn"); - expect(openSidebarButton).not.toBeNull(); - openSidebarButton?.click(); - - await app.updateComplete; - - const strongNodes = Array.from(app.querySelectorAll(".sidebar-markdown strong")); - expect(strongNodes.some((node) => node.textContent === "world")).toBe(true); - }); -}); diff --git a/ui/src/ui/views/chat.test.ts b/ui/src/ui/views/chat.test.ts index 5268b3a746a..1d548d62535 100644 --- a/ui/src/ui/views/chat.test.ts +++ b/ui/src/ui/views/chat.test.ts @@ -1705,6 +1705,57 @@ 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(".chat-tool-msg-summary"); + expect(toolSummary).not.toBeNull(); + toolSummary?.dispatchEvent(new MouseEvent("click", { bubbles: true })); + await flushTasks(); + + const openSidebarButton = container.querySelector(".chat-tool-card__action-btn"); + expect(openSidebarButton).not.toBeNull(); + openSidebarButton?.dispatchEvent(new MouseEvent("click", { bubbles: true })); + await flushTasks(); + + const strongNodes = Array.from(container.querySelectorAll(".sidebar-markdown strong")); + expect(strongNodes.some((node) => node.textContent === "world")).toBe(true); + }); + it("lets a tool call collapse while keeping matching tool output visible", async () => { const container = document.createElement("div");