mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
adds test case for list.id operator
This commit is contained in:
parent
45a66fd966
commit
9dba145df2
1 changed files with 11 additions and 5 deletions
|
@ -8,24 +8,30 @@
|
|||
import { parseQueryFilterToKQL } from './utils';
|
||||
|
||||
describe('utils', () => {
|
||||
const searchableFields = [`name`, `description`, `entries.value`, `entries.entries.value`];
|
||||
const searchableFields = [
|
||||
'name',
|
||||
'description',
|
||||
'entries.value',
|
||||
'entries.entries.value',
|
||||
'entries.list.id',
|
||||
];
|
||||
describe('parseQueryFilterToKQL', () => {
|
||||
it('should parse simple query without term', () => {
|
||||
expect(parseQueryFilterToKQL('', searchableFields)).toBe('');
|
||||
});
|
||||
it('should parse simple query with term', () => {
|
||||
expect(parseQueryFilterToKQL('simpleQuery', searchableFields)).toBe(
|
||||
'(exception-list-agnostic.attributes.name:(*simpleQuery*) OR exception-list-agnostic.attributes.description:(*simpleQuery*) OR exception-list-agnostic.attributes.entries.value:(*simpleQuery*) OR exception-list-agnostic.attributes.entries.entries.value:(*simpleQuery*))'
|
||||
'(exception-list-agnostic.attributes.name:(*simpleQuery*) OR exception-list-agnostic.attributes.description:(*simpleQuery*) OR exception-list-agnostic.attributes.entries.value:(*simpleQuery*) OR exception-list-agnostic.attributes.entries.entries.value:(*simpleQuery*) OR exception-list-agnostic.attributes.entries.list.id:(*simpleQuery*))'
|
||||
);
|
||||
});
|
||||
it('should parse complex query with term', () => {
|
||||
expect(parseQueryFilterToKQL('complex query', searchableFields)).toBe(
|
||||
'(exception-list-agnostic.attributes.name:(*complex*query*) OR exception-list-agnostic.attributes.description:(*complex*query*) OR exception-list-agnostic.attributes.entries.value:(*complex*query*) OR exception-list-agnostic.attributes.entries.entries.value:(*complex*query*))'
|
||||
'(exception-list-agnostic.attributes.name:(*complex*query*) OR exception-list-agnostic.attributes.description:(*complex*query*) OR exception-list-agnostic.attributes.entries.value:(*complex*query*) OR exception-list-agnostic.attributes.entries.entries.value:(*complex*query*) OR exception-list-agnostic.attributes.entries.list.id:(*complex*query*))'
|
||||
);
|
||||
});
|
||||
it('should parse complex query with colon and backslash chars term', () => {
|
||||
expect(parseQueryFilterToKQL('C:\\tmpes', searchableFields)).toBe(
|
||||
'(exception-list-agnostic.attributes.name:(*C\\:\\\\tmpes*) OR exception-list-agnostic.attributes.description:(*C\\:\\\\tmpes*) OR exception-list-agnostic.attributes.entries.value:(*C\\:\\\\tmpes*) OR exception-list-agnostic.attributes.entries.entries.value:(*C\\:\\\\tmpes*))'
|
||||
'(exception-list-agnostic.attributes.name:(*C\\:\\\\tmpes*) OR exception-list-agnostic.attributes.description:(*C\\:\\\\tmpes*) OR exception-list-agnostic.attributes.entries.value:(*C\\:\\\\tmpes*) OR exception-list-agnostic.attributes.entries.entries.value:(*C\\:\\\\tmpes*) OR exception-list-agnostic.attributes.entries.list.id:(*C\\:\\\\tmpes*))'
|
||||
);
|
||||
});
|
||||
it('should parse complex query with special chars term', () => {
|
||||
|
@ -35,7 +41,7 @@ describe('utils', () => {
|
|||
searchableFields
|
||||
)
|
||||
).toBe(
|
||||
"(exception-list-agnostic.attributes.name:(*this'is%&query\\{\\}[]!¿?with.,-+`´special\\<\\>ºª@#|·chars*) OR exception-list-agnostic.attributes.description:(*this'is%&query\\{\\}[]!¿?with.,-+`´special\\<\\>ºª@#|·chars*) OR exception-list-agnostic.attributes.entries.value:(*this'is%&query\\{\\}[]!¿?with.,-+`´special\\<\\>ºª@#|·chars*) OR exception-list-agnostic.attributes.entries.entries.value:(*this'is%&query\\{\\}[]!¿?with.,-+`´special\\<\\>ºª@#|·chars*))"
|
||||
"(exception-list-agnostic.attributes.name:(*this'is%&query\\{\\}[]!¿?with.,-+`´special\\<\\>ºª@#|·chars*) OR exception-list-agnostic.attributes.description:(*this'is%&query\\{\\}[]!¿?with.,-+`´special\\<\\>ºª@#|·chars*) OR exception-list-agnostic.attributes.entries.value:(*this'is%&query\\{\\}[]!¿?with.,-+`´special\\<\\>ºª@#|·chars*) OR exception-list-agnostic.attributes.entries.entries.value:(*this'is%&query\\{\\}[]!¿?with.,-+`´special\\<\\>ºª@#|·chars*) OR exception-list-agnostic.attributes.entries.list.id:(*this'is%&query\\{\\}[]!¿?with.,-+`´special\\<\\>ºª@#|·chars*))"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue