refactor: narrow telegram test mocks off infra runtime

This commit is contained in:
Peter Steinberger
2026-03-28 06:56:41 +00:00
parent df4c9c5bd8
commit 5802d112da
3 changed files with 6 additions and 13 deletions

View File

@@ -273,8 +273,8 @@ const systemEventsHoisted = vi.hoisted(() => ({
export const enqueueSystemEventSpy: MockFn<TelegramBotDeps["enqueueSystemEvent"]> =
systemEventsHoisted.enqueueSystemEventSpy;
vi.doMock("openclaw/plugin-sdk/infra-runtime", async (importOriginal) => {
const actual = await importOriginal<typeof import("openclaw/plugin-sdk/infra-runtime")>();
vi.doMock("openclaw/plugin-sdk/channel-runtime", async (importOriginal) => {
const actual = await importOriginal<typeof import("openclaw/plugin-sdk/channel-runtime")>();
return {
...actual,
enqueueSystemEvent: systemEventsHoisted.enqueueSystemEventSpy,

View File

@@ -286,19 +286,12 @@ vi.mock("@grammyjs/runner", () => ({
run: runSpy,
}));
vi.mock("openclaw/plugin-sdk/infra-runtime", async (importOriginal) => {
const actual = await importOriginal<typeof import("openclaw/plugin-sdk/infra-runtime")>();
return {
...actual,
computeBackoff,
sleepWithAbort,
};
});
vi.mock("openclaw/plugin-sdk/runtime-env", async (importOriginal) => {
const actual = await importOriginal<typeof import("openclaw/plugin-sdk/runtime-env")>();
return {
...actual,
computeBackoff,
sleepWithAbort,
registerUnhandledRejectionHandler: registerUnhandledRejectionHandlerMock,
};
});

View File

@@ -5,8 +5,8 @@ const mocks = vi.hoisted(() => ({
}));
// Mock the runtime-exported backoff sleep that the handler actually imports.
vi.mock("openclaw/plugin-sdk/infra-runtime", async (importOriginal) => {
const actual = await importOriginal<typeof import("openclaw/plugin-sdk/infra-runtime")>();
vi.mock("openclaw/plugin-sdk/runtime-env", async (importOriginal) => {
const actual = await importOriginal<typeof import("openclaw/plugin-sdk/runtime-env")>();
return {
...actual,
sleepWithAbort: mocks.sleepWithAbort,