Skip to content

Commit

Permalink
Add feature rules are displayed when user clicks the first page - wzd…
Browse files Browse the repository at this point in the history
… - 4648 (#4663)

* draft commit for evidence

* draft commit for evidencie

* add validate paginator on Rule page feature

* fix for some issue

* Update draft--check-rows-dropdow.feature

* Update the-user-see-that-the-rule-list-is-paginated.then.js

* Update the-page-button-disable.then.js

* Update the-first-page-is-displayed-then.js

* Update a-new-set-of-rules-displayed.when.js

* Update validate-paginator.feature

* Update draft--check-rows-dropdow.feature

Co-authored-by: Álex <alejandro.ruiz.becerra@wazuh.com>
(cherry picked from commit 7dfe4d6)
  • Loading branch information
mauceballos authored and github-actions[bot] committed Oct 13, 2022
1 parent e2d0c14 commit dbf43d8
Show file tree
Hide file tree
Showing 12 changed files with 227 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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',

};
Original file line number Diff line number Diff line change
@@ -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);
});









Original file line number Diff line number Diff line change
@@ -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);
});
Original file line number Diff line number Diff line change
@@ -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);
})
})

});
Original file line number Diff line number Diff line change
@@ -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');
});
Original file line number Diff line number Diff line change
@@ -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);
});
Original file line number Diff line number Diff line change
@@ -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');
})
Original file line number Diff line number Diff line change
@@ -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);
})
});
Original file line number Diff line number Diff line change
@@ -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');
})
});

0 comments on commit dbf43d8

Please sign in to comment.