You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.7 KiB
53 lines
1.7 KiB
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<string, unknown>): 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",
|
|
});
|
|
});
|
|
});
|
|
|