Skip to content

Donation E2E integration testing #23

@thaninbew

Description

@thaninbew

Summary:

Write integration tests that verify the complete donation flow from HTTP request through service layer to database persistence. Test all endpoints and error scenarios.

Files to create:

  • apps/backend/test/donations.e2e-spec.ts

Test scenarios:

  1. POST /api/donations - successful one-time donation creation
  2. POST /api/donations - successful recurring donation with interval
  3. POST /api/donations - validation errors:
    • Negative amount returns 400
    • Invalid email format returns 400
    • Recurring without interval returns 400
    • One-time with interval returns 400
  4. GET /api/donations/public - returns only non-anonymous donations
  5. GET /api/donations/stats - returns correct total and count

Acceptance criteria:

  • Tests use real database (test database or in-memory SQLite)
  • All endpoints return correct status codes
  • Response bodies match expected DTO shapes
  • Database state verified after POST operations
  • Tests clean up after themselves (transactions or teardown)

Notes:

Use supertest for HTTP testing and NestJS Test.createTestingModule(). Reference existing test patterns in the repo. Each test should be independent.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions