test(query-persist-client-core/retryStrategies): add tests for 'removeOldestQuery' removing the oldest query#10867
Conversation
…eOldestQuery' removing the oldest query
📝 WalkthroughWalkthroughThis PR adds a new test file for the ChangesremoveOldestQuery Test Coverage
🎯 3 (Moderate) | ⏱️ ~20 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 7080f92
☁️ 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-persist-client-core/src/__tests__/retryStrategies.test.ts (1)
41-75: ⚡ Quick winConsider adding edge case coverage for empty queries.
The current tests effectively cover the main behaviors. However, the implementation returns
undefinedwhen the queries array is empty (a distinct code path). Adding a test case for this edge case would improve coverage and document the expected behavior.📋 Suggested test case
it('should return undefined when there are no queries to remove', () => { const persistedClient = createPersistedClient([]) const result = removeOldestQuery({ persistedClient, error: new Error('full'), errorCount: 1, }) expect(result).toBeUndefined() })🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/query-persist-client-core/src/__tests__/retryStrategies.test.ts` around lines 41 - 75, Add a test that covers the empty-queries code path by calling removeOldestQuery with a persisted client created via createPersistedClient([]) and asserting the result is undefined; this verifies the function removeOldestQuery returns undefined when persistedClient.clientState.queries is empty and documents the expected behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/query-persist-client-core/src/__tests__/retryStrategies.test.ts`:
- Around line 41-75: Add a test that covers the empty-queries code path by
calling removeOldestQuery with a persisted client created via
createPersistedClient([]) and asserting the result is undefined; this verifies
the function removeOldestQuery returns undefined when
persistedClient.clientState.queries is empty and documents the expected
behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 9195c565-564b-40a3-a13d-79672f2babb8
📒 Files selected for processing (1)
packages/query-persist-client-core/src/__tests__/retryStrategies.test.ts
size-limit report 📦
|
🎯 Changes
Adds unit tests for the
removeOldestQuerypredefined retry strategy, which previously had no direct unit test in its defining package.These tests cover its core behavior: it removes the single query with the oldest
dataUpdatedAt, and when several queries share that oldest timestamp only one of them is removed.✅ Checklist
pnpm run test:pr.🚀 Release Impact
Summary by CodeRabbit