mirror of
https://github.com/hanzo-studio/studio-frontend.git
synced 2026-10-30 18:55:56 +00:00
+2








b4e1dc7f62
Adds a workflow progress panel component underneath the `actionbar-container`. I suggest starting a review at the extraneous changes that were needed. Including but not limited to: - `get createTime()` in queueStore - `promptIdToWorkflowId`, `initializingPromptIds`, and `nodeProgressStatesByPrompt` in executionStore - `create_time` handling in v2ToV1Adapter - `pointer-events-auto` on ComfyActionbar.vue The rest of the changes should be contained under `QueueProgressOverlay.vue`, and has less of a blast radius in case something goes wrong. --------- Co-authored-by: pythongosssss <[email protected]> Co-authored-by: GitHub Action <[email protected]> Co-authored-by: github-actions <[email protected]> Co-authored-by: Jin Yi <[email protected]> Co-authored-by: Claude <[email protected]> Co-authored-by: Alexander Brown <[email protected]> Co-authored-by: Johnpaul Chiwetelu <[email protected]> Co-authored-by: Christian Byrne <[email protected]> Co-authored-by: Comfy Org PR Bot <[email protected]> Co-authored-by: christian-byrne <[email protected]>
104 lines
3.1 KiB
TypeScript
104 lines
3.1 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
|
|
import { useResultGallery } from '@/composables/queue/useResultGallery'
|
|
import type { JobListItem } from '@/composables/queue/useJobList'
|
|
|
|
type PreviewLike = { url: string; supportsPreview: boolean }
|
|
|
|
const createPreview = (url: string, supportsPreview = true): PreviewLike => ({
|
|
url,
|
|
supportsPreview
|
|
})
|
|
|
|
const createTask = (preview?: PreviewLike) => ({
|
|
previewOutput: preview
|
|
})
|
|
|
|
const createJobItem = (id: string, preview?: PreviewLike): JobListItem =>
|
|
({
|
|
id,
|
|
title: `Job ${id}`,
|
|
meta: '',
|
|
state: 'completed',
|
|
showClear: false,
|
|
taskRef: preview ? { previewOutput: preview } : undefined
|
|
}) as JobListItem
|
|
|
|
describe('useResultGallery', () => {
|
|
it('collects only previewable outputs and preserves their order', () => {
|
|
const previewable = [createPreview('p-1'), createPreview('p-2')]
|
|
const tasks = [
|
|
createTask(previewable[0]),
|
|
createTask({ url: 'skip-me', supportsPreview: false }),
|
|
createTask(previewable[1]),
|
|
createTask()
|
|
]
|
|
|
|
const { galleryItems, galleryActiveIndex, onViewItem } = useResultGallery(
|
|
() => tasks
|
|
)
|
|
|
|
onViewItem(createJobItem('job-1', previewable[0]))
|
|
|
|
expect(galleryItems.value).toEqual(previewable)
|
|
expect(galleryActiveIndex.value).toBe(0)
|
|
})
|
|
|
|
it('does not change state when there are no previewable tasks', () => {
|
|
const { galleryItems, galleryActiveIndex, onViewItem } = useResultGallery(
|
|
() => []
|
|
)
|
|
|
|
onViewItem(createJobItem('job-missing'))
|
|
|
|
expect(galleryItems.value).toEqual([])
|
|
expect(galleryActiveIndex.value).toBe(-1)
|
|
})
|
|
|
|
it('activates the index that matches the viewed preview URL', () => {
|
|
const previewable = [
|
|
createPreview('p-1'),
|
|
createPreview('p-2'),
|
|
createPreview('p-3')
|
|
]
|
|
const tasks = previewable.map((preview) => createTask(preview))
|
|
|
|
const { galleryItems, galleryActiveIndex, onViewItem } = useResultGallery(
|
|
() => tasks
|
|
)
|
|
|
|
onViewItem(createJobItem('job-2', createPreview('p-2')))
|
|
|
|
expect(galleryItems.value).toEqual(previewable)
|
|
expect(galleryActiveIndex.value).toBe(1)
|
|
})
|
|
|
|
it('defaults to the first entry when the clicked job lacks a preview', () => {
|
|
const previewable = [createPreview('p-1'), createPreview('p-2')]
|
|
const tasks = previewable.map((preview) => createTask(preview))
|
|
|
|
const { galleryItems, galleryActiveIndex, onViewItem } = useResultGallery(
|
|
() => tasks
|
|
)
|
|
|
|
onViewItem(createJobItem('job-no-preview'))
|
|
|
|
expect(galleryItems.value).toEqual(previewable)
|
|
expect(galleryActiveIndex.value).toBe(0)
|
|
})
|
|
|
|
it('defaults to the first entry when no gallery item matches the preview URL', () => {
|
|
const previewable = [createPreview('p-1'), createPreview('p-2')]
|
|
const tasks = previewable.map((preview) => createTask(preview))
|
|
|
|
const { galleryItems, galleryActiveIndex, onViewItem } = useResultGallery(
|
|
() => tasks
|
|
)
|
|
|
|
onViewItem(createJobItem('job-mismatch', createPreview('missing')))
|
|
|
|
expect(galleryItems.value).toEqual(previewable)
|
|
expect(galleryActiveIndex.value).toBe(0)
|
|
})
|
|
})
|