mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 12:30:44 +00:00
test: move chat markdown sidebar to direct render
This commit is contained in:
@@ -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<HTMLElement>(".chat-tool-msg-summary");
|
||||
expect(toolSummary).not.toBeNull();
|
||||
toolSummary?.click();
|
||||
|
||||
await app.updateComplete;
|
||||
|
||||
const openSidebarButton = app.querySelector<HTMLElement>(".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);
|
||||
});
|
||||
});
|
||||
@@ -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<HTMLElement>(".chat-tool-msg-summary");
|
||||
expect(toolSummary).not.toBeNull();
|
||||
toolSummary?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
|
||||
await flushTasks();
|
||||
|
||||
const openSidebarButton = container.querySelector<HTMLElement>(".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");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user