Skip to content

test({react,preact}-query/useSuspenseQueries): add test for not suspending but only refetching the stale query when one query has stale and the other has fresh cached data#10349

Merged
sukvvon merged 1 commit intomainfrom
test/useSuspenseQueries-stale-fresh-mixed-cache
Mar 29, 2026
Merged

Conversation

@sukvvon
Copy link
Copy Markdown
Collaborator

@sukvvon sukvvon commented Mar 29, 2026

🎯 Changes

Add a test case for useSuspenseQueries that verifies no suspension occurs and only the stale query is refetched in the background when one query has stale cached data and the other has fresh cached data (the reverse order of #10345).

✅ 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 test cases validating query behavior when multiple queries have mixed data freshness states, ensuring components render without suspending and background refetches occur only for stale queries while fresh queries remain unaffected.

…nding but only refetching the stale query when one query has stale and the other has fresh cached data
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 29, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7d967340-ff24-4adc-9e7d-98603cd8d7d4

📥 Commits

Reviewing files that changed from the base of the PR and between 289fe2e and 48dd473.

📒 Files selected for processing (2)
  • packages/preact-query/src/__tests__/useSuspenseQueries.test.tsx
  • packages/react-query/src/__tests__/useSuspenseQueries.test.tsx

📝 Walkthrough

Walkthrough

Added identical test cases to both react-query and preact-query packages verifying that useSuspenseQueries does not suspend when queries have mixed staleness states (one stale, one fresh) and only triggers background refetch for stale queries.

Changes

Cohort / File(s) Summary
Test case additions for useSuspenseQueries mixed staleness behavior
packages/react-query/src/__tests__/useSuspenseQueries.test.tsx, packages/preact-query/src/__tests__/useSuspenseQueries.test.tsx
Added identical test cases (+68 lines each) verifying that when multiple queries have mixed staleness (one stale, one fresh), the hook renders immediately without suspending and only refetches the stale query.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related PRs

  • #10345: Adds the same mixed fresh/stale useSuspenseQueries test case to verify no suspension behavior.
  • #10202: Adds related useSuspenseQueries tests verifying no suspension when all queries are fresh with background refetch behavior.
  • #10126: Adds related useSuspenseQueries tests for mixed cached vs pending query scenarios with refetch verification.

Suggested labels

package: react-query, package: preact-query

Suggested reviewers

  • TkDodo

Poem

🐰 A test for freshness, a test for the stale,
Where queries mix young and old without fail,
No suspense shall occur when one's dated, one's new,
Just background refresh for the query that's due! ✨

🚥 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 directly describes the main change: adding a test for useSuspenseQueries that verifies no suspension occurs and only the stale query is refetched when mixing stale and fresh cached data.
Description check ✅ Passed The description follows the template with all required sections completed: changes are clearly explained with context (#10345 reference), both checklist items are properly marked, and release impact is correctly identified as dev-only with the checkbox appropriately marked.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/useSuspenseQueries-stale-fresh-mixed-cache

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

@sukvvon sukvvon self-assigned this Mar 29, 2026
@nx-cloud
Copy link
Copy Markdown

nx-cloud bot commented Mar 29, 2026

View your CI Pipeline Execution ↗ for commit 48dd473

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

☁️ Nx Cloud last updated this comment at 2026-03-29 05:42:17 UTC

@github-actions
Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

No changeset entries found. Merging this PR will not cause a version bump for any packages.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 29, 2026

More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

npm i https://pkg.pr.new/@tanstack/preact-query-persist-client@10349

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 48dd473

@github-actions
Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
react full 11.98 KB (0%)
react minimal 9.01 KB (0%)

@sukvvon sukvvon merged commit 55cee0a into main Mar 29, 2026
10 checks passed
@sukvvon sukvvon deleted the test/useSuspenseQueries-stale-fresh-mixed-cache branch March 29, 2026 05:50
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