test: speed up cli and command suites

This commit is contained in:
Peter Steinberger
2026-03-31 02:12:23 +01:00
parent 6b6ddcd2a6
commit 3f1d6fe147
83 changed files with 1161 additions and 1054 deletions

View File

@@ -1,6 +1,7 @@
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { DEFAULT_EXEC_APPROVAL_TIMEOUT_MS } from "../../infra/exec-approvals.js";
import { parseTimeoutMs } from "../parse-timeout.js";
import { callGatewayCli } from "./rpc.js";
/**
* Regression test for #12098:
@@ -18,9 +19,11 @@ import { parseTimeoutMs } from "../parse-timeout.js";
* least approvalTimeoutMs + 10_000.
*/
const callGatewaySpy = vi.fn<
(opts: Record<string, unknown>) => Promise<{ decision: "allow-once" }>
>(async () => ({ decision: "allow-once" }));
const { callGatewaySpy } = vi.hoisted(() => ({
callGatewaySpy: vi.fn<(opts: Record<string, unknown>) => Promise<{ decision: "allow-once" }>>(
async () => ({ decision: "allow-once" }),
),
}));
vi.mock("../../gateway/call.js", () => ({
callGateway: callGatewaySpy,
@@ -32,13 +35,8 @@ vi.mock("../progress.js", () => ({
}));
describe("exec approval transport timeout (#12098)", () => {
let callGatewayCli: typeof import("./rpc.js").callGatewayCli;
const approvalTransportFloorMs = DEFAULT_EXEC_APPROVAL_TIMEOUT_MS + 10_000;
beforeAll(async () => {
({ callGatewayCli } = await import("./rpc.js"));
});
beforeEach(() => {
callGatewaySpy.mockClear();
callGatewaySpy.mockResolvedValue({ decision: "allow-once" });