forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ES|QL] don't suggest in comments (elastic#197341)
## Summary Close elastic#191866 - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: Elastic Machine <[email protected]>
- Loading branch information
1 parent
586b24f
commit 59b2f5f
Showing
7 changed files
with
137 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...n-esql-validation-autocomplete/src/autocomplete/__tests__/suggestions_in_comments.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the "Elastic License | ||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
import { setup } from './helpers'; | ||
|
||
describe('suggestions in comments', () => { | ||
it('does not suggest in single-line comments', async () => { | ||
const { assertSuggestions } = await setup('^'); | ||
await assertSuggestions('FROM index | EVAL // hey there ^', []); | ||
}); | ||
|
||
it('does not suggest in multi-line comments', async () => { | ||
const { assertSuggestions } = await setup('^'); | ||
await assertSuggestions('FROM index | EVAL /* ^ */', []); | ||
await assertSuggestions('FROM index | EVAL /* (^) */', []); | ||
}); | ||
|
||
it('does not suggest in incomplete multi-line comments', async () => { | ||
const { assertSuggestions } = await setup('^'); | ||
assertSuggestions('FROM index | EVAL /* ^', []); | ||
}); | ||
|
||
test('suggests next to comments', async () => { | ||
const { suggest } = await setup('^'); | ||
expect((await suggest('FROM index | EVAL ^/* */')).length).toBeGreaterThan(0); | ||
expect((await suggest('FROM index | EVAL /* */^')).length).toBeGreaterThan(0); | ||
expect((await suggest('FROM index | EVAL ^// a comment')).length).toBeGreaterThan(0); | ||
expect((await suggest('FROM index | EVAL // a comment\n^')).length).toBeGreaterThan(0); | ||
}); | ||
|
||
test('handles multiple comments', async () => { | ||
const { assertSuggestions } = await setup('^'); | ||
assertSuggestions('FROM index | EVAL /* comment1 */ x + /* comment2 ^ */ 1', []); | ||
assertSuggestions('FROM index | EVAL /* ^ comment1 */ x + /* comment2 ^ */ 1', []); | ||
assertSuggestions('FROM index | EVAL /* comment1 */ x + /* comment2 */ 1 // comment3 ^', []); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters