Skip to content

Add integration test for /api/markets - #721

Merged
greatest0fallt1me merged 3 commits into
Predictify-org:mainfrom
Stranger-11:task/integration-markets-test
Jul 29, 2026
Merged

Add integration test for /api/markets#721
greatest0fallt1me merged 3 commits into
Predictify-org:mainfrom
Stranger-11:task/integration-markets-test

Conversation

@Stranger-11

Copy link
Copy Markdown

Overview

This PR adds comprehensive integration tests for the /api/markets endpoints using supertest and Testcontainers-backed PostgreSQL, providing end-to-end coverage across all public market routes.

Related Issue

Closes #483

Changes

Integration test expansion

  • [MODIFY] tests/integration/markets.test.ts expanded from 4 tests to 22 tests covering all public /api/markets endpoints
  • Added requestContextStorage middleware and errorHandler middleware for realistic error envelope responses
  • Added MarketSeed interface and enhanced seedMarkets helper supporting featured, featuredAt, and createdAt fields

Test Coverage

Group Tests What it covers
listing 3 Basic listing, archived exclusion, limit param
empty state 1 No markets returns empty data and null nextCursor
pagination 3 Multi-page cursor pagination, single-page, garbage cursor restart
single market by ID 2 Detail lookup by ID, 404 for non-existent ID
featured markets 3 featuredAt DESC ordering, exclusion of non-featured/archived, empty state
upcoming markets 3 resolutionTime ASC ordering, active exclusion, empty state
search markets 4 Full-text match, non-matching query, missing q param, empty q param
input validation 5 limit bounds (0, >100, non-numeric), default page size, correlationId, error details

Verification

TypeScript compilation passes. Linter has no errors in changed file. Integration tests require Docker (npm run test:integration). All tests follow established patterns from existing integration tests and use the same Testcontainers PostgreSQL setup.

Expands integration test coverage from 4 to 22 tests covering listing, empty state, pagination, single market lookup, featured, upcoming, search, and input validation.

Closes Predictify-org#483
@drips-wave

drips-wave Bot commented Jul 28, 2026

Copy link
Copy Markdown

@Stranger-11 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

@greatest0fallt1me
greatest0fallt1me merged commit c78b61b into Predictify-org:main Jul 29, 2026
1 check passed
@greatest0fallt1me

Copy link
Copy Markdown
Contributor

Green ✅ merging. Thanks for the contribution!

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.

Add integration test for /api/markets

2 participants