ai-chatbot/tests/routes/video-analysis-tools.test.ts

56 lines
1.8 KiB
TypeScript

import { expect, test } from "@playwright/test";
import {
DEFAULT_VIDEO_ANALYSIS_COST,
VIDEO_STORY_NODE_HEIGHT,
VIDEO_STORY_NODE_WIDTH,
getVideoStoryPlacement,
normalizeVideoAnalysisTimeline,
} from "../../lib/video-canvas/video-analysis";
test.describe("video canvas analysis tools", () => {
test("matches the competitor analysis price and result size", () => {
expect(DEFAULT_VIDEO_ANALYSIS_COST).toBe(2);
expect(VIDEO_STORY_NODE_WIDTH).toBe(800);
expect(VIDEO_STORY_NODE_HEIGHT).toBe(400);
});
test("places the first story directly below its source", () => {
expect(
getVideoStoryPlacement(
{ id: "source", x: 120, y: 240, width: 622, height: 350 },
[{ id: "source", x: 120, y: 240, width: 622, height: 350 }],
),
).toEqual({ x: 120, y: 684 });
});
test("moves a new story away from occupied output space", () => {
const placement = getVideoStoryPlacement(
{ id: "source", x: 120, y: 240, width: 622, height: 350 },
[
{ id: "source", x: 120, y: 240, width: 622, height: 350 },
{ id: "story", x: 120, y: 684, width: 800, height: 400 },
],
);
expect(placement).not.toEqual({ x: 120, y: 684 });
});
test("fits model timestamps to the real source duration", () => {
const rows = normalizeVideoAnalysisTimeline(
[
{ startTime: "0", endTime: "5", duration: "5", shot: "1" },
{ startTime: "5", endTime: "10", duration: "5", shot: "2" },
{ startTime: "10", endTime: "15", duration: "5", shot: "3" },
],
5,
);
expect(rows.map(({ startTime, endTime, duration }) => ({ startTime, endTime, duration }))).toEqual([
{ startTime: "0", endTime: "1.67", duration: "1.67" },
{ startTime: "1.67", endTime: "3.33", duration: "1.67" },
{ startTime: "3.33", endTime: "5", duration: "1.67" },
]);
});
});