mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 21:00:22 +00:00
refactor: dedupe plugin lazy runtime helpers
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
import { vi } from "vitest";
|
||||
|
||||
export const pluginCommandMocks = {
|
||||
getPluginCommandSpecs: vi.fn(() => []),
|
||||
matchPluginCommand: vi.fn(() => null),
|
||||
executePluginCommand: vi.fn(async () => ({ text: "ok" })),
|
||||
};
|
||||
|
||||
vi.mock("openclaw/plugin-sdk/plugin-runtime", () => ({
|
||||
getPluginCommandSpecs: pluginCommandMocks.getPluginCommandSpecs,
|
||||
matchPluginCommand: pluginCommandMocks.matchPluginCommand,
|
||||
executePluginCommand: pluginCommandMocks.executePluginCommand,
|
||||
}));
|
||||
|
||||
export function resetPluginCommandMocks() {
|
||||
pluginCommandMocks.getPluginCommandSpecs.mockClear();
|
||||
pluginCommandMocks.getPluginCommandSpecs.mockReturnValue([]);
|
||||
pluginCommandMocks.matchPluginCommand.mockClear();
|
||||
pluginCommandMocks.matchPluginCommand.mockReturnValue(null);
|
||||
pluginCommandMocks.executePluginCommand.mockClear();
|
||||
pluginCommandMocks.executePluginCommand.mockResolvedValue({ text: "ok" });
|
||||
}
|
||||
@@ -4,16 +4,16 @@ import path from "node:path";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { writeSkill } from "../../../src/agents/skills.e2e-test-helpers.js";
|
||||
import type { OpenClawConfig } from "../../../src/config/config.js";
|
||||
import {
|
||||
pluginCommandMocks,
|
||||
resetPluginCommandMocks,
|
||||
} from "../../../test/helpers/extensions/telegram-plugin-command.js";
|
||||
import { registerTelegramNativeCommands } from "./bot-native-commands.js";
|
||||
import {
|
||||
createNativeCommandTestParams,
|
||||
resetNativeCommandMenuMocks,
|
||||
waitForRegisteredCommands,
|
||||
} from "./bot-native-commands.menu-test-support.js";
|
||||
import {
|
||||
pluginCommandMocks,
|
||||
resetPluginCommandMocks,
|
||||
} from "./bot-native-commands.plugin-command-test-support.js";
|
||||
|
||||
const tempDirs: string[] = [];
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import type { RuntimeEnv } from "../../../src/runtime.js";
|
||||
import {
|
||||
pluginCommandMocks,
|
||||
resetPluginCommandMocks,
|
||||
} from "./bot-native-commands.plugin-command-test-support.js";
|
||||
} from "../../../test/helpers/extensions/telegram-plugin-command.js";
|
||||
const skillCommandMocks = vi.hoisted(() => ({
|
||||
listSkillCommandsForAgents: vi.fn(() => []),
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user