Skip to content

Commit 2e0ba75

Browse files
author
Connor Byrne
committed
test(first-run-tour): stop leaking queued jobs between tests
`acceptRun` wrote to a module-level holder that `beforeEach` never reset, so every test after the first ran with a job already accepted and the deadline suppressed rather than disarmed. Four tests asserting a reported run survives past the deadline passed only on that leak. The mock factories also ran on the first dynamic import — mid-test for whichever test ran first — and replaced each holder, discarding setup that test had already written. That made any isolated run read a null workflow and key-miss every status lookup, so `-t`, `.only` and sharding all failed. Verified: full file 54/54, and each affected test green on its own. Addresses review feedback: #15091 (comment)
1 parent 9dfd953 commit 2e0ba75

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

src/renderer/extensions/firstRunTour/tour/useFirstRunTourController.test.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,13 @@ vi.mock('@/composables/billing/useBillingContext', () => ({
4747
})
4848
}))
4949

50+
// Each factory runs on the first dynamic import, which lands mid-test for
51+
// whichever test runs first. Seed the new ref from the holder so that test's
52+
// setup survives instead of being discarded.
5053
vi.mock('@/stores/executionStore', async () => {
5154
const { shallowRef } = await import('vue')
52-
mocks.workflowStatus = shallowRef(new Map<unknown, string>())
53-
mocks.queuedJobs = shallowRef({} as Record<string, { workflow?: unknown }>)
55+
mocks.workflowStatus = shallowRef(new Map(mocks.workflowStatus.value))
56+
mocks.queuedJobs = shallowRef(mocks.queuedJobs.value)
5457
return {
5558
useExecutionStore: () => ({
5659
getWorkflowStatus: (workflow: unknown) =>
@@ -64,16 +67,13 @@ vi.mock('@/stores/executionStore', async () => {
6467

6568
vi.mock('@/stores/executionErrorStore', async () => {
6669
const { reactive } = await import('vue')
67-
mocks.executionErrors = reactive({
68-
hasNodeError: false,
69-
hasPromptError: false
70-
})
70+
mocks.executionErrors = reactive({ ...mocks.executionErrors })
7171
return { useExecutionErrorStore: () => mocks.executionErrors }
7272
})
7373

7474
vi.mock('@/platform/workflow/management/stores/workflowStore', async () => {
7575
const { shallowRef } = await import('vue')
76-
mocks.activeWorkflow = shallowRef(null as unknown)
76+
mocks.activeWorkflow = shallowRef(mocks.activeWorkflow.value)
7777
return {
7878
useWorkflowStore: () => ({
7979
get activeWorkflow() {
@@ -85,7 +85,7 @@ vi.mock('@/platform/workflow/management/stores/workflowStore', async () => {
8585

8686
vi.mock('@/renderer/core/canvas/canvasStore', async () => {
8787
const { shallowRef } = await import('vue')
88-
mocks.linearMode = shallowRef(false)
88+
mocks.linearMode = shallowRef(mocks.linearMode.value)
8989
return {
9090
useCanvasStore: () => ({
9191
get linearMode() {
@@ -242,6 +242,7 @@ describe('useFirstRunTourController', () => {
242242
beforeEach(() => {
243243
mocks.canRunWorkflows = ref(true)
244244
mocks.workflowStatus.value = new Map()
245+
mocks.queuedJobs.value = {}
245246
mocks.executionErrors.hasNodeError = false
246247
mocks.executionErrors.hasPromptError = false
247248
mocks.activeWorkflow.value = null

0 commit comments

Comments
 (0)