Files
suaveplan/openspec/archive/2026-04-27-testing-generics-hardening/tasks.md
2026-05-27 23:29:53 +01:00

64 lines
4.2 KiB
Markdown

# Tasks — Testing generics hardening
> Every checkbox reflects work actually done in this change. Genesis-original package, no `enterprise/<pkg>.md` source mapping.
## 1. Spec authoring
- [x] 1.1 Read `openspec/specs/testing/spec.md`
- [x] 1.2 Read `openspec/AGENTS.md` Sections 13 and 14 (via CLAUDE.md mandate)
- [x] 1.3 Draft `proposal.md` from `openspec/templates/proposal.md`
- [x] 1.4 Source mapping: N/A (genesis-original package)
- [x] 1.5 Draft `specs/testing/spec.md` delta from `openspec/templates/spec-delta.md`
- [x] 1.6 Every requirement in the spec delta carries a `**Verified by:**` line naming concrete `it(...)` titles
## 2. Implementation
- [x] 2.1 Make `TestRequest` and `TestResponse` generic over `TBody` (default `unknown`) in `src/types/http.types.ts`
- [x] 2.2 Make `RequestBuilder` generic over `TBody`; `body()`, `state` getter, and `build()` return typed shapes
- [x] 2.3 Add `<TBody = unknown>` to every request preset (`get`, `post`, `put`, `patch`, `del`, `head`, `options`) and the private `presetBuilder`
- [x] 2.4 Make `ResponseBuilder` generic over `TBody`; `body()`, `state` getter, and `build()` return typed shapes
- [x] 2.5 Add `<TBody = unknown>` to every response preset (`ok`, `created`, `noContent`, `badRequest`, `unauthorized`, `notFound`, `serverError`) and the private `presetBuilder`
- [x] 2.6 Add typed `get<T>(name)` overload to `FixtureManager`; cast confined to impl
- [x] 2.7 Add `<TError extends Error = Error>` to `assertThrows` and `assertThrowsAsync`; cast at boundary
- [x] 2.8 Switch `package.json` `scripts.typecheck` from `bunx tsc …` to `tsc --project tsconfig.lib.json --noEmit`
- [x] 2.9 Bump `openspec/specs/testing/spec.md` coverage requirement from ≥ 95% to 100% across statements/branches/functions/lines; correct path drift `packages/universal/testing/` → `packages/dev/testing/`
- [x] 2.10 Extend `tests/spec-conformance.spec-conformance.test.ts` `ALLOWED_NONDETERMINISM` to include `measureTime` (helpers) and observability wrapper, with in-test justification comments
## 3. Tests
- [x] 3.1 `src/builders/request-builder/request-builder.spec-conformance.test.ts` — `expectTypeOf` on every preset and the class
- [x] 3.2 `src/builders/response-builder/response-builder.spec-conformance.test.ts` — `expectTypeOf` on every preset and the class
- [x] 3.3 `src/fixtures/fixture-manager/fixture-manager.spec-conformance.test.ts` — `expectTypeOf` on `get<T>` overload
- [x] 3.4 `src/helpers/test-helpers.spec-conformance.test.ts` — `expectTypeOf` on `assertThrows<TError>` / `assertThrowsAsync<TError>`
- [x] 3.5 Every `it(...)` carries `{ timeout: 5000 }`
## 4. Documentation
- [x] 4.1 `request-builder.md` updated with generic preset signatures + generic example
- [x] 4.2 `response-builder.md` updated with generic preset signatures + generic example
- [x] 4.3 `test-helpers.md` updated with `assertThrows<TError>` signature + generic example
- [x] 4.4 `fixture-manager.md` updated with `get<T>` overload signature
## 5. Pre-archive verification (the 5-gate triple)
- [x] 5.1 `bun run check` — Biome 0/0/0 across the whole monorepo
- [x] 5.2 `bunx turbo lint typecheck test --filter=@suaveplan/testing` — green (4/4 tasks)
- [x] 5.3 `bunx turbo test:coverage --filter=@suaveplan/testing` — 100/100/100/100
- [x] 5.4 `bun scripts/openspec-conformance.ts @suaveplan/testing` — PASS (0 error, 0 warn, 0 info)
- [x] 5.5 `bunx turbo build --filter=@suaveplan/testing` — green
## 6. Pre-archive 7-row checklist (AGENTS.md Section 13)
- [x] 6.1 Generics threaded; `expectTypeOf` assertions on every literal-type claim
- [x] 6.2 Zod schemas already wired (existing requirement, untouched)
- [x] 6.3 Every error code in `error-codes.ts` thrown by at least one production path (existing requirement, untouched)
- [x] 6.4 Strict-mode behaviors tested both on and off (existing requirement, untouched)
- [x] 6.5 OTel instruments emitted (existing requirement, untouched)
- [x] 6.6 Lifecycle dedup tested (existing requirement, untouched)
- [x] 6.7 No retroactive tick — every box above reflects work done in this change
## 7. Archive
- [x] 7.1 Fold spec delta into `openspec/specs/testing/spec.md`
- [x] 7.2 Move `openspec/changes/testing-generics-hardening/` → `openspec/archive/2026-04-27-testing-generics-hardening/`