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:
parent
bf6da81028
commit
c1cc474a57
@ -91,8 +91,10 @@ vi.mock("@mariozechner/pi-ai/oauth", () => ({
|
||||
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 {
|
||||
...actual,
|
||||
createAgentSession: vi.fn(async () => {
|
||||
const session = {
|
||||
sessionId: "session-1",
|
||||
@ -277,9 +279,13 @@ vi.mock("../../config/channel-capabilities.js", () => ({
|
||||
resolveChannelCapabilities: vi.fn(() => undefined),
|
||||
}));
|
||||
|
||||
vi.mock("../../utils/message-channel.js", () => ({
|
||||
normalizeMessageChannel: vi.fn(() => undefined),
|
||||
}));
|
||||
vi.mock("../../utils/message-channel.js", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("../../utils/message-channel.js")>();
|
||||
return {
|
||||
...actual,
|
||||
normalizeMessageChannel: vi.fn(() => undefined),
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock("../pi-embedded-helpers.js", () => ({
|
||||
ensureSessionHeader: vi.fn(async () => {}),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user