mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-01 19:51:54 +00:00
## Summary Replace legacy `SearchBox` (PrimeVue) and `SearchBoxV2` with the unified `SearchInput` (reka-ui) component across all consumers. ## Changes - **What**: Remove `SearchBox.vue`, `SearchBoxV2.vue`, their tests and stories. Migrate all 14 consumers to `SearchInput`. Move layout classes to `ComboboxRoot` for proper flex sizing. Extract filter button/chips in `NodeLibrarySidebarTab`. Standardize modal search width to `flex-1 max-w-lg`. - **Dependencies**: None new — `SearchInput` already existed using reka-ui ## Review Focus - `NodeLibrarySidebarTab.vue`: filter button and `SearchFilterChip` rendering moved outside the search component - `SearchInput.vue`: `className` now applied to `ComboboxRoot` instead of `ComboboxAnchor` for correct flex layout - Modal dialogs (`WorkflowTemplateSelectorDialog`, `AssetBrowserModal`, `SampleModelSelector`) unified to `flex-1 max-w-lg` ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-9644-feat-unify-search-components-by-replacing-SearchBox-SearchBoxV2-with-SearchInput-31e6d73d365081ebac55cb265f33b631) by [Unito](https://www.unito.io) --------- Co-authored-by: Amp <amp@ampcode.com> Co-authored-by: github-actions <github-actions@github.com>
135 lines
3.4 KiB
TypeScript
135 lines
3.4 KiB
TypeScript
import { mount } from '@vue/test-utils'
|
|
import { createTestingPinia } from '@pinia/testing'
|
|
import { TabsContent, TabsList, TabsRoot, TabsTrigger } from 'reka-ui'
|
|
import { ref } from 'vue'
|
|
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
import { createI18n } from 'vue-i18n'
|
|
|
|
import NodeLibrarySidebarTabV2 from './NodeLibrarySidebarTabV2.vue'
|
|
|
|
vi.mock('@vueuse/core', async () => {
|
|
const actual = await vi.importActual('@vueuse/core')
|
|
return {
|
|
...actual,
|
|
useLocalStorage: vi.fn((_key: string, defaultValue: unknown) =>
|
|
ref(defaultValue)
|
|
)
|
|
}
|
|
})
|
|
|
|
vi.mock('@/composables/node/useNodeDragToCanvas', () => ({
|
|
useNodeDragToCanvas: () => ({
|
|
isDragging: { value: false },
|
|
draggedNode: { value: null },
|
|
cursorPosition: { value: { x: 0, y: 0 } },
|
|
startDrag: vi.fn(),
|
|
cancelDrag: vi.fn(),
|
|
setupGlobalListeners: vi.fn(),
|
|
cleanupGlobalListeners: vi.fn()
|
|
})
|
|
}))
|
|
|
|
vi.mock('@/services/nodeOrganizationService', () => ({
|
|
DEFAULT_TAB_ID: 'essentials',
|
|
DEFAULT_SORTING_ID: 'alphabetical',
|
|
nodeOrganizationService: {
|
|
organizeNodesByTab: vi.fn(() => []),
|
|
getSortingStrategies: vi.fn(() => [])
|
|
}
|
|
}))
|
|
|
|
vi.mock('./nodeLibrary/AllNodesPanel.vue', () => ({
|
|
default: {
|
|
name: 'AllNodesPanel',
|
|
template: '<div data-testid="all-panel"><slot /></div>',
|
|
props: ['sections', 'expandedKeys', 'fillNodeInfo']
|
|
}
|
|
}))
|
|
|
|
vi.mock('./nodeLibrary/BlueprintsPanel.vue', () => ({
|
|
default: {
|
|
name: 'BlueprintsPanel',
|
|
template: '<div data-testid="blueprints-panel"><slot /></div>',
|
|
props: ['sections', 'expandedKeys']
|
|
}
|
|
}))
|
|
|
|
vi.mock('./nodeLibrary/EssentialNodesPanel.vue', () => ({
|
|
default: {
|
|
name: 'EssentialNodesPanel',
|
|
template: '<div data-testid="essential-panel"><slot /></div>',
|
|
props: ['root', 'expandedKeys', 'flatNodes']
|
|
}
|
|
}))
|
|
|
|
vi.mock('./nodeLibrary/NodeDragPreview.vue', () => ({
|
|
default: {
|
|
name: 'NodeDragPreview',
|
|
template: '<div />'
|
|
}
|
|
}))
|
|
|
|
vi.mock('@/components/ui/search-input/SearchInput.vue', () => ({
|
|
default: {
|
|
name: 'SearchBox',
|
|
template: '<input data-testid="search-box" />',
|
|
props: ['modelValue', 'placeholder'],
|
|
setup() {
|
|
return { focus: vi.fn() }
|
|
},
|
|
expose: ['focus']
|
|
}
|
|
}))
|
|
|
|
const i18n = createI18n({
|
|
legacy: false,
|
|
locale: 'en',
|
|
messages: { en: {} }
|
|
})
|
|
|
|
describe('NodeLibrarySidebarTabV2', () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks()
|
|
})
|
|
|
|
function mountComponent() {
|
|
return mount(NodeLibrarySidebarTabV2, {
|
|
global: {
|
|
plugins: [createTestingPinia({ stubActions: false }), i18n],
|
|
components: {
|
|
TabsRoot,
|
|
TabsList,
|
|
TabsTrigger,
|
|
TabsContent
|
|
},
|
|
stubs: {
|
|
teleport: true
|
|
}
|
|
}
|
|
})
|
|
}
|
|
|
|
it('should render with tabs', () => {
|
|
const wrapper = mountComponent()
|
|
|
|
const triggers = wrapper.findAllComponents(TabsTrigger)
|
|
expect(triggers).toHaveLength(3)
|
|
})
|
|
|
|
it('should render search box', () => {
|
|
const wrapper = mountComponent()
|
|
|
|
expect(wrapper.find('[data-testid="search-box"]').exists()).toBe(true)
|
|
})
|
|
|
|
it('should render only the selected panel', () => {
|
|
const wrapper = mountComponent()
|
|
|
|
expect(wrapper.find('[data-testid="essential-panel"]').exists()).toBe(true)
|
|
expect(wrapper.find('[data-testid="all-panel"]').exists()).toBe(false)
|
|
expect(wrapper.find('[data-testid="blueprints-panel"]').exists()).toBe(
|
|
false
|
|
)
|
|
})
|
|
})
|