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:
Johnpaul
2026-01-22 22:34:27 +01:00
parent 35ddd998ec
commit cc6da76aa9
5 changed files with 15 additions and 10 deletions

View File

@@ -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()

View File

@@ -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()

View File

@@ -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
}
}

View File

@@ -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)

View File

@@ -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()