45 lines
1.7 KiB
TypeScript
45 lines
1.7 KiB
TypeScript
import { expect, test } from "@playwright/test";
|
|
|
|
import {
|
|
getVideoDownloadExtension,
|
|
getVideoDownloadFilename,
|
|
normalizeVideoCanvasVideoDownloadConfig,
|
|
resolveVideoDownloadRuleCopy,
|
|
sanitizeVideoDownloadTitle,
|
|
VIDEO_WATERMARK_RULES_STORAGE_KEY,
|
|
} from "../../lib/video-canvas/video-download";
|
|
|
|
test.describe("video download tools", () => {
|
|
test("uses the node title as the downloaded filename", () => {
|
|
expect(getVideoDownloadFilename("视频37", "https://cdn.example.com/result.mp4", "video/mp4"))
|
|
.toBe("视频37.mp4");
|
|
expect(sanitizeVideoDownloadTitle('镜头/01:*?"<>|')).toBe("镜头-01-");
|
|
});
|
|
|
|
test("infers supported video extensions and falls back to mp4", () => {
|
|
expect(getVideoDownloadExtension("https://cdn.example.com/a.bin", "video/webm; charset=binary"))
|
|
.toBe("webm");
|
|
expect(getVideoDownloadExtension("https://cdn.example.com/a.mov?token=1"))
|
|
.toBe("mov");
|
|
expect(getVideoDownloadExtension("https://cdn.example.com/download"))
|
|
.toBe("mp4");
|
|
});
|
|
|
|
test("keeps a versioned preference key for the first-download watermark rules", () => {
|
|
expect(VIDEO_WATERMARK_RULES_STORAGE_KEY).toBe("video-canvas-watermark-rules-v1");
|
|
});
|
|
|
|
test("normalizes configurable watermark copy and resolves the site brand", () => {
|
|
const config = normalizeVideoCanvasVideoDownloadConfig({
|
|
rulesTitle: " 自定义规则 ",
|
|
rulesUrl: "javascript:alert(1)",
|
|
welcomeText: "欢迎使用{{siteName}}",
|
|
});
|
|
expect(config.rulesTitle).toBe("自定义规则");
|
|
expect(config.rulesUrl).toBe("https://resonate.feishu.cn/wiki/");
|
|
expect(resolveVideoDownloadRuleCopy(config.welcomeText, "由壹点AI")).toBe(
|
|
"欢迎使用由壹点AI",
|
|
);
|
|
});
|
|
});
|