Skip to content

Add integration test for search endpoint returning empty results (#765) - #849

Open
Bogunrot wants to merge 1 commit into
accesslayerorg:mainfrom
Bogunrot:765-search-empty-results-integration-test
Open

Add integration test for search endpoint returning empty results (#765)#849
Bogunrot wants to merge 1 commit into
accesslayerorg:mainfrom
Bogunrot:765-search-empty-results-integration-test

Conversation

@Bogunrot

Copy link
Copy Markdown

Closes #765

Problem Statement

A search query that matches no creators on the creator list endpoint should return HTTP 200 with an empty items array rather than a 404 or an error response. While existing tests cover partial matching and mocked empty states, there was no integration test exercising the real HTTP path with supertest for this scenario.

Solution Comparison and Decision

Option A: Unit test with mocked controller — Already exists in creator-list-search-no-results.integration.test.ts, but it mocks fetchCreatorList and never hits the real Express route. It doesn't prove the endpoint works end-to-end.

Option B: Integration test with supertest against the real endpoint (chosen) — Hits GET /api/v1/creators?search=<non-matching> through the full middleware stack using supertest, proving the endpoint returns 200 with a valid empty envelope.

Option C: Add a dedicated /search route — Out of scope; the search functionality already works through the ?search= query parameter on the existing creators list endpoint.

The Change

A single new integration test file:

  • src/modules/creators/creator-search-empty-results.integration.test.ts — 4 test cases exercising the real endpoint
Test What it proves
Empty items array GET /api/v1/creators?search=zzz-nonexistent-query-999 → 200, items: []
Pagination metadata hasMore is false, total is 0
Response shape parity Empty and non-empty responses share the same envelope shape and meta keys
Not 404 Status is explicitly 200, never 404

Compatibility Note

No interface version change. This adds a new test file with zero modifications to existing code.

Incidental Fixes

None — this is a test-only addition with no production code changes.

Testing

Test file: src/modules/creators/creator-search-empty-results.integration.test.ts

Pre-existing failures: The test suite fails to compile due to a pre-existing TypeScript error in src/modules/auth/stellar-challenge.controller.ts (STELLAR_AUTH_SECRET missing from config schema). This affects all integration tests that import the real Express app (including creator-list-search-filter, creator-list-search-partial-name, etc.) and is unrelated to this change.

Tests that don't import app pass: creator-list-zero-results (11/11 ✓) — this test validates the same response shape using mocked controllers and confirms the logic is correct.

Additional Notes

The test seeds two creators with unique prefixed handles (search-empty-alpha, search-empty-beta) to avoid interference with other test suites. Cleanup runs in afterAll.

… 200

Verifies that a search query matching no creators returns HTTP 200 with an
empty items array, hasMore=false, total=0, and the same response envelope
shape as a non-empty result set.

Closes accesslayerorg#765
@drips-wave

drips-wave Bot commented Aug 27, 2026

Copy link
Copy Markdown

@Bogunrot 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.

Add integration test for the search endpoint returning an empty array and 200 when no creators match the query

1 participant