Skip to content

test(query-persist-client-core/persist): add tests for 'persistQueryClient' restore-then-subscribe flow#10878

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

test(query-persist-client-core/persist): add tests for 'persistQueryClient' restore-then-subscribe flow#10878
sukvvon merged 1 commit into
mainfrom
test/query-persist-client-core-persist-query-client

Conversation

@sukvvon
Copy link
Copy Markdown
Collaborator

@sukvvon sukvvon commented Jun 4, 2026

🎯 Changes

Adds unit tests for persistQueryClient, which previously had no test coverage. The tests cover its two-step flow:

  • After a successful restore, it subscribes to the query cache so subsequent changes are persisted.
  • When unsubscribe is called before the restore completes, it never subscribes (the early-unsubscribe guard).

✅ 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 persistence functionality, including validation of persistence subscription initialization after successful restoration and verification of proper cleanup behavior when operations are cancelled.

@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: 46558fd9-76e8-4b71-bbed-94fb6074bbc1

📥 Commits

Reviewing files that changed from the base of the PR and between 5fcb4d7 and 3838f8c.

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

📝 Walkthrough

Walkthrough

New tests for persistQueryClient verify that after restoring completes, persistence starts and queries trigger persist callbacks, and that calling unsubscribe before restore resolves prevents persistence from ever starting.

Changes

persistQueryClient Tests

Layer / File(s) Summary
persistQueryClient behavior tests
packages/query-persist-client-core/src/__tests__/persist.test.ts
Import of persistQueryClient added. New test suite with two async cases: first verifies persistence activates and persists updates after restore resolves; second verifies unsubscribe before restore completion prevents persistence subscription.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Hop hooray! Tests now hop along,
Checking if restore and persist work strong,
Subscriptions dance, unsubscribe sings clear,
Promise timing—all verified here! 🌟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding tests for the 'persistQueryClient' restore-then-subscribe flow.
Description check ✅ Passed The description follows the template structure with all required sections completed: Changes, Checklist (with items checked), and Release Impact clearly marked as dev-only.
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-persist-query-client

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 3838f8c

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

☁️ Nx Cloud last updated this comment at 2026-06-04 05:18:58 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@10878

@tanstack/eslint-plugin-query

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

@tanstack/lit-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 3838f8c

@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 self-assigned this Jun 4, 2026
@sukvvon sukvvon merged commit 0c7b9d6 into main Jun 4, 2026
9 checks passed
@sukvvon sukvvon deleted the test/query-persist-client-core-persist-query-client branch June 4, 2026 05:31
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