Files
openclaw/extensions/telegram/src/inbound-context.contract.test.ts
2026-04-28 01:14:19 +01:00

43 lines
1.2 KiB
TypeScript

import { expectChannelInboundContextContract } from "openclaw/plugin-sdk/channel-contract-testing";
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types";
import { describe, it } from "vitest";
import { buildTelegramMessageContextForTest } from "./bot-message-context.test-harness.js";
describe("Telegram inbound context contract", () => {
it("keeps inbound context finalized", async () => {
const context = await buildTelegramMessageContextForTest({
cfg: {
agents: {
defaults: {
envelopeTimezone: "utc",
},
},
channels: {
telegram: {
groupPolicy: "open",
groups: { "*": { requireMention: false } },
},
},
} satisfies OpenClawConfig,
message: {
chat: { id: 42, type: "group", title: "Ops" },
text: "hello",
date: 1_736_380_800,
message_id: 2,
from: {
id: 99,
first_name: "Ada",
last_name: "Lovelace",
username: "ada",
},
},
});
const payload = context?.ctxPayload;
if (!payload) {
throw new Error("expected telegram inbound payload");
}
expectChannelInboundContextContract(payload);
});
});