From cc6da76aa9f78e9f2fff7262ec78543e4743666e Mon Sep 17 00:00:00 2001 From: Johnpaul Date: Thu, 22 Jan 2026 22:34:27 +0100 Subject: [PATCH] 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 --- src/services/keybindingService.escape.test.ts | 4 ++-- src/stores/comfyRegistryStore.test.ts | 6 ++++-- src/stores/domWidgetStore.test.ts | 5 +++-- src/stores/executionStore.test.ts | 5 +++-- src/stores/workspace/nodeHelpStore.test.ts | 5 +++-- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/services/keybindingService.escape.test.ts b/src/services/keybindingService.escape.test.ts index 053b48bf4..ef322a014 100644 --- a/src/services/keybindingService.escape.test.ts +++ b/src/services/keybindingService.escape.test.ts @@ -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) 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) // Re-create keybinding service to pick up new mock keybindingService = useKeybindingService() diff --git a/src/stores/comfyRegistryStore.test.ts b/src/stores/comfyRegistryStore.test.ts index fa2c86ab7..c8cf9709e 100644 --- a/src/stores/comfyRegistryStore.test.ts +++ b/src/stores/comfyRegistryStore.test.ts @@ -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() diff --git a/src/stores/domWidgetStore.test.ts b/src/stores/domWidgetStore.test.ts index 21a83f7c6..3aa05b461 100644 --- a/src/stores/domWidgetStore.test.ts +++ b/src/stores/domWidgetStore.test.ts @@ -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 } } diff --git a/src/stores/executionStore.test.ts b/src/stores/executionStore.test.ts index 75b6f4a43..46dfbe414 100644 --- a/src/stores/executionStore.test.ts +++ b/src/stores/executionStore.test.ts @@ -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) diff --git a/src/stores/workspace/nodeHelpStore.test.ts b/src/stores/workspace/nodeHelpStore.test.ts index 0514e9029..5e695425c 100644 --- a/src/stores/workspace/nodeHelpStore.test.ts +++ b/src/stores/workspace/nodeHelpStore.test.ts @@ -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()