test(query-devtools/utils): add tests for 'getQueryStatusLabel'#10671
Merged
test(query-devtools/utils): add tests for 'getQueryStatusLabel'#10671
Conversation
Contributor
|
View your CI Pipeline Execution ↗ for commit d1a5c70
☁️ Nx Cloud last updated this comment at |
Contributor
🚀 Changeset Version PreviewNo changeset entries found. Merging this PR will not cause a version bump for any packages. |
Contributor
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@packages/query-devtools/src/__tests__/utils.test.ts`:
- Around line 1304-1371: Add a test covering the missing "stale" branch in
getQueryStatusLabel: create a Query via buildQuery with fetchStatus: 'idle',
some data, an old dataUpdatedAt (or explicitly set isStale: true) to mark it
stale, subscribe an observer using addObserver, and assert
expect(getQueryStatusLabel(query)).toBe('stale'); ensure you unsubscribe in a
finally block exactly like the other observer-based tests (use
QueryClient/QueryObserver helpers already in the file).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 900deedd-77fe-45d7-a4f4-02c7ba4b6b90
📒 Files selected for processing (1)
packages/query-devtools/src/__tests__/utils.test.ts
More templates
@tanstack/angular-query-experimental
@tanstack/eslint-plugin-query
@tanstack/lit-query
@tanstack/preact-query
@tanstack/preact-query-devtools
@tanstack/preact-query-persist-client
@tanstack/query-async-storage-persister
@tanstack/query-broadcast-client-experimental
@tanstack/query-core
@tanstack/query-devtools
@tanstack/query-persist-client-core
@tanstack/query-sync-storage-persister
@tanstack/react-query
@tanstack/react-query-devtools
@tanstack/react-query-next-experimental
@tanstack/react-query-persist-client
@tanstack/solid-query
@tanstack/solid-query-devtools
@tanstack/solid-query-persist-client
@tanstack/svelte-query
@tanstack/svelte-query-devtools
@tanstack/svelte-query-persist-client
@tanstack/vue-query
@tanstack/vue-query-devtools
commit: |
Contributor
size-limit report 📦
|
d1a5c70 to
6e36ef5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎯 Changes
Add unit tests for the
getQueryStatusLabelhelper inquery-devtools/utils.tsx.The helper maps a
Queryto one of five status labels (fetching,inactive,paused,stale,fresh) used to summarize each entry in the devtools panel.Cases:
'fetching'whenfetchStatusis'fetching''inactive'when there are no observers'paused'whenfetchStatusis'paused'and there are observers'paused'even when stale iffetchStatusis'paused'(guards the'paused'-over-isStaleprecedence)'stale'when the query is idle, has observers, and is stale'fresh'when the query is idle, has observers, and is not staleFor the stale-driven cases the test attaches an
enabled: trueQueryObserverwithstaleTime: 0, then forcesfetchStatusanddataUpdatedAt: 0viasetStatesoquery.isStale()resolves totrue. Each test uses realQueryandQueryObserverinstances, mirroring the pattern used by the existingsortFnssuite.queryClient.clear()runs inafterEachto keep tests isolated.✅ Checklist
pnpm run test:pr.🚀 Release Impact
Summary by CodeRabbit