Skip to content

test({react,preact}-query-devtools): assert the forwarded 'onClose' callback in the panel instead of 'expect.any(Function)'#11029

Merged
sukvvon merged 1 commit into
mainfrom
test/react-preact-query-devtools-onclose-assertion
Jul 4, 2026
Merged

test({react,preact}-query-devtools): assert the forwarded 'onClose' callback in the panel instead of 'expect.any(Function)'#11029
sukvvon merged 1 commit into
mainfrom
test/react-preact-query-devtools-onclose-assertion

Conversation

@sukvvon

@sukvvon sukvvon commented Jul 4, 2026

Copy link
Copy Markdown
Member

🎯 Changes

The panel's onClose tests both asserted expect.any(Function), so the "forward" and "default" cases were indistinguishable and could not catch a regression in the props.onClose ?? (() => {}) defaulting logic (any function satisfies the assertion).

  • Forward test: now asserts the exact onClose callback is forwarded (toHaveBeenCalledWith(onClose)) instead of any function.
  • Default test: now captures the forwarded argument and verifies it is a callable no-op (invoking it does not throw and returns undefined) instead of any function.

✅ 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
    • Strengthened test coverage for devtools panel close behavior.
    • Verified the close callback is passed through exactly as expected.
    • Added checks that the default close callback is a function and safely returns no value when called.

…allback in the panel instead of 'expect.any(Function)'
@nx-cloud

nx-cloud Bot commented Jul 4, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 2038463

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

☁️ Nx Cloud last updated this comment at 2026-07-04 15:15:06 UTC

@sukvvon sukvvon self-assigned this Jul 4, 2026
@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

No changeset entries found. Merging this PR will not cause a version bump for any packages.

@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

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: efc59445-04f1-4066-bf42-6f0d339506cc

📥 Commits

Reviewing files that changed from the base of the PR and between 27e680f and 2038463.

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

📝 Walkthrough

Walkthrough

Test files for PreactQueryDevtoolsPanel and ReactQueryDevtoolsPanel were updated to strengthen onClose-related assertions: forwarding tests now check the exact callback, and default-omission tests now verify the forwarded value is a function that returns undefined when invoked.

Changes

onClose Test Assertion Updates

Layer / File(s) Summary
Preact devtools panel onClose tests
packages/preact-query-devtools/src/__tests__/PreactQueryDevtoolsPanel.test.tsx
Default onClose test now asserts the forwarded value is a Function and that invoking it returns undefined, replacing a generic expect.any(Function) check.
React devtools panel onClose tests
packages/react-query-devtools/src/__tests__/ReactQueryDevtoolsPanel.test.tsx
Forwarding test now asserts the exact onClose callback was passed; default test extracts the forwarded callback, asserts it is a Function, and confirms invoking it returns undefined.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Possibly related PRs

  • TanStack/query#10827: Both PRs update unit tests to verify onClose prop forwarding and default behavior for their respective devtools panel wrappers.
  • TanStack/query#10851: Both PRs strengthen ReactQueryDevtoolsPanel onClose wiring assertions.
  • TanStack/query#10852: Both PRs tighten PreactQueryDevtoolsPanel onClose defaulting/forwarding tests.

Suggested labels: package: query-devtools

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately summarizes the main test-only change to onClose forwarding in the React/Preact devtools panels.
Description check ✅ Passed The description follows the template and includes the required changes, checklist, and release impact sections with clear details.
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.
✨ 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/react-preact-query-devtools-onclose-assertion

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

@pkg-pr-new

pkg-pr-new Bot commented Jul 4, 2026

Copy link
Copy Markdown
More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/lit-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 2038463

@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
react full 12.13 KB (0%)
react minimal 9.08 KB (0%)

@sukvvon sukvvon merged commit c476781 into main Jul 4, 2026
9 checks passed
@sukvvon sukvvon deleted the test/react-preact-query-devtools-onclose-assertion branch July 4, 2026 15:20
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