Compare commits

...

2 Commits

Author SHA1 Message Date
Josh Lehman
ad66dc09b9
test: fix pre-existing tsgo errors in backup-create and pairing-pending tests 2026-03-13 13:06:06 -07:00
Josh Lehman
c1cc474a57
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.
2026-03-13 13:06:06 -07:00
3 changed files with 12 additions and 6 deletions

View File

@ -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 () => {}),

View File

@ -64,7 +64,7 @@ describe("formatBackupCreateSummary", () => {
displayPath: "~/.openclaw/config.json",
},
{
kind: "oauth",
kind: "credentials",
sourcePath: "/oauth",
archivePath: "archive/oauth",
displayPath: "~/.openclaw/oauth",

View File

@ -33,7 +33,7 @@ describe("rejectPendingPairingRequest", () => {
idKey: "accountId",
loadState: async () => state,
persistState,
getId: (pending) => pending.accountId,
getId: (pending: { accountId: string }) => pending.accountId,
}),
).resolves.toEqual({
requestId: "reject",