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

4.2 KiB

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

  • 1.1 Read openspec/specs/testing/spec.md
  • 1.2 Read openspec/AGENTS.md Sections 13 and 14 (via CLAUDE.md mandate)
  • 1.3 Draft proposal.md from openspec/templates/proposal.md
  • 1.4 Source mapping: N/A (genesis-original package)
  • 1.5 Draft specs/testing/spec.md delta from openspec/templates/spec-delta.md
  • 1.6 Every requirement in the spec delta carries a **Verified by:** line naming concrete it(...) titles

2. Implementation

  • 2.1 Make TestRequest and TestResponse generic over TBody (default unknown) in src/types/http.types.ts
  • 2.2 Make RequestBuilder generic over TBody; body(), state getter, and build() return typed shapes
  • 2.3 Add <TBody = unknown> to every request preset (get, post, put, patch, del, head, options) and the private presetBuilder
  • 2.4 Make ResponseBuilder generic over TBody; body(), state getter, and build() return typed shapes
  • 2.5 Add <TBody = unknown> to every response preset (ok, created, noContent, badRequest, unauthorized, notFound, serverError) and the private presetBuilder
  • 2.6 Add typed get<T>(name) overload to FixtureManager; cast confined to impl
  • 2.7 Add <TError extends Error = Error> to assertThrows and assertThrowsAsync; cast at boundary
  • 2.8 Switch package.json scripts.typecheck from bunx tsc … to tsc --project tsconfig.lib.json --noEmit
  • 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/
  • 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

  • 3.1 src/builders/request-builder/request-builder.spec-conformance.test.ts — expectTypeOf on every preset and the class
  • 3.2 src/builders/response-builder/response-builder.spec-conformance.test.ts — expectTypeOf on every preset and the class
  • 3.3 src/fixtures/fixture-manager/fixture-manager.spec-conformance.test.ts — expectTypeOf on get<T> overload
  • 3.4 src/helpers/test-helpers.spec-conformance.test.ts — expectTypeOf on assertThrows<TError> / assertThrowsAsync<TError>
  • 3.5 Every it(...) carries { timeout: 5000 }

4. Documentation

  • 4.1 request-builder.md updated with generic preset signatures + generic example
  • 4.2 response-builder.md updated with generic preset signatures + generic example
  • 4.3 test-helpers.md updated with assertThrows<TError> signature + generic example
  • 4.4 fixture-manager.md updated with get<T> overload signature

5. Pre-archive verification (the 5-gate triple)

  • 5.1 bun run check — Biome 0/0/0 across the whole monorepo
  • 5.2 bunx turbo lint typecheck test --filter=@suaveplan/testing — green (4/4 tasks)
  • 5.3 bunx turbo test:coverage --filter=@suaveplan/testing — 100/100/100/100
  • 5.4 bun scripts/openspec-conformance.ts @suaveplan/testing — PASS (0 error, 0 warn, 0 info)
  • 5.5 bunx turbo build --filter=@suaveplan/testing — green

6. Pre-archive 7-row checklist (AGENTS.md Section 13)

  • 6.1 Generics threaded; expectTypeOf assertions on every literal-type claim
  • 6.2 Zod schemas already wired (existing requirement, untouched)
  • 6.3 Every error code in error-codes.ts thrown by at least one production path (existing requirement, untouched)
  • 6.4 Strict-mode behaviors tested both on and off (existing requirement, untouched)
  • 6.5 OTel instruments emitted (existing requirement, untouched)
  • 6.6 Lifecycle dedup tested (existing requirement, untouched)
  • 6.7 No retroactive tick — every box above reflects work done in this change

7. Archive

  • 7.1 Fold spec delta into openspec/specs/testing/spec.md
  • 7.2 Move openspec/changes/testing-generics-hardening/ → openspec/archive/2026-04-27-testing-generics-hardening/