Skip to content

Commit 201b070

Browse files
committed
test
1 parent 380d12c commit 201b070

File tree

3 files changed

+43
-3
lines changed

3 files changed

+43
-3
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe('crossFileContextUtil', function () {
4040
})
4141

4242
it('opentabs context should fetch 3 chunks and each chunk should contains 50 lines', async function () {
43-
sinon.stub(FeatureConfigProvider.instance, 'isNewProjectContextGroup').alwaysReturned(false)
43+
sinon.stub(FeatureConfigProvider.instance, 'getProjectContextGroup').alwaysReturned('control')
4444
await toTextEditor(aStringWithLineCount(200), 'CrossFile.java', tempFolder, { preview: false })
4545
const myCurrentEditor = await toTextEditor('', 'TargetFile.java', tempFolder, {
4646
preview: false,
@@ -212,7 +212,7 @@ describe('crossFileContextUtil', function () {
212212

213213
fileExtLists.forEach((fileExt) => {
214214
it('should be non empty', async function () {
215-
sinon.stub(FeatureConfigProvider.instance, 'isNewProjectContextGroup').alwaysReturned(false)
215+
sinon.stub(FeatureConfigProvider.instance, 'getProjectContextGroup').alwaysReturned('control')
216216
const editor = await toTextEditor('content-1', `file-1.${fileExt}`, tempFolder)
217217
await toTextEditor('content-2', `file-2.${fileExt}`, tempFolder, { preview: false })
218218
await toTextEditor('content-3', `file-3.${fileExt}`, tempFolder, { preview: false })

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('supplementalContextUtil', function () {
2121

2222
beforeEach(async function () {
2323
testFolder = await TestFolder.create()
24-
sinon.stub(FeatureConfigProvider.instance, 'isNewProjectContextGroup').alwaysReturned(false)
24+
sinon.stub(FeatureConfigProvider.instance, 'getProjectContextGroup').alwaysReturned('control')
2525
})
2626

2727
afterEach(function () {

packages/core/src/test/shared/featureConfig.test.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,44 @@ describe('FeatureConfigProvider', () => {
9494
it('should test feature-does-not-exist as disabled', async () => {
9595
assert.strictEqual(FeatureConfigProvider.isEnabled('feature-does-not-exist' as FeatureName), false)
9696
})
97+
98+
describe('getProjectContextGroup', function () {
99+
beforeEach(function () {
100+
sinon.restore()
101+
})
102+
103+
afterEach(function () {
104+
sinon.restore()
105+
})
106+
107+
const cases: { variationName: string; expected: string }[] = [
108+
{ variationName: 'CONTROL', expected: 'control' },
109+
{ variationName: 'TREATMENT_1', expected: 't1' },
110+
{ variationName: 'TREATMENT_2', expected: 't2' },
111+
]
112+
113+
for (const tuple of cases) {
114+
it(`should return ${tuple.expected} when variation name is ${tuple.variationName}`, async function () {
115+
const clientSpy = await createSpyClient()
116+
sinon.stub(clientSpy, 'listFeatureEvaluations').returns({
117+
promise: () =>
118+
Promise.resolve({
119+
$response: {
120+
requestId: '',
121+
},
122+
featureEvaluations: [
123+
{
124+
feature: 'ProjectContextV2',
125+
variation: tuple.variationName,
126+
value: { stringValue: 'foo' },
127+
},
128+
],
129+
}),
130+
} as Request<ListFeatureEvaluationsResponse, AWSError>)
131+
await FeatureConfigProvider.instance.fetchFeatureConfigs()
132+
133+
assert.strictEqual(FeatureConfigProvider.instance.getProjectContextGroup(), tuple.expected)
134+
})
135+
}
136+
})
97137
})

0 commit comments

Comments
 (0)