Skip to content

test(query-devtools/Devtools): add tests for query details panel and query actions#10685

Merged
sukvvon merged 4 commits intomainfrom
test/query-devtools-devtools-query-actions
May 10, 2026
Merged

test(query-devtools/Devtools): add tests for query details panel and query actions#10685
sukvvon merged 4 commits intomainfrom
test/query-devtools-devtools-query-actions

Conversation

@sukvvon
Copy link
Copy Markdown
Collaborator

@sukvvon sukvvon commented May 10, 2026

🎯 Changes

Add tests for the query details panel and the action buttons that operate on the selected query.

query details — opening and closing the details panel:

  • Opens the query details panel when a query row is clicked.
  • Closes the details panel when the same row is clicked again (toggle).

query actions — buttons inside the details panel:

  • Remove removes the query from the cache.
  • Reset resets the query data to undefined.
  • Invalidate marks the query as invalidated.
  • Refetch dispatches a 'REFETCH' event.
  • Trigger Error sets the query status to 'error'.
  • Restore Error restores the query status from 'error'.

✅ 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 test coverage for the Query Details panel toggling and for Query Actions (Remove, Reset, Invalidate, Refetch, Trigger/Restore Error), verifying cache/state changes, status transitions, and that Refetch dispatches the expected devtools event.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 10, 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: 22c0a82d-12d6-43cb-b05e-28ea36cc2f48

📥 Commits

Reviewing files that changed from the base of the PR and between 4925096 and e7b6206.

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

📝 Walkthrough

Walkthrough

Adds tests to Devtools verifying the Query Details panel toggles on row clicks and that details-panel action buttons (Remove, Reset, Invalidate, Refetch, Trigger Error, Restore Error) update QueryClient state and emit the expected devtools event for refetch.

Changes

Devtools Query Interaction Tests

Layer / File(s) Summary
Query Details Panel Tests
packages/query-devtools/src/__tests__/Devtools.test.tsx
Tests verify that clicking a query row opens the Query Details panel and clicking the same row closes it.
Query Actions Tests
packages/query-devtools/src/__tests__/Devtools.test.tsx
Tests validate UI-driven cache/state operations: Remove, Reset, Invalidate, Refetch (with event dispatch), Trigger Error, and Restore Error buttons.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • TanStack/query#10683: Adds tests to the same Devtools test file targeting UI behavior patterns (open/close and query details/actions interactions).

Poem

🐰 I hopped through tests with eager paws,
Clicked the row to open jaws,
Buttons pressed — reset, refetch, and mend,
Errors fall and then ascend,
A tiny hop for test, a bright green pass.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main change: adding tests for the query details panel and query actions in the Devtools component.
Description check ✅ Passed The description follows the repository template, includes all required sections, provides clear details about the changes, has completed checklist items, and correctly marks the PR as dev-only.
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-devtools-devtools-query-actions

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

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented May 10, 2026

View your CI Pipeline Execution ↗ for commit 615d81d

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

☁️ Nx Cloud last updated this comment at 2026-05-10 15:46:29 UTC

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 10, 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 May 10, 2026

More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/lit-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: e7b6206

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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/query-devtools/src/__tests__/Devtools.test.tsx`:
- Around line 487-489: The test uses a single element reference "row" from
rendered.getByLabelText(...) for two clicks which can become stale after a
rerender; change the second click to re-query the DOM (call
rendered.getByLabelText(/Query key \["details-toggle"\]/) again) before firing
the second fireEvent.click to ensure you operate on the current node and catch
rerender-related regressions.
- Around line 564-577: The assertion in the test "should restore the query
status when \"Restore Error\" is clicked after \"Trigger Error\"" is too
lax—replace the negative check with an exact expected status (e.g., assert
queryClient.getQueryState(['action-restore-error'])?.status === 'success' or the
intended exact state) so the test fails if restore lands in the wrong state;
update the expectation in the test block that uses
queryClient.getQueryState(['action-restore-error'])?.status to toBe('success')
(or the precise expected status) and optionally verify the query data if needed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bec0b1b5-ab5e-482e-ab48-dcb3c555d959

📥 Commits

Reviewing files that changed from the base of the PR and between ac57627 and 4925096.

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

Comment thread packages/query-devtools/src/__tests__/Devtools.test.tsx Outdated
Comment thread packages/query-devtools/src/__tests__/Devtools.test.tsx
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 10, 2026

size-limit report 📦

Path Size
react full 12.1 KB (0%)
react minimal 9.07 KB (0%)

@sukvvon sukvvon self-assigned this May 10, 2026
@sukvvon sukvvon merged commit abdc308 into main May 10, 2026
8 checks passed
@sukvvon sukvvon deleted the test/query-devtools-devtools-query-actions branch May 10, 2026 15:47
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