mirror of https://github.com/openclaw/openclaw.git
test: trim telegram bot import graph
This commit is contained in:
parent
9245b9e2f4
commit
d2dae50a75
|
|
@ -0,0 +1,12 @@
|
|||
export {
|
||||
loadSessionStore,
|
||||
resolveMarkdownTableMode,
|
||||
resolveSessionStoreEntry,
|
||||
resolveStorePath,
|
||||
} from "openclaw/plugin-sdk/config-runtime";
|
||||
export { getAgentScopedMediaLocalRoots } from "openclaw/plugin-sdk/media-runtime";
|
||||
export {
|
||||
generateTopicLabel,
|
||||
resolveAutoTopicLabelConfig,
|
||||
resolveChunkMode,
|
||||
} from "openclaw/plugin-sdk/reply-runtime";
|
||||
|
|
@ -1,5 +1,10 @@
|
|||
import type { Bot } from "grammy";
|
||||
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { resolveChunkMode as resolveChunkModeRuntime } from "../../../src/auto-reply/chunk.js";
|
||||
import { resolveAutoTopicLabelConfig as resolveAutoTopicLabelConfigRuntime } from "../../../src/auto-reply/reply/auto-topic-label-config.js";
|
||||
import { resolveMarkdownTableMode as resolveMarkdownTableModeRuntime } from "../../../src/config/markdown-tables.js";
|
||||
import { resolveSessionStoreEntry as resolveSessionStoreEntryRuntime } from "../../../src/config/sessions/store.js";
|
||||
import { getAgentScopedMediaLocalRoots as getAgentScopedMediaLocalRootsRuntime } from "../../../src/media/local-roots.js";
|
||||
import type { TelegramBotDeps } from "./bot-deps.js";
|
||||
import {
|
||||
createSequencedTestDraftStream,
|
||||
|
|
@ -59,14 +64,6 @@ vi.mock("./draft-stream.js", () => ({
|
|||
createTelegramDraftStream,
|
||||
}));
|
||||
|
||||
vi.mock("openclaw/plugin-sdk/reply-runtime", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("openclaw/plugin-sdk/reply-runtime")>();
|
||||
return {
|
||||
...actual,
|
||||
generateTopicLabel,
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock("./bot/delivery.js", () => ({
|
||||
deliverReplies,
|
||||
emitInternalMessageSentHook,
|
||||
|
|
@ -88,15 +85,16 @@ vi.mock("./send.js", () => ({
|
|||
sendStickerTelegram,
|
||||
}));
|
||||
|
||||
vi.mock("openclaw/plugin-sdk/config-runtime", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("openclaw/plugin-sdk/config-runtime")>();
|
||||
return {
|
||||
...actual,
|
||||
loadConfig,
|
||||
loadSessionStore,
|
||||
resolveStorePath,
|
||||
};
|
||||
});
|
||||
vi.mock("./bot-message-dispatch.runtime.js", () => ({
|
||||
generateTopicLabel,
|
||||
getAgentScopedMediaLocalRoots: getAgentScopedMediaLocalRootsRuntime,
|
||||
loadSessionStore,
|
||||
resolveAutoTopicLabelConfig: resolveAutoTopicLabelConfigRuntime,
|
||||
resolveChunkMode: resolveChunkModeRuntime,
|
||||
resolveMarkdownTableMode: resolveMarkdownTableModeRuntime,
|
||||
resolveSessionStoreEntry: resolveSessionStoreEntryRuntime,
|
||||
resolveStorePath,
|
||||
}));
|
||||
|
||||
vi.mock("./sticker-cache.js", () => ({
|
||||
cacheSticker: vi.fn(),
|
||||
|
|
|
|||
|
|
@ -12,28 +12,29 @@ import {
|
|||
removeAckReactionAfterReply,
|
||||
} from "openclaw/plugin-sdk/channel-feedback";
|
||||
import { createChannelReplyPipeline } from "openclaw/plugin-sdk/channel-reply-pipeline";
|
||||
import { resolveMarkdownTableMode } from "openclaw/plugin-sdk/config-runtime";
|
||||
import {
|
||||
loadSessionStore,
|
||||
resolveSessionStoreEntry,
|
||||
resolveStorePath,
|
||||
} from "openclaw/plugin-sdk/config-runtime";
|
||||
import type {
|
||||
OpenClawConfig,
|
||||
ReplyToMode,
|
||||
TelegramAccountConfig,
|
||||
TelegramDirectConfig,
|
||||
} from "openclaw/plugin-sdk/config-runtime";
|
||||
import { getAgentScopedMediaLocalRoots } from "openclaw/plugin-sdk/media-runtime";
|
||||
import { clearHistoryEntriesIfEnabled } from "openclaw/plugin-sdk/reply-history";
|
||||
import { resolveSendableOutboundReplyParts } from "openclaw/plugin-sdk/reply-payload";
|
||||
import { resolveChunkMode } from "openclaw/plugin-sdk/reply-runtime";
|
||||
import type { ReplyPayload } from "openclaw/plugin-sdk/reply-runtime";
|
||||
import { resolveAutoTopicLabelConfig, generateTopicLabel } from "openclaw/plugin-sdk/reply-runtime";
|
||||
import { danger, logVerbose } from "openclaw/plugin-sdk/runtime-env";
|
||||
import type { RuntimeEnv } from "openclaw/plugin-sdk/runtime-env";
|
||||
import { defaultTelegramBotDeps, type TelegramBotDeps } from "./bot-deps.js";
|
||||
import type { TelegramMessageContext } from "./bot-message-context.js";
|
||||
import {
|
||||
loadSessionStore,
|
||||
resolveMarkdownTableMode,
|
||||
resolveSessionStoreEntry,
|
||||
resolveStorePath,
|
||||
getAgentScopedMediaLocalRoots,
|
||||
resolveChunkMode,
|
||||
resolveAutoTopicLabelConfig,
|
||||
generateTopicLabel,
|
||||
} from "./bot-message-dispatch.runtime.js";
|
||||
import type { TelegramBotOptions } from "./bot.js";
|
||||
import { deliverReplies, emitInternalMessageSentHook } from "./bot/delivery.js";
|
||||
import type { TelegramStreamMode } from "./bot/types.js";
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import { resolveDefaultModelForAgent } from "openclaw/plugin-sdk/agent-runtime";
|
||||
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime";
|
||||
import { resetInboundDedupe } from "openclaw/plugin-sdk/reply-runtime";
|
||||
import type { MsgContext } from "openclaw/plugin-sdk/reply-runtime";
|
||||
import type { GetReplyOptions, ReplyPayload } from "openclaw/plugin-sdk/reply-runtime";
|
||||
import { createReplyDispatcher } from "openclaw/plugin-sdk/reply-runtime";
|
||||
import type { MockFn } from "openclaw/plugin-sdk/testing";
|
||||
import { beforeEach, vi } from "vitest";
|
||||
import { resetInboundDedupe } from "../../../src/auto-reply/reply/inbound-dedupe.js";
|
||||
import { createReplyDispatcher } from "../../../src/auto-reply/reply/reply-dispatcher.js";
|
||||
import type { MsgContext } from "../../../src/auto-reply/templating.js";
|
||||
import type { GetReplyOptions, ReplyPayload } from "../../../src/auto-reply/types.js";
|
||||
import type { TelegramBotDeps } from "./bot-deps.js";
|
||||
|
||||
type AnyMock = ReturnType<typeof vi.fn>;
|
||||
|
|
@ -18,7 +18,7 @@ type TelegramBotRuntimeForTest = NonNullable<
|
|||
Parameters<typeof import("./bot.js").setTelegramBotRuntimeForTest>[0]
|
||||
>;
|
||||
type DispatchReplyWithBufferedBlockDispatcherFn =
|
||||
typeof import("openclaw/plugin-sdk/reply-runtime").dispatchReplyWithBufferedBlockDispatcher;
|
||||
typeof import("openclaw/plugin-sdk/reply-dispatch-runtime").dispatchReplyWithBufferedBlockDispatcher;
|
||||
type DispatchReplyWithBufferedBlockDispatcherResult = Awaited<
|
||||
ReturnType<DispatchReplyWithBufferedBlockDispatcherFn>
|
||||
>;
|
||||
|
|
@ -79,16 +79,6 @@ export function setSessionStoreEntriesForTest(entries: SessionStore) {
|
|||
sessionStoreEntries.value = JSON.parse(JSON.stringify(entries)) as SessionStore;
|
||||
}
|
||||
|
||||
vi.doMock("openclaw/plugin-sdk/config-runtime", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("openclaw/plugin-sdk/config-runtime")>();
|
||||
return {
|
||||
...actual,
|
||||
loadConfig,
|
||||
loadSessionStore: loadSessionStoreMock,
|
||||
resolveStorePath: resolveStorePathMock,
|
||||
};
|
||||
});
|
||||
|
||||
const { readChannelAllowFromStore, upsertChannelPairingRequest } = vi.hoisted(
|
||||
(): {
|
||||
readChannelAllowFromStore: MockFn<TelegramBotDeps["readChannelAllowFromStore"]>;
|
||||
|
|
@ -110,23 +100,6 @@ export function getUpsertChannelPairingRequestMock(): AnyAsyncMock {
|
|||
return upsertChannelPairingRequest;
|
||||
}
|
||||
|
||||
vi.doMock("openclaw/plugin-sdk/conversation-runtime", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("openclaw/plugin-sdk/conversation-runtime")>();
|
||||
return {
|
||||
...actual,
|
||||
readChannelAllowFromStore,
|
||||
upsertChannelPairingRequest,
|
||||
};
|
||||
});
|
||||
vi.doMock("openclaw/plugin-sdk/conversation-runtime.js", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("openclaw/plugin-sdk/conversation-runtime")>();
|
||||
return {
|
||||
...actual,
|
||||
readChannelAllowFromStore,
|
||||
upsertChannelPairingRequest,
|
||||
};
|
||||
});
|
||||
|
||||
const skillCommandListHoisted = vi.hoisted(() => ({
|
||||
listSkillCommandsForAgents: vi.fn(() => []),
|
||||
}));
|
||||
|
|
@ -249,27 +222,6 @@ function createModelsProviderDataFromConfig(cfg: OpenClawConfig): {
|
|||
return { byProvider, providers, resolvedDefault, modelNames: new Map<string, string>() };
|
||||
}
|
||||
|
||||
vi.doMock("openclaw/plugin-sdk/reply-runtime", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("openclaw/plugin-sdk/reply-runtime")>();
|
||||
return {
|
||||
...actual,
|
||||
getReplyFromConfig: replySpyHoisted.replySpy,
|
||||
__replySpy: replySpyHoisted.replySpy,
|
||||
dispatchReplyWithBufferedBlockDispatcher:
|
||||
dispatchReplyHoisted.dispatchReplyWithBufferedBlockDispatcher,
|
||||
};
|
||||
});
|
||||
vi.doMock("openclaw/plugin-sdk/reply-runtime.js", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("openclaw/plugin-sdk/reply-runtime")>();
|
||||
return {
|
||||
...actual,
|
||||
getReplyFromConfig: replySpyHoisted.replySpy,
|
||||
__replySpy: replySpyHoisted.replySpy,
|
||||
dispatchReplyWithBufferedBlockDispatcher:
|
||||
dispatchReplyHoisted.dispatchReplyWithBufferedBlockDispatcher,
|
||||
};
|
||||
});
|
||||
|
||||
const systemEventsHoisted = vi.hoisted(() => ({
|
||||
enqueueSystemEventSpy: vi.fn<TelegramBotDeps["enqueueSystemEvent"]>(() => false),
|
||||
}));
|
||||
|
|
|
|||
Loading…
Reference in New Issue