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
46 changes: 40 additions & 6 deletions tests-ui/tests/litegraph/core/LGraphNode.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import { afterEach, beforeEach, describe, expect, vi } from 'vitest'

import type { INodeInputSlot, Point } from '@/lib/litegraph/src/litegraph'
import { LGraphNode, LiteGraph } from '@/lib/litegraph/src/litegraph'
import { LGraph } from '@/lib/litegraph/src/litegraph'
import { NodeInputSlot } from '@/lib/litegraph/src/litegraph'
import { NodeOutputSlot } from '@/lib/litegraph/src/litegraph'
import type { ISerialisedNode } from '@/lib/litegraph/src/litegraph'
import type {
INodeInputSlot,
Point,
ISerialisedNode
} from '@/lib/litegraph/src/litegraph'
import {
LGraphNode,
LiteGraph,
LGraph,
NodeInputSlot,
NodeOutputSlot
} from '@/lib/litegraph/src/litegraph'

import { test } from './fixtures/testExtensions'

Expand Down Expand Up @@ -261,6 +267,34 @@ describe('LGraphNode', () => {
})
})

describe('Applies correct link type on connection', () => {
it.for<[string, string, string]>([
['IMAGE', 'IMAGE', 'IMAGE'],
['*', 'IMAGE', 'IMAGE'],
['IMAGE', '*', 'IMAGE'],
['*', '*', '*'],
['IMAGE,MASK', 'IMAGE,LATENT', 'IMAGE'],
//An invalid connection should use input type
['Mask', 'IMAGE', 'IMAGE']
Comment thread
AustinMroz marked this conversation as resolved.
])(
'Link from %s to %s should have type %s',
([output, input, expected]) => {
const target = new LGraphNode('target')
const source = new LGraphNode('source')
const graph = new LGraph()

target.addInput('input', input)
source.addOutput('output', output)

graph.add(source)
graph.add(target)

const link = source.connect(0, target, 0)
expect(link?.type).toBe(expected)
}
)
})
Comment thread
AustinMroz marked this conversation as resolved.

describe('getInputPos and getOutputPos', () => {
test('should handle collapsed nodes correctly', () => {
const node = new LGraphNode('TestNode') as unknown as Omit<
Expand Down