[backport rh-test] Fix type on LoadClip being marked as asset (#6214)

Backport of #6207 to `rh-test`

Automatically created by backport workflow.

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-6214-backport-rh-test-Fix-type-on-LoadClip-being-marked-as-asset-2956d73d36508180b4ccd59a40672327)
by [Unito](https://www.unito.io)

Co-authored-by: AustinMroz <austin@comfy.org>
This commit is contained in:
Comfy Org PR Bot
2025-10-23 12:56:53 +09:00
committed by GitHub
parent f0a19ebb1d
commit dd1af641db
6 changed files with 45 additions and 40 deletions

View File

@@ -163,7 +163,8 @@ describe('useComboWidget', () => {
)
expect(mockSettingStoreGet).toHaveBeenCalledWith('Comfy.Assets.UseAssetAPI')
expect(vi.mocked(assetService.isAssetBrowserEligible)).toHaveBeenCalledWith(
'CheckpointLoaderSimple'
'CheckpointLoaderSimple',
'ckpt_name'
)
expect(widget).toBe(mockWidget)
})

View File

@@ -16,15 +16,12 @@ const mockGetCategoryForNodeType = vi.fn()
vi.mock('@/stores/modelToNodeStore', () => ({
useModelToNodeStore: vi.fn(() => ({
getRegisteredNodeTypes: vi.fn(
() =>
new Set([
'CheckpointLoaderSimple',
'LoraLoader',
'VAELoader',
'TestNode'
])
),
getRegisteredNodeTypes: vi.fn(() => ({
CheckpointLoaderSimple: 'ckpt_name',
LoraLoader: 'lora_name',
VAELoader: 'vae_name',
TestNode: ''
})),
getCategoryForNodeType: mockGetCategoryForNodeType,
modelToNodeMap: {
checkpoints: [{ nodeDef: { name: 'CheckpointLoaderSimple' } }],
@@ -191,19 +188,19 @@ describe('assetService', () => {
})
describe('isAssetBrowserEligible', () => {
it('should return true for registered node types', () => {
expect(
assetService.isAssetBrowserEligible('CheckpointLoaderSimple')
).toBe(true)
expect(assetService.isAssetBrowserEligible('LoraLoader')).toBe(true)
expect(assetService.isAssetBrowserEligible('VAELoader')).toBe(true)
})
it('should return false for unregistered node types', () => {
expect(assetService.isAssetBrowserEligible('UnknownNode')).toBe(false)
expect(assetService.isAssetBrowserEligible('NotRegistered')).toBe(false)
expect(assetService.isAssetBrowserEligible('')).toBe(false)
})
it.for<[string, string, boolean, string]>([
['CheckpointLoaderSimple', 'ckpt_name', true, 'valid inputs'],
['LoraLoader', 'lora_name', true, 'valid inputs'],
['VAELoader', 'vae_name', true, 'valid inputs'],
['CheckpointLoaderSimple', 'type', false, 'other combo widgets'],
['UnknownNode', 'widget', false, 'unregistered types'],
['NotRegistered', 'widget', false, 'unregistered types']
])(
'isAssetBrowserEligible("%s", "%s") should return %s for %s',
([type, name, expected]) => {
expect(assetService.isAssetBrowserEligible(type, name)).toBe(expected)
}
)
})
describe('getAssetsForNodeType', () => {

View File

@@ -288,7 +288,7 @@ describe('useModelToNodeStore', () => {
// Non-existent nodes are filtered out from registered types
const types = modelToNodeStore.getRegisteredNodeTypes()
expect(types.has('NonExistentLoader')).toBe(false)
expect(types['NonExistentLoader']).toBe(undefined)
expect(
modelToNodeStore.getCategoryForNodeType('NonExistentLoader')
@@ -347,13 +347,13 @@ describe('useModelToNodeStore', () => {
})
describe('getRegisteredNodeTypes', () => {
it('should return a Set instance', () => {
it('should return an object', () => {
const modelToNodeStore = useModelToNodeStore()
const result = modelToNodeStore.getRegisteredNodeTypes()
expect(result).toBeInstanceOf(Set)
expect(result).toBeTypeOf('object')
})
it('should return empty set when nodeDefStore is empty', () => {
it('should return empty Record when nodeDefStore is empty', () => {
// Create fresh Pinia for this test to avoid state persistence
setActivePinia(createPinia())
@@ -363,7 +363,7 @@ describe('useModelToNodeStore', () => {
const modelToNodeStore = useModelToNodeStore()
const result = modelToNodeStore.getRegisteredNodeTypes()
expect(result.size).toBe(0)
expect(result).toStrictEqual({})
// Restore original mock for subsequent tests
vi.mocked(useNodeDefStore, { partial: true }).mockReturnValue({
@@ -371,16 +371,15 @@ describe('useModelToNodeStore', () => {
})
})
it('should contain node types for efficient Set.has() lookups', () => {
it('should contain node types to resolve widget name', () => {
const modelToNodeStore = useModelToNodeStore()
modelToNodeStore.registerDefaults()
const result = modelToNodeStore.getRegisteredNodeTypes()
// Test Set.has() functionality which assetService depends on
expect(result.has('CheckpointLoaderSimple')).toBe(true)
expect(result.has('LoraLoader')).toBe(true)
expect(result.has('NonExistentNode')).toBe(false)
expect(result['CheckpointLoaderSimple']).toBe('ckpt_name')
expect(result['LoraLoader']).toBe('lora_name')
expect(result['NonExistentNode']).toBe(undefined)
})
})