前台分辨率并集只收启用且权重大于 0 的供应线路,避免停用 4K 线路后仍出现不可路由档位。生成回写新媒体时清除旧 assetId,堵住原地重生后「旧素材 + 新资源」配对。 Co-authored-by: Cursor <cursoragent@cursor.com>
38 lines
1.4 KiB
TypeScript
38 lines
1.4 KiB
TypeScript
import { describe, expect, test } from "bun:test";
|
|
|
|
import { applyGeneratedMediaResultMetadata, videoMetadata } from "@/lib/canvas/canvas-generation-task-sync";
|
|
import { CanvasNodeType, type CanvasNodeData } from "@/types/canvas";
|
|
|
|
function videoNode(assetId: string, storageKey: string): CanvasNodeData {
|
|
return {
|
|
id: "node-1",
|
|
type: CanvasNodeType.Video,
|
|
title: "镜头",
|
|
position: { x: 0, y: 0 },
|
|
width: 320,
|
|
height: 180,
|
|
metadata: { assetId, storageKey, content: "https://example.test/old.mp4", prompt: "旧提示词" },
|
|
};
|
|
}
|
|
|
|
describe("applyGeneratedMediaResultMetadata", () => {
|
|
test("clears the previous asset binding when a regenerated media result lands", () => {
|
|
const node = videoNode("asset-old", "video:old");
|
|
const next = applyGeneratedMediaResultMetadata(node, videoMetadata({
|
|
url: "https://example.test/new.mp4",
|
|
storageKey: "video:new",
|
|
width: 1280,
|
|
height: 720,
|
|
bytes: 12,
|
|
mimeType: "video/mp4",
|
|
durationMs: 4000,
|
|
}), { prompt: "新提示词" });
|
|
|
|
expect(next.assetId).toBeUndefined();
|
|
expect(next.storageKey).toBe("video:new");
|
|
expect(next.content).toBe("https://example.test/new.mp4");
|
|
expect(next.prompt).toBe("新提示词");
|
|
expect(next.status).toBe("success");
|
|
});
|
|
});
|