test: dedupe route reply slack no-op cases

This commit is contained in:
Peter Steinberger 2026-03-13 22:16:31 +00:00
parent 36e9a811cc
commit b9e5f23914
1 changed files with 25 additions and 41 deletions

View File

@ -105,6 +105,23 @@ const createMSTeamsPlugin = (params: { outbound: ChannelOutboundAdapter }): Chan
outbound: params.outbound, outbound: params.outbound,
}); });
async function expectSlackNoSend(
payload: Parameters<typeof routeReply>[0]["payload"],
overrides: Partial<Parameters<typeof routeReply>[0]> = {},
) {
mocks.sendMessageSlack.mockClear();
const res = await routeReply({
payload,
channel: "slack",
to: "channel:C123",
cfg: {} as never,
...overrides,
});
expect(res.ok).toBe(true);
expect(mocks.sendMessageSlack).not.toHaveBeenCalled();
return res;
}
describe("routeReply", () => { describe("routeReply", () => {
beforeEach(() => { beforeEach(() => {
setActivePluginRegistry(defaultRegistry); setActivePluginRegistry(defaultRegistry);
@ -132,39 +149,15 @@ describe("routeReply", () => {
}); });
it("no-ops on empty payload", async () => { it("no-ops on empty payload", async () => {
mocks.sendMessageSlack.mockClear(); await expectSlackNoSend({});
const res = await routeReply({
payload: {},
channel: "slack",
to: "channel:C123",
cfg: {} as never,
});
expect(res.ok).toBe(true);
expect(mocks.sendMessageSlack).not.toHaveBeenCalled();
}); });
it("suppresses reasoning payloads", async () => { it("suppresses reasoning payloads", async () => {
mocks.sendMessageSlack.mockClear(); await expectSlackNoSend({ text: "Reasoning:\n_step_", isReasoning: true });
const res = await routeReply({
payload: { text: "Reasoning:\n_step_", isReasoning: true },
channel: "slack",
to: "channel:C123",
cfg: {} as never,
});
expect(res.ok).toBe(true);
expect(mocks.sendMessageSlack).not.toHaveBeenCalled();
}); });
it("drops silent token payloads", async () => { it("drops silent token payloads", async () => {
mocks.sendMessageSlack.mockClear(); await expectSlackNoSend({ text: SILENT_REPLY_TOKEN });
const res = await routeReply({
payload: { text: SILENT_REPLY_TOKEN },
channel: "slack",
to: "channel:C123",
cfg: {} as never,
});
expect(res.ok).toBe(true);
expect(mocks.sendMessageSlack).not.toHaveBeenCalled();
}); });
it("does not drop payloads that merely start with the silent token", async () => { it("does not drop payloads that merely start with the silent token", async () => {
@ -231,23 +224,14 @@ describe("routeReply", () => {
}); });
it("does not bypass the empty-reply guard for invalid Slack blocks", async () => { it("does not bypass the empty-reply guard for invalid Slack blocks", async () => {
mocks.sendMessageSlack.mockClear(); await expectSlackNoSend({
const res = await routeReply({ text: " ",
payload: { channelData: {
text: " ", slack: {
channelData: { blocks: " ",
slack: {
blocks: " ",
},
}, },
}, },
channel: "slack",
to: "channel:C123",
cfg: {} as never,
}); });
expect(res.ok).toBe(true);
expect(mocks.sendMessageSlack).not.toHaveBeenCalled();
}); });
it("does not derive responsePrefix from agent identity when routing", async () => { it("does not derive responsePrefix from agent identity when routing", async () => {