@@ -18,6 +18,8 @@ import { ITerminalEnvVarCollectionService } from '../../../client/interpreter/ac
18
18
import { Common , Interpreters } from '../../../client/common/utils/localize' ;
19
19
import { TerminalEnvVarActivation } from '../../../client/common/experiments/groups' ;
20
20
import { sleep } from '../../core' ;
21
+ import { IInterpreterService } from '../../../client/interpreter/contracts' ;
22
+ import { PythonEnvironment } from '../../../client/pythonEnvironments/info' ;
21
23
22
24
suite ( 'Terminal Environment Variable Collection Prompt' , ( ) => {
23
25
let shell : IApplicationShell ;
@@ -30,12 +32,18 @@ suite('Terminal Environment Variable Collection Prompt', () => {
30
32
let terminalEventEmitter : EventEmitter < Terminal > ;
31
33
let notificationEnabled : IPersistentState < boolean > ;
32
34
let configurationService : IConfigurationService ;
35
+ let interpreterService : IInterpreterService ;
33
36
const prompts = [ Common . doNotShowAgain ] ;
34
- const message = Interpreters . terminalEnvVarCollectionPrompt ;
37
+ const envName = 'env' ;
38
+ const expectedMessage = Interpreters . terminalEnvVarCollectionPrompt . format ( ` (${ envName } )` ) ;
35
39
36
40
setup ( async ( ) => {
37
41
shell = mock < IApplicationShell > ( ) ;
38
42
terminalManager = mock < ITerminalManager > ( ) ;
43
+ interpreterService = mock < IInterpreterService > ( ) ;
44
+ when ( interpreterService . getActiveInterpreter ( anything ( ) ) ) . thenResolve ( ( {
45
+ envName,
46
+ } as unknown ) as PythonEnvironment ) ;
39
47
experimentService = mock < IExperimentService > ( ) ;
40
48
activeResourceService = mock < IActiveResourceService > ( ) ;
41
49
persistentStateFactory = mock < IPersistentStateFactory > ( ) ;
@@ -61,6 +69,7 @@ suite('Terminal Environment Variable Collection Prompt', () => {
61
69
instance ( activeResourceService ) ,
62
70
instance ( terminalEnvVarCollectionService ) ,
63
71
instance ( configurationService ) ,
72
+ instance ( interpreterService ) ,
64
73
instance ( experimentService ) ,
65
74
) ;
66
75
} ) ;
@@ -74,13 +83,13 @@ suite('Terminal Environment Variable Collection Prompt', () => {
74
83
} as unknown ) as Terminal ;
75
84
when ( terminalEnvVarCollectionService . isTerminalPromptSetCorrectly ( resource ) ) . thenReturn ( false ) ;
76
85
when ( notificationEnabled . value ) . thenReturn ( true ) ;
77
- when ( shell . showInformationMessage ( message , ...prompts ) ) . thenResolve ( undefined ) ;
86
+ when ( shell . showInformationMessage ( expectedMessage , ...prompts ) ) . thenResolve ( undefined ) ;
78
87
79
88
await terminalEnvVarCollectionPrompt . activate ( ) ;
80
89
terminalEventEmitter . fire ( terminal ) ;
81
90
await sleep ( 1 ) ;
82
91
83
- verify ( shell . showInformationMessage ( message , ...prompts ) ) . once ( ) ;
92
+ verify ( shell . showInformationMessage ( expectedMessage , ...prompts ) ) . once ( ) ;
84
93
} ) ;
85
94
86
95
test ( 'Do not show notification if automatic terminal activation is turned off' , async ( ) => {
@@ -98,13 +107,13 @@ suite('Terminal Environment Variable Collection Prompt', () => {
98
107
} as unknown ) as Terminal ;
99
108
when ( terminalEnvVarCollectionService . isTerminalPromptSetCorrectly ( resource ) ) . thenReturn ( false ) ;
100
109
when ( notificationEnabled . value ) . thenReturn ( true ) ;
101
- when ( shell . showInformationMessage ( message , ...prompts ) ) . thenResolve ( undefined ) ;
110
+ when ( shell . showInformationMessage ( expectedMessage , ...prompts ) ) . thenResolve ( undefined ) ;
102
111
103
112
await terminalEnvVarCollectionPrompt . activate ( ) ;
104
113
terminalEventEmitter . fire ( terminal ) ;
105
114
await sleep ( 1 ) ;
106
115
107
- verify ( shell . showInformationMessage ( message , ...prompts ) ) . never ( ) ;
116
+ verify ( shell . showInformationMessage ( expectedMessage , ...prompts ) ) . never ( ) ;
108
117
} ) ;
109
118
110
119
test ( 'When not in experiment, do not show notification for the same' , async ( ) => {
@@ -116,15 +125,15 @@ suite('Terminal Environment Variable Collection Prompt', () => {
116
125
} as unknown ) as Terminal ;
117
126
when ( terminalEnvVarCollectionService . isTerminalPromptSetCorrectly ( resource ) ) . thenReturn ( false ) ;
118
127
when ( notificationEnabled . value ) . thenReturn ( true ) ;
119
- when ( shell . showInformationMessage ( message , ...prompts ) ) . thenResolve ( undefined ) ;
128
+ when ( shell . showInformationMessage ( expectedMessage , ...prompts ) ) . thenResolve ( undefined ) ;
120
129
121
130
reset ( experimentService ) ;
122
131
when ( experimentService . inExperimentSync ( TerminalEnvVarActivation . experiment ) ) . thenReturn ( false ) ;
123
132
await terminalEnvVarCollectionPrompt . activate ( ) ;
124
133
terminalEventEmitter . fire ( terminal ) ;
125
134
await sleep ( 1 ) ;
126
135
127
- verify ( shell . showInformationMessage ( message , ...prompts ) ) . never ( ) ;
136
+ verify ( shell . showInformationMessage ( expectedMessage , ...prompts ) ) . never ( ) ;
128
137
} ) ;
129
138
130
139
test ( 'Do not show notification if notification is disabled' , async ( ) => {
@@ -136,13 +145,13 @@ suite('Terminal Environment Variable Collection Prompt', () => {
136
145
} as unknown ) as Terminal ;
137
146
when ( terminalEnvVarCollectionService . isTerminalPromptSetCorrectly ( resource ) ) . thenReturn ( false ) ;
138
147
when ( notificationEnabled . value ) . thenReturn ( false ) ;
139
- when ( shell . showInformationMessage ( message , ...prompts ) ) . thenResolve ( undefined ) ;
148
+ when ( shell . showInformationMessage ( expectedMessage , ...prompts ) ) . thenResolve ( undefined ) ;
140
149
141
150
await terminalEnvVarCollectionPrompt . activate ( ) ;
142
151
terminalEventEmitter . fire ( terminal ) ;
143
152
await sleep ( 1 ) ;
144
153
145
- verify ( shell . showInformationMessage ( message , ...prompts ) ) . never ( ) ;
154
+ verify ( shell . showInformationMessage ( expectedMessage , ...prompts ) ) . never ( ) ;
146
155
} ) ;
147
156
148
157
test ( 'Do not show notification when a new terminal is opened for which there is prompt set' , async ( ) => {
@@ -154,13 +163,13 @@ suite('Terminal Environment Variable Collection Prompt', () => {
154
163
} as unknown ) as Terminal ;
155
164
when ( terminalEnvVarCollectionService . isTerminalPromptSetCorrectly ( resource ) ) . thenReturn ( true ) ;
156
165
when ( notificationEnabled . value ) . thenReturn ( true ) ;
157
- when ( shell . showInformationMessage ( message , ...prompts ) ) . thenResolve ( undefined ) ;
166
+ when ( shell . showInformationMessage ( expectedMessage , ...prompts ) ) . thenResolve ( undefined ) ;
158
167
159
168
await terminalEnvVarCollectionPrompt . activate ( ) ;
160
169
terminalEventEmitter . fire ( terminal ) ;
161
170
await sleep ( 1 ) ;
162
171
163
- verify ( shell . showInformationMessage ( message , ...prompts ) ) . never ( ) ;
172
+ verify ( shell . showInformationMessage ( expectedMessage , ...prompts ) ) . never ( ) ;
164
173
} ) ;
165
174
166
175
test ( "Disable notification if `Don't show again` is clicked" , async ( ) => {
@@ -173,7 +182,9 @@ suite('Terminal Environment Variable Collection Prompt', () => {
173
182
when ( terminalEnvVarCollectionService . isTerminalPromptSetCorrectly ( resource ) ) . thenReturn ( false ) ;
174
183
when ( notificationEnabled . value ) . thenReturn ( true ) ;
175
184
when ( notificationEnabled . updateValue ( false ) ) . thenResolve ( ) ;
176
- when ( shell . showInformationMessage ( message , ...prompts ) ) . thenReturn ( Promise . resolve ( Common . doNotShowAgain ) ) ;
185
+ when ( shell . showInformationMessage ( expectedMessage , ...prompts ) ) . thenReturn (
186
+ Promise . resolve ( Common . doNotShowAgain ) ,
187
+ ) ;
177
188
178
189
await terminalEnvVarCollectionPrompt . activate ( ) ;
179
190
terminalEventEmitter . fire ( terminal ) ;
@@ -192,7 +203,7 @@ suite('Terminal Environment Variable Collection Prompt', () => {
192
203
when ( terminalEnvVarCollectionService . isTerminalPromptSetCorrectly ( resource ) ) . thenReturn ( false ) ;
193
204
when ( notificationEnabled . value ) . thenReturn ( true ) ;
194
205
when ( notificationEnabled . updateValue ( false ) ) . thenResolve ( ) ;
195
- when ( shell . showInformationMessage ( message , ...prompts ) ) . thenReturn ( Promise . resolve ( undefined ) ) ;
206
+ when ( shell . showInformationMessage ( expectedMessage , ...prompts ) ) . thenReturn ( Promise . resolve ( undefined ) ) ;
196
207
197
208
await terminalEnvVarCollectionPrompt . activate ( ) ;
198
209
terminalEventEmitter . fire ( terminal ) ;
0 commit comments