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

devtools.test.tsx

864 lines22.8 KB

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