Improved cucumber tests
This commit is contained in:
parent
b53e5d0e36
commit
b54707f2dc
6 changed files with 49 additions and 18 deletions
|
|
@ -24,6 +24,7 @@ module.exports = function doSteps() {
|
|||
client.waitForVisible('#feedback-tab', 10000);
|
||||
client.click('#feedback-tab');
|
||||
client.waitForVisible('#feedback-form', 10000);
|
||||
client.waitForEnabled('input[name="email"]');
|
||||
client.setValue('input[name="email"]', randomEmail());
|
||||
client.setValue('#feedbackTextarea', randomText(500));
|
||||
client.click('#sendFeedbackBtn');
|
||||
|
|
|
|||
|
|
@ -11,6 +11,14 @@
|
|||
this.waitForVisible(selector, timeout);
|
||||
this.waitForEnabled(selector, timeout);
|
||||
});
|
||||
|
||||
client.addCommand('waitUntilText', function waitUntilText(selector, text, ms) {
|
||||
ms = ms || 5000;
|
||||
this.waitForVisible(selector);
|
||||
const self = this;
|
||||
this.waitUntil(() => self.getText(selector).includes(text), ms, `expected text in ${selector} be different after ${ms / 1000}s. Obtained: '${self.getText(selector)}' expected: '${text}'`);
|
||||
});
|
||||
|
||||
this.initMyCmds = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,35 +35,46 @@ module.exports = function doSteps(notos) {
|
|||
function waitNoBert() {
|
||||
client.pause(2000);
|
||||
if (client.isVisible('.bert-container')) {
|
||||
console.log('Removing bert alert');
|
||||
// console.log('Removing bert alert');
|
||||
client.click('.bert-container');
|
||||
client.waitForVisible('.bert-container', 10000, true);
|
||||
} else {
|
||||
console.log('No bert alert');
|
||||
// console.log('No bert alert');
|
||||
}
|
||||
}
|
||||
|
||||
function register() {
|
||||
function logoutIfLogged() {
|
||||
if (client.isVisible('#logout')) {
|
||||
client.click('#logout');
|
||||
}
|
||||
client.waitForVisible('#signup', 10000);
|
||||
}
|
||||
|
||||
function register() {
|
||||
logoutIfLogged();
|
||||
client.waitForVisible('#signup', 10000);
|
||||
client.click('#signup');
|
||||
setUserValues();
|
||||
if (!notos) {
|
||||
client.click('input[name="tos"]');
|
||||
}
|
||||
client.click('#signUpSubmit');
|
||||
client.waitForVisible('#logout', 10000);
|
||||
}
|
||||
|
||||
this.Given(/^I logout if logged$/, () => {
|
||||
waitNoBert();
|
||||
logoutIfLogged();
|
||||
});
|
||||
|
||||
this.Given(/^I have an account and I logged in$/, () => {
|
||||
register();
|
||||
});
|
||||
|
||||
function checkName() {
|
||||
client.waitForVisible('#profile', 5000);
|
||||
client.waitForText('#profile', firstName);
|
||||
client.waitForText('#profile', lastName);
|
||||
client.waitUntilText('#profile', firstName);
|
||||
client.waitUntilText('#profile', lastName);
|
||||
}
|
||||
|
||||
this.Then(/^I should be logged in$/, () => {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ module.exports = function () {
|
|||
const content = pages[i][1];
|
||||
client.waitForVisible(id, 10000);
|
||||
client.click(id);
|
||||
client.waitForText('#react-root', content);
|
||||
client.waitUntilText('#react-root', content);
|
||||
// https://jasmine.github.io/2.3/introduction.html#section-Expectations
|
||||
expect(client.getTitle()).toContain(pages[i][1]);
|
||||
}
|
||||
|
|
@ -26,7 +26,7 @@ module.exports = function () {
|
|||
const content = pages[i][1];
|
||||
client.url(`${process.env.ROOT_URL}/${url}`);
|
||||
client.waitForVisible('#react-root', 10000);
|
||||
client.waitForText('#react-root', content);
|
||||
client.waitUntilText('#react-root', content);
|
||||
const checkTitle = pages[i][2] === 'true';
|
||||
// https://jasmine.github.io/2.3/introduction.html#section-Expectations
|
||||
if (checkTitle) {
|
||||
|
|
@ -41,10 +41,7 @@ module.exports = function () {
|
|||
|
||||
this.Then(/^I check that all non visible pages works properly$/, (callback) => {
|
||||
for (let i = 0; i < pages.length; i += 1) {
|
||||
client.url(`${process.env.ROOT_URL}/${pages[i][0]}`);
|
||||
const content = pages[i][1];
|
||||
client.waitForVisible('#react-root', 10000);
|
||||
client.waitForText('#react-root', content);
|
||||
processPageUrl(i);
|
||||
}
|
||||
callback();
|
||||
});
|
||||
|
|
@ -77,7 +74,7 @@ module.exports = function () {
|
|||
// Write code here that turns the phrase above into concrete actions
|
||||
for (let i = 0; i < pages.length; i += 1) {
|
||||
client.url(`${process.env.ROOT_URL}/${pages[i][0]}?_escaped_fragment_=`);
|
||||
client.waitForText('#react-root', pages[i][1]);
|
||||
client.waitUntilText('#react-root', pages[i][1]);
|
||||
}
|
||||
callback();
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue