mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[Code] Reenable lsp_indexer mocha tests and incooporate language filter test cases (#37266) (#37296)
This commit is contained in:
parent
11cdfa16fe
commit
5a66d9b225
1 changed files with 41 additions and 21 deletions
|
@ -57,7 +57,7 @@ function prepareProject(url: string, p: string) {
|
|||
});
|
||||
}
|
||||
|
||||
const repoUri = 'github.com/Microsoft/TypeScript-Node-Starter';
|
||||
const repoUri = 'github.com/elastic/TypeScript-Node-Starter';
|
||||
|
||||
const serverOptions = createTestServerOption();
|
||||
|
||||
|
@ -73,7 +73,7 @@ function setupEsClientSpy() {
|
|||
Promise.resolve({
|
||||
_source: {
|
||||
[RepositoryGitStatusReservedField]: {
|
||||
uri: 'github.com/Microsoft/TypeScript-Node-Starter',
|
||||
uri: repoUri,
|
||||
progress: WorkerReservedProgress.COMPLETED,
|
||||
timestamp: new Date(),
|
||||
cloneProgress: {
|
||||
|
@ -125,8 +125,7 @@ function setupLsServiceSendRequestSpy(): sinon.SinonSpy {
|
|||
);
|
||||
}
|
||||
|
||||
// FAILING https://github.com/elastic/kibana/issues/36478
|
||||
describe.skip('lsp_indexer unit tests', function(this: any) {
|
||||
describe('lsp_indexer unit tests', function(this: any) {
|
||||
this.timeout(20000);
|
||||
|
||||
// @ts-ignore
|
||||
|
@ -140,7 +139,7 @@ describe.skip('lsp_indexer unit tests', function(this: any) {
|
|||
// @ts-ignore
|
||||
this.timeout(200000);
|
||||
return await prepareProject(
|
||||
'https://github.com/Microsoft/TypeScript-Node-Starter.git',
|
||||
`https://${repoUri}.git`,
|
||||
path.join(serverOptions.repoPath, repoUri)
|
||||
);
|
||||
});
|
||||
|
@ -172,10 +171,18 @@ describe.skip('lsp_indexer unit tests', function(this: any) {
|
|||
new RepositoryConfigController(esClient as EsClient)
|
||||
);
|
||||
|
||||
lspservice.sendRequest = setupLsServiceSendRequestSpy();
|
||||
const lspSendRequestSpy = setupLsServiceSendRequestSpy();
|
||||
lspservice.sendRequest = lspSendRequestSpy;
|
||||
const supportLanguageSpy = sinon.stub();
|
||||
|
||||
// Setup supported languages, so that unsupported source files won't be
|
||||
// sent for lsp requests.
|
||||
supportLanguageSpy.withArgs('javascript').returns(true);
|
||||
supportLanguageSpy.withArgs('typescript').returns(true);
|
||||
lspservice.supportLanguage = supportLanguageSpy;
|
||||
|
||||
const indexer = new LspIndexer(
|
||||
'github.com/Microsoft/TypeScript-Node-Starter',
|
||||
repoUri,
|
||||
'master',
|
||||
lspservice,
|
||||
serverOptions,
|
||||
|
@ -193,11 +200,13 @@ describe.skip('lsp_indexer unit tests', function(this: any) {
|
|||
assert.strictEqual(createSpy.callCount, 3);
|
||||
assert.strictEqual(putAliasSpy.callCount, 3);
|
||||
|
||||
// There are 22 files in the repo. 1 file + 1 symbol + 1 reference = 3 objects to
|
||||
// index for each file. Total doc indexed should be 3 * 22 = 66, which can be
|
||||
// fitted into a single batch index.
|
||||
// There are 22 files which are written in supported languages in the repo. 1 file + 1 symbol + 1 reference = 3 objects to
|
||||
// index for each file. Total doc indexed for these files should be 3 * 22 = 66.
|
||||
// The rest 158 files will only be indexed for document. So the total number of index
|
||||
// requests will be 66 + 158 = 224.
|
||||
assert.ok(bulkSpy.calledOnce);
|
||||
assert.strictEqual(bulkSpy.getCall(0).args[0].body.length, 66 * 2);
|
||||
assert.strictEqual(lspSendRequestSpy.callCount, 22);
|
||||
assert.strictEqual(bulkSpy.getCall(0).args[0].body.length, 224 * 2);
|
||||
// @ts-ignore
|
||||
}).timeout(20000);
|
||||
|
||||
|
@ -223,7 +232,7 @@ describe.skip('lsp_indexer unit tests', function(this: any) {
|
|||
lspservice.sendRequest = setupLsServiceSendRequestSpy();
|
||||
|
||||
const indexer = new LspIndexer(
|
||||
'github.com/Microsoft/TypeScript-Node-Starter',
|
||||
repoUri,
|
||||
'master',
|
||||
lspservice,
|
||||
serverOptions,
|
||||
|
@ -267,11 +276,19 @@ describe.skip('lsp_indexer unit tests', function(this: any) {
|
|||
new RepositoryConfigController(esClient as EsClient)
|
||||
);
|
||||
|
||||
lspservice.sendRequest = setupLsServiceSendRequestSpy();
|
||||
const lspSendRequestSpy = setupLsServiceSendRequestSpy();
|
||||
lspservice.sendRequest = lspSendRequestSpy;
|
||||
const supportLanguageSpy = sinon.stub();
|
||||
|
||||
// Setup supported languages, so that unsupported source files won't be
|
||||
// sent for lsp requests.
|
||||
supportLanguageSpy.withArgs('javascript').returns(true);
|
||||
supportLanguageSpy.withArgs('typescript').returns(true);
|
||||
lspservice.supportLanguage = supportLanguageSpy;
|
||||
|
||||
const indexer = new LspIndexer(
|
||||
'github.com/Microsoft/TypeScript-Node-Starter',
|
||||
'46971a8',
|
||||
repoUri,
|
||||
'261557d',
|
||||
lspservice,
|
||||
serverOptions,
|
||||
esClient as EsClient,
|
||||
|
@ -282,7 +299,7 @@ describe.skip('lsp_indexer unit tests', function(this: any) {
|
|||
await indexer.start(undefined, {
|
||||
repoUri: '',
|
||||
filePath: 'src/public/js/main.ts',
|
||||
revision: '46971a8',
|
||||
revision: '261557d',
|
||||
localRepoPath: '',
|
||||
});
|
||||
|
||||
|
@ -295,12 +312,15 @@ describe.skip('lsp_indexer unit tests', function(this: any) {
|
|||
assert.strictEqual(createSpy.callCount, 0);
|
||||
assert.strictEqual(putAliasSpy.callCount, 0);
|
||||
|
||||
// There are 22 files in the repo, but only 11 files after the checkpoint.
|
||||
// 1 file + 1 symbol + 1 reference = 3 objects to index for each file.
|
||||
// Total doc indexed should be 3 * 11 = 33, which can be fitted into a
|
||||
// single batch index.
|
||||
// There are 22 files with supported language in the repo, but only 11
|
||||
// files after the checkpoint. 1 file + 1 symbol + 1 reference = 3 objects
|
||||
// to index for each file. Total doc indexed for these files should be
|
||||
// 3 * 11 = 33. Also there are 15 files without supported language. Only one
|
||||
// document will be index for these files. So total index requests would be
|
||||
// 33 + 15 = 48.
|
||||
assert.ok(bulkSpy.calledOnce);
|
||||
assert.strictEqual(bulkSpy.getCall(0).args[0].body.length, 33 * 2);
|
||||
assert.strictEqual(lspSendRequestSpy.callCount, 11);
|
||||
assert.strictEqual(bulkSpy.getCall(0).args[0].body.length, 48 * 2);
|
||||
// @ts-ignore
|
||||
}).timeout(20000);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue