mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 14:50:45 +00:00
test: route extension tests through sdk subpaths
This commit is contained in:
@@ -2,8 +2,8 @@ import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types";
|
||||
import { clearSessionStoreCacheForTest } from "openclaw/plugin-sdk/session-store-runtime";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { clearSessionStoreCacheForTest } from "../../../src/config/sessions/store.js";
|
||||
import { telegramApprovalCapability, telegramNativeApprovalAdapter } from "./approval-native.js";
|
||||
|
||||
function buildConfig(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { Bot } from "grammy";
|
||||
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types";
|
||||
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { OpenClawConfig } from "../../../src/config/types.openclaw.js";
|
||||
import { resolveAutoTopicLabelConfig as resolveAutoTopicLabelConfigRuntime } from "./auto-topic-label-config.js";
|
||||
import type { TelegramBotDeps } from "./bot-deps.js";
|
||||
import {
|
||||
|
||||
@@ -4,7 +4,7 @@ import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||
let registerTelegramNativeCommands: typeof import("./bot-native-commands.js").registerTelegramNativeCommands;
|
||||
let clearPluginCommands: typeof import("../../../src/plugins/commands.js").clearPluginCommands;
|
||||
let registerPluginCommand: typeof import("../../../src/plugins/commands.js").registerPluginCommand;
|
||||
let setActivePluginRegistry: typeof import("../../../src/plugins/runtime.js").setActivePluginRegistry;
|
||||
let setActivePluginRegistry: typeof import("openclaw/plugin-sdk/testing").setActivePluginRegistry;
|
||||
let createCommandBot: typeof import("./bot-native-commands.menu-test-support.js").createCommandBot;
|
||||
let createNativeCommandTestParams: typeof import("./bot-native-commands.menu-test-support.js").createNativeCommandTestParams;
|
||||
let createPrivateCommandContext: typeof import("./bot-native-commands.menu-test-support.js").createPrivateCommandContext;
|
||||
@@ -115,7 +115,7 @@ describe("registerTelegramNativeCommands real plugin registry", () => {
|
||||
beforeAll(async () => {
|
||||
({ clearPluginCommands, registerPluginCommand } =
|
||||
await import("../../../src/plugins/commands.js"));
|
||||
({ setActivePluginRegistry } = await import("../../../src/plugins/runtime.js"));
|
||||
({ setActivePluginRegistry } = await import("openclaw/plugin-sdk/testing"));
|
||||
({ registerTelegramNativeCommands } = await import("./bot-native-commands.js"));
|
||||
({
|
||||
createCommandBot,
|
||||
|
||||
@@ -4,8 +4,8 @@ import {
|
||||
clearPluginInteractiveHandlers,
|
||||
registerPluginInteractiveHandler,
|
||||
} from "openclaw/plugin-sdk/plugin-runtime";
|
||||
import { mockPinnedHostnameResolution } from "openclaw/plugin-sdk/testing";
|
||||
import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { mockPinnedHostnameResolution } from "../../../src/test-helpers/ssrf.js";
|
||||
import type { TelegramInteractiveHandlerContext } from "./interactive-dispatch.js";
|
||||
const {
|
||||
answerCallbackQuerySpy,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { Message } from "@grammyjs/types";
|
||||
import { retryAsync } from "openclaw/plugin-sdk/retry-runtime";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { retryAsync } from "../../../../src/infra/retry.js";
|
||||
import { resolveMedia } from "./delivery.resolve-media.js";
|
||||
import type { TelegramContext } from "./types.js";
|
||||
|
||||
|
||||
@@ -24,27 +24,26 @@ type DeliverWithParams = Omit<
|
||||
Partial<Pick<DeliverRepliesParams, "replyToMode" | "textLimit" | "mediaLoader">>;
|
||||
type RuntimeStub = Pick<RuntimeEnv, "error" | "log" | "exit">;
|
||||
|
||||
vi.mock("openclaw/plugin-sdk/web-media", () => ({
|
||||
loadWebMedia: (...args: unknown[]) => loadWebMedia(...args),
|
||||
}));
|
||||
vi.mock("openclaw/plugin-sdk/web-media", () => ({
|
||||
loadWebMedia: (...args: unknown[]) => loadWebMedia(...args),
|
||||
}));
|
||||
|
||||
vi.mock("../../../../src/plugins/hook-runner-global.js", () => ({
|
||||
getGlobalHookRunner: () => messageHookRunner,
|
||||
}));
|
||||
|
||||
vi.mock("../../../../src/hooks/internal-hooks.js", async () => {
|
||||
const actual = await vi.importActual<typeof import("../../../../src/hooks/internal-hooks.js")>(
|
||||
"../../../../src/hooks/internal-hooks.js",
|
||||
);
|
||||
vi.mock("openclaw/plugin-sdk/hook-runtime", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("openclaw/plugin-sdk/hook-runtime")>();
|
||||
return {
|
||||
...actual,
|
||||
triggerInternalHook,
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock("openclaw/plugin-sdk/plugin-runtime", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("openclaw/plugin-sdk/plugin-runtime")>();
|
||||
return {
|
||||
...actual,
|
||||
getGlobalHookRunner: () => messageHookRunner,
|
||||
};
|
||||
});
|
||||
|
||||
vi.resetModules();
|
||||
const { deliverReplies } = await import("./delivery.js");
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@ import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types";
|
||||
import { withStateDirEnv } from "openclaw/plugin-sdk/testing";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { withStateDirEnv } from "../../../src/test-helpers/state-dir-env.js";
|
||||
import { resolveTelegramToken } from "./token.js";
|
||||
import { readTelegramUpdateOffset, writeTelegramUpdateOffset } from "./update-offset-store.js";
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { withStateDirEnv } from "openclaw/plugin-sdk/testing";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { withStateDirEnv } from "../../../src/test-helpers/state-dir-env.js";
|
||||
import {
|
||||
deleteTelegramUpdateOffset,
|
||||
readTelegramUpdateOffset,
|
||||
|
||||
Reference in New Issue
Block a user