























@@ -63,6 +63,16 @@ describe("registerOnboardCommand", () => {
6363await program.parseAsync(args, { from: "user" });
6464}
656566+function setupWizardOptions(callIndex = 0): Record<string, unknown> {
67+const call = setupWizardCommandMock.mock.calls[callIndex];
68+expect(call).toBeDefined();
69+if (!call) {
70+throw new Error(`expected setup wizard call ${callIndex}`);
71+}
72+expect(call[1]).toBe(runtime);
73+return call[0] as Record<string, unknown>;
74+}
75+6676beforeEach(() => {
6777vi.clearAllMocks();
6878mocks.runCrestodian.mockResolvedValue(undefined);
@@ -72,113 +82,54 @@ describe("registerOnboardCommand", () => {
7282it("defaults installDaemon to undefined when no daemon flags are provided", async () => {
7383await runCli(["onboard"]);
748475-expect(setupWizardCommandMock).toHaveBeenCalledWith(
76-expect.objectContaining({
77-installDaemon: undefined,
78-}),
79-runtime,
80-);
85+expect(setupWizardOptions().installDaemon).toBeUndefined();
8186expect(mocks.runCrestodian).not.toHaveBeenCalled();
8287});
83888489it("sets installDaemon from explicit install flags and prioritizes --skip-daemon", async () => {
8590await runCli(["onboard", "--install-daemon"]);
86-expect(setupWizardCommandMock).toHaveBeenNthCalledWith(
87-1,
88-expect.objectContaining({
89-installDaemon: true,
90-}),
91-runtime,
92-);
91+expect(setupWizardOptions(0).installDaemon).toBe(true);
93929493await runCli(["onboard", "--no-install-daemon"]);
95-expect(setupWizardCommandMock).toHaveBeenNthCalledWith(
96-2,
97-expect.objectContaining({
98-installDaemon: false,
99-}),
100-runtime,
101-);
94+expect(setupWizardOptions(1).installDaemon).toBe(false);
1029510396await runCli(["onboard", "--install-daemon", "--skip-daemon"]);
104-expect(setupWizardCommandMock).toHaveBeenNthCalledWith(
105-3,
106-expect.objectContaining({
107-installDaemon: false,
108-}),
109-runtime,
110-);
97+expect(setupWizardOptions(2).installDaemon).toBe(false);
11198});
11299113100it("parses numeric gateway port and drops invalid values", async () => {
114101await runCli(["onboard", "--gateway-port", "18789"]);
115-expect(setupWizardCommandMock).toHaveBeenNthCalledWith(
116-1,
117-expect.objectContaining({
118-gatewayPort: 18789,
119-}),
120-runtime,
121-);
102+expect(setupWizardOptions(0).gatewayPort).toBe(18789);
122103123104await runCli(["onboard", "--gateway-port", "nope"]);
124-expect(setupWizardCommandMock).toHaveBeenNthCalledWith(
125-2,
126-expect.objectContaining({
127-gatewayPort: undefined,
128-}),
129-runtime,
130-);
105+expect(setupWizardOptions(1).gatewayPort).toBeUndefined();
131106});
132107133108it("forwards --reset-scope to setup wizard options", async () => {
134109await runCli(["onboard", "--reset", "--reset-scope", "full"]);
135-expect(setupWizardCommandMock).toHaveBeenCalledWith(
136-expect.objectContaining({
137-reset: true,
138-resetScope: "full",
139-}),
140-runtime,
141-);
110+const options = setupWizardOptions();
111+expect(options.reset).toBe(true);
112+expect(options.resetScope).toBe("full");
142113});
143114144115it("forwards --skip-bootstrap to setup wizard options", async () => {
145116await runCli(["onboard", "--skip-bootstrap"]);
146-expect(setupWizardCommandMock).toHaveBeenCalledWith(
147-expect.objectContaining({
148-skipBootstrap: true,
149-}),
150-runtime,
151-);
117+expect(setupWizardOptions().skipBootstrap).toBe(true);
152118});
153119154120it("parses --mistral-api-key and forwards mistralApiKey", async () => {
155121await runCli(["onboard", "--mistral-api-key", "sk-mistral-test"]);
156-expect(setupWizardCommandMock).toHaveBeenCalledWith(
157-expect.objectContaining({
158-mistralApiKey: "sk-mistral-test", // pragma: allowlist secret
159-}),
160-runtime,
161-);
122+expect(setupWizardOptions().mistralApiKey).toBe("sk-mistral-test"); // pragma: allowlist secret
162123});
163124164125it("dedupes provider auth flags before registering command options", async () => {
165126await runCli(["onboard", "--openai-api-key", "sk-openai-test"]);
166-expect(setupWizardCommandMock).toHaveBeenCalledWith(
167-expect.objectContaining({
168-openaiApiKey: "sk-openai-test", // pragma: allowlist secret
169-}),
170-runtime,
171-);
127+expect(setupWizardOptions().openaiApiKey).toBe("sk-openai-test"); // pragma: allowlist secret
172128});
173129174130it("forwards --gateway-token-ref-env", async () => {
175131await runCli(["onboard", "--gateway-token-ref-env", "OPENCLAW_GATEWAY_TOKEN"]);
176-expect(setupWizardCommandMock).toHaveBeenCalledWith(
177-expect.objectContaining({
178-gatewayTokenRefEnv: "OPENCLAW_GATEWAY_TOKEN",
179-}),
180-runtime,
181-);
132+expect(setupWizardOptions().gatewayTokenRefEnv).toBe("OPENCLAW_GATEWAY_TOKEN");
182133});
183134184135it("forwards onboarding migration flags", async () => {
@@ -192,15 +143,11 @@ describe("registerOnboardCommand", () => {
192143"/tmp/hermes",
193144"--import-secrets",
194145]);
195-expect(setupWizardCommandMock).toHaveBeenCalledWith(
196-expect.objectContaining({
197-flow: "import",
198-importFrom: "hermes",
199-importSource: "/tmp/hermes",
200-importSecrets: true,
201-}),
202-runtime,
203-);
146+const options = setupWizardOptions();
147+expect(options.flow).toBe("import");
148+expect(options.importFrom).toBe("hermes");
149+expect(options.importSource).toBe("/tmp/hermes");
150+expect(options.importSecrets).toBe(true);
204151});
205152206153it("reports errors via runtime on setup wizard command failures", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。