























@@ -144,10 +144,37 @@ describe("agents helpers", () => {
144144},
145145]);
146146147-expect(result.added).toHaveLength(1);
148-expect(result.skipped).toHaveLength(1);
149-expect(result.conflicts).toHaveLength(1);
150-expect(result.config.bindings).toHaveLength(2);
147+expect(result.added).toStrictEqual([
148+{
149+agentId: "work",
150+match: { channel: "telegram" },
151+},
152+]);
153+expect(result.skipped).toStrictEqual([
154+{
155+agentId: "main",
156+match: { channel: "whatsapp", accountId: "default" },
157+},
158+]);
159+expect(result.conflicts).toStrictEqual([
160+{
161+binding: {
162+agentId: "work",
163+match: { channel: "whatsapp", accountId: "default" },
164+},
165+existingAgentId: "main",
166+},
167+]);
168+expect(result.config.bindings).toStrictEqual([
169+{
170+agentId: "main",
171+match: { channel: "whatsapp", accountId: "default" },
172+},
173+{
174+agentId: "work",
175+match: { channel: "telegram" },
176+},
177+]);
151178});
152179153180it("applyAgentBindings upgrades channel-only binding to account-specific binding for same agent", () => {
@@ -167,9 +194,14 @@ describe("agents helpers", () => {
167194},
168195]);
169196170-expect(result.added).toHaveLength(0);
171-expect(result.updated).toHaveLength(1);
172-expect(result.conflicts).toHaveLength(0);
197+expect(result.added).toStrictEqual([]);
198+expect(result.updated).toStrictEqual([
199+{
200+agentId: "main",
201+match: { channel: "telegram", accountId: "work" },
202+},
203+]);
204+expect(result.conflicts).toStrictEqual([]);
173205expect(result.config.bindings).toEqual([
174206{
175207agentId: "main",
@@ -204,9 +236,36 @@ describe("agents helpers", () => {
204236},
205237]);
206238207-expect(result.added).toHaveLength(1);
208-expect(result.conflicts).toHaveLength(0);
209-expect(result.config.bindings).toHaveLength(2);
239+expect(result.added).toStrictEqual([
240+{
241+agentId: "work",
242+match: {
243+channel: "discord",
244+accountId: "guild-a",
245+guildId: "123",
246+},
247+},
248+]);
249+expect(result.conflicts).toStrictEqual([]);
250+expect(result.config.bindings).toStrictEqual([
251+{
252+agentId: "main",
253+match: {
254+channel: "discord",
255+accountId: "guild-a",
256+guildId: "123",
257+roles: ["111", "222"],
258+},
259+},
260+{
261+agentId: "work",
262+match: {
263+channel: "discord",
264+accountId: "guild-a",
265+guildId: "123",
266+},
267+},
268+]);
210269});
211270212271it("applyAgentBindings keeps distinct bindings when persisted match fields contain pipes", () => {
@@ -232,10 +291,28 @@ describe("agents helpers", () => {
232291},
233292]);
234293235-expect(result.added).toHaveLength(2);
236-expect(result.skipped).toHaveLength(0);
237-expect(result.conflicts).toHaveLength(0);
238-expect(result.config.bindings).toHaveLength(2);
294+expect(result.added).toStrictEqual([
295+{
296+agentId: "main",
297+match: {
298+channel: "discord",
299+peer: { kind: "direct", id: "a|b" },
300+accountId: "default",
301+},
302+},
303+{
304+agentId: "main",
305+match: {
306+channel: "discord",
307+peer: { kind: "direct", id: "a" },
308+guildId: "b",
309+accountId: "|default",
310+},
311+},
312+]);
313+expect(result.skipped).toStrictEqual([]);
314+expect(result.conflicts).toStrictEqual([]);
315+expect(result.config.bindings).toStrictEqual(result.added);
239316});
240317241318it("removeAgentBindings does not remove role-based bindings when removing channel-level routes", () => {
@@ -272,8 +349,17 @@ describe("agents helpers", () => {
272349},
273350]);
274351275-expect(result.removed).toHaveLength(1);
276-expect(result.conflicts).toHaveLength(0);
352+expect(result.removed).toStrictEqual([
353+{
354+agentId: "main",
355+match: {
356+channel: "discord",
357+accountId: "guild-a",
358+guildId: "123",
359+},
360+},
361+]);
362+expect(result.conflicts).toStrictEqual([]);
277363expect(result.config.bindings).toEqual([
278364{
279365agentId: "main",
@@ -307,8 +393,9 @@ describe("agents helpers", () => {
307393const result = pruneAgentConfig(cfg, "work");
308394expect(result.config.agents?.list?.map((agent) => agent.id)).not.toContain("work");
309395expect(result.config.agents?.list?.map((agent) => agent.id)).toContain("home");
310-expect(result.config.bindings).toHaveLength(1);
311-expect(result.config.bindings?.[0]?.agentId).toBe("home");
396+expect(result.config.bindings).toStrictEqual([
397+{ agentId: "home", match: { channel: "telegram" } },
398+]);
312399expect(result.config.tools?.agentToAgent?.allow).toEqual(["home"]);
313400expect(result.removedBindings).toBe(1);
314401expect(result.removedAllow).toBe(1);
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。