Skip to content

fix(tests): P0 test coverage - services & error handler#11

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1776939169-p0-test-coverage-fixes
Open

fix(tests): P0 test coverage - services & error handler#11
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1776939169-p0-test-coverage-fixes

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Addresses the three P0 gaps identified in the test coverage analysis:

  1. New HttpErrorHandler tests (error.service.spec.ts) — 6 tests covering all 3 error-handling paths: client-side ErrorEvent, server-side HTTP status codes, and Spring MVC errors header parsing (including edge cases for missing errorMessage and empty arrays).

  2. Real HTTP tests for 5 stub-only services — Replaced the expect(service).toBeTruthy() stubs in PetService, VetService, VisitService, SpecialtyService, and PetTypeService with full CRUD test suites (get all, get by id, add, update, delete) using HttpTestingController. Each spec verifies HTTP method, URL, request body, and response handling. addPet and addVisit verify their owner-scoped URL construction.

  3. 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 an httpClientSpy that wasn't wired into the test module. Replaced with a working test that uses HttpTestingController.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

  • Verify test fixture shapes match actual interfaces — Each spec hardcodes test data (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.
  • Verify addPet and addVisit URL patterns — These tests assert owner-scoped URLs (owners/{id}/pets, owners/{id}/pets/{id}/visits). Confirm these match the actual service implementations in pet.service.ts and visit.service.ts.
  • Check the owner error test assertion strengthexpect(errorMsg).toContain('404') is loose. Consider whether an exact match against the HttpErrorHandler output format would be more appropriate.
  • Consider whether error-path tests are needed for the 5 new service specs — Only OwnerService has an error-path test. The other 5 services delegate to HttpErrorHandler (now tested separately), but integration-level error tests may still be valuable.

Test plan: Run npx ng test --watch=false --browsers=ChromeHeadless and confirm 70/70 pass. Optionally inspect coverage with npx ng test --code-coverage to confirm the new tests actually hit the service and error handler source lines.

Notes

  • The 5 new service specs follow a uniform pattern (copy-paste with adaptations per service). This is intentional — each service has the same CRUD shape — but worth a quick scan to confirm service-specific details (URLs, method signatures like string vs number for ID params) are correct.
  • Uses the deprecated subscribe(nextFn, errorFn) signature in the owner error test rather than subscribe({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


Open in Devin Review

- 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.
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

@VedantKh

Copy link
Copy Markdown

you are missing some tests still, resolve other high importance gaps in test coverage

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.

1 participant