test: dedupe and optimize test suites

This commit is contained in:
Peter Steinberger
2026-02-19 15:18:50 +00:00
parent b0e55283d5
commit a1cb700a05
80 changed files with 2627 additions and 2962 deletions

View File

@@ -1,5 +1,6 @@
import { Command } from "commander";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { runRegisteredCli } from "../test-utils/command-runner.js";
const updateCommand = vi.fn(async (_opts: unknown) => {});
const updateStatusCommand = vi.fn(async (_opts: unknown) => {});
@@ -28,6 +29,12 @@ vi.mock("../runtime.js", () => ({
}));
describe("update cli option collisions", () => {
let registerUpdateCli: typeof import("./update-cli.js").registerUpdateCli;
beforeAll(async () => {
({ registerUpdateCli } = await import("./update-cli.js"));
});
beforeEach(() => {
updateCommand.mockClear();
updateStatusCommand.mockClear();
@@ -38,11 +45,10 @@ describe("update cli option collisions", () => {
});
it("forwards parent-captured --json/--timeout to `update status`", async () => {
const { registerUpdateCli } = await import("./update-cli.js");
const program = new Command();
registerUpdateCli(program);
await program.parseAsync(["update", "status", "--json", "--timeout", "9"], { from: "user" });
await runRegisteredCli({
register: registerUpdateCli as (program: Command) => void,
argv: ["update", "status", "--json", "--timeout", "9"],
});
expect(updateStatusCommand).toHaveBeenCalledWith(
expect.objectContaining({
@@ -53,11 +59,10 @@ describe("update cli option collisions", () => {
});
it("forwards parent-captured --timeout to `update wizard`", async () => {
const { registerUpdateCli } = await import("./update-cli.js");
const program = new Command();
registerUpdateCli(program);
await program.parseAsync(["update", "wizard", "--timeout", "13"], { from: "user" });
await runRegisteredCli({
register: registerUpdateCli as (program: Command) => void,
argv: ["update", "wizard", "--timeout", "13"],
});
expect(updateWizardCommand).toHaveBeenCalledWith(
expect.objectContaining({