Skip to content

test(vue-query/mutationOptions): add 'queryClient.isMutating' tests for getter overloads#10471

Merged
sukvvon merged 1 commit intomainfrom
test/vue-query-mutationOptions-getter-queryClient-isMutating
Apr 13, 2026
Merged

test(vue-query/mutationOptions): add 'queryClient.isMutating' tests for getter overloads#10471
sukvvon merged 1 commit intomainfrom
test/vue-query-mutationOptions-getter-queryClient-isMutating

Conversation

@sukvvon
Copy link
Copy Markdown
Collaborator

@sukvvon sukvvon commented Apr 13, 2026

🎯 Changes

  • Add 4 runtime tests for mutationOptions getter overloads with queryClient.isMutating:
    • should return the number of fetching mutations when used with queryClient.isMutating (getter with mutationKey in mutationOptions)
    • should return the number of fetching mutations when used with queryClient.isMutating (getter without mutationKey in mutationOptions)
    • should return the number of fetching mutations when used with queryClient.isMutating (getter): multiple mutations with getter
    • should return the number of fetching mutations when used with queryClient.isMutating (getter, filter mutationOpts1.mutationKey): filter by mutationKey with getter

✅ 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 four test cases validating mutation state tracking and reporting behavior across various usage scenarios, including mutations with and without keys, concurrent execution, filtering by keys, and verification of correct state reporting during active mutations and proper cleanup after completion.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 13, 2026

📝 Walkthrough

Walkthrough

Four new Vitest test cases were added to validate queryClient.isMutating behavior when mutationOptions are provided as getter functions. Tests verify proper concurrent mutation counting in various scenarios including with/without mutation keys and key-based filtering.

Changes

Cohort / File(s) Summary
Test Suite Expansion
packages/vue-query/src/__tests__/mutationOptions.test.ts
Added four comprehensive test cases validating queryClient.isMutating counting behavior when mutationOptions are getter functions, covering getter with/without mutationKey, concurrent calls, and filtered mutation key tracking.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested labels

package: vue-query

Poem

🐰 With getters and mutations we test,
Counting the promises in flight,
Four cases ensure we know best,
When zero returns, all is right!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding tests for queryClient.isMutating behavior with mutationOptions getter overloads.
Description check ✅ Passed The description includes all required template sections with specific test names listed, checklist items properly marked, and release impact clearly indicated 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/vue-query-mutationOptions-getter-queryClient-isMutating

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

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Apr 13, 2026

View your CI Pipeline Execution ↗ for commit f4ff840

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

☁️ Nx Cloud last updated this comment at 2026-04-13 02:45:08 UTC

@github-actions
Copy link
Copy Markdown
Contributor

🚀 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 13, 2026

More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: f4ff840

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

size-limit report 📦

Path Size
react full 11.99 KB (0%)
react minimal 9.02 KB (0%)

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/vue-query/src/__tests__/mutationOptions.test.ts (1)

353-480: Consider extracting a small helper for the repeated subscribe/assert flow.

These four tests duplicate the same setup and assertion pattern; a helper would reduce maintenance cost and keep future additions tighter.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/vue-query/src/__tests__/mutationOptions.test.ts` around lines 353 -
480, The four tests duplicate subscribing to the mutation cache and asserting
isMutating changes; extract a small helper (e.g., runMutatingSubscribeTest) that
accepts parameters like an array of mutationOptions factories (mutationOptions),
an optional filter/options object (for mutationKey), and expected max value,
then encapsulate the common flow: create queryClient via useQueryClient, resolve
any provided mutationOptions (resolvedOpts), call useMutation for each option to
get mutate functions, subscribe to queryClient.getMutationCache().subscribe to
push queryClient.isMutating(filter?) into a local array, invoke the mutate
functions, advance timers (vi.advanceTimersByTimeAsync), assert
Math.max(...array) and final array tail equals 0, and unsubscribe; replace the
four duplicated test bodies to call this helper with appropriate arguments
(single getter with/without mutationKey, two concurrent mutations, and filtered
mutationKey case).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/vue-query/src/__tests__/mutationOptions.test.ts`:
- Around line 353-480: The four tests duplicate subscribing to the mutation
cache and asserting isMutating changes; extract a small helper (e.g.,
runMutatingSubscribeTest) that accepts parameters like an array of
mutationOptions factories (mutationOptions), an optional filter/options object
(for mutationKey), and expected max value, then encapsulate the common flow:
create queryClient via useQueryClient, resolve any provided mutationOptions
(resolvedOpts), call useMutation for each option to get mutate functions,
subscribe to queryClient.getMutationCache().subscribe to push
queryClient.isMutating(filter?) into a local array, invoke the mutate functions,
advance timers (vi.advanceTimersByTimeAsync), assert Math.max(...array) and
final array tail equals 0, and unsubscribe; replace the four duplicated test
bodies to call this helper with appropriate arguments (single getter
with/without mutationKey, two concurrent mutations, and filtered mutationKey
case).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8cefcf08-c635-44e6-8eca-1846f371ed4c

📥 Commits

Reviewing files that changed from the base of the PR and between 70a216d and f4ff840.

📒 Files selected for processing (1)
  • packages/vue-query/src/__tests__/mutationOptions.test.ts

@sukvvon sukvvon merged commit 8fc02cc into main Apr 13, 2026
10 checks passed
@sukvvon sukvvon deleted the test/vue-query-mutationOptions-getter-queryClient-isMutating branch April 13, 2026 02:49
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