mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-19 13:59:28 +00:00
## Summary - replace `JobGroupsList` with `JobAssetsList` in `QueueOverlayExpanded` - standardize expanded queue rows to use `AssetsListItem` - add `QueueOverlayExpanded` tests to verify list rendering and action re-emits It works surprisingly well. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-9055-fix-use-AssetsListItem-in-queue-overlay-expanded-30e6d73d365081c586c7c7bca222c290) by [Unito](https://www.unito.io) --------- Co-authored-by: Johnpaul Chiwetelu <49923152+Myestery@users.noreply.github.com> Co-authored-by: GitHub Action <action@github.com>
86 lines
2.1 KiB
TypeScript
86 lines
2.1 KiB
TypeScript
import { mount } from '@vue/test-utils'
|
|
import { describe, expect, it, vi } from 'vitest'
|
|
|
|
import type { JobListItem } from '@/composables/queue/useJobList'
|
|
|
|
vi.mock('@/composables/queue/useJobMenu', () => ({
|
|
useJobMenu: () => ({ jobMenuEntries: [] })
|
|
}))
|
|
|
|
vi.mock('@/composables/useErrorHandling', () => ({
|
|
useErrorHandling: () => ({
|
|
wrapWithErrorHandlingAsync: <T extends (...args: never[]) => unknown>(
|
|
fn: T
|
|
) => fn
|
|
})
|
|
}))
|
|
|
|
import QueueOverlayExpanded from '@/components/queue/QueueOverlayExpanded.vue'
|
|
|
|
const QueueOverlayHeaderStub = {
|
|
template: '<div />'
|
|
}
|
|
|
|
const JobFiltersBarStub = {
|
|
template: '<div />'
|
|
}
|
|
|
|
const JobAssetsListStub = {
|
|
name: 'JobAssetsList',
|
|
template: '<div class="job-assets-list-stub" />'
|
|
}
|
|
|
|
const JobContextMenuStub = {
|
|
template: '<div />'
|
|
}
|
|
|
|
const createJob = (): JobListItem => ({
|
|
id: 'job-1',
|
|
title: 'Job 1',
|
|
meta: 'meta',
|
|
state: 'pending'
|
|
})
|
|
|
|
const mountComponent = () =>
|
|
mount(QueueOverlayExpanded, {
|
|
props: {
|
|
headerTitle: 'Jobs',
|
|
queuedCount: 1,
|
|
selectedJobTab: 'All',
|
|
selectedWorkflowFilter: 'all',
|
|
selectedSortMode: 'mostRecent',
|
|
displayedJobGroups: [],
|
|
hasFailedJobs: false
|
|
},
|
|
global: {
|
|
stubs: {
|
|
QueueOverlayHeader: QueueOverlayHeaderStub,
|
|
JobFiltersBar: JobFiltersBarStub,
|
|
JobAssetsList: JobAssetsListStub,
|
|
JobContextMenu: JobContextMenuStub
|
|
}
|
|
}
|
|
})
|
|
|
|
describe('QueueOverlayExpanded', () => {
|
|
it('renders JobAssetsList', () => {
|
|
const wrapper = mountComponent()
|
|
expect(wrapper.find('.job-assets-list-stub').exists()).toBe(true)
|
|
})
|
|
|
|
it('re-emits list item actions from JobAssetsList', async () => {
|
|
const wrapper = mountComponent()
|
|
const job = createJob()
|
|
const jobAssetsList = wrapper.findComponent({ name: 'JobAssetsList' })
|
|
|
|
jobAssetsList.vm.$emit('cancel-item', job)
|
|
jobAssetsList.vm.$emit('delete-item', job)
|
|
jobAssetsList.vm.$emit('view-item', job)
|
|
await wrapper.vm.$nextTick()
|
|
|
|
expect(wrapper.emitted('cancelItem')?.[0]).toEqual([job])
|
|
expect(wrapper.emitted('deleteItem')?.[0]).toEqual([job])
|
|
expect(wrapper.emitted('viewItem')?.[0]).toEqual([job])
|
|
})
|
|
})
|