From 2bcfb0532e8dd3b7b4efc26ea39fc50d9eadc1a8 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez <=> Date: Fri, 23 Nov 2018 08:05:57 +0100 Subject: [PATCH] #781 Extensiones nightmare loginAndModule extenstion --- e2e/helpers/extensions.js | 27 +++++++++++- .../claim-module/01_edit_basic_data.spec.js | 13 +----- .../client-module/01_create_client.spec.js | 11 +---- .../client-module/02_edit_basic_data.spec.js | 26 +----------- .../client-module/03_edit_fiscal_data.spec.js | 13 +----- .../client-module/04_edit_pay_method.spec.js | 13 +----- .../client-module/05_add_address.spec.js | 13 +----- .../06_add_address_notes.spec.js | 13 +----- .../client-module/07_edit_web_access.spec.js | 13 +----- e2e/paths/client-module/08_add_notes.spec.js | 13 +----- e2e/paths/client-module/09_add_credit.spec.js | 13 +----- e2e/paths/client-module/10_add_greuge.spec.js | 13 +----- e2e/paths/client-module/11_mandate.spec.js | 13 +----- .../12_lock_of_verified_data.spec.js | 13 +----- e2e/paths/client-module/13_log.spec.js | 13 +----- e2e/paths/client-module/14_risk.spec.js | 13 +----- e2e/paths/item-module/01_item_summary.spec.js | 11 +---- .../02_edit_item_basic_data.spec.js | 11 +---- .../item-module/03_edit_item_tax.spec.js | 11 +---- .../item-module/04_create_item_tags.spec.js | 11 +---- .../item-module/05_create_item_niche.spec.js | 11 +---- .../06_create_item_botanical.spec.js | 11 +---- .../07_create_item_barcode.spec.js | 11 +---- .../08_item_create_and_clone.spec.js | 11 +---- .../item-module/09_regularize_item.spec.js | 11 +---- .../01_create_ticket_observations.spec.js | 11 +---- .../02_delete_ticket_expeditions.spec.js | 11 +---- e2e/paths/ticket-module/03_list_sale.spec.js | 13 +----- .../04_create_ticket_packages.spec.js | 13 +----- .../05_create_new_tracking_state.spec.js | 13 +----- .../06_edit_basic_data_steps.spec.js | 13 +----- e2e/paths/ticket-module/07_edit_sale.spec.js | 13 +----- .../ticket-module/08_list_components.spec.js | 13 +----- .../ticket-module/09_ticket_weekly.spec.js | 13 +----- .../ticket-module/10_ticket_request.spec.js | 13 +----- .../ticket-module/11_ticket_diary.spec.js | 13 +----- .../12_delete_ticket_from_descriptor.spec.js | 13 +----- e2e/smokes/01_client_path.spec.js | 42 +++++++------------ 38 files changed, 78 insertions(+), 448 deletions(-) diff --git a/e2e/helpers/extensions.js b/e2e/helpers/extensions.js index 8e79e657a..25bb4264c 100644 --- a/e2e/helpers/extensions.js +++ b/e2e/helpers/extensions.js @@ -1,5 +1,6 @@ /* eslint no-invalid-this: "off" */ +import selectors from './selectors.js'; import config from './config.js'; import Nightmare from 'nightmare'; import {URL} from 'url'; @@ -63,6 +64,20 @@ let actions = { .catch(done); }, + selectModule: function(moduleName, done) { + this.waitToClick(`body > vn-app > vn-vertical > vn-vertical > vn-home > div > div > a[ui-sref="${moduleName}.index"]`) + .waitForURL(moduleName) + .then(done) + .catch(done); + }, + + loginAndModule: function(userName, moduleName, done) { + this.waitForLogin(userName) + .selectModule(moduleName) + .then(done) + .catch(done); + }, + parsedUrl: function(done) { this.url() .then(url => { @@ -268,7 +283,17 @@ let actions = { .then(shapes => { done(null, shapes); }).catch(done); - } + }, + + // indexSearchToSection: function(searchValue, sectionName, done) { + // this.wait(`vn-${sectionName}-index vn-searchbar input`) + // .type(`vn-${sectionName}-index vn-searchbar input`, searchValue) + // .click(`vn-${sectionName}-index vn-searchbar vn-icon[icon="search"]`) + // .waitForNumberOfElements(`vn-${sectionName}-index > div > div > vn-card:nth-child(2) > div > vn-item-client > a`, 1) + // .countElement(selectors.clientsIndex.searchResult); + + // expect(resultCount).toEqual(1); + // } }; Object.keys(actions).forEach(function(name) { diff --git a/e2e/paths/claim-module/01_edit_basic_data.spec.js b/e2e/paths/claim-module/01_edit_basic_data.spec.js index 0b0b89e4c..734f2216d 100644 --- a/e2e/paths/claim-module/01_edit_basic_data.spec.js +++ b/e2e/paths/claim-module/01_edit_basic_data.spec.js @@ -6,18 +6,7 @@ describe('Claim edit basic data path', () => { beforeAll(() => { nightmare - .waitForLogin('salesAssistant'); - }); - - it('should click on the Claims button of the top bar menu', async () => { - const url = await nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.claimsButton) - .wait(selectors.claimsIndex.searchClaimInput) - .parsedUrl(); - - expect(url.hash).toEqual('#!/claim/index'); + .loginAndModule('salesAssistant', 'claim'); }); it('should search for the claim with id 1', async () => { diff --git a/e2e/paths/client-module/01_create_client.spec.js b/e2e/paths/client-module/01_create_client.spec.js index 544913b97..1348f47b6 100644 --- a/e2e/paths/client-module/01_create_client.spec.js +++ b/e2e/paths/client-module/01_create_client.spec.js @@ -6,16 +6,7 @@ describe('Client create path', () => { beforeAll(() => { nightmare - .waitForLogin('employee'); - }); - - it('should access to the clients index by clicking the clients button', async () => { - const url = await nightmare - .click(selectors.moduleAccessView.clientsSectionButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl(); - - expect(url.hash).toEqual('#!/client/index'); + .loginAndModule('employee', 'client'); }); it(`should search for the user Carol Danvers to confirm it isn't created yet`, async () => { 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 c82a07b2e..0af24ea41 100644 --- a/e2e/paths/client-module/02_edit_basic_data.spec.js +++ b/e2e/paths/client-module/02_edit_basic_data.spec.js @@ -6,18 +6,7 @@ describe('Client Edit basicData path', () => { describe('as employee', () => { beforeAll(() => { nightmare - .waitForLogin('employee'); - }); - - it('should click on the Clients button of the top bar menu', async () => { - const url = await nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.clientsButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl(); - - expect(url.hash).toEqual('#!/client/index'); + .loginAndModule('employee', 'client'); }); it('should search for the user Bruce Wayne', async () => { @@ -122,18 +111,7 @@ describe('Client Edit basicData path', () => { beforeAll(() => { nightmare .waitToClick(selectors.globalItems.logOutButton) - .waitForLogin('salesAssistant'); - }); - - it('should now click on the Clients button of the top bar menu', async () => { - const url = await nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.clientsButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl(); - - expect(url.hash).toEqual('#!/client/index'); + .loginAndModule('salesASsistant', 'client'); }); it('should now search for the user Ptonomy Wallace', async () => { 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 a615e4bd0..5f803a770 100644 --- a/e2e/paths/client-module/03_edit_fiscal_data.spec.js +++ b/e2e/paths/client-module/03_edit_fiscal_data.spec.js @@ -6,18 +6,7 @@ describe('Client Edit fiscalData path', () => { describe('as employee', () => { beforeAll(() => { nightmare - .waitForLogin('employee'); - }); - - it('should click on the Clients button of the top bar menu', async () => { - const url = await nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.clientsButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl(); - - expect(url.hash).toEqual('#!/client/index'); + .loginAndModule('employee', 'client'); }); it('should search for the user Bruce Banner', async () => { 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 6e9b8c246..5ac184c79 100644 --- a/e2e/paths/client-module/04_edit_pay_method.spec.js +++ b/e2e/paths/client-module/04_edit_pay_method.spec.js @@ -6,18 +6,7 @@ describe('Client Edit pay method path', () => { beforeAll(() => { nightmare - .waitForLogin('administrative'); - }); - - it('should click on the Clients button of the top bar menu', async () => { - const url = await nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.clientsButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl(); - - expect(url.hash).toEqual('#!/client/index'); + .loginAndModule('administrative', 'client'); }); it('should search for the user Bruce Banner', async () => { diff --git a/e2e/paths/client-module/05_add_address.spec.js b/e2e/paths/client-module/05_add_address.spec.js index 19e558085..e447aa256 100644 --- a/e2e/paths/client-module/05_add_address.spec.js +++ b/e2e/paths/client-module/05_add_address.spec.js @@ -6,18 +6,7 @@ describe('Client Add address path', () => { beforeAll(() => { nightmare - .waitForLogin('employee'); - }); - - it('should click on the Clients button of the top bar menu', async () => { - const url = await nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.clientsButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl(); - - expect(url.hash).toEqual('#!/client/index'); + .loginAndModule('employee', 'client'); }); it('should search for the user Bruce Banner', async () => { 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 ef58d48c5..47896ba50 100644 --- a/e2e/paths/client-module/06_add_address_notes.spec.js +++ b/e2e/paths/client-module/06_add_address_notes.spec.js @@ -6,18 +6,7 @@ describe('Client add address notes path', () => { beforeAll(() => { nightmare - .waitForLogin('employee'); - }); - - it('should click on the Clients button of the top bar menu', async () => { - const url = await nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.clientsButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl(); - - expect(url.hash).toEqual('#!/client/index'); + .loginAndModule('employee', 'client'); }); it('should search for the user Petter Parker', async () => { 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 40e61ba98..b427db7ae 100644 --- a/e2e/paths/client-module/07_edit_web_access.spec.js +++ b/e2e/paths/client-module/07_edit_web_access.spec.js @@ -6,18 +6,7 @@ describe('Client Edit web access path', () => { beforeAll(() => { nightmare - .waitForLogin('employee'); - }); - - it('should click on the Clients button of the top bar menu', async () => { - const url = await nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.clientsButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl(); - - expect(url.hash).toEqual('#!/client/index'); + .loginAndModule('employee', 'client'); }); it('should search for the user Bruce Banner', async () => { diff --git a/e2e/paths/client-module/08_add_notes.spec.js b/e2e/paths/client-module/08_add_notes.spec.js index 7d731da1d..3764f1bb6 100644 --- a/e2e/paths/client-module/08_add_notes.spec.js +++ b/e2e/paths/client-module/08_add_notes.spec.js @@ -6,18 +6,7 @@ describe('Client Add notes path', () => { beforeAll(() => { nightmare - .waitForLogin('employee'); - }); - - it('should click on the Clients button of the top bar menu', async ()=> { - const url = await nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.clientsButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl(); - - expect(url.hash).toEqual('#!/client/index'); + .loginAndModule('employee', 'client'); }); it('should search for the user Bruce Banner', async () => { diff --git a/e2e/paths/client-module/09_add_credit.spec.js b/e2e/paths/client-module/09_add_credit.spec.js index 16761926a..35c5b5c34 100644 --- a/e2e/paths/client-module/09_add_credit.spec.js +++ b/e2e/paths/client-module/09_add_credit.spec.js @@ -6,18 +6,7 @@ describe('Client Add credit path', () => { beforeAll(() => { nightmare - .waitForLogin('salesAssistant'); - }); - - it('should click on the Clients button of the top bar menu', async () => { - const url = await nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.clientsButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl(); - - expect(url.hash).toEqual('#!/client/index'); + .loginAndModule('salesAssistant', 'client'); }); it('should search for the user Hank Pym', async () => { diff --git a/e2e/paths/client-module/10_add_greuge.spec.js b/e2e/paths/client-module/10_add_greuge.spec.js index d61f5ead9..75c2d76b9 100644 --- a/e2e/paths/client-module/10_add_greuge.spec.js +++ b/e2e/paths/client-module/10_add_greuge.spec.js @@ -6,18 +6,7 @@ describe('Client Add greuge path', () => { beforeAll(() => { nightmare - .waitForLogin('salesAssistant'); - }); - - it('should click on the Clients button of the top bar menu', async () => { - const url = await nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.clientsButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl(); - - expect(url.hash).toEqual('#!/client/index'); + .loginAndModule('salesAssistant', 'client'); }); it('should search for the user Petter Parker', async () => { diff --git a/e2e/paths/client-module/11_mandate.spec.js b/e2e/paths/client-module/11_mandate.spec.js index a88fe525c..81467d8fa 100644 --- a/e2e/paths/client-module/11_mandate.spec.js +++ b/e2e/paths/client-module/11_mandate.spec.js @@ -6,18 +6,7 @@ describe('Client mandate path', () => { beforeAll(() => { nightmare - .waitForLogin('salesPerson'); - }); - - it('should click on the Clients button of the top bar menu', async () => { - const url = await nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.clientsButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl(); - - expect(url.hash).toEqual('#!/client/index'); + .loginAndModule('salesPerson', 'client'); }); it('should search for the user Petter Parker', async () => { diff --git a/e2e/paths/client-module/12_lock_of_verified_data.spec.js b/e2e/paths/client-module/12_lock_of_verified_data.spec.js index 822c4f619..5a6c7f03e 100644 --- a/e2e/paths/client-module/12_lock_of_verified_data.spec.js +++ b/e2e/paths/client-module/12_lock_of_verified_data.spec.js @@ -7,18 +7,7 @@ describe('Client lock verified data path', () => { describe('as salesPerson', () => { beforeAll(() => { nightmare - .waitForLogin('salesPerson'); - }); - - it('should click on the Clients button of the top bar menu', async () => { - const url = await nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.clientsButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl(); - - expect(url.hash).toEqual('#!/client/index'); + .loginAndModule('salesPerson', 'client'); }); it('should search for the user Petter Parker', async () => { diff --git a/e2e/paths/client-module/13_log.spec.js b/e2e/paths/client-module/13_log.spec.js index 616041da6..dc2c7fd25 100644 --- a/e2e/paths/client-module/13_log.spec.js +++ b/e2e/paths/client-module/13_log.spec.js @@ -6,18 +6,7 @@ describe('Client log path', () => { beforeAll(() => { nightmare - .waitForLogin('employee'); - }); - - it('should click on the Clients button of the top bar menu', async () => { - let url = await nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.clientsButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl(); - - expect(url.hash).toEqual('#!/client/index'); + .loginAndModule('employee', 'client'); }); it('should search for the user David Charles Haller', async () => { diff --git a/e2e/paths/client-module/14_risk.spec.js b/e2e/paths/client-module/14_risk.spec.js index 369dcd83a..c5302b6db 100644 --- a/e2e/paths/client-module/14_risk.spec.js +++ b/e2e/paths/client-module/14_risk.spec.js @@ -6,18 +6,7 @@ describe('Client risk path', () => { beforeAll(() => { nightmare - .waitForLogin('administrative'); - }); - - it('should click on the Clients button of the top bar menu', async () => { - let url = await nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.clientsButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl(); - - expect(url.hash).toEqual('#!/client/index'); + .loginAndModule('administrative', 'client'); }); it('should search for the user Petter Parker', async () => { diff --git a/e2e/paths/item-module/01_item_summary.spec.js b/e2e/paths/item-module/01_item_summary.spec.js index 1ba685efc..270087a04 100644 --- a/e2e/paths/item-module/01_item_summary.spec.js +++ b/e2e/paths/item-module/01_item_summary.spec.js @@ -6,16 +6,7 @@ describe('Item summary path', () => { beforeAll(() => { nightmare - .waitForLogin('employee'); - }); - - it('should access to the items index by clicking the items button', async () => { - const url = await nightmare - .click(selectors.moduleAccessView.itemsSectionButton) - .wait(selectors.itemsIndex.createItemButton) - .parsedUrl(); - - expect(url.hash).toEqual('#!/item/index'); + .loginAndModule('employee', 'item'); }); it('should search for the item Gem of Time', async () => { 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 f154109a1..a5c7e733d 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 @@ -6,16 +6,7 @@ describe('Item Edit basic data path', () => { beforeAll(() => { nightmare - .waitForLogin('buyer'); - }); - - it('should access to the items index by clicking the items button', async () => { - const url = await nightmare - .click(selectors.moduleAccessView.itemsSectionButton) - .wait(selectors.itemsIndex.createItemButton) - .parsedUrl(); - - expect(url.hash).toEqual('#!/item/index'); + .loginAndModule('buyer', 'item'); }); it('should search for the item Gem of Mind', async () => { 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 fa9d86053..efa22d7c8 100644 --- a/e2e/paths/item-module/03_edit_item_tax.spec.js +++ b/e2e/paths/item-module/03_edit_item_tax.spec.js @@ -6,16 +6,7 @@ describe('Item edit tax path', () => { beforeAll(() => { nightmare - .waitForLogin('buyer'); - }); - - it('should access to the items index by clicking the items button', async () => { - const url = await nightmare - .click(selectors.moduleAccessView.itemsSectionButton) - .wait(selectors.itemsIndex.createItemButton) - .parsedUrl(); - - expect(url.hash).toEqual('#!/item/index'); + .loginAndModule('buyer', 'item'); }); it('should search for the item Gem of Time', async () => { 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 e90a985ca..6cb89b406 100644 --- a/e2e/paths/item-module/04_create_item_tags.spec.js +++ b/e2e/paths/item-module/04_create_item_tags.spec.js @@ -6,16 +6,7 @@ describe('Item create tags path', () => { beforeAll(() => { nightmare - .waitForLogin('buyer'); - }); - - it('should access to the items index by clicking the items button', async () => { - const url = await nightmare - .click(selectors.moduleAccessView.itemsSectionButton) - .wait(selectors.itemsIndex.createItemButton) - .parsedUrl(); - - expect(url.hash).toEqual('#!/item/index'); + .loginAndModule('buyer', 'item'); }); it('should search for the item Gem of Time', async () => { 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 d743e973f..2a3cc014e 100644 --- a/e2e/paths/item-module/05_create_item_niche.spec.js +++ b/e2e/paths/item-module/05_create_item_niche.spec.js @@ -6,16 +6,7 @@ describe('Item create niche path', () => { beforeAll(() => { nightmare - .waitForLogin('buyer'); - }); - - it('should access to the items index by clicking the items button', async () => { - const url = await nightmare - .click(selectors.moduleAccessView.itemsSectionButton) - .wait(selectors.itemsIndex.createItemButton) - .parsedUrl(); - - expect(url.hash).toEqual('#!/item/index'); + .loginAndModule('buyer', 'item'); }); it('should search for the item Gem of Time', async () => { 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 288992a2a..2cee46534 100644 --- a/e2e/paths/item-module/06_create_item_botanical.spec.js +++ b/e2e/paths/item-module/06_create_item_botanical.spec.js @@ -6,16 +6,7 @@ describe('Item Create botanical path', () => { beforeAll(() => { nightmare - .waitForLogin('buyer'); - }); - - it('should access to the items index by clicking the items button', async () => { - const url = await nightmare - .click(selectors.moduleAccessView.itemsSectionButton) - .wait(selectors.itemsIndex.createItemButton) - .parsedUrl(); - - expect(url.hash).toEqual('#!/item/index'); + .loginAndModule('buyer', 'item'); }); it('should search for the item Mjolnir', async () => { 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 6416fbe87..7cda344cc 100644 --- a/e2e/paths/item-module/07_create_item_barcode.spec.js +++ b/e2e/paths/item-module/07_create_item_barcode.spec.js @@ -6,16 +6,7 @@ describe('Item Create barcodes path', () => { beforeAll(() => { nightmare - .waitForLogin('buyer'); - }); - - it('should access to the items index by clicking the items button', async () => { - const url = await nightmare - .click(selectors.moduleAccessView.itemsSectionButton) - .wait(selectors.itemsIndex.createItemButton) - .parsedUrl(); - - expect(url.hash).toEqual('#!/item/index'); + .loginAndModule('buyer', 'item'); }); it('should search for the item Gem of Time', async () => { 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 02a00e470..31a31b52e 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 @@ -6,16 +6,7 @@ describe('Item Create/Clone path', () => { describe('create', () => { beforeAll(() => { nightmare - .waitForLogin('buyer'); - }); - - it('should access to the items index by clicking the items button', async () => { - const url = await nightmare - .click(selectors.moduleAccessView.itemsSectionButton) - .wait(selectors.itemsIndex.createItemButton) - .parsedUrl(); - - expect(url.hash).toEqual('#!/item/index'); + .loginAndModule('buyer', 'item'); }); it(`should search for the item Infinity Gauntlet to confirm it isn't created yet`, async () => { diff --git a/e2e/paths/item-module/09_regularize_item.spec.js b/e2e/paths/item-module/09_regularize_item.spec.js index c21884483..933572495 100644 --- a/e2e/paths/item-module/09_regularize_item.spec.js +++ b/e2e/paths/item-module/09_regularize_item.spec.js @@ -5,16 +5,7 @@ describe('Item regularize path', () => { const nightmare = createNightmare(); beforeAll(() => { nightmare - .waitForLogin('developer'); - }); - - it('should access to the items index by clicking the items button', async () => { - const url = await nightmare - .click(selectors.moduleAccessView.itemsSectionButton) - .wait(selectors.itemsIndex.createItemButton) - .parsedUrl(); - - expect(url.hash).toEqual('#!/item/index'); + .loginAndModule('employee', 'item'); }); it('should search for the item Mjolnir', async () => { diff --git a/e2e/paths/ticket-module/01_create_ticket_observations.spec.js b/e2e/paths/ticket-module/01_create_ticket_observations.spec.js index 50d2794a7..e12de99cd 100644 --- a/e2e/paths/ticket-module/01_create_ticket_observations.spec.js +++ b/e2e/paths/ticket-module/01_create_ticket_observations.spec.js @@ -7,16 +7,7 @@ describe('Ticket', () => { beforeAll(() => { return nightmare - .waitForLogin('employee'); - }); - - it('should access to the tickets index by clicking the tickets button', async () => { - let url = await nightmare - .click(selectors.moduleAccessView.ticketsSectionButton) - .wait(selectors.ticketsIndex.searchTicketInput) - .parsedUrl(); - - expect(url.hash).toEqual('#!/ticket/index'); + .loginAndModule('employee', 'ticket'); }); it('should search for the ticket with id 1', async () => { diff --git a/e2e/paths/ticket-module/02_delete_ticket_expeditions.spec.js b/e2e/paths/ticket-module/02_delete_ticket_expeditions.spec.js index ffd71aeee..8a66d130d 100644 --- a/e2e/paths/ticket-module/02_delete_ticket_expeditions.spec.js +++ b/e2e/paths/ticket-module/02_delete_ticket_expeditions.spec.js @@ -7,16 +7,7 @@ describe('Ticket', () => { beforeAll(() => { return nightmare - .waitForLogin('production'); - }); - - it('should access to the tickets index by clicking the tickets button', async () => { - const url = await nightmare - .click(selectors.moduleAccessView.ticketsSectionButton) - .wait(selectors.ticketsIndex.searchTicketInput) - .parsedUrl(); - - expect(url.hash).toEqual('#!/ticket/index'); + .loginAndModule('production', 'ticket'); }); it('should search for the ticket with id 1', async () => { diff --git a/e2e/paths/ticket-module/03_list_sale.spec.js b/e2e/paths/ticket-module/03_list_sale.spec.js index f6fd79869..d2cfe9f33 100644 --- a/e2e/paths/ticket-module/03_list_sale.spec.js +++ b/e2e/paths/ticket-module/03_list_sale.spec.js @@ -6,18 +6,7 @@ describe('Ticket List sale path', () => { beforeAll(() => { return nightmare - .waitForLogin('employee'); - }); - - it('should click on the Tickets button of the top bar menu', async () => { - const url = await nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.ticketsButton) - .wait(selectors.ticketsIndex.searchTicketInput) - .parsedUrl(); - - expect(url.hash).toEqual('#!/ticket/index'); + .loginAndModule('employee', 'ticket'); }); it('should search for the ticket 8', async () => { diff --git a/e2e/paths/ticket-module/04_create_ticket_packages.spec.js b/e2e/paths/ticket-module/04_create_ticket_packages.spec.js index f944d08b4..500a91750 100644 --- a/e2e/paths/ticket-module/04_create_ticket_packages.spec.js +++ b/e2e/paths/ticket-module/04_create_ticket_packages.spec.js @@ -6,18 +6,7 @@ describe('Ticket Create packages path', () => { beforeAll(() => { return nightmare - .waitForLogin('employee'); - }); - - it('should click on the Tickets button of the top bar menu', async () => { - const url = await nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.ticketsButton) - .wait(selectors.ticketsIndex.searchTicketInput) - .parsedUrl(); - - expect(url.hash).toEqual('#!/ticket/index'); + .loginAndModule('employee', 'ticket'); }); it('should search for the ticket 1', async () => { diff --git a/e2e/paths/ticket-module/05_create_new_tracking_state.spec.js b/e2e/paths/ticket-module/05_create_new_tracking_state.spec.js index fe15c389b..747668def 100644 --- a/e2e/paths/ticket-module/05_create_new_tracking_state.spec.js +++ b/e2e/paths/ticket-module/05_create_new_tracking_state.spec.js @@ -7,18 +7,7 @@ describe('Ticket', () => { beforeAll(() => { return nightmare - .waitForLogin('production'); - }); - - it('should click on the Tickets button of the top bar menu', async () => { - let url = await nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.ticketsButton) - .wait(selectors.ticketsIndex.searchTicketInput) - .parsedUrl(); - - expect(url.hash).toEqual('#!/ticket/index'); + .loginAndModule('production', 'ticket'); }); it('should search for the ticket 1', async () => { diff --git a/e2e/paths/ticket-module/06_edit_basic_data_steps.spec.js b/e2e/paths/ticket-module/06_edit_basic_data_steps.spec.js index 2b0c875c5..5829183c7 100644 --- a/e2e/paths/ticket-module/06_edit_basic_data_steps.spec.js +++ b/e2e/paths/ticket-module/06_edit_basic_data_steps.spec.js @@ -6,18 +6,7 @@ describe('Ticket Edit basic data path', () => { beforeAll(() => { return nightmare - .waitForLogin('employee'); - }); - - it('should click on the Tickets button of the top bar menu', async () => { - let url = await nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.ticketsButton) - .wait(selectors.ticketsIndex.searchTicketInput) - .parsedUrl(); - - expect(url.hash).toEqual('#!/ticket/index'); + .loginAndModule('employee', 'ticket'); }); it('should search for the ticket 11', async () => { diff --git a/e2e/paths/ticket-module/07_edit_sale.spec.js b/e2e/paths/ticket-module/07_edit_sale.spec.js index f568f5911..e3c21a0a3 100644 --- a/e2e/paths/ticket-module/07_edit_sale.spec.js +++ b/e2e/paths/ticket-module/07_edit_sale.spec.js @@ -6,18 +6,7 @@ describe('Ticket Edit sale path', () => { beforeAll(() => { nightmare - .waitForLogin('salesPerson'); - }); - - it('should click on the Tickets button of the top bar menu', async () => { - const url = await nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.ticketsButton) - .wait(selectors.ticketsIndex.searchTicketInput) - .parsedUrl(); - - expect(url.hash).toEqual('#!/ticket/index'); + .loginAndModule('salesPerson', 'ticket'); }); it('should search for a specific ticket', async () => { diff --git a/e2e/paths/ticket-module/08_list_components.spec.js b/e2e/paths/ticket-module/08_list_components.spec.js index 8bf89f0a9..04df126c8 100644 --- a/e2e/paths/ticket-module/08_list_components.spec.js +++ b/e2e/paths/ticket-module/08_list_components.spec.js @@ -6,18 +6,7 @@ describe('Ticket List components path', () => { beforeAll(() => { return nightmare - .waitForLogin('employee'); - }); - - it('should click on the Tickets button of the top bar menu', async () => { - const url = await nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.ticketsButton) - .wait(selectors.ticketsIndex.searchTicketInput) - .parsedUrl(); - - expect(url.hash).toEqual('#!/ticket/index'); + .loginAndModule('employee', 'ticket'); }); it('should search for the ticket 1', async () => { diff --git a/e2e/paths/ticket-module/09_ticket_weekly.spec.js b/e2e/paths/ticket-module/09_ticket_weekly.spec.js index d2624c833..dcce91333 100644 --- a/e2e/paths/ticket-module/09_ticket_weekly.spec.js +++ b/e2e/paths/ticket-module/09_ticket_weekly.spec.js @@ -6,18 +6,7 @@ describe('Ticket descriptor path', () => { beforeAll(() => { nightmare - .waitForLogin('employee'); - }); - - it('should click on the Tickets button of the top bar menu', async () => { - const url = await nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.ticketsButton) - .wait(selectors.ticketsIndex.searchTicketInput) - .parsedUrl(); - - expect(url.hash).toEqual('#!/ticket/index'); + .loginAndModule('employee', 'ticket'); }); it('should count the mount of tickets in the turns section', async () => { diff --git a/e2e/paths/ticket-module/10_ticket_request.spec.js b/e2e/paths/ticket-module/10_ticket_request.spec.js index 8891eb9d9..e269e03e8 100644 --- a/e2e/paths/ticket-module/10_ticket_request.spec.js +++ b/e2e/paths/ticket-module/10_ticket_request.spec.js @@ -6,18 +6,7 @@ describe('Ticket purchase request path', () => { beforeAll(() => { nightmare - .waitForLogin('salesPerson'); - }); - - it('should click on the Tickets button of the top bar menu', async () => { - const url = await nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.ticketsButton) - .wait(selectors.ticketsIndex.searchTicketInput) - .parsedUrl(); - - expect(url.hash).toEqual('#!/ticket/index'); + .loginAndModule('salesPerson', 'ticket'); }); it('should search for a specific ticket', async () => { diff --git a/e2e/paths/ticket-module/11_ticket_diary.spec.js b/e2e/paths/ticket-module/11_ticket_diary.spec.js index f37eb1954..3f7edf1cc 100644 --- a/e2e/paths/ticket-module/11_ticket_diary.spec.js +++ b/e2e/paths/ticket-module/11_ticket_diary.spec.js @@ -7,18 +7,7 @@ describe('Ticket diary path', () => { beforeAll(() => { nightmare - .waitForLogin('employee'); - }); - - it('should click on the Tickets button of the top bar menu', async () => { - const url = await nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.ticketsButton) - .wait(selectors.ticketsIndex.searchTicketInput) - .parsedUrl(); - - expect(url.hash).toEqual('#!/ticket/index'); + .loginAndModule('employee', 'ticket'); }); it('should search for a specific ticket', async () => { diff --git a/e2e/paths/ticket-module/12_delete_ticket_from_descriptor.spec.js b/e2e/paths/ticket-module/12_delete_ticket_from_descriptor.spec.js index 8be68a07e..2a7c6df15 100644 --- a/e2e/paths/ticket-module/12_delete_ticket_from_descriptor.spec.js +++ b/e2e/paths/ticket-module/12_delete_ticket_from_descriptor.spec.js @@ -6,18 +6,7 @@ describe('Ticket descriptor path', () => { beforeAll(() => { nightmare - .waitForLogin('employee'); - }); - - it('should click on the Tickets button of the top bar menu', async () => { - const url = await nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.ticketsButton) - .wait(selectors.ticketsIndex.searchTicketInput) - .parsedUrl(); - - expect(url.hash).toEqual('#!/ticket/index'); + .loginAndModule('employee', 'ticket'); }); it('should search for a specific ticket', async () => { diff --git a/e2e/smokes/01_client_path.spec.js b/e2e/smokes/01_client_path.spec.js index c52c8980b..b83b6d423 100644 --- a/e2e/smokes/01_client_path.spec.js +++ b/e2e/smokes/01_client_path.spec.js @@ -6,37 +6,25 @@ describe('create client path', () => { beforeAll(() => { return nightmare - .waitForLogin('employee'); + .loginAndModule('employee', 'client'); }); - it('should access to the clients index by clicking the clients button', () => { - return nightmare - .click(selectors.moduleAccessView.clientsSectionButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl() - .then(url => { - expect(url.hash).toEqual('#!/client/index'); - }); + it('should access to the create client view by clicking the create-client floating button', async () => { + let url = await nightmare + .click(selectors.clientsIndex.createClientButton) + .wait(selectors.createClientView.createButton) + .parsedUrl(); + + expect(url.hash).toEqual('#!/client/create'); }); - it('should access to the create client view by clicking the create-client floating button', () => { - return nightmare - .click(selectors.clientsIndex.createClientButton) - .wait(selectors.createClientView.createButton) - .parsedUrl() - .then(url => { - expect(url.hash).toEqual('#!/client/create'); - }); - }); + it('should cancel the client creation to go back to clients index', async () => { + let url = await nightmare + .waitToClick(selectors.globalItems.applicationsMenuButton) + .waitToClick(selectors.globalItems.clientsButton) + .wait(selectors.clientsIndex.createClientButton) + .parsedUrl(); - it('should cancel the client creation to go back to clients index', () => { - return nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .waitToClick(selectors.globalItems.clientsButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl() - .then(url => { - expect(url.hash).toEqual('#!/client/index'); - }); + expect(url.hash).toEqual('#!/client/index'); }); });