-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Search] Fixes EQL search strategy #83064
Changes from 8 commits
9e5abf4
3aa44db
471595f
447aaf3
1b4188f
fde464e
52e67a3
6bb0f63
9b2b6e5
aba3b21
34d0d7c
e5de2f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export const NOTIFICATION_TOASTS = '[data-test-subj="globalToastList"]'; | ||
|
||
export const TOAST_ERROR_CLASS = 'euiToast--danger'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Always a bummer when we have to use a class for part of a selector but I get when we have to do it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, this was the best identifier I could find for now. I'll make a note to add a data-test-subj upstream in notifications next time I come through here 👍 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,7 +61,11 @@ import { | |
THRESHOLD_TYPE, | ||
EQL_TYPE, | ||
EQL_QUERY_INPUT, | ||
QUERY_PREVIEW_BUTTON, | ||
EQL_QUERY_PREVIEW_HISTOGRAM, | ||
EQL_QUERY_VALIDATION_SPINNER, | ||
} from '../screens/create_new_rule'; | ||
import { NOTIFICATION_TOASTS, TOAST_ERROR_CLASS } from '../screens/shared'; | ||
import { TIMELINE } from '../screens/timelines'; | ||
import { refreshPage } from './security_header'; | ||
|
||
|
@@ -225,8 +229,12 @@ export const fillDefineThresholdRuleAndContinue = (rule: ThresholdRule) => { | |
|
||
export const fillDefineEqlRuleAndContinue = (rule: CustomRule) => { | ||
cy.get(EQL_QUERY_INPUT).type(rule.customQuery); | ||
cy.get(DEFINE_CONTINUE_BUTTON).should('exist').click({ force: true }); | ||
cy.get(EQL_QUERY_VALIDATION_SPINNER).should('not.exist'); | ||
cy.get(QUERY_PREVIEW_BUTTON).should('not.be.disabled').click({ force: true }); | ||
cy.get(EQL_QUERY_PREVIEW_HISTOGRAM).should('contain.text', 'Hits'); | ||
cy.get(NOTIFICATION_TOASTS).children().should('not.have.class', TOAST_ERROR_CLASS); // asserts no error toast on page | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @MadameSheema I wanted to call out this addition as it might be a nice sanity check throughout the suite |
||
|
||
cy.get(DEFINE_CONTINUE_BUTTON).should('exist').click({ force: true }); | ||
cy.get(EQL_QUERY_INPUT).should('not.exist'); | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,8 +74,6 @@ export const useEqlPreview = (): [ | |
.search<EqlSearchStrategyRequest, EqlSearchStrategyResponse<EqlSearchResponse<Source>>>( | ||
{ | ||
params: { | ||
// @ts-expect-error allow_no_indices is missing on EqlSearch | ||
allow_no_indices: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 Nice! |
||
index: index.join(), | ||
body: { | ||
filter: { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,7 +51,7 @@ describe('PreviewCustomQueryHistogram', () => { | |
|
||
expect(wrapper.find('[data-test-subj="queryPreviewLoading"]').exists()).toBeTruthy(); | ||
expect( | ||
wrapper.find('[data-test-subj="queryPreviewCustomHistogram"]').at(0).prop('subtitle') | ||
wrapper.find('[dataTestSubj="queryPreviewCustomHistogram"]').at(0).prop('subtitle') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @yctercero I tried to make as few changes to these tests as possible to maintain behavior while allowing a custom There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks great! |
||
).toEqual(i18n.QUERY_PREVIEW_SUBTITLE_LOADING); | ||
}); | ||
|
||
|
@@ -78,32 +78,32 @@ describe('PreviewCustomQueryHistogram', () => { | |
|
||
expect(wrapper.find('[data-test-subj="queryPreviewLoading"]').exists()).toBeFalsy(); | ||
expect( | ||
wrapper.find('[data-test-subj="queryPreviewCustomHistogram"]').at(0).prop('subtitle') | ||
wrapper.find('[dataTestSubj="queryPreviewCustomHistogram"]').at(0).prop('subtitle') | ||
).toEqual(i18n.QUERY_PREVIEW_TITLE(9154)); | ||
expect( | ||
wrapper.find('[data-test-subj="queryPreviewCustomHistogram"]').at(0).props().data | ||
).toEqual([ | ||
{ | ||
key: 'hits', | ||
value: [ | ||
{ | ||
g: 'All others', | ||
x: 1602247050000, | ||
y: 2314, | ||
}, | ||
{ | ||
g: 'All others', | ||
x: 1602247162500, | ||
y: 3471, | ||
}, | ||
{ | ||
g: 'All others', | ||
x: 1602247275000, | ||
y: 3369, | ||
}, | ||
], | ||
}, | ||
]); | ||
expect(wrapper.find('[dataTestSubj="queryPreviewCustomHistogram"]').at(0).props().data).toEqual( | ||
[ | ||
{ | ||
key: 'hits', | ||
value: [ | ||
{ | ||
g: 'All others', | ||
x: 1602247050000, | ||
y: 2314, | ||
}, | ||
{ | ||
g: 'All others', | ||
x: 1602247162500, | ||
y: 3471, | ||
}, | ||
{ | ||
g: 'All others', | ||
x: 1602247275000, | ||
y: 3369, | ||
}, | ||
], | ||
}, | ||
] | ||
); | ||
}); | ||
|
||
test('it invokes setQuery with id, inspect, isLoading and refetch', async () => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the crux of the fix; details are in 9e5abf4