mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-29 10:42:44 +00:00
Fix combo input default value (#242)
* Fix combo input default value * Supress logs and fix failure
This commit is contained in:
@@ -120,7 +120,8 @@ export class ComfyInputsSpec {
|
|||||||
name,
|
name,
|
||||||
type,
|
type,
|
||||||
...spec,
|
...spec,
|
||||||
comboOptions: typeRaw
|
comboOptions: typeRaw,
|
||||||
|
default: spec.default ?? typeRaw[0]
|
||||||
})
|
})
|
||||||
default:
|
default:
|
||||||
return plainToClass(CustomInputSpec, { name, type, ...spec })
|
return plainToClass(CustomInputSpec, { name, type, ...spec })
|
||||||
|
|||||||
@@ -3,6 +3,25 @@ import lg from './utils/litegraph'
|
|||||||
|
|
||||||
// Load things once per test file before to ensure its all warmed up for the tests
|
// Load things once per test file before to ensure its all warmed up for the tests
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
|
const originalWarn = console.warn
|
||||||
|
console.error = function (...args) {
|
||||||
|
if (['Error: Not implemented: window.alert'].includes(args[0])) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.warn = function (...args) {
|
||||||
|
if (
|
||||||
|
[
|
||||||
|
"sMethod=='pointer' && !window.PointerEvent",
|
||||||
|
'Warning, nodes missing on pasting'
|
||||||
|
].includes(args[0])
|
||||||
|
) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
originalWarn.apply(console, args)
|
||||||
|
}
|
||||||
|
console.log = function (...args) {}
|
||||||
|
|
||||||
lg.setup(global)
|
lg.setup(global)
|
||||||
await start({ resetEnv: true })
|
await start({ resetEnv: true })
|
||||||
lg.teardown(global)
|
lg.teardown(global)
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ describe('ComfyInputsSpec', () => {
|
|||||||
expect(floatInput.step).toBe(0.1)
|
expect(floatInput.step).toBe(0.1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should handle custom input specs', () => {
|
it('should handle combo input specs', () => {
|
||||||
const plainObject = {
|
const plainObject = {
|
||||||
optional: {
|
optional: {
|
||||||
comboInput: [[1, 2, 3], { default: 2 }]
|
comboInput: [[1, 2, 3], { default: 2 }]
|
||||||
@@ -103,6 +103,21 @@ describe('ComfyInputsSpec', () => {
|
|||||||
expect(result.optional.comboInput.default).toBe(2)
|
expect(result.optional.comboInput.default).toBe(2)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should handle combo input specs (auto-default)', () => {
|
||||||
|
const plainObject = {
|
||||||
|
optional: {
|
||||||
|
comboInput: [[1, 2, 3], {}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = plainToClass(ComfyInputsSpec, plainObject)
|
||||||
|
|
||||||
|
expect(result.optional.comboInput).toBeInstanceOf(ComboInputSpec)
|
||||||
|
expect(result.optional.comboInput.type).toBe('COMBO')
|
||||||
|
// Should pick the first choice as default
|
||||||
|
expect(result.optional.comboInput.default).toBe(1)
|
||||||
|
})
|
||||||
|
|
||||||
it('should handle custom input specs', () => {
|
it('should handle custom input specs', () => {
|
||||||
const plainObject = {
|
const plainObject = {
|
||||||
optional: {
|
optional: {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ const EXAMPLE_NODE_DEFS: ComfyNodeDefImpl[] = [
|
|||||||
{
|
{
|
||||||
input: {
|
input: {
|
||||||
required: {
|
required: {
|
||||||
ckpt_name: [['model1.safetensors', 'model2.ckpt']]
|
ckpt_name: [['model1.safetensors', 'model2.ckpt'], {}]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
output: ['MODEL', 'CLIP', 'VAE'],
|
output: ['MODEL', 'CLIP', 'VAE'],
|
||||||
|
|||||||
Reference in New Issue
Block a user