@@ -12,6 +12,7 @@ import (
1212 "strings"
1313 "testing"
1414
15+ "github.com/MakeNowJust/heredoc"
1516 "github.com/cli/cli/internal/config"
1617 "github.com/cli/cli/internal/ghrepo"
1718 "github.com/cli/cli/internal/run"
@@ -274,6 +275,62 @@ func TestIssueCreate_nonLegacyTemplate(t *testing.T) {
274275 eq (t , output .String (), "https://github.com/OWNER/REPO/issues/12\n " )
275276}
276277
278+ func TestIssueCreate_continueInBrowser (t * testing.T ) {
279+ http := & httpmock.Registry {}
280+ defer http .Verify (t )
281+
282+ http .StubResponse (200 , bytes .NewBufferString (`
283+ { "data": { "repository": {
284+ "id": "REPOID",
285+ "hasIssuesEnabled": true
286+ } } }
287+ ` ))
288+
289+ as , teardown := prompt .InitAskStubber ()
290+ defer teardown ()
291+
292+ // title
293+ as .Stub ([]* prompt.QuestionStub {
294+ {
295+ Name : "Title" ,
296+ Value : "hello" ,
297+ },
298+ })
299+ // confirm
300+ as .Stub ([]* prompt.QuestionStub {
301+ {
302+ Name : "confirmation" ,
303+ Value : 1 ,
304+ },
305+ })
306+
307+ var seenCmd * exec.Cmd
308+ restoreCmd := run .SetPrepareCmd (func (cmd * exec.Cmd ) run.Runnable {
309+ seenCmd = cmd
310+ return & test.OutputStub {}
311+ })
312+ defer restoreCmd ()
313+
314+ output , err := runCommand (http , true , `-b body` )
315+ if err != nil {
316+ t .Errorf ("error running command `issue create`: %v" , err )
317+ }
318+
319+ assert .Equal (t , "" , output .String ())
320+ assert .Equal (t , heredoc .Doc (`
321+
322+ Creating issue in OWNER/REPO
323+
324+ Opening github.com/OWNER/REPO/issues/new in your browser.
325+ ` ), output .Stderr ())
326+
327+ if seenCmd == nil {
328+ t .Fatal ("expected a command to run" )
329+ }
330+ url := seenCmd .Args [len (seenCmd .Args )- 1 ]
331+ assert .Equal (t , "https://github.com/OWNER/REPO/issues/new?body=body&title=hello" , url )
332+ }
333+
277334func TestIssueCreate_metadata (t * testing.T ) {
278335 http := & httpmock.Registry {}
279336 defer http .Verify (t )
0 commit comments