From 1c7cec4d96bee21f477a7f04bd902203bb58d559 Mon Sep 17 00:00:00 2001 From: Dotta Date: Sun, 26 Apr 2026 07:44:50 -0500 Subject: [PATCH] Add security role route coverage --- .../src/__tests__/agent-skills-routes.test.ts | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/server/src/__tests__/agent-skills-routes.test.ts b/server/src/__tests__/agent-skills-routes.test.ts index 99cff4a4784..aa6e3a0c3df 100644 --- a/server/src/__tests__/agent-skills-routes.test.ts +++ b/server/src/__tests__/agent-skills-routes.test.ts @@ -436,6 +436,39 @@ describe.sequential("agent skill routes", () => { ); }); + it("accepts the security role on direct agent creation and preserves it in telemetry", async () => { + mockAgentService.update.mockImplementation(async (_id: string, patch: Record) => ({ + ...makeAgent("claude_local"), + role: "security", + ...patch, + adapterConfig: patch.adapterConfig ?? {}, + })); + + const res = await requestApp(await createApp(), (baseUrl) => request(baseUrl) + .post("/api/companies/company-1/agents") + .send({ + name: "Security Engineer", + role: "security", + adapterType: "claude_local", + adapterConfig: {}, + })); + + expect([200, 201], JSON.stringify(res.body)).toContain(res.status); + expect(mockAgentService.create).toHaveBeenCalledWith( + "company-1", + expect.objectContaining({ + role: "security", + }), + ); + expect(mockTrackAgentCreated).toHaveBeenCalledWith( + expect.anything(), + expect.objectContaining({ + agentId: "11111111-1111-4111-8111-111111111111", + agentRole: "security", + }), + ); + }); + it("materializes a managed AGENTS.md for directly created local agents", async () => { const res = await requestApp(await createApp(), (baseUrl) => request(baseUrl) .post("/api/companies/company-1/agents")