1import { renderToStaticMarkup } from "react-dom/server";
2import { EnvironmentId } from "@t3tools/contracts";
3import { describe, expect, it } from "vite-plus/test";
4
5import { ComposerStashMenu } from "./ComposerStashMenu";
6
7describe("ComposerStashMenu", () => {
8 it("shows saved image thumbnails and incomplete image states", () => {
9 const markup = renderToStaticMarkup(
10 <ComposerStashMenu
11 entries={[
12 {
13 id: "with-images",
14 createdAt: new Date(0).toISOString(),
15 prompt: "Compare these screenshots",
16 attachments: [
17 {
18 id: "image-one",
19 name: "before.png",
20 mimeType: "image/png",
21 sizeBytes: 128,
22 dataUrl: "data:image/png;base64,AA==",
23 },
24 ],
25 droppedImageNames: ["after.png"],
26 unreadableImageNames: [],
27 pendingImageCount: 0,
28 },
29 {
30 id: "saving-images",
31 createdAt: new Date(0).toISOString(),
32 prompt: "Save this image",
33 attachments: [],
34 droppedImageNames: [],
35 unreadableImageNames: [],
36 pendingImageCount: 1,
37 },
38 ]}
39 stashShortcutLabel="Ctrl+S"
40 onRestore={() => {}}
41 onDelete={() => {}}
42 onClose={() => {}}
43 />,
44 );
45
46 expect(markup).toContain('src="data:image/png;base64,AA=="');
47 expect(markup).toContain("1 image dropped");
48 expect(markup).toContain("saving 1 image");
49 });
50
51 it("labels mixed file and image stashes without treating images as files", () => {
52 const markup = renderToStaticMarkup(
53 <ComposerStashMenu
54 entries={[
55 {
56 id: "mixed-attachments",
57 createdAt: new Date(0).toISOString(),
58 prompt: "",
59 attachments: [
60 {
61 id: "image-one",
62 name: "before.png",
63 mimeType: "image/png",
64 sizeBytes: 128,
65 dataUrl: "data:image/png;base64,AA==",
66 },
67 ],
68 files: [
69 {
70 id: "file-one",
71 name: "report.pdf",
72 mimeType: "application/pdf",
73 sizeBytes: 42,
74 attachmentId: "pending-report-pdf",
75 environmentId: EnvironmentId.make("environment-1"),
76 },
77 ],
78 droppedImageNames: [],
79 },
80 ]}
81 stashShortcutLabel={null}
82 onRestore={() => {}}
83 onDelete={() => {}}
84 onClose={() => {}}
85 />,
86 );
87
88 expect(markup).toContain("(2 attachments)");
89 expect(markup).not.toContain("(2 files)");
90 });
91});