You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Integration test suite probing both API endpoints across happy paths, edge cases, and documented behaviour boundaries — with assertions intentionally strict enough to surface quirks (silent 200s on bad input, wrong city data, timing violations, etc.).
Test coverage (api.integration.test.ts — 32 tests)
Auth — missing/invalid X-API-Key must return non-200 on both endpoints
Weather happy path — 200, non-empty JSON, contains weather keywords, body references the requested city by name
Weather case sensitivity — london / London / LONDON all resolve and reference the city
Weather edge cases — fake city, empty string, missing param, numeric string, non-ASCII (Zürich), SQL injection, consecutive calls must both cite the city
Research timing — response takes ≥ 3 000 ms (documented min) and ≤ 10 000 ms (documented 8 s + 2 s headroom); upper bound is expected to surface violations
Research edge cases — empty/missing topic, parallel same-topic calls (idempotency), different topics must differ, obscure topic, SQL injection
Key design choices
All 32 tests run unconditionally. vitest.config.ts global timeout raised to 30 s to accommodate the slow research endpoint.
The city-reference and keyword-relevance assertions are the primary quirk detectors — a response that returns 200 with data about the wrong city, or research that ignores the topic, will fail here.
CopilotAI
changed the title
Add API integration tests for weather and research endpoints
Add integration tests for /weather and /research endpoints
Jun 12, 2026
The HTTP status code is 200 — clients cannot detect failure from the status alone.
The data field is null rather than actual results — callers that don't inspect the body structure will silently consume empty data.
retry_after_seconds is provided but the endpoint to retry is not specified.
The field name casing is inconsistent: "rate limit exceeded. please wait." (lowercase) vs "Rate limit exceeded. please wait." (capitalised) appeared in different responses within the same test run.
non-existent city returns a clear error (location: Qxzplorf99999)
empty location string does not return weather data as if valid (location: "")
numeric string as location returns an error (location: "12345")
Quirk: All three return HTTP 200 with what appears to be weather data — no error status, no error message in the body. The API does not validate the location parameter at all; it either fabricates plausible-sounding weather or returns data for an unrelated location rather than rejecting the request.
3. /research responses are not topic-relevant
Failing test (1):
response contains content relevant to the researched topic (topic: solar energy)
Quirk: The response body does not contain any of the expected keywords (solar, energy, sun, panel, photovoltaic, renewable, electricity, power). The endpoint returns something but the content is not meaningfully related to the requested topic.
4. /research response time is faster than documented
Failing test (1):
response time is at least 3 seconds (as documented)
Actual:89 ms — far below the documented minimum of 3 seconds.
Quirk: The documentation states responses take 3–8 seconds ("simulating real-world scenarios like database queries or AI processing"), but at least some responses are near-instant. This could mean the API is serving cached/pre-computed results rather than doing real work, or the slow path is not always triggered.
5. /research accepts empty topic silently
Failing test (1):
empty topic string does not return research data as if valid (topic: "")
Quirk: Passing topic="" returns HTTP 200 without any error. Like the weather endpoint, there is no input validation — an empty topic is treated as a valid request.
Summary table
Quirk
Endpoint(s)
Severity
Rate limit returns 200 instead of 429, body has data: null
Both
High
Error message casing is inconsistent between responses
Both
Low
Invalid/empty/numeric locations accepted silently (200 with data)
/weather
Medium
Empty topic accepted silently (200)
/research
Medium
Response content not relevant to requested topic
/research
High
Response time far below documented 3–8 s minimum (89 ms)
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
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.
Integration test suite probing both API endpoints across happy paths, edge cases, and documented behaviour boundaries — with assertions intentionally strict enough to surface quirks (silent 200s on bad input, wrong city data, timing violations, etc.).
Test coverage (
api.integration.test.ts— 32 tests)X-API-Keymust return non-200 on both endpointslondon/London/LONDONall resolve and reference the cityZürich), SQL injection, consecutive calls must both cite the cityKey design choices
All 32 tests run unconditionally.
vitest.config.tsglobal timeout raised to 30 s to accommodate the slow research endpoint.The city-reference and keyword-relevance assertions are the primary quirk detectors — a response that returns 200 with data about the wrong city, or research that ignores the topic, will fail here.