fix(tests): P0 test coverage - services & error handler#11
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
fix(tests): P0 test coverage - services & error handler#11devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
- Add comprehensive HttpErrorHandler tests (6 tests covering all 3 error paths) - Replace stub-only PetService spec with real HTTP tests (5 CRUD methods) - Replace stub-only VetService spec with real HTTP tests (5 CRUD methods) - Replace stub-only VisitService spec with real HTTP tests (5 CRUD methods) - Replace stub-only SpecialtyService spec with real HTTP tests (5 CRUD methods) - Replace stub-only PetTypeService spec with real HTTP tests (5 CRUD methods) - Fix broken error test in OwnerService spec (was using disconnected spy) All 70 tests pass.
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
you are missing some tests still, resolve other high importance gaps in test coverage |
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.
Summary
Addresses the three P0 gaps identified in the test coverage analysis:
New
HttpErrorHandlertests (error.service.spec.ts) — 6 tests covering all 3 error-handling paths: client-sideErrorEvent, server-side HTTP status codes, and Spring MVCerrorsheader parsing (including edge cases for missingerrorMessageand empty arrays).Real HTTP tests for 5 stub-only services — Replaced the
expect(service).toBeTruthy()stubs inPetService,VetService,VisitService,SpecialtyService, andPetTypeServicewith full CRUD test suites (get all, get by id, add, update, delete) usingHttpTestingController. Each spec verifies HTTP method, URL, request body, and response handling.addPetandaddVisitverify their owner-scoped URL construction.Fixed broken error test in
owner.service.spec.ts— The original test had a syntax bug (error assertion was inside the success callback via comma operator) and referenced anhttpClientSpythat wasn't wired into the test module. Replaced with a working test that usesHttpTestingController.flush()with a 404 status and subscribes with an error handler.All 70 tests pass locally. Net change: +723 lines, −236 lines across 7 spec files.
Review & Testing Checklist for Human
testPet,testVet,testVisit, etc.). Confirm required fields aren't missing and types are correct (e.g.,Pet.owner,Visit.pet). TypeScript won't catch mismatches in test data if fields are optional.addPetandaddVisitURL patterns — These tests assert owner-scoped URLs (owners/{id}/pets,owners/{id}/pets/{id}/visits). Confirm these match the actual service implementations inpet.service.tsandvisit.service.ts.expect(errorMsg).toContain('404')is loose. Consider whether an exact match against theHttpErrorHandleroutput format would be more appropriate.OwnerServicehas an error-path test. The other 5 services delegate toHttpErrorHandler(now tested separately), but integration-level error tests may still be valuable.Test plan: Run
npx ng test --watch=false --browsers=ChromeHeadlessand confirm 70/70 pass. Optionally inspect coverage withnpx ng test --code-coverageto confirm the new tests actually hit the service and error handler source lines.Notes
stringvsnumberfor ID params) are correct.subscribe(nextFn, errorFn)signature in the owner error test rather thansubscribe({next, error}). This works on the project's current RxJS version but may trigger deprecation warnings on upgrade.Link to Devin session: https://partner-workshops.devinenterprise.com/sessions/03cc3bd30e654edba1792a712ac25648