nandi/oripublic Fork 0
3017563d783a895a85f8f8ad162b58bb5d944946
Commits
Clone
git clone https://git.rickub.com/nandi/ori.git
git clone ssh://git@rickub.com/nandi/ori.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

forked from bots-garden/ori

ToolCallCard.test.tsx · 70 lines · 1.7 KBTypeScript Blame HistoryRaw
✨ Workspace panel, selectors, previews, desktop app, sandbox template, resizable file tree, light/dark theme 76d62ac k33g yesterday1import { render, screen } from "@testing-library/react";
2import { describe, expect, it } from "vitest";
3import type { ToolCall } from "../reducer";
4import { ToolCallCard } from "./ToolCallCard";
5
6function call(overrides: Partial<ToolCall>): ToolCall {
7 return {
8 toolCallId: "c1",
9 title: "A tool call",
10 toolKind: "other",
11 status: "completed",
12 contents: [],
13 locations: [],
14 ...overrides,
15 };
16}
17
18describe("ToolCallCard", () => {
19 it("renders execute output verbatim in a monospace block", () => {
20 const { container } = render(
21 <ToolCallCard
22 call={call({
23 toolKind: "execute",
24 contents: [
25 {
26 type: "content",
27 content: { type: "text", text: "* main\n remote/origin" },
28 },
29 ],
30 })}
31 />,
32 );
33
34 const output = container.querySelector("pre.tool-output");
35 expect(output).not.toBeNull();
36 // Verbatim: the "* " prefix must not have become a markdown list.
37 expect(output?.textContent).toBe("* main\n remote/origin");
38 expect(container.querySelector("ul li")).toBeNull();
39 });
40
41 it("renders backticked commands in the title as monospace code", () => {
42 const { container } = render(
43 <ToolCallCard
44 call={call({ toolKind: "execute", title: "Run `ls .memory/`" })}
45 />,
46 );
47
48 const code = container.querySelector(".tool-title code.inline-code");
49 expect(code?.textContent).toBe("ls .memory/");
50 });
51
52 it("renders non-execute text content as markdown", () => {
53 const { container } = render(
54 <ToolCallCard
55 call={call({
56 toolKind: "read",
57 contents: [
58 {
59 type: "content",
60 content: { type: "text", text: "**bold** result" },
61 },
62 ],
63 })}
64 />,
65 );
66
67 expect(container.querySelector("pre.tool-output")).toBeNull();
68 expect(screen.getByText("bold")).toBeDefined();
69 });
70});