test: group remaining suite cleanups

This commit is contained in:
Peter Steinberger
2026-02-21 21:43:24 +00:00
parent 5c8f0b5a77
commit 861718e4dc
32 changed files with 870 additions and 922 deletions

View File

@@ -1,5 +1,5 @@
import { Command } from "commander";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import type { ConfigFileSnapshot, OpenClawConfig } from "../config/types.js";
/**
@@ -53,8 +53,9 @@ function setSnapshot(resolved: OpenClawConfig, config: OpenClawConfig) {
mockReadConfigFileSnapshot.mockResolvedValueOnce(buildSnapshot({ resolved, config }));
}
let registerConfigCli: typeof import("./config-cli.js").registerConfigCli;
async function runConfigCommand(args: string[]) {
const { registerConfigCli } = await import("./config-cli.js");
const program = new Command();
program.exitOverride();
registerConfigCli(program);
@@ -62,6 +63,10 @@ async function runConfigCommand(args: string[]) {
}
describe("config cli", () => {
beforeAll(async () => {
({ registerConfigCli } = await import("./config-cli.js"));
});
beforeEach(() => {
vi.clearAllMocks();
});
@@ -166,7 +171,6 @@ describe("config cli", () => {
});
it("shows --strict-json and keeps --json as a legacy alias in help", async () => {
const { registerConfigCli } = await import("./config-cli.js");
const program = new Command();
registerConfigCli(program);