Skip to content

test(query-core/mutationCache): add test for removing a mutation that does not exist in the cache#10423

Merged
sukvvon merged 2 commits intomainfrom
test/query-core-mutationCache-add-remove-test
Apr 7, 2026
Merged

test(query-core/mutationCache): add test for removing a mutation that does not exist in the cache#10423
sukvvon merged 2 commits intomainfrom
test/query-core-mutationCache-add-remove-test

Conversation

@sukvvon
Copy link
Copy Markdown
Collaborator

@sukvvon sukvvon commented Apr 7, 2026

🎯 Changes

  • Add test to verify that MutationCache.remove() still notifies removal when called on a mutation that has already been removed from the cache
  • Covers the #mutations.delete(mutation) returning false branch in mutationCache.ts:138
  • This scenario can occur when gcTime expiration and manual removal happen simultaneously

✅ 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 mutation cache removal behavior, verifying correct notification handling when removal operations occur multiple times on the same mutation, and ensuring proper subscription lifecycle management.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 7, 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: b5386c91-7bab-4ca6-b3a0-88f3c41b92b3

📥 Commits

Reviewing files that changed from the base of the PR and between f699190 and 7698b27.

📒 Files selected for processing (1)
  • packages/query-core/src/__tests__/mutationCache.test.tsx

📝 Walkthrough

Walkthrough

Added a new test case to the MutationCache.remove() test suite that verifies subscriber notification behavior when removal is called twice for the same mutation, ensuring the cache is empty after the first removal and validating the callback event object structure.

Changes

Cohort / File(s) Summary
MutationCache removal notification tests
packages/query-core/src/__tests__/mutationCache.test.tsx
Added test case verifying double removal behavior, including cache state after first removal and subscriber callback validation with explicit subscription lifecycle management.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

Poem

🐰 A test hops in, twice removal's the game,
Cache checks and callbacks, all noted the same,
Unsubscribe's dance, so graceful and clean,
The finest mutations cache ever seen! 🎉

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding a test for removing a mutation that does not exist in the cache.
Description check ✅ Passed The description covers all required sections with specific details about changes, follows the template structure, and appropriately marks release impact as dev-only.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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-core-mutationCache-add-remove-test

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

@nx-cloud
Copy link
Copy Markdown

nx-cloud bot commented Apr 7, 2026

View your CI Pipeline Execution ↗ for commit 7698b27

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

☁️ Nx Cloud last updated this comment at 2026-04-07 16:32:05 UTC

@sukvvon sukvvon self-assigned this Apr 7, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 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 Apr 7, 2026

More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 7698b27

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

size-limit report 📦

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

@sukvvon sukvvon merged commit 79dee50 into main Apr 7, 2026
8 checks passed
@sukvvon sukvvon deleted the test/query-core-mutationCache-add-remove-test branch April 7, 2026 16:33
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