|
| 1 | +--- |
| 2 | +name: write-api-e2e-tests |
| 3 | +description: > |
| 4 | + Write API end-to-end tests. Use when adding or changing API endpoints, or when |
| 5 | + the user asks for API e2e, smoke, or contract tests. |
| 6 | +allowed-tools: Bash, Read, Glob, Grep, Edit, Write, AskUserQuestion |
| 7 | +--- |
| 8 | + |
| 9 | +# Write API end-to-end tests |
| 10 | + |
| 11 | +Write or extend API end-to-end tests. |
| 12 | + |
| 13 | +## When to use |
| 14 | + |
| 15 | +- New or changed API endpoints. |
| 16 | +- User asks for API e2e, smoke, or contract tests. |
| 17 | +- Critical API behaviour needs regression coverage. |
| 18 | + |
| 19 | +## When not to use |
| 20 | + |
| 21 | +- Domain or SQL correctness → use `write-unit-tests`. |
| 22 | +- Temporal, OpenSearch, or other eventual side effects outside the documented API e2e scope. |
| 23 | +- Creating a new testing framework or suite style. |
| 24 | + |
| 25 | +## Source of truth |
| 26 | + |
| 27 | +Read before writing. Follow these ADRs and existing suite structure; do not |
| 28 | +invent a parallel testing style. |
| 29 | + |
| 30 | +- [ADR-0012](../../../docs/adr/0012-api-e2e-test-architecture.md) — runtime, isolation, supported surfaces, scope, and assertions. |
| 31 | +- [ADR-0013](../../../docs/adr/0013-api-e2e-test-suite-design.md) — suite organisation, helpers, and conventions. |
| 32 | + |
| 33 | +Current default entrypoint: |
| 34 | + |
| 35 | +- `.github/scripts/public-api-e2e-tests.sh` |
| 36 | + |
| 37 | +## Workflow |
| 38 | + |
| 39 | +1. Identify the API surface. Default to Public API unless the user specifies otherwise. |
| 40 | +2. Read ADR-0012 and ADR-0013. |
| 41 | +3. Add or extend the appropriate suite and register it if required. |
| 42 | +4. Run the affected suite locally and fix failures until green. |
| 43 | +5. If required fixtures cannot be created through the API, prefer testing supported scenarios and explain any coverage gaps instead of seeding the database directly. |
| 44 | +6. Suggest production testability improvements only when they make the API easier to test, and ask before changing production code. |
| 45 | + |
| 46 | +## Run |
| 47 | + |
| 48 | +Export the environment variables required by the suite entrypoint. |
| 49 | + |
| 50 | +```bash |
| 51 | +bash .github/scripts/public-api-e2e-tests.sh |
| 52 | +``` |
| 53 | + |
| 54 | +Refer to ADR-0012 and the suite entrypoint for environment setup, reset behaviour, |
| 55 | +and local development workflows. |
| 56 | + |
| 57 | +## Guardrails |
| 58 | + |
| 59 | +- Keep tests focused on observable API behaviour. |
| 60 | + |
| 61 | +## Output |
| 62 | + |
| 63 | +- Suites and cases added |
| 64 | +- How to re-run |
| 65 | +- Coverage gaps, if any |
| 66 | +- Optional testability suggestions |
0 commit comments