Skip to content

Commit 70d6e55

Browse files
committed
fix cypress tests
1 parent 8c378f3 commit 70d6e55

4 files changed

Lines changed: 33 additions & 23 deletions

File tree

x-pack/plugins/security_solution/cypress/screens/create_new_rule.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ export const RISK_MAPPING_OVERRIDE_OPTION = '#risk_score-mapping-override';
129129
export const RISK_OVERRIDE =
130130
'[data-test-subj="detectionEngineStepAboutRuleRiskScore-riskOverride"]';
131131

132+
export const RULES_CREATION_FORM = '[data-test-subj="stepDefineRule"]';
133+
134+
export const RULES_CREATION_PREVIEW = '[data-test-subj="ruleCreationQueryPreview"]';
135+
132136
export const RULE_DESCRIPTION_INPUT =
133137
'[data-test-subj="detectionEngineStepAboutRuleDescription"] [data-test-subj="input"]';
134138

x-pack/plugins/security_solution/cypress/tasks/create_new_rule.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ import {
7878
AT_LEAST_ONE_VALID_MATCH,
7979
AT_LEAST_ONE_INDEX_PATTERN,
8080
CUSTOM_QUERY_REQUIRED,
81+
RULES_CREATION_FORM,
82+
RULES_CREATION_PREVIEW,
8183
} from '../screens/create_new_rule';
8284
import { TOAST_ERROR } from '../screens/shared';
8385
import { SERVER_SIDE_EVENT_COUNT } from '../screens/timeline';
@@ -271,23 +273,26 @@ export const fillDefineThresholdRuleAndContinue = (rule: ThresholdRule) => {
271273
};
272274

273275
export const fillDefineEqlRuleAndContinue = (rule: CustomRule) => {
274-
cy.get(EQL_QUERY_INPUT).should('exist');
275-
cy.get(EQL_QUERY_INPUT).should('be.visible');
276-
cy.get(EQL_QUERY_INPUT).type(rule.customQuery!);
277-
cy.get(EQL_QUERY_VALIDATION_SPINNER).should('not.exist');
278-
cy.get(QUERY_PREVIEW_BUTTON).should('not.be.disabled').click({ force: true });
276+
cy.get(RULES_CREATION_FORM).find(EQL_QUERY_INPUT).should('exist');
277+
cy.get(RULES_CREATION_FORM).find(EQL_QUERY_INPUT).should('be.visible');
278+
cy.get(RULES_CREATION_FORM).find(EQL_QUERY_INPUT).type(rule.customQuery!);
279+
cy.get(RULES_CREATION_FORM).find(EQL_QUERY_VALIDATION_SPINNER).should('not.exist');
280+
cy.get(RULES_CREATION_PREVIEW)
281+
.find(QUERY_PREVIEW_BUTTON)
282+
.should('not.be.disabled')
283+
.click({ force: true });
279284
cy.get(EQL_QUERY_PREVIEW_HISTOGRAM)
280285
.invoke('text')
281286
.then((text) => {
282287
if (text !== 'Hits') {
283-
cy.get(QUERY_PREVIEW_BUTTON).click({ force: true });
288+
cy.get(RULES_CREATION_PREVIEW).find(QUERY_PREVIEW_BUTTON).click({ force: true });
284289
cy.get(EQL_QUERY_PREVIEW_HISTOGRAM).should('contain.text', 'Hits');
285290
}
286291
});
287292
cy.get(TOAST_ERROR).should('not.exist');
288293

289294
cy.get(DEFINE_CONTINUE_BUTTON).should('exist').click({ force: true });
290-
cy.get(EQL_QUERY_INPUT).should('not.exist');
295+
cy.get(`${RULES_CREATION_FORM} ${EQL_QUERY_INPUT}`).should('not.exist');
291296
};
292297

293298
/**
@@ -480,7 +485,7 @@ export const waitForAlertsToPopulate = async () => {
480485

481486
export const waitForTheRuleToBeExecuted = () => {
482487
cy.waitUntil(() => {
483-
cy.get(REFRESH_BUTTON).click();
488+
cy.get(REFRESH_BUTTON).click({ force: true });
484489
return cy
485490
.get(RULE_STATUS)
486491
.invoke('text')

x-pack/plugins/security_solution/cypress/tasks/date_picker.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
DATE_PICKER_START_DATE_POPOVER_BUTTON,
1616
DATE_PICKER_START_DATE_POPOVER_BUTTON_TIMELINE,
1717
} from '../screens/date_picker';
18+
import { TIMELINE_FLYOUT_HEADER } from '../screens/timeline';
1819

1920
export const setEndDate = (date: string) => {
2021
cy.get(DATE_PICKER_END_DATE_POPOVER_BUTTON).click({ force: true });
@@ -33,7 +34,7 @@ export const setStartDate = (date: string) => {
3334
};
3435

3536
export const setTimelineEndDate = (date: string) => {
36-
cy.get(DATE_PICKER_END_DATE_POPOVER_BUTTON_TIMELINE).click({ force: true });
37+
cy.get(DATE_PICKER_END_DATE_POPOVER_BUTTON_TIMELINE).first().click({ force: true });
3738

3839
cy.get(DATE_PICKER_ABSOLUTE_TAB).first().click({ force: true });
3940

@@ -47,7 +48,7 @@ export const setTimelineEndDate = (date: string) => {
4748
};
4849

4950
export const setTimelineStartDate = (date: string) => {
50-
cy.get(DATE_PICKER_START_DATE_POPOVER_BUTTON_TIMELINE).click({
51+
cy.get(DATE_PICKER_START_DATE_POPOVER_BUTTON_TIMELINE).first().click({
5152
force: true,
5253
});
5354

@@ -68,6 +69,7 @@ export const updateDates = () => {
6869

6970
export const updateTimelineDates = () => {
7071
cy.get(DATE_PICKER_APPLY_BUTTON_TIMELINE)
72+
.first()
7173
.click({ force: true })
7274
.should('not.have.text', 'Updating');
7375
};

x-pack/plugins/security_solution/public/timelines/components/flyout/header/index.tsx

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -126,19 +126,18 @@ const FlyoutHeaderPanelComponent: React.FC<FlyoutHeaderPanelProps> = ({ timeline
126126
{show && (
127127
<EuiFlexItem grow={false}>
128128
<EuiFlexGroup gutterSize="s">
129-
{activeTab === TimelineTabs.query ||
130-
(activeTab === TimelineTabs.eql && (
131-
<EuiFlexItem grow={false}>
132-
<InspectButton
133-
compact
134-
queryId={`${timelineId}-${activeTab}`}
135-
inputId="timeline"
136-
inspectIndex={0}
137-
isDisabled={!isDataInTimeline}
138-
title={i18n.INSPECT_TIMELINE_TITLE}
139-
/>
140-
</EuiFlexItem>
141-
))}
129+
{(activeTab === TimelineTabs.query || activeTab === TimelineTabs.eql) && (
130+
<EuiFlexItem grow={false}>
131+
<InspectButton
132+
compact
133+
queryId={`${timelineId}-${activeTab}`}
134+
inputId="timeline"
135+
inspectIndex={0}
136+
isDisabled={!isDataInTimeline}
137+
title={i18n.INSPECT_TIMELINE_TITLE}
138+
/>
139+
</EuiFlexItem>
140+
)}
142141
<EuiFlexItem grow={false}>
143142
<EuiToolTip content={i18n.CLOSE_TIMELINE}>
144143
<EuiButtonIcon

0 commit comments

Comments
 (0)