Skip to content

Commit

Permalink
Use browser.wait instead of browser.sleep in users e2e tests
Browse files Browse the repository at this point in the history
Waits for the modal to open, instead of just waiting a fixed period of time
  • Loading branch information
rjmackay committed Nov 30, 2015
1 parent 114fc17 commit 501b5aa
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions test/e2e/settings/users-e2e-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ var _ = require('underscore');
describe('users management', function () {

describe('as a loggedin admin user', function () {
var alertText;

beforeEach(function () {
alertText = element(by.css('#alert-modal-text'));

browser.get('/login');

element(by.model('email')).sendKeys('admin@ush.com');
Expand Down Expand Up @@ -92,10 +95,10 @@ describe('users management', function () {
describe('selecting "Member" as new role', function () {
beforeEach(function () {
element(by.linkText('Member')).click();
browser.sleep(500);
browser.wait(alertText.isDisplayed, 500);
});
it('shows an error alert that you cannot change your own role (the user as which your are signed in)', function () {
element(by.css('#alert-modal-text')).getText().then(
alertText.getText().then(
function (text) {
expect(text).toEqual('You cannot change your own role');
});
Expand All @@ -117,7 +120,7 @@ describe('users management', function () {
deleteButton.click();
});

browser.sleep(500);
browser.wait(alertText.isDisplayed, 500);
});

it('shows an error alert that you cannot delete your own user (the user as which your are signed in)', function () {
Expand All @@ -140,9 +143,10 @@ describe('users management', function () {
});

describe('change role button', function () {
var changeRoleButton;
var changeRoleButton, confirmModalText;
beforeEach(function () {
changeRoleButton = element(by.css('button#change-role'));
confirmModalText = element(by.css('#confirm-modal-text'));
});

describe('clicking the button', function () {
Expand All @@ -156,10 +160,10 @@ describe('users management', function () {
describe('selecting "Member" as new role', function () {
beforeEach(function () {
element(by.linkText('Member')).click();
browser.sleep(500);
browser.wait(confirmModalText.isDisplayed, 500);
});
it('shows an alert which asks if you really want to change the roles', function () {
expect(element(by.css('#confirm-modal-text')).getText()).toEqual('Are you sure you want to change the role of 4 users to Member?');
expect(confirmModalText.getText()).toEqual('Are you sure you want to change the role of 4 users to Member?');
element(by.css('button#confirm-modal-ok')).click();
});
});
Expand Down

0 comments on commit 501b5aa

Please sign in to comment.