Open History to see the last commit
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 }
20}
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})