Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions cypress/e2e/projectsModule/projectsModuleUsingPOM.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/// <reference types= "cypress" />

import addProjectPO from "../../page_objects/projectsModulePO/addProject_PO"
import { getRandomString , getRandomEmail} from "../../../utilites/helper";

describe('Verifying Add Project functionality of projects module', function(){

beforeEach(function(){
cy.login()
addProjectPO.goToProjectModule()
})

it('Verifying the action of project registration with empty fields', function(){
addProjectPO.clickAddProjectButton()
addProjectPO.verifyEmptyValidation('project')
})

it('Create new project client name but empty Project Name.', function(){
addProjectPO.selectClientName('Jane Doe')
addProjectPO.clickAddProjectButton()
addProjectPO.verifyEmptyValidation('project')
})

it('Create new project with Project name but empty Client name.', function(){
const randomGeneratedName = getRandomString(10)
addProjectPO.typeProjectName(randomGeneratedName)
addProjectPO.clickAddProjectButton()
addProjectPO.verifyEmptyValidation('client')
})

it('Billable button functionality on create new project', function(){
addProjectPO.checkbillableKeyFunctionality()
})

})
46 changes: 46 additions & 0 deletions cypress/page_objects/projectsModulePO/addProject_PO.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
class addProjectPO{
elements = {
projectName : () => cy.get('[data-cy="addProjectname"]'),
clientName : () => cy.get('#client-id'),
billableKey : () => cy.get('[data-cy="toggleBillable"]'),
addProject : () => cy.get('[data-cy="newProjectCreateButton"]'),
validationError : () => cy.get('.alert-message'),
searchField : () => cy.get('.topnav input')
}

goToProjectModule(){
cy.get('li a span.link-text').eq(1).contains('Projects').click()
cy.url().should('eq', 'https://frontendbootcamp.proshore.eu/projects')
}

verifyEmptyValidation(name){
if(name === 'project') {
this.elements.projectName().invoke('prop', 'validationMessage')
.should('equal', 'Please fill out this field.')
}
if(name == 'client'){
this.elements.clientName().invoke('prop', 'validationMessage')
.should('equal', 'Please select an item in the list.')
}
}

typeProjectName(projectName){
this.elements.projectName().wait(1000).type(projectName)
}

selectClientName(clientName){
this.elements.clientName().select(clientName)
}

checkbillableKeyFunctionality(){
this.elements.billableKey().should('have.attr', 'title', 'Billable')
this.elements.billableKey().click().should('have.attr', 'title', 'Non billable')
this.elements.billableKey().click().should('have.attr', 'title', 'Billable')
}

clickAddProjectButton(){
this.elements.addProject().contains('ADD PROJECT').click()
}
}

module.exports = new addProjectPO();