Files
openclaw-zero-token/cli/program.smoke.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

73 lines
2.1 KiB
TypeScript

import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import {
configureCommand,
ensureConfigReady,
installBaseProgramMocks,
installSmokeProgramMocks,
runTui,
runtime,
setupCommand,
setupWizardCommand,
} from "./program.test-mocks.js";
installBaseProgramMocks();
installSmokeProgramMocks();
vi.mock("./config-cli.js", () => ({
registerConfigCli: (program: {
command: (name: string) => { action: (fn: () => unknown) => void };
}) => {
program.command("config").action(() => configureCommand({}, runtime));
},
runConfigGet: vi.fn(),
runConfigUnset: vi.fn(),
}));
const { buildProgram } = await import("./program.js");
describe("cli program (smoke)", () => {
let program = createProgram();
function createProgram() {
return buildProgram();
}
async function runProgram(argv: string[]) {
await program.parseAsync(argv, { from: "user" });
}
beforeAll(() => {
program = createProgram();
});
beforeEach(() => {
vi.clearAllMocks();
runTui.mockResolvedValue(undefined);
ensureConfigReady.mockResolvedValue(undefined);
});
it("registers message + status commands", () => {
const names = program.commands.map((command) => command.name());
expect(names).toContain("message");
expect(names).toContain("status");
});
it("runs tui with explicit timeout override", async () => {
await runProgram(["tui", "--timeout-ms", "45000"]);
expect(runTui).toHaveBeenCalledWith(expect.objectContaining({ timeoutMs: 45000 }));
});
it("warns and ignores invalid tui timeout override", async () => {
await runProgram(["tui", "--timeout-ms", "nope"]);
expect(runtime.error).toHaveBeenCalledWith('warning: invalid --timeout-ms "nope"; ignoring');
expect(runTui).toHaveBeenCalledWith(expect.objectContaining({ timeoutMs: undefined }));
});
it("runs setup wizard when wizard flags are present", async () => {
await runProgram(["setup", "--remote-url", "ws://example"]);
expect(setupCommand).not.toHaveBeenCalled();
expect(setupWizardCommand).toHaveBeenCalledTimes(1);
});
});