Skip to content

Commit 3b57fa8

Browse files
committed
test: provide a testing Pinia by default
Amp-Thread-ID: https://ampcode.com/threads/T-019feeff-305b-73a5-bb82-3ae3a74e816d
1 parent bb573d8 commit 3b57fa8

137 files changed

Lines changed: 49 additions & 713 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/desktop-ui/src/stores/maintenanceTaskStore.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import { createTestingPinia } from '@pinia/testing'
21
import type { InstallValidation } from '@comfyorg/comfyui-electron-types'
3-
import { setActivePinia } from 'pinia'
42
import { beforeEach, describe, expect, it, vi } from 'vitest'
53

64
const { mockElectron, testTasks } = vi.hoisted(() => {
@@ -55,7 +53,6 @@ function makeUpdate(
5553
}
5654

5755
function createStore() {
58-
setActivePinia(createTestingPinia({ stubActions: false }))
5956
return useMaintenanceTaskStore()
6057
}
6158

apps/desktop-ui/src/test/setup.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
11
import '@testing-library/jest-dom/vitest'
2+
import { createTestingPinia } from '@pinia/testing'
3+
import { setActivePinia } from 'pinia'
4+
import { beforeEach } from 'vitest'
5+
6+
beforeEach(() => {
7+
setActivePinia(createTestingPinia({ stubActions: false }))
8+
})

src/components/builder/useResolvedSelectedInputs.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import { createTestingPinia } from '@pinia/testing'
21
import { fromAny, fromPartial } from '@total-typescript/shoehorn'
3-
import { setActivePinia } from 'pinia'
42
import { beforeEach, describe, expect, it, vi } from 'vitest'
53

64
import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode'
@@ -61,7 +59,6 @@ function dispatchRootGraphEvent(type: string) {
6159

6260
describe('useResolvedSelectedInputs', () => {
6361
beforeEach(() => {
64-
setActivePinia(createTestingPinia({ stubActions: false }))
6562
setRootGraphNodes([])
6663
})
6764

src/components/dialog/GlobalDialog.test.ts

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import { createTestingPinia } from '@pinia/testing'
21
import { cleanup, render, screen, waitFor } from '@testing-library/vue'
32
import userEvent from '@testing-library/user-event'
4-
import { setActivePinia } from 'pinia'
53
import PrimeVue from 'primevue/config'
6-
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
4+
import { afterEach, describe, expect, it, vi } from 'vitest'
75
import { defineComponent, h, nextTick } from 'vue'
86
import { createI18n } from 'vue-i18n'
97

@@ -105,10 +103,6 @@ function mountDialog() {
105103
}
106104

107105
describe('GlobalDialog renderer branching', () => {
108-
beforeEach(() => {
109-
setActivePinia(createTestingPinia({ stubActions: false }))
110-
})
111-
112106
afterEach(() => {
113107
cleanup()
114108
})
@@ -177,10 +171,6 @@ describe('GlobalDialog renderer branching', () => {
177171
})
178172

179173
describe('GlobalDialog Reka parity with PrimeVue', () => {
180-
beforeEach(() => {
181-
setActivePinia(createTestingPinia({ stubActions: false }))
182-
})
183-
184174
afterEach(() => {
185175
cleanup()
186176
})
@@ -368,10 +358,6 @@ describe('GlobalDialog Reka parity with PrimeVue', () => {
368358
})
369359

370360
describe('GlobalDialog Reka overlay scrim', () => {
371-
beforeEach(() => {
372-
setActivePinia(createTestingPinia({ stubActions: false }))
373-
})
374-
375361
afterEach(() => {
376362
cleanup()
377363
})
@@ -490,10 +476,6 @@ describe('GlobalDialog Reka overlay scrim', () => {
490476
})
491477

492478
describe('GlobalDialog Reka focus-outside binding', () => {
493-
beforeEach(() => {
494-
setActivePinia(createTestingPinia({ stubActions: false }))
495-
})
496-
497479
afterEach(() => {
498480
cleanup()
499481
})

src/components/graph/DomWidgets.test.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import { createTestingPinia } from '@pinia/testing'
21
import { fromPartial } from '@total-typescript/shoehorn'
32
import { render } from '@testing-library/vue'
4-
import { setActivePinia } from 'pinia'
5-
import { beforeEach, describe, expect, it, vi } from 'vitest'
3+
import { describe, expect, it, vi } from 'vitest'
64

75
import DomWidgets from '@/components/graph/DomWidgets.vue'
86
import { Rectangle } from '@/lib/litegraph/src/infrastructure/Rectangle'
@@ -59,10 +57,6 @@ function drawFrame(canvas: LGraphCanvas) {
5957
}
6058

6159
describe('DomWidgets positioning', () => {
62-
beforeEach(() => {
63-
setActivePinia(createTestingPinia({ stubActions: false }))
64-
})
65-
6660
it('positions an active visible widget relative to its owning node', () => {
6761
const canvasStore = useCanvasStore()
6862
const domWidgetStore = useDomWidgetStore()

src/components/graph/NodeTooltip.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { cleanup, render, screen } from '@testing-library/vue'
22
import userEvent from '@testing-library/user-event'
3-
import { createTestingPinia } from '@pinia/testing'
4-
import { setActivePinia } from 'pinia'
53
import { nextTick } from 'vue'
64
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
75

@@ -151,8 +149,6 @@ async function renderAndHoverCanvas() {
151149

152150
describe('NodeTooltip', () => {
153151
beforeEach(() => {
154-
setActivePinia(createTestingPinia({ stubActions: false }))
155-
156152
vi.spyOn(useSettingStore(), 'get').mockImplementation(
157153
<K extends keyof Settings>(key: K): Settings[K] => {
158154
switch (key) {

src/components/graph/widgets/DomWidget.test.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import { createTestingPinia } from '@pinia/testing'
21
import { render } from '@testing-library/vue'
32
import { fromPartial } from '@total-typescript/shoehorn'
4-
import { setActivePinia } from 'pinia'
5-
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
3+
import { afterEach, describe, expect, it, vi } from 'vitest'
64
import { nextTick, reactive } from 'vue'
75

86
import type { BaseDOMWidget } from '@/scripts/domWidget'
@@ -85,10 +83,6 @@ function createWidgetState(disabled: boolean): DomWidgetState {
8583
}
8684

8785
describe('DomWidget disabled style', () => {
88-
beforeEach(() => {
89-
setActivePinia(createTestingPinia({ stubActions: false }))
90-
})
91-
9286
afterEach(() => {
9387
useDomWidgetStore().clear()
9488
})

src/components/rightSidePanel/parameters/SectionWidgets.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import { createTestingPinia } from '@pinia/testing'
21
import { render, screen } from '@testing-library/vue'
32
import userEvent from '@testing-library/user-event'
4-
import { setActivePinia } from 'pinia'
53
import { beforeEach, describe, expect, it, vi } from 'vitest'
64
import { defineComponent } from 'vue'
75
import { createI18n } from 'vue-i18n'
@@ -137,7 +135,6 @@ function createHostWithPromotedModel(): {
137135

138136
describe('SectionWidgets', () => {
139137
beforeEach(() => {
140-
setActivePinia(createTestingPinia({ stubActions: false }))
141138
setDirty.mockClear()
142139
getNodeById.mockReset()
143140
animateToBounds.mockClear()

src/components/rightSidePanel/parameters/TabSubgraphInputs.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import { render } from '@testing-library/vue'
2-
import { createTestingPinia } from '@pinia/testing'
3-
import { setActivePinia } from 'pinia'
42
import { beforeEach, describe, expect, it, vi } from 'vitest'
53
import { createI18n } from 'vue-i18n'
64

@@ -78,7 +76,6 @@ function renderPanel(node: SubgraphNode) {
7876

7977
describe('TabSubgraphInputs', () => {
8078
beforeEach(() => {
81-
setActivePinia(createTestingPinia({ stubActions: false }))
8279
captured.rows = []
8380
})
8481

src/components/rightSidePanel/parameters/WidgetActions.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import { createTestingPinia } from '@pinia/testing'
21
import { render, screen } from '@testing-library/vue'
32
import userEvent from '@testing-library/user-event'
43
import { fromAny } from '@total-typescript/shoehorn'
5-
import { setActivePinia } from 'pinia'
64
import type { Slots } from 'vue'
75
import { h } from 'vue'
86
import { beforeEach, describe, expect, it, vi } from 'vitest'
@@ -88,7 +86,6 @@ const i18n = createI18n({
8886

8987
describe('WidgetActions', () => {
9088
beforeEach(() => {
91-
setActivePinia(createTestingPinia({ stubActions: false }))
9289
mockGetInputSpecForWidget.mockReturnValue({
9390
type: 'INT',
9491
default: 42

0 commit comments

Comments
 (0)