Skip to content

test(query-devtools/contexts/PiPContext): add tests for the 'pip_open' auto-open createEffect#10803

Merged
sukvvon merged 2 commits into
mainfrom
test/query-devtools-pipcontext-auto-open-effect
May 26, 2026
Merged

test(query-devtools/contexts/PiPContext): add tests for the 'pip_open' auto-open createEffect#10803
sukvvon merged 2 commits into
mainfrom
test/query-devtools-pipcontext-auto-open-effect

Conversation

@sukvvon
Copy link
Copy Markdown
Collaborator

@sukvvon sukvvon commented May 26, 2026

🎯 Changes

Cover the four branches of the auto-open createEffect at PiPContext.tsx:136-154. This is the effect that restores PiP state after a reload (and the one DevtoolsPanelComponent deliberately disables), so each branch maps to a real user / integrator scenario:

  • should auto-open a PiP window when "pip_open" is "true" on mount: verifies the reload-restore path — localStorage.pip_open === 'true' triggers requestPipWindow (and therefore window.open) on the very first effect run.
  • should not auto-open a PiP window when "disabled" is true: verifies the disabled short-circuit that DevtoolsPanelComponent relies on (<PiPProvider disabled> so the panel-only mode never auto-spawns a PiP popup).
  • should reset "pip_open"/"open" and log when "window.open" returns null on auto-open: verifies the popup-blocker recovery path — window.open returning null makes requestPipWindow throw PipOpenError, which the effect catches, logs to console.error, and uses to reset both pip_open and open so the next reload doesn't loop into the same failure.
  • should re-throw non-"PipOpenError" errors from "window.open" on auto-open: verifies that unexpected window.open failures (anything other than PipOpenError) are surfaced instead of being silently swallowed by the try/catch.

The renderAndAct helper gains a small initialStorage option (and a matching localStorage.clear() in afterEach) so each case can seed pip_open / open before mount without leaking state into siblings. The empty action callback is intentional — these cases assert on the effect that runs at mount, not on anything the actor does afterward.

✅ 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
    • Improved test isolation by clearing storage state between test runs.
    • Extended test helper to support custom storage initialization.
    • Added comprehensive test coverage for auto-open behavior under various conditions and error scenarios.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 26, 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: 1ea51973-8757-4bf4-a1b3-b8f9eaf6ebbf

📥 Commits

Reviewing files that changed from the base of the PR and between d7c27dc and d9f1786.

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

📝 Walkthrough

Walkthrough

Test file extends the PiP test harness to isolate state via localStorage cleanup and adds a comprehensive test suite validating pip_open auto-open behavior, including triggering on mount, suppression when disabled, error logging on null returns, and exception propagation.

Changes

PiP Auto-open Test Coverage

Layer / File(s) Summary
Test harness localStorage setup
packages/query-devtools/src/__tests__/contexts/PiPContext.test.tsx
afterEach now clears localStorage to isolate test state, and renderAndAct helper accepts an initialStorage parameter to pre-populate localStorage entries before rendering.
Auto-open behavior test suite
packages/query-devtools/src/__tests__/contexts/PiPContext.test.tsx
New test section validates pip_open auto-open effect: confirms opening on mount when pip_open is "true", suppresses auto-open when disabled is true, logs error and resets state to "false" when window.open returns null, and re-throws non-"PipOpenError" exceptions.

Possibly related PRs

  • TanStack/query#10762: Both PRs add/adjust PiP-focused test coverage for pip_open/localStorage and PiP lifecycle effects (auto-open, pagehide, and syncing open/panel visibility).
  • TanStack/query#10801: Both PRs update PiPContext.test.tsx, extending the test harness and adding lifecycle/effect-driven assertions around pip_open state transitions.
  • TanStack/query#10761: Both PRs verify the same pip_open auto-open failure path when window.open returns null, asserting error logging and state reset to 'false'.

Suggested labels

package: query-devtools

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A test suite hops with localStorage care,
Clearing state between each test's lair.
PiP windows open—or gracefully fail—
Error logs ready, exceptions don't pale. 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding tests for the pip_open auto-open createEffect in PiPContext, matching the changeset.
Description check ✅ Passed The description is comprehensive and complete, covering all template sections with detailed explanations of test scenarios, implementation details, and checklist items all checked appropriately.
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-pipcontext-auto-open-effect

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

@sukvvon sukvvon self-assigned this May 26, 2026
@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented May 26, 2026

View your CI Pipeline Execution ↗ for commit 33837a3

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

☁️ Nx Cloud last updated this comment at 2026-05-26 01:04:57 UTC

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 26, 2026

🚀 Changeset Version Preview

2 package(s) bumped directly, 23 bumped as dependents.

🟩 Patch bumps

Package Version Reason
@tanstack/lit-query 0.2.6 → 0.2.7 Changeset
@tanstack/query-devtools 5.100.14 → 5.100.15 Changeset
@tanstack/angular-query-experimental 5.100.14 → 5.100.15 Dependent
@tanstack/angular-query-persist-client 5.100.14 → 5.100.15 Dependent
@tanstack/eslint-plugin-query 5.100.14 → 5.100.15 Dependent
@tanstack/preact-query 5.100.14 → 5.100.15 Dependent
@tanstack/preact-query-devtools 5.100.14 → 5.100.15 Dependent
@tanstack/preact-query-persist-client 5.100.14 → 5.100.15 Dependent
@tanstack/query-async-storage-persister 5.100.14 → 5.100.15 Dependent
@tanstack/query-broadcast-client-experimental 5.100.14 → 5.100.15 Dependent
@tanstack/query-core 5.100.14 → 5.100.15 Dependent
@tanstack/query-persist-client-core 5.100.14 → 5.100.15 Dependent
@tanstack/query-sync-storage-persister 5.100.14 → 5.100.15 Dependent
@tanstack/react-query 5.100.14 → 5.100.15 Dependent
@tanstack/react-query-devtools 5.100.14 → 5.100.15 Dependent
@tanstack/react-query-next-experimental 5.100.14 → 5.100.15 Dependent
@tanstack/react-query-persist-client 5.100.14 → 5.100.15 Dependent
@tanstack/solid-query 5.100.14 → 5.100.15 Dependent
@tanstack/solid-query-devtools 5.100.14 → 5.100.15 Dependent
@tanstack/solid-query-persist-client 5.100.14 → 5.100.15 Dependent
@tanstack/svelte-query 6.1.33 → 6.1.34 Dependent
@tanstack/svelte-query-devtools 6.1.33 → 6.1.34 Dependent
@tanstack/svelte-query-persist-client 6.1.33 → 6.1.34 Dependent
@tanstack/vue-query 5.100.14 → 5.100.15 Dependent
@tanstack/vue-query-devtools 6.1.33 → 6.1.34 Dependent

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 26, 2026

More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/lit-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: d9f1786

@github-actions
Copy link
Copy Markdown
Contributor

size-limit report 📦

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

@sukvvon sukvvon merged commit db19ccf into main May 26, 2026
9 checks passed
@sukvvon sukvvon deleted the test/query-devtools-pipcontext-auto-open-effect branch May 26, 2026 01:07
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