Skip to content

test(query-devtools/utils): add tests for 'getMutationStatusColor' and 'getQueryStatusColorByLabel'#10645

Merged
sukvvon merged 2 commits intomainfrom
test/query-devtools-status-color-helpers
May 5, 2026
Merged

test(query-devtools/utils): add tests for 'getMutationStatusColor' and 'getQueryStatusColorByLabel'#10645
sukvvon merged 2 commits intomainfrom
test/query-devtools-status-color-helpers

Conversation

@sukvvon
Copy link
Copy Markdown
Collaborator

@sukvvon sukvvon commented May 5, 2026

🎯 Changes

Add unit tests for two pure status-to-color mapping helpers in query-devtools/utils.tsx.

  • getMutationStatusColor — covers the priority of isPaused over status, plus all branches (error, pending, success, idle)
  • getQueryStatusColorByLabel — covers all 5 labels (fresh, stale, paused, inactive, fetching)

These functions take primitive inputs (no Query/Mutation instances), so the tests follow textbook unit-test style with no type casts.

Coverage for utils.tsx:

  • Branch: 25.74% → 41.58%
  • Funcs: 18.18% → 27.27%

✅ 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
    • Expanded test coverage for mutation and query status color mapping utilities in query-devtools.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 5, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 74eda265-b7e0-4755-a7f2-ff79193a2152

📥 Commits

Reviewing files that changed from the base of the PR and between 0d8d64b and 03225a2.

📒 Files selected for processing (1)
  • packages/query-devtools/src/__tests__/utils.test.ts

📝 Walkthrough

Walkthrough

This PR adds test coverage for two color utility functions (getMutationStatusColor and getQueryStatusColorByLabel) in the query devtools package via parameterized test matrices and direct label-to-color assertions.

Changes

Test Coverage for Color Utilities

Layer / File(s) Summary
Import Updates
packages/query-devtools/src/__tests__/utils.test.ts
Test file imports getMutationStatusColor and getQueryStatusColorByLabel from utils module.
Mutation Status Tests
packages/query-devtools/src/__tests__/utils.test.ts
Parameterized test matrix validates getMutationStatusColor color output across mutation statuses and isPaused states, including error state when paused.
Query Label Tests
packages/query-devtools/src/__tests__/utils.test.ts
Direct assertions verify getQueryStatusColorByLabel returns correct color strings for each label: fresh, stale, paused, inactive, and fetching.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 A leap of logic, colors bright,
From mutation states to query light,
Each test a leaf upon our quest,
The devtools wear their finest vest! 🎨✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding tests for two specific utility functions in query-devtools.
Description check ✅ Passed The description follows the template structure with all required sections completed, including detailed changes, verified checklist items, and clear release impact assessment.
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-devtools-status-color-helpers

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

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

nx-cloud Bot commented May 5, 2026

View your CI Pipeline Execution ↗ for commit 99566cb

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

☁️ Nx Cloud last updated this comment at 2026-05-05 18:00:43 UTC

@github-actions
Copy link
Copy Markdown
Contributor

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

More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 03225a2

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

size-limit report 📦

Path Size
react full 12.1 KB (0%)
react minimal 9.07 KB (0%)

@sukvvon sukvvon merged commit f4a365f into main May 5, 2026
8 checks passed
@sukvvon sukvvon deleted the test/query-devtools-status-color-helpers branch May 5, 2026 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant