Skip to content

test(query-devtools/Devtools): add test for 'pip_open' reset when the popup is blocked#10761

Merged
sukvvon merged 1 commit into
mainfrom
test/query-devtools-devtools-pip-popup-blocked
May 23, 2026
Merged

test(query-devtools/Devtools): add test for 'pip_open' reset when the popup is blocked#10761
sukvvon merged 1 commit into
mainfrom
test/query-devtools-devtools-pip-popup-blocked

Conversation

@sukvvon
Copy link
Copy Markdown
Collaborator

@sukvvon sukvvon commented May 23, 2026

🎯 Changes

Extend Devtools.test.tsx with a test that locks the popup-blocked fallback for the picture-in-picture window — when window.open returns null, the pip_open reactive effect should log the failure and reset the persisted pip_open flag so the user is not left in a broken state.

Added cases (picture-in-picture, 1):

  • should log and reset "pip_open" when the browser blocks the popup — stubs window.open to return null, seeds pip_open=true in localStorage to trigger the auto-open effect, and asserts both the console.error call and that pip_open is reset to "false".

✅ 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 a test covering popup/picture-in-picture blocking: verifies an error is logged when the popup is blocked and that the UI state flag in local storage is reset.
    • Ensures robust handling of blocked popups to prevent stale stored state.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 23, 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: 3d03d8a5-7a08-4576-8d6e-6a76c13f5434

📥 Commits

Reviewing files that changed from the base of the PR and between 80c2c52 and c73b449.

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

📝 Walkthrough

Walkthrough

Adds a test that simulates the browser blocking the picture-in-picture popup by stubbing window.open to return null, asserts an error is logged containing "Failed to open popup", and ensures localStorage's TanstackQueryDevtools.pip_open is reset to 'false'.

Changes

Picture-in-Picture Popup Blocked Test

Layer / File(s) Summary
Popup-blocked error handling test
packages/query-devtools/src/__tests__/Devtools.test.tsx
New test simulates browser popup blocking by stubbing open to return null, asserts console.error contains "Failed to open popup", and verifies localStorage's TanstackQueryDevtools.pip_open is reset to 'false'.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • TanStack/query#10760: Both PRs extend the Picture-in-Picture test suite with popup-related test cases that stub window.open and assert localStorage behavior.

Suggested labels

package: query-devtools

Poem

🐰 A popup blocked? No fear, dear friend,
The test now checks this error's end,
With open stubbed and logs confirmed,
The localStorage flag is earned,
When browsers say "no," our tests hop on trend!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change—adding a test for 'pip_open' reset when a popup is blocked.
Description check ✅ Passed The description follows the template structure with completed 🎯 Changes section, checked ✅ Checklist items, and 🚀 Release Impact assessment marked as docs/CI/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-pip-popup-blocked

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

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented May 23, 2026

View your CI Pipeline Execution ↗ for commit 80c2c52

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

☁️ Nx Cloud last updated this comment at 2026-05-23 05:19:40 UTC

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 23, 2026

🚀 Changeset Version Preview

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

@sukvvon sukvvon self-assigned this May 23, 2026
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 434-454: The test creates a spy via vi.spyOn(console, 'error')
(assigned to consoleError) but never restores it; wrap the test body inside a
try { ... } finally { consoleError.mockRestore() } block so the spy is always
restored after running renderDevtools and assertions, ensuring no leakage
between tests; reference the existing vi.stubGlobal('open', ...) and the
renderDevtools(...) call and ensure the finally block calls
consoleError.mockRestore() to clean up the spy (and optionally restore any other
stubs if present).
🪄 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: 399c4350-e9d6-4c5d-9a2b-2b2aaae43021

📥 Commits

Reviewing files that changed from the base of the PR and between a00c0d2 and 80c2c52.

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

Comment thread packages/query-devtools/src/__tests__/Devtools.test.tsx
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 23, 2026

More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/lit-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: c73b449

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 23, 2026

size-limit report 📦

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

@sukvvon sukvvon force-pushed the test/query-devtools-devtools-pip-popup-blocked branch from 80c2c52 to c73b449 Compare May 23, 2026 05:14
@sukvvon sukvvon merged commit 217b67a into main May 23, 2026
10 checks passed
@sukvvon sukvvon deleted the test/query-devtools-devtools-pip-popup-blocked branch May 23, 2026 05:26
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