@@ -342,31 +342,53 @@ test("a selected hidden provisional tab merges without switching the main pane",
342342 expect ( h . result . current . paneOpen ) . toBe ( false ) ;
343343} ) ;
344344
345- test ( "wrong-root diversion preserves the confirmed tab and resolves into the actual owner" , ( ) => {
346- const session = { } as RelaySession ;
347- const h = renderHook ( ( ) => useChannelTabState ( session , "alpha" ) ) ;
348- act ( ( ) => h . result . current . openThreadTab ( "alpha" , "x" , "x" ) ) ;
349- act ( ( ) => h . result . current . resolveThreadRoot ( "thread:alpha:x" , "x" ) ) ;
350- act ( ( ) =>
351- h . result . current . openThreadTab ( "alpha" , "y" , "y" , "select" , "main" ) ,
352- ) ;
353- act ( ( ) => h . result . current . resolveThreadRoot ( "thread:alpha:y" , "y" ) ) ;
354- act ( ( ) => h . result . current . openThreadTab ( "alpha" , "reply-y" , "x" , "select" ) ) ;
355- act ( ( ) => h . result . current . divertThread ( "thread:alpha:x" , "reply-y" , "x" ) ) ;
356- expect (
357- h . result . current . tabs . find ( ( tab ) => tab . id === "thread:alpha:x" ) ,
358- ) . toMatchObject ( { messageId : "x" , rootId : "x" , pane : "side" } ) ;
359- expect ( h . result . current . selected ) . toBe ( "thread:alpha:reply-y" ) ;
360- act ( ( ) => h . result . current . resolveThreadRoot ( "thread:alpha:reply-y" , "y" ) ) ;
361- expect ( h . result . current . tabs ) . toHaveLength ( 2 ) ;
362- expect ( h . result . current . mainSelected ) . toBe ( "thread:alpha:y" ) ;
363- expect (
364- h . result . current . tabs . find ( ( tab ) => tab . id === "thread:alpha:y" ) ,
365- ) . toMatchObject ( { messageId : "reply-y" } ) ;
366- const tabs = h . result . current . tabs ;
367- act ( ( ) => h . result . current . divertThread ( "thread:alpha:x" , "reply-y" , "x" ) ) ;
368- expect ( h . result . current . tabs ) . toBe ( tabs ) ;
369- } ) ;
345+ test . each ( [ "side" , "main" ] as const ) (
346+ "wrong-root diversion preserves the %s pane despite the opposite default and resolves into the actual owner" ,
347+ ( pane ) => {
348+ const otherPane = pane === "side" ? "main" : "side" ;
349+ setThreadPlacementPreference ( otherPane ) ;
350+ const session = { } as RelaySession ;
351+ const h = renderHook ( ( ) => useChannelTabState ( session , "alpha" ) ) ;
352+ act ( ( ) =>
353+ h . result . current . openThreadTab ( "alpha" , "x" , "x" , "select" , pane ) ,
354+ ) ;
355+ act ( ( ) => h . result . current . resolveThreadRoot ( "thread:alpha:x" , "x" ) ) ;
356+ act ( ( ) =>
357+ h . result . current . openThreadTab ( "alpha" , "y" , "y" , "select" , otherPane ) ,
358+ ) ;
359+ act ( ( ) => h . result . current . resolveThreadRoot ( "thread:alpha:y" , "y" ) ) ;
360+ act ( ( ) =>
361+ h . result . current . openThreadTab ( "alpha" , "reply-y" , "x" , "select" , pane ) ,
362+ ) ;
363+ act ( ( ) => h . result . current . divertThread ( "thread:alpha:x" , "reply-y" , "x" ) ) ;
364+ expect (
365+ h . result . current . tabs . find ( ( tab ) => tab . id === "thread:alpha:x" ) ,
366+ ) . toMatchObject ( { messageId : "x" , rootId : "x" , pane } ) ;
367+ expect (
368+ h . result . current . tabs . find ( ( tab ) => tab . id === "thread:alpha:reply-y" ) ,
369+ ) . toMatchObject ( { messageId : "reply-y" , pane } ) ;
370+ expect (
371+ pane === "side"
372+ ? h . result . current . selected
373+ : h . result . current . mainSelected ,
374+ ) . toBe ( "thread:alpha:reply-y" ) ;
375+ // An already-open verified destination still keeps its own placement.
376+ act ( ( ) => h . result . current . resolveThreadRoot ( "thread:alpha:reply-y" , "y" ) ) ;
377+ expect ( h . result . current . tabs ) . toHaveLength ( 2 ) ;
378+ expect (
379+ otherPane === "main"
380+ ? h . result . current . mainSelected
381+ : h . result . current . selected ,
382+ ) . toBe ( "thread:alpha:y" ) ;
383+ expect (
384+ h . result . current . tabs . find ( ( tab ) => tab . id === "thread:alpha:y" ) ,
385+ ) . toMatchObject ( { messageId : "reply-y" , pane : otherPane } ) ;
386+ const tabs = h . result . current . tabs ;
387+ act ( ( ) => h . result . current . divertThread ( "thread:alpha:x" , "reply-y" , "x" ) ) ;
388+ expect ( h . result . current . tabs ) . toBe ( tabs ) ;
389+ expect ( threadPlacementPreference ( ) ) . toBe ( otherPane ) ;
390+ } ,
391+ ) ;
370392
371393test ( "verified identity takes precedence over a tab's original hint id" , ( ) => {
372394 const session = { } as RelaySession ;
0 commit comments