Files
openclaw-zero-token/cli/update-cli.option-collisions.test.ts
sjhu 571e14a236 feat: upgrade to upstream v2026.3.28
Major upgrade from e26988a38 to upstream v2026.3.28 (f9b107928).
Key changes:
- Upstream src/, ui/, extensions/ (89 bundled extensions)
- Zero-token web providers preserved in src/zero-token/
- AskOnce plugin restored and registered as CLI command
- Added missing packages: @anthropic-ai/vertex-sdk, @modelcontextprotocol/sdk
- Fixed tsconfig rootDir, skipLibCheck for plugin-sdk DTS build
- Added askonce to bundled plugin metadata and package.json exports
- Fixed AskOnce CLI command registration (missing commands metadata)
- Restored AskOnce adapter imports (correct 5-level relative paths)
- Removed stale migration artifacts from root directory
2026-03-30 17:58:12 +08:00

80 lines
2.3 KiB
TypeScript

import { Command } from "commander";
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { runRegisteredCli } from "../test-utils/command-runner.js";
import { createCliRuntimeCapture } from "./test-runtime-capture.js";
const updateCommand = vi.fn(async (_opts: unknown) => {});
const updateStatusCommand = vi.fn(async (_opts: unknown) => {});
const updateWizardCommand = vi.fn(async (_opts: unknown) => {});
const { defaultRuntime, resetRuntimeCapture } = createCliRuntimeCapture();
vi.mock("./update-cli/update-command.js", () => ({
updateCommand: (opts: unknown) => updateCommand(opts),
}));
vi.mock("./update-cli/status.js", () => ({
updateStatusCommand: (opts: unknown) => updateStatusCommand(opts),
}));
vi.mock("./update-cli/wizard.js", () => ({
updateWizardCommand: (opts: unknown) => updateWizardCommand(opts),
}));
vi.mock("../runtime.js", () => ({
defaultRuntime,
}));
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();
updateWizardCommand.mockClear();
resetRuntimeCapture();
defaultRuntime.log.mockClear();
defaultRuntime.error.mockClear();
defaultRuntime.writeStdout.mockClear();
defaultRuntime.writeJson.mockClear();
defaultRuntime.exit.mockClear();
});
it.each([
{
name: "forwards parent-captured --json/--timeout to `update status`",
argv: ["update", "status", "--json", "--timeout", "9"],
assert: () => {
expect(updateStatusCommand).toHaveBeenCalledWith(
expect.objectContaining({
json: true,
timeout: "9",
}),
);
},
},
{
name: "forwards parent-captured --timeout to `update wizard`",
argv: ["update", "wizard", "--timeout", "13"],
assert: () => {
expect(updateWizardCommand).toHaveBeenCalledWith(
expect.objectContaining({
timeout: "13",
}),
);
},
},
])("$name", async ({ argv, assert }) => {
await runRegisteredCli({
register: registerUpdateCli as (program: Command) => void,
argv,
});
assert();
});
});