test(frontend): add unit test coverage for HubService#6390
Conversation
Automated Reviewer SuggestionsBased on the
|
There was a problem hiding this comment.
Pull request overview
Adds a new Vitest unit test suite for the Angular HubService (frontend/src/app/hub/service/hub.service.ts) using HttpClientTestingModule/HttpTestingController, aiming to validate request shape (method/URL/query/body/headers) and response mapping without hitting a backend.
Changes:
- Introduces
hub.service.spec.tswith unit tests covering allHubServiceHTTP wrapper methods. - Adds coverage for
toggleLikebehavior across like/unlike/failure paths, plus request/param assertions for the remaining endpoints.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6390 +/- ##
=========================================
Coverage 68.44% 68.44%
Complexity 3382 3382
=========================================
Files 1142 1142
Lines 44828 44828
Branches 4948 4948
=========================================
Hits 30681 30681
Misses 12507 12507
Partials 1640 1640
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
9e4e325 to
e653c94
Compare
What changes were proposed in this PR?
Adds a Vitest unit-test suite for
frontend/src/app/hub/service/hub.service.ts(
HubService), which previously had no spec (~30% coverage).HubServiceis athin
HttpClientwrapper with ~10Observable-returning methods; the suiteasserts each issues the expected request (method, URL, query params / body,
headers) and maps the response, using
HttpClientTestingModule+HttpTestingController— no backend.15 tests cover:
getCount— GET/countwith theentityTypeparam → emits the count.cloneWorkflow— POST/workflow/clone/:widwith a null body → emits the new wid.isLiked— GET/isLikedappending every id/type → emitsLikedStatus[].postLike/postUnlike— POST/like//unlikewith the json body/header → emit the boolean.toggleLike— three cases: not-liked → likes then re-fetches the count; liked → unlikes then re-fetches; action returnsfalse→ state unchanged and the count defaults to 0.postView— POST/viewwith the json body → emits the view count.getTops— GET/getTopswithentityType/uid/limit/appendedactionTypes, plus theuid= -1 default andlimit-omitted path.getCounts— GET/countsappending types/ids/actionTypes, plus the empty-actionTypes(param omitted) path.getUserAccess— GET/user-accessappending types/ids → emitsAccessResponse[].No production code was changed.
Any related issues, documentation, discussions?
Closes #6387
How was this PR tested?
New unit tests, run locally in
frontend/(all green; the failure path wasverified by deliberately breaking an assertion to confirm the suite goes red):
The suite uses
HttpClientTestingModule/HttpTestingController(seefrontend/TESTING.mdRecipe E), so it makes no real network calls.Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 4.8 [1M context])