@@ -3351,6 +3351,47 @@ describe("unwrap instance", () => {
33513351 expect ( $instances . get ( ) . has ( "slot" ) ) . toBe ( false ) ;
33523352 expect ( $instances . get ( ) . has ( "fragment" ) ) . toBe ( false ) ;
33533353 } ) ;
3354+
3355+ test ( "unwrap command detaches selected duplicated slot occurrence" , ( ) => {
3356+ const { instances, props } = renderData (
3357+ < $ . Body ws :id = "body" >
3358+ < $ . Slot ws :id = "slot1" >
3359+ < $ . Fragment ws :id = "fragment" >
3360+ < ws . element ws :tag = "div" ws :id = "div" > </ ws . element >
3361+ </ $ . Fragment >
3362+ </ $ . Slot >
3363+ < $ . Slot ws :id = "slot2" >
3364+ { /* same ids */ }
3365+ < $ . Fragment ws :id = "fragment" >
3366+ < ws . element ws :tag = "div" ws :id = "div" > </ ws . element >
3367+ </ $ . Fragment >
3368+ </ $ . Slot >
3369+ </ $ . Body >
3370+ ) ;
3371+ $instances . set ( instances ) ;
3372+ $props . set ( props ) ;
3373+ const pages = createDefaultPages ( { rootInstanceId : "body" } ) ;
3374+ $pages . set ( pages ) ;
3375+ $selectedPageId . set ( pages . homePageId ) ;
3376+ selectInstance ( [ "div" , "fragment" , "slot1" , "body" ] ) ;
3377+
3378+ unwrapInstance ( ) ;
3379+
3380+ const bodyChildren = $instances . get ( ) . get ( "body" ) ?. children ;
3381+ const unwrappedDivId =
3382+ bodyChildren ?. [ 0 ] ?. type === "id" ? bodyChildren [ 0 ] . value : undefined ;
3383+
3384+ expect ( unwrappedDivId ) . toBeDefined ( ) ;
3385+ expect ( unwrappedDivId ) . not . toBe ( "div" ) ;
3386+ expect ( $selectedInstanceSelector . get ( ) ) . toEqual ( [ unwrappedDivId , "body" ] ) ;
3387+ expect ( $instances . get ( ) . get ( "slot1" ) ) . toBeUndefined ( ) ;
3388+ expect ( $instances . get ( ) . get ( "slot2" ) ?. children ) . toEqual ( [
3389+ { type : "id" , value : "fragment" } ,
3390+ ] ) ;
3391+ expect ( $instances . get ( ) . get ( "fragment" ) ?. children ) . toEqual ( [
3392+ { type : "id" , value : "div" } ,
3393+ ] ) ;
3394+ } ) ;
33543395} ) ;
33553396
33563397describe ( "canUnwrapInstance" , ( ) => {
0 commit comments