Tests more robusts

This commit is contained in:
vjrj 2018-05-21 17:43:17 +02:00
parent 391b8935be
commit 245619f4e4
4 changed files with 27 additions and 19 deletions

View file

@ -1,4 +1,3 @@
@watch
Feature: Allow users to give feedback Feature: Allow users to give feedback
As a user (authenticated or not) As a user (authenticated or not)

View file

@ -1,3 +1,4 @@
@watch
Feature: Allow users to login and logout Feature: Allow users to login and logout
As a user As a user

View file

@ -5,14 +5,14 @@
this.Before(() => { this.Before(() => {
// global.expect = require('@xolvio/jasmine-expect').expect; // global.expect = require('@xolvio/jasmine-expect').expect;
/* Not used // https://github.com/webdriverio/webdriverio/issues/1145
if (!this.initMyCmds) { if (!this.initMyCmds) {
client.addCommand('waitForClickable', function elementClickable(selector, timeout) { client.addCommand('waitForClickable', function elementClickable(selector, timeout) {
this.waitForVisible(selector, timeout); this.waitForVisible(selector, timeout);
this.waitForEnabled(selector, timeout); this.waitForEnabled(selector, timeout);
}); });
this.initMyCmds = true; this.initMyCmds = true;
} */ }
client.windowHandleSize({ width: 1500, height: 1000 }); client.windowHandleSize({ width: 1500, height: 1000 });

View file

@ -10,7 +10,7 @@ let pass;
let email; let email;
const setUserValues = (isEdit) => { const setUserValues = (isEdit) => {
client.waitForVisible('input[name="firstName"]', 5000); client.waitForVisible('input[name="firstName"]', 10000);
firstName = randomUsername(); firstName = randomUsername();
lastName = randomUsername(); lastName = randomUsername();
email = randomEmail(); email = randomEmail();
@ -32,11 +32,22 @@ module.exports = function doSteps(notos) {
goHome(client); goHome(client);
}); });
function waitNoBert() {
client.pause(2000);
if (client.isVisible('.bert-container')) {
console.log('Removing bert alert');
client.click('.bert-container');
client.waitForVisible('.bert-container', 10000, true);
} else {
console.log('No bert alert');
}
}
function register() { function register() {
if (client.isVisible('#logout')) { if (client.isVisible('#logout')) {
client.click('#logout'); client.click('#logout');
} }
client.waitForVisible('#signup', 5000); client.waitForVisible('#signup', 10000);
client.click('#signup'); client.click('#signup');
setUserValues(); setUserValues();
if (!notos) { if (!notos) {
@ -57,6 +68,7 @@ module.exports = function doSteps(notos) {
this.Then(/^I should be logged in$/, () => { this.Then(/^I should be logged in$/, () => {
client.waitUntil(() => client.isVisible('#logout') === true, 10000); client.waitUntil(() => client.isVisible('#logout') === true, 10000);
client.waitUntil(() => client.isVisible('#profile') === true, 10000);
}); });
/* this.Given(/^I am signed out$/, () => { /* this.Given(/^I am signed out$/, () => {
@ -64,30 +76,24 @@ module.exports = function doSteps(notos) {
* }); * });
*/ */
function closeAlert() {
// client.waitForVisible('.bert-alert', 5000);
// client.click('.bert-content');
client.waitUntil(() => client.isVisible('.bert-alert') === false, 10000);
}
this.When(/^I sign out$/, () => { this.When(/^I sign out$/, () => {
if (client.isVisible('.bert-alert')) { waitNoBert();
client.waitUntil(() => client.isVisible('.bert-alert') === false, 10000); client.waitForClickable('#logout', 10000);
} // client.waitForVisible('#logout', 10000);
client.waitForVisible('#logout', 10000);
client.click('#logout'); client.click('#logout');
client.waitForVisible('#login', 10000); client.waitForVisible('#login', 10000);
}); });
function login(badpass) { function login(badpass) {
waitNoBert();
client.waitForVisible('#login', 10000); client.waitForVisible('#login', 10000);
client.waitUntil(() => client.isVisible('.bert-alert') === false, 10000);
client.click('#login'); client.click('#login');
client.waitForVisible('#loginSubmit', 5000); client.waitForVisible('#loginSubmit', 5000);
client.setValue('input[name="emailAddress"]', email); client.setValue('input[name="emailAddress"]', email);
client.setValue('input[name="password"]', badpass ? randomPassword() : pass); client.setValue('input[name="password"]', badpass ? randomPassword() : pass);
client.click('#loginSubmit'); client.click('#loginSubmit');
closeAlert(); waitNoBert();
} }
this.When(/^I enter my email and password$/, () => { this.When(/^I enter my email and password$/, () => {
@ -95,11 +101,13 @@ module.exports = function doSteps(notos) {
}); });
this.Then(/^I can edit my profile$/, () => { this.Then(/^I can edit my profile$/, () => {
client.waitForVisible('#profile', 5000); waitNoBert();
client.waitForClickable('#profile', 10000);
client.click('#profile'); client.click('#profile');
client.pause(2000);
setUserValues(true); setUserValues(true);
client.click('#profileSubmit'); client.click('#profileSubmit');
closeAlert(); waitNoBert();
checkName(); checkName();
}); });
@ -117,7 +125,7 @@ module.exports = function doSteps(notos) {
this.Then(/^I should be registered$/, () => { this.Then(/^I should be registered$/, () => {
client.waitForVisible('.bert-alert', 10000, true); client.waitForVisible('.bert-alert', 10000, true);
closeAlert(); waitNoBert();
}); });
this.Given(/^I register with some name, password and email but without accept conditions$/, () => { this.Given(/^I register with some name, password and email but without accept conditions$/, () => {