mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-19 05:50:47 +00:00
test: fix imessage extension CI mocks
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import * as onboardHelpers from "../../../src/commands/onboard-helpers.js";
|
||||
import * as execModule from "../../../src/process/exec.js";
|
||||
import * as processRuntime from "../../../src/plugin-sdk/process-runtime.js";
|
||||
import * as setupRuntime from "../../../src/plugin-sdk/setup.js";
|
||||
import * as clientModule from "./client.js";
|
||||
import { probeIMessage } from "./probe.js";
|
||||
|
||||
beforeEach(() => {
|
||||
vi.restoreAllMocks();
|
||||
vi.spyOn(onboardHelpers, "detectBinary").mockResolvedValue(true);
|
||||
vi.spyOn(execModule, "runCommandWithTimeout").mockResolvedValue({
|
||||
vi.spyOn(setupRuntime, "detectBinary").mockResolvedValue(true);
|
||||
vi.spyOn(processRuntime, "runCommandWithTimeout").mockResolvedValue({
|
||||
stdout: "",
|
||||
stderr: 'unknown command "rpc" for "imsg"',
|
||||
code: 1,
|
||||
@@ -25,7 +25,7 @@ describe("probeIMessage", () => {
|
||||
request: vi.fn(),
|
||||
stop: vi.fn(),
|
||||
} as unknown as Awaited<ReturnType<typeof clientModule.createIMessageRpcClient>>);
|
||||
const result = await probeIMessage(1000, { cliPath: "imsg" });
|
||||
const result = await probeIMessage(1000, { cliPath: "imsg-test-rpc" });
|
||||
expect(result.ok).toBe(false);
|
||||
expect(result.fatal).toBe(true);
|
||||
expect(result.error).toMatch(/rpc/i);
|
||||
|
||||
@@ -10,9 +10,13 @@ import {
|
||||
|
||||
const spawnMock = vi.hoisted(() => vi.fn());
|
||||
|
||||
vi.mock("node:child_process", () => ({
|
||||
spawn: (...args: unknown[]) => spawnMock(...args),
|
||||
}));
|
||||
vi.mock("node:child_process", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("node:child_process")>();
|
||||
return {
|
||||
...actual,
|
||||
spawn: (...args: unknown[]) => spawnMock(...args),
|
||||
};
|
||||
});
|
||||
|
||||
describe("imessage targets", () => {
|
||||
it("parses chat_id targets", () => {
|
||||
|
||||
Reference in New Issue
Block a user