---
id: w8/m6/t008
title: Test coverage for period support and history UI
worker: worker8
status: todo
estimate: 35m
depends_on: [w8/m6/t006]
---

## Objective

Add meaningful tests for the behavior this milestone shipped: GraphQL `period` handling, the hook's refetch-on-period-change, and the dashboard's month-picker/trend states.

## Context

- `lego/backend/internal/usage/adapters_test.go` is the existing adapter-test pattern to extend for GraphQL `period`.
- `dashboard/src/features/usage/components/__tests__/usage-page.test.tsx` is the existing UI test file.

## Steps

1. Add GraphQL resolver tests for `period` (valid month, omitted, invalid format).
2. Add hook tests asserting a period change triggers a refetch with the new value.
3. Add UI tests for the month-selector interaction and the trend view's empty/sparse-history state.

## Files

- `lego/backend/internal/usage/adapters_test.go`
- `dashboard/src/features/usage/components/__tests__/usage-page.test.tsx`
- `dashboard/src/features/usage/hooks/__tests__/use-usage.test.ts`

## Acceptance criteria

- [ ] Tests fail if `period` stops working on GraphQL, if the hook stops refetching on period change, or if the trend view crashes on sparse history.

## Out of scope

- End-to-end/Playwright coverage (not part of this repo's usual test tier for dashboard features).
