Skip to content

Commit 0fc8baa

Browse files
committed
added tests
1 parent 8de7231 commit 0fc8baa

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

apps/sim/providers/utils.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,29 @@ describe('prepareToolExecution', () => {
11571157
expect(toolParams.channel).toBe('#general') // User value wins
11581158
expect(toolParams.message).toBe('Hello')
11591159
})
1160+
1161+
it.concurrent('should preserve 0 and false as valid user values in inputMapping', () => {
1162+
const tool = {
1163+
params: {
1164+
workflowId: 'child-workflow',
1165+
inputMapping: '{"limit": 0, "enabled": false, "query": ""}',
1166+
},
1167+
}
1168+
const llmArgs = {
1169+
inputMapping: { limit: 10, enabled: true, query: 'llm-search' },
1170+
}
1171+
const request = {}
1172+
1173+
const { toolParams } = prepareToolExecution(tool, llmArgs, request)
1174+
1175+
// 0 and false should be preserved (they're valid values)
1176+
// empty string should be filled by LLM
1177+
expect(toolParams.inputMapping).toEqual({
1178+
limit: 0,
1179+
enabled: false,
1180+
query: 'llm-search',
1181+
})
1182+
})
11601183
})
11611184

11621185
describe('execution params context', () => {

apps/sim/tools/params.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,26 @@ describe('Tool Parameters Utils', () => {
520520
expect(merged.channel).toBe('#general')
521521
expect(merged.message).toBe('Hello world')
522522
})
523+
524+
it.concurrent('should preserve 0 and false as valid user values in inputMapping', () => {
525+
const userProvided = {
526+
workflowId: 'workflow-123',
527+
inputMapping: '{"limit": 0, "enabled": false, "query": ""}',
528+
}
529+
const llmGenerated = {
530+
inputMapping: { limit: 10, enabled: true, query: 'llm-search' },
531+
}
532+
533+
const merged = mergeToolParameters(userProvided, llmGenerated)
534+
535+
// 0 and false should be preserved (they're valid values)
536+
// empty string should be filled by LLM
537+
expect(merged.inputMapping).toEqual({
538+
limit: 0,
539+
enabled: false,
540+
query: 'llm-search',
541+
})
542+
})
523543
})
524544
})
525545

0 commit comments

Comments
 (0)