fix(*): 质量检查 - 修复预演保存、增量同步与缺失资源恢复
This commit is contained in:
1 parent
298bee1fa9
commit
27c8066e6d
20 files changed
+257
-71
No files matched your search
@@ -5,8 +5,19 @@ import type { CanvasProject } from "@/stores/canvas/use-canvas-store";
|
||||
|
||||
function canvas(patch: Partial<CanvasProject> = {}): CanvasProject {
|
||||
return {
|
||||
id: "canvas", title: "自由画布 1", createdAt: "", updatedAt: "", nodes: [], connections: [], chatSessions: [], activeChatId: null,
|
||||
backgroundMode: "dots" as CanvasProject["backgroundMode"], showImageInfo: false, viewport: { x: 0, y: 0, k: 1 }, previsScenes: [], ...patch,
|
||||
id: "canvas",
|
||||
title: "自由画布 1",
|
||||
createdAt: "",
|
||||
updatedAt: "",
|
||||
nodes: [],
|
||||
connections: [],
|
||||
chatSessions: [],
|
||||
activeChatId: null,
|
||||
backgroundMode: "dots" as CanvasProject["backgroundMode"],
|
||||
showImageInfo: false,
|
||||
viewport: { x: 0, y: 0, k: 1 },
|
||||
previsScenes: [],
|
||||
...patch,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -23,23 +34,28 @@ describe("画布 operations 生成", () => {
|
||||
});
|
||||
|
||||
test("修复旧 journal:移除新画布中重复的 set_field,保留 mutationId", () => {
|
||||
const legacy = JSON.parse(JSON.stringify({
|
||||
mutationId: "m-1",
|
||||
operations: [
|
||||
{ type: "create_canvas", id: "canvas", patch: { title: "自由画布 1" } },
|
||||
{ type: "set_field", field: "title", value: "自由画布 1", beforeValue: undefined },
|
||||
],
|
||||
}));
|
||||
const legacy = JSON.parse(
|
||||
JSON.stringify({
|
||||
mutationId: "m-1",
|
||||
operations: [
|
||||
{ type: "create_canvas", id: "canvas", patch: { title: "自由画布 1" } },
|
||||
{ type: "set_field", field: "title", value: "自由画布 1", beforeValue: undefined },
|
||||
],
|
||||
}),
|
||||
);
|
||||
const repaired = repairPendingCanvasMutationRequest(legacy, undefined, canvas());
|
||||
expect(repaired.mutationId).toBe("m-1");
|
||||
expect(repaired.operations).toEqual([{ type: "create_canvas", id: "canvas", patch: { title: "自由画布 1" } }]);
|
||||
});
|
||||
|
||||
test("修复旧 journal:移除空 projectId 到缺省值的语义 no-op", () => {
|
||||
const legacy = { mutationId: "m-3", operations: [
|
||||
{ type: "create_node", node: { id: "node-1" } },
|
||||
{ type: "set_field", field: "projectId", value: null, beforeValue: "" },
|
||||
] } as never;
|
||||
const legacy = {
|
||||
mutationId: "m-3",
|
||||
operations: [
|
||||
{ type: "create_node", node: { id: "node-1" } },
|
||||
{ type: "set_field", field: "projectId", value: null, beforeValue: "" },
|
||||
],
|
||||
} as never;
|
||||
const repaired = repairPendingCanvasMutationRequest(legacy, canvas({ projectId: "" }), canvas({ projectId: undefined }));
|
||||
expect(repaired.mutationId).toBe("m-3");
|
||||
expect(repaired.operations).toEqual([{ type: "create_node", node: { id: "node-1" } }]);
|
||||
|
||||
Reference in new issue
Block a user