Skip to content

Add distribution API integration tests and consistent error responses #55

Description

@pragmaticAweds

Context

Campaign and donation code now have focused service and validation tests, but the distribution API still has controller/service behavior that returns raw 500 responses for several expected cases and has no matching regression coverage in src/__tests__. The distribution endpoints should have predictable validation, not-found, and database-not-ready responses before more clients depend on them.

Scope

  • Add tests for POST /v1/distributions, PATCH /v1/distributions/:id, and GET /v1/distributions
  • Cover validation failures from policyMiddleware
  • Cover not-found updates with a 404 response
  • Cover database-not-initialized behavior with a stable error payload
  • Align distribution controller responses with shared API response helpers where practical
  • Replace broad console.error handling with project logger or shared error handling conventions

Out of Scope

  • Changing the distribution entity schema
  • Adding authentication requirements unless a separate product decision exists
  • Implementing indexer distribution persistence

Acceptance Criteria

  • Distribution endpoint tests cover success and expected failure paths
  • Expected client errors do not return generic 500 responses
  • Response payload shape is consistent with existing API conventions
  • Tests run under bun run test with coverage thresholds intact
  • bun run type-check passes
  • bun run test passes
  • bun run lint passes

Dependencies

Suggested Files or Packages

  • src/components/v1/distribution/
  • src/__tests__/
  • src/utils/apiResponse.ts
  • src/utils/errorHandler.ts

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions