---
id: w6/m3/t008
title: Test coverage — meaningful tests for the behavior this milestone shipped
worker: worker6
status: done
estimate: 30m
depends_on: [w6/m3/t006]
---

## Closeout

24 new tests across 8 files (`src/features/workspaces/{hooks,context,components}/__tests__/`):

- `use-workspaces.test.ts` — mapping/null-dropping/plan-defaulting/loading-empty behavior.
- `use-create-workspace.test.ts` — success path, the Hobby-cap refusal surfacing inline (not just a toast) via a real `CombinedGraphQLErrors` instance, generic-error fallback, error clearing on retry.
- `use-rename-workspace.test.ts` / `use-delete-workspace.test.ts` — success + inline-error paths.
- `context/index.test.tsx` — fallback-to-first-workspace with nothing stored, restoring a still-valid persisted selection, falling back when the persisted selection was deleted, and `setCurrentWorkspaceId` persisting + propagating to every consumer (a regression test for the exact class of bug this milestone hit — see t001's closeout — verified via a hook consumer, not a component render, so it exercises the context mechanism directly).
- `workspace-switcher.test.tsx` — trigger label, list + switch, navigation to settings/create.
- `delete-workspace-card.test.tsx` — the type-to-confirm guard (disabled until exact match, a typo stays a no-op), success routing to a remaining workspace, and routing to `/new/workspace` when none remain.
- `plan-picker.test.tsx` — all four plan cards render, selection callback fires with the right id.

Full dashboard suite: 489/489 passing; `yarn typecheck`/`yarn lint` clean.

## Objective

Automated tests for the UI behavior that matters: workspace-context scoping (queries re-issued with the new workspace on switch), creation-flow validation and limit-error rendering, role-gated rename, and the delete guard's disabled-until-typed logic. Real assertions, not snapshots.

## Context

- Dashboard test setup: `dashboard/src/test/` + `__tests__/` conventions (Vitest/RTL per `dashboard/CLAUDE.md`).
- Mock Apollo with typed errors matching m1/t006's shapes so error-rendering tests exercise the real mapping.

## Steps

1. Context/provider tests: switch → variables change, persistence, default fallback.
2. `/new/workspace`: plan default, submit wiring, inline limit error.
3. Settings/delete: role gating, confirm-string gating, refusal rendering.

## Files

- `dashboard/src/__tests__/` (or co-located tests)

## Acceptance criteria

- [ ] Switch/scoping, limit error, role gating, and delete guard each have behavior-asserting tests
- [ ] Tests fail if the guard or scoping regresses (verified by mutation of the code under test at least once)
- [ ] Dashboard test suite green

## Out of scope

- Browser e2e (done manually in t005).
