Skip to content

test({react,preact}-query/useMutation): unify destructuring pattern in complex scenario tests#10494

Merged
sukvvon merged 1 commit intomainfrom
test/useMutation-destructure-pattern
Apr 14, 2026
Merged

test({react,preact}-query/useMutation): unify destructuring pattern in complex scenario tests#10494
sukvvon merged 1 commit intomainfrom
test/useMutation-destructure-pattern

Conversation

@sukvvon
Copy link
Copy Markdown
Collaborator

@sukvvon sukvvon commented Apr 14, 2026

🎯 Changes

Apply destructuring pattern to complex scenario tests for consistency with existing tests in the file.

✅ 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
    • Refactored test usage patterns for mutation hooks in both preact-query and react-query packages to improve test code clarity and maintainability.

Note: No user-visible changes in this update.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 14, 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: e8491f4e-1269-476c-916e-0241a6f527a5

📥 Commits

Reviewing files that changed from the base of the PR and between aad1bd5 and 27a0ee9.

📒 Files selected for processing (2)
  • packages/preact-query/src/__tests__/useMutation.test.tsx
  • packages/react-query/src/__tests__/useMutation.test.tsx

📝 Walkthrough

Walkthrough

Two test files refactored to destructure specific mutation functions (mutateAsync, mutate) directly from useMutation results rather than storing whole mutation objects and calling methods on them. Event handlers updated to invoke the destructured functions with preserved callback options.

Changes

Cohort / File(s) Summary
Test Refactoring - Mutation Destructuring
packages/preact-query/src/__tests__/useMutation.test.tsx, packages/react-query/src/__tests__/useMutation.test.tsx
Replaced mutation result object variables with destructured mutation functions ({ mutateAsync } aliased to action names, { mutate }). Updated click handlers to invoke destructured functions directly while maintaining existing per-call options and callbacks (onSuccess, onError, onSettled).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 Mutations now flow more clear,
Functions plucked, no wrapper here,
Destructuring brings light and ease,
Tests refactor with such breeze,
Simpler code, the way to go! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: applying a destructuring pattern unification to useMutation tests in both react and preact query packages.
Description check ✅ Passed The description follows the template structure with completed sections for Changes and Checklist, and properly indicates this is a dev-only change requiring no changeset.

✏️ 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/useMutation-destructure-pattern

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

@sukvvon sukvvon self-assigned this Apr 14, 2026
@nx-cloud
Copy link
Copy Markdown

nx-cloud bot commented Apr 14, 2026

View your CI Pipeline Execution ↗ for commit 27a0ee9

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

☁️ Nx Cloud last updated this comment at 2026-04-14 01:30:05 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 14, 2026

More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 27a0ee9

@github-actions
Copy link
Copy Markdown
Contributor

size-limit report 📦

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

@sukvvon sukvvon merged commit bc83d37 into main Apr 14, 2026
10 checks passed
@sukvvon sukvvon deleted the test/useMutation-destructure-pattern branch April 14, 2026 01:35
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