Skip to content

Commit ad7a2a0

Browse files
committed
Fix unit and Cypress tests
1 parent 709ca98 commit ad7a2a0

5 files changed

Lines changed: 18 additions & 17 deletions

File tree

x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_custom.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import {
3333
DEFINE_CONTINUE_BUTTON,
3434
DEFINE_EDIT_BUTTON,
3535
DEFINE_INDEX_INPUT,
36-
RISK_INPUT,
36+
DEFAULT_RISK_SCORE_INPUT,
3737
RULE_DESCRIPTION_INPUT,
3838
RULE_NAME_INPUT,
3939
SCHEDULE_INTERVAL_AMOUNT_INPUT,
@@ -318,7 +318,7 @@ describe.skip('Custom detection rules deletion and edition', () => {
318318
cy.get(RULE_DESCRIPTION_INPUT).should('have.text', existingRule.description);
319319
cy.get(TAGS_FIELD).should('have.text', existingRule.tags.join(''));
320320
cy.get(SEVERITY_DROPDOWN).should('have.text', existingRule.severity);
321-
cy.get(RISK_INPUT).invoke('val').should('eql', existingRule.riskScore);
321+
cy.get(DEFAULT_RISK_SCORE_INPUT).invoke('val').should('eql', existingRule.riskScore);
322322

323323
goToScheduleStepTab();
324324

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,11 @@ export const REFERENCE_URLS_INPUT =
101101

102102
export const REFRESH_BUTTON = '[data-test-subj="refreshButton"]';
103103

104-
export const RISK_INPUT = '.euiRangeInput';
104+
export const DEFAULT_RISK_SCORE_INPUT =
105+
'[data-test-subj="detectionEngineStepAboutRuleRiskScore-defaultRiskRange"].euiRangeInput';
106+
107+
export const DEFAULT_RISK_SCORE_SLIDER =
108+
'[data-test-subj="detectionEngineStepAboutRuleRiskScore-defaultRiskRange"].euiRangeSlider';
105109

106110
export const RISK_MAPPING_OVERRIDE_OPTION = '#risk_score-mapping-override';
107111

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

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,23 +65,20 @@ export const reload = (afterReload: () => void) => {
6565
};
6666

6767
export const cleanKibana = () => {
68-
cy.exec(`curl -XDELETE "${Cypress.env('ELASTICSEARCH_URL')}/.kibana\*" -k`);
68+
const kibanaIndexUrl = `${Cypress.env('ELASTICSEARCH_URL')}/.kibana\*`;
6969

70-
// We wait until the kibana indexes are deleted
70+
// Delete kibana indexes and wait until they are deleted
71+
cy.request('DELETE', kibanaIndexUrl);
7172
cy.waitUntil(() => {
7273
cy.wait(500);
73-
return cy
74-
.request(`${Cypress.env('ELASTICSEARCH_URL')}/.kibana\*`)
75-
.then((response) => JSON.stringify(response.body) === '{}');
74+
return cy.request(kibanaIndexUrl).then((response) => JSON.stringify(response.body) === '{}');
7675
});
77-
esArchiverLoadEmptyKibana();
7876

79-
// We wait until the kibana indexes are created
77+
// Load kibana indexes and wait until they are created
78+
esArchiverLoadEmptyKibana();
8079
cy.waitUntil(() => {
8180
cy.wait(500);
82-
return cy
83-
.request(`${Cypress.env('ELASTICSEARCH_URL')}/.kibana\*`)
84-
.then((response) => JSON.stringify(response.body) !== '{}');
81+
return cy.request(kibanaIndexUrl).then((response) => JSON.stringify(response.body) !== '{}');
8582
});
8683

8784
removeSignalsIndex();

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import {
3838
MITRE_TACTIC,
3939
REFERENCE_URLS_INPUT,
4040
REFRESH_BUTTON,
41-
RISK_INPUT,
41+
DEFAULT_RISK_SCORE_INPUT,
4242
RISK_MAPPING_OVERRIDE_OPTION,
4343
RISK_OVERRIDE,
4444
RULE_DESCRIPTION_INPUT,
@@ -91,7 +91,7 @@ export const fillAboutRule = (
9191
cy.get(SEVERITY_DROPDOWN).click({ force: true });
9292
cy.get(`#${rule.severity.toLowerCase()}`).click();
9393

94-
cy.get(RISK_INPUT).clear({ force: true }).type(`${rule.riskScore}`, { force: true });
94+
cy.get(DEFAULT_RISK_SCORE_INPUT).type(`{selectall}${rule.riskScore}`, { force: true });
9595

9696
rule.tags.forEach((tag) => {
9797
cy.get(TAGS_INPUT).type(`${tag}{enter}`, { force: true });
@@ -169,7 +169,7 @@ export const fillAboutRuleWithOverrideAndContinue = (rule: OverrideRule) => {
169169
cy.get(COMBO_BOX_INPUT).type(`${rule.riskOverride}{enter}`);
170170
});
171171

172-
cy.get(RISK_INPUT).clear({ force: true }).type(`${rule.riskScore}`, { force: true });
172+
cy.get(DEFAULT_RISK_SCORE_INPUT).type(`{selectall}${rule.riskScore}`, { force: true });
173173

174174
rule.tags.forEach((tag) => {
175175
cy.get(TAGS_INPUT).type(`${tag}{enter}`, { force: true });

x-pack/plugins/security_solution/public/detections/components/rules/step_about_rule/index.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ describe('StepAboutRuleComponent', () => {
206206
.simulate('change', { target: { value: 'Test description text' } });
207207

208208
wrapper
209-
.find('[data-test-subj="detectionEngineStepAboutRuleRiskScore"] input')
209+
.find('[data-test-subj="detectionEngineStepAboutRuleRiskScore-defaultRisk"] input')
210210
.first()
211211
.simulate('change', { target: { value: '80' } });
212212

0 commit comments

Comments
 (0)