---
id: w5/m8/t008
title: Test coverage — query/mutation mapping, list/detail states, create/delete flows, reveal gating
worker: worker5
status: done
estimate: 30m
depends_on: [w5/m8/t006]
---

## Objective

Add meaningful tests for the behavior this milestone shipped — real assertions on mapping and failure modes, not snapshot filler — following the mocked-hook/real-router conventions established by w5/m4 and w5/m7's suites.

## Context

- Cover: `useDatabases` mapping + error passthrough; list states (skeleton/error/empty); create dialog (validation, catalog-sourced plans, success → refetch, failure → no navigation); delete confirm gating the mutation; detail states incl. not-found; connection-info hook fired **only** on reveal (assert no fetch on mount) and password masked until shown.
- Backend: the postgres-family catalog query gets a Go test beside the m7 `instanceTypes` one; the authz reflection sweep (`TestAuthzGuardsEveryVerb`) must still pass unmodified.

## Steps

1. Hook tests (list, lazy connection-info, create/delete mutations with toast/busy lifecycle).
2. Component tests (list states, create dialog, delete confirm, detail + reveal interaction).
3. Go test for the catalog extension; full suites green.

## Files

- `dashboard/src/features/databases/**/__tests__/`
- `lego/backend/internal/...` (catalog query test)

## Acceptance criteria

- [ ] Lazy-reveal behavior is asserted (no connection-info request on mount; request fires on reveal).
- [ ] Create/delete failure modes asserted (error toast, no false success navigation/removal).
- [ ] `yarn lint && yarn typecheck && yarn test && yarn build` and `go test ./...` all green.

## Out of scope

- Tautological or snapshot-everything tests; e2e beyond t006's live verify.
