From 2b5ef022b85dd9e73963370c670356844b89156c Mon Sep 17 00:00:00 2001 From: Wonsuk Choi Date: Sat, 30 May 2026 09:55:15 +0900 Subject: [PATCH 1/2] test(solid-query-devtools/devtoolsPanel): add wiring and default-value cases for 'onClose', 'errorTypes', 'theme', 'setClient', and 'unmount' --- .../src/__tests__/devtoolsPanel.test.tsx | 114 +++++++++++++++++- 1 file changed, 113 insertions(+), 1 deletion(-) diff --git a/packages/solid-query-devtools/src/__tests__/devtoolsPanel.test.tsx b/packages/solid-query-devtools/src/__tests__/devtoolsPanel.test.tsx index 68c591beb8b..db68b0fb968 100644 --- a/packages/solid-query-devtools/src/__tests__/devtoolsPanel.test.tsx +++ b/packages/solid-query-devtools/src/__tests__/devtoolsPanel.test.tsx @@ -1,9 +1,14 @@ -import { describe, expect, it } from 'vitest' +import { afterEach, describe, expect, it, vi } from 'vitest' import { render } from '@solidjs/testing-library' import { QueryClient, QueryClientProvider } from '@tanstack/solid-query' +import { TanstackQueryDevtoolsPanel } from '@tanstack/query-devtools' import SolidQueryDevtoolsPanel from '../devtoolsPanel' describe('SolidQueryDevtoolsPanel', () => { + afterEach(() => { + vi.restoreAllMocks() + }) + it('should throw an error if no query client has been set', () => { expect(() => render(() => )).toThrow( 'No QueryClient set, use QueryClientProvider to set one', @@ -29,4 +34,111 @@ describe('SolidQueryDevtoolsPanel', () => { render(() => ), ).not.toThrow() }) + + it('should forward "onClose" to the devtools instance', () => { + const setOnClose = vi.spyOn( + TanstackQueryDevtoolsPanel.prototype, + 'setOnClose', + ) + const queryClient = new QueryClient() + const onClose = vi.fn() + + render(() => ( + + )) + + expect(setOnClose).toHaveBeenCalledWith(onClose) + }) + + it('should default "onClose" to a no-op function when the prop is omitted', () => { + const setOnClose = vi.spyOn( + TanstackQueryDevtoolsPanel.prototype, + 'setOnClose', + ) + const queryClient = new QueryClient() + + render(() => ) + + expect(setOnClose).toHaveBeenCalledWith(expect.any(Function)) + }) + + it('should forward "errorTypes" to the devtools instance', () => { + const setErrorTypes = vi.spyOn( + TanstackQueryDevtoolsPanel.prototype, + 'setErrorTypes', + ) + const queryClient = new QueryClient() + const errorTypes = [ + { name: 'Network', initializer: () => new Error('Network') }, + ] + + render(() => ( + + )) + + expect(setErrorTypes).toHaveBeenCalledWith(errorTypes) + }) + + it('should default "errorTypes" to an empty array when the prop is omitted', () => { + const setErrorTypes = vi.spyOn( + TanstackQueryDevtoolsPanel.prototype, + 'setErrorTypes', + ) + const queryClient = new QueryClient() + + render(() => ) + + expect(setErrorTypes).toHaveBeenCalledWith([]) + }) + + it('should forward "theme" to the devtools instance', () => { + const setTheme = vi.spyOn( + TanstackQueryDevtoolsPanel.prototype, + 'setTheme', + ) + const queryClient = new QueryClient() + + render(() => ) + + expect(setTheme).toHaveBeenCalledWith('dark') + }) + + it('should default "theme" to "system" when the prop is omitted', () => { + const setTheme = vi.spyOn( + TanstackQueryDevtoolsPanel.prototype, + 'setTheme', + ) + const queryClient = new QueryClient() + + render(() => ) + + expect(setTheme).toHaveBeenCalledWith('system') + }) + + it('should forward the resolved "QueryClient" via "setClient"', () => { + const setClient = vi.spyOn( + TanstackQueryDevtoolsPanel.prototype, + 'setClient', + ) + const queryClient = new QueryClient() + + render(() => ) + + expect(setClient).toHaveBeenCalledWith(queryClient) + }) + + it('should call "unmount" on the devtools instance when the component unmounts', () => { + const unmount = vi.spyOn( + TanstackQueryDevtoolsPanel.prototype, + 'unmount', + ) + const queryClient = new QueryClient() + + const { unmount: unmountComponent } = render(() => ( + + )) + unmountComponent() + + expect(unmount).toHaveBeenCalled() + }) }) From a2342ee27c817d70fcb4b18830d607f84ec086fa Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Sat, 30 May 2026 00:56:40 +0000 Subject: [PATCH 2/2] ci: apply automated fixes --- .../src/__tests__/devtoolsPanel.test.tsx | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/packages/solid-query-devtools/src/__tests__/devtoolsPanel.test.tsx b/packages/solid-query-devtools/src/__tests__/devtoolsPanel.test.tsx index db68b0fb968..e519db5bee3 100644 --- a/packages/solid-query-devtools/src/__tests__/devtoolsPanel.test.tsx +++ b/packages/solid-query-devtools/src/__tests__/devtoolsPanel.test.tsx @@ -92,10 +92,7 @@ describe('SolidQueryDevtoolsPanel', () => { }) it('should forward "theme" to the devtools instance', () => { - const setTheme = vi.spyOn( - TanstackQueryDevtoolsPanel.prototype, - 'setTheme', - ) + const setTheme = vi.spyOn(TanstackQueryDevtoolsPanel.prototype, 'setTheme') const queryClient = new QueryClient() render(() => ) @@ -104,10 +101,7 @@ describe('SolidQueryDevtoolsPanel', () => { }) it('should default "theme" to "system" when the prop is omitted', () => { - const setTheme = vi.spyOn( - TanstackQueryDevtoolsPanel.prototype, - 'setTheme', - ) + const setTheme = vi.spyOn(TanstackQueryDevtoolsPanel.prototype, 'setTheme') const queryClient = new QueryClient() render(() => ) @@ -128,10 +122,7 @@ describe('SolidQueryDevtoolsPanel', () => { }) it('should call "unmount" on the devtools instance when the component unmounts', () => { - const unmount = vi.spyOn( - TanstackQueryDevtoolsPanel.prototype, - 'unmount', - ) + const unmount = vi.spyOn(TanstackQueryDevtoolsPanel.prototype, 'unmount') const queryClient = new QueryClient() const { unmount: unmountComponent } = render(() => (