Skip to content

test(query-persist-client-core/persist): add test for ignoring mutation observer events in 'persistQueryClientSubscribe'#10880

Merged
sukvvon merged 1 commit into
mainfrom
test/query-persist-client-core-save-ignore-mutation-observer-events
Jun 4, 2026
Merged

test(query-persist-client-core/persist): add test for ignoring mutation observer events in 'persistQueryClientSubscribe'#10880
sukvvon merged 1 commit into
mainfrom
test/query-persist-client-core-save-ignore-mutation-observer-events

Conversation

@sukvvon
Copy link
Copy Markdown
Collaborator

@sukvvon sukvvon commented Jun 4, 2026

🎯 Changes

Adds a unit test for persistQueryClientSubscribe covering the mutation cache subscription: events fired by manipulating a mutation observer (e.g. observerAdded, observerOptionsUpdated, observerRemoved) are not cache events, so they must not trigger a persist.

This mirrors the existing query-observer test and covers the previously-untested isCacheEventType guard on the mutation cache subscription.

✅ 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
    • Enhanced test coverage for query client persistence behavior with mutation observer events.

…on observer events in 'persistQueryClientSubscribe'
@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: 2daeae01-25f5-4c95-b56b-3a126f383edf

📥 Commits

Reviewing files that changed from the base of the PR and between 0c7b9d6 and cb27b71.

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

📝 Walkthrough

Walkthrough

The PR adds a test case to the query persist client test suite that verifies persistQueryClientSubscribe does not persist when only mutation observer events occur. The required MutationObserver import is added to support the test.

Changes

Mutation Observer Non-Persistence Test

Layer / File(s) Summary
Mutation observer non-persistence test
packages/query-persist-client-core/src/__tests__/persist.test.ts
MutationObserver import is added; a test case verifies that persistQueryClientSubscribe does not call persister.persistClient when mutation observer events are produced by subscribing, setting mutation options, and unsubscribing.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • TanStack/query#10878: Both PRs update persist test coverage—one guards against persistence on mutation-observer-only events, the other validates restore-then-subscribe and early-unsubscribe scenarios.
  • TanStack/query#10875: Both PRs modify the persistQueryClientSubscribe test suite structure and add subscription-related test coverage.
  • TanStack/query#10869: Both PRs add test cases around persisted mutation handling to ensure mutations do not trigger unwanted persistence behaviors.

Poem

🐰 A rabbit hops through tests so bright,
MutationObserver stays out of sight,
Persistence sleeps when mutations dance,
The coverage grows with each new chance!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and specifically describes the main change: adding a test that verifies mutation observer events are ignored in persistQueryClientSubscribe.
Description check ✅ Passed The description follows the template structure with all required sections completed: Changes section explains the test purpose, Checklist items are marked appropriately, and Release Impact correctly indicates this is a dev-only change.
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-save-ignore-mutation-observer-events

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 cb27b71

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

☁️ Nx Cloud last updated this comment at 2026-06-04 05:39:26 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.

@sukvvon sukvvon self-assigned this Jun 4, 2026
@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@10880

@tanstack/eslint-plugin-query

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

@tanstack/lit-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: cb27b71

@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 79e639e into main Jun 4, 2026
9 checks passed
@sukvvon sukvvon deleted the test/query-persist-client-core-save-ignore-mutation-observer-events branch June 4, 2026 05:40
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