huskies: merge 770

This commit is contained in:
dave
2026-04-28 15:31:29 +00:00
parent 1946709681
commit f63464852b
13 changed files with 212 additions and 266 deletions
+5 -35
View File
@@ -132,38 +132,6 @@ describe("agentsApi", () => {
});
});
describe("listAgents", () => {
it("sends GET to /agents and returns agent list", async () => {
mockFetch.mockResolvedValueOnce(okResponse([sampleAgent]));
const result = await agentsApi.listAgents();
expect(mockFetch).toHaveBeenCalledWith(
"/api/agents",
expect.objectContaining({}),
);
expect(result).toEqual([sampleAgent]);
});
it("returns empty array when no agents running", async () => {
mockFetch.mockResolvedValueOnce(okResponse([]));
const result = await agentsApi.listAgents();
expect(result).toEqual([]);
});
it("uses custom baseUrl when provided", async () => {
mockFetch.mockResolvedValueOnce(okResponse([]));
await agentsApi.listAgents("http://localhost:3002/api");
expect(mockFetch).toHaveBeenCalledWith(
"http://localhost:3002/api/agents",
expect.objectContaining({}),
);
});
});
describe("getAgentConfig", () => {
it("sends GET to /agents/config and returns config list", async () => {
mockFetch.mockResolvedValueOnce(okResponse([sampleConfig]));
@@ -216,15 +184,17 @@ describe("agentsApi", () => {
describe("error handling", () => {
it("throws on non-ok response with body text", async () => {
mockFetch.mockResolvedValueOnce(errorResponse(404, "agent not found"));
mockFetch.mockResolvedValueOnce(errorResponse(404, "config not found"));
await expect(agentsApi.listAgents()).rejects.toThrow("agent not found");
await expect(agentsApi.getAgentConfig()).rejects.toThrow(
"config not found",
);
});
it("throws with status code when no body", async () => {
mockFetch.mockResolvedValueOnce(errorResponse(500, ""));
await expect(agentsApi.listAgents()).rejects.toThrow(
await expect(agentsApi.getAgentConfig()).rejects.toThrow(
"Request failed (500)",
);
});