1import { RuntimeRequestId } from "@t3tools/contracts";
2import { renderToStaticMarkup } from "react-dom/server";
3import { describe, expect, it } from "vite-plus/test";
4
5import { ComposerPendingApprovalActions } from "./ComposerPendingApprovalActions";
6
7describe("ComposerPendingApprovalActions", () => {
8 it("keeps the main decisions visible and secondary decisions in the menu", () => {
9 const markup = renderToStaticMarkup(
10 <ComposerPendingApprovalActions
11 requestId={RuntimeRequestId.make("approval-1")}
12 canRespond
13 isResponding={false}
14 onRespondToApproval={async () => undefined}
15 />,
16 );
17
18 expect(markup).toContain(">Decline<");
19 expect(markup).toContain(">Approve<");
20 expect(markup).not.toContain(">Cancel<");
21 expect(markup).not.toContain("Always allow this session");
22 });
23
24 it("keeps secondary provider labels out of the compact action row", () => {
25 const markup = renderToStaticMarkup(
26 <ComposerPendingApprovalActions
27 requestId={RuntimeRequestId.make("approval-safari")}
28 canRespond
29 isResponding={false}
30 options={[
31 { decision: "decline", label: "Decline" },
32 { decision: "acceptAlways", label: "Always allow Safari" },
33 { decision: "accept", label: "Approve" },
34 ]}
35 onRespondToApproval={async () => undefined}
36 />,
37 );
38
39 expect(markup).not.toContain("Always allow Safari");
40 expect(markup).toContain(">Approve<");
41 expect(markup).not.toContain("Always allow this session");
42 });
43
44 it("preserves provider labels for the main decisions", () => {
45 const markup = renderToStaticMarkup(
46 <ComposerPendingApprovalActions
47 requestId={RuntimeRequestId.make("approval-1")}
48 canRespond
49 isResponding={false}
50 options={[
51 { decision: "accept", label: "Allow once" },
52 { decision: "decline", label: "Deny" },
53 ]}
54 onRespondToApproval={async () => undefined}
55 />,
56 );
57
58 expect(markup).toContain("Allow once");
59 expect(markup).toContain("Deny");
60 expect(markup).not.toContain(">Approve<");
61 expect(markup).not.toContain(">Decline<");
62 });
63});