diff --git a/packages/solid-query/src/__tests__/useQuery.test.tsx b/packages/solid-query/src/__tests__/useQuery.test.tsx
index 745621d171..2642b159ae 100644
--- a/packages/solid-query/src/__tests__/useQuery.test.tsx
+++ b/packages/solid-query/src/__tests__/useQuery.test.tsx
@@ -25,6 +25,7 @@ import {
sleep,
} from '@tanstack/query-test-utils'
import {
+ IsRestoringProvider,
QueryCache,
QueryClient,
QueryClientProvider,
@@ -6159,6 +6160,54 @@ describe('useQuery', () => {
expect(rendered.getByText('data: 3')).toBeInTheDocument()
})
+ it('should not fetch while restoring and refetch after restoring is complete', async () => {
+ const key = queryKey()
+ const queryFn = vi
+ .fn()
+ .mockImplementation(() => sleep(10).then(() => 'data'))
+
+ const [isRestoring, setIsRestoring] = createSignal(true)
+
+ function Page() {
+ const query = useQuery(() => ({
+ queryKey: key,
+ queryFn,
+ }))
+
+ return (
+
+
{query.status}
+
{query.fetchStatus}
+
{query.data ?? 'undefined'}
+
+ )
+ }
+
+ const rendered = render(() => (
+
+
+
+
+
+ ))
+
+ await vi.advanceTimersByTimeAsync(0)
+
+ expect(rendered.getByTestId('status')).toHaveTextContent('pending')
+ expect(rendered.getByTestId('fetchStatus')).toHaveTextContent('idle')
+ expect(rendered.getByTestId('data')).toHaveTextContent('undefined')
+ expect(queryFn).toHaveBeenCalledTimes(0)
+
+ // Restoring complete: should refetch
+ setIsRestoring(false)
+ await vi.advanceTimersByTimeAsync(10)
+
+ expect(rendered.getByTestId('status')).toHaveTextContent('success')
+ expect(rendered.getByTestId('fetchStatus')).toHaveTextContent('idle')
+ expect(rendered.getByTestId('data')).toHaveTextContent('data')
+ expect(queryFn).toHaveBeenCalledTimes(1)
+ })
+
it('should use provided custom queryClient', async () => {
const key = queryKey()
const queryFn = () => sleep(10).then(() => 'custom client')