perf: speed up telegram bot suite setup
This commit is contained in:
@@ -228,16 +228,31 @@ export function makeForumGroupMessageCtx(params?: {
|
||||
|
||||
beforeEach(() => {
|
||||
resetInboundDedupe();
|
||||
loadConfig.mockReset();
|
||||
loadConfig.mockReturnValue({
|
||||
agents: {
|
||||
defaults: {
|
||||
envelopeTimezone: "utc",
|
||||
},
|
||||
},
|
||||
channels: {
|
||||
telegram: { dmPolicy: "open", allowFrom: ["*"] },
|
||||
},
|
||||
});
|
||||
loadWebMedia.mockReset();
|
||||
readChannelAllowFromStore.mockReset();
|
||||
readChannelAllowFromStore.mockResolvedValue([]);
|
||||
upsertChannelPairingRequest.mockReset();
|
||||
upsertChannelPairingRequest.mockResolvedValue({ code: "PAIRCODE", created: true } as const);
|
||||
onSpy.mockReset();
|
||||
commandSpy.mockReset();
|
||||
stopSpy.mockReset();
|
||||
useSpy.mockReset();
|
||||
replySpy.mockReset();
|
||||
replySpy.mockImplementation(async (_ctx, opts) => {
|
||||
await opts?.onReplyStart?.();
|
||||
return undefined;
|
||||
});
|
||||
|
||||
sendAnimationSpy.mockReset();
|
||||
sendAnimationSpy.mockResolvedValue({ message_id: 78 });
|
||||
|
||||
@@ -40,27 +40,6 @@ const ORIGINAL_TZ = process.env.TZ;
|
||||
describe("createTelegramBot", () => {
|
||||
beforeEach(() => {
|
||||
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(() => {
|
||||
process.env.TZ = ORIGINAL_TZ;
|
||||
|
||||
Reference in New Issue
Block a user