Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions src/lib/litegraph/src/LGraphNode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,43 @@ describe('LGraphNode', () => {
expect(Array.from(node.size)).toEqual([70, 80])
})

describe('missing-node placeholder serialization', () => {
function createPlaceholder(): LGraphNode {
const lastSerialization = getMockISerialisedNode({
type: 'UninstalledNodeType',
pos: [100, 100],
size: [140, 60],
widgets_values: [512]
})
const placeholder = new LGraphNode('')
placeholder.last_serialization = lastSerialization
placeholder.has_errors = true
placeholder.configure(lastSerialization)
return placeholder
}

test('carries the live pos and size through to the replayed serialization', () => {
const placeholder = createPlaceholder()
placeholder.pos = [999, 888]
placeholder.size = [777, 666]
Comment thread
mattmillerai marked this conversation as resolved.
Outdated
Comment thread
mattmillerai marked this conversation as resolved.
Outdated

const serialized = placeholder.serialize()

expect(serialized.pos).toEqual([999, 888])
expect(serialized.size).toEqual([777, 666])
})

test('still replays the fields it has no definition to regenerate', () => {
const placeholder = createPlaceholder()
placeholder.size = [777, 666]

const serialized = placeholder.serialize()

expect(serialized.type).toEqual('UninstalledNodeType')
expect(serialized.widgets_values).toEqual([512])
})
})

test('should configure inputs correctly', () => {
const node = new LGraphNode('TestNode')
node.configure(
Expand Down
7 changes: 6 additions & 1 deletion src/lib/litegraph/src/LGraphNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,12 @@ export class LGraphNode

// special case for when there were errors
if (this.constructor === LGraphNode && this.last_serialization)
return { ...this.last_serialization, mode: o.mode, pos: o.pos }
return {
...this.last_serialization,
Comment thread
mattmillerai marked this conversation as resolved.
mode: o.mode,
Comment thread
mattmillerai marked this conversation as resolved.
pos: o.pos,
size: o.size
Comment thread
mattmillerai marked this conversation as resolved.
Outdated
Comment thread
mattmillerai marked this conversation as resolved.
Outdated
}

if (this.inputs)
o.inputs = this.inputs.map((input) => inputAsSerialisable(input))
Expand Down
4 changes: 4 additions & 0 deletions src/lib/litegraph/src/__snapshots__/LGraph.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ exports[`LGraph > supports schema v0.4 graphs > oldSchemaGraph 1`] = `
10,
10,
],
"size": [
140,
60,
],
},
],
"revision": 0,
Expand Down
Loading