From 245619f4e43d16672cb2d01aa349c505fc4a9db4 Mon Sep 17 00:00:00 2001 From: vjrj Date: Mon, 21 May 2018 17:43:17 +0200 Subject: [PATCH] Tests more robusts --- cucumber/features/feedback.feature | 1 - cucumber/features/login.feature | 1 + cucumber/features/steps_definitions/hooks.js | 4 +- cucumber/features/steps_definitions/login.js | 40 ++++++++++++-------- 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/cucumber/features/feedback.feature b/cucumber/features/feedback.feature index 8c759e3..3bbb113 100644 --- a/cucumber/features/feedback.feature +++ b/cucumber/features/feedback.feature @@ -1,4 +1,3 @@ -@watch Feature: Allow users to give feedback As a user (authenticated or not) diff --git a/cucumber/features/login.feature b/cucumber/features/login.feature index 38fe003..a723e56 100644 --- a/cucumber/features/login.feature +++ b/cucumber/features/login.feature @@ -1,3 +1,4 @@ +@watch Feature: Allow users to login and logout As a user diff --git a/cucumber/features/steps_definitions/hooks.js b/cucumber/features/steps_definitions/hooks.js index 9e3e611..712582c 100644 --- a/cucumber/features/steps_definitions/hooks.js +++ b/cucumber/features/steps_definitions/hooks.js @@ -5,14 +5,14 @@ this.Before(() => { // global.expect = require('@xolvio/jasmine-expect').expect; - /* Not used + // https://github.com/webdriverio/webdriverio/issues/1145 if (!this.initMyCmds) { client.addCommand('waitForClickable', function elementClickable(selector, timeout) { this.waitForVisible(selector, timeout); this.waitForEnabled(selector, timeout); }); this.initMyCmds = true; - } */ + } client.windowHandleSize({ width: 1500, height: 1000 }); diff --git a/cucumber/features/steps_definitions/login.js b/cucumber/features/steps_definitions/login.js index f580e1d..c509ba0 100644 --- a/cucumber/features/steps_definitions/login.js +++ b/cucumber/features/steps_definitions/login.js @@ -10,7 +10,7 @@ let pass; let email; const setUserValues = (isEdit) => { - client.waitForVisible('input[name="firstName"]', 5000); + client.waitForVisible('input[name="firstName"]', 10000); firstName = randomUsername(); lastName = randomUsername(); email = randomEmail(); @@ -32,11 +32,22 @@ module.exports = function doSteps(notos) { 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() { if (client.isVisible('#logout')) { client.click('#logout'); } - client.waitForVisible('#signup', 5000); + client.waitForVisible('#signup', 10000); client.click('#signup'); setUserValues(); if (!notos) { @@ -57,6 +68,7 @@ module.exports = function doSteps(notos) { this.Then(/^I should be logged in$/, () => { client.waitUntil(() => client.isVisible('#logout') === true, 10000); + client.waitUntil(() => client.isVisible('#profile') === true, 10000); }); /* 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$/, () => { - if (client.isVisible('.bert-alert')) { - client.waitUntil(() => client.isVisible('.bert-alert') === false, 10000); - } - client.waitForVisible('#logout', 10000); + waitNoBert(); + client.waitForClickable('#logout', 10000); + // client.waitForVisible('#logout', 10000); client.click('#logout'); client.waitForVisible('#login', 10000); }); function login(badpass) { + waitNoBert(); client.waitForVisible('#login', 10000); - client.waitUntil(() => client.isVisible('.bert-alert') === false, 10000); client.click('#login'); client.waitForVisible('#loginSubmit', 5000); client.setValue('input[name="emailAddress"]', email); client.setValue('input[name="password"]', badpass ? randomPassword() : pass); client.click('#loginSubmit'); - closeAlert(); + waitNoBert(); } this.When(/^I enter my email and password$/, () => { @@ -95,11 +101,13 @@ module.exports = function doSteps(notos) { }); this.Then(/^I can edit my profile$/, () => { - client.waitForVisible('#profile', 5000); + waitNoBert(); + client.waitForClickable('#profile', 10000); client.click('#profile'); + client.pause(2000); setUserValues(true); client.click('#profileSubmit'); - closeAlert(); + waitNoBert(); checkName(); }); @@ -117,7 +125,7 @@ module.exports = function doSteps(notos) { this.Then(/^I should be registered$/, () => { client.waitForVisible('.bert-alert', 10000, true); - closeAlert(); + waitNoBert(); }); this.Given(/^I register with some name, password and email but without accept conditions$/, () => {