Testing
Testing in Moveat is used to protect business correctness, not only to increase a coverage number. The highest-risk bugs are not visual. They are product-state bugs: duplicated meals, wrong calorie summaries, broken sessions, incorrect unit conversion, webhook retries that write twice, or Agent actions that bypass Platform validation.Coverage numbers below were measured on 2026-06-13 from the local repositories.
Current snapshot
Platform
21 test files, 61 passing tests. Coverage exists but currently fails the configured 80% global threshold.
Agent
Go tests pass. Statement coverage is 59.5% and no global coverage threshold is enforced yet.
Testing philosophy
Moveat should prioritize tests in this order:- Business invariants that can corrupt user data.
- Auth and authorization boundaries.
- Agent-to-Platform contract behavior.
- Unit conversion and time-zone handling.
- External integration adapters.
- Low-risk wiring and static helpers.
Platform testing
Platform uses Vitest for TypeScript tests.Commands
yarn verify runs linting, typecheck, tests and build.
Coverage result
What Platform already tests
Main Platform gaps
Recommended Platform tests
Meal idempotency
Replaying the same idempotency key should return the same entry and must not increment summaries twice.
Webhook race safety
Concurrent duplicate writes should safely handle unique conflicts and preserve exactly-once summary increments.
Onboarding gates
Meal, weight and workout actions that require profile context should fail cleanly when onboarding is incomplete.
Weight display contract
Latest and list responses should preserve the response-level
unitSystem wrapper and server-side conversion.Workout persistence
Workout sessions should test exercises, sets, invalid payloads and future idempotency behavior.
Session guard
Missing, expired and malformed sessions should return predictable unauthorized errors.
Agent testing
Agent uses the standard Go test runner.Commands
GOCACHE and GOMODCACHE to /tmp so local runs do not depend on user-level cache directories.
Package-level coverage
What Agent already tests
Main Agent gaps
Recommended Agent tests
- Platform client attaches internal auth token, timeout, correlation ID and idempotency key.
- Platform client maps non-2xx responses into typed errors.
- Channel resolution caches safely but never becomes source of truth.
- Register meal flow derives idempotency from the WhatsApp message ID.
- LLM parser handles incomplete, malformed and partially valid JSON.
- Media download validates MIME type and handles Meta API failures.
- Startup fails fast when required LLM or Platform configuration is missing.
Deploy readiness policy
Before deploying Platform:- Platform tests pass.
- Agent tests pass.
- Swagger/OpenAPI reflects the Platform contract.
- Agent DTO/client code matches the internal API contract.
- Idempotency and auth behavior are manually verified in a local or staging-like environment.
- Grafana dashboards are ready to inspect errors after deploy.
