mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-02 20:22:08 +00:00
## Summary Move queue job history into a dedicated sidebar tab (gated by `Comfy.Queue.QPOV2`) and remove mixed job-history UI from the Assets sidebar so assets and job controls are separated. ## Changes - **What**: - Added `JobHistorySidebarTab` with reusable job UI primitives: `JobFilterTabs`, `JobFilterActions`, `JobAssetsList`, and shared `JobHistoryActionsMenu`. - Added reactive `job-history` tab registration in `sidebarTabStore`; prepends above Assets when `Comfy.Queue.QPOV2` is enabled and unregisters cleanly when disabled. - Added debounced search to `useJobList` (filters by job title, metadata, and prompt id). - Extracted clear-history dialog logic to `useQueueClearHistoryDialog` and reused it from queue overlay and job history tab. - Removed active-job rendering and queue-clear controls from assets list/grid/tab views; assets sidebar now focuses on media assets only. - Removed the QPOV2 gate from `MediaAssetViewModeToggle` and updated queue/job localized copy. - Added and updated tests for queue overlay header actions, job filters, search filtering, sidebar tab registration, and assets sidebar behavior. ## Review Focus - Verify QPOV2 toggle behavior: - `Docked Job History` menu action toggles `Comfy.Queue.QPOV2`. - `job-history` tab insertion/removal order and active-tab reset on removal. - Verify behavior split between tabs: - Job controls (cancel/delete/view/filter/search/clear history/clear queue) live in Job History. - Assets sidebar loading/empty states and list/grid rendering remain correct after removing active jobs. ## Screenshots (if applicable) <img width="670" height="707" alt="image" src="https://github.com/user-attachments/assets/3a201fcb-d104-4e95-b5fe-49c4006a30a5" />
124 lines
3.2 KiB
TypeScript
124 lines
3.2 KiB
TypeScript
import { createTestingPinia } from '@pinia/testing'
|
|
import { mount } from '@vue/test-utils'
|
|
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
import { defineComponent } from 'vue'
|
|
|
|
import QueueProgressOverlay from '@/components/queue/QueueProgressOverlay.vue'
|
|
import { i18n } from '@/i18n'
|
|
import type { JobStatus } from '@/platform/remote/comfyui/jobs/jobTypes'
|
|
import { TaskItemImpl, useQueueStore } from '@/stores/queueStore'
|
|
import { useSidebarTabStore } from '@/stores/workspace/sidebarTabStore'
|
|
|
|
vi.mock('@/platform/distribution/types', () => ({
|
|
isCloud: false
|
|
}))
|
|
|
|
const QueueOverlayExpandedStub = defineComponent({
|
|
name: 'QueueOverlayExpanded',
|
|
props: {
|
|
headerTitle: {
|
|
type: String,
|
|
required: true
|
|
}
|
|
},
|
|
template: `
|
|
<div>
|
|
<div data-testid="expanded-title">{{ headerTitle }}</div>
|
|
<button data-testid="show-assets-button" @click="$emit('show-assets')" />
|
|
</div>
|
|
`
|
|
})
|
|
|
|
function createTask(id: string, status: JobStatus): TaskItemImpl {
|
|
return new TaskItemImpl({
|
|
id,
|
|
status,
|
|
create_time: 0,
|
|
priority: 0
|
|
})
|
|
}
|
|
|
|
const mountComponent = (
|
|
runningTasks: TaskItemImpl[],
|
|
pendingTasks: TaskItemImpl[]
|
|
) => {
|
|
const pinia = createTestingPinia({
|
|
createSpy: vi.fn,
|
|
stubActions: false
|
|
})
|
|
const queueStore = useQueueStore(pinia)
|
|
const sidebarTabStore = useSidebarTabStore(pinia)
|
|
queueStore.runningTasks = runningTasks
|
|
queueStore.pendingTasks = pendingTasks
|
|
|
|
const wrapper = mount(QueueProgressOverlay, {
|
|
props: {
|
|
expanded: true
|
|
},
|
|
global: {
|
|
plugins: [pinia, i18n],
|
|
stubs: {
|
|
QueueOverlayExpanded: QueueOverlayExpandedStub,
|
|
QueueOverlayActive: true,
|
|
ResultGallery: true
|
|
},
|
|
directives: {
|
|
tooltip: () => {}
|
|
}
|
|
}
|
|
})
|
|
|
|
return { wrapper, sidebarTabStore }
|
|
}
|
|
|
|
describe('QueueProgressOverlay', () => {
|
|
beforeEach(() => {
|
|
i18n.global.locale.value = 'en'
|
|
})
|
|
|
|
it('shows expanded header with running and queued labels', () => {
|
|
const { wrapper } = mountComponent(
|
|
[
|
|
createTask('running-1', 'in_progress'),
|
|
createTask('running-2', 'in_progress')
|
|
],
|
|
[createTask('pending-1', 'pending')]
|
|
)
|
|
|
|
expect(wrapper.get('[data-testid="expanded-title"]').text()).toBe(
|
|
'2 running, 1 queued'
|
|
)
|
|
})
|
|
|
|
it('shows only running label when queued count is zero', () => {
|
|
const { wrapper } = mountComponent(
|
|
[createTask('running-1', 'in_progress')],
|
|
[]
|
|
)
|
|
|
|
expect(wrapper.get('[data-testid="expanded-title"]').text()).toBe(
|
|
'1 running'
|
|
)
|
|
})
|
|
|
|
it('shows job queue title when there are no active jobs', () => {
|
|
const { wrapper } = mountComponent([], [])
|
|
|
|
expect(wrapper.get('[data-testid="expanded-title"]').text()).toBe(
|
|
'Job Queue'
|
|
)
|
|
})
|
|
|
|
it('toggles the assets sidebar tab when show-assets is clicked', async () => {
|
|
const { wrapper, sidebarTabStore } = mountComponent([], [])
|
|
|
|
expect(sidebarTabStore.activeSidebarTabId).toBe(null)
|
|
|
|
await wrapper.get('[data-testid="show-assets-button"]').trigger('click')
|
|
expect(sidebarTabStore.activeSidebarTabId).toBe('assets')
|
|
|
|
await wrapper.get('[data-testid="show-assets-button"]').trigger('click')
|
|
expect(sidebarTabStore.activeSidebarTabId).toBe(null)
|
|
})
|
|
})
|