Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
yctercero committed Feb 14, 2021
1 parent 4a33720 commit 160fd20
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -21,9 +24,11 @@ import {
} from '../../tasks/alerts';
import {
activateRule,
changeToFiveRowsPerPage,
checkAllRulesIdleModal,
checkAutoRefresh,
dismissAllRulesIdleModal,
goToSecondPage,
resetAllRulesIdleModalTimeout,
sortByActivatedRules,
waitForLoadElasticPrebuiltDetectionRulesTableToBeLoaded,
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"]';
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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 });
};
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const initialState: State = {
lastUpdated: 0,
showIdleModal: false,
isRefreshOn: false,
refreshing: false,
};

describe('allRulesReducer', () => {
Expand Down

0 comments on commit 160fd20

Please sign in to comment.