-
Notifications
You must be signed in to change notification settings - Fork 544
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OHRM5X - 1996 : Test Automation: Admin - Organization structure #1619
Open
Ravindu-Bhagya
wants to merge
1
commit into
orangehrm:5.4
Choose a base branch
from
Ravindu-Bhagya:orgstructure_testing
base: 5.4
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
303 changes: 303 additions & 0 deletions
303
src/test/functional/cypress/integration/feature/admin/orgstructure.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,303 @@ | ||
/** | ||
* OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures | ||
* all the essential functionalities required for any enterprise. | ||
* Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com | ||
* | ||
* OrangeHRM is free software; you can redistribute it and/or modify it under the terms of | ||
* the GNU General Public License as published by the Free Software Foundation; either | ||
* version 2 of the License, or (at your option) any later version. | ||
* | ||
* OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with this program; | ||
* if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
* Boston, MA 02110-1301, USA | ||
*/ | ||
|
||
describe('Admin - Organization Structure', function () { | ||
beforeEach(function () { | ||
cy.task('db:reset'); | ||
cy.fixture('viewport').then(({HD}) => { | ||
cy.viewport(HD.width, HD.height); | ||
}); | ||
cy.fixture('chars').as('strings'); | ||
cy.intercept('GET', '**/api/v2/admin/subunits*').as('getOrgStructure'); | ||
cy.intercept('POST', '**/api/v2/admin/subunits').as('postOrgStructure'); | ||
cy.intercept('PUT', '**/api/v2/admin/subunits/*').as('updateOrgStructure'); | ||
cy.intercept('DELETE', '**/api/v2/admin/subunits/*').as( | ||
'deleteOrgStructure', | ||
); | ||
cy.fixture('user').then(({admin}) => { | ||
this.user = admin; | ||
}); | ||
}); | ||
|
||
describe('Verify the edit button behaviour', function () { | ||
it('switch the edit button and view the Add button', function () { | ||
cy.loginTo(this.user, '/admin/viewCompanyStructure'); | ||
cy.wait('@getOrgStructure'); | ||
cy.getOXD('pageTitle').contains('Organization Structure'); | ||
cy.getOXD('switch').click(); | ||
cy.getOXD('button').contains(' Add '); | ||
}); | ||
}); | ||
|
||
describe('Verify the Add button bahaviour and verify the add organization unit modal', function () { | ||
it('verify the add button behaviour', function () { | ||
cy.loginTo(this.user, '/admin/viewCompanyStructure'); | ||
cy.wait('@getOrgStructure'); | ||
cy.getOXD('pageTitle').contains('Organization Structure'); | ||
cy.getOXD('switch').click(); | ||
cy.getOXD('button').contains(' Add ').click(); | ||
cy.wait('@getOrgStructure'); | ||
cy.get('.orangehrm-modal-header > .oxd-text').contains( | ||
'Add Organization Unit', | ||
); | ||
}); | ||
|
||
it('verify the field validation in the add organization unit modal', function () { | ||
cy.loginTo(this.user, '/admin/viewCompanyStructure'); | ||
cy.wait('@getOrgStructure'); | ||
cy.getOXD('pageTitle').contains('Organization Structure'); | ||
cy.getOXD('switch').click(); | ||
cy.getOXD('button').contains(' Add ').click(); | ||
cy.wait('@getOrgStructure'); | ||
cy.get(':nth-child(1) > .oxd-input-group > :nth-child(2) > .oxd-input') | ||
.type(this.strings.chars120.text) | ||
.isInvalid('Should not exceed 100 characters'); | ||
cy.get(':nth-child(2) > .oxd-input-group > :nth-child(2) > .oxd-input') | ||
.type(this.strings.chars120.text) | ||
.isInvalid('Should not exceed 100 characters'); | ||
cy.get('.oxd-textarea') | ||
.type(this.strings.chars450.text) | ||
.isInvalid('Should not exceed 400 characters'); | ||
cy.get(':nth-child(2) > .oxd-input-group > :nth-child(2) > .oxd-input') | ||
.setValue('') | ||
.isInvalid('Required'); | ||
}); | ||
|
||
it('verify the cancel button behaviour in Add Organization unit modal', function () { | ||
cy.loginTo(this.user, '/admin/viewCompanyStructure'); | ||
cy.wait('@getOrgStructure'); | ||
cy.getOXD('pageTitle').contains('Organization Structure'); | ||
cy.getOXD('switch').click(); | ||
cy.getOXD('button').contains(' Add ').click(); | ||
cy.wait('@getOrgStructure'); | ||
cy.get( | ||
':nth-child(1) > .oxd-input-group > :nth-child(2) > .oxd-input', | ||
).type(this.strings.chars50.text); | ||
cy.get( | ||
':nth-child(2) > .oxd-input-group > :nth-child(2) > .oxd-input', | ||
).type(this.strings.chars50.text); | ||
cy.get('.oxd-textarea').type(this.strings.chars100.text); | ||
cy.get('.oxd-button--ghost').click(); | ||
cy.wait('@getOrgStructure'); | ||
cy.getOXD('pageTitle').contains('Organization Structure'); | ||
}); | ||
}); | ||
|
||
describe('Verify adding a unit for organaizational structure successfully and verify the Updating scenarios', function () { | ||
it('adding a unit with Unit ID and check the behaviour', function () { | ||
cy.loginTo(this.user, '/admin/viewCompanyStructure'); | ||
cy.wait('@getOrgStructure'); | ||
cy.getOXD('switch').click(); | ||
cy.getOXD('button').contains(' Add ').click(); | ||
cy.wait('@getOrgStructure'); | ||
cy.get( | ||
':nth-child(1) > .oxd-input-group > :nth-child(2) > .oxd-input', | ||
).type(this.strings.chars50.text); | ||
cy.get( | ||
':nth-child(2) > .oxd-input-group > :nth-child(2) > .oxd-input', | ||
).type(this.strings.chars50.text); | ||
cy.get('.oxd-textarea').type(this.strings.chars100.text); | ||
cy.get('.oxd-form-actions > .oxd-button--secondary').click(); | ||
cy.wait('@postOrgStructure'); | ||
cy.toast('success', 'Successfully Saved'); | ||
// eslint-disable-next-line cypress/no-unnecessary-waiting | ||
cy.wait(3000); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👀 |
||
cy.task('db:snapshot', {name: 'addedEventOnOrg'}); | ||
}); | ||
|
||
it('check the duplicate validation for unit', function () { | ||
cy.task('db:restore', {name: 'addedEventOnOrg'}); | ||
cy.loginTo(this.user, '/admin/viewCompanyStructure'); | ||
cy.wait('@getOrgStructure'); | ||
cy.getOXD('switch').click(); | ||
cy.getOXD('button').contains(' Add ').click(); | ||
cy.wait('@getOrgStructure'); | ||
cy.get(':nth-child(2) > .oxd-input-group > :nth-child(2) > .oxd-input') | ||
.setValue(this.strings.chars50.text) | ||
.isInvalid('Organization unit name should be unique'); | ||
}); | ||
|
||
it('Verifying edit modal header', function () { | ||
cy.task('db:restore', {name: 'addedEventOnOrg'}); | ||
cy.loginTo(this.user, '/admin/viewCompanyStructure'); | ||
cy.wait('@getOrgStructure'); | ||
cy.getOXD('switch').click(); | ||
cy.get('.org-action > :nth-child(2)').click(); | ||
cy.wait('@getOrgStructure'); | ||
cy.get('.orangehrm-modal-header > .oxd-text').contains( | ||
'Edit Organization Unit', | ||
); | ||
}); | ||
|
||
it('Verifying cancel button in edit modal', function () { | ||
cy.task('db:restore', {name: 'addedEventOnOrg'}); | ||
cy.loginTo(this.user, '/admin/viewCompanyStructure'); | ||
cy.wait('@getOrgStructure'); | ||
cy.getOXD('switch').click(); | ||
cy.get('.org-action > :nth-child(2)').click(); | ||
cy.wait('@getOrgStructure'); | ||
cy.get('.oxd-button--ghost').click(); | ||
cy.wait('@getOrgStructure'); | ||
cy.getOXD('pageTitle').contains('Organization Structure'); | ||
}); | ||
|
||
it('Verifying editing an unit successfully', function () { | ||
cy.task('db:restore', {name: 'addedEventOnOrg'}); | ||
cy.loginTo(this.user, '/admin/viewCompanyStructure'); | ||
cy.wait('@getOrgStructure'); | ||
cy.getOXD('switch').click(); | ||
cy.get('.org-action > :nth-child(2)').click(); | ||
cy.wait('@getOrgStructure'); | ||
cy.get( | ||
':nth-child(1) > .oxd-input-group > :nth-child(2) > .oxd-input', | ||
).type('Updated Unit ID'); | ||
cy.get( | ||
':nth-child(2) > .oxd-input-group > :nth-child(2) > .oxd-input', | ||
).type('Updated Name'); | ||
cy.get('.oxd-textarea').type('Updated description'); | ||
cy.get('.oxd-form-actions > .oxd-button--secondary').click(); | ||
cy.wait('@updateOrgStructure'); | ||
cy.toast('success', 'Successfully Updated'); | ||
//eslint-disable-next-line cypress/no-unnecessary-waiting | ||
cy.wait(3000); | ||
}); | ||
}); | ||
|
||
describe('Verifying deleting scenario', function () { | ||
it('adding a unit with Unit ID and check the behaviour', function () { | ||
cy.loginTo(this.user, '/admin/viewCompanyStructure'); | ||
cy.wait('@getOrgStructure'); | ||
cy.getOXD('switch').click(); | ||
cy.getOXD('button').contains(' Add ').click(); | ||
cy.wait('@getOrgStructure'); | ||
cy.get( | ||
':nth-child(1) > .oxd-input-group > :nth-child(2) > .oxd-input', | ||
).type(this.strings.chars50.text); | ||
cy.get( | ||
':nth-child(2) > .oxd-input-group > :nth-child(2) > .oxd-input', | ||
).type(this.strings.chars50.text); | ||
cy.get('.oxd-textarea').type(this.strings.chars100.text); | ||
cy.get('.oxd-form-actions > .oxd-button--secondary').click(); | ||
cy.wait('@postOrgStructure'); | ||
cy.toast('success', 'Successfully Saved'); | ||
// eslint-disable-next-line cypress/no-unnecessary-waiting | ||
cy.wait(3000); | ||
cy.task('db:snapshot', {name: 'addedEventOnOrgForDelete'}); | ||
// eslint-disable-next-line cypress/no-unnecessary-waiting | ||
cy.wait(3000); | ||
}); | ||
|
||
it('verifying "no delete" button on delete pop up message', function () { | ||
cy.task('db:restore', {name: 'addedEventOnOrgForDelete'}); | ||
cy.loginTo(this.user, '/admin/viewCompanyStructure'); | ||
cy.wait('@getOrgStructure'); | ||
cy.getOXD('switch').click(); | ||
cy.get('.org-action > :nth-child(1)').click(); | ||
cy.get('.oxd-button--text').click(); | ||
//cy.wait('@getOrgStructure'); | ||
cy.getOXD('pageTitle').contains('Organization Structure'); | ||
// eslint-disable-next-line cypress/no-unnecessary-waiting | ||
cy.wait(3000); | ||
}); | ||
|
||
it('verifying yes delete button on delete pop up message and successfully deletion', function () { | ||
cy.task('db:restore', {name: 'addedEventOnOrgForDelete'}); | ||
cy.loginTo(this.user, '/admin/viewCompanyStructure'); | ||
cy.wait('@getOrgStructure'); | ||
cy.getOXD('switch').click(); | ||
cy.get('.org-action > :nth-child(1)').click(); | ||
cy.get('.oxd-button--label-danger').click(); | ||
cy.wait('@deleteOrgStructure'); | ||
cy.toast('success', 'Successfully Deleted'); | ||
// eslint-disable-next-line cypress/no-unnecessary-waiting | ||
cy.wait(3000); | ||
}); | ||
}); | ||
|
||
describe('Verifying adding units to added unit', function () { | ||
it('adding a unit with Unit ID and check the behaviour', function () { | ||
cy.loginTo(this.user, '/admin/viewCompanyStructure'); | ||
cy.wait('@getOrgStructure'); | ||
cy.getOXD('switch').click(); | ||
cy.getOXD('button').contains(' Add ').click(); | ||
cy.wait('@getOrgStructure'); | ||
cy.get( | ||
':nth-child(1) > .oxd-input-group > :nth-child(2) > .oxd-input', | ||
).type(this.strings.chars50.text); | ||
cy.get( | ||
':nth-child(2) > .oxd-input-group > :nth-child(2) > .oxd-input', | ||
).type(this.strings.chars50.text); | ||
cy.get('.oxd-textarea').type(this.strings.chars100.text); | ||
cy.get('.oxd-form-actions > .oxd-button--secondary').click(); | ||
cy.wait('@postOrgStructure'); | ||
cy.toast('success', 'Successfully Saved'); | ||
// eslint-disable-next-line cypress/no-unnecessary-waiting | ||
cy.wait(3000); | ||
cy.task('db:snapshot', {name: 'addedEventOnOrgForAddingAnotherUnit'}); | ||
// eslint-disable-next-line cypress/no-unnecessary-waiting | ||
cy.wait(3000); | ||
}); | ||
|
||
it('checking field level validation for added child event', function () { | ||
cy.task('db:restore', {name: 'addedEventOnOrgForAddingAnotherUnit'}); | ||
cy.loginTo(this.user, '/admin/viewCompanyStructure'); | ||
cy.wait('@getOrgStructure'); | ||
cy.getOXD('switch').click(); | ||
cy.get('.org-action > :nth-child(3)').click(); | ||
cy.wait('@getOrgStructure'); | ||
cy.get(':nth-child(1) > .oxd-input-group > :nth-child(2) > .oxd-input') | ||
.type(this.strings.chars120.text) | ||
.isInvalid('Should not exceed 100 characters'); | ||
cy.get(':nth-child(2) > .oxd-input-group > :nth-child(2) > .oxd-input') | ||
.type(this.strings.chars120.text) | ||
.isInvalid('Should not exceed 100 characters'); | ||
cy.get('.oxd-textarea') | ||
.type(this.strings.chars450.text) | ||
.isInvalid('Should not exceed 400 characters'); | ||
cy.get(':nth-child(2) > .oxd-input-group > :nth-child(2) > .oxd-input') | ||
.setValue('') | ||
.isInvalid('Required'); | ||
// eslint-disable-next-line cypress/no-unnecessary-waiting | ||
cy.wait(3000); | ||
}); | ||
|
||
it('checking cancel button added child event', function () { | ||
cy.task('db:restore', {name: 'addedEventOnOrgForAddingAnotherUnit'}); | ||
cy.loginTo(this.user, '/admin/viewCompanyStructure'); | ||
cy.wait('@getOrgStructure'); | ||
cy.getOXD('switch').click(); | ||
cy.get('.org-action > :nth-child(3)').click(); | ||
cy.wait('@getOrgStructure'); | ||
cy.get(':nth-child(1) > .oxd-input-group > :nth-child(2) > .oxd-input') | ||
.type(this.strings.chars120.text) | ||
.isInvalid('Should not exceed 100 characters'); | ||
cy.get(':nth-child(2) > .oxd-input-group > :nth-child(2) > .oxd-input') | ||
.type(this.strings.chars120.text) | ||
.isInvalid('Should not exceed 100 characters'); | ||
cy.get('.oxd-textarea') | ||
.type(this.strings.chars450.text) | ||
.isInvalid('Should not exceed 400 characters'); | ||
cy.get(':nth-child(2) > .oxd-input-group > :nth-child(2) > .oxd-input') | ||
.setValue('') | ||
.isInvalid('Required'); | ||
cy.get('.oxd-button--ghost').click(); | ||
cy.wait('@getOrgStructure'); | ||
cy.getOXD('pageTitle').contains('Organization Structure'); | ||
}); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not use form?