diff --git a/x-pack/plugins/security_solution/cypress/integration/detection_rules/all_rules_table.spec.ts b/x-pack/plugins/security_solution/cypress/integration/detection_rules/sorting.spec.ts similarity index 72% rename from x-pack/plugins/security_solution/cypress/integration/detection_rules/all_rules_table.spec.ts rename to x-pack/plugins/security_solution/cypress/integration/detection_rules/sorting.spec.ts index 35c21118a4fdc..26d87f9ce9e17 100644 --- a/x-pack/plugins/security_solution/cypress/integration/detection_rules/all_rules_table.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/detection_rules/sorting.spec.ts @@ -12,10 +12,6 @@ import { SECOND_RULE, RULE_AUTO_REFRESH_IDLE_MODAL, FOURTH_RULE, - RULES_TABLE, - FIRST_PAGE_SELECTOR, - SECOND_PAGE_SELECTOR, - FROSTED_LOADING_RULES_TABLE, } from '../../screens/alerts_detection_rules'; import { @@ -25,13 +21,12 @@ import { } from '../../tasks/alerts'; import { activateRule, - changeToFiveRowsPerPage, checkAllRulesIdleModal, checkAutoRefresh, dismissAllRulesIdleModal, - goToSecondPage, resetAllRulesIdleModalTimeout, sortByActivatedRules, + waitForLoadElasticPrebuiltDetectionRulesTableToBeLoaded, waitForRuleToBeActivated, } from '../../tasks/alerts_detection_rules'; import { loginAndWaitForPageWithoutDateRange } from '../../tasks/login'; @@ -52,14 +47,15 @@ describe('Alerts detection rules', () => { createCustomRule(existingRule, '2'); createCustomRule(newOverrideRule, '3'); createCustomRule(newThresholdRule, '4'); - goToManageAlertsDetectionRules(); }); after(() => { cy.clock().invoke('restore'); }); - xit('Sorts by activated rules', () => { + it('Sorts by activated rules', () => { + goToManageAlertsDetectionRules(); + cy.get(RULE_NAME) .eq(SECOND_RULE) .invoke('text') @@ -92,55 +88,28 @@ describe('Alerts detection rules', () => { }); }); - it('Pagination updates page number and results', () => { - createCustomRule(newRule, '5'); - createCustomRule({ ...newRule, name: 'Not same as first rule' }, '6'); - - changeToFiveRowsPerPage(); - - cy.get(RULES_TABLE) - .find(FIRST_PAGE_SELECTOR) - .should('have.class', 'euiPaginationButton-isActive'); - - cy.get(RULES_TABLE) - .find(RULE_NAME) - .first() - .invoke('text') - .then((ruleNameFirstPage) => { - goToSecondPage(); - cy.wait(1500); - cy.get(RULES_TABLE) - .find(RULE_NAME) - .first() - .invoke('text') - .should((ruleNameSecondPage) => { - expect(ruleNameFirstPage).not.to.eq(ruleNameSecondPage); - }); - }); - - cy.get(RULES_TABLE) - .find(FIRST_PAGE_SELECTOR) - .should('not.have.class', 'euiPaginationButton-isActive'); - cy.get(RULES_TABLE) - .find(SECOND_PAGE_SELECTOR) - .should('have.class', 'euiPaginationButton-isActive'); - }); - - it('Auto refreshes rules', () => { + // FIXME: UI hangs on loading + it.skip('Auto refreshes rules', () => { cy.clock(Date.now()); + loginAndWaitForPageWithoutDateRange(DETECTIONS_URL); + waitForAlertsPanelToBeLoaded(); + waitForAlertsIndexToBeCreated(); + goToManageAlertsDetectionRules(); + waitForLoadElasticPrebuiltDetectionRulesTableToBeLoaded(); + // mock 1 minute passing to make sure refresh // is conducted - checkAutoRefresh(60005, 'be.visible'); + checkAutoRefresh(DEFAULT_RULE_REFRESH_INTERVAL_VALUE, 'be.visible'); // mock 45 minutes passing to check that idle modal shows // and refreshing is paused checkAllRulesIdleModal('be.visible'); - checkAutoRefresh(60005, 'not.exist'); + checkAutoRefresh(DEFAULT_RULE_REFRESH_INTERVAL_VALUE, 'not.be.visible'); // clicking on modal to continue, should resume refreshing dismissAllRulesIdleModal(); - checkAutoRefresh(60005, 'be.visible'); + checkAutoRefresh(DEFAULT_RULE_REFRESH_INTERVAL_VALUE, 'be.visible'); // if mouse movement detected, idle modal should not // show after 45 min diff --git a/x-pack/plugins/security_solution/cypress/tasks/alerts_detection_rules.ts b/x-pack/plugins/security_solution/cypress/tasks/alerts_detection_rules.ts index 35928c871372d..4d57926cf3440 100644 --- a/x-pack/plugins/security_solution/cypress/tasks/alerts_detection_rules.ts +++ b/x-pack/plugins/security_solution/cypress/tasks/alerts_detection_rules.ts @@ -31,7 +31,6 @@ import { RULE_AUTO_REFRESH_IDLE_MODAL_CONTINUE, FIVE_ROWS, SECOND_PAGE_SELECTOR, - FIRST_PAGE_SELECTOR, FROSTED_LOADING_RULES_TABLE, } from '../screens/alerts_detection_rules'; import { ALL_ACTIONS, DELETE_RULE } from '../screens/rule_details'; @@ -43,20 +42,10 @@ export const activateRule = (rulePosition: number) => { export const changeToFiveRowsPerPage = () => { cy.get(PAGINATION_POPOVER_BTN).click({ force: true }); cy.get(FIVE_ROWS).click(); - cy.get(FROSTED_LOADING_RULES_TABLE).should('exist'); - cy.get(FROSTED_LOADING_RULES_TABLE).should('not.exist'); }; export const goToSecondPage = () => { - cy.get(SECOND_PAGE_SELECTOR).last().click({ force: true }); - cy.get(FROSTED_LOADING_RULES_TABLE).should('exist'); - cy.get(FROSTED_LOADING_RULES_TABLE).should('not.exist'); -}; - -export const goToFirstPage = () => { - cy.get(FIRST_PAGE_SELECTOR).last().click({ force: true }); - cy.get(FROSTED_LOADING_RULES_TABLE).should('exist'); - cy.get(FROSTED_LOADING_RULES_TABLE).should('not.exist'); + cy.get(SECOND_PAGE_SELECTOR).click({ force: true }); }; export const changeToThreeHundredRowsPerPage = () => { @@ -147,8 +136,12 @@ export const waitForRuleToBeActivated = () => { }; export const waitForRulesToBeLoaded = () => { - cy.get(ASYNC_LOADING_PROGRESS).should('exist'); + cy.get(FROSTED_LOADING_RULES_TABLE).should('exist'); cy.get(FROSTED_LOADING_RULES_TABLE).should('not.exist'); +}; + +export const waitForRulesToBeAutoRefreshed = () => { + cy.get(ASYNC_LOADING_PROGRESS).should('exist'); cy.get(ASYNC_LOADING_PROGRESS).should('not.exist'); };