112 lines
3.1 KiB
TypeScript
112 lines
3.1 KiB
TypeScript
import { expect, test } from "@playwright/test";
|
|
import { defaultVideoCanvasMotionPresets } from "@/lib/video-canvas/config";
|
|
import {
|
|
composeVideoCanvasMotionPrompt,
|
|
normalizeVideoCanvasMotionMentions,
|
|
} from "@/lib/video-canvas/video-motion";
|
|
|
|
test.describe("video camera motion", () => {
|
|
test("matches the 23-item competitor catalog and preview order", () => {
|
|
expect(defaultVideoCanvasMotionPresets).toHaveLength(23);
|
|
expect(defaultVideoCanvasMotionPresets.map((preset) => preset.name)).toEqual([
|
|
"固定镜头",
|
|
"跟随拍摄",
|
|
"盘旋抬升",
|
|
"盘旋下降",
|
|
"镜头上摇",
|
|
"镜头下摇",
|
|
"镜头左摇",
|
|
"镜头右摇",
|
|
"镜头上升",
|
|
"镜头下降",
|
|
"镜头左移",
|
|
"镜头右移",
|
|
"镜头前推",
|
|
"镜头后移",
|
|
"变焦推进",
|
|
"变焦拉远",
|
|
"柯克变焦",
|
|
"环绕拍摄",
|
|
"滚筒旋转",
|
|
"第一视角",
|
|
"无人机",
|
|
"高空航拍",
|
|
"手持拍摄",
|
|
]);
|
|
expect(defaultVideoCanvasMotionPresets[22]?.previewUrl).toBe(
|
|
"https://libtv-res.liblib.art/tool/movement/23.webp",
|
|
);
|
|
});
|
|
|
|
test("normalizes structured motion mentions without removing duplicates", () => {
|
|
const mentions = normalizeVideoCanvasMotionMentions([
|
|
{
|
|
id: "motion first",
|
|
index: 1,
|
|
label: "固定镜头",
|
|
motionId: "fixed",
|
|
offset: 2,
|
|
prompt: "保持机位稳定",
|
|
},
|
|
{
|
|
id: "motion-second",
|
|
index: 2,
|
|
label: "固定镜头",
|
|
motionId: "fixed",
|
|
offset: 2,
|
|
prompt: "保持机位稳定",
|
|
},
|
|
]);
|
|
|
|
expect(mentions).toHaveLength(2);
|
|
expect(mentions[0]).toMatchObject({
|
|
custom: false,
|
|
id: "motion-first",
|
|
label: "固定镜头",
|
|
motionId: "fixed",
|
|
offset: 2,
|
|
});
|
|
expect(mentions[1]?.label).toBe("固定镜头");
|
|
});
|
|
|
|
test("persists all 23 catalog selections without truncating at 20", () => {
|
|
const mentions = normalizeVideoCanvasMotionMentions(
|
|
defaultVideoCanvasMotionPresets.map((preset, index) => ({
|
|
id: `motion-${index + 1}`,
|
|
index: index + 1,
|
|
label: preset.name,
|
|
motionId: preset.id,
|
|
prompt: preset.prompt,
|
|
})),
|
|
);
|
|
|
|
expect(mentions).toHaveLength(23);
|
|
expect(mentions[22]?.label).toBe("手持拍摄");
|
|
expect(mentions[22]?.index).toBe(23);
|
|
});
|
|
|
|
test("resolves ordered motion prompts only when building the generation request", () => {
|
|
const mentions = normalizeVideoCanvasMotionMentions([
|
|
{
|
|
id: "motion-1",
|
|
index: 1,
|
|
label: "固定镜头",
|
|
motionId: "fixed",
|
|
prompt: "保持机位稳定",
|
|
},
|
|
{
|
|
custom: true,
|
|
id: "motion-2",
|
|
index: 2,
|
|
label: "测试运镜",
|
|
motionId: "custom-1",
|
|
prompt: "镜头缓慢向前推进。",
|
|
},
|
|
]);
|
|
|
|
expect(composeVideoCanvasMotionPrompt("人物向前走", mentions)).toBe(
|
|
"人物向前走 运镜要求「固定镜头」:保持机位稳定 运镜要求「测试运镜」:镜头缓慢向前推进。",
|
|
);
|
|
});
|
|
});
|