mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 01:10:21 +00:00
test: narrow auto-reply command imports
This commit is contained in:
@@ -1,12 +1,20 @@
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import { withTempHome } from "../../config/home-env.test-harness.js";
|
||||
import { handleCommands } from "./commands-core.js";
|
||||
import { createCommandWorkspaceHarness } from "./commands-filesystem.test-support.js";
|
||||
import { handleMcpCommand } from "./commands-mcp.js";
|
||||
import { buildCommandTestParams } from "./commands.test-harness.js";
|
||||
|
||||
const workspaceHarness = createCommandWorkspaceHarness("openclaw-command-mcp-");
|
||||
|
||||
function expectMcpResult<T>(result: T | null): T {
|
||||
expect(result).toBeTruthy();
|
||||
if (!result) {
|
||||
throw new Error("expected MCP command result");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function buildCfg(): OpenClawConfig {
|
||||
return {
|
||||
commands: {
|
||||
@@ -32,14 +40,14 @@ describe("handleCommands /mcp", () => {
|
||||
);
|
||||
setParams.command.senderIsOwner = true;
|
||||
|
||||
const setResult = await handleCommands(setParams);
|
||||
const setResult = expectMcpResult(await handleMcpCommand(setParams, true));
|
||||
expect(setResult.reply?.text).toContain('MCP server "context7" saved');
|
||||
|
||||
const showParams = buildCommandTestParams("/mcp show context7", buildCfg(), undefined, {
|
||||
workspaceDir,
|
||||
});
|
||||
showParams.command.senderIsOwner = true;
|
||||
const showResult = await handleCommands(showParams);
|
||||
const showResult = expectMcpResult(await handleMcpCommand(showParams, true));
|
||||
expect(showResult.reply?.text).toContain('"command": "uvx"');
|
||||
expect(showResult.reply?.text).toContain('"args": [');
|
||||
});
|
||||
@@ -60,7 +68,7 @@ describe("handleCommands /mcp", () => {
|
||||
);
|
||||
params.command.senderIsOwner = true;
|
||||
|
||||
const result = await handleCommands(params);
|
||||
const result = expectMcpResult(await handleMcpCommand(params, true));
|
||||
expect(result.reply?.text).toContain("requires operator.admin");
|
||||
});
|
||||
});
|
||||
@@ -76,7 +84,7 @@ describe("handleCommands /mcp", () => {
|
||||
);
|
||||
params.command.senderIsOwner = true;
|
||||
|
||||
const result = await handleCommands(params);
|
||||
const result = expectMcpResult(await handleMcpCommand(params, true));
|
||||
expect(result.reply?.text).toContain('MCP server "remote" saved');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { buildTelegramModelsProviderChannelData } from "../../../test/helpers/channels/command-contract.js";
|
||||
import type { ChannelPlugin } from "../../channels/plugins/types.js";
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import { setActivePluginRegistry } from "../../plugins/runtime.js";
|
||||
@@ -40,7 +39,16 @@ const telegramModelsTestPlugin: ChannelPlugin = {
|
||||
},
|
||||
}),
|
||||
commands: {
|
||||
buildModelsProviderChannelData: buildTelegramModelsProviderChannelData,
|
||||
buildModelsProviderChannelData: ({ providers }) => ({
|
||||
telegram: {
|
||||
buttons: providers.map((provider) => [
|
||||
{
|
||||
text: provider.id,
|
||||
callback_data: `models:${provider.id}`,
|
||||
},
|
||||
]),
|
||||
},
|
||||
}),
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user