[Infra] UI - Testing: Adding Unit Testing Coverage#20596
Merged
yuneng-jiang merged 1 commit intomainfrom Feb 6, 2026
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Greptile OverviewGreptile SummaryAdded unit test coverage for 4 previously untested UI components and hooks in the LiteLLM dashboard. Key additions:
Test quality:
Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| ui/litellm-dashboard/src/app/(dashboard)/hooks/useDisableShowNewBadge.test.ts | Comprehensive test suite for useDisableShowNewBadge hook covering localStorage interaction, storage events, custom events, and cleanup |
| ui/litellm-dashboard/src/app/(dashboard)/hooks/useDisableShowPrompts.test.ts | Comprehensive test suite for useDisableShowPrompts hook with identical structure to useDisableShowNewBadge tests |
| ui/litellm-dashboard/src/components/SearchTools/SearchToolTester.test.tsx | Extensive test suite for SearchToolTester component with 48 test cases covering search functionality, UI states, history management, and error handling |
| ui/litellm-dashboard/src/components/common_components/chartUtils.test.tsx | Thorough test suite for CustomTooltip and CustomLegend chart utility components covering formatting, color conversion, and edge cases |
Sequence Diagram
sequenceDiagram
participant Dev as Developer
participant Test as Test Suite
participant RTL as React Testing Library
participant Hook as Custom Hooks
participant Component as UI Components
participant Mock as Mocked Services
Note over Dev,Mock: Unit Testing Flow for UI Components
Dev->>Test: Run test suite (vitest)
rect rgb(240, 248, 255)
Note right of Test: Hook Tests (useDisableShowNewBadge, useDisableShowPrompts)
Test->>RTL: renderHook()
RTL->>Hook: Initialize hook with useSyncExternalStore
Hook->>Hook: Subscribe to localStorage events
Test->>Hook: Simulate localStorage.setItem()
Test->>Hook: Dispatch StorageEvent/CustomEvent
Hook->>RTL: Return updated state
RTL->>Test: Assert state changes
Test->>RTL: unmount()
RTL->>Hook: Cleanup event listeners
Hook->>Test: Verify removeEventListener calls
end
rect rgb(255, 248, 240)
Note right of Test: Component Tests (SearchToolTester)
Test->>Mock: Mock searchToolQueryCall()
Test->>RTL: render(<SearchToolTester />)
RTL->>Component: Mount component
Test->>RTL: userEvent.type() in search input
Test->>RTL: userEvent.click() search button
Component->>Mock: Call searchToolQueryCall()
Mock->>Component: Return mocked results
Component->>RTL: Update UI with results
RTL->>Test: Assert results displayed
Test->>RTL: userEvent.click() history items
Component->>RTL: Update search query
RTL->>Test: Assert query updated
end
rect rgb(240, 255, 240)
Note right of Test: Utility Tests (chartUtils)
Test->>RTL: render(<CustomTooltip />)
RTL->>Component: Render with mock payload
Component->>Component: Format category names
Component->>Component: Convert color names to hex
Component->>RTL: Display formatted values
RTL->>Test: Assert formatting correct
Test->>RTL: render(<CustomLegend />)
RTL->>Component: Render with categories/colors
Component->>RTL: Display legend items
RTL->>Test: Assert legend items rendered
end
Test->>Dev: Report test results
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
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
tests/litellm/directory, Adding at least 1 test is a hard requirement - see detailsmake test-unitCI (LiteLLM team)
Branch creation CI run
Link:
CI run for the last commit
Link:
Merge / cherry-pick CI run
Links:
Type
🚄 Infrastructure
✅ Test
Changes
This file adds 4 test files to previously untested files.
Screenshot