Skip to content

Commit ee92952

Browse files
bobbai00claude
andcommitted
test(frontend): close the last two patch-coverage gaps
Codecov flagged two uncovered changes in this PR's frontend: - agent.service.ts: the stop-command websocket send in stopGeneration() was never exercised. Add a spec that injects an open mock socket and asserts the `{ type: "command", commandType: "stop" }` frame is sent (plus the REST fallback when no socket is open). - workflow-editor.component.ts: the `if (activeAgentId)` branch in the chat popover's results pull was only half-covered. Add a no-active-agent case so both branches are exercised. Verified against the full frontend coverage run: both lines/branches now hit. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012qFkyrpTd5PrkNBPcBeo4Q
1 parent da817c3 commit ee92952

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

frontend/src/app/workspace/component/workflow-editor/workflow-editor.component.spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,19 @@ describe("WorkflowEditorComponent", () => {
307307
expect(fetchSpy).toHaveBeenCalledWith("agent-1");
308308
});
309309

310+
it("does not pull operator results when no agent is connected", () => {
311+
workflowActionService.addOperator(mockScanPredicate, mockPoint);
312+
const jointCellView = component.paper.findViewByModel(mockScanPredicate.operatorID);
313+
314+
const agentService = TestBed.inject(AgentService);
315+
vi.spyOn(agentService, "getActivelyConnectedAgentIds").mockReturnValue([]);
316+
const fetchSpy = vi.spyOn(agentService, "fetchOperatorResults").mockImplementation(() => {});
317+
318+
(component.paper as any).trigger("element:chat", jointCellView, new Event("click"), 0, 0);
319+
320+
expect(fetchSpy).not.toHaveBeenCalled();
321+
});
322+
310323
it("should react to operator validation and change the color of operator box if the operator is valid ", () => {
311324
workflowActionService.getJointGraphWrapper();
312325
workflowActionService.addOperator(mockScanPredicate, mockPoint);

frontend/src/app/workspace/service/agent/agent.service.spec.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,29 @@ describe("AgentService", () => {
124124
expect(latest?.size).toBe(0);
125125
});
126126
});
127+
128+
describe("stopGeneration", () => {
129+
it("sends a stop command over the websocket when one is open", () => {
130+
const send = vi.fn();
131+
(service as any).agentStateTracking.set("agent-1", {
132+
websocket: { readyState: WebSocket.OPEN, send },
133+
});
134+
135+
service.stopGeneration("agent-1");
136+
137+
expect(send).toHaveBeenCalledWith(JSON.stringify({ type: "command", commandType: "stop" }));
138+
});
139+
140+
it("falls back to the REST stop endpoint when no websocket is open", () => {
141+
(service as any).agentStateTracking.set("agent-1", {
142+
websocket: { readyState: WebSocket.CLOSED, send: vi.fn() },
143+
});
144+
145+
service.stopGeneration("agent-1");
146+
147+
httpMock
148+
.expectOne(r => r.method === "POST" && r.url === "/api/agents/agent-1/stop")
149+
.flush({ status: "stopping" });
150+
});
151+
});
127152
});

0 commit comments

Comments
 (0)