-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security solution] Fix grouping query, be ready for arrays! (#157330)
- Loading branch information
1 parent
951fca5
commit 4371c15
Showing
18 changed files
with
560 additions
and
693 deletions.
There are no files selected for viewing
51 changes: 0 additions & 51 deletions
51
packages/kbn-securitysolution-grouping/src/components/accordion_panel/helpers.ts
This file was deleted.
Oops, something went wrong.
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
35 changes: 35 additions & 0 deletions
35
packages/kbn-securitysolution-grouping/src/containers/query/helpers.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,35 @@ | ||
/* | ||
* 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 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 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { createGroupFilter } from './helpers'; | ||
|
||
const selectedGroup = 'host.name'; | ||
describe('createGroupFilter', () => { | ||
it('returns an array of Filter objects with correct meta and query properties when values and selectedGroup are truthy', () => { | ||
const values = ['host1', 'host2']; | ||
const result = createGroupFilter(selectedGroup, values); | ||
expect(result).toHaveLength(3); | ||
expect(result[0].meta.key).toBe(selectedGroup); | ||
expect(result[0].query.script.script.params.field).toBe(selectedGroup); | ||
expect(result[0].query.script.script.params.size).toBe(values.length); | ||
expect(result[1].meta.key).toBe(selectedGroup); | ||
expect(result[1].query.match_phrase[selectedGroup].query).toBe(values[0]); | ||
expect(result[2].meta.key).toBe(selectedGroup); | ||
expect(result[2].query.match_phrase[selectedGroup].query).toBe(values[1]); | ||
}); | ||
|
||
it('returns an empty array when values is an empty array and selectedGroup is truthy', () => { | ||
const result = createGroupFilter(selectedGroup, []); | ||
expect(result).toHaveLength(0); | ||
}); | ||
|
||
it('returns an empty array when values is null and selectedGroup is truthy', () => { | ||
const result = createGroupFilter(selectedGroup, null); | ||
expect(result).toHaveLength(0); | ||
}); | ||
}); |
Oops, something went wrong.