Skip to content

Commit a2d5431

Browse files
authored
fix(onboarding): remote retry hint omits required risk acknowledgment (#130174)
* fix(onboarding): include risk acknowledgment in remote retry hint * test(onboarding): keep remote retry coverage within lint budget
1 parent 424521a commit a2d5431

2 files changed

Lines changed: 59 additions & 59 deletions

File tree

‎src/commands/onboard.test.ts‎

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,7 @@ describe("setupWizardCommand", () => {
230230
runtime,
231231
);
232232

233-
expect(runtime.error).toHaveBeenCalledOnce();
234-
expect(runtime.error).toHaveBeenCalledWith(
233+
expect(runtime.error).toHaveBeenCalledExactlyOnceWith(
235234
`Invalid --secret-input-mode. Use "plaintext" or "ref", or run ${formatCliCommand("openclaw onboard")} for the interactive setup.`,
236235
);
237236
expect(runtime.exit).toHaveBeenCalledWith(1);
@@ -445,8 +444,7 @@ describe("setupWizardCommand", () => {
445444
runtime,
446445
);
447446

448-
expect(runtime.error).toHaveBeenCalledOnce();
449-
expect(runtime.error).toHaveBeenCalledWith(
447+
expect(runtime.error).toHaveBeenCalledExactlyOnceWith(
450448
`Invalid --reset-scope. Use "config", "config+creds+sessions", or "full". Run ${formatCliCommand("openclaw onboard --reset --reset-scope config")} for a config-only reset.`,
451449
);
452450
expect(runtime.exit).toHaveBeenCalledWith(1);
@@ -521,62 +519,64 @@ describe("setupWizardCommand", () => {
521519
});
522520

523521
it.each([
524-
{
525-
label: "unsupported flow",
526-
options: { flow: "bogus" as never },
527-
expectedError: "Invalid --flow",
528-
},
529-
{
530-
label: "malformed remote URL",
531-
options: { mode: "remote" as const, remoteUrl: "garbage" },
532-
expectedError: "URL must start with ws:// or wss://",
533-
},
534-
{
535-
label: "non-WebSocket remote URL",
536-
options: { mode: "remote" as const, remoteUrl: "https://example.invalid" },
537-
expectedError: "URL must start with ws:// or wss://",
538-
},
539-
{
540-
label: "remote URL in local mode",
541-
options: { mode: "local" as const, remoteUrl: "wss://gateway.example.invalid" },
542-
expectedError: "--remote-url requires --mode remote in non-interactive setup.",
543-
},
544-
{
545-
label: "remote token in default local mode",
546-
options: { remoteToken: "fixture-token" },
547-
expectedError: "--remote-token requires --mode remote in non-interactive setup.",
548-
},
549-
{
550-
label: "remote password in default local mode",
551-
options: { remotePassword: "fixture-password" },
552-
expectedError: "--remote-password requires --mode remote in non-interactive setup.",
553-
},
554-
{
555-
label: "unsupported daemon runtime while daemon install is skipped",
556-
options: { daemonRuntime: "bogus" as never, installDaemon: false },
557-
expectedError: "Invalid --daemon-runtime",
558-
},
559-
{
560-
label: "unsupported node manager",
561-
options: { nodeManager: "bogus" as never },
562-
expectedError: "Invalid --node-manager",
563-
},
564-
])(
565-
"rejects $label before non-interactive setup without reset",
566-
async ({ options, expectedError }) => {
567-
const runtime = makeRuntime();
522+
["unsupported flow", { flow: "bogus" as never }, "Invalid --flow"],
523+
...([false, true] as const).map(
524+
(json) =>
525+
[
526+
`remote mode without a URL${json ? " in JSON output" : ""}`,
527+
{ mode: "remote" as const, json },
528+
formatCliCommand(
529+
"openclaw onboard --non-interactive --accept-risk --mode remote --remote-url ws://127.0.0.1:3000",
530+
),
531+
] as const,
532+
),
533+
[
534+
"malformed remote URL",
535+
{ mode: "remote" as const, remoteUrl: "garbage" },
536+
"URL must start with ws:// or wss://",
537+
],
538+
[
539+
"non-WebSocket remote URL",
540+
{ mode: "remote" as const, remoteUrl: "https://example.invalid" },
541+
"URL must start with ws:// or wss://",
542+
],
543+
[
544+
"remote URL in local mode",
545+
{ mode: "local" as const, remoteUrl: "wss://gateway.example.invalid" },
546+
"--remote-url requires --mode remote in non-interactive setup.",
547+
],
548+
[
549+
"remote token in default local mode",
550+
{ remoteToken: "fixture-token" },
551+
"--remote-token requires --mode remote in non-interactive setup.",
552+
],
553+
[
554+
"remote password in default local mode",
555+
{ remotePassword: "fixture-password" },
556+
"--remote-password requires --mode remote in non-interactive setup.",
557+
],
558+
[
559+
"unsupported daemon runtime while daemon install is skipped",
560+
{ daemonRuntime: "bogus" as never, installDaemon: false },
561+
"Invalid --daemon-runtime",
562+
],
563+
["unsupported node manager", { nodeManager: "bogus" as never }, "Invalid --node-manager"],
564+
] as const)("rejects %s before non-interactive setup without reset", async (_, opts, error) => {
565+
const runtime = makeRuntime();
568566

569-
await setupWizardCommand({ nonInteractive: true, acceptRisk: true, ...options }, runtime);
567+
await setupWizardCommand({ nonInteractive: true, acceptRisk: true, ...opts }, runtime);
570568

571-
expect(runtime.error).toHaveBeenCalledWith(expect.stringContaining(expectedError));
572-
expect(runtime.exit).toHaveBeenCalledWith(1);
573-
expect(mocks.readConfigFileSnapshot).not.toHaveBeenCalled();
574-
expect(mocks.handleReset).not.toHaveBeenCalled();
575-
expect(mocks.runNonInteractiveSetup).not.toHaveBeenCalled();
576-
expect(mocks.runInteractiveSetup).not.toHaveBeenCalled();
577-
expect(mocks.runGuidedOnboarding).not.toHaveBeenCalled();
578-
},
579-
);
569+
expect(runtime.error).toHaveBeenCalledWith(expect.stringContaining(error));
570+
if ("json" in opts && opts.json) {
571+
expect(runtime.log).toHaveBeenCalledWith(expect.stringContaining(error));
572+
}
573+
expect(runtime.exit).toHaveBeenCalledWith(1);
574+
expect(mocks.readConfigFileSnapshot).not.toHaveBeenCalled();
575+
expect(mocks.handleReset).not.toHaveBeenCalled();
576+
expect(mocks.runNonInteractiveSetup).not.toHaveBeenCalled();
577+
expect(mocks.runInteractiveSetup).not.toHaveBeenCalled();
578+
expect(mocks.runGuidedOnboarding).not.toHaveBeenCalled();
579+
});
580580

581581
const tokenError =
582582
"--gateway-token configures local gateway auth. Use --remote-token in remote mode.";

‎src/commands/onboard.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ function validatePreflightOptions(opts: OnboardOptions, runtime: RuntimeEnv): bo
204204
return rejectOption(
205205
opts,
206206
runtime,
207-
`Missing --remote-url for remote mode. Example: ${formatCliCommand("openclaw onboard --non-interactive --mode remote --remote-url ws://127.0.0.1:3000")}.`,
207+
`Missing --remote-url for remote mode. Example: ${formatCliCommand("openclaw onboard --non-interactive --accept-risk --mode remote --remote-url ws://127.0.0.1:3000")}.`,
208208
);
209209
}
210210
if (opts.nonInteractive && opts.mode === "remote" && opts.remoteUrl?.trim()) {

0 commit comments

Comments
 (0)