Skip to content

Conversation

@SamNie2027
Copy link
Contributor

@SamNie2027 SamNie2027 commented Oct 31, 2025

Description

More Donation Controller Unit tests for the POST /api/donations, GET /api/donations/public, and GET /api/donations/stats endpoints
Donation e2e integration tests for the POST /api/donations, GET /api/donations/public, and GET /api/donations/stats endpoints

Testing & Verification

E2E integration tests:
Smoke test to validate test setup

  1. POST /api/donations - successful one-time donation creation
  2. POST /api/donations - successful recurring donation with interval
  3. POST /api/donations - validation errors:
  4. Negative amount returns 400
  5. Invalid email format returns 400
  6. Donation marked recurring without a specified interval returns 400
  7. One-time with interval returns 400
  8. Throws 500 if the database errors
  9. Rejects with missing first name
  10. Rejects with missing last name
  11. Rejects with missing email
  12. Rejects with missing amount
  13. Accepts if isAnonymous is missing
  14. Rejects with missing donationType
  15. Rejects with invalid recurring
  16. Rejects with invalid donationType
  17. GET /api/donations/public - returns only non-anonymous donations
  18. Returns no donations if there are none in the db
  19. Throws if db does
  20. Returns with correct DTO
  21. GET /api/donations/stats - returns correct total and count
  22. Returns correct total and count even with empty db
  23. throws if db throws

More tests for Donation integration tests (with mocks)
4. POST /api/donations - validation errors:
5. Negative amount returns 400
6. Invalid email format returns 400
7. Donation marked recurring without a specified interval returns 400
8. One-time with interval returns 400
9. Throws 500 if the database errors
10. Rejects with missing first name
11. Rejects with missing last name
12. Rejects with missing email
13. Rejects with missing amount
14. Accepts if isAnonymous is missing
15. Rejects with missing donationType
16. Rejects with invalid recurring
17. Rejects with invalid donationType
18. GET /api/donations/public - returns only non-anonymous donations
19. Returns no donations if there are none in the db
21. Throws if db does
22. Returns with correct DTO
23. GET /api/donations/stats - returns correct total and count
24. Returns correct total and count even with empty db
25. throws if db throws

Related Issues

Closes #23

@SamNie2027 SamNie2027 changed the title 23 Donation e2e integration testing 23 Donation e2e integration and controller unit testing Nov 10, 2025
@SamNie2027 SamNie2027 self-assigned this Nov 10, 2025
@SamNie2027 SamNie2027 marked this pull request as ready for review November 17, 2025 23:30
@SamNie2027
Copy link
Contributor Author

Looks like typeORM doesn't return the dates until they're like fully created in the DB and the object returned by saved doesn't include those dates that are defaulted to now() as specified in the migration. I made a potential fix by returning an object found through findOne (which gets the object after it's fully made in the db) but that could lead to worst performance at large scale because it's giving an extra query for info that may not be necessary

@SamNie2027 SamNie2027 requested a review from thaninbew November 22, 2025 23:49
@thaninbew thaninbew merged commit df1afec into main Nov 23, 2025
4 checks passed
@thaninbew thaninbew deleted the 23-Donation-E2E-integration-testing branch November 23, 2025 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Donation E2E integration testing

4 participants