test(query-core/queryObserver): add tests for 'refetchOnWindowFocus' as a function in 'shouldFetchOnWindowFocus'#10898
Conversation
📝 WalkthroughWalkthroughAdds three tests to QueryObserver.shouldFetchOnWindowFocus() verifying behavior when refetchOnWindowFocus is a function returning true, false, or "always", and that the callback is called with the query cache entry. ChangesWindow focus callback behavior tests
Sequence Diagram(s)sequenceDiagram
participant Test
participant QueryObserver
participant QueryClient
participant QueryCache
Test->>QueryObserver: call shouldFetchOnWindowFocus()
QueryObserver->>QueryClient: getQueryCache()
QueryClient->>QueryCache: find({ queryKey })
QueryCache-->>QueryObserver: query cache entry
QueryObserver-->>Test: boolean decision (true/false)
Possibly related PRs
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
View your CI Pipeline Execution ↗ for commit 2a90a52
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗ ☁️ Nx Cloud last updated this comment at |
🚀 Changeset Version PreviewNo changeset entries found. Merging this PR will not cause a version bump for any packages. |
…as a function in 'shouldFetchOnWindowFocus'
2a90a52 to
e6644a8
Compare
size-limit report 📦
|
🎯 Changes
Add tests covering
refetchOnWindowFocusas a function inshouldFetchOnWindowFocus.The existing tests only cover the value forms (
true,false,"always"), which all take the: fieldbranch oftypeof field === "function" ? field(query) : field. These add the function forms so thefield(query)branch is covered.Each function is a
vi.fnand asserts it is called with the query (toHaveBeenCalledWith), so the function-call path and the query argument are both verified:truefalse"always", kept fresh viastaleTime: Infinityso only the"always"path can make ittrue✅ Checklist
pnpm run test:pr.🚀 Release Impact