Skip to content

test: add end-to-end integration tests for auth and delivery flows - #80

Open
AdaBebe0 wants to merge 1 commit into
SwiftChainn:mainfrom
AdaBebe0:feat/integration-tests
Open

test: add end-to-end integration tests for auth and delivery flows#80
AdaBebe0 wants to merge 1 commit into
SwiftChainn:mainfrom
AdaBebe0:feat/integration-tests

Conversation

@AdaBebe0

Copy link
Copy Markdown

Adds two integration suites under tests/integration/ that chain real HTTP requests through the full Controller -> Service -> Model stack against a live MongoDB instance (mongodb-memory-server), complementing the existing per-endpoint tests in tests/*.test.ts.

auth.flow.integration.test.ts: register -> login -> reuse the issued JWT against a real protected route, covering both the success path and error conditions (unknown account, duplicate registration, insufficient role, tampered token, missing token).

delivery.flow.integration.test.ts: carries a single delivery through create -> read -> update -> archive -> restore against the CRUD model, and separately walks a delivery through every valid status transition (pending -> assigned -> picked_up -> in_transit -> delivered) as an authenticated driver against the status-transition endpoint. The two endpoint groups are exercised independently and documented as such, since they currently operate on two distinct Mongoose models (src/models/Delivery.ts vs src/models/deliveryModel.ts) despite sharing the /api/v1/deliveries prefix.

No inline mocks or hardcoded response data are used; only the logger is mocked. All assertions read back real persisted state from Mongo.

closes #57

Adds two integration suites under tests/integration/ that chain real
HTTP requests through the full Controller -> Service -> Model stack
against a live MongoDB instance (mongodb-memory-server), complementing
the existing per-endpoint tests in tests/*.test.ts.

auth.flow.integration.test.ts: register -> login -> reuse the issued
JWT against a real protected route, covering both the success path and
error conditions (unknown account, duplicate registration, insufficient
role, tampered token, missing token).

delivery.flow.integration.test.ts: carries a single delivery through
create -> read -> update -> archive -> restore against the CRUD model,
and separately walks a delivery through every valid status transition
(pending -> assigned -> picked_up -> in_transit -> delivered) as an
authenticated driver against the status-transition endpoint. The two
endpoint groups are exercised independently and documented as such,
since they currently operate on two distinct Mongoose models
(src/models/Delivery.ts vs src/models/deliveryModel.ts) despite sharing
the /api/v1/deliveries prefix.

No inline mocks or hardcoded response data are used; only the logger is
mocked. All assertions read back real persisted state from Mongo.
@drips-wave

drips-wave Bot commented Jul 26, 2026

Copy link
Copy Markdown

@AdaBebe0 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

Backend: Write API Integration Tests for Auth and Delivery flows

1 participant