mengw15 opened a new pull request, #6432:
URL: https://github.com/apache/texera/pull/6432
### What changes were proposed in this PR?
Adds a Vitest unit-test suite for `AIAssistantService`
(`frontend/src/app/workspace/service/ai-assistant/ai-assistant.service.ts`),
previously without a spec (~19% coverage). Uses `HttpClientTestingModule` +
`HttpTestingController` to assert request shape (method / URL / responseType
/
body) and response mapping — no backend.
8 tests cover:
- `checkAIAssistantEnabled` — GET `/isenabled` with `responseType: "text"`;
emits `"OpenAI"` for an `OpenAI` response, `"NoAiAssistant"` for any other
response, and falls back to `"NoAiAssistant"` when the request errors.
- `getTypeAnnotations` — POST `/annotationresult` with the `{ code,
lineNumber, allcode }` body; passes the `TypeAnnotationResponse` through.
- `locateUnannotated` — POST `/annotate-argument` with the `{ selectedCode,
startLine }` body; flattens the nested `underlying.result.value[]` payload into
`UnannotatedArgument[]`, emits `[]` on a null body, and errors with `"Request
to backend failed"` when the request fails.
No production code was changed.
### Any related issues, documentation, discussions?
Closes #6429
### 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/workspace/service/ai-assistant/ai-assistant.service.spec.ts
# Test Files 1 passed (1) | Tests 8 passed (8)
prettier --write <spec> # unchanged
eslint <spec> # clean
```
`HttpClientTestingModule` / `HttpTestingController` back the suite, so it
makes
no real network calls (see `frontend/TESTING.md`).
### 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]