Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Detection Engine][Rule Suppression] Add Suppression to EQL Non-sequence based queries #176422

Merged
merged 133 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
133 commits
Select commit Hold shift + click to select a range
caede2b
add suppression to eql in the FE + adding FF
WafaaNasr Feb 7, 2024
2f93e63
add the return type
WafaaNasr Feb 7, 2024
76505fb
fix type
WafaaNasr Feb 7, 2024
2bd45a7
add initial UI tests
WafaaNasr Feb 7, 2024
eeda81c
[Detection Engine][Rule Suppression] Add suppression fields to EQL sc…
WafaaNasr Feb 7, 2024
5b6a4b2
Merge branch 'main' into security/eql-suppression
WafaaNasr Feb 7, 2024
ba88528
Merge branch 'main' into security/eql-suppression
WafaaNasr Feb 7, 2024
dc8267b
Merge branch 'security/eql-suppression' into eql-suppression-FE-FF-ch…
WafaaNasr Feb 7, 2024
63f213f
Merge branch 'main' into security/eql-suppression
WafaaNasr Feb 8, 2024
5851f08
Merge branch 'security/eql-suppression' into eql-suppression-FE-FF-ch…
WafaaNasr Feb 8, 2024
bb672f5
initial implementation
WafaaNasr Feb 9, 2024
9df871d
Merge branch 'main' into security/eql-suppression
WafaaNasr Feb 9, 2024
6d89584
Merge branch 'security/eql-suppression' into eql-suppression-BE-FTR-c…
WafaaNasr Feb 9, 2024
7f1179f
Merge branch 'main' into security/eql-suppression
WafaaNasr Feb 13, 2024
c579b7e
Merge branch 'security/eql-suppression' into eql-suppression-BE-FTR-c…
WafaaNasr Feb 13, 2024
d15b451
add ftr tests for eql non-sequence query, missing warning cases
WafaaNasr Feb 13, 2024
13ef5dd
Merge branch 'main' into security/eql-suppression
WafaaNasr Feb 13, 2024
aab2540
Merge branch 'security/eql-suppression' into eql-suppression-BE-FTR-c…
WafaaNasr Feb 13, 2024
5296d06
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Feb 13, 2024
e1a4b46
Merge branch 'main' into security/eql-suppression
WafaaNasr Feb 14, 2024
c2d8ec2
undo tsconfig
WafaaNasr Feb 14, 2024
9049b9a
Merge branch 'security/eql-suppression' into eql-suppression-BE-FTR-c…
WafaaNasr Feb 14, 2024
d9bbdf2
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Feb 14, 2024
ef07adb
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Feb 14, 2024
3bd5b88
adding is_alert_suppression_active util + tests
WafaaNasr Feb 14, 2024
b8a370b
fix conflict
WafaaNasr Feb 14, 2024
11a5c70
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Feb 14, 2024
4a55884
fix non-suppression scenario
WafaaNasr Feb 14, 2024
5c5cef1
Merge branch 'eql-suppression-BE-FTR-changes' of https://github.com/W…
WafaaNasr Feb 14, 2024
4b36b32
remove console.log
WafaaNasr Feb 14, 2024
b63a31e
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Feb 14, 2024
65ad9e9
fix investigate in timeline until confirmation
WafaaNasr Feb 19, 2024
6832023
add warning for suppressed max signal message
WafaaNasr Feb 20, 2024
0b97f7c
Merge branch 'eql-suppression-BE-FTR-changes' of https://github.com/W…
WafaaNasr Feb 20, 2024
2cbab23
Merge branch 'main' into security/eql-suppression
WafaaNasr Feb 20, 2024
867e9d1
Merge branch 'security/eql-suppression' into eql-suppression-BE-FTR-c…
WafaaNasr Feb 20, 2024
f28ed3f
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Feb 20, 2024
908793d
add tips for sequence implementation
WafaaNasr Feb 20, 2024
b6b273a
Merge branch 'eql-suppression-BE-FTR-changes' of https://github.com/W…
WafaaNasr Feb 20, 2024
328ce47
Merge branch 'main' into security/eql-suppression
WafaaNasr Feb 21, 2024
72dc1bc
Merge branch 'main' into security/eql-suppression
WafaaNasr Feb 27, 2024
a547408
[Detection Engine][Rule Suppression] Add suppression fields to EQL No…
WafaaNasr Feb 27, 2024
e20f049
Merge branch 'security/eql-suppression' into eql-suppression-BE-FTR-c…
WafaaNasr Feb 27, 2024
01e6ea4
remove extra spaces
WafaaNasr Feb 27, 2024
c40631a
fix ff name
WafaaNasr Feb 27, 2024
9d2635e
Merge branch 'main' into security/eql-suppression
WafaaNasr Feb 28, 2024
756364c
Merge branch 'security/eql-suppression' into eql-suppression-BE-FTR-c…
WafaaNasr Feb 28, 2024
507c6a1
fix tests
WafaaNasr Feb 28, 2024
799aef2
Merge branch 'eql-suppression-BE-FTR-changes' of https://github.com/W…
WafaaNasr Feb 28, 2024
612a467
update schema snapshot for serverless
WafaaNasr Feb 28, 2024
87c324a
fix checktypes
WafaaNasr Feb 28, 2024
ffa1f38
separate the timeline changes in different pr
WafaaNasr Feb 28, 2024
0980bc2
reuse bulk_created_suppressed_alerts_in_memory in search_after_bulk_c…
WafaaNasr Feb 29, 2024
ec1c676
Merge branch 'main' into security/eql-suppression
WafaaNasr Feb 29, 2024
3e2a522
add cypress e2e for eql suppression non-sequence
WafaaNasr Feb 29, 2024
8b8b749
rename
WafaaNasr Feb 29, 2024
18cfd79
Merge branch 'main' into security/eql-suppression
WafaaNasr Mar 4, 2024
fb3573e
[Detection Engine][Rule Suppression] Eql suppression Backend implemen…
WafaaNasr Mar 4, 2024
a869d13
Merge branch 'security/eql-suppression' into eql-suppression-cypress-…
WafaaNasr Mar 4, 2024
c485d51
add extra line
WafaaNasr Mar 4, 2024
231cf6a
Merge branch 'main' into security/eql-suppression
WafaaNasr Mar 4, 2024
ed4cde2
Merge branch 'main' into security/eql-suppression
WafaaNasr Mar 4, 2024
0f936f3
[Detection Engine][Rule Suppression] Non-sequence Eql suppression C…
WafaaNasr Mar 5, 2024
392c3e4
Merge branch 'main' into security/eql-suppression
WafaaNasr Mar 5, 2024
d1df2cb
Merge branch 'main' into security/eql-suppression
WafaaNasr Mar 5, 2024
fb93ff5
[Detection Engine][Rule Suppression] Eql suppression for Non-sequence…
WafaaNasr Mar 12, 2024
b6725f0
disable eql sequence suppression
WafaaNasr Mar 12, 2024
17d2a47
Merge branch 'security/eql-suppression' into eql-suppression-disable-…
WafaaNasr Mar 12, 2024
18ffde8
Merge branch 'main' into security/eql-suppression
WafaaNasr Mar 12, 2024
19db01b
Merge branch 'security/eql-suppression' into eql-suppression-disable-…
WafaaNasr Mar 12, 2024
f78fd96
add tests and todo for be exception
WafaaNasr Mar 12, 2024
7607f97
Merge branch 'main' into security/eql-suppression
WafaaNasr Mar 19, 2024
210012d
Merge branch 'security/eql-suppression' into eql-suppression-disable-…
WafaaNasr Mar 19, 2024
4db87b4
fix after in cypress
WafaaNasr Mar 19, 2024
1c9872f
disable eql sequence suppression and ask the user to reset the suppre…
WafaaNasr Mar 22, 2024
8059f2a
add todo to ignore suppression for sequence query if passed
WafaaNasr Mar 22, 2024
b82c251
Use a slightly more legible feature flag name
rylnd Mar 27, 2024
6aa3dbe
Replace validation-specific predicate with more general helper
rylnd Mar 28, 2024
0a4ef70
Merge branch 'main' into security/eql-suppression
rylnd Mar 28, 2024
0e89184
Remove unused test file
rylnd Mar 28, 2024
f8644ad
Update unload task invocations after API changed
rylnd Mar 28, 2024
895d59b
Fix our mocks in the useAlertSuppression hook
rylnd Mar 28, 2024
fe210e6
Fix bad merge resolution
rylnd Mar 29, 2024
023e932
refactors EQL execution to allow for a handling of sequence suppression
rylnd Mar 29, 2024
700e00c
Sequence EQL rules with suppression are marked as partial failure
rylnd Mar 29, 2024
5504430
Merge branch 'main' into security/eql-suppression
rylnd Apr 1, 2024
fe0e879
Simplify warning if using suppression with EQL sequences
rylnd Apr 4, 2024
cd5ce86
Remove unnecessary addToSearchAfterReturn call
rylnd Apr 4, 2024
7996054
Attempting to test the fact that we suppressed alerts
rylnd Apr 4, 2024
b864456
style: give tests some breathing room
rylnd Apr 4, 2024
2ea1af8
Slightly more comprehensive test assertion
rylnd Apr 4, 2024
27b2071
Merge branch 'security/eql-suppression' into eql-suppression-disable-…
rylnd Apr 5, 2024
980b82c
Ignore complexity post-merge
rylnd Apr 5, 2024
fe1dad5
Alternate implementation of disabling suppression for EQL sequences
rylnd Apr 5, 2024
c52ebb7
Update copy as per docs team feedback
rylnd Apr 5, 2024
f9837b5
Fix translation interpolation
rylnd Apr 5, 2024
b7fc317
Fix translation key
rylnd Apr 5, 2024
ed5b85c
Merge branch 'main' into security/eql-suppression
rylnd Apr 5, 2024
34b9b41
Fix unit tests for EQL query bar
rylnd Apr 5, 2024
0d1b024
Add some tests around added helper
rylnd Apr 5, 2024
6a729ea
Merge branch 'main' into security/eql-suppression
rylnd Apr 8, 2024
c895233
Merge branch 'security/eql-suppression' into eql-suppression-disable-…
rylnd Apr 8, 2024
4a35e59
Fix outdated feature flag reference
rylnd Apr 8, 2024
f974273
Remove assertion about upsell tooltip when suppression is disabled
rylnd Apr 9, 2024
c8c8b22
Only show "disabled for EQL sequence" tooltip on suppression fields
rylnd Apr 9, 2024
0cf5eab
Revert "Remove assertion about upsell tooltip when suppression is dis…
rylnd Apr 9, 2024
8e3b753
Fix cypress assertion following copy change
rylnd Apr 9, 2024
7e96714
Merge branch 'main' into security/eql-suppression
rylnd Apr 9, 2024
64edcb5
Remove duplicated helper
rylnd Apr 9, 2024
b45a21a
Fix useAlertSuppression tests
rylnd Apr 9, 2024
2f1f8cd
Merge branch 'main' into security/eql-suppression
rylnd Apr 9, 2024
5728f79
Merge branch 'main' into security/eql-suppression
rylnd Apr 10, 2024
98541ab
Add missing argument to suppression function in eql executor
rylnd Apr 10, 2024
52d3711
Merge branch 'main' into security/eql-suppression
rylnd Apr 10, 2024
d744cf1
Type fixes
rylnd Apr 10, 2024
602954e
Fix typo in test filename
rylnd Apr 11, 2024
582a11b
Refactor our EQL suppression API tests
rylnd Apr 11, 2024
de90e0f
Normalize EQL cypress tests
rylnd Apr 11, 2024
7aa52b8
Replace ConditionalToopTip with EuiToolTip
rylnd Apr 13, 2024
cc95859
Fix test subjects and cypress constants for accuracy
rylnd Apr 13, 2024
9965c1d
More accurate test descriptions
rylnd Apr 13, 2024
11077bd
Fix logical error in test
rylnd Apr 13, 2024
67a0b6d
Simplify predicate logic
rylnd Apr 13, 2024
3f73123
Simplify logic
rylnd Apr 13, 2024
67472b9
Merge branch 'main' into security/eql-suppression
rylnd Apr 13, 2024
d858353
Add integration tests for risk score enrichment and exceptions
rylnd Apr 13, 2024
5b70ae9
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Apr 13, 2024
2f4d99f
Repurpose existing tooltip to display eql suppression tooltip
rylnd Apr 15, 2024
18d3285
Merge branch 'main' into security/eql-suppression
rylnd Apr 15, 2024
7f0701d
Merge branch 'main' into security/eql-suppression
banderror Apr 16, 2024
b500067
Merge branch 'main' into security/eql-suppression
banderror Apr 16, 2024
ec09071
Add missing index pattern to rule mock
rylnd Apr 16, 2024
6600836
Skip cypress tests reliant on feature flag in serverless MKI
rylnd Apr 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import type {
ThresholdRuleCreateProps,
NewTermsRuleCreateProps,
NewTermsRuleUpdateProps,
EqlRuleCreateProps,
} from './rule_schemas.gen';

export const getCreateRulesSchemaMock = (ruleId = 'rule-1'): QueryRuleCreateProps => ({
Expand Down Expand Up @@ -213,3 +214,15 @@ export const getUpdateNewTermsSchemaMock = (
new_terms_fields: ['user.name'],
history_window_start: 'now-7d',
});

export const getCreateEqlRuleSchemaMock = (ruleId = 'rule-1'): EqlRuleCreateProps => ({
description: 'Event correlation index pattern rule',
name: 'Event correlation index pattern rule',
index: ['auditbeat-*'],
severity: 'high',
risk_score: 55,
rule_id: ruleId,
type: 'eql',
language: 'eql',
query: 'process where process.name == "regsvr32.exe"',
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { expectParseError, expectParseSuccess, stringifyZodError } from '@kbn/zod-helpers';
import { getListArrayMock } from '../../../../detection_engine/schemas/types/lists.mock';
import {
getCreateEqlRuleSchemaMock,
getCreateEsqlRulesSchemaMock,
getCreateMachineLearningRulesSchemaMock,
getCreateNewTermsRulesSchemaMock,
Expand Down Expand Up @@ -1268,6 +1269,7 @@ describe('rules schema', () => {
{ ruleType: 'threat_match', ruleMock: getCreateThreatMatchRulesSchemaMock() },
{ ruleType: 'query', ruleMock: getCreateRulesSchemaMock() },
{ ruleType: 'saved_query', ruleMock: getCreateSavedQueryRulesSchemaMock() },
{ ruleType: 'eql', ruleMock: getCreateEqlRuleSchemaMock() },
{ ruleType: 'new_terms', ruleMock: getCreateNewTermsRulesSchemaMock() },
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ import {
IndexPatternArray,
DataViewId,
RuleFilterArray,
SavedQueryId,
AlertSuppression,
SavedQueryId,
KqlQueryLanguage,
} from './common_attributes.gen';
import { RuleExecutionSummary } from '../../rule_monitoring/model/execution_summary.gen';
Expand Down Expand Up @@ -219,6 +219,7 @@ export const EqlOptionalFields = z.object({
event_category_override: EventCategoryOverride.optional(),
tiebreaker_field: TiebreakerField.optional(),
timestamp_field: TimestampField.optional(),
alert_suppression: AlertSuppression.optional(),
});

export type EqlRuleCreateFields = z.infer<typeof EqlRuleCreateFields>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@ components:
$ref: './specific_attributes/eql_attributes.schema.yaml#/components/schemas/TiebreakerField'
timestamp_field:
$ref: './specific_attributes/eql_attributes.schema.yaml#/components/schemas/TimestampField'
alert_suppression:
$ref: './common_attributes.schema.yaml#/components/schemas/AlertSuppression'

EqlRuleCreateFields:
allOf:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ export const SUPPRESSIBLE_ALERT_RULES: Type[] = [
'query',
'new_terms',
'threat_match',
'eql',
];
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
isSuppressionRuleConfiguredWithDuration,
isSuppressionRuleConfiguredWithGroupBy,
isSuppressionRuleConfiguredWithMissingFields,
isEqlSequenceQuery,
} from './utils';
import type { Type } from '@kbn/securitysolution-io-ts-alerting-types';

Expand Down Expand Up @@ -232,9 +233,9 @@ describe('Alert Suppression Rules', () => {
expect(isSuppressibleAlertRule('query')).toBe(true);
expect(isSuppressibleAlertRule('threat_match')).toBe(true);
expect(isSuppressibleAlertRule('new_terms')).toBe(true);
expect(isSuppressibleAlertRule('eql')).toBe(true);

// Rule types that don't support alert suppression:
expect(isSuppressibleAlertRule('eql')).toBe(false);
expect(isSuppressibleAlertRule('machine_learning')).toBe(false);
expect(isSuppressibleAlertRule('esql')).toBe(false);
});
Expand All @@ -254,9 +255,9 @@ describe('Alert Suppression Rules', () => {
expect(isSuppressionRuleConfiguredWithDuration('query')).toBe(true);
expect(isSuppressionRuleConfiguredWithDuration('threat_match')).toBe(true);
expect(isSuppressionRuleConfiguredWithDuration('new_terms')).toBe(true);
expect(isSuppressionRuleConfiguredWithDuration('eql')).toBe(true);

// Rule types that don't support alert suppression:
expect(isSuppressionRuleConfiguredWithDuration('eql')).toBe(false);
expect(isSuppressionRuleConfiguredWithDuration('machine_learning')).toBe(false);
expect(isSuppressionRuleConfiguredWithDuration('esql')).toBe(false);
});
Expand All @@ -275,9 +276,9 @@ describe('Alert Suppression Rules', () => {
expect(isSuppressionRuleConfiguredWithGroupBy('query')).toBe(true);
expect(isSuppressionRuleConfiguredWithGroupBy('threat_match')).toBe(true);
expect(isSuppressionRuleConfiguredWithGroupBy('new_terms')).toBe(true);
expect(isSuppressionRuleConfiguredWithGroupBy('eql')).toBe(true);

// Rule types that don't support alert suppression:
expect(isSuppressionRuleConfiguredWithGroupBy('eql')).toBe(false);
expect(isSuppressionRuleConfiguredWithGroupBy('machine_learning')).toBe(false);
expect(isSuppressionRuleConfiguredWithGroupBy('esql')).toBe(false);
});
Expand All @@ -301,9 +302,9 @@ describe('Alert Suppression Rules', () => {
expect(isSuppressionRuleConfiguredWithMissingFields('query')).toBe(true);
expect(isSuppressionRuleConfiguredWithMissingFields('threat_match')).toBe(true);
expect(isSuppressionRuleConfiguredWithMissingFields('new_terms')).toBe(true);
expect(isSuppressionRuleConfiguredWithMissingFields('eql')).toBe(true);

// Rule types that don't support alert suppression:
expect(isSuppressionRuleConfiguredWithMissingFields('eql')).toBe(false);
expect(isSuppressionRuleConfiguredWithMissingFields('machine_learning')).toBe(false);
expect(isSuppressionRuleConfiguredWithMissingFields('esql')).toBe(false);
});
Expand All @@ -319,4 +320,31 @@ describe('Alert Suppression Rules', () => {
expect(result).toBe(false);
});
});

describe('isEqlSequenceQuery', () => {
it('is false if query is undefined', () => {
const result = isEqlSequenceQuery(undefined);
expect(result).toBe(false);
});

it('is false if query is an empty string', () => {
const result = isEqlSequenceQuery('');
expect(result).toBe(false);
});

it('is false if query is an nonempty string', () => {
const result = isEqlSequenceQuery('any where true');
expect(result).toBe(false);
});

it('is true if query begins with "sequence"', () => {
const query = 'sequence where true';
expect(isEqlSequenceQuery(query)).toBe(true);
});

it('is true if query begins with some whitespace and then "sequence"', () => {
const query = ' sequence where true';
expect(isEqlSequenceQuery(query)).toBe(true);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ export const normalizeThresholdField = (
[thresholdField!];
};

export const isEqlSequenceQuery = (ruleQuery: string | undefined): boolean =>
ruleQuery?.trim().startsWith('sequence') ?? false;
rylnd marked this conversation as resolved.
Show resolved Hide resolved

export const normalizeThresholdObject = (threshold: Threshold): ThresholdNormalized => {
return {
...threshold,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ export const allowedExperimentalValues = Object.freeze({
*/
alertSuppressionForNewTermsRuleEnabled: false,

/**
* Enables alerts suppression for Eql rules with non-sequence queries
*/
alertSuppressionForNonSequenceEqlRuleEnabled: false,

/**
* Enables experimental Experimental S1 integration data to be available in Analyzer
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ describe('description_step', () => {
});

describe('alert suppression', () => {
const ruleTypesWithoutSuppression: Type[] = ['eql', 'esql', 'machine_learning'];
const ruleTypesWithoutSuppression: Type[] = ['esql', 'machine_learning'];
const suppressionFields = {
groupByDuration: {
unit: 'm',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
*/

import React from 'react';
import { shallow, mount } from 'enzyme';
import { shallow } from 'enzyme';
import { render, screen, fireEvent, within } from '@testing-library/react';

import { mockIndexPattern, TestProviders, useFormFieldMock } from '../../../../common/mock';
import { mockQueryBar } from '../../../rule_management_ui/components/rules_table/__mocks__/mock';
import type { EqlQueryBarProps } from './eql_query_bar';
import { EqlQueryBar } from './eql_query_bar';
import { getEqlValidationError } from './validators.mock';
import { fireEvent, render, within } from '@testing-library/react';

jest.mock('../../../../common/lib/kibana');

Expand All @@ -26,7 +26,7 @@ describe('EqlQueryBar', () => {
});
});

it('renders correctly', () => {
it('should render correctly', () => {
const wrapper = shallow(
<EqlQueryBar
dataTestSubj="myQueryBar"
Expand Down Expand Up @@ -54,8 +54,8 @@ describe('EqlQueryBar', () => {
expect(wrapper.find('[data-test-subj="eqlFilterBar"]')).toHaveLength(1);
});

it('sets the field value on input change', () => {
const wrapper = mount(
it('should set the field value on input change', () => {
render(
<TestProviders>
<EqlQueryBar
dataTestSubj="myQueryBar"
Expand All @@ -65,11 +65,8 @@ describe('EqlQueryBar', () => {
/>
</TestProviders>
);

wrapper
.find('[data-test-subj="eqlQueryBarTextInput"]')
.last()
.simulate('change', { target: { value: 'newQuery' } });
const inputElement = screen.getByTestId('eqlQueryBarTextInput');
fireEvent.change(inputElement, { target: { value: 'newQuery' } });

const expected = {
filters: mockQueryBar.filters,
Expand All @@ -83,8 +80,8 @@ describe('EqlQueryBar', () => {
expect(mockField.setValue).toHaveBeenCalledWith(expected);
});

it('does not render errors for a valid query', () => {
const wrapper = mount(
it('should not render errors for a valid query', () => {
const { queryByTestId } = render(
<TestProviders>
<EqlQueryBar
dataTestSubj="myQueryBar"
Expand All @@ -95,17 +92,15 @@ describe('EqlQueryBar', () => {
</TestProviders>
);

expect(wrapper.find('[data-test-subj="eql-validation-errors-popover"]').exists()).toEqual(
false
);
expect(queryByTestId('eql-validation-errors-popover')).not.toBeInTheDocument();
});

it('renders errors for an invalid query', () => {
it('should render errors for an invalid query', () => {
const invalidMockField = useFormFieldMock({
value: mockQueryBar,
errors: [getEqlValidationError()],
});
const wrapper = mount(
const { getByTestId } = render(
<TestProviders>
<EqlQueryBar
dataTestSubj="myQueryBar"
Expand All @@ -116,7 +111,7 @@ describe('EqlQueryBar', () => {
</TestProviders>
);

expect(wrapper.find('[data-test-subj="eql-validation-errors-popover"]').exists()).toEqual(true);
expect(getByTestId('eql-validation-errors-popover')).toBeInTheDocument();
});

describe('EQL options interaction', () => {
Expand Down
Loading