diff --git a/cucumber/features/login.feature b/cucumber/features/login.feature index a723e56..38fe003 100644 --- a/cucumber/features/login.feature +++ b/cucumber/features/login.feature @@ -1,4 +1,3 @@ -@watch Feature: Allow users to login and logout As a user diff --git a/cucumber/features/pages.feature b/cucumber/features/pages.feature index ac66526..74afc36 100644 --- a/cucumber/features/pages.feature +++ b/cucumber/features/pages.feature @@ -10,8 +10,9 @@ Feature: Test all secundary pages | about | About | Then I check that all pages works properly - Scenario: Check that all secondary pages work well - Given a list of page urls and contents + Scenario: Check that all secondary pages work well when not logged + Given I logout if logged + And a list of page urls and contents | login | Login | true | | signup | Sign Up | true | | fires | Fires | true | @@ -21,12 +22,26 @@ Feature: Test all secundary pages | fire/inexistent | This page doesn't exist | false | | fire/Fe26.2**1a0361ed0384f741403682e26b4bbc3850bee24e775da13c9782b22365ea895f*r_3gmVad5vzkeyqPpo6UcA*1s5fFz3iDGKTYP2RCvXMshof00QCHf4ErDl9K2dxoX0u-J-t6scyOWG8pGp3ehg_FfEtyR_kYcEKU3rE0jaSlZbD09TIvhiIJeS3C6Uc8YD-rit0XBrgsVKfYSxKzTRoOYiYFJ8JYd298hMtfiASePjS05Z58hhicyCcJYYRlarqDScG3LiVY3lL5y2nfcdIMNuSjCiKOJWuMkxwd9nR1UHMudLl0hEoy56mPdnHpDYtP9IYUlIOk1LlWBxcmHKifbXeqHu94p8j13Kk20dh2R49Hw3KsSoE9UbWmGQA9wAZXT82301i3rGF5GPAKjlTlRYcWisQurnPwHSVmx3DhUdiYwKGxt4KeaM5QVI4BE9octvE41OOprB_-Il105diQEh2Y9vdvX51ZVWIRfCboICPM6rJb0Oin7U7F1iM-oD_5s3DGnelfM5LGBcKwiB5paMo5M5vdBMaO-zR216cW9yGVXw9IZqHx8xDQWnoHAZjt8NLHeiGF2QOmIGtEUH7qnwhGpkcvszajmAZzR8saZgoH1qfBfvpVA41YfV14gU**4d030f05e23ad75409cebc609107467fc60be5077d52cf041087cd024fc4dc45*GY97aGFc1MyAsoO3Qxqtgwk9j-MbAPdEGBmEHq6r8VU | Additional information | false | Then I check that all page urls works properly + # And they are spiderable + @watch + Scenario: Check that all secondary pages work well when logged + Given I have an account and I logged in + And a list of page urls and contents + | status | Status | false | + | fires | Fires | true | + | zones | Monitored | true | + | verify-email/something | Verify | true | + | fire/inexistent | This page doesn't exist | false | + | fire/Fe26.2**1a0361ed0384f741403682e26b4bbc3850bee24e775da13c9782b22365ea895f*r_3gmVad5vzkeyqPpo6UcA*1s5fFz3iDGKTYP2RCvXMshof00QCHf4ErDl9K2dxoX0u-J-t6scyOWG8pGp3ehg_FfEtyR_kYcEKU3rE0jaSlZbD09TIvhiIJeS3C6Uc8YD-rit0XBrgsVKfYSxKzTRoOYiYFJ8JYd298hMtfiASePjS05Z58hhicyCcJYYRlarqDScG3LiVY3lL5y2nfcdIMNuSjCiKOJWuMkxwd9nR1UHMudLl0hEoy56mPdnHpDYtP9IYUlIOk1LlWBxcmHKifbXeqHu94p8j13Kk20dh2R49Hw3KsSoE9UbWmGQA9wAZXT82301i3rGF5GPAKjlTlRYcWisQurnPwHSVmx3DhUdiYwKGxt4KeaM5QVI4BE9octvE41OOprB_-Il105diQEh2Y9vdvX51ZVWIRfCboICPM6rJb0Oin7U7F1iM-oD_5s3DGnelfM5LGBcKwiB5paMo5M5vdBMaO-zR216cW9yGVXw9IZqHx8xDQWnoHAZjt8NLHeiGF2QOmIGtEUH7qnwhGpkcvszajmAZzR8saZgoH1qfBfvpVA41YfV14gU**4d030f05e23ad75409cebc609107467fc60be5077d52cf041087cd024fc4dc45*GY97aGFc1MyAsoO3Qxqtgwk9j-MbAPdEGBmEHq6r8VU | Additional information | false | + Then I check that all page urls works properly + + @watch Scenario: Check that other non visible pages work well - Given a list of non visible pages ids and contents - | status | Status | - | error | Upps | + Given I logout if logged + And a list of non visible pages ids and contents + | error | Upppps | false | # FIXME: find a way to monitor json pages # | api/v1/status/last-fire-detected | updateAt | # | api/v1/status/last-fire-check | description | diff --git a/cucumber/features/steps_definitions/feedback.js b/cucumber/features/steps_definitions/feedback.js index f25a3b3..ffd78be 100644 --- a/cucumber/features/steps_definitions/feedback.js +++ b/cucumber/features/steps_definitions/feedback.js @@ -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'); diff --git a/cucumber/features/steps_definitions/hooks.js b/cucumber/features/steps_definitions/hooks.js index 712582c..574b9c4 100644 --- a/cucumber/features/steps_definitions/hooks.js +++ b/cucumber/features/steps_definitions/hooks.js @@ -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; } diff --git a/cucumber/features/steps_definitions/login.js b/cucumber/features/steps_definitions/login.js index c509ba0..b255b96 100644 --- a/cucumber/features/steps_definitions/login.js +++ b/cucumber/features/steps_definitions/login.js @@ -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$/, () => { diff --git a/cucumber/features/steps_definitions/pages.js b/cucumber/features/steps_definitions/pages.js index 38e61b0..29f6aab 100644 --- a/cucumber/features/steps_definitions/pages.js +++ b/cucumber/features/steps_definitions/pages.js @@ -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(); });