mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 09:38:39 +00:00
test: fix stale compact hooks mocks
Regeneration-Prompt: | Fix the broken test imports in src/agents/pi-embedded-runner/compact.hooks.test.ts without touching production code. The immediate failure was a stale vi.mock for ../../utils/message-channel.js that no longer exposed INTERNAL_MESSAGE_CHANNEL, so the mock should spread the real module exports via importOriginal and override only normalizeMessageChannel. After that change, the suite still could not import because the @mariozechner/pi-coding-agent mock also shadowed newer exports, so apply the same partial-mock pattern there. Verify pnpm vitest run src/agents/pi-embedded-runner/compact.hooks.test.ts and pnpm vitest run src/plugins/wired-hooks-compaction.test.ts both pass.
This commit is contained in:
@@ -91,8 +91,10 @@ vi.mock("@mariozechner/pi-ai/oauth", () => ({
|
|||||||
getOAuthProviders: vi.fn(() => []),
|
getOAuthProviders: vi.fn(() => []),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
vi.mock("@mariozechner/pi-coding-agent", () => {
|
vi.mock("@mariozechner/pi-coding-agent", async (importOriginal) => {
|
||||||
|
const actual = await importOriginal<typeof import("@mariozechner/pi-coding-agent")>();
|
||||||
return {
|
return {
|
||||||
|
...actual,
|
||||||
createAgentSession: vi.fn(async () => {
|
createAgentSession: vi.fn(async () => {
|
||||||
const session = {
|
const session = {
|
||||||
sessionId: "session-1",
|
sessionId: "session-1",
|
||||||
@@ -277,9 +279,13 @@ vi.mock("../../config/channel-capabilities.js", () => ({
|
|||||||
resolveChannelCapabilities: vi.fn(() => undefined),
|
resolveChannelCapabilities: vi.fn(() => undefined),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
vi.mock("../../utils/message-channel.js", () => ({
|
vi.mock("../../utils/message-channel.js", async (importOriginal) => {
|
||||||
normalizeMessageChannel: vi.fn(() => undefined),
|
const actual = await importOriginal<typeof import("../../utils/message-channel.js")>();
|
||||||
}));
|
return {
|
||||||
|
...actual,
|
||||||
|
normalizeMessageChannel: vi.fn(() => undefined),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
vi.mock("../pi-embedded-helpers.js", () => ({
|
vi.mock("../pi-embedded-helpers.js", () => ({
|
||||||
ensureSessionHeader: vi.fn(async () => {}),
|
ensureSessionHeader: vi.fn(async () => {}),
|
||||||
|
|||||||
Reference in New Issue
Block a user