@@ -155,176 +155,6 @@ suite('Experimentation service', () => {
155
155
} ) ;
156
156
} ) ;
157
157
158
- suite ( 'In-experiment check' , ( ) => {
159
- const experiment = 'Test Experiment - experiment' ;
160
- let telemetryEvents : { eventName : string ; properties : Record < string , unknown > } [ ] = [ ] ;
161
- let getTreatmentVariableAsyncStub : sinon . SinonStub ;
162
- let sendTelemetryEventStub : sinon . SinonStub ;
163
-
164
- setup ( ( ) => {
165
- sendTelemetryEventStub = sinon
166
- . stub ( Telemetry , 'sendTelemetryEvent' )
167
- . callsFake ( ( eventName : string , _ , properties : Record < string , unknown > ) => {
168
- const telemetry = { eventName, properties } ;
169
- telemetryEvents . push ( telemetry ) ;
170
- } ) ;
171
-
172
- getTreatmentVariableAsyncStub = sinon . stub ( ) . returns ( Promise . resolve ( true ) ) ;
173
- sinon . stub ( tasClient , 'getExperimentationService' ) . returns ( ( {
174
- getTreatmentVariableAsync : getTreatmentVariableAsyncStub ,
175
- } as unknown ) as tasClient . IExperimentationService ) ;
176
-
177
- configureApplicationEnvironment ( 'stable' , extensionVersion ) ;
178
- } ) ;
179
-
180
- teardown ( ( ) => {
181
- telemetryEvents = [ ] ;
182
- } ) ;
183
-
184
- test ( 'If the opt-in and opt-out arrays are empty, return the value from the experimentation framework for a given experiment' , async ( ) => {
185
- configureSettings ( true , [ ] , [ ] ) ;
186
-
187
- const experimentService = new ExperimentService (
188
- instance ( workspaceService ) ,
189
- instance ( appEnvironment ) ,
190
- globalMemento ,
191
- outputChannel ,
192
- ) ;
193
- const result = await experimentService . inExperiment ( experiment ) ;
194
-
195
- assert . isTrue ( result ) ;
196
- sinon . assert . notCalled ( sendTelemetryEventStub ) ;
197
- sinon . assert . calledOnce ( getTreatmentVariableAsyncStub ) ;
198
- } ) ;
199
-
200
- test ( 'If the experiment setting is disabled, inExperiment should return false' , async ( ) => {
201
- configureSettings ( false , [ ] , [ ] ) ;
202
-
203
- const experimentService = new ExperimentService (
204
- instance ( workspaceService ) ,
205
- instance ( appEnvironment ) ,
206
- globalMemento ,
207
- outputChannel ,
208
- ) ;
209
- const result = await experimentService . inExperiment ( experiment ) ;
210
-
211
- assert . isFalse ( result ) ;
212
- sinon . assert . notCalled ( sendTelemetryEventStub ) ;
213
- sinon . assert . notCalled ( getTreatmentVariableAsyncStub ) ;
214
- } ) ;
215
-
216
- test ( 'If the opt-in setting contains "All", inExperiment should return true' , async ( ) => {
217
- configureSettings ( true , [ 'All' ] , [ ] ) ;
218
-
219
- const experimentService = new ExperimentService (
220
- instance ( workspaceService ) ,
221
- instance ( appEnvironment ) ,
222
- globalMemento ,
223
- outputChannel ,
224
- ) ;
225
- const result = await experimentService . inExperiment ( experiment ) ;
226
-
227
- assert . isTrue ( result ) ;
228
- assert . strictEqual ( telemetryEvents . length , 0 ) ;
229
- } ) ;
230
-
231
- test ( 'If the opt-in setting contains `All`, inExperiment should check the value cached by the experiment service' , async ( ) => {
232
- configureSettings ( true , [ 'All' ] , [ ] ) ;
233
-
234
- const experimentService = new ExperimentService (
235
- instance ( workspaceService ) ,
236
- instance ( appEnvironment ) ,
237
- globalMemento ,
238
- outputChannel ,
239
- ) ;
240
- const result = await experimentService . inExperiment ( experiment ) ;
241
-
242
- assert . isTrue ( result ) ;
243
- sinon . assert . notCalled ( sendTelemetryEventStub ) ;
244
- sinon . assert . calledOnce ( getTreatmentVariableAsyncStub ) ;
245
- } ) ;
246
-
247
- test ( 'If the opt-in setting contains `All` and the experiment setting is disabled, inExperiment should return false' , async ( ) => {
248
- configureSettings ( false , [ 'All' ] , [ ] ) ;
249
-
250
- const experimentService = new ExperimentService (
251
- instance ( workspaceService ) ,
252
- instance ( appEnvironment ) ,
253
- globalMemento ,
254
- outputChannel ,
255
- ) ;
256
- const result = await experimentService . inExperiment ( experiment ) ;
257
-
258
- assert . isFalse ( result ) ;
259
- sinon . assert . notCalled ( sendTelemetryEventStub ) ;
260
- sinon . assert . notCalled ( getTreatmentVariableAsyncStub ) ;
261
- } ) ;
262
-
263
- test ( 'If the opt-in setting contains the experiment name, inExperiment should return true' , async ( ) => {
264
- configureSettings ( true , [ experiment ] , [ ] ) ;
265
-
266
- const experimentService = new ExperimentService (
267
- instance ( workspaceService ) ,
268
- instance ( appEnvironment ) ,
269
- globalMemento ,
270
- outputChannel ,
271
- ) ;
272
- const result = await experimentService . inExperiment ( experiment ) ;
273
-
274
- assert . isTrue ( result ) ;
275
- assert . strictEqual ( telemetryEvents . length , 0 ) ;
276
- sinon . assert . calledOnce ( getTreatmentVariableAsyncStub ) ;
277
- } ) ;
278
-
279
- test ( 'If the opt-out setting contains "All", inExperiment should return false' , async ( ) => {
280
- configureSettings ( true , [ ] , [ 'All' ] ) ;
281
-
282
- const experimentService = new ExperimentService (
283
- instance ( workspaceService ) ,
284
- instance ( appEnvironment ) ,
285
- globalMemento ,
286
- outputChannel ,
287
- ) ;
288
- const result = await experimentService . inExperiment ( experiment ) ;
289
-
290
- assert . isFalse ( result ) ;
291
- sinon . assert . notCalled ( sendTelemetryEventStub ) ;
292
- sinon . assert . notCalled ( getTreatmentVariableAsyncStub ) ;
293
- } ) ;
294
-
295
- test ( 'If the opt-out setting contains "All" and the experiment setting is enabled, inExperiment should return false' , async ( ) => {
296
- configureSettings ( true , [ ] , [ 'All' ] ) ;
297
-
298
- const experimentService = new ExperimentService (
299
- instance ( workspaceService ) ,
300
- instance ( appEnvironment ) ,
301
- globalMemento ,
302
- outputChannel ,
303
- ) ;
304
- const result = await experimentService . inExperiment ( experiment ) ;
305
-
306
- assert . isFalse ( result ) ;
307
- sinon . assert . notCalled ( sendTelemetryEventStub ) ;
308
- sinon . assert . notCalled ( getTreatmentVariableAsyncStub ) ;
309
- } ) ;
310
-
311
- test ( 'If the opt-out setting contains the experiment name, inExperiment should return false' , async ( ) => {
312
- configureSettings ( true , [ ] , [ experiment ] ) ;
313
-
314
- const experimentService = new ExperimentService (
315
- instance ( workspaceService ) ,
316
- instance ( appEnvironment ) ,
317
- globalMemento ,
318
- outputChannel ,
319
- ) ;
320
- const result = await experimentService . inExperiment ( experiment ) ;
321
-
322
- assert . isFalse ( result ) ;
323
- assert . strictEqual ( telemetryEvents . length , 0 ) ;
324
- sinon . assert . notCalled ( getTreatmentVariableAsyncStub ) ;
325
- } ) ;
326
- } ) ;
327
-
328
158
suite ( 'In-experiment-sync check' , ( ) => {
329
159
const experiment = 'Test Experiment - experiment' ;
330
160
let telemetryEvents : { eventName : string ; properties : Record < string , unknown > } [ ] = [ ] ;
0 commit comments