From 326d762cd1db93a1bcc3d848727df6be737af5f3 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez <=> Date: Fri, 2 Mar 2018 12:15:17 +0100 Subject: [PATCH] now each e2e path calls it's own loging function for dev to use differente users --- e2e/helpers/extensions.js | 8 ++++---- e2e/helpers/helpers.js | 5 ----- e2e/paths/client-module/01_create_client.spec.js | 5 +++++ e2e/paths/client-module/02_edit_basic_data.spec.js | 5 +++++ e2e/paths/client-module/03_edit_fiscal_data.spec.js | 11 ++++++++--- e2e/paths/client-module/04_edit_pay_method.spec.js | 5 +++++ e2e/paths/client-module/05_add_address.spec.js | 5 +++++ e2e/paths/client-module/06_add_address_notes.spec.js | 5 +++++ e2e/paths/client-module/07_edit_web_access.spec.js | 5 +++++ e2e/paths/client-module/08_add_notes.spec.js | 5 +++++ e2e/paths/client-module/09_add_credit.spec.js | 5 +++++ e2e/paths/client-module/10_add_greuge.spec.js | 5 +++++ e2e/paths/client-module/11_mandate.spec.js | 5 +++++ e2e/paths/item-module/01_item_summary.spec.js | 5 +++++ e2e/paths/item-module/02_edit_item_basic_data.spec.js | 5 +++++ e2e/paths/item-module/03_edit_item_tax.spec.js | 5 +++++ e2e/paths/item-module/04_create_item_tags.spec.js | 5 +++++ e2e/paths/item-module/05_create_item_niche.spec.js | 5 +++++ .../item-module/06_create_item_botanical.spec.js | 5 +++++ e2e/paths/item-module/07_create_item_barcode.spec.js | 5 +++++ .../item-module/08_item_create_and_clone.spec.js | 6 ++++++ 21 files changed, 103 insertions(+), 12 deletions(-) diff --git a/e2e/helpers/extensions.js b/e2e/helpers/extensions.js index ceb6cb9ee..ac9038f29 100644 --- a/e2e/helpers/extensions.js +++ b/e2e/helpers/extensions.js @@ -2,10 +2,10 @@ import config from './config.js'; import Nightmare from 'nightmare'; import {URL} from 'url'; -Nightmare.action('login', function(done) { +Nightmare.action('login', function(userName, done) { this.goto(`${config.url}auth/?apiKey=salix`) .wait(`vn-login input[name=user]`) - .write(`vn-login input[name=user]`, 'developer') + .write(`vn-login input[name=user]`, userName) .write(`vn-login input[name=password]`, 'nightmare') .click(`vn-login input[type=submit]`) // FIXME: Wait for dom to be ready: https://github.com/segmentio/nightmare/issues/481 @@ -29,8 +29,8 @@ Nightmare.action('changeLanguageToEnglish', function(done) { }); }); -Nightmare.action('waitForLogin', function(done) { - this.login() +Nightmare.action('waitForLogin', function(userName, done) { + this.login(userName) .waitForURL('#!/') .url() .changeLanguageToEnglish() diff --git a/e2e/helpers/helpers.js b/e2e/helpers/helpers.js index d2d0b4af9..a7866c2d2 100644 --- a/e2e/helpers/helpers.js +++ b/e2e/helpers/helpers.js @@ -5,11 +5,6 @@ function myCreateNightmare() { let nightmare = createNightmare(); nightmare.header('Accept-Language', 'en'); - beforeAll(() => { - return nightmare - .waitForLogin(); - }); - afterAll(() => { return nightmare .end(); diff --git a/e2e/paths/client-module/01_create_client.spec.js b/e2e/paths/client-module/01_create_client.spec.js index 7192ff65c..a5036e484 100644 --- a/e2e/paths/client-module/01_create_client.spec.js +++ b/e2e/paths/client-module/01_create_client.spec.js @@ -4,6 +4,11 @@ import createNightmare from '../../helpers/helpers'; describe('create client path', () => { let nightmare = createNightmare(); + beforeAll(() => { + return nightmare + .waitForLogin('developer'); + }); + it('should access to the clients index by clicking the clients button', () => { return nightmare .click(selectors.moduleAccessView.clientsSectionButton) diff --git a/e2e/paths/client-module/02_edit_basic_data.spec.js b/e2e/paths/client-module/02_edit_basic_data.spec.js index 8727f591d..695f4d9c2 100644 --- a/e2e/paths/client-module/02_edit_basic_data.spec.js +++ b/e2e/paths/client-module/02_edit_basic_data.spec.js @@ -4,6 +4,11 @@ import createNightmare from '../../helpers/helpers'; describe('Edit basicData path', () => { const nightmare = createNightmare(); + beforeAll(() => { + return nightmare + .waitForLogin('developer'); + }); + it('should click on the Clients button of the top bar menu', () => { return nightmare .waitToClick(selectors.globalItems.applicationsMenuButton) diff --git a/e2e/paths/client-module/03_edit_fiscal_data.spec.js b/e2e/paths/client-module/03_edit_fiscal_data.spec.js index 64c09a34a..81010192a 100644 --- a/e2e/paths/client-module/03_edit_fiscal_data.spec.js +++ b/e2e/paths/client-module/03_edit_fiscal_data.spec.js @@ -1,9 +1,14 @@ import selectors from '../../helpers/selectors.js'; import createNightmare from '../../helpers/helpers'; -describe('Edit fiscalData path', () => { +fdescribe('Edit fiscalData path', () => { const nightmare = createNightmare(); + beforeAll(() => { + return nightmare + .waitForLogin('developer'); + }); + it('should click on the Clients button of the top bar menu', () => { return nightmare .waitToClick(selectors.globalItems.applicationsMenuButton) @@ -354,7 +359,7 @@ describe('Edit fiscalData path', () => { }); }); - it('should confirm Verified data checkbox is unchecked', () => { + it('should confirm Verified data checkbox is checked', () => { return nightmare .waitToClick(selectors.clientBasicData.basicDataButton) .wait(selectors.clientBasicData.nameInput) @@ -364,7 +369,7 @@ describe('Edit fiscalData path', () => { return document.querySelector(selector).checked; }, selectors.clientFiscalData.verifiedDataCheckboxInput) .then(value => { - expect(value).toBeFalsy(); + expect(value).toBeTruthy(); }); }); diff --git a/e2e/paths/client-module/04_edit_pay_method.spec.js b/e2e/paths/client-module/04_edit_pay_method.spec.js index bff96b73b..80dda38bb 100644 --- a/e2e/paths/client-module/04_edit_pay_method.spec.js +++ b/e2e/paths/client-module/04_edit_pay_method.spec.js @@ -4,6 +4,11 @@ import createNightmare from '../../helpers/helpers'; describe('Edit pay method path', () => { const nightmare = createNightmare(); + beforeAll(() => { + return nightmare + .waitForLogin('developer'); + }); + it('should click on the Clients button of the top bar menu', () => { return nightmare .waitToClick(selectors.globalItems.applicationsMenuButton) diff --git a/e2e/paths/client-module/05_add_address.spec.js b/e2e/paths/client-module/05_add_address.spec.js index 2bb2845ab..b3def12dd 100644 --- a/e2e/paths/client-module/05_add_address.spec.js +++ b/e2e/paths/client-module/05_add_address.spec.js @@ -4,6 +4,11 @@ import createNightmare from '../../helpers/helpers'; describe('Add address path', () => { const nightmare = createNightmare(); + beforeAll(() => { + return nightmare + .waitForLogin('developer'); + }); + it('should click on the Clients button of the top bar menu', () => { return nightmare .waitToClick(selectors.globalItems.applicationsMenuButton) diff --git a/e2e/paths/client-module/06_add_address_notes.spec.js b/e2e/paths/client-module/06_add_address_notes.spec.js index 8dafce475..85553d58f 100644 --- a/e2e/paths/client-module/06_add_address_notes.spec.js +++ b/e2e/paths/client-module/06_add_address_notes.spec.js @@ -4,6 +4,11 @@ import createNightmare from '../../helpers/helpers'; describe('Add address notes path', () => { const nightmare = createNightmare(); + beforeAll(() => { + return nightmare + .waitForLogin('developer'); + }); + it('should click on the Clients button of the top bar menu', () => { return nightmare .waitToClick(selectors.globalItems.applicationsMenuButton) diff --git a/e2e/paths/client-module/07_edit_web_access.spec.js b/e2e/paths/client-module/07_edit_web_access.spec.js index c5df454e3..c3da45c10 100644 --- a/e2e/paths/client-module/07_edit_web_access.spec.js +++ b/e2e/paths/client-module/07_edit_web_access.spec.js @@ -4,6 +4,11 @@ import createNightmare from '../../helpers/helpers'; describe('Edit web access path', () => { const nightmare = createNightmare(); + beforeAll(() => { + return nightmare + .waitForLogin('developer'); + }); + it('should click on the Clients button of the top bar menu', () => { return nightmare .waitToClick(selectors.globalItems.applicationsMenuButton) diff --git a/e2e/paths/client-module/08_add_notes.spec.js b/e2e/paths/client-module/08_add_notes.spec.js index 415aaf7cc..5193ee7d4 100644 --- a/e2e/paths/client-module/08_add_notes.spec.js +++ b/e2e/paths/client-module/08_add_notes.spec.js @@ -4,6 +4,11 @@ import createNightmare from '../../helpers/helpers'; describe('Add notes path', () => { const nightmare = createNightmare(); + beforeAll(() => { + return nightmare + .waitForLogin('developer'); + }); + it('should click on the Clients button of the top bar menu', () => { return nightmare .waitToClick(selectors.globalItems.applicationsMenuButton) diff --git a/e2e/paths/client-module/09_add_credit.spec.js b/e2e/paths/client-module/09_add_credit.spec.js index 2493476e1..ca0804fff 100644 --- a/e2e/paths/client-module/09_add_credit.spec.js +++ b/e2e/paths/client-module/09_add_credit.spec.js @@ -4,6 +4,11 @@ import createNightmare from '../../helpers/helpers'; describe('Add credit path', () => { const nightmare = createNightmare(); + beforeAll(() => { + return nightmare + .waitForLogin('developer'); + }); + it('should click on the Clients button of the top bar menu', () => { return nightmare .waitToClick(selectors.globalItems.applicationsMenuButton) diff --git a/e2e/paths/client-module/10_add_greuge.spec.js b/e2e/paths/client-module/10_add_greuge.spec.js index 7b8126e0c..7f2ad9f21 100644 --- a/e2e/paths/client-module/10_add_greuge.spec.js +++ b/e2e/paths/client-module/10_add_greuge.spec.js @@ -4,6 +4,11 @@ import createNightmare from '../../helpers/helpers'; describe('Add greuge path', () => { const nightmare = createNightmare(); + beforeAll(() => { + return nightmare + .waitForLogin('developer'); + }); + it('should click on the Clients button of the top bar menu', () => { return nightmare .waitToClick(selectors.globalItems.applicationsMenuButton) diff --git a/e2e/paths/client-module/11_mandate.spec.js b/e2e/paths/client-module/11_mandate.spec.js index f7a8dc7a9..9728afa02 100644 --- a/e2e/paths/client-module/11_mandate.spec.js +++ b/e2e/paths/client-module/11_mandate.spec.js @@ -4,6 +4,11 @@ import createNightmare from '../../helpers/helpers'; describe('mandate path', () => { const nightmare = createNightmare(); + beforeAll(() => { + return nightmare + .waitForLogin('developer'); + }); + it('should click on the Clients button of the top bar menu', () => { return nightmare .waitToClick(selectors.globalItems.applicationsMenuButton) diff --git a/e2e/paths/item-module/01_item_summary.spec.js b/e2e/paths/item-module/01_item_summary.spec.js index 2b87ab0c1..bed941560 100644 --- a/e2e/paths/item-module/01_item_summary.spec.js +++ b/e2e/paths/item-module/01_item_summary.spec.js @@ -4,6 +4,11 @@ import createNightmare from '../../helpers/helpers'; describe('Item summary path', () => { const nightmare = createNightmare(); + beforeAll(() => { + return nightmare + .waitForLogin('developer'); + }); + it('should access to the items index by clicking the items button', () => { return nightmare .click(selectors.moduleAccessView.itemsSectionButton) diff --git a/e2e/paths/item-module/02_edit_item_basic_data.spec.js b/e2e/paths/item-module/02_edit_item_basic_data.spec.js index d15745e73..9efefe870 100644 --- a/e2e/paths/item-module/02_edit_item_basic_data.spec.js +++ b/e2e/paths/item-module/02_edit_item_basic_data.spec.js @@ -4,6 +4,11 @@ import createNightmare from '../../helpers/helpers'; describe('edit item basic data path', () => { const nightmare = createNightmare(); + beforeAll(() => { + return nightmare + .waitForLogin('developer'); + }); + it('should access to the items index by clicking the items button', () => { return nightmare .click(selectors.moduleAccessView.itemsSectionButton) diff --git a/e2e/paths/item-module/03_edit_item_tax.spec.js b/e2e/paths/item-module/03_edit_item_tax.spec.js index db39aa089..a49380baf 100644 --- a/e2e/paths/item-module/03_edit_item_tax.spec.js +++ b/e2e/paths/item-module/03_edit_item_tax.spec.js @@ -4,6 +4,11 @@ import createNightmare from '../../helpers/helpers'; describe('add item tax path', () => { const nightmare = createNightmare(); + beforeAll(() => { + return nightmare + .waitForLogin('developer'); + }); + it('should access to the items index by clicking the items button', () => { return nightmare .click(selectors.moduleAccessView.itemsSectionButton) diff --git a/e2e/paths/item-module/04_create_item_tags.spec.js b/e2e/paths/item-module/04_create_item_tags.spec.js index 86b5f30b3..bafcdb812 100644 --- a/e2e/paths/item-module/04_create_item_tags.spec.js +++ b/e2e/paths/item-module/04_create_item_tags.spec.js @@ -4,6 +4,11 @@ import createNightmare from '../../helpers/helpers'; describe('create item tags path', () => { const nightmare = createNightmare(); + beforeAll(() => { + return nightmare + .waitForLogin('developer'); + }); + it('should access to the items index by clicking the items button', () => { return nightmare .click(selectors.moduleAccessView.itemsSectionButton) diff --git a/e2e/paths/item-module/05_create_item_niche.spec.js b/e2e/paths/item-module/05_create_item_niche.spec.js index 9f00aed61..60c9cd7cf 100644 --- a/e2e/paths/item-module/05_create_item_niche.spec.js +++ b/e2e/paths/item-module/05_create_item_niche.spec.js @@ -4,6 +4,11 @@ import createNightmare from '../../helpers/helpers'; describe('create item niche path', () => { const nightmare = createNightmare(); + beforeAll(() => { + return nightmare + .waitForLogin('developer'); + }); + it('should access to the items index by clicking the items button', () => { return nightmare .click(selectors.moduleAccessView.itemsSectionButton) diff --git a/e2e/paths/item-module/06_create_item_botanical.spec.js b/e2e/paths/item-module/06_create_item_botanical.spec.js index b8766aa80..a46219cef 100644 --- a/e2e/paths/item-module/06_create_item_botanical.spec.js +++ b/e2e/paths/item-module/06_create_item_botanical.spec.js @@ -4,6 +4,11 @@ import createNightmare from '../../helpers/helpers'; describe('create item botanical path', () => { const nightmare = createNightmare(); + beforeAll(() => { + return nightmare + .waitForLogin('developer'); + }); + it('should access to the items index by clicking the items button', () => { return nightmare .click(selectors.moduleAccessView.itemsSectionButton) diff --git a/e2e/paths/item-module/07_create_item_barcode.spec.js b/e2e/paths/item-module/07_create_item_barcode.spec.js index dcb5d059c..5e27e8067 100644 --- a/e2e/paths/item-module/07_create_item_barcode.spec.js +++ b/e2e/paths/item-module/07_create_item_barcode.spec.js @@ -4,6 +4,11 @@ import createNightmare from '../../helpers/helpers'; describe('create item barcodes path', () => { const nightmare = createNightmare(); + beforeAll(() => { + return nightmare + .waitForLogin('developer'); + }); + it('should access to the items index by clicking the items button', () => { return nightmare .click(selectors.moduleAccessView.itemsSectionButton) diff --git a/e2e/paths/item-module/08_item_create_and_clone.spec.js b/e2e/paths/item-module/08_item_create_and_clone.spec.js index 66c3d79b0..a4a54263a 100644 --- a/e2e/paths/item-module/08_item_create_and_clone.spec.js +++ b/e2e/paths/item-module/08_item_create_and_clone.spec.js @@ -3,6 +3,12 @@ import createNightmare from '../../helpers/helpers'; describe('Item', () => { const nightmare = createNightmare(); + + beforeAll(() => { + return nightmare + .waitForLogin('developer'); + }); + describe('create path', () => { it('should access to the items index by clicking the items button', () => { return nightmare