Skip to content

test(react-query/useQueries): add test for not fetching during restoring period when 'isRestoring' is true#10196

Open
sukvvon wants to merge 1 commit intoTanStack:mainfrom
sukvvon:test/react-query-useQueries-isRestoring
Open

test(react-query/useQueries): add test for not fetching during restoring period when 'isRestoring' is true#10196
sukvvon wants to merge 1 commit intoTanStack:mainfrom
sukvvon:test/react-query-useQueries-isRestoring

Conversation

@sukvvon
Copy link
Contributor

@sukvvon sukvvon commented Feb 27, 2026

🎯 Changes

Add tests to cover the isRestoring branch in useQueries.ts (lines 235, 272).

When IsRestoringProvider provides true, queries should remain in pending status with fetchStatus: 'idle' and never call queryFn, even after the query's sleep duration has elapsed.

Two test cases added:

  • Queries with the same duration should not fetch during the restoring period
  • Queries with different durations should not fetch during the restoring period

✅ 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).

@changeset-bot
Copy link

changeset-bot bot commented Feb 27, 2026

⚠️ No Changeset found

Latest commit: da6fa1f

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

@nx-cloud
Copy link

nx-cloud bot commented Feb 27, 2026

View your CI Pipeline Execution ↗ for commit da6fa1f

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

☁️ Nx Cloud last updated this comment at 2026-02-27 02:17:40 UTC

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0da627b and da6fa1f.

📒 Files selected for processing (1)
  • packages/react-query/src/__tests__/useQueries.test.tsx

📝 Walkthrough

Walkthrough

This PR adds test coverage for the useQueries hook to verify that queries do not fetch while isRestoring is active, including scenarios with identical and different query durations. Additionally, IsRestoringProvider is exposed as part of the public API.

Changes

Cohort / File(s) Summary
Test Coverage for isRestoring State
packages/react-query/src/__tests__/useQueries.test.tsx
Added two test cases asserting that queries do not fetch during the restoring period, with one covering identical query durations and another covering different durations. Introduced IsRestoringProvider import to simulate the restoring state in tests.
Public API Export
packages/react-query/src/index.ts or equivalent
Exposed IsRestoringProvider as part of the library's public exports to make it available for consumer use.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • TkDodo
  • manudeli

Poem

🐰 A restoring whisper, queries pause with care,
IsRestoringProvider floats through the air,
Tests multiply fast, with durations aligned,
Public API grows, a treasure we find!

🚥 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 accurately describes the main change: adding tests for isRestoring behavior to cover the restoring period branch in useQueries, which aligns with the changeset.
Description check ✅ Passed The description comprehensively covers all required sections including changes, checklist items, and release impact, with clear explanation of branch coverage improvements.

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

✨ Finishing Touches
🧪 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.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 27, 2026

More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/preact-query

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: da6fa1f

@sukvvon sukvvon changed the title test(react-query/useQueries): add test for 'isRestoring' to cover restoring period branch test(react-query/useQueries): add test for not fetching during restoring period when 'isRestoring' is true Feb 27, 2026
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