Skip to content

Commit 1b64f7b

Browse files
MadameSheemapatrykkopycinski
authored andcommitted
Removes archives (#86537)
# Conflicts: # x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_custom.spec.ts
1 parent d4eac7c commit 1b64f7b

50 files changed

Lines changed: 281 additions & 37918 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

x-pack/plugins/security_solution/cypress/README.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,9 @@ CYPRESS_BASE_URL=http(s)://<username>:<password>@<kbnUrl> CYPRESS_ELASTICSEARCH_
179179

180180
## Best Practices
181181

182-
### Clean up the state between tests
182+
### Clean up the state
183183

184-
Remember to clean up the state of the test after its execution.
184+
Remember to use the `cleanKibana` method before starting the execution of the test
185185

186186
### Minimize the use of es_archive
187187

@@ -192,15 +192,12 @@ When possible, create all the data that you need for executing the tests using t
192192
Loading the web page takes a big amount of time, in order to minimize that impact, the following points should be
193193
taken into consideration until another solution is implemented:
194194

195-
- Don't refresh the page for every test to clean the state of it.
196-
- Instead, group the tests that are similar in different contexts.
195+
- Group the tests that are similar in different contexts.
197196
- For every context login only once, clean the state between tests if needed without re-loading the page.
198197
- All tests in a spec file must be order-independent.
199-
- If you need to reload the page to make the tests order-independent, consider to create a new context.
200-
198+
201199
Remember that minimizing the number of times the web page is loaded, we minimize as well the execution time.
202200

203-
204201
## Reporting
205202

206203
When Cypress tests are run on the command line via non visual mode

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

Lines changed: 67 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* or more contributor license agreements. Licensed under the Elastic License;
44
* you may not use this file except in compliance with the Elastic License.
55
*/
6+
import { newRule } from '../objects/rule';
67
import {
78
ALERTS,
89
ALERTS_COUNT,
@@ -24,37 +25,35 @@ import {
2425
waitForAlertsToBeLoaded,
2526
markInProgressFirstAlert,
2627
goToInProgressAlerts,
28+
waitForAlertsIndexToBeCreated,
2729
} from '../tasks/alerts';
28-
import { removeSignalsIndex } from '../tasks/api_calls/rules';
30+
import { createCustomRuleActivated } from '../tasks/api_calls/rules';
2931
import { cleanKibana } from '../tasks/common';
30-
import { esArchiverLoad, esArchiverUnload } from '../tasks/es_archiver';
32+
import { waitForAlertsToPopulate } from '../tasks/create_new_rule';
3133
import { loginAndWaitForPage } from '../tasks/login';
34+
import { refreshPage } from '../tasks/security_header';
3235

3336
import { DETECTIONS_URL } from '../urls/navigation';
3437

3538
describe('Alerts', () => {
3639
context('Closing alerts', () => {
3740
beforeEach(() => {
3841
cleanKibana();
39-
removeSignalsIndex();
40-
esArchiverLoad('alerts');
4142
loginAndWaitForPage(DETECTIONS_URL);
42-
});
43-
44-
afterEach(() => {
45-
esArchiverUnload('alerts');
43+
waitForAlertsPanelToBeLoaded();
44+
waitForAlertsIndexToBeCreated();
45+
createCustomRuleActivated(newRule);
46+
refreshPage();
47+
waitForAlertsToPopulate();
4648
});
4749

4850
it('Closes and opens alerts', () => {
49-
waitForAlertsPanelToBeLoaded();
50-
waitForAlertsToBeLoaded();
51-
51+
const numberOfAlertsToBeClosed = 3;
5252
cy.get(ALERTS_COUNT)
5353
.invoke('text')
5454
.then((numberOfAlerts) => {
5555
cy.get(SHOWING_ALERTS).should('have.text', `Showing ${numberOfAlerts} alerts`);
5656

57-
const numberOfAlertsToBeClosed = 3;
5857
selectNumberOfAlerts(numberOfAlertsToBeClosed);
5958

6059
cy.get(SELECTED_ALERTS).should(
@@ -64,8 +63,6 @@ describe('Alerts', () => {
6463

6564
closeAlerts();
6665
waitForAlerts();
67-
cy.reload();
68-
waitForAlerts();
6966

7067
const expectedNumberOfAlertsAfterClosing = +numberOfAlerts - numberOfAlertsToBeClosed;
7168
cy.get(ALERTS_COUNT).should('have.text', expectedNumberOfAlertsAfterClosing.toString());
@@ -92,11 +89,6 @@ describe('Alerts', () => {
9289

9390
openAlerts();
9491
waitForAlerts();
95-
cy.reload();
96-
waitForAlertsToBeLoaded();
97-
waitForAlerts();
98-
goToClosedAlerts();
99-
waitForAlerts();
10092

10193
const expectedNumberOfClosedAlertsAfterOpened = 2;
10294
cy.get(ALERTS_COUNT).should(
@@ -124,8 +116,6 @@ describe('Alerts', () => {
124116
});
125117

126118
it('Closes one alert when more than one opened alerts are selected', () => {
127-
waitForAlertsToBeLoaded();
128-
129119
cy.get(ALERTS_COUNT)
130120
.invoke('text')
131121
.then((numberOfAlerts) => {
@@ -137,8 +127,6 @@ describe('Alerts', () => {
137127
cy.get(TAKE_ACTION_POPOVER_BTN).should('not.have.attr', 'disabled');
138128

139129
closeFirstAlert();
140-
cy.reload();
141-
waitForAlertsToBeLoaded();
142130
waitForAlerts();
143131

144132
const expectedNumberOfAlerts = +numberOfAlerts - numberOfAlertsToBeClosed;
@@ -164,73 +152,82 @@ describe('Alerts', () => {
164152
context('Opening alerts', () => {
165153
beforeEach(() => {
166154
cleanKibana();
167-
removeSignalsIndex();
168-
esArchiverLoad('closed_alerts');
169155
loginAndWaitForPage(DETECTIONS_URL);
170-
});
156+
waitForAlertsPanelToBeLoaded();
157+
waitForAlertsIndexToBeCreated();
158+
createCustomRuleActivated(newRule);
159+
refreshPage();
160+
waitForAlertsToPopulate();
161+
selectNumberOfAlerts(5);
162+
163+
cy.get(SELECTED_ALERTS).should('have.text', `Selected 5 alerts`);
171164

172-
afterEach(() => {
173-
esArchiverUnload('closed_alerts');
165+
closeAlerts();
166+
waitForAlerts();
167+
refreshPage();
174168
});
175169

176170
it('Open one alert when more than one closed alerts are selected', () => {
177-
waitForAlerts();
178-
goToClosedAlerts();
179-
waitForAlertsToBeLoaded();
171+
waitForAlertsToPopulate();
180172

181173
cy.get(ALERTS_COUNT)
182174
.invoke('text')
183-
.then((numberOfAlerts) => {
184-
const numberOfAlertsToBeOpened = 1;
185-
const numberOfAlertsToBeSelected = 3;
186-
187-
cy.get(TAKE_ACTION_POPOVER_BTN).should('have.attr', 'disabled');
188-
selectNumberOfAlerts(numberOfAlertsToBeSelected);
189-
cy.get(TAKE_ACTION_POPOVER_BTN).should('not.have.attr', 'disabled');
190-
191-
openFirstAlert();
192-
cy.reload();
175+
.then((numberOfOpenedAlertsText) => {
176+
const numberOfOpenedAlerts = parseInt(numberOfOpenedAlertsText, 10);
193177
goToClosedAlerts();
194-
waitForAlertsToBeLoaded();
195-
waitForAlerts();
196-
197-
const expectedNumberOfAlerts = +numberOfAlerts - numberOfAlertsToBeOpened;
198-
cy.get(ALERTS_COUNT).should('have.text', expectedNumberOfAlerts.toString());
199-
cy.get(SHOWING_ALERTS).should(
200-
'have.text',
201-
`Showing ${expectedNumberOfAlerts.toString()} alerts`
202-
);
203-
204-
goToOpenedAlerts();
205-
waitForAlerts();
206-
207-
cy.get(ALERTS_COUNT).should('have.text', numberOfAlertsToBeOpened.toString());
208-
cy.get(SHOWING_ALERTS).should(
209-
'have.text',
210-
`Showing ${numberOfAlertsToBeOpened.toString()} alert`
211-
);
212-
cy.get(ALERTS).should('have.length', numberOfAlertsToBeOpened);
178+
cy.get(ALERTS_COUNT)
179+
.invoke('text')
180+
.then((numberOfAlerts) => {
181+
const numberOfAlertsToBeOpened = 1;
182+
const numberOfAlertsToBeSelected = 3;
183+
184+
cy.get(TAKE_ACTION_POPOVER_BTN).should('have.attr', 'disabled');
185+
selectNumberOfAlerts(numberOfAlertsToBeSelected);
186+
cy.get(SELECTED_ALERTS).should(
187+
'have.text',
188+
`Selected ${numberOfAlertsToBeSelected} alerts`
189+
);
190+
191+
cy.get(TAKE_ACTION_POPOVER_BTN).should('not.have.attr', 'disabled');
192+
193+
openFirstAlert();
194+
waitForAlerts();
195+
196+
const expectedNumberOfAlerts = +numberOfAlerts - numberOfAlertsToBeOpened;
197+
cy.get(ALERTS_COUNT).should('have.text', expectedNumberOfAlerts.toString());
198+
cy.get(SHOWING_ALERTS).should(
199+
'have.text',
200+
`Showing ${expectedNumberOfAlerts.toString()} alerts`
201+
);
202+
203+
goToOpenedAlerts();
204+
waitForAlerts();
205+
206+
cy.get(ALERTS_COUNT).should(
207+
'have.text',
208+
(numberOfOpenedAlerts + numberOfAlertsToBeOpened).toString()
209+
);
210+
cy.get(SHOWING_ALERTS).should(
211+
'have.text',
212+
`Showing ${(numberOfOpenedAlerts + numberOfAlertsToBeOpened).toString()} alerts`
213+
);
214+
});
213215
});
214216
});
215217
});
216218

217219
context('Marking alerts as in-progress', () => {
218220
beforeEach(() => {
219221
cleanKibana();
220-
removeSignalsIndex();
221-
esArchiverLoad('alerts');
222222
loginAndWaitForPage(DETECTIONS_URL);
223-
});
224-
225-
afterEach(() => {
226-
esArchiverUnload('alerts');
227-
removeSignalsIndex();
223+
waitForAlertsPanelToBeLoaded();
224+
waitForAlertsIndexToBeCreated();
225+
createCustomRuleActivated(newRule);
226+
refreshPage();
227+
waitForAlertsToPopulate();
228228
});
229229

230230
it('Mark one alert in progress when more than one open alerts are selected', () => {
231-
waitForAlerts();
232-
waitForAlertsToBeLoaded();
233-
234231
cy.get(ALERTS_COUNT)
235232
.invoke('text')
236233
.then((numberOfAlerts) => {
@@ -242,8 +239,6 @@ describe('Alerts', () => {
242239
cy.get(TAKE_ACTION_POPOVER_BTN).should('not.have.attr', 'disabled');
243240

244241
markInProgressFirstAlert();
245-
cy.reload();
246-
goToOpenedAlerts();
247242
waitForAlertsToBeLoaded();
248243

249244
const expectedNumberOfAlerts = +numberOfAlerts - numberOfAlertsToBeMarkedInProgress;

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
} from '../tasks/login';
1717
import { waitForAlertsIndexToBeCreated } from '../tasks/alerts';
1818
import { goToRuleDetails } from '../tasks/alerts_detection_rules';
19-
import { createCustomRule, deleteCustomRule, removeSignalsIndex } from '../tasks/api_calls/rules';
19+
import { createCustomRule, deleteCustomRule } from '../tasks/api_calls/rules';
2020
import { getCallOut, waitForCallOutToBeShown, dismissCallOut } from '../tasks/common/callouts';
2121
import { cleanKibana } from '../tasks/common';
2222

@@ -42,7 +42,6 @@ describe('Detections > Callouts indicating read-only access to resources', () =>
4242
// First, we have to open the app on behalf of a priviledged user in order to initialize it.
4343
// Otherwise the app will be disabled and show a "welcome"-like page.
4444
cleanKibana();
45-
removeSignalsIndex();
4645
loginAndWaitForPageWithoutDateRange(DETECTIONS_URL, ROLES.platform_engineer);
4746
waitForAlertsIndexToBeCreated();
4847

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
goToOpenedAlerts,
1717
waitForAlertsIndexToBeCreated,
1818
} from '../tasks/alerts';
19-
import { createCustomRule, removeSignalsIndex } from '../tasks/api_calls/rules';
19+
import { createCustomRule } from '../tasks/api_calls/rules';
2020
import { goToRuleDetails } from '../tasks/alerts_detection_rules';
2121
import { waitForAlertsToPopulate } from '../tasks/create_new_rule';
2222
import { esArchiverLoad, esArchiverUnload } from '../tasks/es_archiver';
@@ -35,11 +35,10 @@ import { refreshPage } from '../tasks/security_header';
3535
import { DETECTIONS_URL } from '../urls/navigation';
3636
import { cleanKibana } from '../tasks/common';
3737

38-
describe.skip('Exceptions', () => {
38+
describe('Exceptions', () => {
3939
const NUMBER_OF_AUDITBEAT_EXCEPTIONS_ALERTS = '1';
4040
beforeEach(() => {
4141
cleanKibana();
42-
removeSignalsIndex();
4342
loginAndWaitForPageWithoutDateRange(DETECTIONS_URL);
4443
waitForAlertsIndexToBeCreated();
4544
createCustomRule(newRule);

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

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66
import {
7-
FIFTH_RULE,
87
FIRST_RULE,
98
RULE_NAME,
109
RULE_SWITCH,
1110
SECOND_RULE,
12-
SEVENTH_RULE,
1311
RULE_AUTO_REFRESH_IDLE_MODAL,
12+
FOURTH_RULE,
1413
} from '../screens/alerts_detection_rules';
1514

1615
import {
@@ -28,43 +27,45 @@ import {
2827
waitForLoadElasticPrebuiltDetectionRulesTableToBeLoaded,
2928
waitForRuleToBeActivated,
3029
} from '../tasks/alerts_detection_rules';
31-
import { esArchiverLoad, esArchiverUnload } from '../tasks/es_archiver';
3230
import { loginAndWaitForPageWithoutDateRange } from '../tasks/login';
3331
import { DEFAULT_RULE_REFRESH_INTERVAL_VALUE } from '../../common/constants';
3432

3533
import { DETECTIONS_URL } from '../urls/navigation';
36-
import { removeSignalsIndex } from '../tasks/api_calls/rules';
34+
import { createCustomRule, removeSignalsIndex } from '../tasks/api_calls/rules';
3735
import { cleanKibana } from '../tasks/common';
36+
import { existingRule, newOverrideRule, newRule, newThresholdRule } from '../objects/rule';
3837

3938
describe('Alerts detection rules', () => {
40-
before(() => {
39+
beforeEach(() => {
4140
cleanKibana();
4241
removeSignalsIndex();
43-
esArchiverLoad('prebuilt_rules_loaded');
42+
loginAndWaitForPageWithoutDateRange(DETECTIONS_URL);
43+
waitForAlertsPanelToBeLoaded();
44+
waitForAlertsIndexToBeCreated();
45+
createCustomRule(newRule, 'rule1');
46+
createCustomRule(existingRule, 'rule2');
47+
createCustomRule(newOverrideRule, 'rule3');
48+
createCustomRule(newThresholdRule, 'rule4');
4449
});
4550

4651
after(() => {
47-
esArchiverUnload('prebuilt_rules_loaded');
52+
cy.clock().invoke('restore');
4853
});
4954

5055
it('Sorts by activated rules', () => {
51-
loginAndWaitForPageWithoutDateRange(DETECTIONS_URL);
52-
waitForAlertsPanelToBeLoaded();
53-
waitForAlertsIndexToBeCreated();
5456
goToManageAlertsDetectionRules();
55-
waitForLoadElasticPrebuiltDetectionRulesTableToBeLoaded();
5657

5758
cy.get(RULE_NAME)
58-
.eq(FIFTH_RULE)
59+
.eq(SECOND_RULE)
5960
.invoke('text')
60-
.then((fifthRuleName) => {
61-
activateRule(FIFTH_RULE);
61+
.then((secondInitialRuleName) => {
62+
activateRule(SECOND_RULE);
6263
waitForRuleToBeActivated();
6364
cy.get(RULE_NAME)
64-
.eq(SEVENTH_RULE)
65+
.eq(FOURTH_RULE)
6566
.invoke('text')
66-
.then((seventhRuleName) => {
67-
activateRule(SEVENTH_RULE);
67+
.then((fourthInitialRuleName) => {
68+
activateRule(FOURTH_RULE);
6869
waitForRuleToBeActivated();
6970
sortByActivatedRules();
7071
cy.get(RULE_NAME)
@@ -76,8 +77,8 @@ describe('Alerts detection rules', () => {
7677
.invoke('text')
7778
.then((secondRuleName) => {
7879
const expectedRulesNames = `${firstRuleName} ${secondRuleName}`;
79-
cy.wrap(expectedRulesNames).should('include', fifthRuleName);
80-
cy.wrap(expectedRulesNames).should('include', seventhRuleName);
80+
cy.wrap(expectedRulesNames).should('include', secondInitialRuleName);
81+
cy.wrap(expectedRulesNames).should('include', fourthInitialRuleName);
8182
});
8283
});
8384
cy.get(RULE_SWITCH).eq(FIRST_RULE).should('have.attr', 'role', 'switch');

0 commit comments

Comments
 (0)