mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 23:14:32 +00:00
perf(test): trim telegram duplicates and queue wait delays
This commit is contained in:
@@ -52,7 +52,7 @@ describe("command queue", () => {
|
|||||||
active += 1;
|
active += 1;
|
||||||
maxActive = Math.max(maxActive, active);
|
maxActive = Math.max(maxActive, active);
|
||||||
calls.push(id);
|
calls.push(id);
|
||||||
await new Promise((resolve) => setTimeout(resolve, 15));
|
await new Promise((resolve) => setTimeout(resolve, 2));
|
||||||
active -= 1;
|
active -= 1;
|
||||||
return id;
|
return id;
|
||||||
};
|
};
|
||||||
@@ -84,7 +84,7 @@ describe("command queue", () => {
|
|||||||
|
|
||||||
// First task holds the queue long enough to trigger wait notice.
|
// First task holds the queue long enough to trigger wait notice.
|
||||||
const first = enqueueCommand(async () => {
|
const first = enqueueCommand(async () => {
|
||||||
await new Promise((resolve) => setTimeout(resolve, 30));
|
await new Promise((resolve) => setTimeout(resolve, 8));
|
||||||
});
|
});
|
||||||
|
|
||||||
const second = enqueueCommand(async () => {}, {
|
const second = enqueueCommand(async () => {}, {
|
||||||
|
|||||||
@@ -542,36 +542,7 @@ describe("createTelegramBot", () => {
|
|||||||
|
|
||||||
expect(replySpy).toHaveBeenCalledTimes(0);
|
expect(replySpy).toHaveBeenCalledTimes(0);
|
||||||
});
|
});
|
||||||
it("allows group messages from telegram:-prefixed allowFrom entries when groupPolicy is 'allowlist'", async () => {
|
it("allows group messages from tg:-prefixed allowFrom entries case-insensitively", async () => {
|
||||||
onSpy.mockReset();
|
|
||||||
replySpy.mockReset();
|
|
||||||
loadConfig.mockReturnValue({
|
|
||||||
channels: {
|
|
||||||
telegram: {
|
|
||||||
groupPolicy: "allowlist",
|
|
||||||
allowFrom: ["telegram:77112533"],
|
|
||||||
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: 77112533, username: "mneves" },
|
|
||||||
text: "hello",
|
|
||||||
date: 1736380800,
|
|
||||||
},
|
|
||||||
me: { username: "openclaw_bot" },
|
|
||||||
getFile: async () => ({ download: async () => new Uint8Array() }),
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(replySpy).toHaveBeenCalledTimes(1);
|
|
||||||
});
|
|
||||||
it("allows group messages from tg:-prefixed allowFrom entries case-insensitively when groupPolicy is 'allowlist'", async () => {
|
|
||||||
onSpy.mockReset();
|
onSpy.mockReset();
|
||||||
replySpy.mockReset();
|
replySpy.mockReset();
|
||||||
loadConfig.mockReturnValue({
|
loadConfig.mockReturnValue({
|
||||||
|
|||||||
Reference in New Issue
Block a user