mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-26 19:09:52 +00:00
When moving subgraphInput link, properly disconnect old link (#7229)
When moving an existing link with subgraphInput as source to a new node, the prior link is removed, but the previous target node would not have it's link property cleared. Resolves #7225 Also re-enables several functional skipped tests. It feels like I'm having to play whack-a-mole reimplementing the same fixes on every permutation of subgraphIO links. I'd like to setup up a unified test set that covers them all, but wouldn't want the added work to further delay this fix. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-7229-When-moving-subgraphInput-link-properly-disconnect-old-link-2c36d73d36508149aca0ce477fee5c9e) by [Unito](https://www.unito.io)
This commit is contained in:
@@ -1,15 +1,20 @@
|
||||
// TODO: Fix these tests after migration
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import { LinkConnector } from '@/lib/litegraph/src/litegraph'
|
||||
import { MovingOutputLink } from '@/lib/litegraph/src/litegraph'
|
||||
import { ToOutputRenderLink } from '@/lib/litegraph/src/litegraph'
|
||||
import { LGraphNode, LLink } from '@/lib/litegraph/src/litegraph'
|
||||
import {
|
||||
LinkConnector,
|
||||
MovingOutputLink,
|
||||
ToOutputRenderLink,
|
||||
LGraphNode,
|
||||
LLink
|
||||
} from '@/lib/litegraph/src/litegraph'
|
||||
import { ToInputFromIoNodeLink } from '@/lib/litegraph/src/canvas/ToInputFromIoNodeLink'
|
||||
import type { NodeInputSlot } from '@/lib/litegraph/src/litegraph'
|
||||
import { LinkDirection } from '@/lib/litegraph/src/types/globalEnums'
|
||||
|
||||
import { createTestSubgraph } from '../subgraph/fixtures/subgraphHelpers'
|
||||
|
||||
describe.skip('LinkConnector SubgraphInput connection validation', () => {
|
||||
describe('LinkConnector SubgraphInput connection validation', () => {
|
||||
let connector: LinkConnector
|
||||
const mockSetConnectingLinks = vi.fn()
|
||||
|
||||
@@ -17,8 +22,50 @@ describe.skip('LinkConnector SubgraphInput connection validation', () => {
|
||||
connector = new LinkConnector(mockSetConnectingLinks)
|
||||
vi.clearAllMocks()
|
||||
})
|
||||
describe('Link disconnection validation', () => {
|
||||
it('should properly cleanup a moved input link', () => {
|
||||
const subgraph = createTestSubgraph({
|
||||
inputs: [{ name: 'number_input', type: 'number' }]
|
||||
})
|
||||
|
||||
describe.skip('MovingOutputLink validation', () => {
|
||||
const fromTargetNode = new LGraphNode('TargetNode')
|
||||
fromTargetNode.addInput('number_in', 'number')
|
||||
subgraph.add(fromTargetNode)
|
||||
|
||||
const toTargetNode = new LGraphNode('TargetNode')
|
||||
toTargetNode.addInput('number_in', 'number')
|
||||
subgraph.add(toTargetNode)
|
||||
|
||||
const startLink = subgraph.inputNode.slots[0].connect(
|
||||
fromTargetNode.inputs[0],
|
||||
fromTargetNode
|
||||
)
|
||||
|
||||
fromTargetNode.onConnectionsChange = vi.fn()
|
||||
toTargetNode.onConnectionsChange = vi.fn()
|
||||
|
||||
const renderLink = new ToInputFromIoNodeLink(
|
||||
subgraph,
|
||||
subgraph.inputNode,
|
||||
subgraph.inputNode.slots[0],
|
||||
undefined,
|
||||
LinkDirection.CENTER,
|
||||
startLink
|
||||
)
|
||||
renderLink.connectToInput(
|
||||
toTargetNode,
|
||||
toTargetNode.inputs[0],
|
||||
connector.events
|
||||
)
|
||||
|
||||
expect(fromTargetNode.inputs[0].link).toBeNull()
|
||||
expect(toTargetNode.inputs[0].link).not.toBeNull()
|
||||
expect(toTargetNode.onConnectionsChange).toHaveBeenCalledTimes(1)
|
||||
expect(fromTargetNode.onConnectionsChange).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
})
|
||||
|
||||
describe('MovingOutputLink validation', () => {
|
||||
it('should implement canConnectToSubgraphInput method', () => {
|
||||
const subgraph = createTestSubgraph({
|
||||
inputs: [{ name: 'number_input', type: 'number' }]
|
||||
@@ -113,7 +160,7 @@ describe.skip('LinkConnector SubgraphInput connection validation', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe.skip('ToOutputRenderLink validation', () => {
|
||||
describe('ToOutputRenderLink validation', () => {
|
||||
it('should implement canConnectToSubgraphInput method', () => {
|
||||
// Create a minimal valid setup
|
||||
const subgraph = createTestSubgraph()
|
||||
@@ -130,7 +177,7 @@ describe.skip('LinkConnector SubgraphInput connection validation', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe.skip('dropOnIoNode validation', () => {
|
||||
describe('dropOnIoNode validation', () => {
|
||||
it('should prevent invalid connections when dropping on SubgraphInputNode', () => {
|
||||
const subgraph = createTestSubgraph({
|
||||
inputs: [{ name: 'number_input', type: 'number' }]
|
||||
@@ -232,7 +279,7 @@ describe.skip('LinkConnector SubgraphInput connection validation', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe.skip('isSubgraphInputValidDrop', () => {
|
||||
describe('isSubgraphInputValidDrop', () => {
|
||||
it('should check if render links can connect to SubgraphInput', () => {
|
||||
const subgraph = createTestSubgraph({
|
||||
inputs: [{ name: 'number_input', type: 'number' }]
|
||||
|
||||
Reference in New Issue
Block a user