mengw15 opened a new issue, #7889:
URL: https://github.com/apache/texera/issues/7889
### Task Summary
The rest of `AgentService`'s gap (codecov **83.38 %**) is its state
accessors and its HTTP failure paths. The accessors each branch on whether an
agent is being tracked and only the tracked side ever runs; the failure paths
are `catchError` blocks and `err.error?.error || err.message || "…"` fallback
chains that no test provokes.
`agent.service.spec.ts` already has the harness — `HttpClientTestingModule`
for the HTTP calls and a `FakeWebSocket` double for the tracking state. Pure
EXTEND.
Vitest/jsdom; see `frontend/TESTING.md` and `frontend/AGENTS.md`.
### Behavior to add
**`AgentService`**
(`frontend/src/app/workspace/service/agent/agent.service.ts`, codecov 83.38 % —
EXTEND `agent.service.spec.ts`)
**Accessors — cover the untracked side of each**
Each of these returns one thing when the agent has tracking state and
another when it does not; only the first is covered today. Call each for a
tracked agent and for an unknown id:
- `getAgentState` (949–954) — the tracked value versus
`AgentState.UNAVAILABLE`.
- `isAgentConnected` (970) — derived from the above; assert it is false for
an unavailable agent.
- `getHeadIdObservable` (977–978) and `getHeadId` (986) — the observable and
the `tracking ? … : null` accessor.
- `getVisibleSteps` (994) — `tracking ? … : []`.
- `getAgentWorkflowId` (642–643) — the `agent?.delegate?.workflowId` chain;
cover a missing agent, an agent with no delegate, and a full one.
- `getWorkflowObservable` (1099–1102) — the tracked observable versus
`of(null)`.
- `getAgentCount` (852) — `of(this.agents.size)` with none and with several
registered.
- `setHoveredMessage` (1025) and `getReActStepsByOperatorAccess`'s `if
(step.operatorAccess)` (1075) — cover steps with and without operator access.
**`mapStateToAgentState`** (296–305) — the `STOPPING` and `UNAVAILABLE` arms
of the switch are unreached; feed the backend state strings that map to them,
plus one unrecognised value.
**Failure paths**
- `createAgent` (699–702) — flush an HTTP error and assert the fallback
chain `err.error?.error || err.message || "Failed to create agent"`. Cover all
three: a nested `error.error`, only a `message`, and neither.
- `updateAgentSettings` (1149, 1156) — the `if (agent)` guard and the same
fallback chain on failure.
- `getReActSteps` (902) — `catchError(() => of([]))`; flush an error and
assert an empty array is emitted rather than the error propagating.
- `syncAgentsWithBackend` (259, 275, 279) — `catchError(() => of({ agents:
[] }))` on failure, plus the `if (existingAgent)` and `if (tracking)` merge
branches when a synced agent is already known locally.
- `getAllAgents` (776) — `if (!backendAgentIds.has(localId))`, the pruning
branch that drops a local agent the backend no longer reports.
- `stopGeneration` (933, 939) — the two error handlers.
- `getOrCreateStateTracking` (375–377) — the `else if (workflowId &&
!tracking.workflowId)` arm that back-fills a workflow id onto existing tracking.
Determinism notes:
- Use `HttpClientTestingModule` + `HttpTestingController` and flush every
request synchronously; never leave a request outstanding at the end of a test.
- Emit errors with `flush`/`error` on the test request rather than by
pointing at an unreachable host.
- `vi.restoreAllMocks()` in `afterEach`, and clear the service's internal
agent/tracking maps between tests so counts do not leak.
- Stub `notificationService` and assert on the message passed to it, not on
rendered output.
Note several open PRs touch this service (#6211, #6009, #5995, #5928, #5558,
#5275) — rebase before finishing.
### Task Type
- [ ] Refactor / Cleanup
- [ ] DevOps / Deployment / CI
- [x] Testing / QA
- [ ] Documentation
- [ ] Performance
- [ ] Other
--
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]