mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 12:30:44 +00:00
test(types): fix perf test follow-up mocks
This commit is contained in:
@@ -12,15 +12,18 @@ import {
|
||||
|
||||
const runCronIsolatedAgentTurn = await loadRunCronIsolatedAgentTurn();
|
||||
|
||||
function makeParams(overrides?: Record<string, unknown>) {
|
||||
type RunCronIsolatedAgentTurnParams = Parameters<typeof runCronIsolatedAgentTurn>[0];
|
||||
|
||||
function makeParams(
|
||||
overrides?: Partial<RunCronIsolatedAgentTurnParams>,
|
||||
): RunCronIsolatedAgentTurnParams {
|
||||
return {
|
||||
cfg: {
|
||||
auth: {
|
||||
profiles: {
|
||||
"openrouter:default": {
|
||||
type: "api_key",
|
||||
provider: "openrouter",
|
||||
key: "sk-or-test-key",
|
||||
mode: "api_key",
|
||||
},
|
||||
},
|
||||
order: { openrouter: ["openrouter:default"] },
|
||||
|
||||
@@ -25,6 +25,7 @@ vi.mock("../../config/plugin-auto-enable.js", () => ({
|
||||
|
||||
vi.mock("../../channels/plugins/index.js", () => ({
|
||||
listChannelPlugins: mocks.listChannelPlugins,
|
||||
getLoadedChannelPlugin: vi.fn(),
|
||||
getChannelPlugin: vi.fn(),
|
||||
normalizeChannelId: (value: string) => value,
|
||||
}));
|
||||
|
||||
@@ -108,6 +108,27 @@ vi.mock("../../agents/agent-scope.js", () => ({
|
||||
resolveDefaultAgentId: vi.fn(() => "main"),
|
||||
}));
|
||||
vi.mock("../../channels/plugins/index.js", () => ({
|
||||
getLoadedChannelPlugin: vi.fn((provider: string) => {
|
||||
if (provider === "discord") {
|
||||
return {
|
||||
commands: {
|
||||
resolveNativeCommandName: ({
|
||||
commandKey,
|
||||
defaultName,
|
||||
}: {
|
||||
commandKey: string;
|
||||
defaultName: string;
|
||||
}) => {
|
||||
if (commandKey === "model") {
|
||||
return "set_model";
|
||||
}
|
||||
return defaultName;
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
return undefined;
|
||||
}),
|
||||
getChannelPlugin: vi.fn((provider: string) => {
|
||||
if (provider === "discord") {
|
||||
return {
|
||||
|
||||
@@ -39,6 +39,7 @@ vi.mock("../../config/config.js", async () => {
|
||||
});
|
||||
|
||||
vi.mock("../../channels/plugins/index.js", () => ({
|
||||
getLoadedChannelPlugin: mocks.getChannelPlugin,
|
||||
getChannelPlugin: mocks.getChannelPlugin,
|
||||
normalizeChannelId: (value: string) => (value === "webchat" ? null : value),
|
||||
}));
|
||||
|
||||
@@ -6,6 +6,7 @@ const mocks = vi.hoisted(() => ({
|
||||
}));
|
||||
|
||||
vi.mock("../../channels/plugins/index.js", () => ({
|
||||
getLoadedChannelPlugin: vi.fn(),
|
||||
listChannelPlugins: mocks.listChannelPlugins,
|
||||
}));
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
const getChannelPluginMock = vi.hoisted(() => vi.fn((_channel: unknown) => undefined));
|
||||
|
||||
vi.mock("../../channels/plugins/index.js", () => ({
|
||||
getLoadedChannelPlugin: getChannelPluginMock,
|
||||
getChannelPlugin: getChannelPluginMock,
|
||||
}));
|
||||
describe("formatOutboundDeliverySummary", () => {
|
||||
|
||||
@@ -9,6 +9,7 @@ const mocks = vi.hoisted(() => ({
|
||||
|
||||
vi.mock("../../channels/plugins/index.js", () => ({
|
||||
normalizeChannelId: (channel?: string) => channel?.trim().toLowerCase() ?? undefined,
|
||||
getLoadedChannelPlugin: mocks.getChannelPlugin,
|
||||
getChannelPlugin: mocks.getChannelPlugin,
|
||||
listChannelPlugins: () => [],
|
||||
}));
|
||||
|
||||
@@ -18,6 +18,7 @@ const mocks = vi.hoisted(() => ({
|
||||
}));
|
||||
|
||||
vi.mock("../../channels/plugins/index.js", () => ({
|
||||
getLoadedChannelPlugin: (...args: unknown[]) => mocks.getChannelPlugin(...args),
|
||||
getChannelPlugin: (...args: unknown[]) => mocks.getChannelPlugin(...args),
|
||||
normalizeChannelId: (value: string) => value,
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user