feat(*): 短剧创作工作台 - 完善章节分镜、资产管理、技能运行与生成任务恢复
This commit is contained in:
1 parent
4f07daae9e
commit
2f6832f99c
113 files changed
+7016
-723
No files matched your search
@@ -0,0 +1,32 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
|
||||
import { linkSelectedProjectAssets } from "@/pages/projects/detail/project-asset-linking";
|
||||
|
||||
describe("project asset batch linking", () => {
|
||||
test("links every selected asset instead of only the first one", async () => {
|
||||
const visited: string[] = [];
|
||||
const result = await linkSelectedProjectAssets(["asset-1", "asset-2", "asset-3"], async (id) => {
|
||||
visited.push(id);
|
||||
return { id };
|
||||
});
|
||||
|
||||
expect(visited).toEqual(["asset-1", "asset-2", "asset-3"]);
|
||||
expect(result.linked.map((item) => item.id)).toEqual(["asset-1", "asset-2", "asset-3"]);
|
||||
expect(result.failedCount).toBe(0);
|
||||
});
|
||||
|
||||
test("keeps successful links and reports partial failures", async () => {
|
||||
const result = await linkSelectedProjectAssets(["asset-1", "asset-2"], async (id) => {
|
||||
if (id === "asset-2") throw new Error("不可用");
|
||||
return id;
|
||||
});
|
||||
|
||||
expect(result).toEqual({ linked: ["asset-1"], failedCount: 1 });
|
||||
});
|
||||
|
||||
test("surfaces the failure when no asset can be linked", async () => {
|
||||
await expect(linkSelectedProjectAssets(["asset-1"], async () => {
|
||||
throw new Error("素材已失效");
|
||||
})).rejects.toThrow("素材已失效");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user