Skip to content

Commit b269381

Browse files
committed
tst
1 parent 3083846 commit b269381

File tree

9 files changed

+24
-114
lines changed

9 files changed

+24
-114
lines changed

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
session,
1414
CodeWhispererTracker,
1515
RecommendationHandler,
16-
CodeWhispererUserGroupSettings,
1716
AuthUtil,
1817
} from 'aws-core-vscode/codewhisperer'
1918
import { resetCodeWhispererGlobalVariables, createMockTextEditor } from 'aws-core-vscode/test'
@@ -31,7 +30,6 @@ describe('onAcceptance', function () {
3130
afterEach(function () {
3231
sinon.restore()
3332
session.reset()
34-
CodeWhispererUserGroupSettings.instance.reset()
3533
})
3634

3735
it('Should enqueue an event object to tracker', async function () {
@@ -117,7 +115,6 @@ describe('onAcceptance', function () {
117115
codewhispererCompletionType: 'Line',
118116
codewhispererLanguage: 'python',
119117
credentialStartUrl: testStartUrl,
120-
codewhispererUserGroup: 'Control',
121118
})
122119
})
123120
})

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/recommendationHandler.test.ts

Lines changed: 0 additions & 15 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 {
@@ -55,7 +53,6 @@ describe('recommendationHandler', function () {
5553

5654
afterEach(function () {
5755
sinon.restore()
58-
CodeWhispererUserGroupSettings.instance.reset()
5956
})
6057

6158
it('should assign correct recommendations given input', async function () {
@@ -110,11 +107,6 @@ describe('recommendationHandler', function () {
110107
})
111108

112109
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-
118110
const mockServerResult = {
119111
recommendations: [{ content: "print('Hello World!')" }, { content: '' }],
120112
$response: {
@@ -157,16 +149,10 @@ describe('recommendationHandler', function () {
157149
codewhispererSupplementalContextTimeout: false,
158150
codewhispererSupplementalContextLatency: 0,
159151
codewhispererSupplementalContextLength: 100,
160-
codewhispererUserGroup: 'CrossFile',
161152
})
162153
})
163154

164155
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-
170156
const mockServerResult = {
171157
recommendations: [],
172158
nextToken: '',
@@ -198,7 +184,6 @@ describe('recommendationHandler', function () {
198184
codewhispererCompletionType: 'Line',
199185
codewhispererLanguage: 'python',
200186
credentialStartUrl: testStartUrl,
201-
codewhispererUserGroup: 'CrossFile',
202187
})
203188
})
204189
})

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: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,7 @@
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'
1811
import { globals, extensionVersion } from 'aws-core-vscode/shared'
1912
import { assertTelemetryCurried } from 'aws-core-vscode/test'
@@ -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: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ describe('codewhispererTracker', function () {
114114
codewhispererCompletionType: 'Line',
115115
codewhispererLanguage: 'java',
116116
credentialStartUrl: testStartUrl,
117-
codewhispererUserGroup: 'CrossFile',
118117
codewhispererCharactersAccepted: suggestion.originalString.length,
119118
codewhispererCharactersModified: 0,
120119
})

packages/amazonq/test/unit/codewhisperer/util/crossFileContextUtil.test.ts

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import * as vscode from 'vscode'
88
import * as sinon from 'sinon'
99
import * as crossFile from 'aws-core-vscode/codewhisperer'
1010
import { createMockTextEditor } from 'aws-core-vscode/test'
11-
import { CodeWhispererUserGroupSettings, UserGroup, crossFileContextConfig } from 'aws-core-vscode/codewhisperer'
11+
import { crossFileContextConfig } from 'aws-core-vscode/codewhisperer'
1212
import {
1313
assertTabCount,
1414
closeAllEditors,
@@ -20,7 +20,6 @@ import {
2020
import { areEqual, normalize } from 'aws-core-vscode/shared'
2121
import * as path from 'path'
2222

23-
const userGroupSettings = CodeWhispererUserGroupSettings.instance
2423
let tempFolder: string
2524

2625
describe('crossFileContextUtil', function () {
@@ -36,30 +35,18 @@ describe('crossFileContextUtil', function () {
3635
tempFolder = (await createTestWorkspaceFolder()).uri.fsPath
3736
})
3837

39-
describe('should fetch 3 chunks and each chunk should contains 10 lines', function () {
40-
async function assertCorrectCodeChunk() {
41-
await openATextEditorWithText(sampleFileOf60Lines, 'CrossFile.java', tempFolder, { preview: false })
42-
const myCurrentEditor = await openATextEditorWithText('', 'TargetFile.java', tempFolder, {
43-
preview: false,
44-
})
45-
const actual = await crossFile.fetchSupplementalContextForSrc(myCurrentEditor, fakeCancellationToken)
46-
assert.ok(actual)
47-
assert.ok(actual.supplementalContextItems.length === 3)
48-
49-
assert.strictEqual(actual.supplementalContextItems[0].content.split('\n').length, 10)
50-
assert.strictEqual(actual.supplementalContextItems[1].content.split('\n').length, 10)
51-
assert.strictEqual(actual.supplementalContextItems[2].content.split('\n').length, 10)
52-
}
53-
54-
it('control group', async function () {
55-
CodeWhispererUserGroupSettings.instance.userGroup = UserGroup.Control
56-
await assertCorrectCodeChunk()
38+
it('should fetch 3 chunks and each chunk should contains 10 lines', async function () {
39+
await openATextEditorWithText(sampleFileOf60Lines, 'CrossFile.java', tempFolder, { preview: false })
40+
const myCurrentEditor = await openATextEditorWithText('', 'TargetFile.java', tempFolder, {
41+
preview: false,
5742
})
43+
const actual = await crossFile.fetchSupplementalContextForSrc(myCurrentEditor, fakeCancellationToken)
44+
assert.ok(actual)
45+
assert.ok(actual.supplementalContextItems.length === 3)
5846

59-
it('treatment group', async function () {
60-
CodeWhispererUserGroupSettings.instance.userGroup = UserGroup.CrossFile
61-
await assertCorrectCodeChunk()
62-
})
47+
assert.strictEqual(actual.supplementalContextItems[0].content.split('\n').length, 10)
48+
assert.strictEqual(actual.supplementalContextItems[1].content.split('\n').length, 10)
49+
assert.strictEqual(actual.supplementalContextItems[2].content.split('\n').length, 10)
6350
})
6451
})
6552

@@ -145,7 +132,6 @@ describe('crossFileContextUtil', function () {
145132

146133
before(async function () {
147134
this.timeout(60000)
148-
userGroupSettings.userGroup = UserGroup.Control
149135
})
150136

151137
beforeEach(async function () {
@@ -177,7 +163,6 @@ describe('crossFileContextUtil', function () {
177163

178164
before(async function () {
179165
this.timeout(60000)
180-
userGroupSettings.userGroup = UserGroup.CrossFile
181166
})
182167

183168
beforeEach(async function () {

packages/amazonq/test/unit/codewhisperer/util/telemetryHelper.test.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55

66
import assert from 'assert'
77
import { assertTelemetryCurried, resetCodeWhispererGlobalVariables } from 'aws-core-vscode/test'
8-
import { TelemetryHelper, CodeWhispererUserGroupSettings, Completion, session } from 'aws-core-vscode/codewhisperer'
9-
import * as CodeWhispererConstants from 'aws-core-vscode/codewhisperer'
8+
import { TelemetryHelper, Completion, session } from 'aws-core-vscode/codewhisperer'
109
import {
1110
CodewhispererCompletionType,
1211
CodewhispererSuggestionState,
@@ -29,7 +28,6 @@ function aUserDecision(
2928
codewhispererSuggestionState: codewhispererSuggestionState,
3029
codewhispererTriggerType: 'OnDemand',
3130
credentialStartUrl: 'https://www.amazon.com',
32-
codewhispererUserGroup: 'Control',
3331
}
3432
}
3533

@@ -96,7 +94,6 @@ describe('telemetryHelper', function () {
9694
beforeEach(async function () {
9795
await resetCodeWhispererGlobalVariables()
9896
sut = new TelemetryHelper()
99-
CodeWhispererUserGroupSettings.instance.userGroup = CodeWhispererConstants.UserGroup.Control
10097
})
10198

10299
it('should return Line and Accept', function () {
@@ -126,7 +123,6 @@ describe('telemetryHelper', function () {
126123
codewhispererSuggestionCount: 4,
127124
codewhispererSuggestionImportCount: 0,
128125
codewhispererSuggestionState: 'Accept',
129-
codewhispererUserGroup: 'Control',
130126
codewhispererCompletionType: 'Line',
131127
codewhispererTypeaheadLength: 0,
132128
codewhispererCharactersAccepted: aCompletion().content.length,
@@ -160,7 +156,6 @@ describe('telemetryHelper', function () {
160156
codewhispererSuggestionCount: 4,
161157
codewhispererSuggestionImportCount: 0,
162158
codewhispererSuggestionState: 'Accept',
163-
codewhispererUserGroup: 'Control',
164159
codewhispererCompletionType: 'Line',
165160
codewhispererTypeaheadLength: 0,
166161
codewhispererCharactersAccepted: aCompletion().content.length,
@@ -194,7 +189,6 @@ describe('telemetryHelper', function () {
194189
codewhispererSuggestionCount: 4,
195190
codewhispererSuggestionImportCount: 0,
196191
codewhispererSuggestionState: 'Reject',
197-
codewhispererUserGroup: 'Control',
198192
codewhispererCompletionType: 'Line',
199193
codewhispererTypeaheadLength: 0,
200194
codewhispererCharactersAccepted: 0,
@@ -252,13 +246,7 @@ describe('telemetryHelper', function () {
252246
await resetCodeWhispererGlobalVariables()
253247
})
254248

255-
afterEach(function () {
256-
CodeWhispererUserGroupSettings.instance.reset()
257-
})
258-
259249
it('Should call telemetry record for each recommendations with proper arguments', async function () {
260-
CodeWhispererUserGroupSettings.instance.userGroup = CodeWhispererConstants.UserGroup.Classifier
261-
262250
const telemetryHelper = new TelemetryHelper()
263251
const response = [{ content: "print('Hello')" }]
264252
const requestIdList = ['test_x', 'test_x', 'test_y']
@@ -286,7 +274,6 @@ describe('telemetryHelper', function () {
286274
codewhispererSuggestionReferenceCount: 0,
287275
codewhispererCompletionType: 'Line',
288276
codewhispererLanguage: 'python',
289-
codewhispererUserGroup: 'Classifier',
290277
})
291278
})
292279
})

0 commit comments

Comments
 (0)