File tree Expand file tree Collapse file tree
packages/query-devtools/src/__tests__ Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -456,6 +456,43 @@ describe('Devtools', () => {
456456 consoleError . mockRestore ( )
457457 }
458458 } )
459+
460+ it ( 'should hide the in-page panel while a PiP window is open' , ( ) => {
461+ stubPipWindow ( )
462+ const rendered = renderDevtools ( { initialIsOpen : true } )
463+
464+ fireEvent . click (
465+ rendered . getByLabelText ( 'Open in picture-in-picture mode' ) ,
466+ )
467+
468+ expect (
469+ rendered . container . querySelector ( '.tsqd-main-panel-container' ) ,
470+ ) . toBeNull ( )
471+ } )
472+
473+ it ( 'should restore the in-page panel and reset "pip_open" when the PiP window is closed' , ( ) => {
474+ const { fakeWindow } = stubPipWindow ( )
475+ const rendered = renderDevtools ( { initialIsOpen : true } )
476+
477+ fireEvent . click (
478+ rendered . getByLabelText ( 'Open in picture-in-picture mode' ) ,
479+ )
480+
481+ const addEventListener = fakeWindow . addEventListener as ReturnType <
482+ typeof vi . fn
483+ >
484+ const pagehideHandler = addEventListener . mock . calls . find (
485+ ( [ event ] ) => event === 'pagehide' ,
486+ ) ?. [ 1 ] as ( ) => void
487+ pagehideHandler ( )
488+
489+ expect ( localStorage . getItem ( 'TanstackQueryDevtools.pip_open' ) ) . toBe (
490+ 'false' ,
491+ )
492+ expect (
493+ rendered . getByLabelText ( 'Open in picture-in-picture mode' ) ,
494+ ) . toBeInTheDocument ( )
495+ } )
459496 } )
460497
461498 describe ( 'status counts' , ( ) => {
You can’t perform that action at this time.
0 commit comments