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>
This commit is contained in:
2026-02-21 12:58:28 +01:00
parent 79eabf4f9f
commit d6a0b60585
2 changed files with 466 additions and 11 deletions

View File

@@ -1,10 +1,11 @@
---
# nuzlocke-tracker-0arz
title: Integration tests for Runs & Encounters API
status: draft
status: completed
type: task
priority: normal
created_at: 2026-02-10T09:33:21Z
updated_at: 2026-02-10T09:33:21Z
updated_at: 2026-02-21T11:54:42Z
parent: nuzlocke-tracker-yzpb
---
@@ -12,15 +13,15 @@ Write integration tests for the core run tracking and encounter API endpoints. T
## Checklist
- [ ] Test run CRUD operations (create, list, get, update, delete)
- [ ] Test run creation with rules configuration (JSONB field)
- [ ] Test encounter logging on a run (create encounter on a route)
- [ ] Test encounter status changes (alive → dead, alive → retired, etc.)
- [ ] Test duplicate encounter prevention (dupes clause logic)
- [ ] Test shiny encounter handling
- [ ] Test egg encounter handling
- [ ] Test ending a run (completion/failure)
- [ ] Test error cases (encounter on invalid route, duplicate route encounters, etc.)
- [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