@@ -892,7 +892,7 @@ describe('sunset block types', () => {
892892 const loopId = '66666666-6666-4666-8666-666666666666'
893893 const insertedId = '77777777-7777-4777-8777-777777777777'
894894
895- function tableBlock ( id : string , type : string , name : string ) {
895+ function tableBlock ( id : string , type : string , name : string , parentId ?: string ) {
896896 return {
897897 id,
898898 type,
@@ -901,10 +901,45 @@ describe('sunset block types', () => {
901901 enabled : true ,
902902 subBlocks : { tableId : { id : 'tableId' , type : 'short-input' , value : 'tbl_old' } } ,
903903 outputs : { } ,
904- data : { } ,
904+ data : parentId ? { parentId } : { } ,
905905 }
906906 }
907907
908+ it ( 'updates a placed legacy child but refuses a new one when a container edit merges children' , ( ) => {
909+ const workflow = {
910+ blocks : {
911+ [ loopId ] : { ...tableBlock ( loopId , 'loop' , 'Each' ) , subBlocks : { } } ,
912+ [ legacyId ] : tableBlock ( legacyId , 'table' , 'Rows' , loopId ) ,
913+ } ,
914+ edges : [ ] ,
915+ loops : { } ,
916+ parallels : { } ,
917+ }
918+
919+ const { state, skippedItems } = applyOperationsToWorkflowState ( workflow , [
920+ {
921+ operation_type : 'edit' ,
922+ block_id : loopId ,
923+ params : {
924+ nestedNodes : {
925+ [ legacyId ] : { type : 'table' , name : 'Rows' , inputs : { tableId : 'tbl_new' } } ,
926+ [ newId ] : { type : 'table' , name : 'Fresh rows' } ,
927+ } ,
928+ } ,
929+ } ,
930+ ] )
931+
932+ expect ( state . blocks [ legacyId ] . subBlocks . tableId . value ) . toBe ( 'tbl_new' )
933+ expect ( state . blocks [ newId ] ) . toBeUndefined ( )
934+ expect ( skippedItems ) . toEqual ( [
935+ expect . objectContaining ( {
936+ type : 'block_not_allowed' ,
937+ operationType : 'add_nested_node' ,
938+ blockId : newId ,
939+ } ) ,
940+ ] )
941+ } )
942+
908943 it ( 'refuses a new legacy block, top-level or nested, and names its successor' , ( ) => {
909944 const { state, skippedItems } = applyOperationsToWorkflowState (
910945 { blocks : { } , edges : [ ] , loops : { } , parallels : { } } ,
0 commit comments