1- import { Config } from '@oclif/core'
1+ import { Config , ux } from '@oclif/core'
2+ import ansis from 'ansis'
23import { expect , fancy } from 'fancy-test'
34import inquirer from 'inquirer'
45import nock from 'nock'
@@ -7,6 +8,7 @@ import {fileURLToPath} from 'node:url'
78import * as sinon from 'sinon'
89
910import { Command as CommandBase } from '../src/command.js'
11+ import { Login } from '../src/login.js'
1012import { restoreNetrcStub , stubNetrc } from './helpers/netrc-stub.js'
1113
1214class Command extends CommandBase {
@@ -123,3 +125,22 @@ describe('login with interactive', () => {
123125 } )
124126 } )
125127} )
128+
129+ describe ( 'login with browser' , ( ) => {
130+ test
131+ . it ( 'prints fallback URL on its own line' , async ctx => {
132+ const cmd = new Command ( [ ] , ctx . config )
133+ const login = new Login ( ctx . config , cmd . heroku )
134+ const warnStub = sinon . stub ( ux , 'warn' )
135+ const stderrStub = sinon . stub ( ux , 'stderr' )
136+ const url = 'https://cli-auth.heroku.com/auth/cli/browser/abc123?requestor=xyz'
137+
138+ const showManualBrowserLoginUrl = ( login as any ) . showManualBrowserLoginUrl . bind ( login )
139+ showManualBrowserLoginUrl ( url )
140+
141+ expect ( warnStub . calledWithExactly ( 'If browser does not open, visit:' ) ) . to . equal ( true )
142+ expect ( warnStub . firstCall . args [ 0 ] ) . to . not . contain ( url )
143+ expect ( stderrStub . calledWithExactly ( ansis . greenBright ( url ) ) ) . to . equal ( true )
144+ sinon . assert . callOrder ( warnStub , stderrStub )
145+ } )
146+ } )
0 commit comments