mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-04 15:10:06 +00:00
refactor: remove any types from batch 15 test files (10 instances)
Fixed 10 'as any' instances across 5 files: - keybindingService.escape.test.ts: Used ReturnType for dialog store mock - nodeHelpStore.test.ts: Used ComfyNodeDefImpl type for node parameter - comfyRegistryStore.test.ts: Used ReturnType for registry service mock - domWidgetStore.test.ts: Used LGraphNode for mock node property - executionStore.test.ts: Used LGraphNode for mock subgraph nodes
This commit is contained in:
@@ -40,7 +40,7 @@ describe('keybindingService - Escape key handling', () => {
|
||||
// Reset dialog store mock to empty
|
||||
vi.mocked(useDialogStore).mockReturnValue({
|
||||
dialogStack: []
|
||||
} as any)
|
||||
} as unknown as ReturnType<typeof useDialogStore>)
|
||||
|
||||
keybindingService = useKeybindingService()
|
||||
keybindingService.registerCoreKeybindings()
|
||||
@@ -179,7 +179,7 @@ describe('keybindingService - Escape key handling', () => {
|
||||
// Mock dialog store to have open dialogs
|
||||
vi.mocked(useDialogStore).mockReturnValue({
|
||||
dialogStack: [{ key: 'test-dialog' }]
|
||||
} as any)
|
||||
} as unknown as ReturnType<typeof useDialogStore>)
|
||||
|
||||
// Re-create keybinding service to pick up new mock
|
||||
keybindingService = useKeybindingService()
|
||||
|
||||
@@ -126,7 +126,9 @@ describe('useComfyRegistryStore', () => {
|
||||
}
|
||||
|
||||
vi.mocked(useComfyRegistryService).mockReturnValue(
|
||||
mockRegistryService as any
|
||||
mockRegistryService as unknown as ReturnType<
|
||||
typeof useComfyRegistryService
|
||||
>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -176,7 +178,7 @@ describe('useComfyRegistryStore', () => {
|
||||
const store = useComfyRegistryStore()
|
||||
vi.spyOn(store.getPackById, 'call').mockResolvedValueOnce(null)
|
||||
|
||||
const result = await store.getPackById.call(null as any)
|
||||
const result = await store.getPackById.call(null as unknown as string)
|
||||
|
||||
expect(result).toBeNull()
|
||||
expect(mockRegistryService.getPackById).not.toHaveBeenCalled()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { createPinia, setActivePinia } from 'pinia'
|
||||
import { beforeEach, describe, expect, it } from 'vitest'
|
||||
|
||||
import type { LGraphNode } from '@/lib/litegraph/src/litegraph'
|
||||
import { useDomWidgetStore } from '@/stores/domWidgetStore'
|
||||
|
||||
// Mock DOM widget for testing
|
||||
@@ -14,7 +15,7 @@ const createMockDOMWidget = (id: string) => {
|
||||
title: 'Test Node',
|
||||
pos: [0, 0],
|
||||
size: [200, 100]
|
||||
} as any,
|
||||
} as unknown as LGraphNode,
|
||||
name: 'test_widget',
|
||||
type: 'text',
|
||||
value: 'test',
|
||||
@@ -22,7 +23,7 @@ const createMockDOMWidget = (id: string) => {
|
||||
y: 0,
|
||||
margin: 10,
|
||||
isVisible: () => true,
|
||||
containerNode: undefined as any
|
||||
containerNode: undefined
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { createPinia, setActivePinia } from 'pinia'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import type { LGraphNode } from '@/lib/litegraph/src/litegraph'
|
||||
import { app } from '@/scripts/app'
|
||||
import { useExecutionStore } from '@/stores/executionStore'
|
||||
|
||||
@@ -75,7 +76,7 @@ describe('useExecutionStore - NodeLocatorId conversions', () => {
|
||||
id: 123,
|
||||
isSubgraphNode: () => true,
|
||||
subgraph: mockSubgraph
|
||||
} as any
|
||||
} as unknown as LGraphNode
|
||||
|
||||
// Mock app.rootGraph.getNodeById to return the mock node
|
||||
vi.mocked(app.rootGraph.getNodeById).mockReturnValue(mockNode)
|
||||
@@ -181,7 +182,7 @@ describe('useExecutionStore - Node Error Lookups', () => {
|
||||
id: 123,
|
||||
isSubgraphNode: () => true,
|
||||
subgraph: mockSubgraph
|
||||
} as any
|
||||
} as unknown as LGraphNode
|
||||
|
||||
vi.mocked(app.rootGraph.getNodeById).mockReturnValue(mockNode)
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { createPinia, setActivePinia } from 'pinia'
|
||||
import { beforeEach, describe, expect, it } from 'vitest'
|
||||
|
||||
import type { ComfyNodeDefImpl } from '@/stores/nodeDefStore'
|
||||
import { useNodeHelpStore } from '@/stores/workspace/nodeHelpStore'
|
||||
|
||||
describe('nodeHelpStore', () => {
|
||||
@@ -26,7 +27,7 @@ describe('nodeHelpStore', () => {
|
||||
it('should open help for a node', () => {
|
||||
const nodeHelpStore = useNodeHelpStore()
|
||||
|
||||
nodeHelpStore.openHelp(mockCoreNode as any)
|
||||
nodeHelpStore.openHelp(mockCoreNode as unknown as ComfyNodeDefImpl)
|
||||
|
||||
expect(nodeHelpStore.currentHelpNode).toStrictEqual(mockCoreNode)
|
||||
expect(nodeHelpStore.isHelpOpen).toBe(true)
|
||||
@@ -35,7 +36,7 @@ describe('nodeHelpStore', () => {
|
||||
it('should close help', () => {
|
||||
const nodeHelpStore = useNodeHelpStore()
|
||||
|
||||
nodeHelpStore.openHelp(mockCoreNode as any)
|
||||
nodeHelpStore.openHelp(mockCoreNode as unknown as ComfyNodeDefImpl)
|
||||
expect(nodeHelpStore.isHelpOpen).toBe(true)
|
||||
|
||||
nodeHelpStore.closeHelp()
|
||||
|
||||
Reference in New Issue
Block a user