mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 04:21:24 +00:00
perf: speed up telegram bot suite setup
This commit is contained in:
@@ -228,16 +228,31 @@ export function makeForumGroupMessageCtx(params?: {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
resetInboundDedupe();
|
resetInboundDedupe();
|
||||||
|
loadConfig.mockReset();
|
||||||
loadConfig.mockReturnValue({
|
loadConfig.mockReturnValue({
|
||||||
|
agents: {
|
||||||
|
defaults: {
|
||||||
|
envelopeTimezone: "utc",
|
||||||
|
},
|
||||||
|
},
|
||||||
channels: {
|
channels: {
|
||||||
telegram: { dmPolicy: "open", allowFrom: ["*"] },
|
telegram: { dmPolicy: "open", allowFrom: ["*"] },
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
loadWebMedia.mockReset();
|
loadWebMedia.mockReset();
|
||||||
|
readChannelAllowFromStore.mockReset();
|
||||||
|
readChannelAllowFromStore.mockResolvedValue([]);
|
||||||
|
upsertChannelPairingRequest.mockReset();
|
||||||
|
upsertChannelPairingRequest.mockResolvedValue({ code: "PAIRCODE", created: true } as const);
|
||||||
onSpy.mockReset();
|
onSpy.mockReset();
|
||||||
commandSpy.mockReset();
|
commandSpy.mockReset();
|
||||||
stopSpy.mockReset();
|
stopSpy.mockReset();
|
||||||
useSpy.mockReset();
|
useSpy.mockReset();
|
||||||
|
replySpy.mockReset();
|
||||||
|
replySpy.mockImplementation(async (_ctx, opts) => {
|
||||||
|
await opts?.onReplyStart?.();
|
||||||
|
return undefined;
|
||||||
|
});
|
||||||
|
|
||||||
sendAnimationSpy.mockReset();
|
sendAnimationSpy.mockReset();
|
||||||
sendAnimationSpy.mockResolvedValue({ message_id: 78 });
|
sendAnimationSpy.mockResolvedValue({ message_id: 78 });
|
||||||
|
|||||||
@@ -40,27 +40,6 @@ const ORIGINAL_TZ = process.env.TZ;
|
|||||||
describe("createTelegramBot", () => {
|
describe("createTelegramBot", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
process.env.TZ = "UTC";
|
process.env.TZ = "UTC";
|
||||||
loadConfig.mockReturnValue({
|
|
||||||
agents: {
|
|
||||||
defaults: {
|
|
||||||
envelopeTimezone: "utc",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
channels: {
|
|
||||||
telegram: { dmPolicy: "open", allowFrom: ["*"] },
|
|
||||||
},
|
|
||||||
});
|
|
||||||
readChannelAllowFromStore.mockReset().mockResolvedValue([]);
|
|
||||||
upsertChannelPairingRequest
|
|
||||||
.mockReset()
|
|
||||||
.mockResolvedValue({ code: "PAIRCODE", created: true } as const);
|
|
||||||
|
|
||||||
// Some tests override reply behavior; keep a stable baseline between tests.
|
|
||||||
replySpy.mockReset();
|
|
||||||
replySpy.mockImplementation(async (_ctx, opts) => {
|
|
||||||
await opts?.onReplyStart?.();
|
|
||||||
return undefined;
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
process.env.TZ = ORIGINAL_TZ;
|
process.env.TZ = ORIGINAL_TZ;
|
||||||
|
|||||||
Reference in New Issue
Block a user