Skip to content

Commit 10bd455

Browse files
committed
fix(tables): remove any types, clean up test variable assignments
1 parent 3f937bc commit 10bd455

File tree

3 files changed

+97
-107
lines changed

3 files changed

+97
-107
lines changed

apps/sim/app/api/schedules/execute/route.test.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
*
44
* @vitest-environment node
55
*/
6+
67
import { createFeatureFlagsMock, createMockRequest } from '@sim/testing'
78
import { drizzleOrmMock } from '@sim/testing/mocks'
9+
import type { NextRequest } from 'next/server'
810
import { beforeEach, describe, expect, it, vi } from 'vitest'
911

1012
const {
@@ -190,7 +192,7 @@ describe('Scheduled Workflow Execution API Route', () => {
190192
it('should execute scheduled workflows with Trigger.dev disabled', async () => {
191193
mockDbReturning.mockReturnValueOnce(SINGLE_SCHEDULE).mockReturnValueOnce([])
192194

193-
const response = await GET(createCronRequest() as any)
195+
const response = await GET(createCronRequest() as unknown as NextRequest)
194196

195197
expect(response).toBeDefined()
196198
expect(response.status).toBe(200)
@@ -203,7 +205,7 @@ describe('Scheduled Workflow Execution API Route', () => {
203205
mockFeatureFlags.isTriggerDevEnabled = true
204206
mockDbReturning.mockReturnValueOnce(SINGLE_SCHEDULE).mockReturnValueOnce([])
205207

206-
const response = await GET(createCronRequest() as any)
208+
const response = await GET(createCronRequest() as unknown as NextRequest)
207209

208210
expect(response).toBeDefined()
209211
expect(response.status).toBe(200)
@@ -214,7 +216,7 @@ describe('Scheduled Workflow Execution API Route', () => {
214216
it('should handle case with no due schedules', async () => {
215217
mockDbReturning.mockReturnValueOnce([]).mockReturnValueOnce([])
216218

217-
const response = await GET(createCronRequest() as any)
219+
const response = await GET(createCronRequest() as unknown as NextRequest)
218220

219221
expect(response.status).toBe(200)
220222
const data = await response.json()
@@ -225,7 +227,7 @@ describe('Scheduled Workflow Execution API Route', () => {
225227
it('should execute multiple schedules in parallel', async () => {
226228
mockDbReturning.mockReturnValueOnce(MULTIPLE_SCHEDULES).mockReturnValueOnce([])
227229

228-
const response = await GET(createCronRequest() as any)
230+
const response = await GET(createCronRequest() as unknown as NextRequest)
229231

230232
expect(response.status).toBe(200)
231233
const data = await response.json()
@@ -235,7 +237,7 @@ describe('Scheduled Workflow Execution API Route', () => {
235237
it('should queue mothership jobs to BullMQ when available', async () => {
236238
mockDbReturning.mockReturnValueOnce([]).mockReturnValueOnce(SINGLE_JOB)
237239

238-
const response = await GET(createCronRequest() as any)
240+
const response = await GET(createCronRequest() as unknown as NextRequest)
239241

240242
expect(response.status).toBe(200)
241243
expect(mockEnqueueWorkspaceDispatch).toHaveBeenCalledWith(
@@ -260,7 +262,7 @@ describe('Scheduled Workflow Execution API Route', () => {
260262
it('should enqueue preassigned correlation metadata for schedules', async () => {
261263
mockDbReturning.mockReturnValue(SINGLE_SCHEDULE)
262264

263-
const response = await GET(createCronRequest() as any)
265+
const response = await GET(createCronRequest() as unknown as NextRequest)
264266

265267
expect(response.status).toBe(200)
266268
expect(mockEnqueueWorkspaceDispatch).toHaveBeenCalledWith(

apps/sim/lib/workflows/comparison/compare.test.ts

Lines changed: 80 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/**
22
* Tests for workflow change detection comparison logic
33
*/
4+
5+
import type { WorkflowVariableFixture } from '@sim/testing'
46
import {
57
createBlock as createTestBlock,
68
createWorkflowState as createTestWorkflowState,
@@ -47,7 +49,9 @@ function createBlock(id: string, overrides: Record<string, any> = {}): any {
4749
})
4850
}
4951

50-
function createVariablesMap(...variables: Parameters<typeof createWorkflowVariablesMap>[0]): any {
52+
function createVariablesMap(
53+
...variables: Parameters<typeof createWorkflowVariablesMap>[0]
54+
): Record<string, WorkflowVariableFixture> {
5155
return createWorkflowVariablesMap(variables)
5256
}
5357

@@ -2871,159 +2875,135 @@ describe('hasWorkflowChanged', () => {
28712875
describe('Variables (UI-only fields should not trigger change)', () => {
28722876
it.concurrent('should not detect change when validationError differs', () => {
28732877
const deployedState = createWorkflowState({
2874-
blocks: {
2875-
block1: createBlock('block1'),
2876-
},
2877-
})
2878-
;(deployedState as any).variables = createVariablesMap({
2879-
id: 'var1',
2880-
workflowId: 'workflow1',
2881-
name: 'myVar',
2882-
type: 'plain',
2883-
value: 'test',
2878+
blocks: { block1: createBlock('block1') },
2879+
variables: createVariablesMap({
2880+
id: 'var1',
2881+
workflowId: 'workflow1',
2882+
name: 'myVar',
2883+
type: 'plain',
2884+
value: 'test',
2885+
}),
28842886
})
28852887

28862888
const currentState = createWorkflowState({
2887-
blocks: {
2888-
block1: createBlock('block1'),
2889-
},
2890-
})
2891-
;(currentState as any).variables = createVariablesMap({
2892-
id: 'var1',
2893-
workflowId: 'workflow1',
2894-
name: 'myVar',
2895-
type: 'plain',
2896-
value: 'test',
2897-
validationError: undefined,
2889+
blocks: { block1: createBlock('block1') },
2890+
variables: createVariablesMap({
2891+
id: 'var1',
2892+
workflowId: 'workflow1',
2893+
name: 'myVar',
2894+
type: 'plain',
2895+
value: 'test',
2896+
validationError: undefined,
2897+
}),
28982898
})
28992899

29002900
expect(hasWorkflowChanged(currentState, deployedState)).toBe(false)
29012901
})
29022902

29032903
it.concurrent('should not detect change when validationError has value vs missing', () => {
29042904
const deployedState = createWorkflowState({
2905-
blocks: {
2906-
block1: createBlock('block1'),
2907-
},
2908-
})
2909-
;(deployedState as any).variables = createVariablesMap({
2910-
id: 'var1',
2911-
workflowId: 'workflow1',
2912-
name: 'myVar',
2913-
type: 'number',
2914-
value: 'invalid',
2905+
blocks: { block1: createBlock('block1') },
2906+
variables: createVariablesMap({
2907+
id: 'var1',
2908+
workflowId: 'workflow1',
2909+
name: 'myVar',
2910+
type: 'number',
2911+
value: 'invalid',
2912+
}),
29152913
})
29162914

29172915
const currentState = createWorkflowState({
2918-
blocks: {
2919-
block1: createBlock('block1'),
2920-
},
2921-
})
2922-
;(currentState as any).variables = createVariablesMap({
2923-
id: 'var1',
2924-
workflowId: 'workflow1',
2925-
name: 'myVar',
2926-
type: 'number',
2927-
value: 'invalid',
2928-
validationError: 'Not a valid number',
2916+
blocks: { block1: createBlock('block1') },
2917+
variables: createVariablesMap({
2918+
id: 'var1',
2919+
workflowId: 'workflow1',
2920+
name: 'myVar',
2921+
type: 'number',
2922+
value: 'invalid',
2923+
validationError: 'Not a valid number',
2924+
}),
29292925
})
29302926

29312927
expect(hasWorkflowChanged(currentState, deployedState)).toBe(false)
29322928
})
29332929

29342930
it.concurrent('should detect change when variable value differs', () => {
29352931
const deployedState = createWorkflowState({
2936-
blocks: {
2937-
block1: createBlock('block1'),
2938-
},
2939-
})
2940-
;(deployedState as any).variables = createVariablesMap({
2941-
id: 'var1',
2942-
workflowId: 'workflow1',
2943-
name: 'myVar',
2944-
type: 'plain',
2945-
value: 'old value',
2932+
blocks: { block1: createBlock('block1') },
2933+
variables: createVariablesMap({
2934+
id: 'var1',
2935+
workflowId: 'workflow1',
2936+
name: 'myVar',
2937+
type: 'plain',
2938+
value: 'old value',
2939+
}),
29462940
})
29472941

29482942
const currentState = createWorkflowState({
2949-
blocks: {
2950-
block1: createBlock('block1'),
2951-
},
2952-
})
2953-
;(currentState as any).variables = createVariablesMap({
2954-
id: 'var1',
2955-
workflowId: 'workflow1',
2956-
name: 'myVar',
2957-
type: 'plain',
2958-
value: 'new value',
2959-
validationError: undefined,
2943+
blocks: { block1: createBlock('block1') },
2944+
variables: createVariablesMap({
2945+
id: 'var1',
2946+
workflowId: 'workflow1',
2947+
name: 'myVar',
2948+
type: 'plain',
2949+
value: 'new value',
2950+
}),
29602951
})
29612952

29622953
expect(hasWorkflowChanged(currentState, deployedState)).toBe(true)
29632954
})
29642955

29652956
it.concurrent('should detect change when variable is added', () => {
29662957
const deployedState = createWorkflowState({
2967-
blocks: {
2968-
block1: createBlock('block1'),
2969-
},
2958+
blocks: { block1: createBlock('block1') },
2959+
variables: {},
29702960
})
2971-
;(deployedState as any).variables = {}
29722961

29732962
const currentState = createWorkflowState({
2974-
blocks: {
2975-
block1: createBlock('block1'),
2976-
},
2977-
})
2978-
;(currentState as any).variables = createVariablesMap({
2979-
id: 'var1',
2980-
workflowId: 'workflow1',
2981-
name: 'myVar',
2982-
type: 'plain',
2983-
value: 'test',
2963+
blocks: { block1: createBlock('block1') },
2964+
variables: createVariablesMap({
2965+
id: 'var1',
2966+
workflowId: 'workflow1',
2967+
name: 'myVar',
2968+
type: 'plain',
2969+
value: 'test',
2970+
}),
29842971
})
29852972

29862973
expect(hasWorkflowChanged(currentState, deployedState)).toBe(true)
29872974
})
29882975

29892976
it.concurrent('should detect change when variable is removed', () => {
29902977
const deployedState = createWorkflowState({
2991-
blocks: {
2992-
block1: createBlock('block1'),
2993-
},
2994-
})
2995-
;(deployedState as any).variables = createVariablesMap({
2996-
id: 'var1',
2997-
workflowId: 'workflow1',
2998-
name: 'myVar',
2999-
type: 'plain',
3000-
value: 'test',
2978+
blocks: { block1: createBlock('block1') },
2979+
variables: createVariablesMap({
2980+
id: 'var1',
2981+
workflowId: 'workflow1',
2982+
name: 'myVar',
2983+
type: 'plain',
2984+
value: 'test',
2985+
}),
30012986
})
30022987

30032988
const currentState = createWorkflowState({
3004-
blocks: {
3005-
block1: createBlock('block1'),
3006-
},
2989+
blocks: { block1: createBlock('block1') },
2990+
variables: {},
30072991
})
3008-
;(currentState as any).variables = {}
30092992

30102993
expect(hasWorkflowChanged(currentState, deployedState)).toBe(true)
30112994
})
30122995

30132996
it.concurrent('should not detect change when empty array vs empty object', () => {
30142997
const deployedState = createWorkflowState({
3015-
blocks: {
3016-
block1: createBlock('block1'),
3017-
},
2998+
blocks: { block1: createBlock('block1') },
30182999
})
3019-
;(deployedState as any).variables = []
3000+
// Intentional type violation to test robustness with malformed data
3001+
;(deployedState as unknown as Record<string, unknown>).variables = []
30203002

30213003
const currentState = createWorkflowState({
3022-
blocks: {
3023-
block1: createBlock('block1'),
3024-
},
3004+
blocks: { block1: createBlock('block1') },
3005+
variables: {},
30253006
})
3026-
;(currentState as any).variables = {}
30273007

30283008
expect(hasWorkflowChanged(currentState, deployedState)).toBe(false)
30293009
})

packages/testing/src/mocks/edit-workflow.mock.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
const editWorkflowBlockConfigs: Record<string, any> = {
1+
const editWorkflowBlockConfigs: Record<
2+
string,
3+
{
4+
type: string
5+
name: string
6+
outputs: Record<string, unknown>
7+
subBlocks: { id: string; type: string }[]
8+
}
9+
> = {
210
condition: {
311
type: 'condition',
412
name: 'Condition',

0 commit comments

Comments
 (0)