test(gateway): decouple send coverage from telegram specifics

This commit is contained in:
Peter Steinberger
2026-03-29 22:59:32 +01:00
parent 168ab94eee
commit 6ca81f8ec7
2 changed files with 28 additions and 27 deletions

View File

@@ -21,3 +21,4 @@ read_when:
- updated Discord preflight wording to match runtime-snapshot semantics
- adjusted session-listing subagent selection to prefer active disk-only runs while still honoring newer in-memory replacement rows
- deleted the flaky duplicated Telegram gateway writeback integration test and kept stable coverage in `server-methods/send.test.ts` plus `extensions/telegram/src/target-writeback.test.ts`
- trimmed remaining Telegram-specific assertions from `src/gateway/server-methods/send.test.ts` so core only covers generic channel-send contracts and Telegram writeback behavior stays extension-owned

View File

@@ -214,42 +214,42 @@ describe("gateway send mirroring", () => {
});
it("forwards gateway client scopes into outbound delivery", async () => {
mockDeliverySuccess("m-telegram-scope");
mockDeliverySuccess("m-scope");
await runSendWithClient(
{
to: "https://t.me/mychannel",
to: "channel:C1",
message: "hi",
channel: "telegram",
idempotencyKey: "idem-telegram-scope",
channel: "slack",
idempotencyKey: "idem-scope",
},
{ connect: { scopes: ["operator.write"] } },
);
expect(mocks.deliverOutboundPayloads).toHaveBeenCalledWith(
expect.objectContaining({
channel: "telegram",
channel: "slack",
gatewayClientScopes: ["operator.write"],
}),
);
});
it("forwards an empty gateway scope array into outbound delivery", async () => {
mockDeliverySuccess("m-telegram-empty-scope");
mockDeliverySuccess("m-empty-scope");
await runSendWithClient(
{
to: "https://t.me/mychannel",
to: "channel:C1",
message: "hi",
channel: "telegram",
idempotencyKey: "idem-telegram-empty-scope",
channel: "slack",
idempotencyKey: "idem-empty-scope",
},
{ connect: { scopes: [] } },
);
expect(mocks.deliverOutboundPayloads).toHaveBeenCalledWith(
expect.objectContaining({
channel: "telegram",
channel: "slack",
gatewayClientScopes: [],
}),
);
@@ -367,10 +367,10 @@ describe("gateway send mirroring", () => {
it("forwards gateway client scopes into outbound poll delivery", async () => {
await runPollWithClient(
{
to: "https://t.me/mychannel",
to: "channel:C1",
question: "Q?",
options: ["A", "B"],
channel: "telegram",
channel: "slack",
idempotencyKey: "idem-poll-scope",
},
{ connect: { scopes: ["operator.admin"] } },
@@ -388,10 +388,10 @@ describe("gateway send mirroring", () => {
it("forwards an empty gateway scope array into outbound poll delivery", async () => {
await runPollWithClient(
{
to: "https://t.me/mychannel",
to: "channel:C1",
question: "Q?",
options: ["A", "B"],
channel: "telegram",
channel: "slack",
idempotencyKey: "idem-poll-empty-scope",
},
{ connect: { scopes: [] } },
@@ -677,37 +677,37 @@ describe("gateway send mirroring", () => {
);
});
it("recovers cold plugin resolution for telegram threaded sends", async () => {
it("recovers cold plugin resolution for threaded sends", async () => {
mocks.resolveOutboundTarget.mockReturnValue({ ok: true, to: "123" });
mocks.deliverOutboundPayloads.mockResolvedValue([
{ messageId: "m-telegram", channel: "telegram" },
{ messageId: "m-threaded", channel: "slack" },
]);
const telegramPlugin = { outbound: { sendPoll: mocks.sendPoll } };
const outboundPlugin = { outbound: { sendPoll: mocks.sendPoll } };
mocks.getChannelPlugin
.mockReturnValueOnce(undefined)
.mockReturnValueOnce(telegramPlugin)
.mockReturnValue(telegramPlugin);
.mockReturnValueOnce(outboundPlugin)
.mockReturnValue(outboundPlugin);
const { respond } = await runSend({
to: "123",
message: "forum completion",
channel: "telegram",
threadId: "42",
idempotencyKey: "idem-cold-telegram-thread",
message: "threaded completion",
channel: "slack",
threadId: "1710000000.9999",
idempotencyKey: "idem-cold-thread",
});
expect(mocks.deliverOutboundPayloads).toHaveBeenCalledWith(
expect.objectContaining({
channel: "telegram",
channel: "slack",
to: "123",
threadId: "42",
threadId: "1710000000.9999",
}),
);
expect(respond).toHaveBeenCalledWith(
true,
expect.objectContaining({ messageId: "m-telegram" }),
expect.objectContaining({ messageId: "m-threaded" }),
undefined,
expect.objectContaining({ channel: "telegram" }),
expect.objectContaining({ channel: "slack" }),
);
});
});