From b41aafb9c0f0ad8efdf93ee85633baa3f285e93a Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Wed, 4 Mar 2026 01:11:35 -0500 Subject: [PATCH] test(slack): cover binding-aware system event routing --- src/slack/monitor/monitor.test.ts | 47 +++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/slack/monitor/monitor.test.ts b/src/slack/monitor/monitor.test.ts index c1fac686971..d6e819ca46d 100644 --- a/src/slack/monitor/monitor.test.ts +++ b/src/slack/monitor/monitor.test.ts @@ -184,6 +184,53 @@ describe("resolveSlackSystemEventSessionKey", () => { "agent:main:slack:channel:c123", ); }); + + it("routes channel system events through account bindings", () => { + const ctx = createSlackMonitorContext({ + ...baseParams(), + accountId: "work", + cfg: { + bindings: [ + { + agentId: "ops", + match: { + channel: "slack", + accountId: "work", + }, + }, + ], + }, + }); + expect( + ctx.resolveSlackSystemEventSessionKey({ channelId: "C123", channelType: "channel" }), + ).toBe("agent:ops:slack:channel:c123"); + }); + + it("routes DM system events through direct-peer bindings when sender is known", () => { + const ctx = createSlackMonitorContext({ + ...baseParams(), + accountId: "work", + cfg: { + bindings: [ + { + agentId: "ops-dm", + match: { + channel: "slack", + accountId: "work", + peer: { kind: "direct", id: "U123" }, + }, + }, + ], + }, + }); + expect( + ctx.resolveSlackSystemEventSessionKey({ + channelId: "D123", + channelType: "im", + senderId: "U123", + }), + ).toBe("agent:ops-dm:main"); + }); }); describe("isChannelAllowed with groupPolicy and channelsConfig", () => {