Files
nuzlocke-tracker/.beans/nuzlocke-tracker-0arz--integration-tests-for-runs-encounters-api.md
Julian Tabel d6a0b60585 Add integration tests for Runs & Encounters API
28 tests covering run CRUD, rules JSONB storage, encounter creation,
route-lock enforcement, shinyClause and giftClause bypasses, status
transitions (complete/fail), and encounter update/delete.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 12:58:28 +01:00

31 lines
1.3 KiB
Markdown

---
# nuzlocke-tracker-0arz
title: Integration tests for Runs & Encounters API
status: completed
type: task
priority: normal
created_at: 2026-02-10T09:33:21Z
updated_at: 2026-02-21T11:54:42Z
parent: nuzlocke-tracker-yzpb
---
Write integration tests for the core run tracking and encounter API endpoints. This is the heart of the application.
## Checklist
- [x] Test run CRUD operations (create, list, get, update, delete)
- [x] Test run creation with rules configuration (JSONB field)
- [x] Test encounter logging on a run (create encounter on a route)
- [x] Test encounter status changes (alive → dead, faintLevel, deathCause)
- [x] Test route-lock enforcement (duplicate sibling encounter → 409)
- [x] Test shiny encounter handling (shinyClause bypasses route-lock)
- [x] Test gift clause bypass (giftClause=true, origin=gift bypasses route-lock)
- [x] Test ending a run (completion/failure, completed_at set, 400 on double-end)
- [x] Test error cases (404 for invalid run/route/pokemon, 400 for parent route, 422 for missing fields)
## Notes
- Run endpoints: `backend/src/app/api/runs.py`
- Encounter endpoints: `backend/src/app/api/encounters.py`
- This is the most critical area — Nuzlocke rules enforcement should be thoroughly tested
- Tests need game + pokemon + route fixtures as prerequisites