test(flaky): harden slow vmFork unit suites

Co-authored-by: Ho Lim <166576253+HOYALIM@users.noreply.github.com>
This commit is contained in:
Peter Steinberger
2026-02-22 19:00:54 +01:00
parent 9ea5228f42
commit 2858901441
5 changed files with 22 additions and 10 deletions

View File

@@ -1,9 +1,18 @@
import { createRequire } from "node:module";
import { describe, expect, it } from "vitest";
import {
buildRelayWsUrl,
isRetryableReconnectError,
reconnectDelayMs,
} from "../../assets/chrome-extension/background-utils.js";
type BackgroundUtilsModule = {
buildRelayWsUrl: (port: number, gatewayToken: string) => string;
isRetryableReconnectError: (err: unknown) => boolean;
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", () => {
it("builds websocket url with encoded gateway token", () => {

View File

@@ -16,7 +16,7 @@ import {
} from "./doctor.e2e-harness.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");
describe("doctor command", () => {

View File

@@ -1,7 +1,7 @@
import { describe, expect, it, vi } from "vitest";
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");
describe("doctor command", () => {

View File

@@ -1,5 +1,7 @@
import { describe, expect, it, vi } from "vitest";
const SANDBOX_EXPLAIN_TEST_TIMEOUT_MS = process.platform === "win32" ? 45_000 : 30_000;
let mockCfg: unknown = {};
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");
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 = {
agents: {
defaults: {
@@ -42,5 +44,5 @@ describe("sandbox explain command", () => {
expect(Array.isArray(parsed.fixIt)).toBe(true);
expect(parsed.fixIt).toContain("agents.defaults.sandbox.mode=off");
expect(parsed.fixIt).toContain("tools.sandbox.tools.deny");
}, 15_000);
});
});

View File

@@ -12,6 +12,7 @@ const TELEGRAM_TEST_TIMINGS = {
mediaGroupFlushMs: 20,
textFragmentGapMs: 30,
} as const;
const TELEGRAM_BOT_IMPORT_TIMEOUT_MS = process.platform === "win32" ? 180_000 : 150_000;
let createTelegramBot: typeof import("./bot.js").createTelegramBot;
let replySpy: ReturnType<typeof vi.fn>;
@@ -98,7 +99,7 @@ beforeAll(async () => {
({ createTelegramBot } = await import("./bot.js"));
const replyModule = await import("../auto-reply/reply.js");
replySpy = (replyModule as unknown as { __replySpy: ReturnType<typeof vi.fn> }).__replySpy;
});
}, TELEGRAM_BOT_IMPORT_TIMEOUT_MS);
vi.mock("./sticker-cache.js", () => ({
cacheSticker: (...args: unknown[]) => cacheStickerSpy(...args),