@@ -33,14 +33,14 @@ function createBlock(
3333}
3434
3535describe ( 'start-block utilities' , ( ) => {
36- it ( 'buildResolutionFromBlock returns null when metadata id missing' , ( ) => {
36+ it . concurrent ( 'buildResolutionFromBlock returns null when metadata id missing' , ( ) => {
3737 const block = createBlock ( 'api_trigger' )
3838 ; ( block . metadata as Record < string , unknown > ) . id = undefined
3939
4040 expect ( buildResolutionFromBlock ( block ) ) . toBeNull ( )
4141 } )
4242
43- it ( 'resolveExecutorStartBlock prefers unified start block' , ( ) => {
43+ it . concurrent ( 'resolveExecutorStartBlock prefers unified start block' , ( ) => {
4444 const blocks = [
4545 createBlock ( 'api_trigger' , 'api' ) ,
4646 createBlock ( 'starter' , 'starter' ) ,
@@ -56,7 +56,7 @@ describe('start-block utilities', () => {
5656 expect ( resolution ?. path ) . toBe ( StartBlockPath . UNIFIED )
5757 } )
5858
59- it ( 'buildStartBlockOutput normalizes unified start payload' , ( ) => {
59+ it . concurrent ( 'buildStartBlockOutput normalizes unified start payload' , ( ) => {
6060 const block = createBlock ( 'start_trigger' , 'start' )
6161 const resolution = {
6262 blockId : 'start' ,
@@ -67,15 +67,14 @@ describe('start-block utilities', () => {
6767 const output = buildStartBlockOutput ( {
6868 resolution,
6969 workflowInput : { payload : 'value' } ,
70- isDeployedExecution : true ,
7170 } )
7271
7372 expect ( output . payload ) . toBe ( 'value' )
7473 expect ( output . input ) . toBeUndefined ( )
7574 expect ( output . conversationId ) . toBeUndefined ( )
7675 } )
7776
78- it ( 'buildStartBlockOutput uses trigger schema for API triggers' , ( ) => {
77+ it . concurrent ( 'buildStartBlockOutput uses trigger schema for API triggers' , ( ) => {
7978 const apiBlock = createBlock ( 'api_trigger' , 'api' , {
8079 subBlocks : {
8180 inputFormat : {
@@ -113,11 +112,108 @@ describe('start-block utilities', () => {
113112 } ,
114113 files,
115114 } ,
116- isDeployedExecution : false ,
117115 } )
118116
119117 expect ( output . name ) . toBe ( 'Ada' )
120118 expect ( output . input ) . toEqual ( { name : 'Ada' , count : 5 } )
121119 expect ( output . files ) . toEqual ( files )
122120 } )
121+
122+ describe ( 'inputFormat default values' , ( ) => {
123+ it . concurrent ( 'uses default value when runtime does not provide the field' , ( ) => {
124+ const block = createBlock ( 'start_trigger' , 'start' , {
125+ subBlocks : {
126+ inputFormat : {
127+ value : [
128+ { name : 'input' , type : 'string' } ,
129+ { name : 'customField' , type : 'string' , value : 'defaultValue' } ,
130+ ] ,
131+ } ,
132+ } ,
133+ } )
134+
135+ const resolution = {
136+ blockId : 'start' ,
137+ block,
138+ path : StartBlockPath . UNIFIED ,
139+ } as const
140+
141+ const output = buildStartBlockOutput ( {
142+ resolution,
143+ workflowInput : { input : 'hello' } ,
144+ } )
145+
146+ expect ( output . input ) . toBe ( 'hello' )
147+ expect ( output . customField ) . toBe ( 'defaultValue' )
148+ } )
149+
150+ it . concurrent ( 'runtime value overrides default value' , ( ) => {
151+ const block = createBlock ( 'start_trigger' , 'start' , {
152+ subBlocks : {
153+ inputFormat : {
154+ value : [ { name : 'customField' , type : 'string' , value : 'defaultValue' } ] ,
155+ } ,
156+ } ,
157+ } )
158+
159+ const resolution = {
160+ blockId : 'start' ,
161+ block,
162+ path : StartBlockPath . UNIFIED ,
163+ } as const
164+
165+ const output = buildStartBlockOutput ( {
166+ resolution,
167+ workflowInput : { customField : 'runtimeValue' } ,
168+ } )
169+
170+ expect ( output . customField ) . toBe ( 'runtimeValue' )
171+ } )
172+
173+ it . concurrent ( 'empty string from runtime overrides default value' , ( ) => {
174+ const block = createBlock ( 'start_trigger' , 'start' , {
175+ subBlocks : {
176+ inputFormat : {
177+ value : [ { name : 'customField' , type : 'string' , value : 'defaultValue' } ] ,
178+ } ,
179+ } ,
180+ } )
181+
182+ const resolution = {
183+ blockId : 'start' ,
184+ block,
185+ path : StartBlockPath . UNIFIED ,
186+ } as const
187+
188+ const output = buildStartBlockOutput ( {
189+ resolution,
190+ workflowInput : { customField : '' } ,
191+ } )
192+
193+ expect ( output . customField ) . toBe ( '' )
194+ } )
195+
196+ it . concurrent ( 'null from runtime does not override default value' , ( ) => {
197+ const block = createBlock ( 'start_trigger' , 'start' , {
198+ subBlocks : {
199+ inputFormat : {
200+ value : [ { name : 'customField' , type : 'string' , value : 'defaultValue' } ] ,
201+ } ,
202+ } ,
203+ } )
204+
205+ const resolution = {
206+ blockId : 'start' ,
207+ block,
208+ path : StartBlockPath . UNIFIED ,
209+ } as const
210+
211+ const output = buildStartBlockOutput ( {
212+ resolution,
213+ workflowInput : { customField : null } ,
214+ } )
215+
216+ expect ( output . customField ) . toBe ( 'defaultValue' )
217+ } )
218+ } )
123219} )
0 commit comments