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

[Security Solution] Improves detections tests #77295

Merged
merged 26 commits into from
Sep 29, 2020
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ee00b9f
improves 'Creates and activates a new custom rule' test
MadameSheema Sep 10, 2020
5e3f5d5
fixes constant problem
MadameSheema Sep 13, 2020
0b5afe1
improves 'Creates and activates a new custom rule with override optio…
MadameSheema Sep 13, 2020
0c34e9b
improves 'Creates and activates a new threshold rule' test
MadameSheema Sep 13, 2020
d97ef1a
Merge branch 'master' into improves-detections
MadameSheema Sep 16, 2020
56c4c92
refactor
MadameSheema Sep 16, 2020
5ac8324
fixes type check issue
MadameSheema Sep 17, 2020
579fb54
Merge branch 'master' into improves-detections
elasticmachine Sep 17, 2020
9486073
improves assertions
MadameSheema Sep 17, 2020
f41a9e8
Merge branch 'improves-detections' of github.com:MadameSheema/kibana …
MadameSheema Sep 17, 2020
a1948b1
Merge branch 'master' into improves-detections
elasticmachine Sep 20, 2020
5a48b9b
Merge branch 'master' into improves-detections
elasticmachine Sep 23, 2020
578ce01
removes unused code
MadameSheema Sep 23, 2020
f9c3555
changes variables for constants
MadameSheema Sep 23, 2020
6fe2d60
improves 'waitForTheRuleToBeExecuted' test
MadameSheema Sep 23, 2020
905ee85
improves readability
MadameSheema Sep 23, 2020
c061b7a
Merge branch 'master' into improves-detections
elasticmachine Sep 24, 2020
da955b6
Merge branch 'master' into improves-detections
elasticmachine Sep 24, 2020
6a2ec50
Merge branch 'master' into improves-detections
elasticmachine Sep 24, 2020
26e6298
Merge branch 'master' into improves-detections
elasticmachine Sep 24, 2020
492cf98
fixes jenkins error
MadameSheema Sep 26, 2020
2fe6861
Merge branch 'master' into improves-detections
elasticmachine Sep 26, 2020
1e7dde8
refactor
MadameSheema Sep 27, 2020
3b8ca5e
Merge branch 'improves-detections' of github.com:MadameSheema/kibana …
MadameSheema Sep 27, 2020
1dec5b2
refactor
MadameSheema Sep 28, 2020
f683221
Merge branch 'master' into improves-detections
elasticmachine Sep 29, 2020
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
65 changes: 35 additions & 30 deletions x-pack/plugins/security_solution/cypress/integration/alerts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,24 +140,25 @@ describe('Alerts', () => {
waitForAlerts();

const expectedNumberOfAlerts = +numberOfAlerts - numberOfAlertsToBeClosed;
cy.get(NUMBER_OF_ALERTS).invoke('text').should('eq', expectedNumberOfAlerts.toString());
cy.get(SHOWING_ALERTS)
.invoke('text')
.should('eql', `Showing ${expectedNumberOfAlerts.toString()} alerts`);
cy.get(NUMBER_OF_ALERTS).should('have.text', expectedNumberOfAlerts.toString());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this is the preference for text assertions, now? Is it more robust, or better errors, or both?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this is the preference now when possible, is more robust because should clause in Cypress will continue to retry its specified assertions until it times out, and also improves the readability of the tests.

cy.get(SHOWING_ALERTS).should(
'have.text',
`Showing ${expectedNumberOfAlerts.toString()} alerts`
);

goToClosedAlerts();
waitForAlerts();

cy.get(NUMBER_OF_ALERTS)
.invoke('text')
.should('eql', numberOfAlertsToBeClosed.toString());
cy.get(SHOWING_ALERTS)
.invoke('text')
.should('eql', `Showing ${numberOfAlertsToBeClosed.toString()} alert`);
cy.get(NUMBER_OF_ALERTS).should('have.text', numberOfAlertsToBeClosed.toString());
cy.get(SHOWING_ALERTS).should(
'have.text',
`Showing ${numberOfAlertsToBeClosed.toString()} alert`
);
cy.get(ALERTS).should('have.length', numberOfAlertsToBeClosed);
});
});
});

context('Opening alerts', () => {
beforeEach(() => {
esArchiverLoad('closed_alerts');
Expand Down Expand Up @@ -186,24 +187,25 @@ describe('Alerts', () => {
waitForAlerts();

const expectedNumberOfAlerts = +numberOfAlerts - numberOfAlertsToBeOpened;
cy.get(NUMBER_OF_ALERTS).invoke('text').should('eq', expectedNumberOfAlerts.toString());
cy.get(SHOWING_ALERTS)
.invoke('text')
.should('eql', `Showing ${expectedNumberOfAlerts.toString()} alerts`);
cy.get(NUMBER_OF_ALERTS).should('have.text', expectedNumberOfAlerts.toString());
cy.get(SHOWING_ALERTS).should(
'have.text',
`Showing ${expectedNumberOfAlerts.toString()} alerts`
);

goToOpenedAlerts();
waitForAlerts();

cy.get(NUMBER_OF_ALERTS)
.invoke('text')
.should('eql', numberOfAlertsToBeOpened.toString());
cy.get(SHOWING_ALERTS)
.invoke('text')
.should('eql', `Showing ${numberOfAlertsToBeOpened.toString()} alert`);
cy.get(NUMBER_OF_ALERTS).should('have.text', numberOfAlertsToBeOpened.toString());
cy.get(SHOWING_ALERTS).should(
'have.text',
`Showing ${numberOfAlertsToBeOpened.toString()} alert`
);
cy.get(ALERTS).should('have.length', numberOfAlertsToBeOpened);
});
});
});

context('Marking alerts as in-progress', () => {
beforeEach(() => {
esArchiverLoad('alerts');
Expand Down Expand Up @@ -231,20 +233,23 @@ describe('Alerts', () => {
waitForAlerts();

const expectedNumberOfAlerts = +numberOfAlerts - numberOfAlertsToBeMarkedInProgress;
cy.get(NUMBER_OF_ALERTS).invoke('text').should('eq', expectedNumberOfAlerts.toString());
cy.get(SHOWING_ALERTS)
.invoke('text')
.should('eql', `Showing ${expectedNumberOfAlerts.toString()} alerts`);
cy.get(NUMBER_OF_ALERTS).should('have.text', expectedNumberOfAlerts.toString());
cy.get(SHOWING_ALERTS).should(
'have.text',
`Showing ${expectedNumberOfAlerts.toString()} alerts`
);

goToInProgressAlerts();
waitForAlerts();

cy.get(NUMBER_OF_ALERTS)
.invoke('text')
.should('eql', numberOfAlertsToBeMarkedInProgress.toString());
cy.get(SHOWING_ALERTS)
.invoke('text')
.should('eql', `Showing ${numberOfAlertsToBeMarkedInProgress.toString()} alert`);
cy.get(NUMBER_OF_ALERTS).should(
'have.text',
numberOfAlertsToBeMarkedInProgress.toString()
);
cy.get(SHOWING_ALERTS).should(
'have.text',
`Showing ${numberOfAlertsToBeMarkedInProgress.toString()} alert`
);
cy.get(ALERTS).should('have.length', numberOfAlertsToBeMarkedInProgress);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ describe('Alerts detection rules', () => {
waitForAlertsIndexToBeCreated();
goToManageAlertsDetectionRules();
waitForLoadElasticPrebuiltDetectionRulesTableToBeLoaded();

cy.get(RULE_NAME)
.eq(FIFTH_RULE)
.invoke('text')
Expand All @@ -56,7 +57,6 @@ describe('Alerts detection rules', () => {
activateRule(SEVENTH_RULE);
waitForRuleToBeActivated();
sortByActivatedRules();

cy.get(RULE_NAME)
.eq(FIRST_RULE)
.invoke('text')
Expand All @@ -70,7 +70,6 @@ describe('Alerts detection rules', () => {
cy.wrap(expectedRulesNames).should('include', seventhRuleName);
});
});

cy.get(RULE_SWITCH).eq(FIRST_RULE).should('have.attr', 'role', 'switch');
cy.get(RULE_SWITCH).eq(SECOND_RULE).should('have.attr', 'role', 'switch');
});
Expand Down
Loading