Skip to content

test(frontend): add unit test coverage for HubService#6390

Merged
mengw15 merged 1 commit into
apache:mainfrom
mengw15:chore/6387-hub-service-test
Jul 13, 2026
Merged

test(frontend): add unit test coverage for HubService#6390
mengw15 merged 1 commit into
apache:mainfrom
mengw15:chore/6387-hub-service-test

Conversation

@mengw15

@mengw15 mengw15 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

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). HubService is a
thin HttpClient wrapper with ~10 Observable-returning methods; the suite
asserts 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 /count with the entityType param → emits the count.
  • cloneWorkflow — POST /workflow/clone/:wid with a null body → emits the new wid.
  • isLiked — GET /isLiked appending every id/type → emits LikedStatus[].
  • postLike / postUnlike — POST /like / /unlike with the json body/header → emit the boolean.
  • toggleLike — three cases: not-liked → likes then re-fetches the count; liked → unlikes then re-fetches; action returns false → state unchanged and the count defaults to 0.
  • postView — POST /view with the json body → emits the view count.
  • getTops — GET /getTops with entityType/uid/limit/appended actionTypes, plus the uid = -1 default and limit-omitted path.
  • getCounts — GET /counts appending types/ids/actionTypes, plus the empty-actionTypes (param omitted) path.
  • getUserAccess — GET /user-access appending types/ids → emits AccessResponse[].

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 was
verified by deliberately breaking an assertion to confirm the suite goes red):

ng test --watch=false --include src/app/hub/service/hub.service.spec.ts
# Test Files 1 passed (1) | Tests 15 passed (15)
prettier --write src/app/hub/service/hub.service.spec.ts   # unchanged
eslint  src/app/hub/service/hub.service.spec.ts            # clean

The suite uses HttpClientTestingModule / HttpTestingController (see
frontend/TESTING.md Recipe 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])

@github-actions github-actions Bot added the frontend Changes related to the frontend GUI label Jul 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • No candidates found from git blame history.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.ts with unit tests covering all HubService HTTP wrapper methods.
  • Adds coverage for toggleLike behavior 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.

Comment thread frontend/src/app/hub/service/hub.service.spec.ts Outdated
Comment thread frontend/src/app/hub/service/hub.service.spec.ts
Comment thread frontend/src/app/hub/service/hub.service.spec.ts Outdated
@codecov-commenter

codecov-commenter commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.44%. Comparing base (8dee1c7) to head (e653c94).

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           
Flag Coverage Δ *Carryforward flag
access-control-service 70.00% <ø> (ø) Carriedforward from 8dee1c7
agent-service 76.76% <ø> (ø) Carriedforward from 8dee1c7
amber 66.58% <ø> (ø) Carriedforward from 8dee1c7
computing-unit-managing-service 9.97% <ø> (ø) Carriedforward from 8dee1c7
config-service 52.30% <ø> (ø) Carriedforward from 8dee1c7
file-service 63.97% <ø> (ø) Carriedforward from 8dee1c7
frontend 65.00% <ø> (ø) Carriedforward from 8dee1c7
notebook-migration-service 78.94% <ø> (ø) Carriedforward from 8dee1c7
pyamber 91.18% <ø> (ø) Carriedforward from 8dee1c7
workflow-compiling-service 55.14% <ø> (ø) Carriedforward from 8dee1c7

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mengw15 mengw15 force-pushed the chore/6387-hub-service-test branch from 9e4e325 to e653c94 Compare July 13, 2026 06:34

@aglinxinyuan aglinxinyuan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@mengw15 mengw15 added this pull request to the merge queue Jul 13, 2026
Merged via the queue into apache:main with commit fd77b32 Jul 13, 2026
21 checks passed
@mengw15 mengw15 deleted the chore/6387-hub-service-test branch July 13, 2026 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend Changes related to the frontend GUI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add unit test coverage for HubService (hub.service.ts)

4 participants