Serialize NodeInputSlot.widget (#622)

Serialize linked widget on node input slot properly according to current
save format in
76818b54e6/src/extensions/core/widgetInputs.ts
This commit is contained in:
Chenlei Hu
2025-02-26 14:15:31 -05:00
committed by GitHub
parent c166a34fd8
commit d20aab757c
5 changed files with 54 additions and 17 deletions

View File

@@ -46,5 +46,27 @@ describe("NodeSlot", () => {
const serialized = serializeSlot(normalSlot)
expect(serialized).toHaveProperty("pos")
})
it("preserves only widget name during serialization", () => {
const widgetInputSlot: INodeInputSlot = {
name: "test-id",
type: "STRING",
link: null,
widget: {
name: "test-widget",
type: "combo",
value: "test-value-1",
options: {
values: ["test-value-1", "test-value-2"],
},
},
}
const serialized = serializeSlot(widgetInputSlot)
expect(serialized.widget).toEqual({ name: "test-widget" })
expect(serialized.widget).not.toHaveProperty("type")
expect(serialized.widget).not.toHaveProperty("value")
expect(serialized.widget).not.toHaveProperty("options")
})
})
})