mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-30 11:11:53 +00:00
Add tests for link type (#7213)
Quick followup adding tests to #7211 ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-7213-Add-tests-for-link-type-2c16d73d365081898707f94a40f2e866) by [Unito](https://www.unito.io)
This commit is contained in:
@@ -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'
|
||||
|
||||
@@ -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']
|
||||
])(
|
||||
'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)
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
describe('getInputPos and getOutputPos', () => {
|
||||
test('should handle collapsed nodes correctly', () => {
|
||||
const node = new LGraphNode('TestNode') as unknown as Omit<
|
||||
|
||||
Reference in New Issue
Block a user