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,4 +1,5 @@
import { describe, expect, it, vi } from "vitest";
import { probeGatewayStatus } from "./probe.js";
const callGatewayMock = vi.hoisted(() => vi.fn());
const probeGatewayMock = vi.hoisted(() => vi.fn());
@@ -15,8 +16,6 @@ vi.mock("../progress.js", () => ({
withProgress: async (_opts: unknown, fn: () => Promise<unknown>) => await fn(),
}));
const { probeGatewayStatus } = await import("./probe.js");
describe("probeGatewayStatus", () => {
it("uses lightweight token-only probing for daemon status", async () => {
callGatewayMock.mockReset();

View File

@@ -2,6 +2,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { createMockGatewayService } from "../../daemon/service.test-helpers.js";
import { captureEnv } from "../../test-utils/env.js";
import type { GatewayRestartSnapshot } from "./restart-health.js";
import { gatherDaemonStatus } from "./status.gather.js";
const callGatewayStatusProbe = vi.fn<
(opts?: unknown) => Promise<{ ok: boolean; url?: string; error?: string | null }>
@@ -136,8 +137,6 @@ vi.mock("./restart-health.js", () => ({
inspectGatewayRestart: (opts: unknown) => inspectGatewayRestart(opts),
}));
const { gatherDaemonStatus } = await import("./status.gather.js");
describe("gatherDaemonStatus", () => {
let envSnapshot: ReturnType<typeof captureEnv>;

View File

@@ -1,5 +1,6 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import { formatCliCommand } from "../command-format.js";
import { printDaemonStatus } from "./status.print.js";
const runtime = vi.hoisted(() => ({
log: vi.fn<(line: string) => void>(),
@@ -69,8 +70,6 @@ vi.mock("./status.gather.js", () => ({
resolvePortListeningAddresses: () => ["127.0.0.1:18789"],
}));
const { printDaemonStatus } = await import("./status.print.js");
describe("printDaemonStatus", () => {
beforeEach(() => {
runtime.log.mockReset();