Skip to content

test(query-devtools/contexts/PiPContext): add tests for 'closePipWindow' guard and reset#10802

Merged
sukvvon merged 1 commit into
mainfrom
test/query-devtools-pipcontext-close-pip-window
May 26, 2026
Merged

test(query-devtools/contexts/PiPContext): add tests for 'closePipWindow' guard and reset#10802
sukvvon merged 1 commit into
mainfrom
test/query-devtools-pipcontext-close-pip-window

Conversation

@sukvvon
Copy link
Copy Markdown
Collaborator

@sukvvon sukvvon commented May 26, 2026

🎯 Changes

Cover the public closePipWindow API the module exposes through usePiPWindow().closePipWindow (PiPContext.tsx:40-46). Devtools itself doesn't call it today, but it's part of the PiPContextType contract external integrators can call.

Three cases pin down the guard and the cleanup it owns:

  • should be a noop when no window is open: verifies the if (w != null) guard that prevents a null.close() TypeError when there's no PiP window yet.
  • should call "close" on the opened window and reset the "pipWindow" signal: verifies the happy path — requestPipWindowclosePipWindow calls close exactly once and the pipWindow accessor transitions from fakeWindownull (asserted via the observed array, matching the "pagehide" lifecycle style).
  • should call "close" only once when "closePipWindow" runs twice in a row: verifies the same guard from the post-close lifecycle phase — a second call after the signal is already null must stay a noop, protecting integrators against accidental double-invocation.

✅ 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 coverage for the Picture-in-Picture window closing functionality, including edge cases such as closing when no window is open and handling multiple close calls.

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: edf61a2e-75f9-4847-be08-285dbc7b7772

📥 Commits

Reviewing files that changed from the base of the PR and between 4cfd8a7 and 1ac4621.

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

📝 Walkthrough

Walkthrough

This PR adds test coverage for the closePipWindow() hook API in PiPContext. Three test cases verify that closing behaves as a no-op when no window exists, properly closes an open window and resets the internal signal, and maintains idempotency across consecutive calls.

Changes

PiP Window Closure Test Suite

Layer / File(s) Summary
closePipWindow lifecycle and idempotency tests
packages/query-devtools/src/__tests__/contexts/PiPContext.test.tsx
Three test cases validate no-op behavior when pipWindow is null, proper close() call and signal reset after closing an opened window, and idempotency such that consecutive closePipWindow() calls only invoke close() once.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related PRs

  • TanStack/query#10796: Extends the same PiPContext test suite with additional usePiPWindow behavior validation.
  • TanStack/query#10801: Adds coverage for pipWindow signal reset and state transitions in PiP window lifecycle.

Suggested labels

package: query-devtools

Poem

🐰 A window to close, tested with care,
No-op, then reset—a closure so fair!
Call it twice, once is the way,
Idempotent hops save the day! 🪟✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and specifically describes the main change: adding tests for the 'closePipWindow' guard and reset behavior.
Description check ✅ Passed The description follows the required template with all sections completed, including detailed explanation of changes, checklist items marked, and release impact clearly stated.
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-pipcontext-close-pip-window

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

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented May 26, 2026

View your CI Pipeline Execution ↗ for commit 1ac4621

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

☁️ Nx Cloud last updated this comment at 2026-05-26 00:47:59 UTC

@github-actions
Copy link
Copy Markdown
Contributor

🚀 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

@sukvvon sukvvon self-assigned this May 26, 2026
@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@10802

@tanstack/eslint-plugin-query

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

@tanstack/lit-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 1ac4621

@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 d7c27dc into main May 26, 2026
9 checks passed
@sukvvon sukvvon deleted the test/query-devtools-pipcontext-close-pip-window branch May 26, 2026 00:48
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