Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

devtools.test.tsx

866 lines23.4 KB

1import * as React from 'react'
2import { fireEvent, screen, waitFor, act } from '@testing-library/react'
3import { ErrorBoundary } from 'react-error-boundary'
4import '@testing-library/jest-dom'
5import type { QueryClient } from '@tanstack/react-query'
6import { useQuery } from '@tanstack/react-query'
7import { sortFns } from '../utils'
8import {
9 getByTextContent,
10 renderWithClient,
11 sleep,
12 createQueryClient,
13} from './utils'
14​
15// TODO: This should be removed with the types for react-error-boundary get updated.
16declare module 'react-error-boundary' {
17 interface ErrorBoundaryPropsWithFallback {
18 children: any
19 }
21​
22Object.defineProperty(window, 'matchMedia', {
23 writable: true,
24 value: jest.fn().mockImplementation((query: string) => ({
25 matches: false,
26 media: query,
27 onchange: null,
28 addListener: jest.fn(), // deprecated
29 removeListener: jest.fn(), // deprecated
30 addEventListener: jest.fn(),
31 removeEventListener: jest.fn(),
32 dispatchEvent: jest.fn(),
33 })),
34})
35​
36describe('ReactQueryDevtools', () => {
37 beforeEach(() => {
38 localStorage.removeItem('reactQueryDevtoolsOpen')
39 })
40 it('should be able to open and close devtools', async () => {
41 const { queryClient } = createQueryClient()
42 const onCloseClick = jest.fn()
43 const onToggleClick = jest.fn()
44​
45 function Page() {
46 const { data = 'default' } = useQuery(['check'], async () => {
47 await sleep(10)
48 return 'test'
49 })
50​
51 return (
52 <div>
53 <h1>{data}</h1>
54 </div>
55 )
56 }
57​
58 renderWithClient(queryClient, <Page />, {
59 initialIsOpen: false,
60 closeButtonProps: { onClick: onCloseClick },
61 toggleButtonProps: { onClick: onToggleClick },
62 })
63​
64 const verifyDevtoolsIsOpen = () => {
65 expect(
66 screen.queryByRole('generic', { name: /react query devtools panel/i }),
67 ).not.toBeNull()
68 expect(
69 screen.queryByRole('button', { name: /open react query devtools/i }),
70 ).toBeNull()
71 }
72 const verifyDevtoolsIsClosed = () => {
73 expect(
74 screen.queryByRole('generic', { name: /react query devtools panel/i }),
75 ).toBeNull()
76 expect(
77 screen.queryByRole('button', { name: /open react query devtools/i }),
78 ).not.toBeNull()
79 }
80​
81 const waitForDevtoolsToOpen = () =>
82 screen.findByRole('button', { name: /close react query devtools/i })
83 const waitForDevtoolsToClose = () =>
84 screen.findByRole('button', { name: /open react query devtools/i })
85​
86 const getOpenLogoButton = () =>
87 screen.getByRole('button', { name: /open react query devtools/i })
88 const getCloseLogoButton = () =>
89 screen.getByRole('button', { name: /close react query devtools/i })
90 const getCloseButton = () =>
91 screen.getByRole('button', { name: /^close$/i })
92​
93 verifyDevtoolsIsClosed()
94​
95 fireEvent.click(getOpenLogoButton())
96 await waitForDevtoolsToOpen()
97​
98 verifyDevtoolsIsOpen()
99​
100 fireEvent.click(getCloseLogoButton())
101 await waitForDevtoolsToClose()
102​
103 verifyDevtoolsIsClosed()
104​
105 fireEvent.click(getOpenLogoButton())
106 await waitForDevtoolsToOpen()
107​
108 verifyDevtoolsIsOpen()
109​
110 fireEvent.click(getCloseButton())
111 await waitForDevtoolsToClose()
112​
113 verifyDevtoolsIsClosed()
114 })
115​
116 it('should be able to drag devtools without error', async () => {
117 const { queryClient } = createQueryClient()
118​
119 function Page() {
120 const { data = 'default' } = useQuery(['check'], async () => {
121 await sleep(10)
122 return 'test'
123 })
124​
125 return (
126 <div>
127 <h1>{data}</h1>
128 </div>
129 )
130 }
131​
132 const result = renderWithClient(queryClient, <Page />, {
133 initialIsOpen: false,
134 })
135​
136 const draggableElement = result.container
137 .querySelector('#ReactQueryDevtoolsPanel')
138 ?.querySelector('div')
139​
140 if (!draggableElement) {
141 throw new Error('Could not find the draggable element')
142 }
143​
144 await act(async () => {
145 fireEvent.mouseDown(draggableElement)
146 })
147 })
148​
149 it('should display the correct query states', async () => {
150 const { queryClient, queryCache } = createQueryClient()
151​
152 function Page() {
153 const { data = 'default' } = useQuery(
154 ['check'],
155 async () => {
156 await sleep(100)
157 return 'test'
158 },
159 { staleTime: 300 },
160 )
161​
162 return (
163 <div>
164 <h1>{data}</h1>
165 </div>
166 )
167 }
168​
169 function PageParent() {
170 const [isPageVisible, togglePageVisible] = React.useReducer(
171 (visible) => !visible,
172 true,
173 )
174​
175 return (
176 <div>
177 <button
178 type="button"
179 aria-label="Toggle page visibility"
180 onClick={togglePageVisible}
181 >
182 Toggle Page
183 </button>
184 {isPageVisible && <Page />}
185 </div>
186 )
187 }
188​
189 renderWithClient(queryClient, <PageParent />)
190​
191 fireEvent.click(
192 screen.getByRole('button', { name: /open react query devtools/i }),
193 )
194​
195 const currentQuery = queryCache.find(['check'])
196​
197 // When the query is fetching then expect number of
198 // fetching queries to be 1
199 expect(currentQuery?.state.fetchStatus).toEqual('fetching')
200 await screen.findByText(
201 getByTextContent(
202 'fresh (0) fetching (1) paused (0) stale (0) inactive (0)',
203 ),
204 )
205​
206 // When we are done fetching the query doesn't go stale
207 // until 300ms after, so expect the number of fresh
208 // queries to be 1
209 await waitFor(() => {
210 expect(currentQuery?.state.fetchStatus).toEqual('idle')
211 })
212 await screen.findByText(
213 getByTextContent(
214 'fresh (1) fetching (0) paused (0) stale (0) inactive (0)',
215 ),
216 )
217​
218 // Then wait for the query to go stale and then
219 // expect the number of stale queries to be 1
220 await waitFor(() => {
221 expect(currentQuery?.isStale()).toEqual(false)
222 })
223 await screen.findByText(
224 getByTextContent(
225 'fresh (0) fetching (0) paused (0) stale (1) inactive (0)',
226 ),
227 )
228​
229 // Unmount the page component thus making the query inactive
230 // and expect number of inactive queries to be 1
231 fireEvent.click(
232 screen.getByRole('button', { name: /toggle page visibility/i }),
233 )
234 await screen.findByText(
235 getByTextContent(
236 'fresh (0) fetching (0) paused (0) stale (0) inactive (1)',
237 ),
238 )
239 })
240​
241 it('should display the query hash and open the query details', async () => {
242 const { queryClient, queryCache } = createQueryClient()
243​
244 function Page() {
245 const { data = 'default' } = useQuery(['check'], async () => {
246 await sleep(10)
247 return 'test'
248 })
249​
250 return (
251 <div>
252 <h1>{data}</h1>
253 </div>
254 )
255 }
256​
257 renderWithClient(queryClient, <Page />)
258​
259 fireEvent.click(
260 screen.getByRole('button', { name: /open react query devtools/i }),
261 )
262​
263 const currentQuery = queryCache.find(['check'])
264​
265 await screen.findByText(getByTextContent(`1${currentQuery?.queryHash}`))
266​
267 const queryButton = await screen.findByRole('button', {
268 name: `Open query details for ${currentQuery?.queryHash}`,
269 })
270​
271 fireEvent.click(queryButton)
272​
273 await screen.findByText(/query details/i)
274 })
275​
276 it('should filter the queries via the query hash', async () => {
277 const { queryClient, queryCache } = createQueryClient()
278​
279 function Page() {
280 const fooResult = useQuery(['foo'], async () => {
281 await sleep(10)
282 return 'foo-result'
283 })
284​
285 const barResult = useQuery(['bar'], async () => {
286 await sleep(10)
287 return 'bar-result'
288 })
289​
290 const bazResult = useQuery(['baz'], async () => {
291 await sleep(10)
292 return 'baz-result'
293 })
294​
295 return (
296 <div>
297 <h1>
298 {barResult.data} {fooResult.data} {bazResult.data}
299 </h1>
300 </div>
301 )
302 }
303​
304 renderWithClient(queryClient, <Page />)
305​
306 fireEvent.click(
307 screen.getByRole('button', { name: /open react query devtools/i }),
308 )
309​
310 const fooQueryHash = queryCache.find(['foo'])?.queryHash ?? 'invalid hash'
311 const barQueryHash = queryCache.find(['bar'])?.queryHash ?? 'invalid hash'
312 const bazQueryHash = queryCache.find(['baz'])?.queryHash ?? 'invalid hash'
313​
314 await screen.findByText(fooQueryHash)
315 screen.getByText(barQueryHash)
316 screen.getByText(bazQueryHash)
317​
318 const filterInput = screen.getByLabelText(/filter by queryhash/i)
319 fireEvent.change(filterInput, { target: { value: 'fo' } })
320​
321 await screen.findByText(fooQueryHash)
322 const barItem = screen.queryByText(barQueryHash)
323 const bazItem = screen.queryByText(bazQueryHash)
324 expect(barItem).toBeNull()
325 expect(bazItem).toBeNull()
326​
327 fireEvent.change(filterInput, { target: { value: '' } })
328 })
329​
330 it('should show a disabled label if all observers are disabled', async () => {
331 const { queryClient } = createQueryClient()
332​
333 function Page() {
334 const [enabled, setEnabled] = React.useState(false)
335 const { data } = useQuery(
336 ['key'],
337 async () => {
338 await sleep(10)
339 return 'test'
340 },
341 {
342 enabled,
343 },
344 )
345​
346 return (
347 <div>
348 <h1>{data}</h1>
349 <button onClick={() => setEnabled(true)}>Enable Query</button>
350 </div>
351 )
352 }
353​
354 renderWithClient(queryClient, <Page />, { initialIsOpen: true })
355​
356 await screen.findByText(/disabled/i)
357​
358 fireEvent.click(screen.getByRole('button', { name: /enable query/i }))
359​
360 await waitFor(() => {
361 expect(screen.queryByText(/disabled/i)).not.toBeInTheDocument()
362 })
363 })
364​
365 it('should not show a disabled label for inactive queries', async () => {
366 const { queryClient } = createQueryClient()
367​
368 function Page() {
369 const { data } = useQuery(['key'], () => Promise.resolve('test'), {
370 enabled: false,
371 })
372​
373 return (
374 <div>
375 <h1>{data}</h1>
376 </div>
377 )
378 }
379​
380 function App() {
381 const [visible, setVisible] = React.useState(true)
382​
383 return (
384 <div>
385 {visible ? <Page /> : null}
386 <button onClick={() => setVisible(false)}>Hide Query</button>
387 </div>
388 )
389 }
390​
391 renderWithClient(queryClient, <App />, { initialIsOpen: true })
392​
393 await screen.findByText(/disabled/i)
394​
395 fireEvent.click(screen.getByRole('button', { name: /hide query/i }))
396​
397 await waitFor(() => {
398 expect(screen.queryByText(/disabled/i)).not.toBeInTheDocument()
399 })
400 })
401​
402 it('should simulate offline mode', async () => {
403 const { queryClient } = createQueryClient()
404 let count = 0
405​
406 function App() {
407 const { data, fetchStatus } = useQuery(['key'], () => {
408 count++
409 return Promise.resolve('test')
410 })
411​
412 return (
413 <div>
414 <h1>
415 {data}, {fetchStatus}
416 </h1>
417 </div>
418 )
419 }
420​
421 renderWithClient(queryClient, <App />, {
422 initialIsOpen: true,
423 })
424​
425 await screen.findByRole('heading', { name: /test/i })
426​
427 fireEvent.click(
428 screen.getByRole('button', { name: /mock offline behavior/i }),
429 )
430​
431 const queryButton = await screen.findByRole('button', {
432 name: 'Open query details for ["key"]',
433 })
434 fireEvent.click(queryButton)
435​
436 const refetchButton = await screen.findByRole('button', {
437 name: /refetch/i,
438 })
439 fireEvent.click(refetchButton)
440​
441 await waitFor(() => {
442 expect(screen.getByText('test, paused')).toBeInTheDocument()
443 })
444​
445 fireEvent.click(
446 screen.getByRole('button', { name: /restore offline mock/i }),
447 )
448​
449 await waitFor(() => {
450 expect(screen.getByText('test, idle')).toBeInTheDocument()
451 })
452​
453 expect(count).toBe(2)
454 })
455​
456 it('should sort the queries according to the sorting filter', async () => {
457 const { queryClient, queryCache } = createQueryClient()
458​
459 function Page() {
460 const query1Result = useQuery(['query-1'], async () => {
461 await sleep(20)
462 return 'query-1-result'
463 })
464​
465 const query3Result = useQuery(
466 ['query-3'],
467 async () => {
468 await sleep(10)
469 return 'query-3-result'
470 },
471 { staleTime: Infinity, enabled: typeof query1Result.data === 'string' },
472 )
473​
474 const query2Result = useQuery(
475 ['query-2'],
476 async () => {
477 await sleep(10)
478 return 'query-2-result'
479 },
480 {
481 enabled: typeof query3Result.data === 'string',
482 },
483 )
484​
485 return (
486 <div>
487 <h1>
488 {query1Result.data} {query2Result.data} {query3Result.data}
489 </h1>
490 </div>
491 )
492 }
493​
494 renderWithClient(queryClient, <Page />)
495​
496 fireEvent.click(
497 screen.getByRole('button', { name: /open react query devtools/i }),
498 )
499​
500 const query1Hash = queryCache.find(['query-1'])?.queryHash ?? 'invalid hash'
501 const query2Hash = queryCache.find(['query-2'])?.queryHash ?? 'invalid hash'
502 const query3Hash = queryCache.find(['query-3'])?.queryHash ?? 'invalid hash'
503​
504 const sortSelect = screen.getByLabelText(/sort queries/i)
505 let queries = []
506​
507 // When sorted by query hash the queries get sorted according
508 // to just the number, with the order being -> query-1, query-2, query-3
509 fireEvent.change(sortSelect, { target: { value: 'Query Hash' } })
510​
511 /** To check the order of the queries we can use regex to find
512 * all the row items in an array and then compare the items
513 * one by one in the order we expect it
514 * @reference https://github.com/testing-library/react-testing-library/issues/313#issuecomment-625294327
515 */
516 queries = await screen.findAllByText(/\["query-[1-3]"\]/)
517 expect(queries[0]?.textContent).toEqual(query1Hash)
518 expect(queries[1]?.textContent).toEqual(query2Hash)
519 expect(queries[2]?.textContent).toEqual(query3Hash)
520​
521 // Wait for the queries to be resolved
522 await screen.findByText(/query-1-result query-2-result query-3-result/i)
523​
524 // When sorted by the last updated date the queries are sorted by the time
525 // they were updated and since the query-2 takes longest time to complete
526 // and query-1 the shortest, so the order is -> query-2, query-3, query-1
527 fireEvent.change(sortSelect, { target: { value: 'Last Updated' } })
528​
529 queries = await screen.findAllByText(/\["query-[1-3]"\]/)
530 expect(queries[0]?.textContent).toEqual(query2Hash)
531 expect(queries[1]?.textContent).toEqual(query3Hash)
532 expect(queries[2]?.textContent).toEqual(query1Hash)
533​
534 // When sorted by the status and then last updated date the queries
535 // query-3 takes precedence because its stale time being infinity, it
536 // always remains fresh, the rest of the queries are sorted by their last
537 // updated time, so the resulting order is -> query-3, query-2, query-1
538 fireEvent.change(sortSelect, {
539 target: { value: 'Status > Last Updated' },
540 })
541​
542 queries = await screen.findAllByText(/\["query-[1-3]"\]/)
543 expect(queries[0]?.textContent).toEqual(query3Hash)
544 expect(queries[1]?.textContent).toEqual(query2Hash)
545 expect(queries[2]?.textContent).toEqual(query1Hash)
546​
547 // Switch the order form ascending to descending and expect the
548 // query order to be reversed from previous state
549 fireEvent.click(screen.getByRole('button', { name: /⬆ asc/i }))
550​
551 queries = await screen.findAllByText(/\["query-[1-3]"\]/)
552 expect(queries[0]?.textContent).toEqual(query1Hash)
553 expect(queries[1]?.textContent).toEqual(query2Hash)
554 expect(queries[2]?.textContent).toEqual(query3Hash)
555 })
556​
557 it('should initialize filtering and sorting values with defaults when they are not stored in localstorage', () => {
558 localStorage.removeItem('reactQueryDevtoolsBaseSort')
559 localStorage.removeItem('reactQueryDevtoolsSortFn')
560 localStorage.removeItem('reactQueryDevtoolsFilter')
561​
562 const { queryClient } = createQueryClient()
563​
564 function Page() {
565 const { data = 'default' } = useQuery(['check'], async () => {
566 await sleep(10)
567 return 'test'
568 })
569​
570 return (
571 <div>
572 <h1>{data}</h1>
573 </div>
574 )
575 }
576​
577 renderWithClient(queryClient, <Page />, {
578 initialIsOpen: true,
579 })
580​
581 const filterInput: HTMLInputElement =
582 screen.getByLabelText(/Filter by queryhash/i)
583 expect(filterInput.value).toEqual('')
584​
585 const sortCombobox: HTMLSelectElement =
586 screen.getByLabelText(/Sort queries/i)
587 expect(sortCombobox.value).toEqual(Object.keys(sortFns)[0])
588​
589 expect(screen.getByRole('button', { name: /Asc/i })).toBeInTheDocument()
590​
591 const detailsPanel = screen.queryByText(/Query Details/i)
592 expect(detailsPanel).not.toBeInTheDocument()
593 })
594​
595 it('should initialize sorting values with ones stored in localstorage', async () => {
596 localStorage.setItem('reactQueryDevtoolsBaseSort', 'true')
597 localStorage.setItem(
598 'reactQueryDevtoolsSortFn',
599 JSON.stringify(Object.keys(sortFns)[1]),
600 )
601​
602 const { queryClient } = createQueryClient()
603​
604 function Page() {
605 const { data = 'default' } = useQuery(['check'], async () => {
606 await sleep(10)
607 return 'test'
608 })
609​
610 return (
611 <div>
612 <h1>{data}</h1>
613 </div>
614 )
615 }
616​
617 renderWithClient(queryClient, <Page />, {
618 initialIsOpen: true,
619 })
620​
621 const sortCombobox: HTMLSelectElement =
622 screen.getByLabelText(/Sort queries/i)
623 expect(sortCombobox.value).toEqual(Object.keys(sortFns)[1])
624​
625 expect(screen.getByRole('button', { name: /Desc/i })).toBeInTheDocument()
626 })
627​
628 it('should initialize filter value with one stored in localstorage', () => {
629 localStorage.setItem('reactQueryDevtoolsFilter', JSON.stringify('posts'))
630​
631 const { queryClient } = createQueryClient()
632​
633 function Page() {
634 const { data = 'default' } = useQuery(['check'], async () => {
635 await sleep(10)
636 return 'test'
637 })
638​
639 return (
640 <div>
641 <h1>{data}</h1>
642 </div>
643 )
644 }
645​
646 renderWithClient(queryClient, <Page />, {
647 initialIsOpen: true,
648 })
649​
650 const filterInput: HTMLInputElement =
651 screen.getByLabelText(/Filter by queryhash/i)
652 expect(filterInput.value).toEqual('posts')
653 })
654​
655 it('style should have a nonce', async () => {
656 const { queryClient } = createQueryClient()
657​
658 function Page() {
659 return <div></div>
660 }
661​
662 const { container } = renderWithClient(queryClient, <Page />, {
663 styleNonce: 'test-nonce',
664 initialIsOpen: false,
665 })
666 const styleTag = container.querySelector('style')
667 expect(styleTag).toHaveAttribute('nonce', 'test-nonce')
668​
669 await screen.findByRole('button', { name: /react query devtools/i })
670 })
671​
672 describe('with custom context', () => {
673 it('should render without error when the custom context aligns', async () => {
674 const context = React.createContext<QueryClient | undefined>(undefined)
675 const { queryClient } = createQueryClient()
676​
677 function Page() {
678 const { data = 'default' } = useQuery(['check'], async () => 'test', {
679 context,
680 })
681​
682 return (
683 <div>
684 <h1>{data}</h1>
685 </div>
686 )
687 }
688​
689 renderWithClient(queryClient, <Page />, {
690 initialIsOpen: false,
691 context,
692 })
693​
694 await screen.findByRole('button', { name: /open react query devtools/i })
695 })
696​
697 it('should render with error when the custom context is not passed to useQuery', async () => {
698 const consoleErrorMock = jest.spyOn(console, 'error')
699 consoleErrorMock.mockImplementation(() => undefined)
700​
701 const context = React.createContext<QueryClient | undefined>(undefined)
702 const { queryClient } = createQueryClient()
703​
704 function Page() {
705 const { data = 'default' } = useQuery(['check'], async () => 'test', {
706 useErrorBoundary: true,
707 })
708​
709 return (
710 <div>
711 <h1>{data}</h1>
712 </div>
713 )
714 }
715​
716 const rendered = renderWithClient(
717 queryClient,
718 <ErrorBoundary fallbackRender={() => <div>error boundary</div>}>
719 <Page />
720 </ErrorBoundary>,
721 {
722 initialIsOpen: false,
723 context,
724 },
725 )
726​
727 await waitFor(() => rendered.getByText('error boundary'))
728​
729 consoleErrorMock.mockRestore()
730 })
731​
732 it('should render with error when the custom context is not passed to ReactQueryDevtools', async () => {
733 const consoleErrorMock = jest.spyOn(console, 'error')
734 consoleErrorMock.mockImplementation(() => undefined)
735​
736 const context = React.createContext<QueryClient | undefined>(undefined)
737 const { queryClient } = createQueryClient()
738​
739 function Page() {
740 const { data = 'default' } = useQuery(['check'], async () => 'test', {
741 useErrorBoundary: true,
742 context,
743 })
744​
745 return (
746 <div>
747 <h1>{data}</h1>
748 </div>
749 )
750 }
751​
752 const rendered = renderWithClient(
753 queryClient,
754 <ErrorBoundary fallbackRender={() => <div>error boundary</div>}>
755 <Page />
756 </ErrorBoundary>,
757 {
758 initialIsOpen: false,
759 },
760 )
761​
762 await waitFor(() => rendered.getByText('error boundary'))
763​
764 consoleErrorMock.mockRestore()
765 })
766 })
767​
768 it('should render a menu to select panel position', async () => {
769 const { queryClient } = createQueryClient()
770​
771 function Page() {
772 const { data = 'default' } = useQuery(['check'], async () => 'test')
773​
774 return (
775 <div>
776 <h1>{data}</h1>
777 </div>
778 )
779 }
780​
781 renderWithClient(queryClient, <Page />, {
782 initialIsOpen: true,
783 })
784​
785 const positionSelect = (await screen.findByLabelText(
786 'Panel position',
787 )) as HTMLSelectElement
788​
789 expect(positionSelect.value).toBe('bottom')
790 })
791​
792 it(`should render the panel to the left if panelPosition is set to 'left'`, async () => {
793 const { queryClient } = createQueryClient()
794​
795 function Page() {
796 const { data = 'default' } = useQuery(['check'], async () => 'test')
797​
798 return (
799 <div>
800 <h1>{data}</h1>
801 </div>
802 )
803 }
804​
805 renderWithClient(queryClient, <Page />, {
806 initialIsOpen: true,
807 panelPosition: 'left',
808 })
809​
810 const positionSelect = (await screen.findByLabelText(
811 'Panel position',
812 )) as HTMLSelectElement
813​
814 expect(positionSelect.value).toBe('left')
815​
816 const panel = (await screen.getByLabelText(
817 'React Query Devtools Panel',
818 )) as HTMLDivElement
819​
820 expect(panel.style.left).toBe('0px')
821 expect(panel.style.width).toBe('500px')
822 expect(panel.style.height).toBe('100vh')
823 })
824​
825 it('should change the panel position if user select different option from the menu', async () => {
826 const { queryClient } = createQueryClient()
827​
828 function Page() {
829 const { data = 'default' } = useQuery(['check'], async () => 'test')
830​
831 return (
832 <div>
833 <h1>{data}</h1>
834 </div>
835 )
836 }
837​
838 renderWithClient(queryClient, <Page />, {
839 initialIsOpen: true,
840 })
841​
842 const positionSelect = (await screen.findByLabelText(
843 'Panel position',
844 )) as HTMLSelectElement
845​
846 expect(positionSelect.value).toBe('bottom')
847​
848 const panel = (await screen.getByLabelText(
849 'React Query Devtools Panel',
850 )) as HTMLDivElement
851​
852 expect(panel.style.bottom).toBe('0px')
853 expect(panel.style.height).toBe('500px')
854 expect(panel.style.width).toBe('100%')
855​
856 await act(async () => {
857 fireEvent.change(positionSelect, { target: { value: 'right' } })
858 })
859​
860 expect(positionSelect.value).toBe('right')
861​
862 expect(panel.style.right).toBe('0px')
863 expect(panel.style.width).toBe('500px')
864 expect(panel.style.height).toBe('100vh')
865 })
866})