|
|
@ -381,6 +381,49 @@ describe("applyEditOperations", () => { |
|
|
expect(updated!.data).toHaveProperty("status", "idle"); |
|
|
expect(updated!.data).toHaveProperty("status", "idle"); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it("updates node position from top-level position without requiring data changes", () => { |
|
|
|
|
|
const ops: EditOperation[] = [ |
|
|
|
|
|
{ |
|
|
|
|
|
type: "updateNode", |
|
|
|
|
|
nodeId: "prompt-1", |
|
|
|
|
|
position: { x: 420, y: 240 }, |
|
|
|
|
|
data: {}, |
|
|
|
|
|
}, |
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
const result = applyEditOperations(ops, { |
|
|
|
|
|
nodes: baseNodes, |
|
|
|
|
|
edges: baseEdges, |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const updated = result.nodes.find((n) => n.id === "prompt-1"); |
|
|
|
|
|
expect(updated!.position).toEqual({ x: 420, y: 240 }); |
|
|
|
|
|
expect(updated!.data).toHaveProperty("prompt", "sunset photo"); |
|
|
|
|
|
expect(result.applied).toBe(1); |
|
|
|
|
|
expect(result.skipped).toEqual([]); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it("updates node position from data.position for backwards compatibility", () => { |
|
|
|
|
|
const ops: EditOperation[] = [ |
|
|
|
|
|
{ |
|
|
|
|
|
type: "updateNode", |
|
|
|
|
|
nodeId: "prompt-1", |
|
|
|
|
|
data: { position: { x: 320, y: 180 } }, |
|
|
|
|
|
}, |
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
const result = applyEditOperations(ops, { |
|
|
|
|
|
nodes: baseNodes, |
|
|
|
|
|
edges: baseEdges, |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const updated = result.nodes.find((n) => n.id === "prompt-1"); |
|
|
|
|
|
expect(updated!.position).toEqual({ x: 320, y: 180 }); |
|
|
|
|
|
expect(updated!.data).not.toHaveProperty("position"); |
|
|
|
|
|
expect(result.applied).toBe(1); |
|
|
|
|
|
expect(result.skipped).toEqual([]); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
it("skips with message when nodeId not found", () => { |
|
|
it("skips with message when nodeId not found", () => { |
|
|
const ops: EditOperation[] = [ |
|
|
const ops: EditOperation[] = [ |
|
|
{ |
|
|
{ |
|
|
|