-
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
Removes archives #86537
Removes archives #86537
Changes from 19 commits
3d7a451
b5a0e25
daf466d
aea2a41
2ef701a
a9c0400
b7ad376
3099793
99c3688
2205516
828ab3f
611b5ba
af163ac
40e4504
e78c001
7f8aa5f
0c4c485
6704df6
15a87ca
630409d
89fe2c0
ef8393d
4d2390e
e42b392
a8a4570
e91583b
1247931
fcd352a
ee296ca
5e44d0d
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
import { newRule } from '../objects/rule'; | ||
import { | ||
ALERTS, | ||
ALERTS_COUNT, | ||
|
@@ -24,37 +25,35 @@ import { | |
waitForAlertsToBeLoaded, | ||
markInProgressFirstAlert, | ||
goToInProgressAlerts, | ||
waitForAlertsIndexToBeCreated, | ||
} from '../tasks/alerts'; | ||
import { removeSignalsIndex } from '../tasks/api_calls/rules'; | ||
import { createCustomRuleActivated } from '../tasks/api_calls/rules'; | ||
import { cleanKibana } from '../tasks/common'; | ||
import { esArchiverLoad, esArchiverUnload } from '../tasks/es_archiver'; | ||
import { waitForAlertsToPopulate } from '../tasks/create_new_rule'; | ||
import { loginAndWaitForPage } from '../tasks/login'; | ||
import { refreshPage } from '../tasks/security_header'; | ||
|
||
import { DETECTIONS_URL } from '../urls/navigation'; | ||
|
||
describe('Alerts', () => { | ||
context('Closing alerts', () => { | ||
beforeEach(() => { | ||
cleanKibana(); | ||
removeSignalsIndex(); | ||
esArchiverLoad('alerts'); | ||
loginAndWaitForPage(DETECTIONS_URL); | ||
}); | ||
|
||
afterEach(() => { | ||
esArchiverUnload('alerts'); | ||
waitForAlertsPanelToBeLoaded(); | ||
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. I'm a little bit wary of moving these steps into a beforeEach because of the fail-fast behavior and potential for false negatives, but I think that the speed and DRYness of this approach make it an acceptable tradeoff. |
||
waitForAlertsIndexToBeCreated(); | ||
createCustomRuleActivated(newRule); | ||
refreshPage(); | ||
waitForAlertsToPopulate(); | ||
}); | ||
|
||
it('Closes and opens alerts', () => { | ||
waitForAlertsPanelToBeLoaded(); | ||
waitForAlertsToBeLoaded(); | ||
|
||
const numberOfAlertsToBeClosed = 3; | ||
cy.get(ALERTS_COUNT) | ||
.invoke('text') | ||
.then((numberOfAlerts) => { | ||
cy.get(SHOWING_ALERTS).should('have.text', `Showing ${numberOfAlerts} alerts`); | ||
|
||
const numberOfAlertsToBeClosed = 3; | ||
selectNumberOfAlerts(numberOfAlertsToBeClosed); | ||
|
||
cy.get(SELECTED_ALERTS).should( | ||
|
@@ -64,8 +63,6 @@ describe('Alerts', () => { | |
|
||
closeAlerts(); | ||
waitForAlerts(); | ||
cy.reload(); | ||
waitForAlerts(); | ||
|
||
const expectedNumberOfAlertsAfterClosing = +numberOfAlerts - numberOfAlertsToBeClosed; | ||
cy.get(ALERTS_COUNT).should('have.text', expectedNumberOfAlertsAfterClosing.toString()); | ||
|
@@ -92,11 +89,6 @@ describe('Alerts', () => { | |
|
||
openAlerts(); | ||
waitForAlerts(); | ||
cy.reload(); | ||
waitForAlertsToBeLoaded(); | ||
waitForAlerts(); | ||
goToClosedAlerts(); | ||
waitForAlerts(); | ||
|
||
const expectedNumberOfClosedAlertsAfterOpened = 2; | ||
cy.get(ALERTS_COUNT).should( | ||
|
@@ -124,8 +116,6 @@ describe('Alerts', () => { | |
}); | ||
|
||
it('Closes one alert when more than one opened alerts are selected', () => { | ||
waitForAlertsToBeLoaded(); | ||
|
||
cy.get(ALERTS_COUNT) | ||
.invoke('text') | ||
.then((numberOfAlerts) => { | ||
|
@@ -137,8 +127,6 @@ describe('Alerts', () => { | |
cy.get(TAKE_ACTION_POPOVER_BTN).should('not.have.attr', 'disabled'); | ||
|
||
closeFirstAlert(); | ||
cy.reload(); | ||
waitForAlertsToBeLoaded(); | ||
waitForAlerts(); | ||
|
||
const expectedNumberOfAlerts = +numberOfAlerts - numberOfAlertsToBeClosed; | ||
|
@@ -164,73 +152,82 @@ describe('Alerts', () => { | |
context('Opening alerts', () => { | ||
beforeEach(() => { | ||
cleanKibana(); | ||
removeSignalsIndex(); | ||
esArchiverLoad('closed_alerts'); | ||
loginAndWaitForPage(DETECTIONS_URL); | ||
}); | ||
waitForAlertsPanelToBeLoaded(); | ||
waitForAlertsIndexToBeCreated(); | ||
createCustomRuleActivated(newRule); | ||
refreshPage(); | ||
waitForAlertsToPopulate(); | ||
selectNumberOfAlerts(5); | ||
|
||
cy.get(SELECTED_ALERTS).should('have.text', `Selected 5 alerts`); | ||
|
||
afterEach(() => { | ||
esArchiverUnload('closed_alerts'); | ||
closeAlerts(); | ||
waitForAlerts(); | ||
refreshPage(); | ||
}); | ||
|
||
it('Open one alert when more than one closed alerts are selected', () => { | ||
waitForAlerts(); | ||
goToClosedAlerts(); | ||
waitForAlertsToBeLoaded(); | ||
waitForAlertsToPopulate(); | ||
|
||
cy.get(ALERTS_COUNT) | ||
.invoke('text') | ||
.then((numberOfAlerts) => { | ||
const numberOfAlertsToBeOpened = 1; | ||
const numberOfAlertsToBeSelected = 3; | ||
|
||
cy.get(TAKE_ACTION_POPOVER_BTN).should('have.attr', 'disabled'); | ||
selectNumberOfAlerts(numberOfAlertsToBeSelected); | ||
cy.get(TAKE_ACTION_POPOVER_BTN).should('not.have.attr', 'disabled'); | ||
|
||
openFirstAlert(); | ||
cy.reload(); | ||
.then((numberOfOpenedAlertsText) => { | ||
const numberOfOpenedAlerts = parseInt(numberOfOpenedAlertsText, 10); | ||
goToClosedAlerts(); | ||
waitForAlertsToBeLoaded(); | ||
waitForAlerts(); | ||
|
||
const expectedNumberOfAlerts = +numberOfAlerts - numberOfAlertsToBeOpened; | ||
cy.get(ALERTS_COUNT).should('have.text', expectedNumberOfAlerts.toString()); | ||
cy.get(SHOWING_ALERTS).should( | ||
'have.text', | ||
`Showing ${expectedNumberOfAlerts.toString()} alerts` | ||
); | ||
|
||
goToOpenedAlerts(); | ||
waitForAlerts(); | ||
|
||
cy.get(ALERTS_COUNT).should('have.text', numberOfAlertsToBeOpened.toString()); | ||
cy.get(SHOWING_ALERTS).should( | ||
'have.text', | ||
`Showing ${numberOfAlertsToBeOpened.toString()} alert` | ||
); | ||
cy.get(ALERTS).should('have.length', numberOfAlertsToBeOpened); | ||
cy.get(ALERTS_COUNT) | ||
.invoke('text') | ||
.then((numberOfAlerts) => { | ||
const numberOfAlertsToBeOpened = 1; | ||
const numberOfAlertsToBeSelected = 3; | ||
|
||
cy.get(TAKE_ACTION_POPOVER_BTN).should('have.attr', 'disabled'); | ||
selectNumberOfAlerts(numberOfAlertsToBeSelected); | ||
cy.get(SELECTED_ALERTS).should( | ||
'have.text', | ||
`Selected ${numberOfAlertsToBeSelected} alerts` | ||
); | ||
|
||
cy.get(TAKE_ACTION_POPOVER_BTN).should('not.have.attr', 'disabled'); | ||
|
||
openFirstAlert(); | ||
waitForAlerts(); | ||
|
||
const expectedNumberOfAlerts = +numberOfAlerts - numberOfAlertsToBeOpened; | ||
cy.get(ALERTS_COUNT).should('have.text', expectedNumberOfAlerts.toString()); | ||
cy.get(SHOWING_ALERTS).should( | ||
'have.text', | ||
`Showing ${expectedNumberOfAlerts.toString()} alerts` | ||
); | ||
|
||
goToOpenedAlerts(); | ||
waitForAlerts(); | ||
|
||
cy.get(ALERTS_COUNT).should( | ||
'have.text', | ||
(numberOfOpenedAlerts + numberOfAlertsToBeOpened).toString() | ||
); | ||
cy.get(SHOWING_ALERTS).should( | ||
'have.text', | ||
`Showing ${(numberOfOpenedAlerts + numberOfAlertsToBeOpened).toString()} alerts` | ||
); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
context('Marking alerts as in-progress', () => { | ||
beforeEach(() => { | ||
cleanKibana(); | ||
removeSignalsIndex(); | ||
esArchiverLoad('alerts'); | ||
loginAndWaitForPage(DETECTIONS_URL); | ||
}); | ||
|
||
afterEach(() => { | ||
esArchiverUnload('alerts'); | ||
removeSignalsIndex(); | ||
waitForAlertsPanelToBeLoaded(); | ||
waitForAlertsIndexToBeCreated(); | ||
createCustomRuleActivated(newRule); | ||
refreshPage(); | ||
waitForAlertsToPopulate(); | ||
}); | ||
|
||
it('Mark one alert in progress when more than one open alerts are selected', () => { | ||
waitForAlerts(); | ||
waitForAlertsToBeLoaded(); | ||
|
||
cy.get(ALERTS_COUNT) | ||
.invoke('text') | ||
.then((numberOfAlerts) => { | ||
|
@@ -242,8 +239,6 @@ describe('Alerts', () => { | |
cy.get(TAKE_ACTION_POPOVER_BTN).should('not.have.attr', 'disabled'); | ||
|
||
markInProgressFirstAlert(); | ||
cy.reload(); | ||
goToOpenedAlerts(); | ||
waitForAlertsToBeLoaded(); | ||
|
||
const expectedNumberOfAlerts = +numberOfAlerts - numberOfAlertsToBeMarkedInProgress; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,12 @@ | |
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
import { | ||
FIFTH_RULE, | ||
FIRST_RULE, | ||
RULE_NAME, | ||
RULE_SWITCH, | ||
SECOND_RULE, | ||
SEVENTH_RULE, | ||
RULE_AUTO_REFRESH_IDLE_MODAL, | ||
FOURTH_RULE, | ||
} from '../screens/alerts_detection_rules'; | ||
|
||
import { | ||
|
@@ -28,43 +27,45 @@ import { | |
waitForLoadElasticPrebuiltDetectionRulesTableToBeLoaded, | ||
waitForRuleToBeActivated, | ||
} from '../tasks/alerts_detection_rules'; | ||
import { esArchiverLoad, esArchiverUnload } from '../tasks/es_archiver'; | ||
import { loginAndWaitForPageWithoutDateRange } from '../tasks/login'; | ||
import { DEFAULT_RULE_REFRESH_INTERVAL_VALUE } from '../../common/constants'; | ||
|
||
import { DETECTIONS_URL } from '../urls/navigation'; | ||
import { removeSignalsIndex } from '../tasks/api_calls/rules'; | ||
import { createCustomRule, removeSignalsIndex } from '../tasks/api_calls/rules'; | ||
import { cleanKibana } from '../tasks/common'; | ||
import { existingRule, newOverrideRule, newRule, newThresholdRule } from '../objects/rule'; | ||
|
||
describe('Alerts detection rules', () => { | ||
before(() => { | ||
beforeEach(() => { | ||
cleanKibana(); | ||
removeSignalsIndex(); | ||
esArchiverLoad('prebuilt_rules_loaded'); | ||
loginAndWaitForPageWithoutDateRange(DETECTIONS_URL); | ||
waitForAlertsPanelToBeLoaded(); | ||
waitForAlertsIndexToBeCreated(); | ||
createCustomRule(newRule, 'rule1'); | ||
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. 💯 this is so much better, it's immediately clear that we're working with four rules in this test. |
||
createCustomRule(existingRule, 'rule2'); | ||
createCustomRule(newOverrideRule, 'rule3'); | ||
createCustomRule(newThresholdRule, 'rule4'); | ||
}); | ||
|
||
after(() => { | ||
esArchiverUnload('prebuilt_rules_loaded'); | ||
cy.clock().invoke('restore'); | ||
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. Nit: this teardown is specific to a single time-traveling test. It would be nice if such tests were isolated in their own context with clock-specific setup/teardown hooks. |
||
}); | ||
|
||
it('Sorts by activated rules', () => { | ||
loginAndWaitForPageWithoutDateRange(DETECTIONS_URL); | ||
waitForAlertsPanelToBeLoaded(); | ||
waitForAlertsIndexToBeCreated(); | ||
goToManageAlertsDetectionRules(); | ||
waitForLoadElasticPrebuiltDetectionRulesTableToBeLoaded(); | ||
|
||
cy.get(RULE_NAME) | ||
.eq(FIFTH_RULE) | ||
.eq(SECOND_RULE) | ||
.invoke('text') | ||
.then((fifthRuleName) => { | ||
activateRule(FIFTH_RULE); | ||
.then((secondInitialRuleName) => { | ||
activateRule(SECOND_RULE); | ||
waitForRuleToBeActivated(); | ||
cy.get(RULE_NAME) | ||
.eq(SEVENTH_RULE) | ||
.eq(FOURTH_RULE) | ||
.invoke('text') | ||
.then((seventhRuleName) => { | ||
activateRule(SEVENTH_RULE); | ||
.then((fourthInitialRuleName) => { | ||
activateRule(FOURTH_RULE); | ||
waitForRuleToBeActivated(); | ||
sortByActivatedRules(); | ||
cy.get(RULE_NAME) | ||
|
@@ -76,8 +77,8 @@ describe('Alerts detection rules', () => { | |
.invoke('text') | ||
.then((secondRuleName) => { | ||
const expectedRulesNames = `${firstRuleName} ${secondRuleName}`; | ||
cy.wrap(expectedRulesNames).should('include', fifthRuleName); | ||
cy.wrap(expectedRulesNames).should('include', seventhRuleName); | ||
cy.wrap(expectedRulesNames).should('include', secondInitialRuleName); | ||
cy.wrap(expectedRulesNames).should('include', fourthInitialRuleName); | ||
}); | ||
}); | ||
cy.get(RULE_SWITCH).eq(FIRST_RULE).should('have.attr', 'role', 'switch'); | ||
|
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.
Rather than leaving this as a task for the test writer, we could enforce it as a global
beforeEach
hook.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.
Here I'm not 100% sure. There are some cases where using before instead of beforeEach, save us execution time. So we need to take into consideration that if we move that to a global hook, we are going to make our tests more slow. Another reason is because I don't like how Cypress handles right now global hooks.
Anyway, this is a think we can investigate/work in a different PR :)