mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-07-17 09:18:26 +00:00
## Summary Wire `essentials_category` through from backend to the Essentials tab UI. Creates a single source of truth for node categorization and ordering. ### Changes **New file — `src/constants/essentialsNodes.ts`:** - Single source of truth: `ESSENTIALS_NODES` (ordered nodes per category), `ESSENTIALS_CATEGORIES` (folder display order), `ESSENTIALS_CATEGORY_MAP` (flat lookup), `TOOLKIT_NOVEL_NODE_NAMES` (telemetry), `TOOLKIT_BLUEPRINT_MODULES` **Refactored files:** - `src/types/nodeSource.ts`: Removed inline `ESSENTIALS_CATEGORY_MOCK`, imports `ESSENTIALS_CATEGORY_MAP` from centralized constants - `src/services/nodeOrganizationService.ts`: Removed inline `NODE_ORDER_BY_FOLDER`, imports `ESSENTIALS_NODES` and `ESSENTIALS_CATEGORIES` - `src/constants/toolkitNodes.ts`: Re-exports from `essentialsNodes.ts` instead of maintaining a separate list **Subgraph passthrough:** - `src/stores/subgraphStore.ts`: Passes `essentials_category` from `GlobalSubgraphData` and extracts it from `definitions.subgraphs[0]` as fallback - `src/platform/workflow/validation/schemas/workflowSchema.ts`: Added `essentials_category` to `SubgraphDefinitionBase` and `zSubgraphDefinition` **Tests:** - `src/constants/essentialsNodes.test.ts`: 6 tests validating no duplicates, complete coverage, basics exclusion - `src/stores/subgraphStore.test.ts`: 2 tests for essentials_category passthrough All 43 relevant tests pass. Typecheck, lint, format clean. **Depends on:** Comfy-Org/ComfyUI#12573 Fixes COM-15221 ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-9091-feat-wire-essentials_category-for-Essentials-tab-display-30f6d73d3650814ab3d4c06b451c273b) by [Unito](https://www.unito.io) --------- Co-authored-by: github-actions <github-actions@github.com>
63 lines
1.9 KiB
TypeScript
63 lines
1.9 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import {
|
|
ESSENTIALS_CATEGORIES,
|
|
ESSENTIALS_CATEGORY_CANONICAL,
|
|
ESSENTIALS_CATEGORY_MAP,
|
|
ESSENTIALS_NODES,
|
|
TOOLKIT_BLUEPRINT_MODULES,
|
|
TOOLKIT_NOVEL_NODE_NAMES
|
|
} from './essentialsNodes'
|
|
|
|
describe('essentialsNodes', () => {
|
|
it('has no duplicate node names across categories', () => {
|
|
const seen = new Map<string, string>()
|
|
for (const [category, nodes] of Object.entries(ESSENTIALS_NODES)) {
|
|
for (const node of nodes) {
|
|
expect(
|
|
seen.has(node),
|
|
`"${node}" duplicated in "${category}" and "${seen.get(node)}"`
|
|
).toBe(false)
|
|
seen.set(node, category)
|
|
}
|
|
}
|
|
})
|
|
|
|
it('ESSENTIALS_CATEGORY_MAP covers every node in ESSENTIALS_NODES', () => {
|
|
for (const [category, nodes] of Object.entries(ESSENTIALS_NODES)) {
|
|
for (const node of nodes) {
|
|
expect(ESSENTIALS_CATEGORY_MAP[node]).toBe(category)
|
|
}
|
|
}
|
|
})
|
|
|
|
it('TOOLKIT_NOVEL_NODE_NAMES excludes basics nodes', () => {
|
|
for (const basicNode of ESSENTIALS_NODES.basics) {
|
|
expect(TOOLKIT_NOVEL_NODE_NAMES.has(basicNode)).toBe(false)
|
|
}
|
|
})
|
|
|
|
it('TOOLKIT_NOVEL_NODE_NAMES excludes SubgraphBlueprint-prefixed nodes', () => {
|
|
for (const name of TOOLKIT_NOVEL_NODE_NAMES) {
|
|
expect(name.startsWith('SubgraphBlueprint.')).toBe(false)
|
|
}
|
|
})
|
|
|
|
it('ESSENTIALS_NODES keys match ESSENTIALS_CATEGORIES', () => {
|
|
const nodeKeys = Object.keys(ESSENTIALS_NODES)
|
|
expect(nodeKeys).toEqual([...ESSENTIALS_CATEGORIES])
|
|
})
|
|
|
|
it('TOOLKIT_BLUEPRINT_MODULES contains comfy_essentials', () => {
|
|
expect(TOOLKIT_BLUEPRINT_MODULES.has('comfy_essentials')).toBe(true)
|
|
})
|
|
|
|
it('ESSENTIALS_CATEGORY_CANONICAL maps every category case-insensitively', () => {
|
|
for (const category of ESSENTIALS_CATEGORIES) {
|
|
expect(ESSENTIALS_CATEGORY_CANONICAL.get(category.toLowerCase())).toBe(
|
|
category
|
|
)
|
|
}
|
|
})
|
|
})
|