Add integration test for search endpoint returning empty results (#765) - #849
Open
Bogunrot wants to merge 1 commit into
Open
Add integration test for search endpoint returning empty results (#765)#849Bogunrot wants to merge 1 commit into
Bogunrot wants to merge 1 commit into
Conversation
… 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
|
@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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 mocksfetchCreatorListand 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
/searchroute — 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 endpointGET /api/v1/creators?search=zzz-nonexistent-query-999→ 200,items: []hasMoreisfalse,totalis0Compatibility 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.tsPre-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_SECRETmissing from config schema). This affects all integration tests that import the real Expressapp(includingcreator-list-search-filter,creator-list-search-partial-name, etc.) and is unrelated to this change.Tests that don't import
apppass: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 inafterAll.