@@ -322,3 +322,51 @@ func TestPRCreate_survey_defaults_monocommit(t *testing.T) {
322322
323323 eq (t , output .String (), "https://github.com/OWNER/REPO/pull/12\n " )
324324}
325+
326+ func TestPRCreate_survey_autofill (t * testing.T ) {
327+ initBlankContext ("OWNER/REPO" , "feature" )
328+ http := initFakeHTTP ()
329+ http .StubRepoResponse ("OWNER" , "REPO" )
330+ http .StubResponse (200 , bytes .NewBufferString (`
331+ { "data": { "createPullRequest": { "pullRequest": {
332+ "URL": "https://github.com/OWNER/REPO/pull/12"
333+ } } } }
334+ ` ))
335+
336+ cs , cmdTeardown := initCmdStubber ()
337+ defer cmdTeardown ()
338+
339+ cs .Stub ("" ) // git status
340+ cs .Stub ("1234567890,the sky above the port" ) // git log
341+ cs .Stub ("was the color of a television, turned to a dead channel" ) // git show
342+ cs .Stub ("" ) // git rev-parse
343+ cs .Stub ("" ) // git push
344+ cs .Stub ("" ) // browser open
345+
346+ output , err := RunCommand (prCreateCmd , `pr create -f` )
347+ eq (t , err , nil )
348+
349+ bodyBytes , _ := ioutil .ReadAll (http .Requests [1 ].Body )
350+ reqBody := struct {
351+ Variables struct {
352+ Input struct {
353+ RepositoryID string
354+ Title string
355+ Body string
356+ BaseRefName string
357+ HeadRefName string
358+ }
359+ }
360+ }{}
361+ json .Unmarshal (bodyBytes , & reqBody )
362+
363+ expectedBody := "was the color of a television, turned to a dead channel"
364+
365+ eq (t , reqBody .Variables .Input .RepositoryID , "REPOID" )
366+ eq (t , reqBody .Variables .Input .Title , "the sky above the port" )
367+ eq (t , reqBody .Variables .Input .Body , expectedBody )
368+ eq (t , reqBody .Variables .Input .BaseRefName , "master" )
369+ eq (t , reqBody .Variables .Input .HeadRefName , "feature" )
370+
371+ eq (t , output .String (), "https://github.com/OWNER/REPO/pull/12\n " )
372+ }
0 commit comments