mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 23:04:32 +00:00
test: stabilize agent embedded-run mocks
This commit is contained in:
@@ -2,7 +2,6 @@ import fs from "node:fs";
|
|||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { beforeEach, describe, expect, it, type MockInstance, vi } from "vitest";
|
import { beforeEach, describe, expect, it, type MockInstance, vi } from "vitest";
|
||||||
import { telegramPlugin } from "../../extensions/telegram/src/channel.js";
|
import { telegramPlugin } from "../../extensions/telegram/src/channel.js";
|
||||||
import "../cron/isolated-agent.mocks.js";
|
|
||||||
import { setTelegramRuntime } from "../../extensions/telegram/src/runtime.js";
|
import { setTelegramRuntime } from "../../extensions/telegram/src/runtime.js";
|
||||||
import { withTempHome as withTempHomeBase } from "../../test/helpers/temp-home.js";
|
import { withTempHome as withTempHomeBase } from "../../test/helpers/temp-home.js";
|
||||||
import { loadModelCatalog } from "../agents/model-catalog.js";
|
import { loadModelCatalog } from "../agents/model-catalog.js";
|
||||||
@@ -16,6 +15,22 @@ import type { RuntimeEnv } from "../runtime.js";
|
|||||||
import { createTestRegistry } from "../test-utils/channel-plugins.js";
|
import { createTestRegistry } from "../test-utils/channel-plugins.js";
|
||||||
import { agentCommand } from "./agent.js";
|
import { agentCommand } from "./agent.js";
|
||||||
|
|
||||||
|
vi.mock("../agents/pi-embedded.js", () => ({
|
||||||
|
runEmbeddedPiAgent: vi.fn(),
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock("../agents/model-catalog.js", () => ({
|
||||||
|
loadModelCatalog: vi.fn(),
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock("../agents/model-selection.js", async (importOriginal) => {
|
||||||
|
const actual = await importOriginal<typeof import("../agents/model-selection.js")>();
|
||||||
|
return {
|
||||||
|
...actual,
|
||||||
|
isCliProvider: vi.fn(() => false),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
const runtime: RuntimeEnv = {
|
const runtime: RuntimeEnv = {
|
||||||
log: vi.fn(),
|
log: vi.fn(),
|
||||||
error: vi.fn(),
|
error: vi.fn(),
|
||||||
|
|||||||
@@ -10,6 +10,14 @@ vi.mock("../agents/model-catalog.js", () => ({
|
|||||||
loadModelCatalog: vi.fn(),
|
loadModelCatalog: vi.fn(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
vi.mock("../agents/model-selection.js", async (importOriginal) => {
|
||||||
|
const actual = await importOriginal<typeof import("../agents/model-selection.js")>();
|
||||||
|
return {
|
||||||
|
...actual,
|
||||||
|
isCliProvider: vi.fn(() => false),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
vi.mock("../agents/subagent-announce.js", () => ({
|
vi.mock("../agents/subagent-announce.js", () => ({
|
||||||
runSubagentAnnounceFlow: vi.fn(),
|
runSubagentAnnounceFlow: vi.fn(),
|
||||||
}));
|
}));
|
||||||
|
|||||||
Reference in New Issue
Block a user