Skip to content

Commit 965e9ac

Browse files
author
test
committed
test(workflows): stabilize async route queue mocks
1 parent 5493e78 commit 965e9ac

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

apps/sim/app/api/workflows/[id]/execute/route.async.test.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@ const {
99
mockCheckHybridAuth,
1010
mockAuthorizeWorkflowByWorkspacePermission,
1111
mockPreprocessExecution,
12+
mockGetJobQueue,
13+
mockShouldExecuteInline,
1214
mockEnqueue,
1315
} = vi.hoisted(() => ({
1416
mockCheckHybridAuth: vi.fn(),
1517
mockAuthorizeWorkflowByWorkspacePermission: vi.fn(),
1618
mockPreprocessExecution: vi.fn(),
19+
mockGetJobQueue: vi.fn(),
20+
mockShouldExecuteInline: vi.fn(),
1721
mockEnqueue: vi.fn().mockResolvedValue('job-123'),
1822
}))
1923

@@ -37,13 +41,8 @@ vi.mock('@/lib/execution/preprocessing', () => ({
3741
}))
3842

3943
vi.mock('@/lib/core/async-jobs', () => ({
40-
getJobQueue: vi.fn().mockResolvedValue({
41-
enqueue: mockEnqueue,
42-
startJob: vi.fn(),
43-
completeJob: vi.fn(),
44-
markJobFailed: vi.fn(),
45-
}),
46-
shouldExecuteInline: vi.fn().mockReturnValue(false),
44+
getJobQueue: mockGetJobQueue,
45+
shouldExecuteInline: mockShouldExecuteInline,
4746
}))
4847

4948
vi.mock('@/lib/core/utils/request', () => ({
@@ -89,6 +88,15 @@ describe('workflow execute async route', () => {
8988
beforeEach(() => {
9089
vi.clearAllMocks()
9190

91+
mockEnqueue.mockResolvedValue('job-123')
92+
mockGetJobQueue.mockResolvedValue({
93+
enqueue: mockEnqueue,
94+
startJob: vi.fn(),
95+
completeJob: vi.fn(),
96+
markJobFailed: vi.fn(),
97+
})
98+
mockShouldExecuteInline.mockReturnValue(false)
99+
92100
mockCheckHybridAuth.mockResolvedValue({
93101
success: true,
94102
userId: 'session-user-1',

0 commit comments

Comments
 (0)