Skip to content

Commit 0a2696e

Browse files
committed
test(query-devtools/Devtools): add tests for in-page panel visibility while a PiP window is open
1 parent 217b67a commit 0a2696e

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

packages/query-devtools/src/__tests__/Devtools.test.tsx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff 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', () => {

0 commit comments

Comments
 (0)