test(students): add unit, integration and e2e tests for /students (#109) #137

Merged
djalim merged 3 commits from PMPR-109 into develop 2026-04-26 12:33:58 +00:00
Collaborator

Summary

  • Unit (tests/unit/students_test.ts): fixture shapes, mock API (GET/POST/PUT/DELETE, 400/404), mock DB CRUD
  • Integration (tests/integration/students_test.ts): real DB via testDb — list, filter by promo, create, get, update, delete, not-found cases
  • E2E (tests/e2e/students_test.ts): calls Fresh handlers directly with mock FreshContext + real DB — covers auth (employee vs non-employee → 200 vs empty/403), 400/404 responses

Also adds:

  • tests/helpers/handler.ts — shared utilities (makeEmployeeContext, makeContextWithAffiliation, makeGetRequest, makeJsonRequest) used by all future e2e tests
  • deno task test:e2e task
  • E2E step in CI (test.yml)

Test plan

  • deno task test:unit — 37 passed
  • deno task test:integration — 11 passed
  • deno task test:e2e — 13 passed

closes #109

## Summary - **Unit** (`tests/unit/students_test.ts`): fixture shapes, mock API (GET/POST/PUT/DELETE, 400/404), mock DB CRUD - **Integration** (`tests/integration/students_test.ts`): real DB via `testDb` — list, filter by promo, create, get, update, delete, not-found cases - **E2E** (`tests/e2e/students_test.ts`): calls Fresh handlers directly with mock `FreshContext` + real DB — covers auth (employee vs non-employee → 200 vs empty/403), 400/404 responses Also adds: - `tests/helpers/handler.ts` — shared utilities (`makeEmployeeContext`, `makeContextWithAffiliation`, `makeGetRequest`, `makeJsonRequest`) used by all future e2e tests - `deno task test:e2e` task - E2E step in CI (`test.yml`) ## Test plan - [x] `deno task test:unit` — 37 passed - [x] `deno task test:integration` — 11 passed - [x] `deno task test:e2e` — 13 passed closes #109
djalim added 1 commit 2026-04-26 12:14:23 +00:00
test(students): add unit, integration and e2e tests for /students (#109)
Check Deno code / Check Deno code (pull_request) Failing after 5s
Tests / Unit tests (pull_request) Successful in 12s
Tests / Integration tests (pull_request) Successful in 58s
e5c6c389ea
- unit: fixture shapes, mock API (GET/POST/PUT/DELETE), mock DB operations
- integration: real DB CRUD via testDb (list, filter, create, get, update, delete)
- e2e: handler calls directly with mock FreshContext + real DB
  covers auth (employee vs non-employee), 400/403/404 cases
- adds test:e2e deno task and CI step
- adds tests/helpers/handler.ts with makeEmployeeContext, makeContextWithAffiliation,
  makeGetRequest, makeJsonRequest utilities

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
djalim added 1 commit 2026-04-26 12:18:31 +00:00
style: fix deno fmt on students tests and drizzle.config
Check Deno code / Check Deno code (pull_request) Failing after 8s
Tests / Unit tests (pull_request) Successful in 11s
Tests / Integration tests (pull_request) Successful in 58s
cd5c524ff0
djalim added 1 commit 2026-04-26 12:32:03 +00:00
ci: remove Run tests step from lint workflow
Check Deno code / Check Deno code (push) Successful in 6s
Tests / Unit tests (push) Successful in 12s
Tests / Integration tests (push) Successful in 57s
Check Deno code / Check Deno code (pull_request) Successful in 6s
Tests / Unit tests (pull_request) Successful in 12s
Tests / Integration tests (pull_request) Successful in 1m3s
e2f5bf7b95
djalim merged commit e2f5bf7b95 into develop 2026-04-26 12:33:58 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: admin/PolyMPR#137