[Test] UI - CostTrackingSettings: Add comprehensive Vitest coverage#22354
Merged
yuneng-jiang merged 1 commit intomainfrom Feb 28, 2026
Merged
[Test] UI - CostTrackingSettings: Add comprehensive Vitest coverage#22354yuneng-jiang merged 1 commit intomainfrom
yuneng-jiang merged 1 commit intomainfrom
Conversation
Add 88 tests across 9 test files for the CostTrackingSettings component directory: - provider_display_helpers.test.ts: 9 tests for helper functions - how_it_works.test.tsx: 9 tests for discount calculator component - add_provider_form.test.tsx: 7 tests for provider form validation - add_margin_form.test.tsx: 9 tests for margin form with type toggle - provider_discount_table.test.tsx: 12 tests for table editing and interactions - provider_margin_table.test.tsx: 13 tests for margin table with sorting - use_discount_config.test.ts: 11 tests for discount hook logic - use_margin_config.test.ts: 12 tests for margin hook logic - cost_tracking_settings.test.tsx: 15 tests for main component and role-based rendering All tests passing. Coverage includes form validation, user interactions, API calls, state management, and conditional rendering. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Greptile SummaryThis PR adds 88 comprehensive unit tests across 9 new test files for the
The tests follow the project's established testing conventions from Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| ui/litellm-dashboard/src/components/CostTrackingSettings/provider_display_helpers.test.ts | 9 tests for provider display helper functions. Well-structured with proper mocks and correct assertions for known/unknown providers, backend value lookup, and image error fallback behavior. |
| ui/litellm-dashboard/src/components/CostTrackingSettings/how_it_works.test.tsx | 9 tests for the HowItWorks discount calculator component. Good coverage of rendering, form interactions, and conditional display of calculated results. |
| ui/litellm-dashboard/src/components/CostTrackingSettings/add_provider_form.test.tsx | 7 tests for AddProviderForm covering rendering, button disabled/enabled states based on provider selection and discount value, and click handler invocation. |
| ui/litellm-dashboard/src/components/CostTrackingSettings/add_margin_form.test.tsx | 9 tests for AddMarginForm covering percentage/fixed mode toggle, conditional input rendering, button states, and callback invocations. Tests properly verify margin type switching. |
| ui/litellm-dashboard/src/components/CostTrackingSettings/provider_discount_table.test.tsx | 12 tests for ProviderDiscountTable covering table rendering, inline editing, save/cancel flows, validation, and delete actions. Mocks Tremor components correctly for SimpleTable rendering. |
| ui/litellm-dashboard/src/components/CostTrackingSettings/provider_margin_table.test.tsx | 13 tests for ProviderMarginTable covering percentage, fixed, and combined margin display. Good coverage of global provider handling, edit/cancel/save flows, and delete actions. |
| ui/litellm-dashboard/src/components/CostTrackingSettings/use_discount_config.test.ts | 11 tests for useDiscountConfig hook covering fetch, add (with validations), remove, and change operations. All network calls properly mocked via vi.spyOn(global, "fetch"). |
| ui/litellm-dashboard/src/components/CostTrackingSettings/use_margin_config.test.ts | 12 tests for useMarginConfig hook covering fetch, add (percentage/fixed/global), remove, and change operations including complex margin values. All network calls properly mocked. |
| ui/litellm-dashboard/src/components/CostTrackingSettings/cost_tracking_settings.test.tsx | 15 tests for the main CostTrackingSettings component covering null access token, role-based visibility (admin vs non-admin), modal triggers, and empty state messages. Hooks properly mocked to avoid network calls. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[cost_tracking_settings.test.tsx<br/>15 tests] --> B[use_discount_config.test.ts<br/>11 tests]
A --> C[use_margin_config.test.ts<br/>12 tests]
A --> D[provider_discount_table.test.tsx<br/>12 tests]
A --> E[provider_margin_table.test.tsx<br/>13 tests]
A --> F[how_it_works.test.tsx<br/>9 tests]
D --> G[provider_display_helpers.test.ts<br/>9 tests]
E --> G
A --> H[add_provider_form.test.tsx<br/>7 tests]
A --> I[add_margin_form.test.tsx<br/>9 tests]
style A fill:#4CAF50,color:#fff
style B fill:#2196F3,color:#fff
style C fill:#2196F3,color:#fff
style D fill:#FF9800,color:#fff
style E fill:#FF9800,color:#fff
style F fill:#9C27B0,color:#fff
style G fill:#607D8B,color:#fff
style H fill:#FF9800,color:#fff
style I fill:#FF9800,color:#fff
Last reviewed commit: c4a0174
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.
Relevant issues
None
Summary
Added 88 comprehensive unit tests across 9 test files for the CostTrackingSettings component directory in Vitest + React Testing Library. Tests cover form validation, user interactions, hooks, state management, and conditional rendering with 100% of tests passing.
Changes
Type
✅ Test