Skip to content

Commit 27e1880

Browse files
committed
fix flaky crossfileContextUtil.test
1 parent 9eb37d2 commit 27e1880

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ describe('crossFileContextUtil', function () {
3838
describe('fetchSupplementalContextForSrc', function () {
3939
beforeEach(async function () {
4040
tempFolder = (await createTestWorkspaceFolder()).uri.fsPath
41+
sinon.restore()
4142
})
4243

4344
afterEach(async function () {
@@ -50,10 +51,12 @@ describe('crossFileContextUtil', function () {
5051
const myCurrentEditor = await toTextEditor('', 'TargetFile.java', tempFolder, {
5152
preview: false,
5253
})
54+
55+
await assertTabCount(2)
56+
5357
const actual = await crossFile.fetchSupplementalContextForSrc(myCurrentEditor, fakeCancellationToken)
5458
assert.ok(actual)
55-
assert.ok(actual.supplementalContextItems.length === 3)
56-
59+
assert.strictEqual(actual.supplementalContextItems.length, 3)
5760
assert.strictEqual(actual.supplementalContextItems[0].content.split('\n').length, 50)
5861
assert.strictEqual(actual.supplementalContextItems[1].content.split('\n').length, 50)
5962
assert.strictEqual(actual.supplementalContextItems[2].content.split('\n').length, 50)
@@ -64,6 +67,9 @@ describe('crossFileContextUtil', function () {
6467
const myCurrentEditor = await toTextEditor('', 'TargetFile.java', tempFolder, {
6568
preview: false,
6669
})
70+
71+
await assertTabCount(2)
72+
6773
sinon.stub(FeatureConfigProvider.instance, 'getProjectContextGroup').returns('t1')
6874
sinon
6975
.stub(LspController.instance, 'queryInlineProjectContext')
@@ -78,7 +84,7 @@ describe('crossFileContextUtil', function () {
7884

7985
const actual = await crossFile.fetchSupplementalContextForSrc(myCurrentEditor, fakeCancellationToken)
8086
assert.ok(actual)
81-
assert.ok(actual.supplementalContextItems.length === 4)
87+
assert.strictEqual(actual.supplementalContextItems.length, 4)
8288
assert.strictEqual(actual?.strategy, 'codemap')
8389
assert.deepEqual(actual?.supplementalContextItems[0], {
8490
content: 'foo',
@@ -96,6 +102,9 @@ describe('crossFileContextUtil', function () {
96102
const myCurrentEditor = await toTextEditor('', 'TargetFile.java', tempFolder, {
97103
preview: false,
98104
})
105+
106+
await assertTabCount(2)
107+
99108
sinon.stub(FeatureConfigProvider.instance, 'getProjectContextGroup').returns('t2')
100109
sinon
101110
.stub(LspController.instance, 'queryInlineProjectContext')
@@ -130,7 +139,7 @@ describe('crossFileContextUtil', function () {
130139

131140
const actual = await crossFile.fetchSupplementalContextForSrc(myCurrentEditor, fakeCancellationToken)
132141
assert.ok(actual)
133-
assert.ok(actual.supplementalContextItems.length === 5)
142+
assert.strictEqual(actual.supplementalContextItems.length, 5)
134143
assert.strictEqual(actual?.strategy, 'bm25')
135144

136145
assert.deepEqual(actual?.supplementalContextItems[0], {

0 commit comments

Comments
 (0)