test: fix current ci regressions

This commit is contained in:
Peter Steinberger 2026-03-14 01:28:58 +00:00
parent 2bfe188510
commit 8de2f7339c
3 changed files with 32 additions and 12 deletions

View File

@ -1,10 +1,6 @@
import type { ClawdbotConfig } from "openclaw/plugin-sdk/feishu";
import { afterEach, describe, expect, it, vi } from "vitest";
import { monitorFeishuProvider, stopFeishuMonitor } from "./monitor.js";
import {
createFeishuClientMockModule,
createFeishuRuntimeMockModule,
} from "./monitor.test-mocks.js";
const probeFeishuMock = vi.hoisted(() => vi.fn());
@ -12,8 +8,26 @@ vi.mock("./probe.js", () => ({
probeFeishu: probeFeishuMock,
}));
vi.mock("./client.js", () => createFeishuClientMockModule());
vi.mock("./runtime.js", () => createFeishuRuntimeMockModule());
vi.mock("./client.js", () => ({
createFeishuWSClient: vi.fn(() => ({ start: vi.fn() })),
createEventDispatcher: vi.fn(() => ({ register: vi.fn() })),
}));
vi.mock("./runtime.js", () => ({
getFeishuRuntime: () => ({
channel: {
debounce: {
resolveInboundDebounceMs: () => 0,
createInboundDebouncer: () => ({
enqueue: async () => {},
flushKey: async () => {},
}),
},
text: {
hasControlCommand: () => false,
},
},
}),
}));
function buildMultiAccountWebsocketConfig(accountIds: string[]): ClawdbotConfig {
return {

View File

@ -51,7 +51,12 @@ vi.mock("undici", () => ({
fetch: undiciFetch,
}));
import { getProxyUrlFromFetch, makeProxyFetch, resolveProxyFetchFromEnv } from "./proxy-fetch.js";
import {
getProxyUrlFromFetch,
makeProxyFetch,
PROXY_FETCH_PROXY_URL,
resolveProxyFetchFromEnv,
} from "./proxy-fetch.js";
function clearProxyEnv(): void {
for (const key of PROXY_ENV_KEYS) {
@ -112,9 +117,9 @@ describe("getProxyUrlFromFetch", () => {
it("returns undefined for plain fetch functions or blank metadata", () => {
const plainFetch = vi.fn() as unknown as typeof fetch;
const blankMetadataFetch = vi.fn() as unknown as typeof fetch & {
[Symbol.for("openclaw.proxyFetch.proxyUrl")]?: string;
[PROXY_FETCH_PROXY_URL]?: string;
};
blankMetadataFetch[Symbol.for("openclaw.proxyFetch.proxyUrl")] = " ";
blankMetadataFetch[PROXY_FETCH_PROXY_URL] = " ";
expect(getProxyUrlFromFetch(plainFetch)).toBeUndefined();
expect(getProxyUrlFromFetch(blankMetadataFetch)).toBeUndefined();

View File

@ -1,3 +1,4 @@
import path from "node:path";
import { describe, expect, it, vi } from "vitest";
import {
pruneExpiredPending,
@ -8,9 +9,9 @@ import {
describe("pairing file helpers", () => {
it("resolves pairing file paths from explicit base dirs", () => {
expect(resolvePairingPaths("/tmp/openclaw-state", "devices")).toEqual({
dir: "/tmp/openclaw-state/devices",
pendingPath: "/tmp/openclaw-state/devices/pending.json",
pairedPath: "/tmp/openclaw-state/devices/paired.json",
dir: path.join("/tmp/openclaw-state", "devices"),
pendingPath: path.join("/tmp/openclaw-state", "devices", "pending.json"),
pairedPath: path.join("/tmp/openclaw-state", "devices", "paired.json"),
});
});