11// TODO: Fix these tests after migration
22import { beforeEach , describe , expect , it , vi } from 'vitest'
33
4- import { LinkConnector } from '@/lib/litegraph/src/litegraph'
5- import { MovingOutputLink } from '@/lib/litegraph/src/litegraph'
6- import { ToOutputRenderLink } from '@/lib/litegraph/src/litegraph'
7- import { LGraphNode , LLink } from '@/lib/litegraph/src/litegraph'
4+ import {
5+ LinkConnector ,
6+ MovingOutputLink ,
7+ ToOutputRenderLink ,
8+ LGraphNode ,
9+ LLink
10+ } from '@/lib/litegraph/src/litegraph'
11+ import { ToInputFromIoNodeLink } from '@/lib/litegraph/src/canvas/ToInputFromIoNodeLink'
812import type { NodeInputSlot } from '@/lib/litegraph/src/litegraph'
13+ import { LinkDirection } from '@/lib/litegraph/src/types/globalEnums'
914
1015import { createTestSubgraph } from '../subgraph/fixtures/subgraphHelpers'
1116
12- describe . skip ( 'LinkConnector SubgraphInput connection validation' , ( ) => {
17+ describe ( 'LinkConnector SubgraphInput connection validation' , ( ) => {
1318 let connector : LinkConnector
1419 const mockSetConnectingLinks = vi . fn ( )
1520
1621 beforeEach ( ( ) => {
1722 connector = new LinkConnector ( mockSetConnectingLinks )
1823 vi . clearAllMocks ( )
1924 } )
25+ describe ( 'Link disconnection validation' , ( ) => {
26+ it ( 'should properly cleanup a moved input link' , ( ) => {
27+ const subgraph = createTestSubgraph ( {
28+ inputs : [ { name : 'number_input' , type : 'number' } ]
29+ } )
30+
31+ const fromTargetNode = new LGraphNode ( 'TargetNode' )
32+ fromTargetNode . addInput ( 'number_in' , 'number' )
33+ subgraph . add ( fromTargetNode )
34+
35+ const toTargetNode = new LGraphNode ( 'TargetNode' )
36+ toTargetNode . addInput ( 'number_in' , 'number' )
37+ subgraph . add ( toTargetNode )
38+
39+ const startLink = subgraph . inputNode . slots [ 0 ] . connect (
40+ fromTargetNode . inputs [ 0 ] ,
41+ fromTargetNode
42+ )
43+
44+ fromTargetNode . onConnectionsChange = vi . fn ( )
45+ toTargetNode . onConnectionsChange = vi . fn ( )
46+
47+ const renderLink = new ToInputFromIoNodeLink (
48+ subgraph ,
49+ subgraph . inputNode ,
50+ subgraph . inputNode . slots [ 0 ] ,
51+ undefined ,
52+ LinkDirection . CENTER ,
53+ startLink
54+ )
55+ renderLink . connectToInput (
56+ toTargetNode ,
57+ toTargetNode . inputs [ 0 ] ,
58+ connector . events
59+ )
60+
61+ expect ( fromTargetNode . inputs [ 0 ] . link ) . toBeNull ( )
62+ expect ( toTargetNode . inputs [ 0 ] . link ) . not . toBeNull ( )
63+ expect ( toTargetNode . onConnectionsChange ) . toHaveBeenCalledTimes ( 1 )
64+ expect ( fromTargetNode . onConnectionsChange ) . toHaveBeenCalledTimes ( 1 )
65+ } )
66+ } )
2067
21- describe . skip ( 'MovingOutputLink validation' , ( ) => {
68+ describe ( 'MovingOutputLink validation' , ( ) => {
2269 it ( 'should implement canConnectToSubgraphInput method' , ( ) => {
2370 const subgraph = createTestSubgraph ( {
2471 inputs : [ { name : 'number_input' , type : 'number' } ]
@@ -113,7 +160,7 @@ describe.skip('LinkConnector SubgraphInput connection validation', () => {
113160 } )
114161 } )
115162
116- describe . skip ( 'ToOutputRenderLink validation' , ( ) => {
163+ describe ( 'ToOutputRenderLink validation' , ( ) => {
117164 it ( 'should implement canConnectToSubgraphInput method' , ( ) => {
118165 // Create a minimal valid setup
119166 const subgraph = createTestSubgraph ( )
@@ -130,7 +177,7 @@ describe.skip('LinkConnector SubgraphInput connection validation', () => {
130177 } )
131178 } )
132179
133- describe . skip ( 'dropOnIoNode validation' , ( ) => {
180+ describe ( 'dropOnIoNode validation' , ( ) => {
134181 it ( 'should prevent invalid connections when dropping on SubgraphInputNode' , ( ) => {
135182 const subgraph = createTestSubgraph ( {
136183 inputs : [ { name : 'number_input' , type : 'number' } ]
@@ -232,7 +279,7 @@ describe.skip('LinkConnector SubgraphInput connection validation', () => {
232279 } )
233280 } )
234281
235- describe . skip ( 'isSubgraphInputValidDrop' , ( ) => {
282+ describe ( 'isSubgraphInputValidDrop' , ( ) => {
236283 it ( 'should check if render links can connect to SubgraphInput' , ( ) => {
237284 const subgraph = createTestSubgraph ( {
238285 inputs : [ { name : 'number_input' , type : 'number' } ]
0 commit comments