Skip to content

Test/consolidate test suite#58

Closed
ademboukabes wants to merge 50 commits into
mainfrom
test/consolidate-test-suite
Closed

Test/consolidate test suite#58
ademboukabes wants to merge 50 commits into
mainfrom
test/consolidate-test-suite

Conversation

@ademboukabes

Copy link
Copy Markdown
Collaborator

Note

Context
This PR introduces a robust testing infrastructure to ensure the reliability of our core services. It adds extensive Unit, Integration, and End-to-End (E2E) tests tailored to the new asynchronous OTP authentication flow and the AI photo processing pipeline.

Test Coverage & Scope

1. Unit Tests (tests/unit/)

  • Auth & Security: Validates the two-step mobile registration flow (OTP), login intent, JWT token validation, and rate-limiting limits.
  • Photo Approval Service: Tests the decision-making lifecycle for photos (Approve/Reject/Pending) and verifies audit logging behaviors.
  • AI Worker Messaging: Verifies that NATS messages for single faces and group photos are properly processed and that notifications are correctly dispatched.
  • Data Privacy: Ensures strict GDPR compliance by confirming no plaintext emails or sensitive data leak into the server logs.

2. Integration Tests (tests/integration/)

  • Database Interactions: Uses a real PostgreSQL database to verify that AI-generated face embeddings (vectors) are correctly persisted upon user enrollment without dimension errors.
  • Flow state: Ensures that OTP sessions are successfully stored and cleaned up in Redis during the registration cycle.

3. End-to-End (E2E) Tests (tests/e2e/)

  • Full Authentication Pipeline: Simulates a complete user journey: hitting the /register endpoint, retrieving the OTP directly from Redis, validating via /register/verify, and successfully logging in.
  • AI Load & Edge Cases: Simulates real-world traffic by uploading multiple photos (empty photos, group photos, and massive batches of 20+ photos) to ensure the API and AI Worker can handle concurrent load without crashing.

Verification

All tests are passing successfully (140/140) across the entire suite.

  • Unit tests passed locally
  • Integration tests passed locally
  • E2E tests passed locally

wailbentafat and others added 30 commits June 1, 2026 00:12
- Auto-approve group photos as public when no face matches any user
- Add ExpireStaleApprovals SQL + service method to unblock photos
  where users never respond (default 7-day timeout via config)
- Wire hourly expiry background task into FastAPI lifespan
This test validates the asynchronous workflow of the AI pipeline locally. It uploads a photo, triggers the NATS event, polls for the processing_job completion, and asserts that the photo status transitions to 'approved'.

Test output: 1 passed in ~1.5s
fix(photo-approval): resolve group photo lifecycle gaps
@ademboukabes ademboukabes requested a review from wailbentafat July 1, 2026 14:13
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.

3 participants