mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 06:20:11 +00:00
- Emit dispatchNodeConnectionChange in SubgraphInputNode stale-link fallback - Balance beforeChange/afterChange with try/finally in SubgraphOutput.connect - Emit disconnect event when SubgraphOutput.connect replaces existing link - Guard connectSubgraphOutputSlot return and skip dispatch on falsy link - Move onAfterGraphConfigured to finally block in graphConfigureUtil - Add dispatchSlotLinkChanged to connectSubgraphOutputSlot for parity - Guard remapProxyWidgets call with explicit map-entry check - Harden LinkStore restore test assertions with existence checks - Use dispatchDisconnectNodePair in disconnectOutput for consistency Amp-Thread-ID: https://ampcode.com/threads/T-019cb1e7-a18e-712a-b8c7-4448f603c8b1 Co-authored-by: Amp <amp@ampcode.com>
73 lines
1.8 KiB
TypeScript
73 lines
1.8 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
|
|
import type { LGraph } from '@/lib/litegraph/src/litegraph'
|
|
import { fixLinkInputSlots } from '@/utils/litegraphUtil'
|
|
import { triggerCallbackOnAllNodes } from '@/utils/graphTraversalUtil'
|
|
|
|
import { addAfterConfigureHandler } from './graphConfigureUtil'
|
|
|
|
vi.mock('@/utils/litegraphUtil', () => ({
|
|
fixLinkInputSlots: vi.fn()
|
|
}))
|
|
|
|
vi.mock('@/utils/graphTraversalUtil', () => ({
|
|
triggerCallbackOnAllNodes: vi.fn()
|
|
}))
|
|
|
|
vi.mock('@/renderer/core/layout/store/layoutStore', () => ({
|
|
layoutStore: { setPendingSlotSync: vi.fn() }
|
|
}))
|
|
|
|
vi.mock(
|
|
'@/renderer/extensions/vueNodes/composables/useSlotElementTracking',
|
|
() => ({
|
|
flushScheduledSlotLayoutSync: vi.fn()
|
|
})
|
|
)
|
|
|
|
function createConfigureGraph(): LGraph {
|
|
return {
|
|
nodes: [],
|
|
onConfigure: vi.fn()
|
|
} satisfies Partial<LGraph> as unknown as LGraph
|
|
}
|
|
|
|
describe('addAfterConfigureHandler', () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks()
|
|
})
|
|
|
|
it('runs legacy slot repair on configure', () => {
|
|
const graph = createConfigureGraph()
|
|
|
|
addAfterConfigureHandler(graph, () => undefined)
|
|
graph.onConfigure!.call(
|
|
graph,
|
|
{} as Parameters<NonNullable<LGraph['onConfigure']>>[0]
|
|
)
|
|
|
|
expect(fixLinkInputSlots).toHaveBeenCalledWith(graph)
|
|
})
|
|
|
|
it('runs onAfterGraphConfigured even if onConfigure throws', () => {
|
|
const graph = createConfigureGraph()
|
|
graph.onConfigure = vi.fn(() => {
|
|
throw new Error('onConfigure failed')
|
|
})
|
|
|
|
addAfterConfigureHandler(graph, () => undefined)
|
|
|
|
expect(() =>
|
|
graph.onConfigure!.call(
|
|
graph,
|
|
{} as Parameters<NonNullable<LGraph['onConfigure']>>[0]
|
|
)
|
|
).toThrow('onConfigure failed')
|
|
|
|
expect(triggerCallbackOnAllNodes).toHaveBeenCalledWith(
|
|
graph,
|
|
'onAfterGraphConfigured'
|
|
)
|
|
})
|
|
})
|