@@ -12,6 +12,7 @@ vi.mock('@/blocks/registry-maps', async () => {
1212 const { partialBlockRegistry } = await import ( '@sim/testing/mocks/block-registry.mock' )
1313 return partialBlockRegistry (
1414 await import ( '@/blocks/blocks/condition' ) ,
15+ await import ( '@/blocks/blocks/file' ) ,
1516 await import ( '@/blocks/blocks/pagerduty' ) ,
1617 await import ( '@/blocks/blocks/function' )
1718 )
@@ -118,6 +119,30 @@ describe('sanitizeMalformedSubBlocks', () => {
118119 } )
119120
120121 describe ( 'regular blocks (config is the schema)' , ( ) => {
122+ it ( 'repairs scalar blanks for multi-select fields while preserving their empty arrays' , ( ) => {
123+ const block = {
124+ id : 'block-1' ,
125+ type : 'file_v5' ,
126+ subBlocks : {
127+ folderSelection : { id : 'folderSelection' , type : 'folder-selector' , value : '' } ,
128+ } ,
129+ }
130+ const options = { convertEmptyStringToNull : true }
131+
132+ expect ( sanitizeMalformedSubBlocks ( block , options ) . subBlocks . folderSelection . value ) . toBeNull ( )
133+ expect (
134+ sanitizeMalformedSubBlocks (
135+ {
136+ ...block ,
137+ subBlocks : {
138+ folderSelection : { ...block . subBlocks . folderSelection , value : [ ] } ,
139+ } ,
140+ } ,
141+ options
142+ ) . subBlocks . folderSelection . value
143+ ) . toEqual ( [ ] )
144+ } )
145+
121146 it ( 'preserves declared empty dropdown choices and cleared selectors without suppressing dropdown defaults' , ( ) => {
122147 const { subBlocks } = sanitizeMalformedSubBlocks (
123148 {
0 commit comments