mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-30 02:40:18 +00:00
test: fix current ci regressions
This commit is contained in:
@@ -1,10 +1,6 @@
|
|||||||
import type { ClawdbotConfig } from "openclaw/plugin-sdk/feishu";
|
import type { ClawdbotConfig } from "openclaw/plugin-sdk/feishu";
|
||||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||||
import { monitorFeishuProvider, stopFeishuMonitor } from "./monitor.js";
|
import { monitorFeishuProvider, stopFeishuMonitor } from "./monitor.js";
|
||||||
import {
|
|
||||||
createFeishuClientMockModule,
|
|
||||||
createFeishuRuntimeMockModule,
|
|
||||||
} from "./monitor.test-mocks.js";
|
|
||||||
|
|
||||||
const probeFeishuMock = vi.hoisted(() => vi.fn());
|
const probeFeishuMock = vi.hoisted(() => vi.fn());
|
||||||
|
|
||||||
@@ -12,8 +8,26 @@ vi.mock("./probe.js", () => ({
|
|||||||
probeFeishu: probeFeishuMock,
|
probeFeishu: probeFeishuMock,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
vi.mock("./client.js", () => createFeishuClientMockModule());
|
vi.mock("./client.js", () => ({
|
||||||
vi.mock("./runtime.js", () => createFeishuRuntimeMockModule());
|
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 {
|
function buildMultiAccountWebsocketConfig(accountIds: string[]): ClawdbotConfig {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -51,7 +51,12 @@ vi.mock("undici", () => ({
|
|||||||
fetch: undiciFetch,
|
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 {
|
function clearProxyEnv(): void {
|
||||||
for (const key of PROXY_ENV_KEYS) {
|
for (const key of PROXY_ENV_KEYS) {
|
||||||
@@ -112,9 +117,9 @@ describe("getProxyUrlFromFetch", () => {
|
|||||||
it("returns undefined for plain fetch functions or blank metadata", () => {
|
it("returns undefined for plain fetch functions or blank metadata", () => {
|
||||||
const plainFetch = vi.fn() as unknown as typeof fetch;
|
const plainFetch = vi.fn() as unknown as typeof fetch;
|
||||||
const blankMetadataFetch = 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(plainFetch)).toBeUndefined();
|
||||||
expect(getProxyUrlFromFetch(blankMetadataFetch)).toBeUndefined();
|
expect(getProxyUrlFromFetch(blankMetadataFetch)).toBeUndefined();
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import path from "node:path";
|
||||||
import { describe, expect, it, vi } from "vitest";
|
import { describe, expect, it, vi } from "vitest";
|
||||||
import {
|
import {
|
||||||
pruneExpiredPending,
|
pruneExpiredPending,
|
||||||
@@ -8,9 +9,9 @@ import {
|
|||||||
describe("pairing file helpers", () => {
|
describe("pairing file helpers", () => {
|
||||||
it("resolves pairing file paths from explicit base dirs", () => {
|
it("resolves pairing file paths from explicit base dirs", () => {
|
||||||
expect(resolvePairingPaths("/tmp/openclaw-state", "devices")).toEqual({
|
expect(resolvePairingPaths("/tmp/openclaw-state", "devices")).toEqual({
|
||||||
dir: "/tmp/openclaw-state/devices",
|
dir: path.join("/tmp/openclaw-state", "devices"),
|
||||||
pendingPath: "/tmp/openclaw-state/devices/pending.json",
|
pendingPath: path.join("/tmp/openclaw-state", "devices", "pending.json"),
|
||||||
pairedPath: "/tmp/openclaw-state/devices/paired.json",
|
pairedPath: path.join("/tmp/openclaw-state", "devices", "paired.json"),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user