@@ -495,12 +495,18 @@ func Test_createRun(t *testing.T) {
495495 switch message {
496496 case "What would you like to add?" :
497497 return prompter .IndexesFor (options , "Assignees" )
498- case "Assignees" :
499- return prompter .IndexesFor (options , "Copilot (AI)" , "MonaLisa (Mona Display Name)" )
500498 default :
501499 return nil , fmt .Errorf ("unexpected multi-select prompt: %s" , message )
502500 }
503501 }
502+ pm .MultiSelectWithSearchFunc = func (message , searchPrompt string , defaults , persistentOptions []string , searchFunc func (string ) prompter.MultiSelectSearchResult ) ([]string , error ) {
503+ switch message {
504+ case "Assignees" :
505+ return []string {"copilot-swe-agent" , "MonaLisa" }, nil
506+ default :
507+ return nil , fmt .Errorf ("unexpected multi-select-with-search prompt: %s" , message )
508+ }
509+ }
504510 pm .SelectFunc = func (message , defaultValue string , options []string ) (int , error ) {
505511 switch message {
506512 case "What's next?" :
@@ -524,25 +530,25 @@ func Test_createRun(t *testing.T) {
524530 "viewerPermission": "WRITE"
525531 } } }
526532 ` ))
527- r .Register (
528- httpmock .GraphQL (`query RepositoryAssignableActors\b` ),
529- httpmock .StringResponse (`
530- { "data": { "repository": { "suggestedActors": {
531- "nodes": [
532- { "login": "copilot-swe-agent", "id": "COPILOTID", "name": "Copilot (AI)", "__typename": "Bot" },
533- { "login": "MonaLisa", "id": "MONAID", "name": "Mona Display Name", "__typename": "User" }
534- ],
535- "pageInfo": { "hasNextPage": false }
536- } } } }
537- ` ))
538533 r .Register (
539534 httpmock .GraphQL (`mutation IssueCreate\b` ),
540535 httpmock .GraphQLMutation (`
541536 { "data": { "createIssue": { "issue": {
537+ "id": "ISSUEID",
542538 "URL": "https://github.com/OWNER/REPO/issues/12"
543539 } } } }
544540 ` , func (inputs map [string ]interface {}) {
545- assert .Equal (t , []interface {}{"COPILOTID" , "MONAID" }, inputs ["assigneeIds" ])
541+ if v , ok := inputs ["assigneeIds" ]; ok {
542+ t .Errorf ("did not expect assigneeIds: %v" , v )
543+ }
544+ }))
545+ r .Register (
546+ httpmock .GraphQL (`mutation ReplaceActorsForAssignable\b` ),
547+ httpmock .GraphQLMutation (`
548+ { "data": { "replaceActorsForAssignable": { "__typename": "" } } }
549+ ` , func (inputs map [string ]interface {}) {
550+ assert .Equal (t , "ISSUEID" , inputs ["assignableId" ])
551+ assert .Equal (t , []interface {}{"copilot-swe-agent" , "MonaLisa" }, inputs ["actorLogins" ])
546552 }))
547553 },
548554 wantsStdout : "https://github.com/OWNER/REPO/issues/12\n " ,
@@ -948,16 +954,6 @@ func TestIssueCreate_metadata(t *testing.T) {
948954 defer http .Verify (t )
949955
950956 http .StubRepoInfoResponse ("OWNER" , "REPO" , "main" )
951- http .Register (
952- httpmock .GraphQL (`query RepositoryAssignableActors\b` ),
953- httpmock .StringResponse (`
954- { "data": { "repository": { "suggestedActors": {
955- "nodes": [
956- { "login": "MonaLisa", "id": "MONAID", "name": "Mona Display Name", "__typename": "User" }
957- ],
958- "pageInfo": { "hasNextPage": false }
959- } } } }
960- ` ))
961957 http .Register (
962958 httpmock .GraphQL (`query RepositoryLabelList\b` ),
963959 httpmock .StringResponse (`
@@ -1030,19 +1026,30 @@ func TestIssueCreate_metadata(t *testing.T) {
10301026 httpmock .GraphQL (`mutation IssueCreate\b` ),
10311027 httpmock .GraphQLMutation (`
10321028 { "data": { "createIssue": { "issue": {
1029+ "id": "NEWISSUEID",
10331030 "URL": "https://github.com/OWNER/REPO/issues/12"
10341031 } } } }
10351032 ` , func (inputs map [string ]interface {}) {
10361033 assert .Equal (t , "TITLE" , inputs ["title" ])
10371034 assert .Equal (t , "BODY" , inputs ["body" ])
1038- assert .Equal (t , []interface {}{"MONAID" }, inputs ["assigneeIds" ])
1035+ if v , ok := inputs ["assigneeIds" ]; ok {
1036+ t .Errorf ("did not expect assigneeIds: %v" , v )
1037+ }
10391038 assert .Equal (t , []interface {}{"BUGID" , "TODOID" }, inputs ["labelIds" ])
10401039 assert .Equal (t , []interface {}{"ROADMAPID" }, inputs ["projectIds" ])
10411040 assert .Equal (t , "BIGONEID" , inputs ["milestoneId" ])
10421041 assert .NotContains (t , inputs , "userIds" )
10431042 assert .NotContains (t , inputs , "teamIds" )
10441043 assert .NotContains (t , inputs , "projectV2Ids" )
10451044 }))
1045+ http .Register (
1046+ httpmock .GraphQL (`mutation ReplaceActorsForAssignable\b` ),
1047+ httpmock .GraphQLMutation (`
1048+ { "data": { "replaceActorsForAssignable": { "__typename": "" } } }
1049+ ` , func (inputs map [string ]interface {}) {
1050+ assert .Equal (t , "NEWISSUEID" , inputs ["assignableId" ])
1051+ assert .Equal (t , []interface {}{"monalisa" }, inputs ["actorLogins" ])
1052+ }))
10461053
10471054 output , err := runCommand (http , true , `-t TITLE -b BODY -a monalisa -l bug -l todo -p roadmap -m 'big one.oh'` , nil )
10481055 if err != nil {
@@ -1091,27 +1098,27 @@ func TestIssueCreate_AtMeAssignee(t *testing.T) {
10911098 "hasIssuesEnabled": true
10921099 } } }
10931100 ` ))
1094- http .Register (
1095- httpmock .GraphQL (`query RepositoryAssignableActors\b` ),
1096- httpmock .StringResponse (`
1097- { "data": { "repository": { "suggestedActors": {
1098- "nodes": [
1099- { "login": "MonaLisa", "id": "MONAID", "name": "Mona Display Name", "__typename": "User" },
1100- { "login": "SomeOneElse", "id": "SOMEID", "name": "Someone else", "__typename": "User" }
1101- ],
1102- "pageInfo": { "hasNextPage": false }
1103- } } } }
1104- ` ))
11051101 http .Register (
11061102 httpmock .GraphQL (`mutation IssueCreate\b` ),
11071103 httpmock .GraphQLMutation (`
11081104 { "data": { "createIssue": { "issue": {
1105+ "id": "NEWISSUEID",
11091106 "URL": "https://github.com/OWNER/REPO/issues/12"
11101107 } } } }
11111108 ` , func (inputs map [string ]interface {}) {
11121109 assert .Equal (t , "hello" , inputs ["title" ])
11131110 assert .Equal (t , "cash rules everything around me" , inputs ["body" ])
1114- assert .Equal (t , []interface {}{"MONAID" , "SOMEID" }, inputs ["assigneeIds" ])
1111+ if v , ok := inputs ["assigneeIds" ]; ok {
1112+ t .Errorf ("did not expect assigneeIds: %v" , v )
1113+ }
1114+ }))
1115+ http .Register (
1116+ httpmock .GraphQL (`mutation ReplaceActorsForAssignable\b` ),
1117+ httpmock .GraphQLMutation (`
1118+ { "data": { "replaceActorsForAssignable": { "__typename": "" } } }
1119+ ` , func (inputs map [string ]interface {}) {
1120+ assert .Equal (t , "NEWISSUEID" , inputs ["assignableId" ])
1121+ assert .Equal (t , []interface {}{"MonaLisa" , "someoneelse" }, inputs ["actorLogins" ])
11151122 }))
11161123
11171124 output , err := runCommand (http , true , `-a @me -a someoneelse -t hello -b "cash rules everything around me"` , nil )
@@ -1134,26 +1141,27 @@ func TestIssueCreate_AtCopilotAssignee(t *testing.T) {
11341141 "hasIssuesEnabled": true
11351142 } } }
11361143 ` ))
1137- http .Register (
1138- httpmock .GraphQL (`query RepositoryAssignableActors\b` ),
1139- httpmock .StringResponse (`
1140- { "data": { "repository": { "suggestedActors": {
1141- "nodes": [
1142- { "login": "copilot-swe-agent", "id": "COPILOTID", "name": "Copilot (AI)", "__typename": "Bot" }
1143- ],
1144- "pageInfo": { "hasNextPage": false }
1145- } } } }
1146- ` ))
11471144 http .Register (
11481145 httpmock .GraphQL (`mutation IssueCreate\b` ),
11491146 httpmock .GraphQLMutation (`
11501147 { "data": { "createIssue": { "issue": {
1148+ "id": "NEWISSUEID",
11511149 "URL": "https://github.com/OWNER/REPO/issues/12"
11521150 } } } }
11531151 ` , func (inputs map [string ]interface {}) {
11541152 assert .Equal (t , "hello" , inputs ["title" ])
11551153 assert .Equal (t , "cash rules everything around me" , inputs ["body" ])
1156- assert .Equal (t , []interface {}{"COPILOTID" }, inputs ["assigneeIds" ])
1154+ if v , ok := inputs ["assigneeIds" ]; ok {
1155+ t .Errorf ("did not expect assigneeIds: %v" , v )
1156+ }
1157+ }))
1158+ http .Register (
1159+ httpmock .GraphQL (`mutation ReplaceActorsForAssignable\b` ),
1160+ httpmock .GraphQLMutation (`
1161+ { "data": { "replaceActorsForAssignable": { "__typename": "" } } }
1162+ ` , func (inputs map [string ]interface {}) {
1163+ assert .Equal (t , "NEWISSUEID" , inputs ["assignableId" ])
1164+ assert .Equal (t , []interface {}{"copilot-swe-agent" }, inputs ["actorLogins" ])
11571165 }))
11581166
11591167 output , err := runCommand (http , true , `-a @copilot -t hello -b "cash rules everything around me"` , nil )
0 commit comments