Skip to content

test(frontend): add unit tests for AuthService#6470

Open
Ma77Ball wants to merge 2 commits into
apache:mainfrom
Ma77Ball:test/auth-service-spec
Open

test(frontend): add unit tests for AuthService#6470
Ma77Ball wants to merge 2 commits into
apache:mainfrom
Ma77Ball:test/auth-service-spec

Conversation

@Ma77Ball

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

  • Adds auth.service.spec.ts covering AuthService; no production code changed.
  • Verifies the static access-token helpers and the login, register and Google HTTP endpoints.
  • Covers logout and the loginWithExistingToken branches (no token, expired, valid, invite-only inactive).

Any related issues, documentation, discussions?

Closes: #6458

How was this PR tested?

  • Run cd frontend && npx nx test gui --include="**/auth.service.spec.ts", expect 10 passed.
  • Full frontend suite runs in CI via yarn test:ci, selected by the auto-applied frontend label.

Was this PR authored or co-authored using generative AI tooling?

Co-authored with Claude Opus 4.8 in compliance with ASF

@github-actions github-actions Bot added the frontend Changes related to the frontend GUI label Jul 16, 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.

@codecov-commenter

codecov-commenter commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.29%. Comparing base (c7473a1) to head (2d059e8).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #6470      +/-   ##
============================================
+ Coverage     70.20%   70.29%   +0.08%     
  Complexity     3390     3390              
============================================
  Files          1142     1142              
  Lines         44844    44871      +27     
  Branches       4949     4955       +6     
============================================
+ Hits          31484    31542      +58     
+ Misses        11725    11692      -33     
- Partials       1635     1637       +2     
Flag Coverage Δ *Carryforward flag
access-control-service 70.00% <ø> (ø) Carriedforward from 2db7de7
agent-service 76.76% <ø> (ø) Carriedforward from 2db7de7
amber 66.68% <ø> (ø) Carriedforward from 2db7de7
computing-unit-managing-service 9.97% <ø> (ø) Carriedforward from 2db7de7
config-service 52.30% <ø> (ø) Carriedforward from 2db7de7
file-service 65.63% <ø> (ø) Carriedforward from 2db7de7
frontend 69.18% <ø> (+0.21%) ⬆️
notebook-migration-service 78.94% <ø> (ø) Carriedforward from 2db7de7
pyamber 91.19% <ø> (ø) Carriedforward from 2db7de7
workflow-compiling-service 55.14% <ø> (ø) Carriedforward from 2db7de7

*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.

@Ma77Ball

Copy link
Copy Markdown
Contributor Author

/request-review @aglinxinyuan

@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!

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 spec to improve frontend unit-test coverage for the AuthService user-authentication helper/service without modifying production code. This supports the broader Angular frontend by validating client-side auth request shapes and local token handling behavior.

Changes:

  • Added auth.service.spec.ts covering static access-token helpers (set/get/remove) and logout behavior.
  • Added HTTP request assertions for register(), auth() and googleAuth() endpoint calls.
  • Added branch coverage for loginWithExistingToken() (no token, expired token, valid token, invite-only inactive user flow).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +81 to +84
afterEach(() => {
httpMock.verify();
localStorage.clear();
});
Comment on lines +103 to +107
describe("HTTP auth endpoints", () => {
it("register() POSTs username/password to the register endpoint", () => {
service.register("alice", "pw").subscribe();
const req = httpMock.expectOne(`${api}/${AuthService.REGISTER_ENDPOINT}`);
expect(req.request.method).toEqual("POST");
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 frontend unit tests for AuthService

4 participants