Skip to content

test(dashboard): AnalyticsPage + CostPage integration tests#4068

Merged
aegis-gh-agent[bot] merged 1 commit into
developfrom
test/analytics-cost-page-tests
May 23, 2026
Merged

test(dashboard): AnalyticsPage + CostPage integration tests#4068
aegis-gh-agent[bot] merged 1 commit into
developfrom
test/analytics-cost-page-tests

Conversation

@OneStepAt4time
Copy link
Copy Markdown
Owner

Summary

Adds 17 integration tests for two untested dashboard pages:

AnalyticsPage.test.tsx (8 tests)

  • Renders loading state with spinner
  • Fetches and displays analytics data (KPI banner, charts)
  • Empty chart state when no data
  • Error state with retry button
  • Rate limit analytics section
  • Data consistency warning (sessions exist, charts empty)
  • Model distribution bar
  • Error rate calculation and color-coding

CostPage.test.tsx (9 tests)

  • Loading skeleton state
  • Empty state ("No cost data yet")
  • Error state with ErrorState component
  • Cost data display with model names
  • Time range picker (7d, 30d, 90d) + switching
  • Budget overview with disabled alerts (documents rule-of-hooks violation)
  • Budget overview with enabled alerts
  • Model breakdown section
  • Zero-cost edge case

Bug discovered

  • BudgetOverview has a rule-of-hooks violation: useT() is called inside a conditional if (!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 pass
  • npx vitest run src/__tests__/CostPage.test.tsx --maxWorkers=1 β€” 9/9 pass
  • CI green

- 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).
Copy link
Copy Markdown
Contributor

@aegis-gh-agent aegis-gh-agent Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@aegis-gh-agent aegis-gh-agent Bot merged commit 50b80bb into develop May 23, 2026
18 checks passed
@aegis-gh-agent aegis-gh-agent Bot deleted the test/analytics-cost-page-tests branch May 23, 2026 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant