-
-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ef15624
commit ab87b1c
Showing
8 changed files
with
122 additions
and
54 deletions.
There are no files selected for viewing
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
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
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 |
---|---|---|
@@ -1,20 +1,81 @@ | ||
const utils = require('../../utils'), | ||
usersPage = require('../../page-objects/users/users.po.js'), | ||
common = require('../../page-objects/common/common.po.js'), | ||
helper = require('../../helper'), | ||
addUserModal = require('../../page-objects/users/add-user-modal.po.js'); | ||
|
||
const addedUser = 'bedetester2020', | ||
fullName = 'Bede Ngaruko'; | ||
|
||
describe('Add user test : ', () => { | ||
it('should open add user modal', () => { | ||
common.goToConfiguration(); | ||
browser.get(utils.getBaseUrl() + '/_design/medic/_rewrite/#/configuration/users'); | ||
usersPage.openAddUserModal(); | ||
addUserModal.fillForm(addedUser, fullName); | ||
addUserModal.submit(); | ||
expect(helper.isTextDisplayed(addedUser)); | ||
expect(helper.isTextDisplayed(fullName)); | ||
}); | ||
usersPage = require('../../page-objects/users/users.po.js'), | ||
helper = require('../../helper'), | ||
addUserModal = require('../../page-objects/users/add-user-modal.po.js'); | ||
|
||
const addedUser = 'fulltester' + new Date().getTime(), | ||
fullName = 'Bede Ngaruko', | ||
errorMessagePassword = element.all(by.css('span.help-block.ng-binding')).get(3); | ||
|
||
describe('Add user : ', () => { | ||
afterEach(done => { | ||
utils.resetBrowser(); | ||
done(); | ||
}); | ||
|
||
afterAll(utils.afterEach); | ||
|
||
it('should add user with valid password', () => { | ||
usersPage.openAddUserModal(); | ||
addUserModal.fillForm(addedUser, fullName, 'StrongP@ssword1'); | ||
addUserModal.submit(); | ||
browser.wait(() => { | ||
return element(by.css('#edit-user-profile')).isDisplayed() | ||
.then(isDisplayed => { | ||
return !isDisplayed; | ||
}) | ||
.catch(() => { | ||
return true; | ||
}); | ||
}, 2000); | ||
expect(helper.isTextDisplayed(addedUser)); | ||
expect(helper.isTextDisplayed(fullName)); | ||
}); | ||
|
||
it('should reject passwords shorter than 8 characters', () => { | ||
usersPage.openAddUserModal(); | ||
addUserModal.fillForm('user0', 'Not Saved', 'short'); | ||
addUserModal.submit(); | ||
expect(errorMessagePassword.getText()).toBe('The password must be at least 8 characters long.'); | ||
}); | ||
|
||
it('should reject weak passwords', () => { | ||
usersPage.openAddUserModal(); | ||
addUserModal.fillForm('user0', 'Not Saved', 'weakPassword'); | ||
addUserModal.submit(); | ||
expect(errorMessagePassword.getText()).toBe('The password is too easy to guess. Include a range of types of characters to increase the score.'); | ||
}); | ||
|
||
it('should reject non-matching passwords', () => { | ||
usersPage.openAddUserModal(); | ||
addUserModal.fillForm('user0', 'Not Saved', '%4wbbygxkgdwvdwT65'); | ||
element(by.id('password-confirm')).sendKeys('abc'); | ||
addUserModal.submit(); | ||
expect(errorMessagePassword.getText()).toBe('Passwords must match.'); | ||
}); | ||
|
||
it('should require password', () => { | ||
usersPage.openAddUserModal(); | ||
addUserModal.fillForm('user0', 'Not Saved', ''); | ||
addUserModal.submit(); | ||
expect(errorMessagePassword.getText()).toBe('Password is a required field.'); | ||
}); | ||
|
||
it('should require username', () => { | ||
usersPage.openAddUserModal(); | ||
addUserModal.fillForm('', 'Not Saved', '%4wbbygxkgdwvdwT65'); | ||
addUserModal.submit(); | ||
const errorMessageUserName = element.all(by.css('span.help-block.ng-binding')).get(0); | ||
helper.waitUntilReady(errorMessageUserName); | ||
expect(errorMessageUserName.getText()).toBe('User name is a required field.'); | ||
}); | ||
|
||
it('should require place and contact for restricted user', () => { | ||
usersPage.openAddUserModal(); | ||
addUserModal.fillForm('restricted', 'Not Saved', '%4wbbygxkgdwvdwT65'); | ||
helper.selectDropdownByText(element(by.id('type')), 'Restricted to their place'); | ||
addUserModal.submit(); | ||
expect(element.all(by.css('span.help-block.ng-binding')).get(1).getText()).toBe('Place is a required field.'); | ||
expect(element.all(by.css('span.help-block.ng-binding')).get(2).getText()).toBe('Associated contact is a required field.'); | ||
}); | ||
}); |
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
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
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
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 |
---|---|---|
|
@@ -49,16 +49,16 @@ module.exports = { | |
getCancelButton().click(); | ||
}, | ||
|
||
fillForm: (username, fullName) => { | ||
fillForm: (username, fullName, password) => { | ||
helper.waitUntilReady(getSubmitButton()); // wait for form to load | ||
getUsernameField().sendKeys(username); | ||
getFullNameField().sendKeys(fullName); | ||
getEmailField().sendKeys('[email protected]'); | ||
getPhoneField().sendKeys('0064212134566'); | ||
helper.selectDropdownByText(getLanguageField(), 'English', 2); | ||
helper.selectDropdownByText(getUserTypeField(), 'Full access'); | ||
getPasswordField().sendKeys('pass'); | ||
getConfirmPasswordField().sendKeys('pass'); | ||
getPasswordField().sendKeys(password); | ||
getConfirmPasswordField().sendKeys(password); | ||
} | ||
}; | ||
|
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