69 lines
2.4 KiB
TypeScript
69 lines
2.4 KiB
TypeScript
import { expect, test } from "@playwright/test";
|
|
import { defaultVideoCanvasEffectPresets } from "../../lib/video-canvas/config";
|
|
import {
|
|
getVideoCanvasAttachedEffect,
|
|
rankVideoCanvasEffectPresets,
|
|
setVideoCanvasAttachedEffect,
|
|
} from "../../lib/video-canvas/video-effects";
|
|
|
|
test.describe("video effect library", () => {
|
|
test("ships the 49 observed recommended effects with usable thumbnails", () => {
|
|
expect(defaultVideoCanvasEffectPresets).toHaveLength(49);
|
|
expect(defaultVideoCanvasEffectPresets.every((preset) => preset.featured)).toBe(true);
|
|
expect(
|
|
defaultVideoCanvasEffectPresets.every((preset) =>
|
|
preset.thumbnailUrl.startsWith(
|
|
"https://libtv-res.liblib.art/tool/cinematic/",
|
|
),
|
|
),
|
|
).toBe(true);
|
|
});
|
|
|
|
test("ranks a submitted semantic search without removing unmatched effects", () => {
|
|
const ranked = rankVideoCanvasEffectPresets(
|
|
defaultVideoCanvasEffectPresets,
|
|
"产品扫光",
|
|
);
|
|
|
|
expect(ranked).toHaveLength(defaultVideoCanvasEffectPresets.length);
|
|
expect(ranked.slice(0, 10).map((preset) => preset.id)).toEqual([
|
|
"product-light-sweep",
|
|
"macro-push",
|
|
"underwater-slow",
|
|
"cyber-makeup",
|
|
"multi-angle",
|
|
"float-in",
|
|
"prada-change",
|
|
"red-carpet-flash",
|
|
"bee-camera-kling",
|
|
"dragon-rider",
|
|
]);
|
|
});
|
|
|
|
test("stores, replaces, and removes a single inline video effect", () => {
|
|
const originalDraft = {
|
|
params: { prompt: "保留原提示词" },
|
|
prompt: "保留原提示词",
|
|
};
|
|
const first = defaultVideoCanvasEffectPresets[0];
|
|
const second = defaultVideoCanvasEffectPresets[1];
|
|
const attached = setVideoCanvasAttachedEffect(originalDraft, first);
|
|
const replaced = setVideoCanvasAttachedEffect(attached, second);
|
|
|
|
expect(getVideoCanvasAttachedEffect(attached)).toMatchObject({
|
|
id: "bee-camera",
|
|
title: "小蜜蜂运镜",
|
|
});
|
|
expect(getVideoCanvasAttachedEffect(replaced)).toMatchObject({
|
|
id: "cloud-dive",
|
|
title: "穿云而入",
|
|
});
|
|
expect((replaced.params as Record<string, unknown>).prompt).toBe("保留原提示词");
|
|
|
|
const cleared = setVideoCanvasAttachedEffect(replaced, null);
|
|
expect(getVideoCanvasAttachedEffect(cleared)).toBeNull();
|
|
expect((cleared.params as Record<string, unknown>).prompt).toBe("保留原提示词");
|
|
expect((cleared as Record<string, unknown>).prompt).toBe("保留原提示词");
|
|
});
|
|
});
|