Skip to content

Add donation API integration tests and stable error mapping #62

Description

@pragmaticAweds

Context

Donation service and validation tests exist, but the route/controller layer has several public endpoints with authentication, admin checks, query validation, and not-found behavior. Controller errors currently collapse most failures into INTERNAL_ERROR, including database-not-ready paths, so clients do not have a fully tested response contract.

Scope

  • Add route/controller tests for donation creation, list, detail, campaign donations, user donations, my donations, and stats
  • Cover auth-required and admin-required responses
  • Cover validation failures from policyMiddleware
  • Cover donation not found with a 404 response
  • Map database-not-initialized errors to a stable API error code
  • Ensure response payloads use shared API response helpers consistently

Out of Scope

  • Changing donation schema fields
  • Adding new donation endpoints
  • External payment or chain confirmation logic

Acceptance Criteria

  • Donation API tests cover success and expected failure paths
  • Expected client/auth errors do not return generic 500 responses
  • Database-not-ready behavior has a stable error code and test
  • bun run type-check passes
  • bun run test passes
  • bun run lint passes

Suggested Files or Packages

  • src/components/v1/Donation/
  • src/__tests__/
  • src/utils/apiResponse.ts
  • src/appMiddlewares/jwtAuth.api.ts

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions