mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-07 06:00:03 +00:00
## Summary As the commit says, the model loaders were broken in cloud if you enabled Vue Nodes (not a thing I think user does yet). This fixes it by configuring the `WidgetSelectDropdown` to load so the user load models like they would load a input or output asset. ## Review Focus Probably `useAssetWidgetData` to make sure it's idomatic. This part of [assetsStore](https://github.com/Comfy-Org/ComfyUI_frontend/pull/6607/files#diff-18a5914c9f12c16d9c9c3a9f6d0e203a9c00598414d3d1c8637da9ca77339d83R158-R234) as well. ## Screenshots <img width="1196" height="1005" alt="Screenshot 2025-11-05 at 5 34 22 PM" src="https://github.com/user-attachments/assets/804cd3c4-3370-4667-b606-bed52fcd6278" /> ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-6607-fix-use-WidgetSelectDropdown-for-models-2a36d73d36508143b185d06d736e4af9) by [Unito](https://www.unito.io) --------- Co-authored-by: GitHub Action <action@github.com>
90 lines
2.4 KiB
TypeScript
90 lines
2.4 KiB
TypeScript
import { createTestingPinia } from '@pinia/testing'
|
|
import { flushPromises, mount } from '@vue/test-utils'
|
|
import PrimeVue from 'primevue/config'
|
|
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
|
|
import type { SimplifiedWidget } from '@/types/simplifiedWidget'
|
|
|
|
import WidgetSelect from '@/renderer/extensions/vueNodes/widgets/components/WidgetSelect.vue'
|
|
|
|
// Mock modules
|
|
vi.mock('@/platform/distribution/types', () => ({
|
|
isCloud: true
|
|
}))
|
|
|
|
vi.mock('@/platform/assets/services/assetService', () => ({
|
|
assetService: {
|
|
isAssetBrowserEligible: vi.fn(() => true)
|
|
}
|
|
}))
|
|
|
|
const mockSettingStoreGet = vi.fn()
|
|
|
|
vi.mock('@/platform/settings/settingStore', () => ({
|
|
useSettingStore: vi.fn(() => ({
|
|
get: mockSettingStoreGet
|
|
}))
|
|
}))
|
|
|
|
// Import after mocks are defined
|
|
import { assetService } from '@/platform/assets/services/assetService'
|
|
const mockAssetServiceEligible = vi.mocked(assetService.isAssetBrowserEligible)
|
|
|
|
describe('WidgetSelect asset mode', () => {
|
|
const createWidget = (): SimplifiedWidget<string | number | undefined> => ({
|
|
name: 'ckpt_name',
|
|
type: 'combo',
|
|
value: undefined,
|
|
options: {
|
|
values: []
|
|
}
|
|
})
|
|
|
|
beforeEach(() => {
|
|
vi.clearAllMocks()
|
|
mockAssetServiceEligible.mockReturnValue(true)
|
|
mockSettingStoreGet.mockReturnValue(true) // Default to true for UseAssetAPI
|
|
})
|
|
|
|
// Helper to mount with common setup
|
|
const mountWidget = () => {
|
|
return mount(WidgetSelect, {
|
|
props: {
|
|
widget: createWidget(),
|
|
modelValue: undefined,
|
|
nodeType: 'CheckpointLoaderSimple'
|
|
},
|
|
global: {
|
|
plugins: [PrimeVue, createTestingPinia()]
|
|
}
|
|
})
|
|
}
|
|
|
|
it('uses dropdown when isCloud && UseAssetAPI && isEligible', async () => {
|
|
const wrapper = mountWidget()
|
|
await flushPromises()
|
|
|
|
expect(
|
|
wrapper.findComponent({ name: 'WidgetSelectDropdown' }).exists()
|
|
).toBe(true)
|
|
})
|
|
|
|
it('uses default widget when UseAssetAPI setting is false', () => {
|
|
mockSettingStoreGet.mockReturnValue(false)
|
|
const wrapper = mountWidget()
|
|
|
|
expect(
|
|
wrapper.findComponent({ name: 'WidgetSelectDefault' }).exists()
|
|
).toBe(true)
|
|
})
|
|
|
|
it('uses default widget when node is not eligible', () => {
|
|
mockAssetServiceEligible.mockReturnValue(false)
|
|
const wrapper = mountWidget()
|
|
|
|
expect(
|
|
wrapper.findComponent({ name: 'WidgetSelectDefault' }).exists()
|
|
).toBe(true)
|
|
})
|
|
})
|