diff --git a/docs/testing/store-testing.md b/docs/testing/store-testing.md index aec716c07..9b736fa36 100644 --- a/docs/testing/store-testing.md +++ b/docs/testing/store-testing.md @@ -18,7 +18,8 @@ Basic setup for testing Pinia stores: ```typescript // Example from: tests-ui/tests/store/workflowStore.test.ts -import { createPinia, setActivePinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' +import { setActivePinia } from 'pinia' import { beforeEach, describe, expect, it, vi } from 'vitest' import { useWorkflowStore } from '@/domains/workflow/ui/stores/workflowStore' @@ -27,8 +28,8 @@ describe('useWorkflowStore', () => { let store: ReturnType beforeEach(() => { - // Create a fresh pinia and activate it for each test - setActivePinia(createPinia()) + // Create a fresh testing pinia and activate it for each test + setActivePinia(createTestingPinia({ stubActions: false })) // Initialize the store store = useWorkflowStore() diff --git a/src/platform/cloud/subscription/composables/useSubscriptionCredits.test.ts b/src/platform/cloud/subscription/composables/useSubscriptionCredits.test.ts index dde7313e4..8e3ef1dc1 100644 --- a/src/platform/cloud/subscription/composables/useSubscriptionCredits.test.ts +++ b/src/platform/cloud/subscription/composables/useSubscriptionCredits.test.ts @@ -1,4 +1,5 @@ -import { createPinia, setActivePinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' +import { setActivePinia } from 'pinia' import { beforeEach, describe, expect, it, vi } from 'vitest' import type * as VueI18nModule from 'vue-i18n' @@ -79,7 +80,7 @@ describe('useSubscriptionCredits', () => { let authStore: ReturnType beforeEach(() => { - setActivePinia(createPinia()) + setActivePinia(createTestingPinia({ stubActions: false })) authStore = useFirebaseAuthStore() vi.clearAllMocks() }) diff --git a/src/platform/updates/common/versionCompatibilityStore.test.ts b/src/platform/updates/common/versionCompatibilityStore.test.ts index 3fdb80eaa..06ba4aea8 100644 --- a/src/platform/updates/common/versionCompatibilityStore.test.ts +++ b/src/platform/updates/common/versionCompatibilityStore.test.ts @@ -1,5 +1,6 @@ import { until } from '@vueuse/core' -import { createPinia, setActivePinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' +import { setActivePinia } from 'pinia' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import { ref } from 'vue' @@ -40,7 +41,7 @@ describe('useVersionCompatibilityStore', () => { let mockSettingStore: { get: ReturnType } beforeEach(() => { - setActivePinia(createPinia()) + setActivePinia(createTestingPinia({ stubActions: false })) // Clear the mock dismissal storage mockDismissalStorage.value = {} diff --git a/src/platform/workflow/management/stores/workflowStore.test.ts b/src/platform/workflow/management/stores/workflowStore.test.ts index fad21ccfc..f13daf21c 100644 --- a/src/platform/workflow/management/stores/workflowStore.test.ts +++ b/src/platform/workflow/management/stores/workflowStore.test.ts @@ -1,4 +1,5 @@ -import { createPinia, setActivePinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' +import { setActivePinia } from 'pinia' import { beforeEach, describe, expect, it, vi } from 'vitest' import { nextTick } from 'vue' @@ -66,7 +67,7 @@ describe('useWorkflowStore', () => { } beforeEach(() => { - setActivePinia(createPinia()) + setActivePinia(createTestingPinia({ stubActions: false })) store = useWorkflowStore() bookmarkStore = useWorkflowBookmarkStore() vi.clearAllMocks() diff --git a/src/platform/workflow/persistence/composables/useWorkflowPersistence.test.ts b/src/platform/workflow/persistence/composables/useWorkflowPersistence.test.ts index 76dac06c6..0fb69f65d 100644 --- a/src/platform/workflow/persistence/composables/useWorkflowPersistence.test.ts +++ b/src/platform/workflow/persistence/composables/useWorkflowPersistence.test.ts @@ -1,4 +1,5 @@ -import { createPinia, setActivePinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' +import { setActivePinia } from 'pinia' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import type * as I18n from 'vue-i18n' @@ -108,7 +109,7 @@ describe('useWorkflowPersistence', () => { beforeEach(() => { vi.useFakeTimers() vi.setSystemTime(new Date('2025-01-01T00:00:00Z')) - setActivePinia(createPinia()) + setActivePinia(createTestingPinia({ stubActions: false })) localStorage.clear() sessionStorage.clear() vi.clearAllMocks() diff --git a/src/platform/workspace/stores/teamWorkspaceStore.test.ts b/src/platform/workspace/stores/teamWorkspaceStore.test.ts index a66be714a..92b712787 100644 --- a/src/platform/workspace/stores/teamWorkspaceStore.test.ts +++ b/src/platform/workspace/stores/teamWorkspaceStore.test.ts @@ -1,4 +1,5 @@ -import { createPinia, setActivePinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' +import { setActivePinia } from 'pinia' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import { useTeamWorkspaceStore } from './teamWorkspaceStore' @@ -111,7 +112,7 @@ const mockMemberWorkspace = { describe('useTeamWorkspaceStore', () => { beforeEach(() => { - setActivePinia(createPinia()) + setActivePinia(createTestingPinia({ stubActions: false })) vi.clearAllMocks() vi.stubGlobal('localStorage', mockLocalStorage) sessionStorage.clear() diff --git a/src/renderer/extensions/minimap/composables/useMinimapSettings.test.ts b/src/renderer/extensions/minimap/composables/useMinimapSettings.test.ts index 448f64090..44d2d0f57 100644 --- a/src/renderer/extensions/minimap/composables/useMinimapSettings.test.ts +++ b/src/renderer/extensions/minimap/composables/useMinimapSettings.test.ts @@ -1,4 +1,5 @@ -import { createPinia, setActivePinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' +import { setActivePinia } from 'pinia' import { beforeEach, describe, expect, it, vi } from 'vitest' import { useSettingStore } from '@/platform/settings/settingStore' @@ -15,7 +16,7 @@ vi.mock('@/stores/workspace/colorPaletteStore', () => ({ describe('useMinimapSettings', () => { beforeEach(() => { - setActivePinia(createPinia()) + setActivePinia(createTestingPinia({ stubActions: false })) vi.clearAllMocks() }) diff --git a/src/renderer/extensions/vueNodes/components/NodeHeader.test.ts b/src/renderer/extensions/vueNodes/components/NodeHeader.test.ts index a813e88af..e5bb31224 100644 --- a/src/renderer/extensions/vueNodes/components/NodeHeader.test.ts +++ b/src/renderer/extensions/vueNodes/components/NodeHeader.test.ts @@ -1,5 +1,6 @@ +import { createTestingPinia } from '@pinia/testing' import { mount } from '@vue/test-utils' -import { createPinia, setActivePinia } from 'pinia' +import { setActivePinia } from 'pinia' import PrimeVue from 'primevue/config' import InputText from 'primevue/inputtext' import { describe, expect, it, vi } from 'vitest' @@ -29,7 +30,7 @@ const makeNodeData = (overrides: Partial = {}): VueNodeData => ({ }) const setupMockStores = () => { - const pinia = createPinia() + const pinia = createTestingPinia({ stubActions: false }) setActivePinia(pinia) const settingStore = useSettingStore() diff --git a/src/renderer/extensions/vueNodes/components/NodeSlots.test.ts b/src/renderer/extensions/vueNodes/components/NodeSlots.test.ts index 6f3c75adf..a8991f9f8 100644 --- a/src/renderer/extensions/vueNodes/components/NodeSlots.test.ts +++ b/src/renderer/extensions/vueNodes/components/NodeSlots.test.ts @@ -1,6 +1,6 @@ /* eslint-disable vue/one-component-per-file */ +import { createTestingPinia } from '@pinia/testing' import { mount } from '@vue/test-utils' -import { createPinia } from 'pinia' import { describe, expect, it } from 'vitest' import { defineComponent } from 'vue' import type { PropType } from 'vue' @@ -84,7 +84,7 @@ const mountSlots = (nodeData: VueNodeData, readonly = false) => { }) return mount(NodeSlots, { global: { - plugins: [i18n, createPinia()], + plugins: [i18n, createTestingPinia({ stubActions: false })], stubs: { InputSlot: InputSlotStub, OutputSlot: OutputSlotStub diff --git a/src/services/keybindingService.escape.test.ts b/src/services/keybindingService.escape.test.ts index 053b48bf4..caaf10e46 100644 --- a/src/services/keybindingService.escape.test.ts +++ b/src/services/keybindingService.escape.test.ts @@ -1,4 +1,5 @@ -import { createPinia, setActivePinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' +import { setActivePinia } from 'pinia' import { beforeEach, describe, expect, it, vi } from 'vitest' import { CORE_KEYBINDINGS } from '@/constants/coreKeybindings' @@ -30,7 +31,7 @@ describe('keybindingService - Escape key handling', () => { beforeEach(() => { vi.clearAllMocks() - setActivePinia(createPinia()) + setActivePinia(createTestingPinia({ stubActions: false })) // Mock command store execute const commandStore = useCommandStore() diff --git a/src/services/keybindingService.forwarding.test.ts b/src/services/keybindingService.forwarding.test.ts index 1c62222dd..bd3951f56 100644 --- a/src/services/keybindingService.forwarding.test.ts +++ b/src/services/keybindingService.forwarding.test.ts @@ -1,4 +1,5 @@ -import { createPinia, setActivePinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' +import { setActivePinia } from 'pinia' import { beforeEach, describe, expect, it, vi } from 'vitest' import { app } from '@/scripts/app' @@ -68,7 +69,7 @@ describe('keybindingService - Event Forwarding', () => { beforeEach(() => { vi.clearAllMocks() - setActivePinia(createPinia()) + setActivePinia(createTestingPinia({ stubActions: false })) // Mock command store execute const commandStore = useCommandStore() diff --git a/src/stores/comfyRegistryStore.test.ts b/src/stores/comfyRegistryStore.test.ts index fa2c86ab7..f1c1d76cf 100644 --- a/src/stores/comfyRegistryStore.test.ts +++ b/src/stores/comfyRegistryStore.test.ts @@ -1,4 +1,5 @@ -import { createPinia, setActivePinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' +import { setActivePinia } from 'pinia' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import { ref } from 'vue' @@ -83,7 +84,7 @@ describe('useComfyRegistryStore', () => { } beforeEach(() => { - setActivePinia(createPinia()) + setActivePinia(createTestingPinia({ stubActions: false })) vi.clearAllMocks() mockRegistryService = { isLoading: ref(false), diff --git a/src/stores/dialogStore.test.ts b/src/stores/dialogStore.test.ts index 3d21ff695..67cfa3788 100644 --- a/src/stores/dialogStore.test.ts +++ b/src/stores/dialogStore.test.ts @@ -1,4 +1,5 @@ -import { createPinia, setActivePinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' +import { setActivePinia } from 'pinia' import { beforeEach, describe, expect, it } from 'vitest' import { defineComponent } from 'vue' @@ -11,7 +12,7 @@ const MockComponent = defineComponent({ describe('dialogStore', () => { beforeEach(() => { - setActivePinia(createPinia()) + setActivePinia(createTestingPinia({ stubActions: false })) }) describe('priority system', () => { diff --git a/src/stores/domWidgetStore.test.ts b/src/stores/domWidgetStore.test.ts index 21a83f7c6..24c2d47e6 100644 --- a/src/stores/domWidgetStore.test.ts +++ b/src/stores/domWidgetStore.test.ts @@ -1,4 +1,5 @@ -import { createPinia, setActivePinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' +import { setActivePinia } from 'pinia' import { beforeEach, describe, expect, it } from 'vitest' import { useDomWidgetStore } from '@/stores/domWidgetStore' @@ -30,7 +31,7 @@ describe('domWidgetStore', () => { let store: ReturnType beforeEach(() => { - setActivePinia(createPinia()) + setActivePinia(createTestingPinia({ stubActions: false })) store = useDomWidgetStore() }) diff --git a/src/stores/executionStore.test.ts b/src/stores/executionStore.test.ts index 75b6f4a43..f15c6a8dc 100644 --- a/src/stores/executionStore.test.ts +++ b/src/stores/executionStore.test.ts @@ -1,4 +1,5 @@ -import { createPinia, setActivePinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' +import { setActivePinia } from 'pinia' import { beforeEach, describe, expect, it, vi } from 'vitest' import { app } from '@/scripts/app' @@ -59,7 +60,7 @@ describe('useExecutionStore - NodeLocatorId conversions', () => { mockNodeIdToNodeLocatorId.mockReset() mockNodeLocatorIdToNodeExecutionId.mockReset() - setActivePinia(createPinia()) + setActivePinia(createTestingPinia({ stubActions: false })) store = useExecutionStore() }) @@ -137,7 +138,7 @@ describe('useExecutionStore - Node Error Lookups', () => { beforeEach(() => { vi.clearAllMocks() - setActivePinia(createPinia()) + setActivePinia(createTestingPinia({ stubActions: false })) store = useExecutionStore() }) diff --git a/src/stores/firebaseAuthStore.test.ts b/src/stores/firebaseAuthStore.test.ts index 54beac934..47ed75c25 100644 --- a/src/stores/firebaseAuthStore.test.ts +++ b/src/stores/firebaseAuthStore.test.ts @@ -1,6 +1,7 @@ import { FirebaseError } from 'firebase/app' import * as firebaseAuth from 'firebase/auth' -import { createPinia, setActivePinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' +import { setActivePinia } from 'pinia' import { beforeEach, describe, expect, it, vi } from 'vitest' import * as vuefire from 'vuefire' @@ -153,7 +154,7 @@ describe('useFirebaseAuthStore', () => { }) // Initialize Pinia - setActivePinia(createPinia()) + setActivePinia(createTestingPinia({ stubActions: false })) store = useFirebaseAuthStore() // Reset and set up getIdToken mock @@ -175,7 +176,7 @@ describe('useFirebaseAuthStore', () => { vi.mocked(vuefire.useFirebaseAuth).mockReturnValue(mockAuth as any) - setActivePinia(createPinia()) + setActivePinia(createTestingPinia({ stubActions: false })) store = useFirebaseAuthStore() }) diff --git a/src/stores/imagePreviewStore.test.ts b/src/stores/imagePreviewStore.test.ts index d2bb8d639..4b796e479 100644 --- a/src/stores/imagePreviewStore.test.ts +++ b/src/stores/imagePreviewStore.test.ts @@ -1,4 +1,5 @@ -import { createPinia, setActivePinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' +import { setActivePinia } from 'pinia' import { beforeEach, describe, expect, it, vi } from 'vitest' import type { LGraphNode } from '@/lib/litegraph/src/litegraph' @@ -30,7 +31,7 @@ const createMockOutputs = ( describe('imagePreviewStore getPreviewParam', () => { beforeEach(() => { - setActivePinia(createPinia()) + setActivePinia(createTestingPinia({ stubActions: false })) vi.clearAllMocks() vi.mocked(litegraphUtil.isVideoNode).mockReturnValue(false) }) diff --git a/src/stores/keybindingStore.test.ts b/src/stores/keybindingStore.test.ts index 120f8c174..1f7e1c6e2 100644 --- a/src/stores/keybindingStore.test.ts +++ b/src/stores/keybindingStore.test.ts @@ -1,11 +1,12 @@ -import { createPinia, setActivePinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' +import { setActivePinia } from 'pinia' import { beforeEach, describe, expect, it } from 'vitest' import { KeybindingImpl, useKeybindingStore } from '@/stores/keybindingStore' describe('useKeybindingStore', () => { beforeEach(() => { - setActivePinia(createPinia()) + setActivePinia(createTestingPinia({ stubActions: false })) }) it('should add and retrieve default keybindings', () => { diff --git a/src/stores/modelStore.test.ts b/src/stores/modelStore.test.ts index c9ed82e55..2bc6f6ab3 100644 --- a/src/stores/modelStore.test.ts +++ b/src/stores/modelStore.test.ts @@ -1,4 +1,5 @@ -import { createPinia, setActivePinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' +import { setActivePinia } from 'pinia' import { beforeEach, describe, expect, it, vi } from 'vitest' import { assetService } from '@/platform/assets/services/assetService' @@ -89,7 +90,7 @@ describe('useModelStore', () => { let store: ReturnType beforeEach(async () => { - setActivePinia(createPinia()) + setActivePinia(createTestingPinia({ stubActions: false })) vi.resetAllMocks() }) diff --git a/src/stores/modelToNodeStore.test.ts b/src/stores/modelToNodeStore.test.ts index c79af19b5..6e804151b 100644 --- a/src/stores/modelToNodeStore.test.ts +++ b/src/stores/modelToNodeStore.test.ts @@ -1,4 +1,5 @@ -import { createPinia, setActivePinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' +import { setActivePinia } from 'pinia' import { beforeEach, describe, expect, it, vi } from 'vitest' import type { ComfyNodeDef as ComfyNodeDefV1 } from '@/schemas/nodeDefSchema' @@ -82,7 +83,7 @@ vi.mock('@/stores/nodeDefStore', async (importOriginal) => { describe('useModelToNodeStore', () => { beforeEach(() => { - setActivePinia(createPinia()) + setActivePinia(createTestingPinia({ stubActions: false })) vi.clearAllMocks() }) @@ -330,7 +331,7 @@ describe('useModelToNodeStore', () => { it('should not register when nodeDefStore is empty', () => { // Create fresh Pinia for this test to avoid state persistence - setActivePinia(createPinia()) + setActivePinia(createTestingPinia({ stubActions: false })) vi.mocked(useNodeDefStore, { partial: true }).mockReturnValue({ nodeDefsByName: {} @@ -355,7 +356,7 @@ describe('useModelToNodeStore', () => { it('should return empty Record when nodeDefStore is empty', () => { // Create fresh Pinia for this test to avoid state persistence - setActivePinia(createPinia()) + setActivePinia(createTestingPinia({ stubActions: false })) vi.mocked(useNodeDefStore, { partial: true }).mockReturnValue({ nodeDefsByName: {} diff --git a/src/stores/nodeDefStore.test.ts b/src/stores/nodeDefStore.test.ts index d4d9828d4..242b457b6 100644 --- a/src/stores/nodeDefStore.test.ts +++ b/src/stores/nodeDefStore.test.ts @@ -1,4 +1,5 @@ -import { createPinia, setActivePinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' +import { setActivePinia } from 'pinia' import { beforeEach, describe, expect, it } from 'vitest' import type { ComfyNodeDef } from '@/schemas/nodeDefSchema' @@ -9,7 +10,7 @@ describe('useNodeDefStore', () => { let store: ReturnType beforeEach(() => { - setActivePinia(createPinia()) + setActivePinia(createTestingPinia({ stubActions: false })) store = useNodeDefStore() }) diff --git a/src/stores/queueStore.loadWorkflow.test.ts b/src/stores/queueStore.loadWorkflow.test.ts index 8b9ae30a5..c0c13033c 100644 --- a/src/stores/queueStore.loadWorkflow.test.ts +++ b/src/stores/queueStore.loadWorkflow.test.ts @@ -1,4 +1,5 @@ -import { createPinia, setActivePinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' +import { setActivePinia } from 'pinia' import { beforeEach, describe, expect, it, vi } from 'vitest' import type { @@ -71,7 +72,7 @@ describe('TaskItemImpl.loadWorkflow - workflow fetching', () => { let mockFetchApi: ReturnType beforeEach(() => { - setActivePinia(createPinia()) + setActivePinia(createTestingPinia({ stubActions: false })) vi.clearAllMocks() mockFetchApi = vi.fn() diff --git a/src/stores/queueStore.test.ts b/src/stores/queueStore.test.ts index 063658b2f..0f3e8c0f1 100644 --- a/src/stores/queueStore.test.ts +++ b/src/stores/queueStore.test.ts @@ -1,4 +1,5 @@ -import { createPinia, setActivePinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' +import { setActivePinia } from 'pinia' import { beforeEach, describe, expect, it, vi } from 'vitest' import type { JobListItem } from '@/platform/remote/comfyui/jobs/jobTypes' @@ -240,7 +241,7 @@ describe('useQueueStore', () => { let store: ReturnType beforeEach(() => { - setActivePinia(createPinia()) + setActivePinia(createTestingPinia({ stubActions: false })) store = useQueueStore() vi.clearAllMocks() }) diff --git a/src/stores/serverConfigStore.test.ts b/src/stores/serverConfigStore.test.ts index dd25c5b64..ee4c9cc54 100644 --- a/src/stores/serverConfigStore.test.ts +++ b/src/stores/serverConfigStore.test.ts @@ -1,4 +1,5 @@ -import { createPinia, setActivePinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' +import { setActivePinia } from 'pinia' import { beforeEach, describe, expect, it } from 'vitest' import type { ServerConfig } from '@/constants/serverConfig' @@ -14,7 +15,7 @@ describe('useServerConfigStore', () => { let store: ReturnType beforeEach(() => { - setActivePinia(createPinia()) + setActivePinia(createTestingPinia({ stubActions: false })) store = useServerConfigStore() }) diff --git a/src/stores/subgraphNavigationStore.test.ts b/src/stores/subgraphNavigationStore.test.ts index e16700602..bf38a0324 100644 --- a/src/stores/subgraphNavigationStore.test.ts +++ b/src/stores/subgraphNavigationStore.test.ts @@ -1,4 +1,5 @@ -import { createPinia, setActivePinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' +import { setActivePinia } from 'pinia' import { beforeEach, describe, expect, it, vi } from 'vitest' import { nextTick } from 'vue' @@ -47,7 +48,7 @@ vi.mock('@/utils/graphTraversalUtil', () => ({ describe('useSubgraphNavigationStore', () => { beforeEach(() => { - setActivePinia(createPinia()) + setActivePinia(createTestingPinia({ stubActions: false })) }) it('should not clear navigation stack when workflow internal state changes', async () => { diff --git a/src/stores/subgraphNavigationStore.viewport.test.ts b/src/stores/subgraphNavigationStore.viewport.test.ts index 6dbf85a6b..fe52138d3 100644 --- a/src/stores/subgraphNavigationStore.viewport.test.ts +++ b/src/stores/subgraphNavigationStore.viewport.test.ts @@ -1,4 +1,5 @@ -import { createPinia, setActivePinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' +import { setActivePinia } from 'pinia' import { beforeEach, describe, expect, it, vi } from 'vitest' import { nextTick } from 'vue' @@ -46,7 +47,7 @@ const mockCanvas = app.canvas as any describe('useSubgraphNavigationStore - Viewport Persistence', () => { beforeEach(() => { - setActivePinia(createPinia()) + setActivePinia(createTestingPinia({ stubActions: false })) // Reset canvas state mockCanvas.ds.scale = 1 mockCanvas.ds.offset = [0, 0] diff --git a/src/stores/subgraphStore.test.ts b/src/stores/subgraphStore.test.ts index 68f528ae4..e8b49f947 100644 --- a/src/stores/subgraphStore.test.ts +++ b/src/stores/subgraphStore.test.ts @@ -1,4 +1,5 @@ -import { createPinia, setActivePinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' +import { setActivePinia } from 'pinia' import { beforeEach, describe, expect, it, vi } from 'vitest' import type { ComfyNodeDef as ComfyNodeDefV1 } from '@/schemas/nodeDefSchema' @@ -78,7 +79,7 @@ describe('useSubgraphStore', () => { } beforeEach(() => { - setActivePinia(createPinia()) + setActivePinia(createTestingPinia({ stubActions: false })) store = useSubgraphStore() vi.clearAllMocks() }) diff --git a/src/stores/systemStatsStore.test.ts b/src/stores/systemStatsStore.test.ts index 49653c780..a6f070481 100644 --- a/src/stores/systemStatsStore.test.ts +++ b/src/stores/systemStatsStore.test.ts @@ -1,4 +1,5 @@ -import { createPinia, setActivePinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' +import { setActivePinia } from 'pinia' import { beforeEach, describe, expect, it, vi } from 'vitest' import { api } from '@/scripts/api' @@ -25,7 +26,7 @@ describe('useSystemStatsStore', () => { beforeEach(() => { // Mock API to prevent automatic fetch on store creation vi.mocked(api.getSystemStats).mockResolvedValue(null as any) - setActivePinia(createPinia()) + setActivePinia(createTestingPinia({ stubActions: false })) store = useSystemStatsStore() vi.clearAllMocks() }) diff --git a/src/stores/templateRankingStore.test.ts b/src/stores/templateRankingStore.test.ts index cb3a9539d..12e7950fa 100644 --- a/src/stores/templateRankingStore.test.ts +++ b/src/stores/templateRankingStore.test.ts @@ -1,4 +1,5 @@ -import { createPinia, setActivePinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' +import { setActivePinia } from 'pinia' import { beforeEach, describe, expect, it, vi } from 'vitest' import { useTemplateRankingStore } from '@/stores/templateRankingStore' @@ -12,7 +13,7 @@ vi.mock('axios', () => ({ describe('templateRankingStore', () => { beforeEach(() => { - setActivePinia(createPinia()) + setActivePinia(createTestingPinia({ stubActions: false })) vi.clearAllMocks() }) diff --git a/src/stores/userFileStore.test.ts b/src/stores/userFileStore.test.ts index dad0d3fa1..b94bd983b 100644 --- a/src/stores/userFileStore.test.ts +++ b/src/stores/userFileStore.test.ts @@ -1,4 +1,5 @@ -import { createPinia, setActivePinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' +import { setActivePinia } from 'pinia' import { beforeEach, describe, expect, it, vi } from 'vitest' import { api } from '@/scripts/api' @@ -19,7 +20,7 @@ describe('useUserFileStore', () => { let store: ReturnType beforeEach(() => { - setActivePinia(createPinia()) + setActivePinia(createTestingPinia({ stubActions: false })) store = useUserFileStore() vi.resetAllMocks() }) diff --git a/src/stores/workspace/bottomPanelStore.test.ts b/src/stores/workspace/bottomPanelStore.test.ts index 7d9a2406e..edfa6960b 100644 --- a/src/stores/workspace/bottomPanelStore.test.ts +++ b/src/stores/workspace/bottomPanelStore.test.ts @@ -1,4 +1,5 @@ -import { createPinia, setActivePinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' +import { setActivePinia } from 'pinia' import { beforeEach, describe, expect, it, vi } from 'vitest' import { useBottomPanelStore } from '@/stores/workspace/bottomPanelStore' @@ -53,7 +54,7 @@ vi.mock('@/utils/envUtil', () => ({ describe('useBottomPanelStore', () => { beforeEach(() => { - setActivePinia(createPinia()) + setActivePinia(createTestingPinia({ stubActions: false })) }) it('should initialize with empty panels', () => { diff --git a/src/stores/workspace/nodeHelpStore.test.ts b/src/stores/workspace/nodeHelpStore.test.ts index 0514e9029..365df0b74 100644 --- a/src/stores/workspace/nodeHelpStore.test.ts +++ b/src/stores/workspace/nodeHelpStore.test.ts @@ -1,4 +1,5 @@ -import { createPinia, setActivePinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' +import { setActivePinia } from 'pinia' import { beforeEach, describe, expect, it } from 'vitest' import { useNodeHelpStore } from '@/stores/workspace/nodeHelpStore' @@ -14,7 +15,7 @@ describe('nodeHelpStore', () => { } beforeEach(() => { - setActivePinia(createPinia()) + setActivePinia(createTestingPinia({ stubActions: false })) }) it('should initialize with empty state', () => { diff --git a/src/stores/workspace/searchBoxStore.test.ts b/src/stores/workspace/searchBoxStore.test.ts index 10a3ab7d4..e74111f2a 100644 --- a/src/stores/workspace/searchBoxStore.test.ts +++ b/src/stores/workspace/searchBoxStore.test.ts @@ -1,4 +1,5 @@ -import { createPinia, setActivePinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' +import { setActivePinia } from 'pinia' import { beforeEach, describe, expect, it, vi } from 'vitest' import type NodeSearchBoxPopover from '@/components/searchbox/NodeSearchBoxPopover.vue' @@ -34,7 +35,7 @@ function createMockSettingStore(): ReturnType { describe('useSearchBoxStore', () => { beforeEach(() => { - setActivePinia(createPinia()) + setActivePinia(createTestingPinia({ stubActions: false })) vi.restoreAllMocks() }) diff --git a/src/workbench/extensions/manager/components/manager/NodeConflictDialogContent.test.ts b/src/workbench/extensions/manager/components/manager/NodeConflictDialogContent.test.ts index e169ec9f0..c55b94dc2 100644 --- a/src/workbench/extensions/manager/components/manager/NodeConflictDialogContent.test.ts +++ b/src/workbench/extensions/manager/components/manager/NodeConflictDialogContent.test.ts @@ -1,5 +1,6 @@ import { mount } from '@vue/test-utils' -import { createPinia, setActivePinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' +import { setActivePinia } from 'pinia' import Button from '@/components/ui/button/Button.vue' import { beforeEach, describe, expect, it, vi } from 'vitest' import { computed, ref } from 'vue' @@ -44,11 +45,11 @@ vi.mock( ) describe('NodeConflictDialogContent', () => { - let pinia: ReturnType + let pinia: ReturnType beforeEach(() => { vi.clearAllMocks() - pinia = createPinia() + pinia = createTestingPinia({ stubActions: false }) setActivePinia(pinia) // Reset mock data mockConflictData.value = [] diff --git a/src/workbench/extensions/manager/components/manager/PackVersionBadge.test.ts b/src/workbench/extensions/manager/components/manager/PackVersionBadge.test.ts index d57b25f1f..ff846b9f1 100644 --- a/src/workbench/extensions/manager/components/manager/PackVersionBadge.test.ts +++ b/src/workbench/extensions/manager/components/manager/PackVersionBadge.test.ts @@ -1,6 +1,6 @@ import type { VueWrapper } from '@vue/test-utils' import { mount } from '@vue/test-utils' -import { createPinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' import PrimeVue from 'primevue/config' import Tooltip from 'primevue/tooltip' import { beforeEach, describe, expect, it, vi } from 'vitest' @@ -89,7 +89,7 @@ describe('PackVersionBadge', () => { ...props }, global: { - plugins: [PrimeVue, createPinia(), i18n], + plugins: [PrimeVue, createTestingPinia({ stubActions: false }), i18n], directives: { tooltip: Tooltip }, diff --git a/src/workbench/extensions/manager/components/manager/PackVersionSelectorPopover.test.ts b/src/workbench/extensions/manager/components/manager/PackVersionSelectorPopover.test.ts index 792983c22..a9337c7f1 100644 --- a/src/workbench/extensions/manager/components/manager/PackVersionSelectorPopover.test.ts +++ b/src/workbench/extensions/manager/components/manager/PackVersionSelectorPopover.test.ts @@ -1,6 +1,6 @@ import type { VueWrapper } from '@vue/test-utils' import { mount } from '@vue/test-utils' -import { createPinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' import Button from '@/components/ui/button/Button.vue' import PrimeVue from 'primevue/config' import Listbox from 'primevue/listbox' @@ -115,7 +115,7 @@ describe('PackVersionSelectorPopover', () => { ...props }, global: { - plugins: [PrimeVue, createPinia(), i18n], + plugins: [PrimeVue, createTestingPinia({ stubActions: false }), i18n], components: { Listbox, VerifiedIcon, diff --git a/src/workbench/extensions/manager/components/manager/button/PackEnableToggle.test.ts b/src/workbench/extensions/manager/components/manager/button/PackEnableToggle.test.ts index 54bbe5bb9..bfd40a9ce 100644 --- a/src/workbench/extensions/manager/components/manager/button/PackEnableToggle.test.ts +++ b/src/workbench/extensions/manager/components/manager/button/PackEnableToggle.test.ts @@ -1,6 +1,6 @@ import type { VueWrapper } from '@vue/test-utils' import { mount } from '@vue/test-utils' -import { createPinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' import PrimeVue from 'primevue/config' import ToggleSwitch from 'primevue/toggleswitch' import { beforeEach, describe, expect, it, vi } from 'vitest' @@ -81,7 +81,7 @@ describe('PackEnableToggle', () => { ...props }, global: { - plugins: [PrimeVue, createPinia(), i18n] + plugins: [PrimeVue, createTestingPinia({ stubActions: false }), i18n] } }) } diff --git a/src/workbench/extensions/manager/components/manager/packCard/PackCardFooter.test.ts b/src/workbench/extensions/manager/components/manager/packCard/PackCardFooter.test.ts index 950f8f647..9f6e1d5a6 100644 --- a/src/workbench/extensions/manager/components/manager/packCard/PackCardFooter.test.ts +++ b/src/workbench/extensions/manager/components/manager/packCard/PackCardFooter.test.ts @@ -1,6 +1,6 @@ import type { VueWrapper } from '@vue/test-utils' import { mount } from '@vue/test-utils' -import { createPinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' import PrimeVue from 'primevue/config' import { beforeEach, describe, expect, it, vi } from 'vitest' import { ref } from 'vue' @@ -73,7 +73,7 @@ describe('PackCardFooter', () => { ...props }, global: { - plugins: [PrimeVue, createPinia(), i18n], + plugins: [PrimeVue, createTestingPinia({ stubActions: false }), i18n], provide: { [IsInstallingKey]: ref(false) } diff --git a/src/workbench/extensions/manager/components/manager/skeleton/PackCardGridSkeleton.test.ts b/src/workbench/extensions/manager/components/manager/skeleton/PackCardGridSkeleton.test.ts index 1df7162d9..3a48d7eab 100644 --- a/src/workbench/extensions/manager/components/manager/skeleton/PackCardGridSkeleton.test.ts +++ b/src/workbench/extensions/manager/components/manager/skeleton/PackCardGridSkeleton.test.ts @@ -1,6 +1,6 @@ import type { VueWrapper } from '@vue/test-utils' import { mount } from '@vue/test-utils' -import { createPinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' import PrimeVue from 'primevue/config' import { describe, expect, it } from 'vitest' import { nextTick } from 'vue' @@ -32,7 +32,7 @@ describe('GridSkeleton', () => { ...props }, global: { - plugins: [PrimeVue, createPinia(), i18n], + plugins: [PrimeVue, createTestingPinia({ stubActions: false }), i18n], stubs: { PackCardSkeleton: true } diff --git a/src/workbench/extensions/manager/composables/nodePack/usePacksSelection.test.ts b/src/workbench/extensions/manager/composables/nodePack/usePacksSelection.test.ts index c38fc9c33..3a17a1ba1 100644 --- a/src/workbench/extensions/manager/composables/nodePack/usePacksSelection.test.ts +++ b/src/workbench/extensions/manager/composables/nodePack/usePacksSelection.test.ts @@ -1,4 +1,5 @@ -import { createPinia, setActivePinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' +import { setActivePinia } from 'pinia' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import { ref } from 'vue' @@ -36,7 +37,7 @@ describe('usePacksSelection', () => { beforeEach(() => { vi.clearAllMocks() - const pinia = createPinia() + const pinia = createTestingPinia({ stubActions: false }) setActivePinia(pinia) managerStore = useComfyManagerStore() diff --git a/src/workbench/extensions/manager/composables/nodePack/usePacksStatus.test.ts b/src/workbench/extensions/manager/composables/nodePack/usePacksStatus.test.ts index 2fbabb3fb..5977196ce 100644 --- a/src/workbench/extensions/manager/composables/nodePack/usePacksStatus.test.ts +++ b/src/workbench/extensions/manager/composables/nodePack/usePacksStatus.test.ts @@ -1,4 +1,5 @@ -import { createPinia, setActivePinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' +import { setActivePinia } from 'pinia' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import { ref } from 'vue' @@ -48,7 +49,7 @@ describe('usePacksStatus', () => { beforeEach(() => { vi.clearAllMocks() - setActivePinia(createPinia()) + setActivePinia(createTestingPinia({ stubActions: false })) conflictDetectionStore = useConflictDetectionStore() }) diff --git a/src/workbench/extensions/manager/composables/useConflictAcknowledgment.test.ts b/src/workbench/extensions/manager/composables/useConflictAcknowledgment.test.ts index 43f25da9e..dbd7a5f25 100644 --- a/src/workbench/extensions/manager/composables/useConflictAcknowledgment.test.ts +++ b/src/workbench/extensions/manager/composables/useConflictAcknowledgment.test.ts @@ -1,10 +1,11 @@ -import { createPinia, setActivePinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' +import { setActivePinia } from 'pinia' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' describe('useConflictAcknowledgment', () => { beforeEach(() => { // Set up Pinia for each test - setActivePinia(createPinia()) + setActivePinia(createTestingPinia({ stubActions: false })) // Clear localStorage before each test localStorage.clear() // Reset modules to ensure fresh state diff --git a/src/workbench/extensions/manager/composables/useConflictDetection.test.ts b/src/workbench/extensions/manager/composables/useConflictDetection.test.ts index 28fa8302c..46aec9d2c 100644 --- a/src/workbench/extensions/manager/composables/useConflictDetection.test.ts +++ b/src/workbench/extensions/manager/composables/useConflictDetection.test.ts @@ -1,4 +1,5 @@ -import { createPinia, setActivePinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' +import { setActivePinia } from 'pinia' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import { computed, ref } from 'vue' @@ -114,7 +115,7 @@ vi.mock('@/workbench/extensions/manager/composables/useManagerState', () => ({ })) describe('useConflictDetection', () => { - let pinia: ReturnType + let pinia: ReturnType const mockComfyManagerService = { getImportFailInfoBulk: vi.fn(), @@ -221,7 +222,7 @@ describe('useConflictDetection', () => { beforeEach(() => { vi.clearAllMocks() - pinia = createPinia() + pinia = createTestingPinia({ stubActions: false }) setActivePinia(pinia) // Setup mocks diff --git a/src/workbench/extensions/manager/composables/useImportFailedDetection.test.ts b/src/workbench/extensions/manager/composables/useImportFailedDetection.test.ts index d548af8da..83944f4f8 100644 --- a/src/workbench/extensions/manager/composables/useImportFailedDetection.test.ts +++ b/src/workbench/extensions/manager/composables/useImportFailedDetection.test.ts @@ -1,4 +1,5 @@ -import { createPinia, setActivePinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' +import { setActivePinia } from 'pinia' import { beforeEach, describe, expect, it, vi } from 'vitest' import { computed, ref } from 'vue' @@ -31,7 +32,7 @@ describe('useImportFailedDetection', () => { let mockDialogService: ReturnType beforeEach(() => { - setActivePinia(createPinia()) + setActivePinia(createTestingPinia({ stubActions: false })) mockComfyManagerStore = { isPackInstalled: vi.fn() diff --git a/src/workbench/extensions/manager/stores/comfyManagerStore.test.ts b/src/workbench/extensions/manager/stores/comfyManagerStore.test.ts index d1754d59a..8509d8c3a 100644 --- a/src/workbench/extensions/manager/stores/comfyManagerStore.test.ts +++ b/src/workbench/extensions/manager/stores/comfyManagerStore.test.ts @@ -1,4 +1,5 @@ -import { createPinia, setActivePinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' +import { setActivePinia } from 'pinia' import { beforeEach, describe, expect, it, vi } from 'vitest' import { nextTick, ref } from 'vue' @@ -72,7 +73,7 @@ describe('useComfyManagerStore', () => { } beforeEach(() => { - setActivePinia(createPinia()) + setActivePinia(createTestingPinia({ stubActions: false })) vi.clearAllMocks() mockManagerService = { isLoading: ref(false), diff --git a/src/workbench/extensions/manager/stores/conflictDetectionStore.test.ts b/src/workbench/extensions/manager/stores/conflictDetectionStore.test.ts index 7c74ea6c1..0b5c1e0e1 100644 --- a/src/workbench/extensions/manager/stores/conflictDetectionStore.test.ts +++ b/src/workbench/extensions/manager/stores/conflictDetectionStore.test.ts @@ -1,4 +1,5 @@ -import { createPinia, setActivePinia } from 'pinia' +import { createTestingPinia } from '@pinia/testing' +import { setActivePinia } from 'pinia' import { beforeEach, describe, expect, it } from 'vitest' import { useConflictDetectionStore } from '@/workbench/extensions/manager/stores/conflictDetectionStore' @@ -6,7 +7,7 @@ import type { ConflictDetectionResult } from '@/workbench/extensions/manager/typ describe('useConflictDetectionStore', () => { beforeEach(() => { - setActivePinia(createPinia()) + setActivePinia(createTestingPinia({ stubActions: false })) }) const mockConflictedPackages: ConflictDetectionResult[] = [