From c51d33973272ce5224db5e122f23651aabdb56ce Mon Sep 17 00:00:00 2001 From: Carlos Jimenez <=> Date: Thu, 7 Dec 2017 15:51:48 +0100 Subject: [PATCH] changeLanguage extension applied to the whole e2e testing. --- e2e/helpers/extensions.js | 2 +- e2e/paths/create_client_path.spec.js | 19 +++++-------------- e2e/paths/edit_basic_data.spec.js | 19 +++++-------------- e2e/paths/edit_fiscal_data.spec.js | 19 +++++-------------- 4 files changed, 16 insertions(+), 43 deletions(-) diff --git a/e2e/helpers/extensions.js b/e2e/helpers/extensions.js index a99d6f833..a90d4f410 100644 --- a/e2e/helpers/extensions.js +++ b/e2e/helpers/extensions.js @@ -137,7 +137,7 @@ Nightmare.action('changeLanguageToEnglish', function(done) { this.click(selectors.globalItems.languageButton) .then(done); } - if (result != 'Cambiar idioma') { + if (result === 'Change language') { this.then(done); } }); diff --git a/e2e/paths/create_client_path.spec.js b/e2e/paths/create_client_path.spec.js index f67859183..887475d1b 100644 --- a/e2e/paths/create_client_path.spec.js +++ b/e2e/paths/create_client_path.spec.js @@ -33,20 +33,11 @@ describe('create client path', () => { it('should make sure the language is English', done => { nightmare - .wait(selectors.globalItems.languageButton) - .evaluate(selector => { - return document.querySelector(selector).title; - }, selectors.globalItems.languageButton) - .then(result => { - if (result === 'Cambiar idioma') { - nightmare.click(selectors.globalItems.languageButton) - .then(done); - } - if (result != 'Cambiar idioma') { - nightmare - .then(done); - } - }); + .changeLanguageToEnglish() + .then(() => { + done(); + }) + .catch(catchErrors(done)); }); it('should access to the clients index by clicking the clients button', done => { diff --git a/e2e/paths/edit_basic_data.spec.js b/e2e/paths/edit_basic_data.spec.js index c8099b03f..db1058ba8 100644 --- a/e2e/paths/edit_basic_data.spec.js +++ b/e2e/paths/edit_basic_data.spec.js @@ -33,20 +33,11 @@ describe('Edit basicData path', () => { it('should make sure the language is English', done => { nightmare - .wait(selectors.globalItems.languageButton) - .evaluate(selector => { - return document.querySelector(selector).title; - }, selectors.globalItems.languageButton) - .then(result => { - if (result === 'Cambiar idioma') { - nightmare.click(selectors.globalItems.languageButton) - .then(done); - } - if (result != 'Cambiar idioma') { - nightmare - .then(done); - } - }); + .changeLanguageToEnglish() + .then(() => { + done(); + }) + .catch(catchErrors(done)); }); it('should click on the Clients button of the top bar menu', done => { diff --git a/e2e/paths/edit_fiscal_data.spec.js b/e2e/paths/edit_fiscal_data.spec.js index 4b9dbbcf3..d88af12b0 100644 --- a/e2e/paths/edit_fiscal_data.spec.js +++ b/e2e/paths/edit_fiscal_data.spec.js @@ -33,20 +33,11 @@ describe('Edit fiscalData path', () => { it('should make sure the language is English', done => { nightmare - .wait(selectors.globalItems.languageButton) - .evaluate(selector => { - return document.querySelector(selector).title; - }, selectors.globalItems.languageButton) - .then(result => { - if (result === 'Cambiar idioma') { - nightmare.click(selectors.globalItems.languageButton) - .then(done); - } - if (result != 'Cambiar idioma') { - nightmare - .then(done); - } - }); + .changeLanguageToEnglish() + .then(() => { + done(); + }) + .catch(catchErrors(done)); }); it('should click on the Clients button of the top bar menu', done => {