Skip to content

Commit db4bf31

Browse files
authored
refactor(codewhisperer): remove usage of UserGroupSettings (#5643)
## Problem Remove *ALL* usage of userGroupSettings as we're pivoting to `featureConfigProvider.ts` ## Solution --- <!--- REMINDER: Ensure that your PR meets the guidelines in CONTRIBUTING.md --> License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 699919d commit db4bf31

16 files changed

+36
-194
lines changed

packages/amazonq/test/unit/codewhisperer/commands/onAcceptance.test.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,14 @@ import * as vscode from 'vscode'
88
import * as sinon from 'sinon'
99
import {
1010
onAcceptance,
11-
UserGroup,
1211
AcceptedSuggestionEntry,
1312
session,
1413
CodeWhispererTracker,
1514
RecommendationHandler,
16-
CodeWhispererUserGroupSettings,
1715
AuthUtil,
1816
} from 'aws-core-vscode/codewhisperer'
1917
import { resetCodeWhispererGlobalVariables, createMockTextEditor } from 'aws-core-vscode/test'
2018
import { assertTelemetryCurried } from 'aws-core-vscode/test'
21-
import { globals } from 'aws-core-vscode/shared'
22-
import { extensionVersion } from 'aws-core-vscode/shared'
2319

2420
describe('onAcceptance', function () {
2521
describe('onAcceptance', function () {
@@ -31,7 +27,6 @@ describe('onAcceptance', function () {
3127
afterEach(function () {
3228
sinon.restore()
3329
session.reset()
34-
CodeWhispererUserGroupSettings.instance.reset()
3530
})
3631

3732
it('Should enqueue an event object to tracker', async function () {
@@ -75,11 +70,6 @@ describe('onAcceptance', function () {
7570
})
7671

7772
it('Should report telemetry that records this user decision event', async function () {
78-
await globals.globalState.update('CODEWHISPERER_USER_GROUP', {
79-
group: UserGroup.Control,
80-
version: extensionVersion,
81-
})
82-
8373
const testStartUrl = 'testStartUrl'
8474
sinon.stub(AuthUtil.instance, 'startUrl').value(testStartUrl)
8575
const mockEditor = createMockTextEditor()
@@ -117,7 +107,6 @@ describe('onAcceptance', function () {
117107
codewhispererCompletionType: 'Line',
118108
codewhispererLanguage: 'python',
119109
credentialStartUrl: testStartUrl,
120-
codewhispererUserGroup: 'Control',
121110
})
122111
})
123112
})

packages/amazonq/test/unit/codewhisperer/commands/onInlineAcceptance.test.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,7 @@ import * as vscode from 'vscode'
88
import * as sinon from 'sinon'
99
import { resetCodeWhispererGlobalVariables, createMockTextEditor } from 'aws-core-vscode/test'
1010
import { assertTelemetryCurried } from 'aws-core-vscode/test'
11-
import {
12-
onInlineAcceptance,
13-
RecommendationHandler,
14-
AuthUtil,
15-
session,
16-
CodeWhispererUserGroupSettings,
17-
UserGroup,
18-
} from 'aws-core-vscode/codewhisperer'
11+
import { onInlineAcceptance, RecommendationHandler, AuthUtil, session } from 'aws-core-vscode/codewhisperer'
1912
import { globals } from 'aws-core-vscode/shared'
2013
import { extensionVersion } from 'aws-core-vscode/shared'
2114

@@ -29,7 +22,6 @@ describe('onInlineAcceptance', function () {
2922
afterEach(function () {
3023
sinon.restore()
3124
session.reset()
32-
CodeWhispererUserGroupSettings.instance.reset()
3325
})
3426

3527
it('Should dispose inline completion provider', async function () {
@@ -53,7 +45,6 @@ describe('onInlineAcceptance', function () {
5345

5446
it('Should report telemetry that records this user decision event', async function () {
5547
await globals.globalState.update('CODEWHISPERER_USER_GROUP', {
56-
group: UserGroup.Classifier,
5748
version: extensionVersion,
5849
})
5950

@@ -95,7 +86,6 @@ describe('onInlineAcceptance', function () {
9586
codewhispererCompletionType: 'Line',
9687
codewhispererLanguage: 'python',
9788
credentialStartUrl: testStartUrl,
98-
codewhispererUserGroup: 'Classifier',
9989
})
10090
})
10191
})

packages/amazonq/test/unit/codewhisperer/service/keyStrokeHandler.test.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@ import {
1313
resetCodeWhispererGlobalVariables,
1414
} from 'aws-core-vscode/test'
1515
import * as EditorContext from 'aws-core-vscode/codewhisperer'
16-
import * as CodeWhispererConstants from 'aws-core-vscode/codewhisperer'
1716
import {
1817
ConfigurationEntry,
1918
DocumentChangedSource,
2019
KeyStrokeHandler,
2120
DefaultDocumentChangedType,
2221
RecommendationService,
23-
CodeWhispererUserGroupSettings,
2422
ClassifierTrigger,
2523
isInlineCompletionEnabled,
2624
RecommendationHandler,
@@ -52,7 +50,6 @@ describe('keyStrokeHandler', function () {
5250
})
5351
afterEach(function () {
5452
sinon.restore()
55-
CodeWhispererUserGroupSettings.instance.reset()
5653
})
5754

5855
it('Whatever the input is, should skip when automatic trigger is turned off, should not call invokeAutomatedTrigger', async function () {
@@ -145,19 +142,13 @@ describe('keyStrokeHandler', function () {
145142
}
146143
})
147144

148-
async function testShouldInvoke(
149-
input: string,
150-
shouldTrigger: boolean,
151-
rightContext: string = '',
152-
userGroup: CodeWhispererConstants.UserGroup = CodeWhispererConstants.UserGroup.Control
153-
) {
145+
async function testShouldInvoke(input: string, shouldTrigger: boolean, rightContext: string = '') {
154146
const mockEditor = createMockTextEditor(rightContext, 'test.js', 'javascript', 0, 0)
155147
const mockEvent: vscode.TextDocumentChangeEvent = createTextDocumentChangeEvent(
156148
mockEditor.document,
157149
new vscode.Range(new vscode.Position(0, 0), new vscode.Position(0, 1)),
158150
input
159151
)
160-
CodeWhispererUserGroupSettings.instance.userGroup = userGroup
161152
await KeyStrokeHandler.instance.processKeyStroke(mockEvent, mockEditor, mockClient, config)
162153
assert.strictEqual(
163154
invokeSpy.called,

packages/amazonq/test/unit/codewhisperer/service/recommendationHandler.test.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@ import {
1010
ReferenceInlineProvider,
1111
session,
1212
AuthUtil,
13-
CodeWhispererUserGroupSettings,
1413
DefaultCodeWhispererClient,
1514
RecommendationsList,
1615
ConfigurationEntry,
1716
RecommendationHandler,
1817
CodeWhispererCodeCoverageTracker,
19-
UserGroup,
2018
supplementalContextUtil,
2119
} from 'aws-core-vscode/codewhisperer'
2220
import {
@@ -26,7 +24,6 @@ import {
2624
resetCodeWhispererGlobalVariables,
2725
} from 'aws-core-vscode/test'
2826
// import * as supplementalContextUtil from 'aws-core-vscode/codewhisperer'
29-
import { globals, extensionVersion } from 'aws-core-vscode/shared'
3027

3128
describe('recommendationHandler', function () {
3229
const config: ConfigurationEntry = {
@@ -55,7 +52,6 @@ describe('recommendationHandler', function () {
5552

5653
afterEach(function () {
5754
sinon.restore()
58-
CodeWhispererUserGroupSettings.instance.reset()
5955
})
6056

6157
it('should assign correct recommendations given input', async function () {
@@ -110,11 +106,6 @@ describe('recommendationHandler', function () {
110106
})
111107

112108
it('should call telemetry function that records a CodeWhisperer service invocation', async function () {
113-
await globals.globalState.update('CODEWHISPERER_USER_GROUP', {
114-
group: UserGroup.CrossFile,
115-
version: extensionVersion,
116-
})
117-
118109
const mockServerResult = {
119110
recommendations: [{ content: "print('Hello World!')" }, { content: '' }],
120111
$response: {
@@ -157,16 +148,10 @@ describe('recommendationHandler', function () {
157148
codewhispererSupplementalContextTimeout: false,
158149
codewhispererSupplementalContextLatency: 0,
159150
codewhispererSupplementalContextLength: 100,
160-
codewhispererUserGroup: 'CrossFile',
161151
})
162152
})
163153

164154
it('should call telemetry function that records a Empty userDecision event', async function () {
165-
await globals.globalState.update('CODEWHISPERER_USER_GROUP', {
166-
group: UserGroup.CrossFile,
167-
version: extensionVersion,
168-
})
169-
170155
const mockServerResult = {
171156
recommendations: [],
172157
nextToken: '',
@@ -198,7 +183,6 @@ describe('recommendationHandler', function () {
198183
codewhispererCompletionType: 'Line',
199184
codewhispererLanguage: 'python',
200185
credentialStartUrl: testStartUrl,
201-
codewhispererUserGroup: 'CrossFile',
202186
})
203187
})
204188
})

packages/amazonq/test/unit/codewhisperer/service/telemetry.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ describe.skip('CodeWhisperer telemetry', async function () {
5353
codewhispererSuggestionState: 'Accept',
5454
codewhispererSuggestionImportCount: 0,
5555
codewhispererTypeaheadLength: 0,
56-
codewhispererUserGroup: 'Control',
5756
...ops,
5857
}
5958
}

packages/amazonq/test/unit/codewhisperer/tracker/codewhispererCodeCoverageTracker.test.ts

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,9 @@
66
import assert from 'assert'
77
import * as sinon from 'sinon'
88
import * as vscode from 'vscode'
9-
import {
10-
CodeWhispererCodeCoverageTracker,
11-
vsCodeState,
12-
TelemetryHelper,
13-
AuthUtil,
14-
UserGroup,
15-
CodeWhispererUserGroupSettings,
16-
} from 'aws-core-vscode/codewhisperer'
9+
import { CodeWhispererCodeCoverageTracker, vsCodeState, TelemetryHelper, AuthUtil } from 'aws-core-vscode/codewhisperer'
1710
import { createMockDocument, createMockTextEditor, resetCodeWhispererGlobalVariables } from 'aws-core-vscode/test'
18-
import { globals, extensionVersion } from 'aws-core-vscode/shared'
11+
import { globals } from 'aws-core-vscode/shared'
1912
import { assertTelemetryCurried } from 'aws-core-vscode/test'
2013

2114
describe('codewhispererCodecoverageTracker', function () {
@@ -516,21 +509,14 @@ describe('codewhispererCodecoverageTracker', function () {
516509
if (tracker) {
517510
sinon.stub(tracker, 'isActive').returns(true)
518511
}
519-
CodeWhispererUserGroupSettings.instance.reset()
520512
})
521513

522514
afterEach(function () {
523515
sinon.restore()
524516
CodeWhispererCodeCoverageTracker.instances.clear()
525-
CodeWhispererUserGroupSettings.instance.reset()
526517
})
527518

528519
it('should emit correct code coverage telemetry in python file', async function () {
529-
await globals.globalState.update('CODEWHISPERER_USER_GROUP', {
530-
group: UserGroup.Control,
531-
version: extensionVersion,
532-
})
533-
534520
const tracker = CodeWhispererCodeCoverageTracker.getTracker(language)
535521

536522
const assertTelemetry = assertTelemetryCurried('codewhisperer_codePercentage')
@@ -545,16 +531,10 @@ describe('codewhispererCodecoverageTracker', function () {
545531
codewhispererSuggestedTokens: 7,
546532
codewhispererPercentage: 7,
547533
successCount: 1,
548-
codewhispererUserGroup: 'Control',
549534
})
550535
})
551536

552537
it('should emit correct code coverage telemetry when success count = 0', async function () {
553-
await globals.globalState.update('CODEWHISPERER_USER_GROUP', {
554-
group: UserGroup.Control,
555-
version: extensionVersion,
556-
})
557-
558538
const tracker = CodeWhispererCodeCoverageTracker.getTracker('java')
559539

560540
const assertTelemetry = assertTelemetryCurried('codewhisperer_codePercentage')
@@ -574,7 +554,6 @@ describe('codewhispererCodecoverageTracker', function () {
574554
codewhispererSuggestedTokens: 18,
575555
codewhispererPercentage: 60,
576556
successCount: 2,
577-
codewhispererUserGroup: 'Control',
578557
})
579558
})
580559
})

packages/amazonq/test/unit/codewhisperer/tracker/codewhispererTracker.test.ts

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,9 @@
66
import assert from 'assert'
77
import * as sinon from 'sinon'
88
import { assertTelemetryCurried } from 'aws-core-vscode/test'
9-
import {
10-
AuthUtil,
11-
CodeWhispererTracker,
12-
UserGroup,
13-
CodeWhispererUserGroupSettings,
14-
} from 'aws-core-vscode/codewhisperer'
9+
import { AuthUtil, CodeWhispererTracker } from 'aws-core-vscode/codewhisperer'
1510
import { resetCodeWhispererGlobalVariables, createAcceptedSuggestionEntry } from 'aws-core-vscode/test'
16-
import { globals, extensionVersion } from 'aws-core-vscode/shared'
11+
import { globals } from 'aws-core-vscode/shared'
1712

1813
describe('codewhispererTracker', function () {
1914
describe('enqueue', function () {
@@ -86,20 +81,7 @@ describe('codewhispererTracker', function () {
8681
})
8782

8883
describe('emitTelemetryOnSuggestion', function () {
89-
beforeEach(function () {
90-
CodeWhispererUserGroupSettings.instance.reset()
91-
})
92-
93-
afterEach(function () {
94-
CodeWhispererUserGroupSettings.instance.reset()
95-
})
96-
9784
it('Should call recordCodewhispererUserModification with suggestion event', async function () {
98-
await globals.globalState.update('CODEWHISPERER_USER_GROUP', {
99-
group: UserGroup.CrossFile,
100-
version: extensionVersion,
101-
})
102-
10385
const testStartUrl = 'testStartUrl'
10486
sinon.stub(AuthUtil.instance, 'startUrl').value(testStartUrl)
10587
const suggestion = createAcceptedSuggestionEntry()
@@ -114,7 +96,6 @@ describe('codewhispererTracker', function () {
11496
codewhispererCompletionType: 'Line',
11597
codewhispererLanguage: 'java',
11698
credentialStartUrl: testStartUrl,
117-
codewhispererUserGroup: 'CrossFile',
11899
codewhispererCharactersAccepted: suggestion.originalString.length,
119100
codewhispererCharactersModified: 0,
120101
})

0 commit comments

Comments
 (0)