diff --git a/x-pack/plugins/security_solution/cypress/integration/detection_rules/sorting.spec.ts b/x-pack/plugins/security_solution/cypress/integration/detection_rules/sorting.spec.ts index 26d87f9ce9e17..9cdac29fca690 100644 --- a/x-pack/plugins/security_solution/cypress/integration/detection_rules/sorting.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/detection_rules/sorting.spec.ts @@ -12,6 +12,9 @@ import { SECOND_RULE, RULE_AUTO_REFRESH_IDLE_MODAL, FOURTH_RULE, + RULES_TABLE, + FIRST_PAGE_SELECTOR, + SECOND_PAGE_SELECTOR, } from '../../screens/alerts_detection_rules'; import { @@ -21,9 +24,11 @@ import { } from '../../tasks/alerts'; import { activateRule, + changeToFiveRowsPerPage, checkAllRulesIdleModal, checkAutoRefresh, dismissAllRulesIdleModal, + goToSecondPage, resetAllRulesIdleModalTimeout, sortByActivatedRules, waitForLoadElasticPrebuiltDetectionRulesTableToBeLoaded, @@ -88,6 +93,41 @@ describe('Alerts detection rules', () => { }); }); + it('Pagination updates page number and results', () => { + createCustomRule({ ...newRule, name: 'Test a rule' }, '5'); + createCustomRule({ ...newRule, name: 'Not same as first rule' }, '6'); + + goToManageAlertsDetectionRules(); + 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'); + }); + // FIXME: UI hangs on loading it.skip('Auto refreshes rules', () => { cy.clock(Date.now()); diff --git a/x-pack/plugins/security_solution/cypress/screens/alerts_detection_rules.ts b/x-pack/plugins/security_solution/cypress/screens/alerts_detection_rules.ts index 1a22d14e396ed..67e4889df64a5 100644 --- a/x-pack/plugins/security_solution/cypress/screens/alerts_detection_rules.ts +++ b/x-pack/plugins/security_solution/cypress/screens/alerts_detection_rules.ts @@ -68,6 +68,12 @@ export const SORT_RULES_BTN = '[data-test-subj="tableHeaderSortButton"]'; export const THREE_HUNDRED_ROWS = '[data-test-subj="tablePagination-300-rows"]'; +export const FIVE_ROWS = '[data-test-subj="tablePagination-5-rows"]'; + export const RULE_AUTO_REFRESH_IDLE_MODAL = '[data-test-subj="allRulesIdleModal"]'; export const RULE_AUTO_REFRESH_IDLE_MODAL_CONTINUE = '[data-test-subj="allRulesIdleModal"] button'; + +export const FIRST_PAGE_SELECTOR = '[data-test-subj="pagination-button-0"]'; + +export const SECOND_PAGE_SELECTOR = '[data-test-subj="pagination-button-1"]'; 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 799124190b18d..2fb732c981b65 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 @@ -29,6 +29,8 @@ import { ASYNC_LOADING_PROGRESS, RULE_AUTO_REFRESH_IDLE_MODAL, RULE_AUTO_REFRESH_IDLE_MODAL_CONTINUE, + FIVE_ROWS, + SECOND_PAGE_SELECTOR, } from '../screens/alerts_detection_rules'; import { ALL_ACTIONS, DELETE_RULE } from '../screens/rule_details'; @@ -152,3 +154,12 @@ export const resetAllRulesIdleModalTimeout = () => { cy.window().trigger('mousemove', { force: true }); cy.tick(700000); }; + +export const changeToFiveRowsPerPage = () => { + cy.get(PAGINATION_POPOVER_BTN).click({ force: true }); + cy.get(FIVE_ROWS).click(); +}; + +export const goToSecondPage = () => { + cy.get(SECOND_PAGE_SELECTOR).last().click({ force: true }); +}; diff --git a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/reducer.test.ts b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/reducer.test.ts index 20e4e5f747349..36df13175d381 100644 --- a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/reducer.test.ts +++ b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/reducer.test.ts @@ -32,6 +32,7 @@ const initialState: State = { lastUpdated: 0, showIdleModal: false, isRefreshOn: false, + refreshing: false, }; describe('allRulesReducer', () => {