mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-24 22:58:08 +00:00
test: assert PrimitiveNode lands in utils/primitive tree branch
Add a behavior test that builds the node tree from SYSTEM_NODE_DEFS and verifies PrimitiveNode is routed under utils/primitive while the remaining frontend-only virtual nodes (Reroute, Note, MarkdownNote) stay flat under utils. Addresses code review feedback that the prior test only asserted the constant value.
This commit is contained in:
@@ -3,7 +3,12 @@ import { setActivePinia } from 'pinia'
|
||||
import { beforeEach, describe, expect, it } from 'vitest'
|
||||
|
||||
import type { ComfyNodeDef } from '@/schemas/nodeDefSchema'
|
||||
import { SYSTEM_NODE_DEFS, useNodeDefStore } from '@/stores/nodeDefStore'
|
||||
import {
|
||||
ComfyNodeDefImpl,
|
||||
SYSTEM_NODE_DEFS,
|
||||
buildNodeDefTree,
|
||||
useNodeDefStore
|
||||
} from '@/stores/nodeDefStore'
|
||||
import type { NodeDefFilter } from '@/stores/nodeDefStore'
|
||||
|
||||
describe('useNodeDefStore', () => {
|
||||
@@ -370,5 +375,35 @@ describe('useNodeDefStore', () => {
|
||||
expect(SYSTEM_NODE_DEFS.Note.category).toBe('utils')
|
||||
expect(SYSTEM_NODE_DEFS.MarkdownNote.category).toBe('utils')
|
||||
})
|
||||
|
||||
it('routes PrimitiveNode into the utils/primitive branch of the node tree', () => {
|
||||
const systemDefs = Object.values(SYSTEM_NODE_DEFS).map(
|
||||
(def) => new ComfyNodeDefImpl(def)
|
||||
)
|
||||
const tree = buildNodeDefTree(systemDefs)
|
||||
|
||||
const utilsBranch = tree.children?.find(
|
||||
(child) => child.label === 'utils'
|
||||
)
|
||||
expect(utilsBranch).toBeDefined()
|
||||
|
||||
const primitiveBranch = utilsBranch?.children?.find(
|
||||
(child) => child.label === 'primitive'
|
||||
)
|
||||
expect(primitiveBranch).toBeDefined()
|
||||
|
||||
const primitiveLeaf = primitiveBranch?.children?.find(
|
||||
(child) => child.data?.name === 'PrimitiveNode'
|
||||
)
|
||||
expect(primitiveLeaf).toBeDefined()
|
||||
|
||||
const flatUtilsLeaves =
|
||||
utilsBranch?.children
|
||||
?.filter((child) => child.label !== 'primitive')
|
||||
.map((child) => child.data?.name) ?? []
|
||||
expect(flatUtilsLeaves).toEqual(
|
||||
expect.arrayContaining(['Reroute', 'Note', 'MarkdownNote'])
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user