test(frontend): add unit tests for AuthService#6470
Conversation
Automated Reviewer SuggestionsBased on the
|
Codecov Report✅ All modified and coverable lines are covered by tests. 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
*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:
|
|
/request-review @aglinxinyuan |
There was a problem hiding this comment.
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.tscovering static access-token helpers (set/get/remove) and logout behavior. - Added HTTP request assertions for
register(),auth()andgoogleAuth()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.
| afterEach(() => { | ||
| httpMock.verify(); | ||
| localStorage.clear(); | ||
| }); |
| 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"); |
What changes were proposed in this PR?
Any related issues, documentation, discussions?
Closes: #6458
How was this PR tested?
cd frontend && npx nx test gui --include="**/auth.service.spec.ts", expect 10 passed.yarn test:ci, selected by the auto-appliedfrontendlabel.Was this PR authored or co-authored using generative AI tooling?
Co-authored with Claude Opus 4.8 in compliance with ASF