mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-23 16:24:06 +00:00
## Summary Add sidebar badge behavior for queue/asset visibility updates: - Job History tab icon shows active jobs count (`queued + running`) only when the Job History panel is closed. - Assets tab icon no longer mirrors active jobs; when QPO V2 is enabled it now shows the number of assets added since the last time Assets was opened. - Opening Assets clears the unseen added-assets badge count. ## Changes - Added `iconBadge` logic to Job History sidebar tab. - Replaced Assets sidebar badge source with new unseen-assets counter logic. - Added `assetsSidebarBadgeStore` to track unseen asset additions from history updates and reset on Assets open. - Added/updated unit tests for both sidebar tab composables and the new store behavior. https://github.com/user-attachments/assets/33588a2a-c607-4fcc-8221-e7f11c3d79cc ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-9050-fix-add-job-history-and-assets-sidebar-badge-behavior-30e6d73d365081c38297fe6aac9cd34c) 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>
56 lines
1.6 KiB
TypeScript
56 lines
1.6 KiB
TypeScript
import { describe, expect, it, vi } from 'vitest'
|
|
|
|
import { useAssetsSidebarTab } from '@/composables/sidebarTabs/useAssetsSidebarTab'
|
|
|
|
const { mockGetSetting, mockUnseenAddedAssetsCount } = vi.hoisted(() => ({
|
|
mockGetSetting: vi.fn(),
|
|
mockUnseenAddedAssetsCount: { value: 0 }
|
|
}))
|
|
|
|
vi.mock('@/platform/settings/settingStore', () => ({
|
|
useSettingStore: () => ({
|
|
get: mockGetSetting
|
|
})
|
|
}))
|
|
|
|
vi.mock('@/components/sidebar/tabs/AssetsSidebarTab.vue', () => ({
|
|
default: {}
|
|
}))
|
|
|
|
vi.mock('@/stores/workspace/assetsSidebarBadgeStore', () => ({
|
|
useAssetsSidebarBadgeStore: () => ({
|
|
unseenAddedAssetsCount: mockUnseenAddedAssetsCount.value
|
|
})
|
|
}))
|
|
|
|
describe('useAssetsSidebarTab', () => {
|
|
it('hides icon badge when QPO V2 is disabled', () => {
|
|
mockGetSetting.mockReturnValue(false)
|
|
mockUnseenAddedAssetsCount.value = 3
|
|
|
|
const sidebarTab = useAssetsSidebarTab()
|
|
|
|
expect(typeof sidebarTab.iconBadge).toBe('function')
|
|
expect((sidebarTab.iconBadge as () => string | null)()).toBeNull()
|
|
})
|
|
|
|
it('shows unseen added assets count when QPO V2 is enabled', () => {
|
|
mockGetSetting.mockReturnValue(true)
|
|
mockUnseenAddedAssetsCount.value = 3
|
|
|
|
const sidebarTab = useAssetsSidebarTab()
|
|
|
|
expect(typeof sidebarTab.iconBadge).toBe('function')
|
|
expect((sidebarTab.iconBadge as () => string | null)()).toBe('3')
|
|
})
|
|
|
|
it('hides badge when there are no unseen added assets', () => {
|
|
mockGetSetting.mockReturnValue(true)
|
|
mockUnseenAddedAssetsCount.value = 0
|
|
|
|
const sidebarTab = useAssetsSidebarTab()
|
|
|
|
expect((sidebarTab.iconBadge as () => string | null)()).toBeNull()
|
|
})
|
|
})
|