Skip to content

test(query-core/queryObserver): split 'shouldFetchOnWindowFocus' test by 'refetchOnWindowFocus' value#10889

Merged
sukvvon merged 1 commit into
mainfrom
test/query-core-query-observer-split-should-fetch-on-window-focus
Jun 5, 2026
Merged

test(query-core/queryObserver): split 'shouldFetchOnWindowFocus' test by 'refetchOnWindowFocus' value#10889
sukvvon merged 1 commit into
mainfrom
test/query-core-query-observer-split-should-fetch-on-window-focus

Conversation

@sukvvon
Copy link
Copy Markdown
Collaborator

@sukvvon sukvvon commented Jun 5, 2026

🎯 Changes

Splits the single shouldFetchOnWindowFocus should respect refetchOnWindowFocus option test into two focused tests, one per refetchOnWindowFocus value:

  • shouldFetchOnWindowFocus returns true when refetchOnWindowFocus is true
  • shouldFetchOnWindowFocus returns false when refetchOnWindowFocus is false

The two cases are independent (no shared state or ordering between them), so splitting them isolates failures and makes each test title describe a single behavior. The assertions are unchanged.

✅ 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
    • Enhanced test coverage for window focus refresh behavior with separate assertions for enabled and disabled states.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 5, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ae32a58c-e4c3-49d0-a852-7536f59b19cf

📥 Commits

Reviewing files that changed from the base of the PR and between b63da8a and c8b8e44.

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

📝 Walkthrough

Walkthrough

The PR refactors the QueryObserver.shouldFetchOnWindowFocus() test by splitting a single combined test into two separate, focused test cases: one verifying the true behavior when refetchOnWindowFocus: true, and another verifying the false behavior when refetchOnWindowFocus: false.

Changes

Test case refactoring

Layer / File(s) Summary
shouldFetchOnWindowFocus() test split
packages/query-core/src/__tests__/queryObserver.test.tsx
Two separate tests replace a single combined assertion: one creates a QueryObserver with refetchOnWindowFocus: true and expects shouldFetchOnWindowFocus() to return true; another creates one with refetchOnWindowFocus: false and expects it to return false.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐰 A test once held two truths in one,
Now split apart, each has its fun—
True and false, now side by side,
Focused tests with nowhere to hide! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: splitting a test by refetchOnWindowFocus values, which is the primary modification in this PR.
Description check ✅ Passed The description covers all required template sections with complete information: changes are clearly explained, checklist items are marked appropriately, and release impact is correctly identified 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-core-query-observer-split-should-fetch-on-window-focus

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

@sukvvon sukvvon self-assigned this Jun 5, 2026
@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Jun 5, 2026

View your CI Pipeline Execution ↗ for commit c8b8e44

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

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-06-05 16:45:04 UTC

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 5, 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 Jun 5, 2026

More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/lit-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: c8b8e44

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 5, 2026

size-limit report 📦

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

@sukvvon sukvvon merged commit ba7fbc4 into main Jun 5, 2026
9 checks passed
@sukvvon sukvvon deleted the test/query-core-query-observer-split-should-fetch-on-window-focus branch June 5, 2026 16:49
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