@@ -342,7 +342,40 @@ layer("AzureDevOpsPullRequestCli.layer", (it) => {
342342 } ) ,
343343 ) ;
344344
345+ it . effect ( "stores the squash choice with an auto-completion, as a merge now does" , ( ) =>
346+ Effect . gen ( function * ( ) {
347+ mockedExecute . mockReturnValue ( Effect . succeed ( output ( "{}" ) ) ) ;
348+ const cli = yield * AzureDevOpsPullRequestCli . AzureDevOpsPullRequestCli ;
349+
350+ yield * cli . runPullRequestAction ( {
351+ cwd : "/w" ,
352+ number : 42 ,
353+ action : "enable-auto-merge" ,
354+ mergeMethod : "squash" ,
355+ } ) ;
356+
357+ expect ( argsOfCall ( 0 ) ) . toEqual ( [
358+ "repos" ,
359+ "pr" ,
360+ "update" ,
361+ "--detect" ,
362+ "true" ,
363+ "--id" ,
364+ "42" ,
365+ "--auto-complete" ,
366+ "true" ,
367+ "--squash" ,
368+ "true" ,
369+ "--only-show-errors" ,
370+ "--output" ,
371+ "json" ,
372+ ] ) ;
373+ } ) ,
374+ ) ;
375+
345376 it . effect . each ( [
377+ { action : "enable-auto-merge" , expected : [ "--auto-complete" , "true" , "--squash" , "false" ] } ,
378+ { action : "disable-auto-merge" , expected : [ "--auto-complete" , "false" ] } ,
346379 { action : "draft" , expected : [ "--draft" , "true" ] } ,
347380 { action : "ready" , expected : [ "--draft" , "false" ] } ,
348381 { action : "close" , expected : [ "--status" , "abandoned" ] } ,
@@ -370,6 +403,79 @@ layer("AzureDevOpsPullRequestCli.layer", (it) => {
370403 } ) ,
371404 ) ;
372405
406+ it . effect . each ( [
407+ { name : "a title" , rewrite : { title : "Add the page" } , expected : [ "--title=Add the page" ] } ,
408+ {
409+ name : "a description" ,
410+ rewrite : { body : "Why the page changed" } ,
411+ expected : [ "--description=Why the page changed" ] ,
412+ } ,
413+ {
414+ name : "both" ,
415+ rewrite : { title : "Add the page" , body : "Why the page changed" } ,
416+ expected : [ "--title=Add the page" , "--description=Why the page changed" ] ,
417+ } ,
418+ ] as const ) ( "rewrites $name, sending nothing it was not given" , ( { rewrite, expected } ) =>
419+ Effect . gen ( function * ( ) {
420+ mockedExecute . mockReturnValue ( Effect . succeed ( output ( "{}" ) ) ) ;
421+ const cli = yield * AzureDevOpsPullRequestCli . AzureDevOpsPullRequestCli ;
422+
423+ yield * cli . updatePullRequest ( { cwd : "/w" , number : 42 , ...rewrite } ) ;
424+
425+ expect ( argsOfCall ( 0 ) ) . toEqual ( [
426+ "repos" ,
427+ "pr" ,
428+ "update" ,
429+ "--detect" ,
430+ "true" ,
431+ "--id" ,
432+ "42" ,
433+ ...expected ,
434+ "--only-show-errors" ,
435+ "--output" ,
436+ "json" ,
437+ ] ) ;
438+ } ) ,
439+ ) ;
440+
441+ it . effect ( "sends a description that starts with a dash as one value, not as a flag" , ( ) =>
442+ Effect . gen ( function * ( ) {
443+ mockedExecute . mockReturnValue ( Effect . succeed ( output ( "{}" ) ) ) ;
444+ const cli = yield * AzureDevOpsPullRequestCli . AzureDevOpsPullRequestCli ;
445+
446+ yield * cli . updatePullRequest ( {
447+ cwd : "/w" ,
448+ number : 42 ,
449+ body : "- rewrote the page\n- kept the rest" ,
450+ } ) ;
451+
452+ // One argument, so the leading dash of an ordinary bullet list never reaches az as a flag,
453+ // and the whole text stays together where `--description` would otherwise take several.
454+ expect ( argsOfCall ( 0 ) ) . toContain ( "--description=- rewrote the page\n- kept the rest" ) ;
455+ } ) ,
456+ ) ;
457+
458+ it . effect ( "rewrites through the provider, which says it takes one" , ( ) =>
459+ Effect . gen ( function * ( ) {
460+ mockedExecute . mockReturnValue ( Effect . succeed ( output ( "{}" ) ) ) ;
461+ const provider = yield * AzureDevOpsPullRequestProvider . make ;
462+
463+ // False for a remark because nothing here can post one, so there is none to rewrite.
464+ expect ( provider . capabilities . edit ) . toEqual ( { changeRequest : true , comment : false } ) ;
465+ assert . isDefined ( provider . updateChangeRequest ) ;
466+ yield * provider . updateChangeRequest ( {
467+ cwd : "/w" ,
468+ repository : "web" ,
469+ host : "dev.azure.com" ,
470+ number : 42 ,
471+ title : "Add the page" ,
472+ } ) ;
473+
474+ expect ( argsOfCall ( 0 ) ) . toContain ( "--title=Add the page" ) ;
475+ expect ( argsOfCall ( 0 ) ) . not . toContain ( "--description" ) ;
476+ } ) ,
477+ ) ;
478+
373479 it . effect ( "reads the conversation through the REST API, pinned to a version" , ( ) =>
374480 Effect . gen ( function * ( ) {
375481 mockedExecute . mockReturnValueOnce (
0 commit comments