Skip to content
Merged
Changes from all 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
40 changes: 40 additions & 0 deletions src/lib/litegraph/src/LGraph.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,46 @@ describe('Graph Clearing and Callbacks', () => {
)
})

test('a node reusing a cleared node id does not inherit its widget value (#20648)', () => {
const samplers = ['euler', 'dpmpp_2m']
const samplerNodeType = (title: string) =>
class extends LGraphNode {
constructor() {
super(title)
this.addWidget('combo', 'sampler_name', 'euler', null, {
values: samplers
})
}
}
LiteGraph.registerNodeType('test/Sampler', samplerNodeType('Sampler'))
LiteGraph.registerNodeType(
'test/SamplerSelect',
samplerNodeType('SamplerSelect')
)
const addNode = (graph: LGraph, type: string) => {
const node = LiteGraph.createNode(type)
assert.exists(node)
graph.add(node)
const widget = node.widgets?.[0]
assert.exists(widget)
return { node, widget }
}

const graph = new LGraph()
const sampler = addNode(graph, 'test/Sampler')
sampler.widget.value = 'dpmpp_2m'
const staleKey = widgetId(graph.id, sampler.node.id, 'sampler_name')
const store = useWidgetValueStore()
expect(store.getWidget(staleKey)?.value).toBe('dpmpp_2m')

graph.clear()
expect(store.getWidget(staleKey)).toBeUndefined()

const select = addNode(graph, 'test/SamplerSelect')
expect(select.node.id).toBe(sampler.node.id)
expect(select.widget.value).toBe('euler')
})

test('configure clears state already stored under the incoming graph id', () => {
const incoming = new LGraph()
const incomingId = 'graph-configure-cleanup' as UUID
Expand Down
Loading