Frontend: test the HTTP API adapter, ratchet coverage gate - #15
Merged
Merged
Conversation
The frontend had only 2 smoke tests and no enforced coverage. This adds real logic tests + a jest coverage threshold, on a branch parallel to the backend work (based on the A0 test-infra PR #4) so it reviews independently. - export getIFFColor + estimateDistance from CameraDisplay so the pure HUD helpers are testable without the canvas. - tests: config layer (getConfig path resolution/defaults, URL builders, validateConfig, getFullConfig) and CameraDisplay helpers (IFF colour by prediction method incl. homography_source fallback; distance-from-bbox-height). - package.json: jest coverageThreshold on the logic layer (config + domain) — statements/lines >= 55%, branches >= 45%, functions >= 30%; test:ci runs --coverage. - gitignore the jest coverage/ output dir. 29 frontend tests pass (was 14); logic-layer coverage 63%. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Stacks on the frontend-coverage PR. Adds tests for apiAdapter and raises the jest coverage threshold. - tests: ApiResponse (isSuccess, getOrThrow success/throw), buildUrl (leading-slash normalization), and fetch-mocked get/post (success, HTTP error -> failed response, network error -> status 0, startCamera/stopCamera paths, JSON body serialization). - package.json: add apiAdapter.js to coverage scope; raise the global gate to statements/lines >= 65%, branches >= 55%, functions >= 40%. 40 frontend tests pass (was 29); apiAdapter coverage 86%. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What & why
Extends the frontend test coverage to the HTTP API adapter and ratchets the coverage gate up.
Changes
apiAdapter.test.js):ApiResponse—isSuccess,getOrThrow(returns data / throws with message orHTTP <status>)buildUrl— leading-slash normalizationget/post— success → parsed data, HTTP error → failedApiResponsewith status, network error → status 0,startCamera/stopCamerahit the right POST paths, JSON body serializationpackage.json— addedapiAdapter.jsto the coverage scope and raised the global gate: statements/lines ≥ 65%, branches ≥ 55%, functions ≥ 40%.Verification
apiAdapter.jscoverage 86%;npm run buildclean.🤖 Generated with Claude Code