mengw15 opened a new pull request, #6764:
URL: https://github.com/apache/texera/pull/6764

   ### What changes were proposed in this PR?
   
   Extends the two auth-layer service specs
   (`frontend/src/app/common/service/user/user.service.ts`,
   `frontend/src/app/common/service/user/auth.service.ts`) to cover the state,
   avatar and registration paths they had left untested. No production code was
   changed.
   
   **`UserService`** (+6 tests)
   
   - `changeUser` / `getCurrentUser` — sets the current user (assigning an 
`hsl(…)`
     color) and emits it on `userChanged`;
   - `isAdmin` — true only for the `ADMIN` role;
   - `getAvatar` — returns `undefined` for an empty id; returns the cached 
object URL
     while fresh; and the network path (`fetchBlob`) — wraps the fetched blob 
in an
     object URL and caches it, or returns `undefined` when the fetch fails.
     `getAvatar` / `fetchBlob` use the native `fetch`/`URL` globals (not
     `HttpClient`), so those globals are stubbed deterministically and the 
originals
     are restored in `afterEach`.
   
   **`AuthService`** (+4 tests)
   
   - `registerAutoLogout` — with `vi.useFakeTimers()`, schedules a logout that 
fires
     once the token expiry elapses, and is a no-op when the token is already 
expired
     (real timers restored in `afterEach`);
   - the invite-only inactive-user branch when registration **is** required
     (`checkRegistrationRequired` → `true`) opens the registration modal
     (`openRegistrationModal`), and `submitRegistration` PUTs the 
affiliation/reason
     when the modal is confirmed. (The registration-**not**-required branch is 
already
     covered.)
   
   ### Any related issues, documentation, discussions?
   
   Closes #6753
   
   ### How was this PR tested?
   
   Extended unit tests, run locally in `frontend/` (all green; the failure path 
was
   verified by breaking the timer and network assertions to confirm the suite 
goes
   red):
   
   ```
   ng test --watch=false --include 
src/app/common/service/user/user.service.spec.ts   # 16 passed
   ng test --watch=false --include 
src/app/common/service/user/auth.service.spec.ts   # 17 passed
   prettier --write <specs>   # clean
   eslint  <specs>            # clean
   ```
   
   ### Was this PR authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code (Opus 4.8 [1M context])
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to