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:
Glary-Bot
2026-05-06 17:41:34 +00:00
parent d4a6d02fcd
commit 3aaa5ff72c

View File

@@ -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'])
)
})
})
})