Skip to content

Commit 0058704

Browse files
authored
Merge pull request #93 from Programcode/docs/test-diet-rules
docs(agents): say which behavior deserves a test
2 parents 4025827 + 69e69aa commit 0058704

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

‎AGENTS.md‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,30 @@ The skill is maintained code. A change that breaks it or makes it stale must upd
111111

112112
Never weaken a recipe's assertions to make it pass.
113113

114+
## What to test
115+
116+
Prove a change by using it: `npm run lint`, `npm run typecheck`, `npm run build`, then drive the feature in the real app with `verify-debatelab`. New tests are not a substitute for that, and a test-heavy diff is harder to review.
117+
118+
Write a test only when a regression would be costly or hard to notice by using the app:
119+
120+
- auth, sessions, RLS and pgTAP policies, and cross-user or cross-debate isolation;
121+
- billing, Stripe webhooks, quotas, daily limits, and cost accounting;
122+
- migrations and data integrity, concurrency, and the collaboration service;
123+
- parsers, validators, schemas at a trust boundary, prompt routing in the fake provider, and stream accounting;
124+
- a fixed bug that could plausibly come back.
125+
126+
Do not write tests that:
127+
128+
- restate a TypeScript type or a schema's shape;
129+
- check that a removed feature stays removed, or that a column, file, export, route, or translation key exists (the i18n catalog check already covers keys);
130+
- assert static copy, or only that a component renders;
131+
- only exercise mocks, or can never fail.
132+
133+
Keep a PR's test diff small enough to read next to the change. Deleting a test that cannot catch a real regression is not weakening tests; deleting or loosening one to make a failing run pass is. Never lower a coverage threshold in `vitest.config.ts` without Adam's approval.
134+
114135
## Hard boundaries
115136

116-
- Start bug fixes with a failing test or repeatable browser reproduction when a suitable test layer exists.
137+
- Start bug fixes with a failing test when the bug is in behavior listed under [What to test](#what-to-test), otherwise with a repeatable browser reproduction.
117138
- Stub sessions prove rendering only. Do not call them authenticated backend proof.
118139
- Never put staging or production credentials in jobs, logs, traces, screenshots, commits, comments, or docs. Two scoped exceptions reach jobs only through GitHub Actions secrets:
119140
- the protected staging values;

‎docs/testing.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ npx vitest run src/test/security/url-validation.test.ts
5353

5454
For a bug, watch the reproduction fail for the expected reason before implementing the fix.
5555

56+
Which behavior deserves a test, and which tests not to write, is in [AGENTS.md](../AGENTS.md#what-to-test). The short version: test specs where a regression is costly or invisible (auth, RLS, billing, quotas, migrations, concurrency, parsers, regressions of fixed bugs), and prove everything else by using the app.
57+
5658
## Collaboration service tests
5759

5860
```bash

0 commit comments

Comments
 (0)