Skip to content

Add backend end-to-end test suite with database and Redis fixtures #170

Description

@Josie123-Dev

What

Create a working test/jest-e2e.json configuration and write end-to-end tests for the core API flows: authentication (JWT + wallet signature), credential CRUD, verification workflow, and data sharing. Tests should use a real PostgreSQL database and Redis instance (via test containers or a test database).

Why

The backend has 22 unit test spec files but zero e2e tests. package.json references npm run test:e2e but the jest-e2e.json config file doesn't exist. Unit tests mock dependencies, so they can't catch integration issues like incorrect TypeORM queries, broken middleware chains, or auth flow failures. For a health credential platform, integration testing is critical.

Scope

In scope:

  • Create backend/test/jest-e2e.json with proper NestJS e2e test configuration
  • Create a test database setup/teardown utility (TypeORM migrations or synchronize: true for test DB)
  • Write e2e tests for: auth flow (register + login via wallet signature), credential CRUD (create, read, update, delete), verification workflow (submit, approve, reject), data sharing (share, access, revoke)
  • Add test:e2e script that runs against a test database
  • Add test fixtures for common test data

Out of scope:

  • Load testing or performance testing
  • Contract interaction testing (mock Soroban calls)
  • IPFS integration testing (mock Pinata calls)
  • AI/Groq integration testing (mock Groq calls)

Acceptance Criteria

  • backend/test/jest-e2e.json exists and is valid
  • npm run test:e2e runs successfully (requires PostgreSQL + Redis)
  • At least 4 e2e test suites: auth, credentials, verification, data-sharing
  • Each suite tests the happy path and at least 2 error cases
  • Tests use a dedicated test database (not the dev database)
  • Database is cleaned between tests (beforeEach or afterAll)
  • Tests are independent (no ordering dependencies)

Technical Context

  • NestJS e2e testing: https://docs.nestjs.com/fundamentals/testing
  • Use @nestjs/testing Test.createTestingModule() with supertest for HTTP assertions
  • TypeORM test config: use a separate test database with synchronize: true
  • Redis: use a separate DB index (e.g., DB 15) for tests
  • Existing unit tests: backend/src/**/*.spec.ts (22 files) — follow their patterns

Metadata

Metadata

Assignees

No one assigned

    Labels

    GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardThird CampaignCampaign: Third CampaignbackendBackend related issuesdifficulty:hardHard difficulty issuespriority:highHigh priority issuestestingTest coverage and quality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions