mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-14 01:20:03 +00:00
## Summary Adds enter builder menu item for easier access to app builder. Fixes issues with seen item tracking ## Changes - **What**: - add enter builder menu item - change non visible items to still be returned as part of the array, so they are not incorrectly removed from the seen-items tracking - split toggle-app-mode into two stable items ## Screenshots (if applicable) <img width="309" height="526" alt="image" src="https://github.com/user-attachments/assets/69affc2c-34ab-45eb-b47b-efacb8a20b99" /> ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-9341-feat-App-mode-enter-builder-menu-item-3176d73d365081a9a7e7cf1a1986354f) by [Unito](https://www.unito.io)
101 lines
2.7 KiB
TypeScript
101 lines
2.7 KiB
TypeScript
import { shallowMount } from '@vue/test-utils'
|
|
import { describe, expect, it, vi } from 'vitest'
|
|
|
|
import WorkflowActionsList from '@/components/common/WorkflowActionsList.vue'
|
|
import type {
|
|
WorkflowMenuAction,
|
|
WorkflowMenuItem
|
|
} from '@/types/workflowMenuItem'
|
|
|
|
function createWrapper(items: WorkflowMenuItem[]) {
|
|
return shallowMount(WorkflowActionsList, {
|
|
props: { items },
|
|
global: { renderStubDefaultSlot: true }
|
|
})
|
|
}
|
|
|
|
describe('WorkflowActionsList', () => {
|
|
it('renders action items with label and icon', () => {
|
|
const items: WorkflowMenuItem[] = [
|
|
{ id: 'save', label: 'Save', icon: 'pi pi-save', command: vi.fn() }
|
|
]
|
|
|
|
const wrapper = createWrapper(items)
|
|
|
|
expect(wrapper.text()).toContain('Save')
|
|
expect(wrapper.find('.pi-save').exists()).toBe(true)
|
|
})
|
|
|
|
it('renders separator items', () => {
|
|
const items: WorkflowMenuItem[] = [
|
|
{ id: 'before', label: 'Before', icon: 'pi pi-a', command: vi.fn() },
|
|
{ separator: true },
|
|
{ id: 'after', label: 'After', icon: 'pi pi-b', command: vi.fn() }
|
|
]
|
|
|
|
const wrapper = createWrapper(items)
|
|
const html = wrapper.html()
|
|
|
|
expect(html).toContain('dropdown-menu-separator-stub')
|
|
expect(wrapper.text()).toContain('Before')
|
|
expect(wrapper.text()).toContain('After')
|
|
})
|
|
|
|
it('dispatches command on select', async () => {
|
|
const command = vi.fn()
|
|
const items: WorkflowMenuItem[] = [
|
|
{ id: 'action', label: 'Action', icon: 'pi pi-play', command }
|
|
]
|
|
|
|
const wrapper = createWrapper(items)
|
|
const item = wrapper.findComponent({ name: 'DropdownMenuItem' })
|
|
await item.vm.$emit('select')
|
|
|
|
expect(command).toHaveBeenCalledOnce()
|
|
})
|
|
|
|
it('renders badge when present', () => {
|
|
const items: WorkflowMenuItem[] = [
|
|
{
|
|
id: 'new-feature',
|
|
label: 'New Feature',
|
|
icon: 'pi pi-star',
|
|
command: vi.fn(),
|
|
badge: 'NEW'
|
|
}
|
|
]
|
|
|
|
const wrapper = createWrapper(items)
|
|
|
|
expect(wrapper.text()).toContain('NEW')
|
|
})
|
|
|
|
it('does not render items with visible set to false', () => {
|
|
const items: WorkflowMenuItem[] = [
|
|
{
|
|
id: 'hidden',
|
|
label: 'Hidden Item',
|
|
icon: 'pi pi-eye-slash',
|
|
command: vi.fn(),
|
|
visible: false
|
|
},
|
|
{ id: 'shown', label: 'Shown Item', icon: 'pi pi-eye', command: vi.fn() }
|
|
]
|
|
|
|
const wrapper = createWrapper(items)
|
|
|
|
expect(wrapper.text()).not.toContain('Hidden Item')
|
|
expect(wrapper.text()).toContain('Shown Item')
|
|
})
|
|
|
|
it('does not render badge when absent', () => {
|
|
const items: WorkflowMenuAction[] = [
|
|
{ id: 'plain', label: 'Plain', icon: 'pi pi-check', command: vi.fn() }
|
|
]
|
|
|
|
const wrapper = createWrapper(items)
|
|
|
|
expect(wrapper.text()).not.toContain('NEW')
|
|
})
|
|
})
|