From 3aaa5ff72ca940dd5ecc16488177b5e7e3dcd7a8 Mon Sep 17 00:00:00 2001 From: Glary-Bot Date: Wed, 6 May 2026 17:41:34 +0000 Subject: [PATCH] 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. --- src/stores/nodeDefStore.test.ts | 37 ++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/stores/nodeDefStore.test.ts b/src/stores/nodeDefStore.test.ts index 944c42db15..a4141ed692 100644 --- a/src/stores/nodeDefStore.test.ts +++ b/src/stores/nodeDefStore.test.ts @@ -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']) + ) + }) }) })