The GitHub Actions job "Required Checks" on 
texera.git/gh-readonly-queue/main/pr-6432-1ff47715057a2c9e3a5ca94761a574f5d6687f63
 has failed.
Run started by GitHub user aglinxinyuan (triggered by aglinxinyuan).

Head commit for run:
e5066f4053a523cbd4f8c30f6e7de5d6d72e9460 / Meng Wang <[email protected]>
test(frontend): add unit test coverage for AIAssistantService (#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])

Report URL: https://github.com/apache/texera/actions/runs/29381914767

With regards,
GitHub Actions via GitBox

Reply via email to