Skip to content

Commit

Permalink
Add buzz section, add wait after each workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
readytotest committed Oct 24, 2023
1 parent 509d4d2 commit bd918c3
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 20 deletions.
4 changes: 2 additions & 2 deletions cypress/fixtures/orange-demo/orangeDemoTestData.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"passwordValid": "admin123"
},

"_comment": {
"note": "this is a placeholder for comments"
"formData": {
"buzzMessageText": "buzz-post-test-text"
},

"_dataPlaceholder": {
Expand Down
18 changes: 18 additions & 0 deletions cypress/pages/orange-demo-pom/orangeDemoBuzzPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class orangeDemoBuzzPage{

elements = {
buzzMessageField:() => cy.get('.oxd-buzz-post-input'),
buzzMessagePostButton:() => cy.get('button[type="submit"]')

}

typeBuzzMessage(inputBuzzMessage) {
this.elements.buzzMessageField().type(inputBuzzMessage);
}

postBuzzMessage() {
this.elements.buzzMessagePostButton().click();
}
}

module.exports = new orangeDemoBuzzPage();
5 changes: 5 additions & 0 deletions cypress/pages/orange-demo-pom/orangeDemoDashboardPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class orangeDemoDashboardPage{
dashboardHeader:() => cy.contains('.oxd-topbar-header-breadcrumb', 'Dashboard'),
dashboardTimeAtWork:() => cy.contains('.oxd-text.oxd-text--p', 'Time at Work'),
dashboardMyActions:() => cy.contains('.oxd-text.oxd-text--p', 'My Actions'),
dashboardBuzzFeed:() => cy.get('.oxd-text.oxd-text--p.orangehrm-buzz-widget-body')

}

Expand All @@ -19,6 +20,10 @@ class orangeDemoDashboardPage{
this.elements.dashboardMyActions().should('be.visible');
}

confirmDashboardBuzzFeed() {
this.elements.dashboardBuzzFeed().first().should('include.text', 'buzz-post-test-text')
}

}

module.exports = new orangeDemoDashboardPage();
47 changes: 43 additions & 4 deletions cypress/pages/orange-demo-pom/orangeDemoMyInfoPage.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
class orangeDemoMyInfoPage{

elements = {
personalDetailsLink:() => cy.contains('.orangehrm-tabs-item', 'Personal Details'),
contactDetailsLink:() => cy.contains('.orangehrm-tabs-item', 'Contact Details'),
firstNameField:() => cy.get('input[name="firstName"]'),
lastNameField:() => cy.get('input[name="lastName"]'),
//Don't like using nth child from the Cypress selector tool, but couldn't get anything else to work
workEmailField:() => cy.get(':nth-child(9) > .oxd-grid-3 > :nth-child(1) > .oxd-input-group > :nth-child(2) > .oxd-input'),
myInfoSaveButton:() => cy.get('button[type="submit"]'),
toastMessage:() => cy.get('#oxd-toaster_1')

}

clickPersonalDetailsLink(){
this.elements.personalDetailsLink().click();
}

clickContactDetailsLink(){
this.elements.contactDetailsLink().click();
}
Expand All @@ -17,20 +24,52 @@ class orangeDemoMyInfoPage{
this.elements.workEmailField().clear();
}

checkIfFieldEmpty(){
clearFirstNameField(){
this.elements.firstNameField().clear();
}

clearLastNameField(){
this.elements.lastNameField().clear();
}

checkIfWorkEmailFieldEmpty(){
this.elements.workEmailField().invoke('val').should('be.empty');
}

checkIfFieldNotEmpty(){
checkIfFirstNameFieldEmpty(){
this.elements.firstNameField().invoke('val').should('be.empty');
}

checkIfLastNameFieldEmpty(){
this.elements.lastNameField().invoke('val').should('be.empty');
}

checkIfWorkEmailFieldNotEmpty(){
this.elements.workEmailField().invoke('val').should('not.be.empty');
}

checkIfFirstNameFieldNotEmpty(){
this.elements.firstNameField().invoke('val').should('not.be.empty');
}

checkIfLastNameFieldNotEmpty(){
this.elements.lastNameField().invoke('val').should('not.be.empty');
}

typeWorkEmail(inputWorkEmail){
this.elements.workEmailField().type(inputWorkEmail);
}

clickMyInfoSaveButton(){
this.elements.myInfoSaveButton().realClick();
typeFirstName(inputFirstName){
this.elements.firstNameField().type(inputFirstName);
}

typeLastName(inputLastName){
this.elements.lastNameField().type(inputLastName);
}

clickFirstMyInfoSaveButton(){
this.elements.myInfoSaveButton().first().click();
}

confirmSaveSuccessful(){
Expand Down
6 changes: 3 additions & 3 deletions cypress/pages/orange-demo-pom/orangeDemoProfileMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ class orangeDemoProfileMenu{

elements = {
profileMenu: () => cy.get('p[class="oxd-userdropdown-name"]'),
profileMenuLogout: () => cy.get('[href="/web/index.php/auth/logout"]')
profileMenuLogout: () => cy.contains('.oxd-userdropdown-link', 'Logout')

}

openProfileMenu(){
this.elements.profileMenu().click();
this.elements.profileMenu().realClick();
}

clickLogoutMenu(){
this.elements.profileMenuLogout().click();
this.elements.profileMenuLogout().realClick();
}

}
Expand Down
10 changes: 10 additions & 0 deletions cypress/pages/orange-demo-pom/orangeDemoVerticalMenu.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
class orangeDemoVerticalMenu{

elements = {
dashboardLink:() => cy.contains('.oxd-main-menu-item', 'Dashboard'),
myInfoLink:() => cy.contains('.oxd-main-menu-item', 'My Info'),
buzzLink: () => cy.contains('.oxd-main-menu-item', 'Buzz'),

}

clickDashboardLink(){
this.elements.dashboardLink().click();
}

clickMyInfoLink(){
this.elements.myInfoLink().click();
}

clickBuzzLink(){
this.elements.buzzLink().click();
}
}

module.exports = new orangeDemoVerticalMenu();
55 changes: 44 additions & 11 deletions cypress/tests/orange-demo-site/orangeDemoSmoke.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@ import orangeDemoTestData from '../../fixtures/orange-demo/orangeDemoTestData.js
import orangeDemoProfileMenu from '../../pages/orange-demo-pom/orangeDemoProfileMenu';
import orangeDemoVerticalMenu from '../../pages/orange-demo-pom/orangeDemoVerticalMenu';
import orangeDemoMyInfoPage from '../../pages/orange-demo-pom/orangeDemoMyInfoPage';
import orangeDemoBuzzPage from '../../pages/orange-demo-pom/orangeDemoBuzzPage';


/* Need to look into another alternative for random data
like https://fakerjs.dev/ when I get time */
const numRandom = () => Math.floor((Math.random() + 1) * 9999);
const insertNum = numRandom();
const randomEmailGenerator = `user@fake-email-${insertNum}.org`;
const randomFirstNameGenerator = `firstname${insertNum}`;
const randomLastNameGenerator = `lastname${insertNum}`;


describe('Orange Demo Smoke Test', () => {

Expand All @@ -26,29 +33,55 @@ describe('Orange Demo Smoke Test', () => {

orangeDemoProfileMenu.openProfileMenu();
orangeDemoProfileMenu.clickLogoutMenu();
/*Need to add the wait because if one of the it blocks fails, then
after each will fail on confirming the login button unless the wait is there.
The wait isn't required if all it blocks pass???? */
cy.wait(1000);
orangeDemoLoginPage.confirmLoginButtonExists();
cy.log('Logout successful!');

});

it('Check dashboard', () => {
orangeDemoDashboardPage.confirmDashboardTimeAtWork();
orangeDemoDashboardPage.confirmDashboardMyActions();

})

it('Edit and Save Data in My Info', () => {
it('My Info: Edit Name and Work Email', () => {

orangeDemoVerticalMenu.clickMyInfoLink();

orangeDemoMyInfoPage.clickPersonalDetailsLink();
orangeDemoMyInfoPage.clearFirstNameField();
orangeDemoMyInfoPage.checkIfFirstNameFieldEmpty();
orangeDemoMyInfoPage.typeFirstName(randomFirstNameGenerator);
orangeDemoMyInfoPage.checkIfFirstNameFieldNotEmpty();
orangeDemoMyInfoPage.clearLastNameField();
orangeDemoMyInfoPage.checkIfLastNameFieldEmpty();
orangeDemoMyInfoPage.typeLastName(randomLastNameGenerator);
orangeDemoMyInfoPage.checkIfLastNameFieldNotEmpty();
orangeDemoMyInfoPage.clickFirstMyInfoSaveButton();
//This wait is required or save won't occur
cy.wait(1000);
orangeDemoMyInfoPage.confirmSaveSuccessful();

orangeDemoMyInfoPage.clickContactDetailsLink();
orangeDemoMyInfoPage.clearWorkEmailField();
orangeDemoMyInfoPage.checkIfFieldEmpty();
orangeDemoMyInfoPage.checkIfWorkEmailFieldEmpty();
orangeDemoMyInfoPage.typeWorkEmail(randomEmailGenerator);
orangeDemoMyInfoPage.checkIfFieldNotEmpty();
orangeDemoMyInfoPage.clickMyInfoSaveButton();
//This wait is required or the email won't save
orangeDemoMyInfoPage.checkIfWorkEmailFieldNotEmpty();
orangeDemoMyInfoPage.clickFirstMyInfoSaveButton();
//This wait is required or save won't occur
cy.wait(1000);
orangeDemoMyInfoPage.confirmSaveSuccessful();

})

it('Buzz: add post. Dashboard: check if post Appears and confirm headings on page', () => {

orangeDemoVerticalMenu.clickBuzzLink();
orangeDemoBuzzPage.typeBuzzMessage(orangeDemoTestData.formData.buzzMessageText);
orangeDemoBuzzPage.postBuzzMessage();
orangeDemoVerticalMenu.clickDashboardLink();
orangeDemoDashboardPage.confirmDashboardBuzzFeed();
orangeDemoDashboardPage.confirmDashboardTimeAtWork();
orangeDemoDashboardPage.confirmDashboardMyActions();

})

});

0 comments on commit bd918c3

Please sign in to comment.