---
id: w5/m14/t007
title: Test coverage — meaningful tests for the delete flow
worker: worker5
status: done
estimate: 30m
depends_on: [w5/m14/t005]
---

## Objective

Add tests asserting real behavior and failure modes for the delete flow: the confirm-guard (button disabled until name matches), cache eviction, and redirect-on-success.

## Context

- Existing pattern: `dashboard/src/features/services/hooks/__tests__/use-service-lifecycle.test.ts` for hook-level tests; `dashboard/src/features/services/components/__tests__/` for component tests.
- Tests must assert real behavior/failure modes — no trivial or tautological assertions.

## Steps

1. Hook test: `useDeleteService` evicts the right cache entry and surfaces error state on a failed mutation.
2. Component test: danger-zone confirm button stays disabled on a name mismatch, enables on exact match, and disables again while the mutation is in flight.
3. Regression test: deleting a service the caller doesn't own (cross-tenant) surfaces the 403 from the backend rather than a generic error.

## Files

- `dashboard/src/features/services/hooks/__tests__/use-delete-service.test.ts` (new)
- `dashboard/src/features/services/components/__tests__/danger-zone.test.tsx` (new)

## Acceptance criteria

- [ ] `yarn test` covers the confirm-guard, cache eviction, and error-state paths — not just the happy path.
- [ ] No snapshot-everything or tautological assertions.

## Out of scope

- Backend test coverage (that's w2/m4's own closing tasks).
