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] Cover persistent rules table state by e2e tests #149638

Merged
merged 33 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
5e4b81a
add persistent rules table state e2e tests
maximpn Jan 26, 2023
b12063c
improve visit's implementation
maximpn Jan 26, 2023
b1d4abb
revert role's removal
maximpn Jan 26, 2023
c0f6169
fix typing errors
maximpn Jan 26, 2023
077786f
add no tags expectactor
maximpn Jan 26, 2023
2460c9a
add no elastic vs custom filter selection expectactor
maximpn Jan 26, 2023
588382d
fix visit function usage
maximpn Jan 27, 2023
1a196fe
fix e2e tests
maximpn Jan 28, 2023
a219fcb
skip agent installation in e2e tests
maximpn Jan 28, 2023
8a5fdd1
get rid of type delay which cause test flakiness
maximpn Jan 29, 2023
8f24e70
convert timerange string param into readable object
maximpn Jan 29, 2023
53dcb7b
add selector's suffix
maximpn Jan 29, 2023
b0c8c46
move selector to the screen file
maximpn Jan 29, 2023
959c12d
fix imports
maximpn Jan 29, 2023
ef6232b
include enabled/disabled rule state to e2e tests
maximpn Feb 7, 2023
5dee538
fix e2e tests
maximpn Feb 7, 2023
d637e61
rely on aria-selected to detect tab selection
maximpn Feb 13, 2023
c3e0609
rename helper functions to better reflect its purpose
maximpn Feb 13, 2023
ab095fa
remove duplicated tags check
maximpn Feb 13, 2023
3fc77c7
add logging outputs
maximpn Feb 13, 2023
8239c3d
update description text
maximpn Feb 13, 2023
fc6ac1e
remove accidentally added piece of code
maximpn Feb 13, 2023
5e9b522
update function's name
maximpn Feb 14, 2023
7f978b2
move data corruption test from e2e to unit tests
maximpn Feb 14, 2023
5efd2a5
remove e2e test duplicated by unit tests
maximpn Feb 14, 2023
53186ac
focus rule's search term input before typing
maximpn Feb 15, 2023
5e275f9
improve tests readability
maximpn Feb 15, 2023
eab2046
remove an unused function
maximpn Feb 15, 2023
9ba9b57
force typing in search term to avoid flakiness
maximpn Feb 20, 2023
899ba77
add dedicated tests for displayed rules
maximpn Feb 20, 2023
35bfa72
improve tests readability
maximpn Feb 20, 2023
5aeb0a8
remove table page navigation in tabs test
maximpn Feb 21, 2023
6255256
simplify visit's timerange setup
maximpn Feb 22, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,12 @@ export const AddFirstIntegrationSplashScreen: React.FC<{
<CreatePackagePolicyBottomBar
cancelUrl={cancelUrl}
cancelMessage={
<FormattedMessage
id="xpack.fleet.createPackagePolicyBottomBar.skipAddAgentButton"
defaultMessage="Add integration only (skip agent installation)"
/>
<span data-test-subj="skipAgentInstallation">
<FormattedMessage
id="xpack.fleet.createPackagePolicyBottomBar.skipAddAgentButton"
defaultMessage="Add integration only (skip agent installation)"
/>
</span>
}
cancelClickHandler={cancelClickHandler}
isLoading={isLoading}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { login, visitWithoutDateRange } from '../../tasks/login';
import { getUnmappedRule } from '../../objects/rule';

import { ALERTS_URL } from '../../urls/navigation';
import { pageSelector } from '../../screens/alerts_detection_rules';
import { tablePageSelector } from '../../screens/table_pagination';

describe('Alert details with unmapped fields', () => {
before(() => {
Expand Down Expand Up @@ -65,7 +65,7 @@ describe('Alert details with unmapped fields', () => {
};

openTable();
cy.get(ALERT_FLYOUT).find(pageSelector(4)).click({ force: true });
cy.get(ALERT_FLYOUT).find(tablePageSelector(4)).click({ force: true });
cy.get(ALERT_FLYOUT)
.find(TABLE_ROWS)
.last()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { TIMELINE_TEMPLATE_DETAILS } from '../../screens/rule_details';
import { EUI_FILTER_SELECT_ITEM } from '../../screens/common/controls';

import {
changeRowsPerPageTo,
waitForRulesTableToBeLoaded,
selectAllRules,
goToTheRuleDetailsOf,
Expand Down Expand Up @@ -100,6 +99,7 @@ import { getIndicatorMatchTimelineTemplate } from '../../objects/timeline';

import { esArchiverResetKibana } from '../../tasks/es_archiver';
import { getAvailablePrebuiltRulesCount } from '../../tasks/api_calls/prebuilt_rules';
import { setRowsPerPageTo } from '../../tasks/table_pagination';

const RULE_NAME = 'Custom rule for bulk actions';

Expand Down Expand Up @@ -224,7 +224,7 @@ describe('Detection rules, bulk edit', () => {
it('should not lose rules selection after edit action', () => {
const rulesCount = 4;
// Switch to 5 rules per page, to have few pages in pagination(ideal way to test auto refresh and selection of few items)
changeRowsPerPageTo(numberOfRulesPerPage);
setRowsPerPageTo(numberOfRulesPerPage);
selectNumberOfRules(rulesCount);

// open add tags form and add 2 new tags
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
RISK_SCORE,
RULE_NAME,
RULES_ROW,
RULES_TABLE,
RULES_MANAGEMENT_TABLE,
RULE_SWITCH,
SEVERITY,
} from '../../screens/alerts_detection_rules';
Expand Down Expand Up @@ -172,7 +172,7 @@ describe('Custom query rules', () => {
cy.get(CUSTOM_RULES_BTN).should('have.text', 'Custom rules (1)');

cy.log('Asserting rule view in rules list');
cy.get(RULES_TABLE).find(RULES_ROW).should('have.length', expectedNumberOfRules);
cy.get(RULES_MANAGEMENT_TABLE).find(RULES_ROW).should('have.length', expectedNumberOfRules);
cy.get(RULE_NAME).should('have.text', ruleFields.ruleName);
cy.get(RISK_SCORE).should('have.text', ruleFields.riskScore);
cy.get(SEVERITY)
Expand Down Expand Up @@ -247,7 +247,7 @@ describe('Custom query rules', () => {
});

it('Deletes one rule', () => {
cy.get(RULES_TABLE)
cy.get(RULES_MANAGEMENT_TABLE)
.find(RULES_ROW)
.then((rules) => {
const initialNumberOfRules = rules.length;
Expand All @@ -260,7 +260,7 @@ describe('Custom query rules', () => {

deleteFirstRule();

cy.get(RULES_TABLE)
cy.get(RULES_MANAGEMENT_TABLE)
.find(RULES_ROW)
.should('have.length', expectedNumberOfRulesAfterDeletion);
cy.request({ url: '/api/detection_engine/rules/_find' }).then(({ body }) => {
Expand All @@ -275,7 +275,7 @@ describe('Custom query rules', () => {
});

it('Deletes more than one rule', () => {
cy.get(RULES_TABLE)
cy.get(RULES_MANAGEMENT_TABLE)
.find(RULES_ROW)
.then((rules) => {
const initialNumberOfRules = rules.length;
Expand All @@ -286,21 +286,21 @@ describe('Custom query rules', () => {
selectNumberOfRules(numberOfRulesToBeDeleted);
deleteSelectedRules();

cy.get(RULES_TABLE)
cy.get(RULES_MANAGEMENT_TABLE)
.get(RULES_ROW)
.first()
.within(() => {
cy.get(RULE_SWITCH).should('not.exist');
});

cy.get(RULES_TABLE)
cy.get(RULES_MANAGEMENT_TABLE)
.find(RULES_ROW)
.should('have.length', expectedNumberOfRulesAfterDeletion);
cy.request({ url: '/api/detection_engine/rules/_find' }).then(({ body }) => {
const numberOfRules = body.data.length;
expect(numberOfRules).to.eql(expectedNumberOfRulesAfterDeletion);
});
cy.get(RULES_TABLE)
cy.get(RULES_MANAGEMENT_TABLE)
.get(RULES_ROW)
.first()
.within(() => {
Expand All @@ -314,7 +314,7 @@ describe('Custom query rules', () => {
});

it('Deletes one rule from detail page', () => {
cy.get(RULES_TABLE)
cy.get(RULES_MANAGEMENT_TABLE)
.find(RULES_ROW)
.then((rules) => {
const initialNumberOfRules = rules.length;
Expand All @@ -327,8 +327,8 @@ describe('Custom query rules', () => {

// @ts-expect-error update types
cy.waitFor('@deleteRule').then(() => {
cy.get(RULES_TABLE).should('exist');
cy.get(RULES_TABLE)
cy.get(RULES_MANAGEMENT_TABLE).should('exist');
cy.get(RULES_MANAGEMENT_TABLE)
.find(RULES_ROW)
.should('have.length', expectedNumberOfRulesAfterDeletion);
cy.request({ url: '/api/detection_engine/rules/_find' }).then(({ body }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
RISK_SCORE,
RULE_NAME,
RULES_ROW,
RULES_TABLE,
RULES_MANAGEMENT_TABLE,
RULE_SWITCH,
SEVERITY,
} from '../../screens/alerts_detection_rules';
Expand Down Expand Up @@ -115,7 +115,7 @@ describe('Custom query rules', () => {

cy.get(CUSTOM_RULES_BTN).should('have.text', 'Custom rules (1)');

cy.get(RULES_TABLE).find(RULES_ROW).should('have.length', expectedNumberOfRules);
cy.get(RULES_MANAGEMENT_TABLE).find(RULES_ROW).should('have.length', expectedNumberOfRules);
cy.get(RULE_NAME).should('have.text', this.rule.name);
cy.get(RISK_SCORE).should('have.text', this.rule.riskScore);
cy.get(SEVERITY).should('have.text', this.rule.severity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { ALERT_DATA_GRID, NUMBER_OF_ALERTS } from '../../screens/alerts';
import {
CUSTOM_RULES_BTN,
RISK_SCORE,
RULES_MANAGEMENT_TABLE,
RULE_NAME,
RULE_SWITCH,
SEVERITY,
Expand Down Expand Up @@ -102,7 +103,7 @@ describe('EQL rules', () => {

cy.get(CUSTOM_RULES_BTN).should('have.text', 'Custom rules (1)');

expectNumberOfRules(expectedNumberOfRules);
expectNumberOfRules(RULES_MANAGEMENT_TABLE, expectedNumberOfRules);

cy.get(RULE_NAME).should('have.text', this.rule.name);
cy.get(RISK_SCORE).should('have.text', this.rule.riskScore);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { TOASTER } from '../../screens/alerts_detection_rules';
import { RULES_MANAGEMENT_TABLE, TOASTER } from '../../screens/alerts_detection_rules';
import {
expectNumberOfRules,
expectToContainRule,
Expand Down Expand Up @@ -41,8 +41,8 @@ describe('Import rules', () => {
'Successfully imported 1 ruleSuccessfully imported 1 exception.'
);

expectNumberOfRules(expectedNumberOfRules);
expectToContainRule(expectedImportedRuleName);
expectNumberOfRules(RULES_MANAGEMENT_TABLE, expectedNumberOfRules);
expectToContainRule(RULES_MANAGEMENT_TABLE, expectedImportedRuleName);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
import {
CUSTOM_RULES_BTN,
RISK_SCORE,
RULES_MANAGEMENT_TABLE,
RULE_NAME,
RULE_SWITCH,
SEVERITY,
Expand Down Expand Up @@ -432,7 +433,7 @@ describe('indicator match', () => {

cy.get(CUSTOM_RULES_BTN).should('have.text', 'Custom rules (1)');

expectNumberOfRules(expectedNumberOfRules);
expectNumberOfRules(RULES_MANAGEMENT_TABLE, expectedNumberOfRules);

cy.get(RULE_NAME).should('have.text', rule.name);
cy.get(RISK_SCORE).should('have.text', rule.riskScore);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { getNewRule } from '../../objects/rule';
import { RULES_MONITORING_TABLE, RULE_NAME } from '../../screens/alerts_detection_rules';
import { RULES_MONITORING_TAB, RULE_NAME } from '../../screens/alerts_detection_rules';
import { createCustomRuleEnabled } from '../../tasks/api_calls/rules';
import { cleanKibana, deleteAlertsAndRules } from '../../tasks/common';
import { login, visitWithoutDateRange } from '../../tasks/login';
Expand All @@ -29,7 +29,7 @@ describe('Rules talbes links', () => {
});

it('should render correct link for rule name - rule monitoring', () => {
cy.get(RULES_MONITORING_TABLE).first().click();
cy.get(RULES_MONITORING_TAB).click();
cy.get(RULE_NAME).first().click();
cy.url().should('contain', 'rules/id/');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { getMachineLearningRule } from '../../objects/rule';
import {
CUSTOM_RULES_BTN,
RISK_SCORE,
RULES_MANAGEMENT_TABLE,
RULE_NAME,
RULE_SWITCH,
SEVERITY,
Expand Down Expand Up @@ -73,7 +74,7 @@ describe('Detection rules, machine learning', () => {

cy.get(CUSTOM_RULES_BTN).should('have.text', 'Custom rules (1)');

expectNumberOfRules(expectedNumberOfRules);
expectNumberOfRules(RULES_MANAGEMENT_TABLE, expectedNumberOfRules);

cy.get(RULE_NAME).should('have.text', getMachineLearningRule().name);
cy.get(RISK_SCORE).should('have.text', getMachineLearningRule().riskScore);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { ALERT_DATA_GRID } from '../../screens/alerts';
import {
CUSTOM_RULES_BTN,
RISK_SCORE,
RULES_MANAGEMENT_TABLE,
RULE_NAME,
RULE_SWITCH,
SEVERITY,
Expand Down Expand Up @@ -98,7 +99,7 @@ describe('New Terms rules', () => {

cy.get(CUSTOM_RULES_BTN).should('have.text', 'Custom rules (1)');

expectNumberOfRules(expectedNumberOfRules);
expectNumberOfRules(RULES_MANAGEMENT_TABLE, expectedNumberOfRules);

cy.get(RULE_NAME).should('have.text', this.rule.name);
cy.get(RISK_SCORE).should('have.text', this.rule.riskScore);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { NUMBER_OF_ALERTS, ALERT_GRID_CELL } from '../../screens/alerts';
import {
CUSTOM_RULES_BTN,
RISK_SCORE,
RULES_MANAGEMENT_TABLE,
RULE_NAME,
RULE_SWITCH,
SEVERITY,
Expand Down Expand Up @@ -97,7 +98,7 @@ describe('Detection rules, override', () => {

cy.get(CUSTOM_RULES_BTN).should('have.text', 'Custom rules (1)');

expectNumberOfRules(1);
expectNumberOfRules(RULES_MANAGEMENT_TABLE, 1);

cy.get(RULE_NAME).should('have.text', this.rule.name);
cy.get(RISK_SCORE).should('have.text', this.rule.riskScore);
Expand Down
Loading