@@ -8,7 +8,7 @@ import * as sinon from 'sinon';
8
8
import { anything , instance , mock , verify , when } from 'ts-mockito' ;
9
9
import * as TypeMoq from 'typemoq' ;
10
10
import { ExtensionSurveyPrompt , extensionSurveyStateKeys } from '../../client/activation/extensionSurvey' ;
11
- import { IApplicationEnvironment , IApplicationShell } from '../../client/common/application/types' ;
11
+ import { IApplicationEnvironment , IApplicationShell , IWorkspaceService } from '../../client/common/application/types' ;
12
12
import { ShowExtensionSurveyPrompt } from '../../client/common/experiments/groups' ;
13
13
import { PersistentStateFactory } from '../../client/common/persistentState' ;
14
14
import { IPlatformService } from '../../client/common/platform/types' ;
@@ -23,6 +23,7 @@ import { createDeferred } from '../../client/common/utils/async';
23
23
import { Common , ExtensionSurveyBanner } from '../../client/common/utils/localize' ;
24
24
import { OSType } from '../../client/common/utils/platform' ;
25
25
import { sleep } from '../core' ;
26
+ import { WorkspaceConfiguration } from 'vscode' ;
26
27
27
28
suite ( 'Extension survey prompt - shouldShowBanner()' , ( ) => {
28
29
let appShell : TypeMoq . IMock < IApplicationShell > ;
@@ -35,6 +36,8 @@ suite('Extension survey prompt - shouldShowBanner()', () => {
35
36
let disableSurveyForTime : TypeMoq . IMock < IPersistentState < any > > ;
36
37
let doNotShowAgain : TypeMoq . IMock < IPersistentState < any > > ;
37
38
let extensionSurveyPrompt : ExtensionSurveyPrompt ;
39
+ let workspaceService : TypeMoq . IMock < IWorkspaceService > ;
40
+
38
41
setup ( ( ) => {
39
42
experiments = TypeMoq . Mock . ofType < IExperimentService > ( ) ;
40
43
appShell = TypeMoq . Mock . ofType < IApplicationShell > ( ) ;
@@ -45,6 +48,7 @@ suite('Extension survey prompt - shouldShowBanner()', () => {
45
48
doNotShowAgain = TypeMoq . Mock . ofType < IPersistentState < any > > ( ) ;
46
49
platformService = TypeMoq . Mock . ofType < IPlatformService > ( ) ;
47
50
appEnvironment = TypeMoq . Mock . ofType < IApplicationEnvironment > ( ) ;
51
+ workspaceService = TypeMoq . Mock . ofType < IWorkspaceService > ( ) ;
48
52
when (
49
53
persistentStateFactory . createGlobalPersistentState (
50
54
extensionSurveyStateKeys . disableSurveyForTime ,
@@ -63,6 +67,7 @@ suite('Extension survey prompt - shouldShowBanner()', () => {
63
67
experiments . object ,
64
68
appEnvironment . object ,
65
69
platformService . object ,
70
+ workspaceService . object ,
66
71
10 ,
67
72
) ;
68
73
} ) ;
@@ -122,6 +127,23 @@ suite('Extension survey prompt - shouldShowBanner()', () => {
122
127
}
123
128
random . verifyAll ( ) ;
124
129
} ) ;
130
+ test ( 'Returns false if telemetry.disableFeedback is enabled' , async ( ) => {
131
+ disableSurveyForTime . setup ( ( d ) => d . value ) . returns ( ( ) => false ) ;
132
+ doNotShowAgain . setup ( ( d ) => d . value ) . returns ( ( ) => false ) ;
133
+
134
+ const telemetryConfig = TypeMoq . Mock . ofType < WorkspaceConfiguration > ( ) ;
135
+ workspaceService . setup ( ( w ) => w . getConfiguration ( 'telemetry' ) ) . returns ( ( ) => telemetryConfig . object ) ;
136
+ telemetryConfig
137
+ . setup ( ( t ) => t . get ( TypeMoq . It . isValue ( 'disableFeedback' ) , TypeMoq . It . isValue ( false ) ) )
138
+ . returns ( ( ) => true ) ;
139
+
140
+ const result = extensionSurveyPrompt . shouldShowBanner ( ) ;
141
+
142
+ expect ( result ) . to . equal ( false , 'Banner should not be shown when telemetry.disableFeedback is true' ) ;
143
+ workspaceService . verify ( ( w ) => w . getConfiguration ( 'telemetry' ) , TypeMoq . Times . once ( ) ) ;
144
+ telemetryConfig . verify ( ( t ) => t . get ( 'disableFeedback' , false ) , TypeMoq . Times . once ( ) ) ;
145
+ } ) ;
146
+
125
147
test ( 'Returns true if user is in the random sampling' , async ( ) => {
126
148
disableSurveyForTime . setup ( ( d ) => d . value ) . returns ( ( ) => false ) ;
127
149
doNotShowAgain . setup ( ( d ) => d . value ) . returns ( ( ) => false ) ;
@@ -142,6 +164,7 @@ suite('Extension survey prompt - shouldShowBanner()', () => {
142
164
experiments . object ,
143
165
appEnvironment . object ,
144
166
platformService . object ,
167
+ workspaceService . object ,
145
168
100 ,
146
169
) ;
147
170
disableSurveyForTime . setup ( ( d ) => d . value ) . returns ( ( ) => false ) ;
@@ -162,6 +185,7 @@ suite('Extension survey prompt - shouldShowBanner()', () => {
162
185
experiments . object ,
163
186
appEnvironment . object ,
164
187
platformService . object ,
188
+ workspaceService . object ,
165
189
0 ,
166
190
) ;
167
191
disableSurveyForTime . setup ( ( d ) => d . value ) . returns ( ( ) => false ) ;
@@ -186,6 +210,7 @@ suite('Extension survey prompt - showSurvey()', () => {
186
210
let platformService : TypeMoq . IMock < IPlatformService > ;
187
211
let appEnvironment : TypeMoq . IMock < IApplicationEnvironment > ;
188
212
let extensionSurveyPrompt : ExtensionSurveyPrompt ;
213
+ let workspaceService : TypeMoq . IMock < IWorkspaceService > ;
189
214
setup ( ( ) => {
190
215
appShell = TypeMoq . Mock . ofType < IApplicationShell > ( ) ;
191
216
browserService = TypeMoq . Mock . ofType < IBrowserService > ( ) ;
@@ -195,6 +220,7 @@ suite('Extension survey prompt - showSurvey()', () => {
195
220
doNotShowAgain = TypeMoq . Mock . ofType < IPersistentState < any > > ( ) ;
196
221
platformService = TypeMoq . Mock . ofType < IPlatformService > ( ) ;
197
222
appEnvironment = TypeMoq . Mock . ofType < IApplicationEnvironment > ( ) ;
223
+ workspaceService = TypeMoq . Mock . ofType < IWorkspaceService > ( ) ;
198
224
when (
199
225
persistentStateFactory . createGlobalPersistentState (
200
226
extensionSurveyStateKeys . disableSurveyForTime ,
@@ -214,6 +240,7 @@ suite('Extension survey prompt - showSurvey()', () => {
214
240
experiments . object ,
215
241
appEnvironment . object ,
216
242
platformService . object ,
243
+ workspaceService . object ,
217
244
10 ,
218
245
) ;
219
246
} ) ;
@@ -406,6 +433,7 @@ suite('Extension survey prompt - activate()', () => {
406
433
let extensionSurveyPrompt : ExtensionSurveyPrompt ;
407
434
let platformService : TypeMoq . IMock < IPlatformService > ;
408
435
let appEnvironment : TypeMoq . IMock < IApplicationEnvironment > ;
436
+ let workspaceService : TypeMoq . IMock < IWorkspaceService > ;
409
437
setup ( ( ) => {
410
438
appShell = TypeMoq . Mock . ofType < IApplicationShell > ( ) ;
411
439
browserService = TypeMoq . Mock . ofType < IBrowserService > ( ) ;
@@ -414,6 +442,7 @@ suite('Extension survey prompt - activate()', () => {
414
442
experiments = TypeMoq . Mock . ofType < IExperimentService > ( ) ;
415
443
platformService = TypeMoq . Mock . ofType < IPlatformService > ( ) ;
416
444
appEnvironment = TypeMoq . Mock . ofType < IApplicationEnvironment > ( ) ;
445
+ workspaceService = TypeMoq . Mock . ofType < IWorkspaceService > ( ) ;
417
446
} ) ;
418
447
419
448
teardown ( ( ) => {
@@ -431,6 +460,7 @@ suite('Extension survey prompt - activate()', () => {
431
460
experiments . object ,
432
461
appEnvironment . object ,
433
462
platformService . object ,
463
+ workspaceService . object ,
434
464
10 ,
435
465
) ;
436
466
experiments
@@ -460,6 +490,7 @@ suite('Extension survey prompt - activate()', () => {
460
490
experiments . object ,
461
491
appEnvironment . object ,
462
492
platformService . object ,
493
+ workspaceService . object ,
463
494
10 ,
464
495
50 ,
465
496
) ;
@@ -494,6 +525,7 @@ suite('Extension survey prompt - activate()', () => {
494
525
experiments . object ,
495
526
appEnvironment . object ,
496
527
platformService . object ,
528
+ workspaceService . object ,
497
529
10 ,
498
530
50 ,
499
531
) ;
0 commit comments