Skip to content

Commit 05451f2

Browse files
committed
fix tests
1 parent 9192769 commit 05451f2

File tree

3 files changed

+72
-13
lines changed

3 files changed

+72
-13
lines changed

apps/sim/executor/utils/block-data.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ function getInputFormatFields(block: SerializedBlock): OutputSchema {
3535

3636
const schema: OutputSchema = {}
3737
for (const field of inputFormat) {
38-
schema[field.name!] = {
38+
if (!field.name) continue
39+
schema[field.name] = {
3940
type: (field.type || 'any') as 'string' | 'number' | 'boolean' | 'object' | 'array' | 'any',
4041
}
4142
}

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

Lines changed: 65 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,8 @@ describe('hasWorkflowChanged', () => {
557557
})
558558

559559
describe('InputFormat SubBlock Special Handling', () => {
560-
it.concurrent('should ignore value and collapsed fields in inputFormat', () => {
560+
it.concurrent('should ignore collapsed field but detect value changes in inputFormat', () => {
561+
// Only collapsed changes - should NOT detect as change
561562
const state1 = createWorkflowState({
562563
blocks: {
563564
block1: createBlock('block1', {
@@ -578,8 +579,8 @@ describe('hasWorkflowChanged', () => {
578579
subBlocks: {
579580
inputFormat: {
580581
value: [
581-
{ id: 'input1', name: 'Name', value: 'Jane', collapsed: false },
582-
{ id: 'input2', name: 'Age', value: 30, collapsed: true },
582+
{ id: 'input1', name: 'Name', value: 'John', collapsed: false },
583+
{ id: 'input2', name: 'Age', value: 25, collapsed: true },
583584
],
584585
},
585586
},
@@ -589,6 +590,32 @@ describe('hasWorkflowChanged', () => {
589590
expect(hasWorkflowChanged(state1, state2)).toBe(false)
590591
})
591592

593+
it.concurrent('should detect value changes in inputFormat', () => {
594+
const state1 = createWorkflowState({
595+
blocks: {
596+
block1: createBlock('block1', {
597+
subBlocks: {
598+
inputFormat: {
599+
value: [{ id: 'input1', name: 'Name', value: 'John' }],
600+
},
601+
},
602+
}),
603+
},
604+
})
605+
const state2 = createWorkflowState({
606+
blocks: {
607+
block1: createBlock('block1', {
608+
subBlocks: {
609+
inputFormat: {
610+
value: [{ id: 'input1', name: 'Name', value: 'Jane' }],
611+
},
612+
},
613+
}),
614+
},
615+
})
616+
expect(hasWorkflowChanged(state1, state2)).toBe(true)
617+
})
618+
592619
it.concurrent('should detect actual inputFormat changes', () => {
593620
const state1 = createWorkflowState({
594621
blocks: {
@@ -1712,15 +1739,15 @@ describe('hasWorkflowChanged', () => {
17121739
})
17131740

17141741
describe('Input Format Field Scenarios', () => {
1715-
it.concurrent('should not detect change when inputFormat value is typed and cleared', () => {
1716-
// The "value" field in inputFormat is UI-only and should be ignored
1742+
it.concurrent('should not detect change when only inputFormat collapsed changes', () => {
1743+
// The "collapsed" field in inputFormat is UI-only and should be ignored
17171744
const deployedState = createWorkflowState({
17181745
blocks: {
17191746
block1: createBlock('block1', {
17201747
subBlocks: {
17211748
inputFormat: {
17221749
value: [
1723-
{ id: 'field1', name: 'Name', type: 'string', value: '', collapsed: false },
1750+
{ id: 'field1', name: 'Name', type: 'string', value: 'test', collapsed: false },
17241751
],
17251752
},
17261753
},
@@ -1738,7 +1765,7 @@ describe('hasWorkflowChanged', () => {
17381765
id: 'field1',
17391766
name: 'Name',
17401767
type: 'string',
1741-
value: 'typed then cleared',
1768+
value: 'test',
17421769
collapsed: true,
17431770
},
17441771
],
@@ -1748,10 +1775,40 @@ describe('hasWorkflowChanged', () => {
17481775
},
17491776
})
17501777

1751-
// value and collapsed are UI-only fields - should NOT detect as change
1778+
// collapsed is UI-only field - should NOT detect as change
17521779
expect(hasWorkflowChanged(currentState, deployedState)).toBe(false)
17531780
})
17541781

1782+
it.concurrent('should detect change when inputFormat value changes', () => {
1783+
// The "value" field in inputFormat is meaningful and should trigger change detection
1784+
const deployedState = createWorkflowState({
1785+
blocks: {
1786+
block1: createBlock('block1', {
1787+
subBlocks: {
1788+
inputFormat: {
1789+
value: [{ id: 'field1', name: 'Name', type: 'string', value: '' }],
1790+
},
1791+
},
1792+
}),
1793+
},
1794+
})
1795+
1796+
const currentState = createWorkflowState({
1797+
blocks: {
1798+
block1: createBlock('block1', {
1799+
subBlocks: {
1800+
inputFormat: {
1801+
value: [{ id: 'field1', name: 'Name', type: 'string', value: 'new value' }],
1802+
},
1803+
},
1804+
}),
1805+
},
1806+
})
1807+
1808+
// value changes should be detected
1809+
expect(hasWorkflowChanged(currentState, deployedState)).toBe(true)
1810+
})
1811+
17551812
it.concurrent('should detect change when inputFormat field name changes', () => {
17561813
const deployedState = createWorkflowState({
17571814
blocks: {

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ describe('Workflow Normalization Utilities', () => {
370370
expect(sanitizeInputFormat({} as any)).toEqual([])
371371
})
372372

373-
it.concurrent('should remove value and collapsed fields', () => {
373+
it.concurrent('should remove collapsed field but keep value', () => {
374374
const inputFormat = [
375375
{ id: 'input1', name: 'Name', value: 'John', collapsed: true },
376376
{ id: 'input2', name: 'Age', value: 25, collapsed: false },
@@ -379,13 +379,13 @@ describe('Workflow Normalization Utilities', () => {
379379
const result = sanitizeInputFormat(inputFormat)
380380

381381
expect(result).toEqual([
382-
{ id: 'input1', name: 'Name' },
383-
{ id: 'input2', name: 'Age' },
382+
{ id: 'input1', name: 'Name', value: 'John' },
383+
{ id: 'input2', name: 'Age', value: 25 },
384384
{ id: 'input3', name: 'Email' },
385385
])
386386
})
387387

388-
it.concurrent('should preserve all other fields', () => {
388+
it.concurrent('should preserve all other fields including value', () => {
389389
const inputFormat = [
390390
{
391391
id: 'input1',
@@ -402,6 +402,7 @@ describe('Workflow Normalization Utilities', () => {
402402
expect(result[0]).toEqual({
403403
id: 'input1',
404404
name: 'Complex Input',
405+
value: 'test-value',
405406
type: 'string',
406407
required: true,
407408
validation: { min: 0, max: 100 },

0 commit comments

Comments
 (0)