Conversation
… when 'notifyOnChangeProps' is set
📝 WalkthroughWalkthroughA new test case is added to Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 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 e605f9f
☁️ 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. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/query-core/src/__tests__/queriesObserver.test.tsx (1)
622-631: Strengthen the test by asserting reference identity, not just call count.You already verify
trackResultis not invoked, but the test name/intent also says the observer result is returned directly. Please assert thattrackedResults[0]is the exact same object as the raw optimistic result entry.Suggested diff
- const [, , trackResult] = observer.getOptimisticResult( + const [rawResults, , trackResult] = observer.getOptimisticResult( [{ queryKey: key, queryFn, notifyOnChangeProps: ['data'] }], undefined, ) const trackedResults = trackResult() expect(trackedResults).toHaveLength(1) + expect(trackedResults[0]).toBe(rawResults[0]) // trackResult should NOT be called when notifyOnChangeProps is set expect(trackResultSpy).not.toHaveBeenCalled()🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/query-core/src/__tests__/queriesObserver.test.tsx` around lines 622 - 631, Destructure the optimistic results from observer.getOptimisticResult so you can assert identity rather than only call count: change the destructuring to capture the first return value (e.g. const [optimisticResults, , trackResult] = observer.getOptimisticResult(...)) and after calling trackResult() add an assertion expect(trackedResults[0]).toBe(optimisticResults[0]) to verify the returned trackedResults entry is the exact same object as the raw optimistic result; use the existing symbols observer.getOptimisticResult, trackResult, trackedResults, trackResultSpy, key, queryFn, and notifyOnChangeProps to locate the test code.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/query-core/src/__tests__/queriesObserver.test.tsx`:
- Around line 622-631: Destructure the optimistic results from
observer.getOptimisticResult so you can assert identity rather than only call
count: change the destructuring to capture the first return value (e.g. const
[optimisticResults, , trackResult] = observer.getOptimisticResult(...)) and
after calling trackResult() add an assertion
expect(trackedResults[0]).toBe(optimisticResults[0]) to verify the returned
trackedResults entry is the exact same object as the raw optimistic result; use
the existing symbols observer.getOptimisticResult, trackResult, trackedResults,
trackResultSpy, key, queryFn, and notifyOnChangeProps to locate the test code.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 329007f6-2b3e-456a-9004-76830e7e8003
📒 Files selected for processing (1)
packages/query-core/src/__tests__/queriesObserver.test.tsx
size-limit report 📦
|
🎯 Changes
Add a test to verify that
#trackResultreturns the observer result directly (without callingtrackResult) whennotifyOnChangePropsis set on the query options.This covers the else branch of
!notifyOnChangeProps ? trackResult(...) : observerResultin#trackResult.✅ Checklist
pnpm run test:pr.🚀 Release Impact
Summary by CodeRabbit