test(dashboard): AnalyticsPage + CostPage integration tests#4068
Merged
Conversation
- AnalyticsPage.test.tsx: 8 tests covering loading, data display, empty state, error state, rate limits, consistency warning, model distribution, error rate calculation - CostPage.test.tsx: 9 tests covering loading skeleton, empty state, error state, data display, time range picker, budget alerts, budget overview, model breakdown, zero-cost edge case Both test suites mock api/client, useStore, and budgetSettings following established patterns from AuditPage.test.tsx. All 17 tests pass. Also documents rule-of-hooks violation in BudgetOverview component (useT called conditionally when budgetAlertEnabled is false).
Contributor
There was a problem hiding this comment.
Review: Approved β
Verdict
17 new integration tests for two previously-untested dashboard pages. All CI green, test-only changes, no production code modified.
Quality Assessment
- Coverage: Loading, success, error, empty, edge cases all covered
- Mocking: Clean vi.fn() pattern with proper beforeEach cleanup
- Observability: Good catch documenting the BudgetOverview rule-of-hooks violation in a test comment
- Test structure: Each test is focused and independent; proper waitFor for async rendering
Gates Check
- β Review completed
- β No conflicts
- β CI green (all checks pass)
- β No regressions (test-only)
- β Unit tests (that IS this PR)
- β Documented (inline comments + PR body)
- β Security clean (no secrets, no production changes)
- β Targets develop
All 9 gates pass. Merging.
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.
Summary
Adds 17 integration tests for two untested dashboard pages:
AnalyticsPage.test.tsx (8 tests)
CostPage.test.tsx (9 tests)
Bug discovered
BudgetOverviewhas a rule-of-hooks violation:useT()is called inside a conditionalif (!budgetSettings.budgetAlertEnabled)block. This should be refactored to call the hook at the top of the function.Test plan
npx vitest run src/__tests__/AnalyticsPage.test.tsx --maxWorkers=1β 8/8 passnpx vitest run src/__tests__/CostPage.test.tsx --maxWorkers=1β 9/9 pass