Skip to content

test(react-query/suspense): add test cases for 'static' staleTime with number and function#10089

Open
sukvvon wants to merge 1 commit intoTanStack:mainfrom
sukvvon:test/react-query-suspense-static-stale-time
Open

test(react-query/suspense): add test cases for 'static' staleTime with number and function#10089
sukvvon wants to merge 1 commit intoTanStack:mainfrom
sukvvon:test/react-query-suspense-static-stale-time

Conversation

@sukvvon
Copy link
Contributor

@sukvvon sukvvon commented Feb 3, 2026

🎯 Changes

Add test cases for 'static' staleTime in ensureSuspenseTimers to cover the clamp branch that preserves 'static' value as-is.

  • staleTime: 'static' (number type)
  • staleTime: () => 'static' (function type)
  • Use StaleTime type from @tanstack/query-core instead of inline type

✅ 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 coverage validating that staleTime configuration is correctly preserved when using static values and function-based approaches, ensuring proper cache behavior across different input types.

@changeset-bot
Copy link

changeset-bot bot commented Feb 3, 2026

⚠️ No Changeset found

Latest commit: f3588c5

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 3, 2026

📝 Walkthrough

Walkthrough

Type import added for StaleTime from query-core. Updated staleTime parameter type signature in createTestQuery to use StaleTime type. Two new test cases introduced to verify staleTime caching behavior with string literals and function returns.

Changes

Cohort / File(s) Summary
Test Updates
packages/react-query/src/__tests__/suspense.test.tsx
Added StaleTime type import, updated staleTime parameter type signature from number | (() => number) to StaleTime | (() => StaleTime), and introduced two new test cases verifying staleTime preservation with static strings and function returns.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested labels

package: react-query

Suggested reviewers

  • manudeli

Poem

🐰 A rabbit hops through test files with glee,
Adding string staleTime for all to see,
Type safety blooms like clover so sweet,
Cache behavior verified—a review complete! ✨

🚥 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 test cases for 'static' staleTime with both number and function variants in the suspense tests.
Description check ✅ Passed The description follows the template structure with completed 🎯 Changes and ✅ Checklist sections, plus 🚀 Release Impact clearly marked as dev-only.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Important

Action Needed: IP Allowlist Update

If your organization protects your Git platform with IP whitelisting, please add the new CodeRabbit IP address to your allowlist:

  • 136.113.208.247/32 (new)
  • 34.170.211.100/32
  • 35.222.179.152/32

Failure to add the new IP will result in interrupted reviews.


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

@nx-cloud
Copy link

nx-cloud bot commented Feb 3, 2026

View your CI Pipeline Execution ↗ for commit f3588c5

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

☁️ Nx Cloud last updated this comment at 2026-02-03 14:32:49 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 3, 2026

More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: f3588c5

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