test(telegram): rewire bot harnesses to runtime seams

This commit is contained in:
Ayaan Zaidi
2026-03-18 09:47:58 +05:30
parent edcf3e9d32
commit 23f618d62d
3 changed files with 126 additions and 42 deletions

View File

@@ -5,7 +5,7 @@ import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";
import { escapeRegExp, formatEnvelopeTimestamp } from "../../../test/helpers/envelope-timestamp.js";
import { withEnvAsync } from "../../../test/helpers/extensions/env.js";
import { useFrozenTime, useRealTime } from "../../../test/helpers/extensions/frozen-time.js";
import {
const {
answerCallbackQuerySpy,
botCtorSpy,
commandSpy,
@@ -26,13 +26,26 @@ import {
sequentializeSpy,
setMessageReactionSpy,
setMyCommandsSpy,
telegramBotHandlersRuntimeForTest,
telegramBotMessageDispatchRuntimeForTest,
telegramBotNativeCommandsRuntimeForTest,
telegramBotRuntimeForTest,
throttlerSpy,
useSpy,
} from "./bot.create-telegram-bot.test-harness.js";
} = await import("./bot.create-telegram-bot.test-harness.js");
import { resolveTelegramFetch } from "./fetch.js";
// Import after the harness registers `vi.mock(...)` for grammY and Telegram internals.
const { createTelegramBot, getTelegramSequentialKey } = await import("./bot.js");
const { createTelegramBot, getTelegramSequentialKey, setTelegramBotRuntimeForTest } =
await import("./bot.js");
const { setBotHandlersRuntimeForTest } = await import("./bot-handlers.runtime.js");
const { setBotMessageDispatchRuntimeForTest } = await import("./bot-message-dispatch.js");
const { setBotNativeCommandsRuntimeForTest } = await import("./bot-native-commands.js");
setTelegramBotRuntimeForTest(telegramBotRuntimeForTest);
setBotHandlersRuntimeForTest(telegramBotHandlersRuntimeForTest);
setBotMessageDispatchRuntimeForTest(telegramBotMessageDispatchRuntimeForTest);
setBotNativeCommandsRuntimeForTest(telegramBotNativeCommandsRuntimeForTest);
const loadConfig = getLoadConfigMock();
const loadWebMedia = getLoadWebMediaMock();