Skip to content

Commit a5a2e33

Browse files
committed
fix tests
1 parent 6cc5d1e commit a5a2e33

File tree

1 file changed

+44
-12
lines changed

1 file changed

+44
-12
lines changed

apps/sim/tools/workflow/executor.test.ts

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,42 @@ describe('workflowExecutorTool', () => {
1616
expect(result).toEqual({
1717
input: { firstName: 'John', lastName: 'Doe', age: 30 },
1818
triggerType: 'api',
19+
useDraftState: true,
20+
})
21+
})
22+
23+
it.concurrent('should use deployed state when isDeployedContext is true', () => {
24+
const params = {
25+
workflowId: 'test-workflow-id',
26+
inputMapping: { name: 'Test' },
27+
_context: { isDeployedContext: true },
28+
}
29+
30+
const result = buildBody(params)
31+
32+
expect(result).toEqual({
33+
input: { name: 'Test' },
34+
triggerType: 'api',
1935
useDraftState: false,
2036
})
2137
})
2238

39+
it.concurrent('should use draft state when isDeployedContext is false', () => {
40+
const params = {
41+
workflowId: 'test-workflow-id',
42+
inputMapping: { name: 'Test' },
43+
_context: { isDeployedContext: false },
44+
}
45+
46+
const result = buildBody(params)
47+
48+
expect(result).toEqual({
49+
input: { name: 'Test' },
50+
triggerType: 'api',
51+
useDraftState: true,
52+
})
53+
})
54+
2355
it.concurrent('should parse JSON string inputMapping (UI-provided via tool-input)', () => {
2456
const params = {
2557
workflowId: 'test-workflow-id',
@@ -31,7 +63,7 @@ describe('workflowExecutorTool', () => {
3163
expect(result).toEqual({
3264
input: { firstName: 'John', lastName: 'Doe' },
3365
triggerType: 'api',
34-
useDraftState: false,
66+
useDraftState: true,
3567
})
3668
})
3769

@@ -46,7 +78,7 @@ describe('workflowExecutorTool', () => {
4678
expect(result).toEqual({
4779
input: { user: { name: 'John', email: 'john@example.com' }, count: 5 },
4880
triggerType: 'api',
49-
useDraftState: false,
81+
useDraftState: true,
5082
})
5183
})
5284

@@ -61,7 +93,7 @@ describe('workflowExecutorTool', () => {
6193
expect(result).toEqual({
6294
input: { tags: ['a', 'b', 'c'], ids: [1, 2, 3] },
6395
triggerType: 'api',
64-
useDraftState: false,
96+
useDraftState: true,
6597
})
6698
})
6799

@@ -76,7 +108,7 @@ describe('workflowExecutorTool', () => {
76108
expect(result).toEqual({
77109
input: {},
78110
triggerType: 'api',
79-
useDraftState: false,
111+
useDraftState: true,
80112
})
81113
})
82114

@@ -91,7 +123,7 @@ describe('workflowExecutorTool', () => {
91123
expect(result).toEqual({
92124
input: {},
93125
triggerType: 'api',
94-
useDraftState: false,
126+
useDraftState: true,
95127
})
96128
})
97129

@@ -106,7 +138,7 @@ describe('workflowExecutorTool', () => {
106138
expect(result).toEqual({
107139
input: {},
108140
triggerType: 'api',
109-
useDraftState: false,
141+
useDraftState: true,
110142
})
111143
})
112144

@@ -121,7 +153,7 @@ describe('workflowExecutorTool', () => {
121153
expect(result).toEqual({
122154
input: {},
123155
triggerType: 'api',
124-
useDraftState: false,
156+
useDraftState: true,
125157
})
126158
})
127159

@@ -136,7 +168,7 @@ describe('workflowExecutorTool', () => {
136168
expect(result).toEqual({
137169
input: {},
138170
triggerType: 'api',
139-
useDraftState: false,
171+
useDraftState: true,
140172
})
141173
})
142174

@@ -151,7 +183,7 @@ describe('workflowExecutorTool', () => {
151183
expect(result).toEqual({
152184
input: {},
153185
triggerType: 'api',
154-
useDraftState: false,
186+
useDraftState: true,
155187
})
156188
})
157189

@@ -166,7 +198,7 @@ describe('workflowExecutorTool', () => {
166198
expect(result).toEqual({
167199
input: { message: 'Hello\nWorld', path: 'C:\\Users' },
168200
triggerType: 'api',
169-
useDraftState: false,
201+
useDraftState: true,
170202
})
171203
})
172204

@@ -181,7 +213,7 @@ describe('workflowExecutorTool', () => {
181213
expect(result).toEqual({
182214
input: { greeting: 'こんにちは', emoji: '👋' },
183215
triggerType: 'api',
184-
useDraftState: false,
216+
useDraftState: true,
185217
})
186218
})
187219

@@ -196,7 +228,7 @@ describe('workflowExecutorTool', () => {
196228
expect(result).toEqual({
197229
input: { data: '{"nested": "json"}' },
198230
triggerType: 'api',
199-
useDraftState: false,
231+
useDraftState: true,
200232
})
201233
})
202234
})

0 commit comments

Comments
 (0)