@@ -155,7 +155,11 @@ suite('Set Interpreter Command', () => {
155
155
} as PythonEnvironment ,
156
156
} ;
157
157
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 } ` ,
159
163
alwaysShow : true ,
160
164
} ;
161
165
const currentPythonPath = 'python' ;
@@ -237,6 +241,7 @@ suite('Set Interpreter Command', () => {
237
241
recommended . description = interpreterPath ;
238
242
const suggestions = [
239
243
expectedEnterInterpreterPathSuggestion ,
244
+ { kind : QuickPickItemKind . Separator , label : '' } ,
240
245
defaultInterpreterPathSuggestion ,
241
246
{ kind : QuickPickItemKind . Separator , label : EnvGroups . Recommended } ,
242
247
recommended ,
@@ -278,11 +283,66 @@ suite('Set Interpreter Command', () => {
278
283
assert . deepStrictEqual ( actualParameters , expectedParameters , 'Params not equal' ) ;
279
284
} ) ;
280
285
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
+
281
340
test ( 'Picker should be displayed with expected items if no interpreters are available' , async ( ) => {
282
341
const state : InterpreterStateArgs = { path : 'some path' , workspace : undefined } ;
283
342
const multiStepInput = TypeMoq . Mock . ofType < IMultiStepInput < InterpreterStateArgs > > ( ) ;
284
343
const suggestions = [
285
344
expectedEnterInterpreterPathSuggestion ,
345
+ { kind : QuickPickItemKind . Separator , label : '' } ,
286
346
defaultInterpreterPathSuggestion ,
287
347
noPythonInstalled ,
288
348
] ;
@@ -440,6 +500,7 @@ suite('Set Interpreter Command', () => {
440
500
recommended . description = interpreterPath ;
441
501
const suggestions = [
442
502
expectedEnterInterpreterPathSuggestion ,
503
+ { kind : QuickPickItemKind . Separator , label : '' } ,
443
504
defaultInterpreterPathSuggestion ,
444
505
{ kind : QuickPickItemKind . Separator , label : EnvGroups . Recommended } ,
445
506
recommended ,
@@ -556,6 +617,7 @@ suite('Set Interpreter Command', () => {
556
617
recommended . description = interpreterPath ;
557
618
const suggestions = [
558
619
expectedEnterInterpreterPathSuggestion ,
620
+ { kind : QuickPickItemKind . Separator , label : '' } ,
559
621
defaultInterpreterPathSuggestion ,
560
622
{ kind : QuickPickItemKind . Separator , label : EnvGroups . Recommended } ,
561
623
recommended ,
@@ -652,7 +714,13 @@ suite('Set Interpreter Command', () => {
652
714
alwaysShow : true ,
653
715
} ;
654
716
655
- const suggestions = [ expectedEnterInterpreterPathSuggestion , defaultPathSuggestion , separator , recommended ] ;
717
+ const suggestions = [
718
+ expectedEnterInterpreterPathSuggestion ,
719
+ { kind : QuickPickItemKind . Separator , label : '' } ,
720
+ defaultPathSuggestion ,
721
+ separator ,
722
+ recommended ,
723
+ ] ;
656
724
const expectedParameters : IQuickPickParameters < QuickPickItem > = {
657
725
placeholder : `Selected Interpreter: ${ currentPythonPath } ` ,
658
726
items : suggestions ,
0 commit comments