diff --git a/languageServer/src/test/definitions.test.ts b/languageServer/src/test/definitions.test.ts index 6617ac5526..392f4b4e43 100644 --- a/languageServer/src/test/definitions.test.ts +++ b/languageServer/src/test/definitions.test.ts @@ -6,7 +6,7 @@ import { foreach_dvc_yaml, params_dvc_yaml } from './fixtures/examples/valid' -import { params } from './fixtures/params' +import { params, paramsJson } from './fixtures/params' import { requestDefinitions } from './utils/requestDefinitions' import { openTheseFilesAndNotifyServer } from './utils/openTheseFilesAndNotifyServer' import { @@ -122,4 +122,77 @@ describe('textDocument/definitions', () => { uri: 'file:///moreParams/otherParams.json' }) }) + + it('should send responses for a big number of the same file', async () => { + const multipleDocuments = [ + { + languageId: 'yaml', + mockContents: file_path_dvc_yaml, + mockPath: 'dvc.yaml' + } + ] + + for (let i = 0; i < 100; i++) { + multipleDocuments.push({ + languageId: 'yaml', + mockContents: file_path_dvc_yaml, + mockPath: 'dvc.yaml' + }) + } + + const [dvcYaml] = await openTheseFilesAndNotifyServer(multipleDocuments) + + const response = await requestDefinitions(dvcYaml, 'params.json') + + expect(response).toBeTruthy() + }) + + it('should send responses for a big number of different files', async () => { + const multipleDocuments = [ + { + languageId: 'yaml', + mockContents: file_path_dvc_yaml, + mockPath: 'dvc.yaml' + } + ] + + for (let i = 0; i < 100; i++) { + multipleDocuments.push( + { + languageId: 'yaml', + mockContents: file_path_dvc_yaml.repeat(i), + mockPath: 'dvc.yaml' + }, + { + languageId: 'json', + mockContents: paramsJson.repeat(i), + mockPath: 'params.json' + } + ) + } + + const [dvcYaml] = await openTheseFilesAndNotifyServer(multipleDocuments) + + const response = await requestDefinitions(dvcYaml, 'params.json') + + expect(response).toBeTruthy() + }) + + it('should send responses for a big number of requests to the same file', async () => { + const multipleDocuments = [ + { + languageId: 'yaml', + mockContents: file_path_dvc_yaml, + mockPath: 'dvc.yaml' + } + ] + + for (let i = 0; i < 100; i++) { + const [dvcYaml] = await openTheseFilesAndNotifyServer(multipleDocuments) + + const response = await requestDefinitions(dvcYaml, 'params.json') + + expect(response).toBeTruthy() + } + }) }) diff --git a/languageServer/src/test/fixtures/params/index.ts b/languageServer/src/test/fixtures/params/index.ts index 94dd2eb7bf..47bb68fa24 100644 --- a/languageServer/src/test/fixtures/params/index.ts +++ b/languageServer/src/test/fixtures/params/index.ts @@ -5,3 +5,10 @@ epochs: 15 auc: 0.9 loss: 0.2 `.trim() + +export const paramsJson = ` +{ + "lr": 0.003, + "epochs": 15 +} +`