docs(adr): ADR-011 TDD foundation; update AGENTS.md per-feature
Captures the decision to add @repo/core-testing, factories, contract suites, vitest safety defaults, coverage thresholds, Storybook test-runner, and CI as one cohesive TDD foundation. Per-feature AGENTS.md gains a Tests section pointing to factories, contract suite, and the canonical test commands. Spec: §7.4, §7.5 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -75,6 +75,20 @@ beforeEach(() => {
|
||||
|
||||
Covered areas: sign-in/up/out use cases, user validation, DI container binding.
|
||||
|
||||
## Tests
|
||||
|
||||
- **Factories:** `src/__factories__/user.factory.ts`, `src/__factories__/session.factory.ts` — use `userFactory.build({ overrides })` to construct test data with stable defaults.
|
||||
- **Contract suite:** `src/__contracts__/users-repository.contract.ts` — runs against every repository implementation (mock + payload).
|
||||
- **Unit tests:** colocated as `*.test.ts` next to the source file.
|
||||
- **Feature integration:** `tests/sign-in-flow.feature.test.ts` — full slice through tRPC router → controller → use case → mock repo.
|
||||
|
||||
```bash
|
||||
pnpm test --filter @repo/auth # all tests for this feature
|
||||
pnpm test --filter @repo/auth -- --watch # watch mode
|
||||
```
|
||||
|
||||
See `docs/guides/tdd-workflow.md` for the cycle.
|
||||
|
||||
## Structure (minimal feature)
|
||||
|
||||
```
|
||||
|
||||
@@ -75,6 +75,20 @@ beforeEach(() => {
|
||||
|
||||
Covered areas: article CRUD use cases, slug validation, publish/unpublish flows, DI container binding.
|
||||
|
||||
## Tests
|
||||
|
||||
- **Factories:** `src/__factories__/article.factory.ts` — use `articleFactory.build({ overrides })` to construct test data with stable defaults.
|
||||
- **Contract suite:** `src/__contracts__/articles-repository.contract.ts` — runs against every repository implementation (mock + payload).
|
||||
- **Unit tests:** colocated as `*.test.ts` next to the source file.
|
||||
- **Feature integration:** `tests/articles.feature.test.ts` — full slice through tRPC router → controller → use case → mock repo.
|
||||
|
||||
```bash
|
||||
pnpm test --filter @repo/blog # all tests for this feature
|
||||
pnpm test --filter @repo/blog -- --watch # watch mode
|
||||
```
|
||||
|
||||
See `docs/guides/tdd-workflow.md` for the cycle.
|
||||
|
||||
## Structure
|
||||
|
||||
```
|
||||
|
||||
@@ -70,6 +70,20 @@ beforeEach(() => {
|
||||
- **Alias** — `@/` resolves to `src/`
|
||||
- **Run** — `pnpm test --filter @repo/marketing-pages`
|
||||
|
||||
## Tests
|
||||
|
||||
- **Factories:** `src/__factories__/page.factory.ts`, `src/__factories__/site-settings.factory.ts` — use `pageFactory.build({ overrides })` to construct test data with stable defaults.
|
||||
- **Contract suite:** `src/__contracts__/pages-repository.contract.ts` — runs against every repository implementation (mock + payload).
|
||||
- **Unit tests:** colocated as `*.test.ts` next to the source file.
|
||||
- **Feature integration:** `tests/page-by-slug.feature.test.ts` — full slice through tRPC router → controller → use case → mock repo.
|
||||
|
||||
```bash
|
||||
pnpm test --filter @repo/marketing-pages # all tests for this feature
|
||||
pnpm test --filter @repo/marketing-pages -- --watch # watch mode
|
||||
```
|
||||
|
||||
See `docs/guides/tdd-workflow.md` for the cycle.
|
||||
|
||||
## Structure (minimal)
|
||||
|
||||
```
|
||||
|
||||
@@ -69,6 +69,18 @@ beforeEach(() => {
|
||||
- **Alias** — `@/` resolves to `src/`
|
||||
- **Run** — `pnpm test --filter @repo/media`
|
||||
|
||||
## Tests
|
||||
|
||||
- **Factories:** `src/__factories__/media.factory.ts` — use `mediaFactory.build({ overrides })` to construct test data with stable defaults.
|
||||
- **Unit tests:** colocated as `*.test.ts` next to the source file.
|
||||
|
||||
```bash
|
||||
pnpm test --filter @repo/media # all tests for this feature
|
||||
pnpm test --filter @repo/media -- --watch # watch mode
|
||||
```
|
||||
|
||||
See `docs/guides/tdd-workflow.md` for the cycle.
|
||||
|
||||
## Structure (minimal)
|
||||
|
||||
```
|
||||
|
||||
@@ -69,6 +69,20 @@ beforeEach(() => {
|
||||
- **Alias** — `@/` resolves to `src/`
|
||||
- **Run** — `pnpm test --filter @repo/navigation`
|
||||
|
||||
## Tests
|
||||
|
||||
- **Factories:** `src/__factories__/header.factory.ts` — use `headerFactory.build({ overrides })` to construct test data with stable defaults.
|
||||
- **Contract suite:** `src/__contracts__/navigation-repository.contract.ts` — runs against every repository implementation (mock + payload).
|
||||
- **Unit tests:** colocated as `*.test.ts` next to the source file.
|
||||
- **Feature integration:** `tests/get-header.feature.test.ts` — full slice through tRPC router → controller → use case → mock repo.
|
||||
|
||||
```bash
|
||||
pnpm test --filter @repo/navigation # all tests for this feature
|
||||
pnpm test --filter @repo/navigation -- --watch # watch mode
|
||||
```
|
||||
|
||||
See `docs/guides/tdd-workflow.md` for the cycle.
|
||||
|
||||
## Structure (minimal)
|
||||
|
||||
Per spec addendum v5 ("create folders only when needed"), this feature is small:
|
||||
|
||||
Reference in New Issue
Block a user