Skip to content

Comments

test(solid-query/useQuery): add test for refetching query when 'queryClient' changes#10167

Open
sukvvon wants to merge 6 commits intoTanStack:mainfrom
sukvvon:test/solid-query-useBaseQuery-client-change
Open

test(solid-query/useQuery): add test for refetching query when 'queryClient' changes#10167
sukvvon wants to merge 6 commits intoTanStack:mainfrom
sukvvon:test/solid-query-useBaseQuery-client-change

Conversation

@sukvvon
Copy link
Contributor

@sukvvon sukvvon commented Feb 22, 2026

🎯 Changes

Add a test to verify that when queryClient changes, the query refetches with the new client. Covers useBaseQuery.ts lines 317-327 where the client signal change triggers observer re-creation and re-subscription.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Tests
    • Added tests verifying that switching between different query client instances triggers refetches, preserves separate per-client caches, and updates UI status correctly; a duplicate of this test was added in a second location.

@changeset-bot
Copy link

changeset-bot bot commented Feb 22, 2026

⚠️ No Changeset found

Latest commit: ac5447c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 22, 2026

No actionable comments were generated in the recent review. 🎉


📝 Walkthrough

Walkthrough

Adds a test to useQuery that verifies swapping between two distinct QueryClient instances causes refetches, ensures each client maintains its own cache, and that the query function runs once per client when swapped. (Test appears duplicated in the suite.)

Changes

Cohort / File(s) Summary
useQuery test
packages/solid-query/src/__tests__/useQuery.test.tsx
Adds test "should refetch query when queryClient changes" that mounts a component with a dynamic client resolver, swaps between two QueryClient instances, and asserts the query function runs once per client, both clients cache the key, and UI updates on swap.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested reviewers

  • TkDodo
  • manudeli

Poem

🐰 I hopped between two clients with a curious twitch,
Each cache kept its secret, each fetch just a stitch.
Keys stayed the same, queries ran true,
A rabbit’s small test — swap, refetch, and view. 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding a test for refetching when queryClient changes, which matches the actual diff that adds a test to useQuery.test.tsx.
Description check ✅ Passed The description follows the template structure with all required sections completed: Changes section explains the test purpose and coverage, Checklist items are marked appropriately, and Release Impact correctly identifies this as dev-only.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud
Copy link

nx-cloud bot commented Feb 22, 2026

View your CI Pipeline Execution ↗ for commit ac5447c

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 1m 34s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-02-22 13:55:02 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 22, 2026

More templates

@tanstack/angular-query-experimental

npm i https://pkg.pr.new/@tanstack/angular-query-experimental@10167

@tanstack/eslint-plugin-query

npm i https://pkg.pr.new/@tanstack/eslint-plugin-query@10167

@tanstack/preact-query

npm i https://pkg.pr.new/@tanstack/preact-query@10167

@tanstack/query-async-storage-persister

npm i https://pkg.pr.new/@tanstack/query-async-storage-persister@10167

@tanstack/query-broadcast-client-experimental

npm i https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@10167

@tanstack/query-core

npm i https://pkg.pr.new/@tanstack/query-core@10167

@tanstack/query-devtools

npm i https://pkg.pr.new/@tanstack/query-devtools@10167

@tanstack/query-persist-client-core

npm i https://pkg.pr.new/@tanstack/query-persist-client-core@10167

@tanstack/query-sync-storage-persister

npm i https://pkg.pr.new/@tanstack/query-sync-storage-persister@10167

@tanstack/react-query

npm i https://pkg.pr.new/@tanstack/react-query@10167

@tanstack/react-query-devtools

npm i https://pkg.pr.new/@tanstack/react-query-devtools@10167

@tanstack/react-query-next-experimental

npm i https://pkg.pr.new/@tanstack/react-query-next-experimental@10167

@tanstack/react-query-persist-client

npm i https://pkg.pr.new/@tanstack/react-query-persist-client@10167

@tanstack/solid-query

npm i https://pkg.pr.new/@tanstack/solid-query@10167

@tanstack/solid-query-devtools

npm i https://pkg.pr.new/@tanstack/solid-query-devtools@10167

@tanstack/solid-query-persist-client

npm i https://pkg.pr.new/@tanstack/solid-query-persist-client@10167

@tanstack/svelte-query

npm i https://pkg.pr.new/@tanstack/svelte-query@10167

@tanstack/svelte-query-devtools

npm i https://pkg.pr.new/@tanstack/svelte-query-devtools@10167

@tanstack/svelte-query-persist-client

npm i https://pkg.pr.new/@tanstack/svelte-query-persist-client@10167

@tanstack/vue-query

npm i https://pkg.pr.new/@tanstack/vue-query@10167

@tanstack/vue-query-devtools

npm i https://pkg.pr.new/@tanstack/vue-query-devtools@10167

commit: ac5447c

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/solid-query/src/__tests__/useQuery.test.tsx`:
- Around line 6194-6212: The test currently drives both the QueryClientProvider
and the useQuery client accessor from the same signal so it doesn't truly verify
the explicit client accessor; change the setup so QueryClientProvider receives a
fixed client (e.g., queryClient1) while the accessor passed into Page (the prop
used by useQuery) is driven by createSignal and toggled to a different client
(e.g., queryClient2); update the render to pass a constant client to
QueryClientProvider and pass client() (signal) into <Page client={client()} />,
so Page -> useQuery(...) uses the decoupled accessor and the test asserts the
explicit client parameter behavior (reference symbols: QueryClientProvider,
Page, useQuery, createSignal, client, setClient, queryClient1, queryClient2).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant