Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions src/lib/litegraph/src/canvas/ToInputFromIoNodeLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ export class ToInputFromIoNodeLink implements RenderLink {

if (existingLink) {
// Moving an existing link
const { input, inputNode } = existingLink.resolve(this.network)
if (inputNode && input)
this.node._disconnectNodeInput(inputNode, input, existingLink)
events.dispatch('input-moved', this)
} else {
// Creating a new link
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,71 @@
// 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'

Comment on lines 1 to 14
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Clean up stale TODO and consider consolidating imports

Now that these tests are fixed and running, the comment on Line 1 (// TODO: Fix these tests after migration) is misleading. It can be removed to avoid confusion.

Also, you’re correctly using the litegraph barrel for most types. If ToInputFromIoNodeLink is (or can be) re-exported from the same barrel, consider importing it from there as well to keep subgraph-related tests on a single import surface and reduce the risk of deep-path coupling.

🤖 Prompt for AI Agents
In tests-ui/tests/litegraph/canvas/LinkConnectorSubgraphInputValidation.test.ts
around lines 1 to 14, remove the stale top-line comment "// TODO: Fix these
tests after migration" and, if ToInputFromIoNodeLink is re-exported by the
litegraph barrel, replace its deep import with a single import from
'@/lib/litegraph/src/litegraph' to consolidate imports; update the import list
accordingly so all litegraph symbols come from the same barrel and delete the
misleading TODO comment.

import { createTestSubgraph } from '../subgraph/fixtures/subgraphHelpers'

describe.skip('LinkConnector SubgraphInput connection validation', () => {
describe('LinkConnector SubgraphInput connection validation', () => {
let connector: LinkConnector
const mockSetConnectingLinks = vi.fn()

beforeEach(() => {
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' }]
})

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.skip('MovingOutputLink validation', () => {
describe('MovingOutputLink validation', () => {
it('should implement canConnectToSubgraphInput method', () => {
const subgraph = createTestSubgraph({
inputs: [{ name: 'number_input', type: 'number' }]
Expand Down Expand Up @@ -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()
Expand All @@ -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' }]
Expand Down Expand Up @@ -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' }]
Expand Down
Loading