Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ describe('NodeSearchCategorySidebar', () => {
createMockNodeDef({
name: 'EssentialNode',
essentials_category: 'basic'
}),
createMockNodeDef({
name: 'ApiNode',
display_name: 'API Node',
api_node: true
})
])
await nextTick()
Expand All @@ -60,6 +65,7 @@ describe('NodeSearchCategorySidebar', () => {
expect(wrapper.text()).toContain('Most relevant')
expect(wrapper.text()).toContain('Favorites')
expect(wrapper.text()).toContain('Essentials')
expect(wrapper.text()).toContain('API Nodes')
expect(wrapper.text()).toContain('Custom')
})

Expand Down
7 changes: 7 additions & 0 deletions src/components/searchbox/v2/NodeSearchCategorySidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,18 @@ const hasEssentialNodes = computed(() =>
)
)

const hasApiNodes = computed(() =>
nodeDefStore.visibleNodeDefs.some((n) => n.api_node)
)

const sourceCategories = computed(() => {
const categories = []
if (flags.nodeLibraryEssentialsEnabled && hasEssentialNodes.value) {
categories.push({ id: 'essentials', label: t('g.essentials') })
}
if (hasApiNodes.value) {
categories.push({ id: 'api', label: t('g.API Nodes') })
}
categories.push({ id: 'custom', label: t('g.custom') })
return categories
})
Expand Down
26 changes: 26 additions & 0 deletions src/components/searchbox/v2/NodeSearchContent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,32 @@ describe('NodeSearchContent', () => {
expect(items[0].text()).toContain('Custom Node')
})

it('should show only API nodes when API Nodes is selected', async () => {
useNodeDefStore().updateNodeDefs([
createMockNodeDef({
name: 'ApiNode',
display_name: 'API Node',
python_module: 'comfy_api_nodes.provider',
api_node: true
}),
createMockNodeDef({
name: 'CoreNode',
display_name: 'Core Node',
python_module: 'nodes',
api_node: false
})
])
await nextTick()

const wrapper = await createWrapper()
await wrapper.find('[data-testid="category-api"]').trigger('click')
await nextTick()

const items = getNodeItems(wrapper)
expect(items).toHaveLength(1)
expect(items[0].text()).toContain('API Node')
})

it('should hide Essentials category when no essential nodes exist', async () => {
useNodeDefStore().updateNodeDefs([
createMockNodeDef({
Expand Down
3 changes: 3 additions & 0 deletions src/components/searchbox/v2/NodeSearchContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ const displayedResults = computed<ComfyNodeDefImpl[]>(() => {
(n) => n.nodeSource.type === NodeSourceType.Essentials
)
break
case 'api':
results = allNodes.filter((n) => n.api_node)
break
case 'custom':
results = allNodes.filter(
(n) =>
Expand Down
1 change: 1 addition & 0 deletions src/components/searchbox/v2/__test__/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const testI18n = createI18n({
mostRelevant: 'Most relevant',
favorites: 'Favorites',
essentials: 'Essentials',
'API Nodes': 'API Nodes',
custom: 'Custom',
noResults: 'No results',
filterByType: 'Filter by {type}...',
Expand Down