|
1 | 1 | import { ErrorEvent } from "eventsource";
|
2 | 2 | import { describe, expect, it } from "vitest";
|
| 3 | +import * as apiHelper from "./api-helper"; |
3 | 4 | import {
|
4 | 5 | AgentMetadataEventSchema,
|
5 | 6 | AgentMetadataEventSchemaArray,
|
6 | 7 | errToStr,
|
7 | 8 | extractAgents,
|
8 |
| - extractAllAgents, |
9 | 9 | } from "./api-helper";
|
10 | 10 | import {
|
11 | 11 | createMockAgent,
|
@@ -140,33 +140,31 @@ describe("api-helper", () => {
|
140 | 140 | });
|
141 | 141 |
|
142 | 142 | describe("extractAllAgents", () => {
|
143 |
| - it.each([ |
144 |
| - [ |
145 |
| - "multiple workspaces with agents", |
146 |
| - [ |
147 |
| - createWorkspaceWithAgents([{ id: "agent1", name: "main" }]), |
148 |
| - createWorkspaceWithAgents([{ id: "agent2", name: "secondary" }]), |
149 |
| - ], |
150 |
| - ["agent1", "agent2"], |
151 |
| - ], |
152 |
| - ["empty workspace list", [], []], |
153 |
| - [ |
154 |
| - "mixed workspaces", |
155 |
| - [ |
156 |
| - createWorkspaceWithAgents([{ id: "agent1", name: "main" }]), |
157 |
| - createMockWorkspace({ |
158 |
| - latest_build: { |
159 |
| - ...createMockWorkspace().latest_build, |
160 |
| - resources: [], |
161 |
| - }, |
162 |
| - }), |
163 |
| - createWorkspaceWithAgents([{ id: "agent2", name: "secondary" }]), |
164 |
| - ], |
165 |
| - ["agent1", "agent2"], |
166 |
| - ], |
167 |
| - ])("should handle %s", (_, workspaces, expectedIds) => { |
168 |
| - const allAgents = extractAllAgents(workspaces); |
169 |
| - expect(allAgents.map((a) => a.id)).toEqual(expectedIds); |
| 143 | + it("should extract agents from multiple workspaces", () => { |
| 144 | + const workspaces = [ |
| 145 | + createWorkspaceWithAgents([ |
| 146 | + createMockAgent({ id: "agent1", name: "main" }), |
| 147 | + ]), |
| 148 | + createWorkspaceWithAgents([ |
| 149 | + createMockAgent({ id: "agent2", name: "secondary" }), |
| 150 | + ]), |
| 151 | + ]; |
| 152 | + |
| 153 | + const agents = apiHelper.extractAllAgents(workspaces); |
| 154 | + expect(agents).toHaveLength(2); |
| 155 | + expect(agents.map((a) => a.id)).toEqual(["agent1", "agent2"]); |
| 156 | + }); |
| 157 | + |
| 158 | + it("should handle empty workspaces array", () => { |
| 159 | + const agents = apiHelper.extractAllAgents([]); |
| 160 | + expect(agents).toHaveLength(0); |
| 161 | + expect(agents).toEqual([]); |
| 162 | + }); |
| 163 | + |
| 164 | + it("should handle workspaces with no agents", () => { |
| 165 | + const workspaces = [createMockWorkspace(), createMockWorkspace()]; |
| 166 | + const agents = apiHelper.extractAllAgents(workspaces); |
| 167 | + expect(agents).toHaveLength(0); |
170 | 168 | });
|
171 | 169 | });
|
172 | 170 |
|
|
0 commit comments