The GitHub Actions job "Required Checks" on texera.git/gh-readonly-queue/main/pr-7908-4931330c377d8c8698747bdad4411fda8b4c5b83 has failed. Run started by GitHub user aglinxinyuan (triggered by aglinxinyuan).
Head commit for run: 54a9a597d87eb63304af77c67ab744da37086d03 / Meng Wang <[email protected]> test(frontend): cover the agent service's state accessors and failure paths (#7908) ### What changes were proposed in this PR? Extends `agent.service.spec.ts` over the two gaps the issue lists — the state accessors' untracked side, and the HTTP failure paths — with 24 tests. Measured locally with `--coverage --coverage-reporters=lcovonly`: | `agent.service.ts` | Before | After | | --- | --- | --- | | lines | 301/329 (91.49 %) | **324/329 (98.48 %)** | | branches | 147/186 | **168/186** | | functions | 90/103 | **102/103** | **Accessors — both arms of each `tracking ? … : …`**, by calling each for a tracked agent and for an unknown id: `getAgentState` / `isAgentConnected`, `getHeadId` (+ observable), `getVisibleSteps`, `getWorkflowObservable`, `getAgentWorkflowId`'s `agent?.delegate?.workflowId` chain (missing agent, no delegate, full), and `getAgentCount`. `setHoveredMessage` gets a non-null step that carries no operator access (the else-branch, distinct from the already-covered null case) and a no-tracking no-op; `getReActStepsByOperatorAccess` gets a step with no `operatorAccess`. `mapStateToAgentState` is fed `STOPPING`, `UNAVAILABLE` and an unrecognised value through `getAllAgents`. **Failure paths:** - `createAgent` and `updateAgentSettings` — the `err.error?.error || err.message || "…"` fallback chains. The nested and message arms use a real `HttpTestingController` flush; the default-label arm is only reachable for an error that is *not* an `HttpErrorResponse` (which always carries a `message`), so that one case throws a bare object through a `throwError` stub, noted in a comment. - `getReActSteps` — `catchError(() => of([]))` emits `[]` rather than propagating. - `syncAgentsWithBackend` — the `catchError` (a failed sync is treated as an empty backend), the `if (existingAgent)` false side (a backend agent not cached locally is not merged in), and the `if (tracking)` false side (an existing agent with no tracking entry still has its state updated). - `getAllAgents` — the non-pruning branch: a local agent the backend still reports is kept. - `stopGeneration` — both error handlers (a throwing websocket `send`, and the REST fallback failing). - `getOrCreateStateTracking` — the workflow-id back-fill arm, reached by re-entering through `ensureWorkflowPolling` after tracking was created without an id. Determinism: every request is flushed synchronously through `HttpTestingController` and `httpMock.verify()` runs in `afterEach`; errors are raised with `flush`/`throwError` rather than a live host; `console.error` spies are restored per test; each test gets a fresh service from `TestBed`, so the internal agent/tracking maps never leak. The remaining uncovered lines are the websocket transport paths, which the issue scoped out. No production code was changed. ### Any related issues, documentation, discussions? Closes #7889. ### How was this PR tested? `ng test --watch=false --include src/app/workspace/service/agent/agent.service.spec.ts` — 71 passed (47 before, 24 new), repeated 3× for stability; the whole `workspace/service/agent/**` folder stays green. `yarn format:ci` clean. Failure path verified by breaking one assertion in each of the 24 new tests: 24 failed / 47 passed, non-zero exit, then restored to green. ### 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/32795084430 With regards, GitHub Actions via GitBox
