diff --git a/test/cypress/cypress/integration/features/management/rules/draft--check-rows-dropdow.feature b/test/cypress/cypress/integration/features/management/rules/draft--check-rows-dropdow.feature new file mode 100644 index 0000000000..fe2b65c431 --- /dev/null +++ b/test/cypress/cypress/integration/features/management/rules/draft--check-rows-dropdow.feature @@ -0,0 +1,51 @@ +Feature: Validate row dropdown on Rule page + + As a wazuh user + I want to see the Rules pages + in order to manage them + + Scenario: Rules are displayed - Select 10 rows + Given the wazuh admin user is logged + When the user navigates to management rules + And the user sees that the rule list is displayed with a limit per rows + And the user clicks the limit selector + And the user selects 10 rows + Then a maximum of 10 rows of rules are displayed per page + + + Scenario: Rules are displayed - Select 15 rows + Given the wazuh admin user is logged + When the user navigates to management rules + And the user sees that the rule list is displayed with a limit per rows + And the user clicks the limit selector + And the user selects 15 rows + Then a maximum of 15 rows of rules are displayed per page + + + Scenario: Rules are displayed - Select 25 rows + Given the wazuh admin user is logged + When the user navigates to management rules + And the user sees that the rule list is displayed with a limit per rows + And the user clicks the limit selector + And the user selects 25 rows + Then a maximum of 25 rows of rules are displayed per page + + + + Scenario: Rules are displayed - Select 50 rows + Given the wazuh admin user is logged + When the user navigates to management rules + And the user sees that the rule list is displayed with a limit per rows + And the user clicks the limit selector + And the user selects 50 rows + Then a maximum of 50 rows of rules are displayed per page + + + + Scenario: Rules are displayed - Select 100 rows + Given the wazuh admin user is logged + When the user navigates to management rules + And the user sees that the rule list is displayed with a limit per rows + And the user clicks the limit selector + And the user selects 100 rows + Then a maximum of 100 rows of rules are displayed per page diff --git a/test/cypress/cypress/integration/features/management/rules/filter-rules-si-displayed-after-refresh.feature b/test/cypress/cypress/integration/features/management/rules/filter-rules-is-displayed-after-refresh.feature similarity index 100% rename from test/cypress/cypress/integration/features/management/rules/filter-rules-si-displayed-after-refresh.feature rename to test/cypress/cypress/integration/features/management/rules/filter-rules-is-displayed-after-refresh.feature diff --git a/test/cypress/cypress/integration/features/management/rules/validate-paginator.feature b/test/cypress/cypress/integration/features/management/rules/validate-paginator.feature new file mode 100644 index 0000000000..a168ef2af5 --- /dev/null +++ b/test/cypress/cypress/integration/features/management/rules/validate-paginator.feature @@ -0,0 +1,36 @@ +Feature: Validate paginator on Rule page + + As a wazuh user + i want to see the Rules pages + in order to manage them + + Background: the user navigate to the Rules page + Given The wazuh admin user is logged + When The user navigates to rules + Then The user see that the rule list is paginated + + Scenario: Rules are displayed when user clicks the first page + When The user clicks on the second page button + And A new set of rules it's displayed + And The user clicks on the first page button + Then The first page of rules it displayed + + Scenario: Rules are displayed - Select a previous page + When The user clicks on the second page button + And The rule page is not the first available + And The user clicks on the previous page button + Then The user should be redirected to the next rule page available + + Scenario: Rules are displayed - Select a next page + When The user clicks on the second page button + And The rule page is not the last available + And The user clicks on the next page button + Then The user should be redirected to the next rule page available + + Scenario: Rules are displayed - Last Page + When The rule page is the last available page + Then The next page button should be disabled + + Scenario: Rules are displayed - First Page + When The rule page is the first available page + Then The previous page button should be disabled diff --git a/test/cypress/cypress/integration/pageobjects/wzd/wazuh-menu/rules.page.js b/test/cypress/cypress/integration/pageobjects/wzd/wazuh-menu/rules.page.js index fecb4f338d..d53d99bbb1 100644 --- a/test/cypress/cypress/integration/pageobjects/wzd/wazuh-menu/rules.page.js +++ b/test/cypress/cypress/integration/pageobjects/wzd/wazuh-menu/rules.page.js @@ -22,4 +22,13 @@ export const RULES_PAGE = { filterLevelSelector: 'button:contains("level")', filterNumberSelector: 'button:nth-child(0)', filterLabelSelector: '.euiPopover.euiPopover--anchorDownLeft [data-testid="wz-search-badge-0"]', + paginatorSelector: '.euiBasicTable .euiPagination', + paginatorPreviousSelector: '[data-test-subj="pagination-button-previous"]', + paginatorNextSelector: '[data-test-subj="pagination-button-next"]', + paginatorFirstSelector: '.euiBasicTable .euiPagination li.euiPagination__item:first-child', + paginatorSecondSelector: '.euiBasicTable .euiPagination li.euiPagination__item:nth-child(2)', + paginatorthirdSelector: '.euiBasicTable .euiPagination li.euiPagination__item:nth-child(3)', + paginatorFourthSelector: '.euiBasicTable .euiPagination li.euiPagination__item:nth-child(4)', + paginatorLastSelector: '.euiBasicTable .euiPagination li.euiPagination__item:last-child', + }; diff --git a/test/cypress/cypress/integration/step-definitions/management/rules/The-user-clicks-on-the-page-when.js b/test/cypress/cypress/integration/step-definitions/management/rules/The-user-clicks-on-the-page-when.js new file mode 100644 index 0000000000..035d219988 --- /dev/null +++ b/test/cypress/cypress/integration/step-definitions/management/rules/The-user-clicks-on-the-page-when.js @@ -0,0 +1,40 @@ +import { Then, When } from 'cypress-cucumber-preprocessor/steps'; +import { clickElement, elementIsVisible, getSelector } from '../../../utils/driver'; +import { RULES_PAGE as pageName } from '../../../utils/pages-constants'; +const paginatorSelector = getSelector('paginatorSelector', pageName); +const paginatorSecondSelector = getSelector('paginatorSecondSelector', pageName); +const paginatorNextSelector = getSelector('paginatorNextSelector', pageName); +const paginatorPreviousSelector = getSelector('paginatorPreviousSelector', pageName); +const paginatorFirstSelector = getSelector('paginatorFirstSelector', pageName); + +When('The user clicks on the {} page button', (page) => { + let selector; + elementIsVisible(paginatorSelector); + switch (page) { + case 'first': + selector = paginatorFirstSelector; + break; + case 'second': + selector = paginatorSecondSelector; + break; + case 'next': + selector = paginatorNextSelector; + break; + case 'previous': + selector = paginatorPreviousSelector; + break; + default: + throw new Error(`The page ${page} is not defined`); + } + clickElement(selector); + cy.wait(3000); +}); + + + + + + + + + diff --git a/test/cypress/cypress/integration/step-definitions/management/rules/a-new-set-of-rules-displayed.when.js b/test/cypress/cypress/integration/step-definitions/management/rules/a-new-set-of-rules-displayed.when.js new file mode 100644 index 0000000000..394bf843c2 --- /dev/null +++ b/test/cypress/cypress/integration/step-definitions/management/rules/a-new-set-of-rules-displayed.when.js @@ -0,0 +1,10 @@ +import { When } from 'cypress-cucumber-preprocessor/steps'; +import { elementIsVisible, getSelector } from '../../../utils/driver'; +import { RULES_PAGE as pageName } from '../../../utils/pages-constants'; +const paginatorSelector = getSelector('paginatorSelector', pageName); + + +When('A new set of rules is displayed', () => { + cy.wait(2500); + elementIsVisible(paginatorSelector); +}); diff --git a/test/cypress/cypress/integration/step-definitions/management/rules/the-first-page-is-displayed-then.js b/test/cypress/cypress/integration/step-definitions/management/rules/the-first-page-is-displayed-then.js new file mode 100644 index 0000000000..063cbf699a --- /dev/null +++ b/test/cypress/cypress/integration/step-definitions/management/rules/the-first-page-is-displayed-then.js @@ -0,0 +1,16 @@ +import { Then } from 'cypress-cucumber-preprocessor/steps'; +import { getSelector } from '../../../utils/driver'; +import { RULES_PAGE as pageName } from '../../../utils/pages-constants'; +const rulestableSelector = getSelector('rulestableSelector', pageName); + +Then('The first page of rules is displayed', () => { + cy.wait(1500); + cy.get(rulestableSelector).then(($rules) => { + const rulesText = $rules.text(); + cy.log(rulesText); + cy.get('@listRulesText').then(($e) => { + expect(rulesText).to.be.equals($e); + }) + }) + +}); diff --git a/test/cypress/cypress/integration/step-definitions/management/rules/the-page-button-disable.then.js b/test/cypress/cypress/integration/step-definitions/management/rules/the-page-button-disable.then.js new file mode 100644 index 0000000000..6f6dbc1e5a --- /dev/null +++ b/test/cypress/cypress/integration/step-definitions/management/rules/the-page-button-disable.then.js @@ -0,0 +1,11 @@ +import { Then } from 'cypress-cucumber-preprocessor/steps'; +import { getSelector } from '../../../utils/driver'; +import { RULES_PAGE as pageName } from '../../../utils/pages-constants'; +const paginatorNextSelector = getSelector('paginatorNextSelector', pageName); +const paginatorPreviousSelector = getSelector('paginatorPreviousSelector', pageName); + + +Then('The {} page button should be disabled',(positionPage) => { + cy.wait(2000); + (positionPage == 'next') ? cy.get(paginatorNextSelector).should('have.attr', 'disabled') : cy.get(paginatorPreviousSelector).should('have.attr', 'disabled'); +}); diff --git a/test/cypress/cypress/integration/step-definitions/management/rules/the-rule-page-is-available.then.js b/test/cypress/cypress/integration/step-definitions/management/rules/the-rule-page-is-available.then.js new file mode 100644 index 0000000000..3d879449a4 --- /dev/null +++ b/test/cypress/cypress/integration/step-definitions/management/rules/the-rule-page-is-available.then.js @@ -0,0 +1,16 @@ +import { Then } from 'cypress-cucumber-preprocessor/steps'; +import { clickElement, getSelector, elementIsVisible } from '../../../utils/driver'; +import { RULES_PAGE as pageName } from '../../../utils/pages-constants'; +const paginatorFirstSelector = getSelector('paginatorFirstSelector', pageName); +const paginatorLastSelector = getSelector('paginatorLastSelector', pageName); + +Then('The rule page is the {} available page', (page) => { + if (page == 'first') { + elementIsVisible(paginatorFirstSelector) + clickElement(paginatorFirstSelector) + } else { + elementIsVisible(paginatorLastSelector); + clickElement(paginatorLastSelector); + } + cy.wait(1500); +}); \ No newline at end of file diff --git a/test/cypress/cypress/integration/step-definitions/management/rules/the-rule-page-is-not-available.when.js b/test/cypress/cypress/integration/step-definitions/management/rules/the-rule-page-is-not-available.when.js new file mode 100644 index 0000000000..ce014e3aaf --- /dev/null +++ b/test/cypress/cypress/integration/step-definitions/management/rules/the-rule-page-is-not-available.when.js @@ -0,0 +1,9 @@ +import { When } from 'cypress-cucumber-preprocessor/steps'; +import { getSelector } from '../../../utils/driver'; +import { RULES_PAGE as pageName } from '../../../utils/pages-constants'; +const paginatorFirstSelector = getSelector('paginatorFirstSelector', pageName); +const paginatorLastSelector = getSelector('paginatorLastSelector', pageName); + +When('The rule page is not the {} available', (page) => { + (page == 'first') ? cy.get(paginatorFirstSelector).should('not.have.attr', 'disabled') : cy.get(paginatorLastSelector).should('not.have.attr', 'disabled'); +}) \ No newline at end of file diff --git a/test/cypress/cypress/integration/step-definitions/management/rules/the-user-redirected-next-rule-page-then.js b/test/cypress/cypress/integration/step-definitions/management/rules/the-user-redirected-next-rule-page-then.js new file mode 100644 index 0000000000..1765238c11 --- /dev/null +++ b/test/cypress/cypress/integration/step-definitions/management/rules/the-user-redirected-next-rule-page-then.js @@ -0,0 +1,15 @@ +import { Then } from 'cypress-cucumber-preprocessor/steps'; +import { getSelector } from '../../../utils/driver'; +import { RULES_PAGE as pageName } from '../../../utils/pages-constants'; +const rulestableSelector = getSelector('rulestableSelector', pageName); + +Then('The user should be redirected to the next rule page available',() => { + cy.wait(3000); + cy.get(rulestableSelector).then(($rules) => { + const rulesText = $rules.text(); + cy.log(rulesText); + assert.isNotEmpty(rulesText); + assert.isNotNaN(rulesText); + assert.isNotNull(rulesText); + }) +}); diff --git a/test/cypress/cypress/integration/step-definitions/management/rules/the-user-see-that-the-rule-list-is-paginated.then.js b/test/cypress/cypress/integration/step-definitions/management/rules/the-user-see-that-the-rule-list-is-paginated.then.js new file mode 100644 index 0000000000..80f5f66ce9 --- /dev/null +++ b/test/cypress/cypress/integration/step-definitions/management/rules/the-user-see-that-the-rule-list-is-paginated.then.js @@ -0,0 +1,14 @@ +import { Then } from 'cypress-cucumber-preprocessor/steps'; +import { elementIsVisible, getSelector} from '../../../utils/driver'; +import { RULES_PAGE as pageName} from '../../../utils/pages-constants'; +const paginatorSelector = getSelector('paginatorSelector', pageName); +const rulestableSelector = getSelector('rulestableSelector', pageName); + +Then('The user sees that the rule list is paginated', () => { + elementIsVisible(paginatorSelector); + cy.get(rulestableSelector).then(($e) =>{ + const listRulesText = $e.text(); + cy.log(listRulesText); + cy.wrap(listRulesText).as('listRulesText'); + }) +});