Skip to content

Commit d7b7a11

Browse files
authored
[Security Analytics] Fix cypress tests (#1765)
* [Security Analytics] Fix cypress tests Signed-off-by: vikhy-aws <[email protected]> * [Security Analytics] Fix flakiness in cypress tests Signed-off-by: vikhy-aws <[email protected]> --------- Signed-off-by: vikhy-aws <[email protected]>
1 parent 0e4e715 commit d7b7a11

File tree

3 files changed

+32
-18
lines changed

3 files changed

+32
-18
lines changed

cypress/integration/plugins/security-analytics-dashboards-plugin/1_detectors.spec.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,11 @@ const fillDetailsForm = (
153153
getDataSourceField().sa_selectComboboxItem(dataSource);
154154
}
155155

156-
getDataSourceField().focus().blur();
156+
getDataSourceField().focus();
157+
getDataSourceField().blur();
157158
getLogTypeField().sa_selectComboboxItem(getLogTypeLabel(cypressLogTypeDns));
158-
getLogTypeField().focus().blur();
159+
getLogTypeField().focus();
160+
getLogTypeField().blur();
159161
};
160162

161163
const createDetector = (detectorName, dataSource, expectFailure) => {
@@ -283,7 +285,8 @@ describe('Detectors', () => {
283285

284286
it('...should validate name field', () => {
285287
getNameField().should('be.empty');
286-
getNameField().focus().blur();
288+
getNameField().focus();
289+
getNameField().blur();
287290
getNameField()
288291
.parentsUntil('.euiFormRow__fieldWrapper')
289292
.siblings()
@@ -409,7 +412,8 @@ describe('Detectors', () => {
409412
fillDetailsForm(detectorName, cypressIndexDns);
410413

411414
getDataSourceField().sa_selectComboboxItem(cypressIndexWindows);
412-
getDataSourceField().focus().blur();
415+
getDataSourceField().focus();
416+
getDataSourceField().blur();
413417

414418
cy.get('[data-test-subj="define-detector-diff-log-types-warning"]')
415419
.should('be.visible')

cypress/integration/plugins/security-analytics-dashboards-plugin/2_rules.spec.js

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,8 @@ describe('Rules', () => {
246246
);
247247

248248
getNameField().should('be.empty');
249-
getNameField().focus().blur();
249+
getNameField().focus();
250+
getNameField().blur();
250251
getNameField().sa_containsError('Rule name is required');
251252

252253
getNameField()
@@ -305,7 +306,8 @@ describe('Rules', () => {
305306
);
306307

307308
getAuthorField().should('be.empty');
308-
getAuthorField().focus().blur();
309+
getAuthorField().focus();
310+
getAuthorField().blur();
309311

310312
let invalidAuthor = '';
311313

@@ -327,7 +329,8 @@ describe('Rules', () => {
327329

328330
it('...should validate log type field', () => {
329331
getLogTypeField().should('be.empty');
330-
getLogTypeField().focus().blur();
332+
getLogTypeField().focus();
333+
getLogTypeField().blur();
331334
getLogTypeField().sa_containsError('Log type is required');
332335

333336
getLogTypeField().sa_selectComboboxItem(
@@ -338,27 +341,34 @@ describe('Rules', () => {
338341

339342
it('...should validate rule level field', () => {
340343
getRuleLevelField().should('be.empty');
341-
getRuleLevelField().focus().blur();
344+
getRuleLevelField().focus();
345+
getRuleLevelField().blur();
342346
getRuleLevelField().sa_containsError('Rule level is required');
343347

344348
getRuleLevelField().sa_selectComboboxItem(SAMPLE_RULE.severity);
345-
getRuleLevelField().focus().blur().sa_shouldNotHaveError();
349+
getRuleLevelField().focus();
350+
getRuleLevelField().blur();
351+
getRuleLevelField().sa_shouldNotHaveError();
346352
});
347353

348354
it('...should validate rule status field', () => {
349355
getRuleStatusField().sa_containsValue(SAMPLE_RULE.status);
350-
getRuleStatusField().focus().blur().sa_shouldNotHaveError();
356+
getRuleStatusField().focus();
357+
getRuleStatusField().blur();
358+
getRuleStatusField().sa_shouldNotHaveError();
351359

352360
getRuleStatusField().sa_clearCombobox();
353-
getRuleStatusField().focus().blur();
361+
getRuleStatusField().focus();
362+
getRuleStatusField().blur();
354363
getRuleStatusField().sa_containsError('Rule status is required');
355364
});
356365

357366
it('...should validate selection', () => {
358367
getSelectionPanelByIndex(0).within(() => {
359368
getSelectionNameField().should('have.value', 'Selection_1');
360369
getSelectionNameField().sa_clearValue();
361-
getSelectionNameField().focus().blur();
370+
getSelectionNameField().focus();
371+
getSelectionNameField().blur();
362372
getSelectionNameField()
363373
.parentsUntil('.euiFormRow__fieldWrapper')
364374
.siblings()
@@ -403,7 +413,8 @@ describe('Rules', () => {
403413
it('...should validate selection map value field', () => {
404414
getSelectionPanelByIndex(0).within(() => {
405415
getMapValueField().should('be.empty');
406-
getMapValueField().focus().blur();
416+
getMapValueField().focus();
417+
getMapValueField().blur();
407418
getMapValueField()
408419
.parentsUntil('.euiFormRow__fieldWrapper')
409420
.siblings()
@@ -423,7 +434,8 @@ describe('Rules', () => {
423434
getSelectionPanelByIndex(0).within(() => {
424435
getListRadioField().click({ force: true });
425436
getMapListField().should('be.empty');
426-
getMapListField().focus().blur();
437+
getMapListField().focus();
438+
getMapListField().blur();
427439
getMapListField()
428440
.parentsUntil('.euiFormRow')
429441
.contains('Value is required');
@@ -450,7 +462,8 @@ describe('Rules', () => {
450462

451463
it('...should validate tag field', () => {
452464
getTagField(0).should('be.empty');
453-
getTagField(0).type('wrong.tag').focus().blur();
465+
getTagField(0).type('wrong.tag').focus();
466+
getTagField(0).type('wrong.tag').blur();
454467
getTagField(0)
455468
.parents('.euiFormRow__fieldWrapper')
456469
.contains("Tags must start with 'attack.'");

cypress/integration/plugins/security-analytics-dashboards-plugin/3_alerts.spec.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,6 @@ describe('Alerts', () => {
272272
2
273273
);
274274
const documentLines = document.split('\n');
275-
cy.get(
276-
'[data-test-subj="finding-details-flyout-document-toggle-0"]'
277-
).click({ force: true });
278275
cy.get('[data-test-subj="finding-details-flyout-rule-document-0"]')
279276
.get('[class="euiCodeBlock__line"]')
280277
.each((lineElement, lineIndex) => {

0 commit comments

Comments
 (0)