Merge remote-tracking branch 'origin/pr-579' into codex/pr-557-589-security-integration

This commit is contained in:
ddCat
2026-09-22 11:05:07 +08:00
3 changed files with 104 additions and 8 deletions

View File

@@ -1,6 +1,7 @@
import { describe, expect, test } from "bun:test";
import { storyboardRowsFromTask } from "../src/lib/canvas/canvas-project-domain";
import { storyboardRowsToProjectShots } from "../src/pages/projects/detail/chapter-storyboard-production";
import type { GenerationTask } from "../src/services/api/task-center";
function storyboardTask(resultJson: string): GenerationTask {
@@ -44,6 +45,34 @@ describe("storyboardRowsFromTask", () => {
expect(storyboardRowsFromTask(task).rows).toHaveLength(1);
});
test("title 不是字符串时仍可恢复任务结果", () => {
const task = storyboardTask(JSON.stringify({ title: { value: "章节" }, rows: [{ shotNumber: 1, plotDescription: "单镜头" }] }));
expect(storyboardRowsFromTask(task).title).toBeUndefined();
expect(storyboardRowsFromTask(task).rows).toHaveLength(1);
});
test("text 为结构化对象时仍可解析分镜行", () => {
const task = storyboardTask(JSON.stringify({ text: { title: "章节", rows: [{ shotNumber: 1, plotDescription: "单镜头" }] } }));
expect(storyboardRowsFromTask(task).rows).toHaveLength(1);
});
test("镜头文本字段不是字符串时仍可继续落库", () => {
const task = storyboardTask(JSON.stringify({ rows: [{
plotDescription: { text: "对象形式的剧情" },
dialogue: ["台词一", "台词二"],
camera: { value: "中景" },
motion: { description: "缓慢推进" },
timeBeats: 3,
}] }));
const result = storyboardRowsFromTask(task);
const shots = storyboardRowsToProjectShots(result.rows);
expect(shots[0]?.description).toBe("对象形式的剧情");
expect(shots[0]?.revision.dialogue).toBe("台词一、台词二");
expect(shots[0]?.revision.cameraAngle).toBe("中景");
expect(shots[0]?.revision.cameraMovement).toBe("缓慢推进");
expect(shots[0]?.revision.actionBeats).toEqual([{ description: "3" }]);
});
test("text 内层不是 JSON 时抛出缺行错误", () => {
// 无契约时期模型返回 Markdown 表格的真实场景。
const task = storyboardTask(JSON.stringify({ mode: "text", text: "| 7-41 | 全景/拉远 | 桃园结义 |" }));