Open History to see the last commit
1import { ApprovalRequestId } from "@t3tools/contracts";
2import { renderToStaticMarkup } from "react-dom/server";
3import { describe, expect, it } from "vite-plus/test";
4
5import { ComposerPendingApprovalPanel } from "./ComposerPendingApprovalPanel";
6
7describe("ComposerPendingApprovalPanel", () => {
8 it("keeps the complete command readable in the compact row", () => {
9 const detail = `bun run release -- ${"x".repeat(500)}\nsecond line`;
10 const markup = renderToStaticMarkup(
11 <ComposerPendingApprovalPanel
12 approval={{
13 requestId: ApprovalRequestId.make("approval-1"),
14 requestKind: "command",
15 createdAt: "2026-07-18T00:00:00.000Z",
16 detail,
17 }}
18 pendingCount={1}
19 />,
20 );
21
22 expect(markup).toContain(detail);
23 expect(markup).not.toContain("Command approval requested");
24 });
25
26 it("falls back to the approval kind when the provider sends an empty detail", () => {
27 const markup = renderToStaticMarkup(
28 <ComposerPendingApprovalPanel
29 approval={{
30 requestId: ApprovalRequestId.make("approval-2"),
31 requestKind: "file-read",
32 createdAt: "2026-07-18T00:00:00.000Z",
33 detail: "",
34 }}
35 pendingCount={1}
36 />,
37 );
38
39 expect(markup).toContain("File read approval");
40 });
41
42 it("shows the app name and message for an MCP access request", () => {
43 const markup = renderToStaticMarkup(
44 <ComposerPendingApprovalPanel
45 approval={{
46 requestId: ApprovalRequestId.make("approval-safari"),
47 requestKind: "mcp-elicitation",
48 createdAt: "2026-08-24T00:00:00.000Z",
49 appName: "Safari",
50 detail: "Allow ChatGPT to use Safari?",
51 }}
52 pendingCount={1}
53 />,
54 );
55
56 expect(markup).toContain(">Safari<");
57 expect(markup).toContain("Allow ChatGPT to use Safari?");
58 });
59
60 it("preserves the full app name and approval message", () => {
61 const appName = "A".repeat(200);
62 const detail = "Allow ChatGPT to access the selected application?";
63 const markup = renderToStaticMarkup(
64 <ComposerPendingApprovalPanel
65 approval={{
66 requestId: ApprovalRequestId.make("approval-long-app-name"),
67 requestKind: "mcp-elicitation",
68 createdAt: "2026-08-24T00:00:00.000Z",
69 appName,
70 detail,
71 }}
72 pendingCount={1}
73 />,
74 );
75
76 expect(markup).toContain(appName);
77 expect(markup).toContain(detail);
78 });
79});