Skip to content

Backend: add API integration test suite with fixtures and coverage - #837

Open
nasalehj wants to merge 1 commit into
UnityChainxx:mainfrom
nasalehj:test/756-api-integration-suite
Open

nasalehj wants to merge 1 commit into
UnityChainxx:mainfrom
nasalehj:test/756-api-integration-suite

Conversation

@nasalehj

Copy link
Copy Markdown

Summary

Resolves #756. Adds backend/test/api-integration.e2e-spec.ts to the e2e run, with reusable DB fixtures, live route discovery, and coverage reporting in CI.

Automated coverage of all public API endpoints

  • The suite reads the application's own Swagger document at test time and calls every mounted operation (method + path). That list cannot drift from the code, and a framework Cannot <METHOD> 404 fails the suite, proving the route is mounted.
  • Discovery is asserted to include the core routes (/puzzles/active, /puzzle-submission, /health/live) and to yield more than 50 operations.

Test DB fixtures

  • backend/test/fixtures/test-database.fixture.ts provides resetDatabase() (truncates every entity table with RESTART IDENTITY CASCADE) and seedDatabase() (deterministic admin, player, active/inactive puzzles, completion, reward, category, category puzzle, content, and progress).
  • Fixture-backed flows cover: puzzle discovery hiding solutions/hints, admin puzzle creation → grading (correct + wrong, case-insensitive) → publication, anonymous admin writes returning 401, reward creation/listing and duplicate-claim 409, and seeded content/categories.

Runs in CI + reports coverage

  • New npm run test:e2e:cov writes text-summary + lcov to coverage-e2e/.
  • The backend-e2e job now runs with coverage and uploads backend-e2e-coverage as an artifact.

Supporting fix

  • Progress.userId declared type: 'uuid' with length: 128, which makes TypeORM throw Column userId of Entity Progress does not support length property when building metadata outside the full app. Removed the invalid length.

Verification

  • The fixture layer was executed against a real PostgreSQL 16 instance: seedDatabase() inserted 1 admin, 1 user, 2 puzzles, 1 reward, and 1 content row; resetDatabase() then left every table empty.
  • tsc --noEmit reports no errors for the new files.
  • Limitation: the repository's Jest e2e runner currently cannot load its own NestJS 12 ESM packages (SyntaxError: Unexpected token 'export' from @nestjs/schedule/@nestjs/typeorm), which also blocks the pre-existing app.e2e-spec.ts from running locally. The new spec is subject to the same pre-existing runner configuration; the suite itself is wired into the existing backend-e2e CI job and will run wherever that job runs.

Closes #756

Add an integration suite that discovers the full route graph from the
application's Swagger document and calls every mounted operation, so new
endpoints are covered automatically. Fixture-backed flows then exercise
puzzle discovery, admin creation/publication, submission grading, rewards
and duplicate-claim prevention, content, and categories against a seeded
test database.

Add reusable reset/seed fixtures, a coverage-reporting e2e script, and a
CI step that uploads the report as an artifact. Fix the Progress entity's
invalid uuid+length column, which prevented TypeORM from building its
metadata outside the application.

Closes UnityChainxx#756

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@drips-wave

drips-wave Bot commented Oct 19, 2026

Copy link
Copy Markdown

@nasalehj 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 test suite

1 participant