@@ -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,79 +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 : "remote mode without a URL" ,
531- options : { mode : "remote" as const } ,
532- expectedError : formatCliCommand (
533- "openclaw onboard --non-interactive --accept-risk --mode remote --remote-url ws://127.0.0.1:3000" ,
534- ) ,
535- } ,
536- {
537- label : "remote mode without a URL in JSON output" ,
538- options : { mode : "remote" as const , json : true } ,
539- expectedError : formatCliCommand (
540- "openclaw onboard --non-interactive --accept-risk --mode remote --remote-url ws://127.0.0.1:3000" ,
541- ) ,
542- } ,
543- {
544- label : "malformed remote URL" ,
545- options : { mode : "remote" as const , remoteUrl : "garbage" } ,
546- expectedError : "URL must start with ws:// or wss://" ,
547- } ,
548- {
549- label : "non-WebSocket remote URL" ,
550- options : { mode : "remote" as const , remoteUrl : "https://example.invalid" } ,
551- expectedError : "URL must start with ws:// or wss://" ,
552- } ,
553- {
554- label : "remote URL in local mode" ,
555- options : { mode : "local" as const , remoteUrl : "wss://gateway.example.invalid" } ,
556- expectedError : "--remote-url requires --mode remote in non-interactive setup." ,
557- } ,
558- {
559- label : "remote token in default local mode" ,
560- options : { remoteToken : "fixture-token" } ,
561- expectedError : "--remote-token requires --mode remote in non-interactive setup." ,
562- } ,
563- {
564- label : "remote password in default local mode" ,
565- options : { remotePassword : "fixture-password" } ,
566- expectedError : "--remote-password requires --mode remote in non-interactive setup." ,
567- } ,
568- {
569- label : "unsupported daemon runtime while daemon install is skipped" ,
570- options : { daemonRuntime : "bogus" as never , installDaemon : false } ,
571- expectedError : "Invalid --daemon-runtime" ,
572- } ,
573- {
574- label : "unsupported node manager" ,
575- options : { nodeManager : "bogus" as never } ,
576- expectedError : "Invalid --node-manager" ,
577- } ,
578- ] ) (
579- "rejects $label before non-interactive setup without reset" ,
580- async ( { options, expectedError } ) => {
581- 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 ( ) ;
582566
583- await setupWizardCommand ( { nonInteractive : true , acceptRisk : true , ...options } , runtime ) ;
567+ await setupWizardCommand ( { nonInteractive : true , acceptRisk : true , ...opts } , runtime ) ;
584568
585- expect ( runtime . error ) . toHaveBeenCalledWith ( expect . stringContaining ( expectedError ) ) ;
586- if ( "json" in options && options . json ) {
587- expect ( runtime . log ) . toHaveBeenCalledWith ( expect . stringContaining ( expectedError ) ) ;
588- }
589- expect ( runtime . exit ) . toHaveBeenCalledWith ( 1 ) ;
590- expect ( mocks . readConfigFileSnapshot ) . not . toHaveBeenCalled ( ) ;
591- expect ( mocks . handleReset ) . not . toHaveBeenCalled ( ) ;
592- expect ( mocks . runNonInteractiveSetup ) . not . toHaveBeenCalled ( ) ;
593- expect ( mocks . runInteractiveSetup ) . not . toHaveBeenCalled ( ) ;
594- expect ( mocks . runGuidedOnboarding ) . not . toHaveBeenCalled ( ) ;
595- } ,
596- ) ;
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+ } ) ;
597580
598581 const tokenError =
599582 "--gateway-token configures local gateway auth. Use --remote-token in remote mode." ;
0 commit comments