mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 11:58:38 +00:00
test(flaky): harden slow vmFork unit suites
Co-authored-by: Ho Lim <166576253+HOYALIM@users.noreply.github.com>
This commit is contained in:
@@ -1,9 +1,18 @@
|
|||||||
|
import { createRequire } from "node:module";
|
||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
import {
|
|
||||||
buildRelayWsUrl,
|
type BackgroundUtilsModule = {
|
||||||
isRetryableReconnectError,
|
buildRelayWsUrl: (port: number, gatewayToken: string) => string;
|
||||||
reconnectDelayMs,
|
isRetryableReconnectError: (err: unknown) => boolean;
|
||||||
} from "../../assets/chrome-extension/background-utils.js";
|
reconnectDelayMs: (
|
||||||
|
attempt: number,
|
||||||
|
opts?: { baseMs?: number; maxMs?: number; jitterMs?: number; random?: () => number },
|
||||||
|
) => number;
|
||||||
|
};
|
||||||
|
|
||||||
|
const require = createRequire(import.meta.url);
|
||||||
|
const { buildRelayWsUrl, isRetryableReconnectError, reconnectDelayMs } =
|
||||||
|
require("../../assets/chrome-extension/background-utils.js") as BackgroundUtilsModule;
|
||||||
|
|
||||||
describe("chrome extension background utils", () => {
|
describe("chrome extension background utils", () => {
|
||||||
it("builds websocket url with encoded gateway token", () => {
|
it("builds websocket url with encoded gateway token", () => {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import {
|
|||||||
} from "./doctor.e2e-harness.js";
|
} from "./doctor.e2e-harness.js";
|
||||||
import "./doctor.fast-path-mocks.js";
|
import "./doctor.fast-path-mocks.js";
|
||||||
|
|
||||||
const DOCTOR_MIGRATION_TIMEOUT_MS = 20_000;
|
const DOCTOR_MIGRATION_TIMEOUT_MS = process.platform === "win32" ? 60_000 : 45_000;
|
||||||
const { doctorCommand } = await import("./doctor.js");
|
const { doctorCommand } = await import("./doctor.js");
|
||||||
|
|
||||||
describe("doctor command", () => {
|
describe("doctor command", () => {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { describe, expect, it, vi } from "vitest";
|
import { describe, expect, it, vi } from "vitest";
|
||||||
import { readConfigFileSnapshot, writeConfigFile } from "./doctor.e2e-harness.js";
|
import { readConfigFileSnapshot, writeConfigFile } from "./doctor.e2e-harness.js";
|
||||||
|
|
||||||
const DOCTOR_MIGRATION_TIMEOUT_MS = 20_000;
|
const DOCTOR_MIGRATION_TIMEOUT_MS = process.platform === "win32" ? 60_000 : 45_000;
|
||||||
const { doctorCommand } = await import("./doctor.js");
|
const { doctorCommand } = await import("./doctor.js");
|
||||||
|
|
||||||
describe("doctor command", () => {
|
describe("doctor command", () => {
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import { describe, expect, it, vi } from "vitest";
|
import { describe, expect, it, vi } from "vitest";
|
||||||
|
|
||||||
|
const SANDBOX_EXPLAIN_TEST_TIMEOUT_MS = process.platform === "win32" ? 45_000 : 30_000;
|
||||||
|
|
||||||
let mockCfg: unknown = {};
|
let mockCfg: unknown = {};
|
||||||
|
|
||||||
vi.mock("../config/config.js", async (importOriginal) => {
|
vi.mock("../config/config.js", async (importOriginal) => {
|
||||||
@@ -13,7 +15,7 @@ vi.mock("../config/config.js", async (importOriginal) => {
|
|||||||
const { sandboxExplainCommand } = await import("./sandbox-explain.js");
|
const { sandboxExplainCommand } = await import("./sandbox-explain.js");
|
||||||
|
|
||||||
describe("sandbox explain command", () => {
|
describe("sandbox explain command", () => {
|
||||||
it("prints JSON shape + fix-it keys", async () => {
|
it("prints JSON shape + fix-it keys", { timeout: SANDBOX_EXPLAIN_TEST_TIMEOUT_MS }, async () => {
|
||||||
mockCfg = {
|
mockCfg = {
|
||||||
agents: {
|
agents: {
|
||||||
defaults: {
|
defaults: {
|
||||||
@@ -42,5 +44,5 @@ describe("sandbox explain command", () => {
|
|||||||
expect(Array.isArray(parsed.fixIt)).toBe(true);
|
expect(Array.isArray(parsed.fixIt)).toBe(true);
|
||||||
expect(parsed.fixIt).toContain("agents.defaults.sandbox.mode=off");
|
expect(parsed.fixIt).toContain("agents.defaults.sandbox.mode=off");
|
||||||
expect(parsed.fixIt).toContain("tools.sandbox.tools.deny");
|
expect(parsed.fixIt).toContain("tools.sandbox.tools.deny");
|
||||||
}, 15_000);
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ const TELEGRAM_TEST_TIMINGS = {
|
|||||||
mediaGroupFlushMs: 20,
|
mediaGroupFlushMs: 20,
|
||||||
textFragmentGapMs: 30,
|
textFragmentGapMs: 30,
|
||||||
} as const;
|
} as const;
|
||||||
|
const TELEGRAM_BOT_IMPORT_TIMEOUT_MS = process.platform === "win32" ? 180_000 : 150_000;
|
||||||
let createTelegramBot: typeof import("./bot.js").createTelegramBot;
|
let createTelegramBot: typeof import("./bot.js").createTelegramBot;
|
||||||
let replySpy: ReturnType<typeof vi.fn>;
|
let replySpy: ReturnType<typeof vi.fn>;
|
||||||
|
|
||||||
@@ -98,7 +99,7 @@ beforeAll(async () => {
|
|||||||
({ createTelegramBot } = await import("./bot.js"));
|
({ createTelegramBot } = await import("./bot.js"));
|
||||||
const replyModule = await import("../auto-reply/reply.js");
|
const replyModule = await import("../auto-reply/reply.js");
|
||||||
replySpy = (replyModule as unknown as { __replySpy: ReturnType<typeof vi.fn> }).__replySpy;
|
replySpy = (replyModule as unknown as { __replySpy: ReturnType<typeof vi.fn> }).__replySpy;
|
||||||
});
|
}, TELEGRAM_BOT_IMPORT_TIMEOUT_MS);
|
||||||
|
|
||||||
vi.mock("./sticker-cache.js", () => ({
|
vi.mock("./sticker-cache.js", () => ({
|
||||||
cacheSticker: (...args: unknown[]) => cacheStickerSpy(...args),
|
cacheSticker: (...args: unknown[]) => cacheStickerSpy(...args),
|
||||||
|
|||||||
Reference in New Issue
Block a user