Skip to content

test(query-persist-client-core/persist): add test for removing a cache without a timestamp in 'persistQueryClientRestore'#10877

Merged
sukvvon merged 1 commit into
mainfrom
test/query-persist-client-core-restore-missing-timestamp
Jun 4, 2026
Merged

test(query-persist-client-core/persist): add test for removing a cache without a timestamp in 'persistQueryClientRestore'#10877
sukvvon merged 1 commit into
mainfrom
test/query-persist-client-core-restore-missing-timestamp

Conversation

@sukvvon
Copy link
Copy Markdown
Collaborator

@sukvvon sukvvon commented Jun 4, 2026

🎯 Changes

Adds a unit test for persistQueryClientRestore covering the case where the persisted client has no timestamp: the client is removed instead of being hydrated.

✅ 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 for query client persistence restoration edge-case handling.

…e without a timestamp in 'persistQueryClientRestore'
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 4, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0127b50c-e6e2-449a-b281-34aaedb95704

📥 Commits

Reviewing files that changed from the base of the PR and between 89bae56 and c9b9956.

📒 Files selected for processing (1)
  • packages/query-persist-client-core/src/__tests__/persist.test.ts

📝 Walkthrough

Walkthrough

This PR adds a single unit test to the persistQueryClientRestore test suite. The test verifies that when the persisted cache has timestamp: 0 (indicating no usable timestamp), the function correctly calls persister.removeClient() to remove the stale client without relying on maxAge or buster options.

Changes

Zero-timestamp cache removal test

Layer / File(s) Summary
Zero-timestamp cache removal verification
packages/query-persist-client-core/src/__tests__/persist.test.ts
Test case validates that persistQueryClientRestore calls persister.removeClient() exactly once when restoreClient() returns a persisted payload with timestamp: 0.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • TanStack/query#10872: Adds related persistQueryClientRestore unit tests covering restore behavior for different persisted-cache cases (valid timestamp vs timestamp: 0).
  • TanStack/query#10874: Modifies the same persistQueryClientRestore test suite with setup/teardown refactoring and assertions for removeClient behavior.
  • TanStack/query#10876: Adds similar unit tests for persistQueryClientRestore asserting persister.removeClient is called for invalid persisted cache states.

Poem

🐰 A test hops in, so simple and bright,
When timestamp is zero, we'll clean it right!
removeClient called, assertion holds true—
One happy validator, shiny and new!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding a test for removing cache without timestamp in persistQueryClientRestore.
Description check ✅ Passed The description follows the template structure with all required sections completed, including clear explanation of changes and proper checklist responses.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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/query-persist-client-core-restore-missing-timestamp

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

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Jun 4, 2026

View your CI Pipeline Execution ↗ for commit c9b9956

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

☁️ Nx Cloud last updated this comment at 2026-06-04 04:45:06 UTC

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

🚀 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 Jun 4, 2026

More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/lit-query

npm i https://pkg.pr.new/@tanstack/lit-query@10877

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: c9b9956

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

size-limit report 📦

Path Size
react full 12.11 KB (0%)
react minimal 9.08 KB (0%)

@sukvvon sukvvon merged commit 5fcb4d7 into main Jun 4, 2026
9 checks passed
@sukvvon sukvvon deleted the test/query-persist-client-core-restore-missing-timestamp branch June 4, 2026 04:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant