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

   ### What changes were proposed in this PR?
   
   Adds a Vitest unit-test suite for `AiAnalystService`
   (`frontend/src/app/workspace/service/ai-analyst/ai-analyst.service.ts`),
   previously without a spec (~32% coverage). Uses `HttpClientTestingModule` +
   `HttpTestingController`; `WorkflowActionService` (an unused constructor
   dependency) is stubbed. No backend.
   
   9 tests cover:
   
   - `isOpenAIEnabled` — GET `/aiassistant/isenabled` with `responseType: 
"text"`; emits `true` for an `OpenAI` response, `false` for anything else, 
`false` when the request errors, and short-circuits to the cached flag without 
issuing a request.
   - `sendPromptToOpenAI` — the manual `Observable` contract: emits `""` (and 
skips the OpenAI call) when the assistant is disabled; POSTs `{ prompt }` to 
`/aiassistant/openai` and emits the trimmed completion when enabled; emits `""` 
when the OpenAI request fails; and emits `""` when the enablement check itself 
errors.
   
   No production code was changed.
   
   ### Any related issues, documentation, discussions?
   
   Closes #6430
   
   ### 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-analyst/ai-analyst.service.spec.ts
   # Test Files 1 passed (1) | Tests 9 passed (9)
   prettier --write <spec>   # unchanged
   eslint  <spec>            # clean
   ```
   
   The suite is backed by `HttpClientTestingModule` / `HttpTestingController`, 
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]

Reply via email to