@@ -155,7 +155,11 @@ suite('Set Interpreter Command', () => {
155155 } as PythonEnvironment ,
156156 } ;
157157 const expectedEnterInterpreterPathSuggestion = {
158- label : `${ Octicons . Add } ${ InterpreterQuickPickList . enterPath . label } ` ,
158+ label : `${ Octicons . Folder } ${ InterpreterQuickPickList . enterPath . label } ` ,
159+ alwaysShow : true ,
160+ } ;
161+ const expectedCreateEnvSuggestion = {
162+ label : `${ Octicons . Add } ${ InterpreterQuickPickList . create . label } ` ,
159163 alwaysShow : true ,
160164 } ;
161165 const currentPythonPath = 'python' ;
@@ -237,6 +241,7 @@ suite('Set Interpreter Command', () => {
237241 recommended . description = interpreterPath ;
238242 const suggestions = [
239243 expectedEnterInterpreterPathSuggestion ,
244+ { kind : QuickPickItemKind . Separator , label : '' } ,
240245 defaultInterpreterPathSuggestion ,
241246 { kind : QuickPickItemKind . Separator , label : EnvGroups . Recommended } ,
242247 recommended ,
@@ -278,11 +283,66 @@ suite('Set Interpreter Command', () => {
278283 assert . deepStrictEqual ( actualParameters , expectedParameters , 'Params not equal' ) ;
279284 } ) ;
280285
286+ test ( 'Picker should show create env when set in options' , async ( ) => {
287+ const state : InterpreterStateArgs = { path : 'some path' , workspace : undefined } ;
288+ const multiStepInput = TypeMoq . Mock . ofType < IMultiStepInput < InterpreterStateArgs > > ( ) ;
289+ const recommended = cloneDeep ( item ) ;
290+ recommended . label = `${ Octicons . Star } ${ item . label } ` ;
291+ recommended . description = interpreterPath ;
292+ const suggestions = [
293+ expectedCreateEnvSuggestion ,
294+ { kind : QuickPickItemKind . Separator , label : '' } ,
295+ expectedEnterInterpreterPathSuggestion ,
296+ { kind : QuickPickItemKind . Separator , label : '' } ,
297+ defaultInterpreterPathSuggestion ,
298+ { kind : QuickPickItemKind . Separator , label : EnvGroups . Recommended } ,
299+ recommended ,
300+ ] ;
301+ const expectedParameters : IQuickPickParameters < QuickPickItem > = {
302+ placeholder : `Selected Interpreter: ${ currentPythonPath } ` ,
303+ items : suggestions ,
304+ matchOnDetail : true ,
305+ matchOnDescription : true ,
306+ title : InterpreterQuickPickList . browsePath . openButtonLabel ,
307+ sortByLabel : true ,
308+ keepScrollPosition : true ,
309+ } ;
310+ let actualParameters : IQuickPickParameters < QuickPickItem > | undefined ;
311+ multiStepInput
312+ . setup ( ( i ) => i . showQuickPick ( TypeMoq . It . isAny ( ) ) )
313+ . callback ( ( options ) => {
314+ actualParameters = options ;
315+ } )
316+ . returns ( ( ) => Promise . resolve ( ( undefined as unknown ) as QuickPickItem ) ) ;
317+
318+ await setInterpreterCommand . _pickInterpreter ( multiStepInput . object , state , undefined , {
319+ showCreateEnvironment : true ,
320+ } ) ;
321+
322+ expect ( actualParameters ) . to . not . equal ( undefined , 'Parameters not set' ) ;
323+ const refreshButtons = actualParameters ! . customButtonSetups ;
324+ expect ( refreshButtons ) . to . not . equal ( undefined , 'Callback not set' ) ;
325+ delete actualParameters ! . initialize ;
326+ delete actualParameters ! . customButtonSetups ;
327+ delete actualParameters ! . onChangeItem ;
328+ if ( typeof actualParameters ! . activeItem === 'function' ) {
329+ const activeItem = await actualParameters ! . activeItem ( ( { items : suggestions } as unknown ) as QuickPick <
330+ QuickPickType
331+ > ) ;
332+ assert . deepStrictEqual ( activeItem , recommended ) ;
333+ } else {
334+ assert ( false , 'Not a function' ) ;
335+ }
336+ delete actualParameters ! . activeItem ;
337+ assert . deepStrictEqual ( actualParameters , expectedParameters , 'Params not equal' ) ;
338+ } ) ;
339+
281340 test ( 'Picker should be displayed with expected items if no interpreters are available' , async ( ) => {
282341 const state : InterpreterStateArgs = { path : 'some path' , workspace : undefined } ;
283342 const multiStepInput = TypeMoq . Mock . ofType < IMultiStepInput < InterpreterStateArgs > > ( ) ;
284343 const suggestions = [
285344 expectedEnterInterpreterPathSuggestion ,
345+ { kind : QuickPickItemKind . Separator , label : '' } ,
286346 defaultInterpreterPathSuggestion ,
287347 noPythonInstalled ,
288348 ] ;
@@ -440,6 +500,7 @@ suite('Set Interpreter Command', () => {
440500 recommended . description = interpreterPath ;
441501 const suggestions = [
442502 expectedEnterInterpreterPathSuggestion ,
503+ { kind : QuickPickItemKind . Separator , label : '' } ,
443504 defaultInterpreterPathSuggestion ,
444505 { kind : QuickPickItemKind . Separator , label : EnvGroups . Recommended } ,
445506 recommended ,
@@ -556,6 +617,7 @@ suite('Set Interpreter Command', () => {
556617 recommended . description = interpreterPath ;
557618 const suggestions = [
558619 expectedEnterInterpreterPathSuggestion ,
620+ { kind : QuickPickItemKind . Separator , label : '' } ,
559621 defaultInterpreterPathSuggestion ,
560622 { kind : QuickPickItemKind . Separator , label : EnvGroups . Recommended } ,
561623 recommended ,
@@ -652,7 +714,13 @@ suite('Set Interpreter Command', () => {
652714 alwaysShow : true ,
653715 } ;
654716
655- const suggestions = [ expectedEnterInterpreterPathSuggestion , defaultPathSuggestion , separator , recommended ] ;
717+ const suggestions = [
718+ expectedEnterInterpreterPathSuggestion ,
719+ { kind : QuickPickItemKind . Separator , label : '' } ,
720+ defaultPathSuggestion ,
721+ separator ,
722+ recommended ,
723+ ] ;
656724 const expectedParameters : IQuickPickParameters < QuickPickItem > = {
657725 placeholder : `Selected Interpreter: ${ currentPythonPath } ` ,
658726 items : suggestions ,
0 commit comments