fix(canvas): 任务结果恢复 - 规范化分镜行文本字段

This commit is contained in:
root
2026-09-21 20:13:22 +08:00
parent 1bf9561800
commit 4e950169a3
2 changed files with 60 additions and 5 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 {
@@ -55,6 +56,23 @@ describe("storyboardRowsFromTask", () => {
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 | 全景/拉远 | 桃园结义 |" }));