Skip to content

Commit 837059b

Browse files
[Security Solution] clean unused types, export components and add many unit tests (elastic#217100)
## Summary This code change was originally part of [a bigger PR](elastic#216744) related to the AI for SOC effort. I decided to split the work for 2 reasons: - less files to review, less teams impacted - this current PR will easily be backported to `8.x` while the AI for SOC is only targeting `9.1` This PR makes only a few small changes: - remove unused types - export a few components/functions outside of the `alerts_table` folder to make them reusable within the new AI for SOC alert summary page (see PR linked above) - add a lot of unit tests to everything, especially the now exported components/functions #### UI remains unchanged: ![Screenshot 2025-04-03 at 6 09 57 PM](https://github.com/user-attachments/assets/3e4135e7-6e2f-4b4f-94e5-0dd72f1710bb) ![Screenshot 2025-04-03 at 6 10 06 PM](https://github.com/user-attachments/assets/382391d6-7ae1-4da4-a76f-495b6db69db3) ![Screenshot 2025-04-03 at 6 10 13 PM](https://github.com/user-attachments/assets/28c5947b-2168-4080-b298-5fea1f3f97c7) ![Screenshot 2025-04-03 at 6 10 21 PM](https://github.com/user-attachments/assets/2dc75fcb-9929-4821-830d-b84fceaf232d) ### Checklist - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [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 Will unblock elastic/security-team#11973
1 parent 2ed4266 commit 837059b

13 files changed

Lines changed: 343 additions & 508 deletions

File tree

src/platform/packages/shared/kbn-grouping/src/components/grouping.mock.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import React from 'react';
1111
import { EuiContextMenuItem } from '@elastic/eui';
12+
1213
export const host1Name = 'nice-host';
1314
export const host2Name = 'cool-host';
1415

@@ -48,9 +49,6 @@ export const mockGroupingProps = {
4849
},
4950
],
5051
},
51-
countSeveritySubAggregation: {
52-
value: 1,
53-
},
5452
usersCountAggregation: {
5553
value: 1,
5654
},
@@ -81,9 +79,6 @@ export const mockGroupingProps = {
8179
},
8280
],
8381
},
84-
countSeveritySubAggregation: {
85-
value: 1,
86-
},
8782
usersCountAggregation: {
8883
value: 1,
8984
},
@@ -115,9 +110,6 @@ export const mockGroupingProps = {
115110
},
116111
],
117112
},
118-
countSeveritySubAggregation: {
119-
value: 11,
120-
},
121113
usersCountAggregation: {
122114
value: 11,
123115
},

src/platform/packages/shared/kbn-grouping/src/containers/query/index.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ describe('group selector', () => {
2727
bucket_truncate: { bucket_sort: { from: 0, size: 25 } },
2828
alertsCount: { cardinality: { field: 'kibana.alert.uuid' } },
2929
rulesCountAggregation: { cardinality: { field: 'kibana.alert.rule.rule_id' } },
30-
countSeveritySubAggregation: { cardinality: { field: 'kibana.alert.severity' } },
3130
severitiesSubAggregation: { terms: { field: 'kibana.alert.severity' } },
3231
usersCountAggregation: { cardinality: { field: 'user.name' } },
3332
});

src/platform/packages/shared/kbn-grouping/src/mocks.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export const groupingBucket = {
2525
{ key: 'medium', doc_count: 480 },
2626
],
2727
},
28-
countSeveritySubAggregation: { value: 4 },
2928
};
3029

3130
export const mocktestProps1: GroupingQueryArgs = {
@@ -50,13 +49,6 @@ export const mocktestProps1: GroupingQueryArgs = {
5049
},
5150
},
5251
},
53-
{
54-
countSeveritySubAggregation: {
55-
cardinality: {
56-
field: 'kibana.alert.severity',
57-
},
58-
},
59-
},
6052
{
6153
severitiesSubAggregation: {
6254
terms: {

x-pack/solutions/observability/packages/kbn-alerts-grouping/src/mocks/grouping_query.mock.ts

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,6 @@ export const groupingSearchResponse = {
131131
},
132132
],
133133
},
134-
countSeveritySubAggregation: {
135-
value: 1,
136-
},
137134
usersCountAggregation: {
138135
value: 0,
139136
},
@@ -182,9 +179,6 @@ export const groupingSearchResponse = {
182179
},
183180
],
184181
},
185-
countSeveritySubAggregation: {
186-
value: 1,
187-
},
188182
usersCountAggregation: {
189183
value: 0,
190184
},
@@ -233,9 +227,6 @@ export const groupingSearchResponse = {
233227
},
234228
],
235229
},
236-
countSeveritySubAggregation: {
237-
value: 1,
238-
},
239230
usersCountAggregation: {
240231
value: 0,
241232
},
@@ -284,9 +275,6 @@ export const groupingSearchResponse = {
284275
},
285276
],
286277
},
287-
countSeveritySubAggregation: {
288-
value: 1,
289-
},
290278
usersCountAggregation: {
291279
value: 0,
292280
},
@@ -335,9 +323,6 @@ export const groupingSearchResponse = {
335323
},
336324
],
337325
},
338-
countSeveritySubAggregation: {
339-
value: 1,
340-
},
341326
usersCountAggregation: {
342327
value: 0,
343328
},
@@ -386,9 +371,6 @@ export const groupingSearchResponse = {
386371
},
387372
],
388373
},
389-
countSeveritySubAggregation: {
390-
value: 1,
391-
},
392374
usersCountAggregation: {
393375
value: 0,
394376
},
@@ -437,9 +419,6 @@ export const groupingSearchResponse = {
437419
},
438420
],
439421
},
440-
countSeveritySubAggregation: {
441-
value: 1,
442-
},
443422
usersCountAggregation: {
444423
value: 0,
445424
},
@@ -488,9 +467,6 @@ export const groupingSearchResponse = {
488467
},
489468
],
490469
},
491-
countSeveritySubAggregation: {
492-
value: 1,
493-
},
494470
usersCountAggregation: {
495471
value: 0,
496472
},
@@ -539,9 +515,6 @@ export const groupingSearchResponse = {
539515
},
540516
],
541517
},
542-
countSeveritySubAggregation: {
543-
value: 1,
544-
},
545518
usersCountAggregation: {
546519
value: 91,
547520
},
@@ -590,9 +563,6 @@ export const groupingSearchResponse = {
590563
},
591564
],
592565
},
593-
countSeveritySubAggregation: {
594-
value: 1,
595-
},
596566
usersCountAggregation: {
597567
value: 91,
598568
},
@@ -641,9 +611,6 @@ export const groupingSearchResponse = {
641611
},
642612
],
643613
},
644-
countSeveritySubAggregation: {
645-
value: 1,
646-
},
647614
usersCountAggregation: {
648615
value: 91,
649616
},
@@ -692,9 +659,6 @@ export const groupingSearchResponse = {
692659
},
693660
],
694661
},
695-
countSeveritySubAggregation: {
696-
value: 1,
697-
},
698662
usersCountAggregation: {
699663
value: 91,
700664
},
@@ -743,9 +707,6 @@ export const groupingSearchResponse = {
743707
},
744708
],
745709
},
746-
countSeveritySubAggregation: {
747-
value: 1,
748-
},
749710
usersCountAggregation: {
750711
value: 91,
751712
},
@@ -794,9 +755,6 @@ export const groupingSearchResponse = {
794755
},
795756
],
796757
},
797-
countSeveritySubAggregation: {
798-
value: 1,
799-
},
800758
usersCountAggregation: {
801759
value: 91,
802760
},
@@ -845,9 +803,6 @@ export const groupingSearchResponse = {
845803
},
846804
],
847805
},
848-
countSeveritySubAggregation: {
849-
value: 1,
850-
},
851806
usersCountAggregation: {
852807
value: 91,
853808
},
@@ -896,9 +851,6 @@ export const groupingSearchResponse = {
896851
},
897852
],
898853
},
899-
countSeveritySubAggregation: {
900-
value: 1,
901-
},
902854
usersCountAggregation: {
903855
value: 91,
904856
},
@@ -947,9 +899,6 @@ export const groupingSearchResponse = {
947899
},
948900
],
949901
},
950-
countSeveritySubAggregation: {
951-
value: 1,
952-
},
953902
usersCountAggregation: {
954903
value: 0,
955904
},
@@ -998,9 +947,6 @@ export const groupingSearchResponse = {
998947
},
999948
],
1000949
},
1001-
countSeveritySubAggregation: {
1002-
value: 1,
1003-
},
1004950
usersCountAggregation: {
1005951
value: 0,
1006952
},
@@ -1049,9 +995,6 @@ export const groupingSearchResponse = {
1049995
},
1050996
],
1051997
},
1052-
countSeveritySubAggregation: {
1053-
value: 1,
1054-
},
1055998
usersCountAggregation: {
1056999
value: 0,
10571000
},
@@ -1100,9 +1043,6 @@ export const groupingSearchResponse = {
11001043
},
11011044
],
11021045
},
1103-
countSeveritySubAggregation: {
1104-
value: 1,
1105-
},
11061046
usersCountAggregation: {
11071047
value: 0,
11081048
},
@@ -1151,9 +1091,6 @@ export const groupingSearchResponse = {
11511091
},
11521092
],
11531093
},
1154-
countSeveritySubAggregation: {
1155-
value: 1,
1156-
},
11571094
usersCountAggregation: {
11581095
value: 0,
11591096
},
@@ -1202,9 +1139,6 @@ export const groupingSearchResponse = {
12021139
},
12031140
],
12041141
},
1205-
countSeveritySubAggregation: {
1206-
value: 1,
1207-
},
12081142
usersCountAggregation: {
12091143
value: 0,
12101144
},
@@ -1253,9 +1187,6 @@ export const groupingSearchResponse = {
12531187
},
12541188
],
12551189
},
1256-
countSeveritySubAggregation: {
1257-
value: 1,
1258-
},
12591190
usersCountAggregation: {
12601191
value: 0,
12611192
},
@@ -1304,9 +1235,6 @@ export const groupingSearchResponse = {
13041235
},
13051236
],
13061237
},
1307-
countSeveritySubAggregation: {
1308-
value: 1,
1309-
},
13101238
usersCountAggregation: {
13111239
value: 0,
13121240
},
@@ -1355,9 +1283,6 @@ export const groupingSearchResponse = {
13551283
},
13561284
],
13571285
},
1358-
countSeveritySubAggregation: {
1359-
value: 1,
1360-
},
13611286
usersCountAggregation: {
13621287
value: 91,
13631288
},

0 commit comments

Comments
 (0)