import { describe, expect, it } from "vitest"; import type { Node } from "@xyflow/react"; import type { NodeType } from "@/types"; import { getNodeHeaderMediaMeta } from "@/components/nodes/nodeHeaderMedia"; function makeNode(type: NodeType, data: Record): Node { return { id: `${type}-1`, type, position: { x: 0, y: 0 }, data, } as Node; } describe("getNodeHeaderMediaMeta", () => { it("uses uploaded image filename and pixel dimensions", () => { expect(getNodeHeaderMediaMeta(makeNode("imageInput", { image: "data:image/png;base64,input", filename: "act2-shot1-window.png", dimensions: { width: 496, height: 864 }, }), "Image Input")).toEqual({ kind: "image", name: "act2-shot1-window.png", dimensions: "496 x 864", }); }); it("uses generation history id and configured resolution for generated images", () => { expect(getNodeHeaderMediaMeta(makeNode("nanoBanana", { outputImage: "data:image/png;base64,out", imageHistory: [{ id: "history-123", timestamp: 1, prompt: "", aspectRatio: "1:1", model: "m" }], selectedHistoryIndex: 0, resolution: "2K", }), "Nano Banana")).toEqual({ kind: "image", name: "history-123", dimensions: "2K", }); }); it("uses configured video resolution for generated video nodes", () => { expect(getNodeHeaderMediaMeta(makeNode("generateVideo", { outputVideo: "https://cdn.example.com/video.mp4", videoHistory: [{ id: "video-123", timestamp: 1, prompt: "", model: "m" }], selectedVideoHistoryIndex: 0, resolution: "720p", }), "Seedance")).toEqual({ kind: "video", name: "video-123", dimensions: "720p", }); }); });