---
id: w4/m14/t009
title: Test coverage — hook/component tests for the states above
worker: worker4
status: done
estimate: 30m
depends_on: [w4/m14/t007]
---

## Objective

Meaningful tests for `useAuditLog` and `AuditLogPanel` — real behavior and failure modes, not tautological/snapshot-everything tests.

## Context

- Precedent: `features/team/components/__tests__/team-panel.test.tsx`, `features/api-keys/hooks/__tests__/use-api-keys.test.ts`.

## Steps

1. Hook tests (`use-audit-log.test.ts`): initial load populates events; `loadMore()` appends and dedupes correctly across a page boundary; a 403 sets `forbidden` with no `error`; a 503 sets `unavailable` with no `error`; another failure sets `error`.
2. Component tests (`audit-log-panel.test.tsx`): non-admin (`forbidden`) renders nothing; loading renders the skeleton; `unavailable` renders the explanatory state; empty renders the empty state; a populated list renders rows in order with correct allowed/denied badges.

## Files

- `dashboard/src/features/audit/hooks/__tests__/use-audit-log.test.ts` (new)
- `dashboard/src/features/audit/components/__tests__/audit-log-panel.test.tsx` (new)

## Acceptance criteria

- [ ] Every state in t002/t005's acceptance criteria has a corresponding test that would fail if the behavior regressed.
- [ ] `yarn test` green.

## Out of scope

- E2E/browser verification (not required by this milestone's DoD; API-level parity already E2E-verified in w4/m10).
