forked from Lilly-Protocol/lily-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreject-duplicate-capabilities.test.ts
More file actions
60 lines (54 loc) · 2 KB
/
Copy pathreject-duplicate-capabilities.test.ts
File metadata and controls
60 lines (54 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { describe, it, expect, beforeEach } from "vitest";
import request from "supertest";
import { createApp } from "../src/app";
import { agentsService } from "../src/modules/agents/agents.service";
describe("Reject duplicate capabilities and normalize casing (issue #84)", () => {
const app = createApp();
beforeEach(() => {
agentsService.reset?.();
});
it("should deduplicate identical capabilities", async () => {
const res = await request(app)
.post("/api/v1/agents")
.send({
name: "Dedup Agent",
description: "Testing capability deduplication behavior",
capabilities: ["payments", "payments", "payments"],
});
expect(res.status).toBe(201);
expect(res.body.data.agent.capabilities).toEqual(["payments"]);
});
it("should normalize capabilities to lowercase", async () => {
const res = await request(app)
.post("/api/v1/agents")
.send({
name: "Case Agent",
description: "Testing capability case normalization behavior",
capabilities: ["Payments", "WALLET", "Settlement"],
});
expect(res.status).toBe(201);
expect(res.body.data.agent.capabilities).toEqual(["payments", "wallet", "settlement"]);
});
it("should deduplicate case-variant capabilities", async () => {
const res = await request(app)
.post("/api/v1/agents")
.send({
name: "Case Dedup Agent",
description: "Testing case variant deduplication behavior",
capabilities: ["payments", "Payments", "PAYMENTS"],
});
expect(res.status).toBe(201);
expect(res.body.data.agent.capabilities).toEqual(["payments"]);
});
it("should still reject empty capabilities array after transform", async () => {
const res = await request(app)
.post("/api/v1/agents")
.send({
name: "Empty Caps Agent",
description: "Testing empty capabilities rejection behavior",
capabilities: [],
});
expect(res.status).toBe(400);
expect(res.body.success).toBe(false);
});
});