mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 18:01:23 +00:00
test: remove duplicate telegram allowFrom cases
This commit is contained in:
@@ -1424,33 +1424,6 @@ describe("createTelegramBot", () => {
|
|||||||
|
|
||||||
expect(replySpy).toHaveBeenCalledTimes(1);
|
expect(replySpy).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
it("allows direct messages with telegram:-prefixed allowFrom entries", async () => {
|
|
||||||
onSpy.mockReset();
|
|
||||||
replySpy.mockReset();
|
|
||||||
loadConfig.mockReturnValue({
|
|
||||||
channels: {
|
|
||||||
telegram: {
|
|
||||||
allowFrom: ["telegram:123456789"],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
createTelegramBot({ token: "tok" });
|
|
||||||
const handler = getOnHandler("message") as (ctx: Record<string, unknown>) => Promise<void>;
|
|
||||||
|
|
||||||
await handler({
|
|
||||||
message: {
|
|
||||||
chat: { id: 123456789, type: "private" },
|
|
||||||
from: { id: 123456789, username: "testuser" },
|
|
||||||
text: "hello",
|
|
||||||
date: 1736380800,
|
|
||||||
},
|
|
||||||
me: { username: "openclaw_bot" },
|
|
||||||
getFile: async () => ({ download: async () => new Uint8Array() }),
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(replySpy).toHaveBeenCalledTimes(1);
|
|
||||||
});
|
|
||||||
it("matches direct message allowFrom against sender user id when chat id differs", async () => {
|
it("matches direct message allowFrom against sender user id when chat id differs", async () => {
|
||||||
onSpy.mockReset();
|
onSpy.mockReset();
|
||||||
replySpy.mockReset();
|
replySpy.mockReset();
|
||||||
@@ -1560,36 +1533,6 @@ describe("createTelegramBot", () => {
|
|||||||
|
|
||||||
expect(replySpy).not.toHaveBeenCalled();
|
expect(replySpy).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
it("matches telegram:-prefixed allowFrom entries in group allowlist", async () => {
|
|
||||||
onSpy.mockReset();
|
|
||||||
replySpy.mockReset();
|
|
||||||
loadConfig.mockReturnValue({
|
|
||||||
channels: {
|
|
||||||
telegram: {
|
|
||||||
groupPolicy: "allowlist",
|
|
||||||
allowFrom: ["telegram:123456789"],
|
|
||||||
groups: { "*": { requireMention: false } },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
createTelegramBot({ token: "tok" });
|
|
||||||
const handler = getOnHandler("message") as (ctx: Record<string, unknown>) => Promise<void>;
|
|
||||||
|
|
||||||
await handler({
|
|
||||||
message: {
|
|
||||||
chat: { id: -100123456789, type: "group", title: "Test Group" },
|
|
||||||
from: { id: 123456789, username: "testuser" },
|
|
||||||
text: "hello from prefixed user",
|
|
||||||
date: 1736380800,
|
|
||||||
},
|
|
||||||
me: { username: "openclaw_bot" },
|
|
||||||
getFile: async () => ({ download: async () => new Uint8Array() }),
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(replySpy).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("sends replies without native reply threading", async () => {
|
it("sends replies without native reply threading", async () => {
|
||||||
onSpy.mockReset();
|
onSpy.mockReset();
|
||||||
sendMessageSpy.mockReset();
|
sendMessageSpy.mockReset();
|
||||||
|
|||||||
Reference in New Issue
Block a user