Skip to content

test(query-devtools/Devtools): add test for hiding the panel when the 'TANSTACK' logo is clicked#10693

Merged
sukvvon merged 1 commit intomainfrom
test/query-devtools-devtools-logo-close
May 11, 2026
Merged

test(query-devtools/Devtools): add test for hiding the panel when the 'TANSTACK' logo is clicked#10693
sukvvon merged 1 commit intomainfrom
test/query-devtools-devtools-logo-close

Conversation

@sukvvon
Copy link
Copy Markdown
Collaborator

@sukvvon sukvvon commented May 11, 2026

🎯 Changes

Adds a test for Devtools.tsx covering:

  • should hide the panel when the TanStack logo is clicked

The TanStack logo doubles as a close button and triggers setLocalStore('open', 'false') when no PiP window or panel-only mode is active.

✅ 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 devtools panel close functionality when triggering the logo control action.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 11, 2026

📝 Walkthrough

Walkthrough

This PR adds a test suite that verifies clicking the TanStack logo control closes and removes the devtools panel from the DOM.

Changes

Logo Close Test Suite

Layer / File(s) Summary
Logo Close Test
packages/query-devtools/src/__tests__/Devtools.test.tsx
New test suite describe('logo close') clicks the TanStack logo control and asserts the "Tanstack query devtools" panel is removed from the document.

Possibly related PRs

Suggested labels

package: query-devtools

Poem

🐰 A test clicks the logo bright,
Closing panels left and right,
The devtools fade from view,
Verified clean and true! ✨

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately describes the main change: adding a test for the logo close functionality in the Devtools component.
Description check ✅ Passed The description follows the template structure with all required sections completed, including a clear explanation of the change, checked checklist items, and release impact assessment.
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-logo-close

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

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented May 11, 2026

View your CI Pipeline Execution ↗ for commit e81505d

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

☁️ Nx Cloud last updated this comment at 2026-05-11 02:51:38 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 May 11, 2026

More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/lit-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: e81505d

@github-actions
Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
react full 12.1 KB (0%)
react minimal 9.07 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.

Actionable comments posted: 1

🤖 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 1093-1103: The test currently clicks the logo via fireEvent on the
element found by getByLabelText('Close Tanstack query devtools') and checks the
panel is removed; extend this to also assert that localStorage now stores
'false' for the 'open' key (verify localStorage.getItem('open') === 'false' or
that the mock setItem was called with ('open','false')), and then assert the
open-button is rendered again (query/getByLabelText for the open button label
used elsewhere, e.g. 'Open Tanstack query devtools') to match the existing
close-button tests; update the test after the fireEvent.click in the describe
block around renderDevtools to include these two assertions.
🪄 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: a55bfea2-188b-444a-b470-c713a3c22b02

📥 Commits

Reviewing files that changed from the base of the PR and between c84c9d0 and e81505d.

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

Comment on lines +1093 to +1103
describe('logo close', () => {
it('should hide the panel when the TanStack logo is clicked', () => {
const rendered = renderDevtools({ initialIsOpen: true })

fireEvent.click(rendered.getByLabelText('Close Tanstack query devtools'))

expect(
rendered.queryByLabelText('Tanstack query devtools'),
).not.toBeInTheDocument()
})
})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Add assertions for localStorage persistence and open button re-rendering.

The test verifies the panel is hidden, but the PR objectives mention that clicking the logo "triggers setLocalStore('open', 'false')". For completeness and consistency with the existing close button tests (lines 228-234 and 210-218), also verify:

  1. localStorage persists 'false' (matches PR objective)
  2. The open button re-appears after closing
✨ Proposed enhancement to match existing close button test coverage
   describe('logo close', () => {
     it('should hide the panel when the TanStack logo is clicked', () => {
       const rendered = renderDevtools({ initialIsOpen: true })
 
       fireEvent.click(rendered.getByLabelText('Close Tanstack query devtools'))
 
       expect(
         rendered.queryByLabelText('Tanstack query devtools'),
       ).not.toBeInTheDocument()
+      expect(
+        rendered.getByLabelText('Open Tanstack query devtools'),
+      ).toBeInTheDocument()
+      expect(localStorage.getItem('TanstackQueryDevtools.open')).toBe('false')
     })
   })
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
describe('logo close', () => {
it('should hide the panel when the TanStack logo is clicked', () => {
const rendered = renderDevtools({ initialIsOpen: true })
fireEvent.click(rendered.getByLabelText('Close Tanstack query devtools'))
expect(
rendered.queryByLabelText('Tanstack query devtools'),
).not.toBeInTheDocument()
})
})
describe('logo close', () => {
it('should hide the panel when the TanStack logo is clicked', () => {
const rendered = renderDevtools({ initialIsOpen: true })
fireEvent.click(rendered.getByLabelText('Close Tanstack query devtools'))
expect(
rendered.queryByLabelText('Tanstack query devtools'),
).not.toBeInTheDocument()
expect(
rendered.getByLabelText('Open Tanstack query devtools'),
).toBeInTheDocument()
expect(localStorage.getItem('TanstackQueryDevtools.open')).toBe('false')
})
})
🤖 Prompt for 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.

In `@packages/query-devtools/src/__tests__/Devtools.test.tsx` around lines 1093 -
1103, The test currently clicks the logo via fireEvent on the element found by
getByLabelText('Close Tanstack query devtools') and checks the panel is removed;
extend this to also assert that localStorage now stores 'false' for the 'open'
key (verify localStorage.getItem('open') === 'false' or that the mock setItem
was called with ('open','false')), and then assert the open-button is rendered
again (query/getByLabelText for the open button label used elsewhere, e.g. 'Open
Tanstack query devtools') to match the existing close-button tests; update the
test after the fireEvent.click in the describe block around renderDevtools to
include these two assertions.

@sukvvon sukvvon merged commit 55c6b8a into main May 11, 2026
10 checks passed
@sukvvon sukvvon deleted the test/query-devtools-devtools-logo-close branch May 11, 2026 03:13
@sukvvon sukvvon self-assigned this May 11, 2026
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