mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-28 10:12:11 +00:00
[TS] Enable strict mode (#3136)
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
// @ts-strict-ignore
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import {
|
||||
@@ -41,6 +40,7 @@ describe('validateNodeDef', () => {
|
||||
(inputSpec, expected) => {
|
||||
it(`should accept input spec format: ${JSON.stringify(inputSpec)}`, async () => {
|
||||
expect(
|
||||
// @ts-expect-error fixme ts strict error
|
||||
validateComfyNodeDef({
|
||||
...EXAMPLE_NODE_DEF,
|
||||
input: {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// @ts-strict-ignore
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import { adjustColor } from '@/utils/colorUtil'
|
||||
@@ -107,7 +106,9 @@ describe('colorUtil - adjustColor', () => {
|
||||
})
|
||||
|
||||
it('returns the original value for null or undefined inputs', () => {
|
||||
// @ts-expect-error fixme ts strict error
|
||||
expect(adjustColor(null, { opacity: targetOpacity })).toBe(null)
|
||||
// @ts-expect-error fixme ts strict error
|
||||
expect(adjustColor(undefined, { opacity: targetOpacity })).toBe(undefined)
|
||||
})
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// @ts-strict-ignore
|
||||
import fs from 'fs'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
@@ -68,10 +67,12 @@ describe('parseComfyWorkflow', () => {
|
||||
// Should automatically transform the legacy format object to array.
|
||||
workflow.nodes[0].pos = { '0': 3, '1': 4 }
|
||||
let validatedWorkflow = await validateComfyWorkflow(workflow)
|
||||
// @ts-expect-error fixme ts strict error
|
||||
expect(validatedWorkflow.nodes[0].pos).toEqual([3, 4])
|
||||
|
||||
workflow.nodes[0].pos = { 0: 3, 1: 4 }
|
||||
validatedWorkflow = await validateComfyWorkflow(workflow)
|
||||
// @ts-expect-error fixme ts strict error
|
||||
expect(validatedWorkflow.nodes[0].pos).toEqual([3, 4])
|
||||
|
||||
// Should accept the legacy bugged format object.
|
||||
@@ -89,6 +90,7 @@ describe('parseComfyWorkflow', () => {
|
||||
'9': 0
|
||||
}
|
||||
validatedWorkflow = await validateComfyWorkflow(workflow)
|
||||
// @ts-expect-error fixme ts strict error
|
||||
expect(validatedWorkflow.nodes[0].pos).toEqual([600, 340])
|
||||
})
|
||||
|
||||
@@ -107,6 +109,7 @@ describe('parseComfyWorkflow', () => {
|
||||
// dynamic widgets display.
|
||||
workflow.nodes[0].widgets_values = { foo: 'bar' }
|
||||
const validatedWorkflow = await validateComfyWorkflow(workflow)
|
||||
// @ts-expect-error fixme ts strict error
|
||||
expect(validatedWorkflow.nodes[0].widgets_values).toEqual({ foo: 'bar' })
|
||||
})
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// @ts-strict-ignore
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { transformNodeDefV1ToV2 } from '@/schemas/nodeDef/migration'
|
||||
@@ -223,6 +222,7 @@ describe('NodeDef Migration', () => {
|
||||
|
||||
const result = transformNodeDefV1ToV2(nodeDef)
|
||||
|
||||
// @ts-expect-error fixme ts strict error
|
||||
expect(result.hidden).toEqual(plainObject.hidden)
|
||||
expect(result.hidden?.someHiddenValue).toBe(42)
|
||||
expect(result.hidden?.anotherHiddenValue).toEqual({ nested: 'object' })
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// @ts-strict-ignore
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { ComfyNodeDef } from '@/schemas/nodeDefSchema'
|
||||
@@ -66,8 +65,10 @@ describe('nodeSearchService', () => {
|
||||
it('searches with input filter', () => {
|
||||
const service = new NodeSearchService(EXAMPLE_NODE_DEFS)
|
||||
const inputFilter = service.getFilterById('input')
|
||||
// @ts-expect-error fixme ts strict error
|
||||
expect(service.searchNode('L', [[inputFilter, 'LATENT']])).toHaveLength(1)
|
||||
// Wildcard should match all.
|
||||
// @ts-expect-error fixme ts strict error
|
||||
expect(service.searchNode('L', [[inputFilter, '*']])).toHaveLength(2)
|
||||
expect(service.searchNode('L')).toHaveLength(2)
|
||||
})
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// @ts-strict-ignore
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { TaskItemImpl } from '@/stores/queueStore'
|
||||
@@ -7,6 +6,7 @@ describe('TaskItemImpl', () => {
|
||||
it('should remove animated property from outputs during construction', () => {
|
||||
const taskItem = new TaskItemImpl(
|
||||
'History',
|
||||
// @ts-expect-error fixme ts strict error
|
||||
[0, 'prompt-id', {}, {}, []],
|
||||
{ status_str: 'success', messages: [] },
|
||||
{
|
||||
@@ -22,12 +22,14 @@ describe('TaskItemImpl', () => {
|
||||
|
||||
// Verify other output properties remain intact
|
||||
expect(taskItem.outputs['node-1'].images).toBeDefined()
|
||||
// @ts-expect-error fixme ts strict error
|
||||
expect(taskItem.outputs['node-1'].images[0].filename).toBe('test.png')
|
||||
})
|
||||
|
||||
it('should handle outputs without animated property', () => {
|
||||
const taskItem = new TaskItemImpl(
|
||||
'History',
|
||||
// @ts-expect-error fixme ts strict error
|
||||
[0, 'prompt-id', {}, {}, []],
|
||||
{ status_str: 'success', messages: [] },
|
||||
{
|
||||
@@ -39,12 +41,14 @@ describe('TaskItemImpl', () => {
|
||||
|
||||
// Verify outputs are preserved when no animated property exists
|
||||
expect(taskItem.outputs['node-1'].images).toBeDefined()
|
||||
// @ts-expect-error fixme ts strict error
|
||||
expect(taskItem.outputs['node-1'].images[0].filename).toBe('test.png')
|
||||
})
|
||||
|
||||
it('should recognize webm video from core', () => {
|
||||
const taskItem = new TaskItemImpl(
|
||||
'History',
|
||||
// @ts-expect-error fixme ts strict error
|
||||
[0, 'prompt-id', {}, {}, []],
|
||||
{ status_str: 'success', messages: [] },
|
||||
{
|
||||
@@ -67,6 +71,7 @@ describe('TaskItemImpl', () => {
|
||||
it('should recognize webm video from VHS', () => {
|
||||
const taskItem = new TaskItemImpl(
|
||||
'History',
|
||||
// @ts-expect-error fixme ts strict error
|
||||
[0, 'prompt-id', {}, {}, []],
|
||||
{ status_str: 'success', messages: [] },
|
||||
{
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// @ts-strict-ignore
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import type {
|
||||
@@ -22,7 +21,9 @@ describe('nodeDefUtil', () => {
|
||||
|
||||
expect(result).not.toBeNull()
|
||||
expect(result?.[0]).toBe('INT')
|
||||
// @ts-expect-error fixme ts strict error
|
||||
expect(result?.[1].min).toBe(5)
|
||||
// @ts-expect-error fixme ts strict error
|
||||
expect(result?.[1].max).toBe(10)
|
||||
})
|
||||
|
||||
@@ -43,7 +44,9 @@ describe('nodeDefUtil', () => {
|
||||
|
||||
expect(result).not.toBeNull()
|
||||
expect(result?.[0]).toBe('FLOAT')
|
||||
// @ts-expect-error fixme ts strict error
|
||||
expect(result?.[1].min).toBe(5.5)
|
||||
// @ts-expect-error fixme ts strict error
|
||||
expect(result?.[1].max).toBe(10.5)
|
||||
})
|
||||
|
||||
@@ -55,7 +58,9 @@ describe('nodeDefUtil', () => {
|
||||
|
||||
expect(result).not.toBeNull()
|
||||
expect(result?.[0]).toBe('FLOAT')
|
||||
// @ts-expect-error fixme ts strict error
|
||||
expect(result?.[1].min).toBe(0.5)
|
||||
// @ts-expect-error fixme ts strict error
|
||||
expect(result?.[1].max).toBe(15.5)
|
||||
})
|
||||
|
||||
@@ -67,6 +72,7 @@ describe('nodeDefUtil', () => {
|
||||
|
||||
expect(result).not.toBeNull()
|
||||
expect(result?.[0]).toBe('INT')
|
||||
// @ts-expect-error fixme ts strict error
|
||||
expect(result?.[1].step).toBe(6) // LCM of 2 and 3 is 6
|
||||
})
|
||||
|
||||
@@ -78,6 +84,7 @@ describe('nodeDefUtil', () => {
|
||||
|
||||
expect(result).not.toBeNull()
|
||||
expect(result?.[0]).toBe('INT')
|
||||
// @ts-expect-error fixme ts strict error
|
||||
expect(result?.[1].step).toBe(4) // LCM of 1 and 4 is 4
|
||||
})
|
||||
|
||||
@@ -89,6 +96,7 @@ describe('nodeDefUtil', () => {
|
||||
|
||||
expect(result).not.toBeNull()
|
||||
expect(result?.[0]).toBe('FLOAT')
|
||||
// @ts-expect-error fixme ts strict error
|
||||
expect(result?.[1].step).toBe(0.5)
|
||||
})
|
||||
})
|
||||
@@ -103,6 +111,7 @@ describe('nodeDefUtil', () => {
|
||||
|
||||
expect(result).not.toBeNull()
|
||||
expect(result?.[0]).toBe('COMBO')
|
||||
// @ts-expect-error fixme ts strict error
|
||||
expect(result?.[1].options).toEqual(['B', 'C'])
|
||||
})
|
||||
|
||||
@@ -137,9 +146,13 @@ describe('nodeDefUtil', () => {
|
||||
|
||||
expect(result).not.toBeNull()
|
||||
expect(result?.[0]).toBe('COMBO')
|
||||
// @ts-expect-error fixme ts strict error
|
||||
expect(result?.[1].options).toEqual(['B', 'C'])
|
||||
// @ts-expect-error fixme ts strict error
|
||||
expect(result?.[1].default).toBe('B')
|
||||
// @ts-expect-error fixme ts strict error
|
||||
expect(result?.[1].tooltip).toBe('Select an option')
|
||||
// @ts-expect-error fixme ts strict error
|
||||
expect(result?.[1].multiline).toBe(true)
|
||||
})
|
||||
|
||||
@@ -151,6 +164,7 @@ describe('nodeDefUtil', () => {
|
||||
|
||||
expect(result).not.toBeNull()
|
||||
expect(result?.[0]).toBe('COMBO')
|
||||
// @ts-expect-error fixme ts strict error
|
||||
expect(result?.[1].options).toEqual(['C', 'D'])
|
||||
})
|
||||
})
|
||||
@@ -188,8 +202,11 @@ describe('nodeDefUtil', () => {
|
||||
|
||||
expect(result).not.toBeNull()
|
||||
expect(result?.[0]).toBe('STRING')
|
||||
// @ts-expect-error fixme ts strict error
|
||||
expect(result?.[1].default).toBe('value2')
|
||||
// @ts-expect-error fixme ts strict error
|
||||
expect(result?.[1].tooltip).toBe('Tooltip 2')
|
||||
// @ts-expect-error fixme ts strict error
|
||||
expect(result?.[1].step).toBe(1)
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user