Skip to content

Commit

Permalink
fix flaky crossfileContextUtil.test
Browse files Browse the repository at this point in the history
  • Loading branch information
Will-ShaoHua committed Nov 15, 2024
1 parent 9eb37d2 commit 27e1880
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ describe('crossFileContextUtil', function () {
describe('fetchSupplementalContextForSrc', function () {
beforeEach(async function () {
tempFolder = (await createTestWorkspaceFolder()).uri.fsPath
sinon.restore()
})

afterEach(async function () {
Expand All @@ -50,10 +51,12 @@ describe('crossFileContextUtil', function () {
const myCurrentEditor = await toTextEditor('', 'TargetFile.java', tempFolder, {
preview: false,
})

await assertTabCount(2)

const actual = await crossFile.fetchSupplementalContextForSrc(myCurrentEditor, fakeCancellationToken)
assert.ok(actual)
assert.ok(actual.supplementalContextItems.length === 3)

assert.strictEqual(actual.supplementalContextItems.length, 3)
assert.strictEqual(actual.supplementalContextItems[0].content.split('\n').length, 50)
assert.strictEqual(actual.supplementalContextItems[1].content.split('\n').length, 50)
assert.strictEqual(actual.supplementalContextItems[2].content.split('\n').length, 50)
Expand All @@ -64,6 +67,9 @@ describe('crossFileContextUtil', function () {
const myCurrentEditor = await toTextEditor('', 'TargetFile.java', tempFolder, {
preview: false,
})

await assertTabCount(2)

sinon.stub(FeatureConfigProvider.instance, 'getProjectContextGroup').returns('t1')
sinon
.stub(LspController.instance, 'queryInlineProjectContext')
Expand All @@ -78,7 +84,7 @@ describe('crossFileContextUtil', function () {

const actual = await crossFile.fetchSupplementalContextForSrc(myCurrentEditor, fakeCancellationToken)
assert.ok(actual)
assert.ok(actual.supplementalContextItems.length === 4)
assert.strictEqual(actual.supplementalContextItems.length, 4)
assert.strictEqual(actual?.strategy, 'codemap')
assert.deepEqual(actual?.supplementalContextItems[0], {
content: 'foo',
Expand All @@ -96,6 +102,9 @@ describe('crossFileContextUtil', function () {
const myCurrentEditor = await toTextEditor('', 'TargetFile.java', tempFolder, {
preview: false,
})

await assertTabCount(2)

sinon.stub(FeatureConfigProvider.instance, 'getProjectContextGroup').returns('t2')
sinon
.stub(LspController.instance, 'queryInlineProjectContext')
Expand Down Expand Up @@ -130,7 +139,7 @@ describe('crossFileContextUtil', function () {

const actual = await crossFile.fetchSupplementalContextForSrc(myCurrentEditor, fakeCancellationToken)
assert.ok(actual)
assert.ok(actual.supplementalContextItems.length === 5)
assert.strictEqual(actual.supplementalContextItems.length, 5)
assert.strictEqual(actual?.strategy, 'bm25')

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

0 comments on commit 27e1880

Please sign in to comment.