diff --git a/pages/headerMobile.js b/pages/headerMobile.js new file mode 100644 index 0000000..ac6ac5c --- /dev/null +++ b/pages/headerMobile.js @@ -0,0 +1,84 @@ +import selectors from "../selectors/headerMobile" +export class HeaderMobile { + /** + * Method used to search a process and press `start` button from mobile view + * @param processName, Process name to create a Case + * @param nroStartEvent, A process can have many start events, then this parameter select one of them + */ + createCaseMobile(processName, nroStartEvent = 0){ + cy.get(selectors.createCaseMobile).should("be.visible").click(); + cy.get(selectors.panelCreateCase).eq(1).should("be.visible").within(() => { + cy.get(selectors.searchFieldCreateCase).type(processName, {delay:100}); + cy.get(selectors.startButtonCreateCase).eq(nroStartEvent).click(); + }); + cy.get(selectors.HeaderMobile).should('be.visible'); + } + + /** + * header can select the option two options change to desktop view or logout + * @param {option} option + */ + selectOptionUser(option = "Log Out") { + let optionSelected = 1; + cy.get(selectors.headerUserButton).should("be.visible").click(); + switch(option){ + case "Switch to Desktop View": + optionSelected = 0; + break; + default: + optionSelected = 1; + } + cy.get(selectors.headerOptionList).should("be.visible").eq(optionSelected).click(); + cy.url().should("contain", "/login"); + } + + /** + * Select a tab in mobile version + * @param {tabName} tabName should be Tasks, Cases, or default Processes tab + */ + + selectTab(tabName){ + switch(tabName){ + case "Tasks": + cy.get(selectors.tabs).eq(0).click(); + cy.url().should("contain", "/tasks"); + break; + case "Cases": + cy.get(selectors.tabs).eq(1).click(); + cy.url().should("contain", "/cases"); + break; + default: + cy.get(selectors.tabs).eq(2).click(); + cy.url().should("contain", "/process-browser"); + } + + } + + /** + * Press back arroy button when a screen is displayed + */ + pressBackArroyTask() { + cy.get(selectors.backArroyButtonTask).should("be.visible").click(); + } + + /** + * Press `Prev` button when a screen is displayed + */ + pressPrevButtonTask() { + cy.get(selectors.prevButtonTask).should("be.visible").click(); + } + + /** + * Press `Next` button when a screen is displayed + */ + pressNextButtonTask() { + cy.get(selectors.nextButtonTask).should("be.visible").click(); + } + + /** + * Press `info` button when a screen is displayed + */ + pressInfoButtonTask() { + cy.get(selectors.infoButtonTask).should("be.visible").click(); + } +} diff --git a/pages/loginMobile.js b/pages/loginMobile.js new file mode 100644 index 0000000..13465bf --- /dev/null +++ b/pages/loginMobile.js @@ -0,0 +1,32 @@ +import selectors from "../selectors/loginMobile"; +export class LoginMobile { + /** + * method to login with credentials, by default uses admin user. + * @param {username} username + * @param {password} password + */ + LoginMobile(username = Cypress.env("username"), password = Cypress.env("password")){ + cy.visit("/"); + cy.get("form") + .scrollIntoView() + .within(() => { + cy.get(selectors.usernameTxt).type(username); + cy.get(selectors.passwordTxt).type(password); + cy.get(selectors.loginBtn).click(); + }); + } + + /** + * Use viewport in order to change the screen size + * @param {size} size, value can be an array or a string according to https://docs.cypress.io/api/commands/viewport#Arguments + */ + checkResolution(size) { + if (Cypress._.isArray(size)) { + cy.log("is array"); + cy.viewport(size[0], size[1]); + } else { + cy.viewport(size); + } + } + +} diff --git a/selectors/headerMobile.js b/selectors/headerMobile.js new file mode 100644 index 0000000..e5cdcec --- /dev/null +++ b/selectors/headerMobile.js @@ -0,0 +1,14 @@ +export default { + createCaseButton: 'button[id="navbar-request-button-mobile"]', + panelCreateCase: 'div[class="modal-content"]', + searchFieldCreateCase: '[data-test="new-request-modal-search-input"]', + startButtonCreateCase: 'button[data-test="new-request-modal-process-start-button"]', + headerMobile: 'div[id="navbarTaskMobile"]', + headerUserButton: '[class="content-nav"] a button[type="buttom"]', + headerOptionList: 'div a[class="dropdown-item"]', + tabs: 'li[role="presentation"]', + backArroyButtonTask: '[id="navbarTaskMobile"] button i[class="fas fa-arrow-left"]', + prevButtonTask: '[id="navbarTaskMobile"] button i[class="fas fa-chevron-left mr-1"]', + nextButtonTask: '[id="navbarTaskMobile"] button i[fas fa-chevron-right ml-1]', + infoButtonTask: '[id="navbarTaskMobile"] button i[class="fas fa-info-circle"]', +} diff --git a/selectors/loginMobile.js b/selectors/loginMobile.js new file mode 100644 index 0000000..54492d8 --- /dev/null +++ b/selectors/loginMobile.js @@ -0,0 +1,5 @@ +export default { + usernameTxt: 'input[id="username"]', + passwordTxt: 'input[id="password"]', + loginBtn: 'button[type="submit"]', +}