From 1e601ab6b6f3202340d8f297beaeac242f755b4b Mon Sep 17 00:00:00 2001 From: Carlos Jimenez <=> Date: Tue, 20 Feb 2018 22:35:54 +0100 Subject: [PATCH] e2e path for niches completed plus extension name corrected --- e2e/helpers/extensions.js | 2 +- e2e/helpers/selectors.js | 11 ++- .../client-module/01_create_client.spec.js | 6 +- .../client-module/02_edit_basic_data.spec.js | 2 +- .../client-module/03_edit_fiscal_data.spec.js | 2 +- .../client-module/04_edit_pay_method.spec.js | 2 +- .../client-module/05_add_address.spec.js | 2 +- .../06_add_address_notes.spec.js | 2 +- .../client-module/07_edit_web_access.spec.js | 2 +- e2e/paths/client-module/08_add_notes.spec.js | 2 +- e2e/paths/client-module/09_add_credit.spec.js | 2 +- e2e/paths/client-module/10_add_greuge.spec.js | 2 +- e2e/paths/client-module/11_mandate.spec.js | 2 +- .../item-module/04_create_item_niche.spec.js | 70 +++++++++++++++++++ .../06_create_item_barcode.spec.js | 2 +- 15 files changed, 94 insertions(+), 17 deletions(-) create mode 100644 e2e/paths/item-module/04_create_item_niche.spec.js diff --git a/e2e/helpers/extensions.js b/e2e/helpers/extensions.js index 218984411..5af02780c 100644 --- a/e2e/helpers/extensions.js +++ b/e2e/helpers/extensions.js @@ -37,7 +37,7 @@ Nightmare.action('waitForLogin', function(done) { .then(done); }); -Nightmare.action('urlParsed', function(done) { +Nightmare.action('parsedUrl', function(done) { this.url() .then(url => { done(null, new URL(url)); diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 59122d1dd..0c3b89808 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -151,8 +151,15 @@ export default { }, itemNiches: { nicheButton: `${components.vnMenuItem}[ui-sref="item.card.niche"]`, + addNicheButton: `${components.vnIcon}[icon="add_circle"]`, firstWarehouseSelect: `${components.vnAutocomplete}[field="niche.warehouseFk"] > vn-vertical > ${components.vnTextfield}`, - firstWarehouseSelectFirstOption: `${components.vnAutocomplete}[field="niche.warehouseFk"] > vn-vertical > vn-drop-down > vn-vertical:not(.ng-hide) > vn-auto:nth-child(2) > ul > li:nth-child(1)`, - secondNicheRemoveButton: `vn-horizontal:nth-child(2) > vn-one > ${components.vnIcon}[icon="remove_circle_outline"]` + firstWarehouseSelectSecondOption: `${components.vnAutocomplete}[field="niche.warehouseFk"] > vn-vertical > vn-drop-down > vn-vertical:not(.ng-hide) > vn-auto:nth-child(2) > ul > li:nth-child(2)`, + thirdWarehouseSelect: `vn-horizontal:nth-child(4) > ${components.vnAutocomplete}[field="niche.warehouseFk"] > vn-vertical > ${components.vnTextfield}`, + thirdWarehouseSelectFourthOption: `vn-horizontal:nth-child(4) > ${components.vnAutocomplete}[field="niche.warehouseFk"] > vn-vertical > vn-drop-down > vn-vertical:not(.ng-hide) > vn-auto:nth-child(2) > ul > li:nth-child(4)`, + secondNicheRemoveButton: `vn-horizontal:nth-child(3) > vn-one > ${components.vnIcon}[icon="remove_circle_outline"]`, + firstCodeInput: `vn-horizontal:nth-child(2) > ${components.vnTextfield}`, + thirdCodeInput: `vn-horizontal:nth-child(4) > ${components.vnTextfield}`, + submitNichesButton: `${components.vnSubmit}` } }; + diff --git a/e2e/paths/client-module/01_create_client.spec.js b/e2e/paths/client-module/01_create_client.spec.js index 78a521ece..d12ca1b15 100644 --- a/e2e/paths/client-module/01_create_client.spec.js +++ b/e2e/paths/client-module/01_create_client.spec.js @@ -8,7 +8,7 @@ describe('create client path', () => { return nightmare .click(selectors.moduleAccessView.clientsSectionButton) .wait(selectors.clientsIndex.createClientButton) - .urlParsed() + .parsedUrl() .then(url => { expect(url.hash).toEqual('#!/clients'); }); @@ -30,7 +30,7 @@ describe('create client path', () => { return nightmare .click(selectors.clientsIndex.createClientButton) .wait(selectors.createClientView.createButton) - .urlParsed() + .parsedUrl() .then(url => { expect(url.hash).toEqual('#!/create'); }); @@ -144,7 +144,7 @@ describe('create client path', () => { .wait(selectors.globalItems.applicationsMenuVisible) .waitToClick(selectors.globalItems.clientsButton) .wait(selectors.clientsIndex.createClientButton) - .urlParsed() + .parsedUrl() .then(url => { expect(url.hash).toEqual('#!/clients'); }); 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 82bef943a..c8b186347 100644 --- a/e2e/paths/client-module/02_edit_basic_data.spec.js +++ b/e2e/paths/client-module/02_edit_basic_data.spec.js @@ -10,7 +10,7 @@ describe('Edit basicData path', () => { .wait(selectors.globalItems.applicationsMenuVisible) .waitToClick(selectors.globalItems.clientsButton) .wait(selectors.clientsIndex.createClientButton) - .urlParsed() + .parsedUrl() .then(url => { expect(url.hash).toEqual('#!/clients'); }); 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 47907a9ca..64c09a34a 100644 --- a/e2e/paths/client-module/03_edit_fiscal_data.spec.js +++ b/e2e/paths/client-module/03_edit_fiscal_data.spec.js @@ -10,7 +10,7 @@ describe('Edit fiscalData path', () => { .wait(selectors.globalItems.applicationsMenuVisible) .waitToClick(selectors.globalItems.clientsButton) .wait(selectors.clientsIndex.createClientButton) - .urlParsed() + .parsedUrl() .then(url => { expect(url.hash).toEqual('#!/clients'); }); 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 888050ed1..bff96b73b 100644 --- a/e2e/paths/client-module/04_edit_pay_method.spec.js +++ b/e2e/paths/client-module/04_edit_pay_method.spec.js @@ -10,7 +10,7 @@ describe('Edit pay method path', () => { .wait(selectors.globalItems.applicationsMenuVisible) .waitToClick(selectors.globalItems.clientsButton) .wait(selectors.clientsIndex.createClientButton) - .urlParsed() + .parsedUrl() .then(url => { expect(url.hash).toEqual('#!/clients'); }); diff --git a/e2e/paths/client-module/05_add_address.spec.js b/e2e/paths/client-module/05_add_address.spec.js index 02992d12b..efec6cd32 100644 --- a/e2e/paths/client-module/05_add_address.spec.js +++ b/e2e/paths/client-module/05_add_address.spec.js @@ -10,7 +10,7 @@ describe('Add address path', () => { .wait(selectors.globalItems.applicationsMenuVisible) .waitToClick(selectors.globalItems.clientsButton) .wait(selectors.clientsIndex.createClientButton) - .urlParsed() + .parsedUrl() .then(url => { expect(url.hash).toEqual('#!/clients'); }); 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 0fe8a8213..55760a4db 100644 --- a/e2e/paths/client-module/06_add_address_notes.spec.js +++ b/e2e/paths/client-module/06_add_address_notes.spec.js @@ -10,7 +10,7 @@ describe('Add address notes path', () => { .wait(selectors.globalItems.applicationsMenuVisible) .waitToClick(selectors.globalItems.clientsButton) .wait(selectors.clientsIndex.createClientButton) - .urlParsed() + .parsedUrl() .then(url => { expect(url.hash).toEqual('#!/clients'); }); 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 2457513e0..c5df454e3 100644 --- a/e2e/paths/client-module/07_edit_web_access.spec.js +++ b/e2e/paths/client-module/07_edit_web_access.spec.js @@ -10,7 +10,7 @@ describe('Edit web access path', () => { .wait(selectors.globalItems.applicationsMenuVisible) .waitToClick(selectors.globalItems.clientsButton) .wait(selectors.clientsIndex.createClientButton) - .urlParsed() + .parsedUrl() .then(url => { expect(url.hash).toEqual('#!/clients'); }); diff --git a/e2e/paths/client-module/08_add_notes.spec.js b/e2e/paths/client-module/08_add_notes.spec.js index ca07ec054..415aaf7cc 100644 --- a/e2e/paths/client-module/08_add_notes.spec.js +++ b/e2e/paths/client-module/08_add_notes.spec.js @@ -10,7 +10,7 @@ describe('Add notes path', () => { .wait(selectors.globalItems.applicationsMenuVisible) .waitToClick(selectors.globalItems.clientsButton) .wait(selectors.clientsIndex.createClientButton) - .urlParsed() + .parsedUrl() .then(url => { expect(url.hash).toEqual('#!/clients'); }); diff --git a/e2e/paths/client-module/09_add_credit.spec.js b/e2e/paths/client-module/09_add_credit.spec.js index 206adc0d4..2493476e1 100644 --- a/e2e/paths/client-module/09_add_credit.spec.js +++ b/e2e/paths/client-module/09_add_credit.spec.js @@ -10,7 +10,7 @@ describe('Add credit path', () => { .wait(selectors.globalItems.applicationsMenuVisible) .waitToClick(selectors.globalItems.clientsButton) .wait(selectors.clientsIndex.createClientButton) - .urlParsed() + .parsedUrl() .then(url => { expect(url.hash).toEqual('#!/clients'); }); diff --git a/e2e/paths/client-module/10_add_greuge.spec.js b/e2e/paths/client-module/10_add_greuge.spec.js index adf081ea2..7b8126e0c 100644 --- a/e2e/paths/client-module/10_add_greuge.spec.js +++ b/e2e/paths/client-module/10_add_greuge.spec.js @@ -10,7 +10,7 @@ describe('Add greuge path', () => { .wait(selectors.globalItems.applicationsMenuVisible) .waitToClick(selectors.globalItems.clientsButton) .wait(selectors.clientsIndex.createClientButton) - .urlParsed() + .parsedUrl() .then(url => { expect(url.hash).toEqual('#!/clients'); }); diff --git a/e2e/paths/client-module/11_mandate.spec.js b/e2e/paths/client-module/11_mandate.spec.js index 570f696b1..f7a8dc7a9 100644 --- a/e2e/paths/client-module/11_mandate.spec.js +++ b/e2e/paths/client-module/11_mandate.spec.js @@ -10,7 +10,7 @@ describe('mandate path', () => { .wait(selectors.globalItems.applicationsMenuVisible) .waitToClick(selectors.globalItems.clientsButton) .wait(selectors.clientsIndex.createClientButton) - .urlParsed() + .parsedUrl() .then(url => { expect(url.hash).toEqual('#!/clients'); }); diff --git a/e2e/paths/item-module/04_create_item_niche.spec.js b/e2e/paths/item-module/04_create_item_niche.spec.js new file mode 100644 index 000000000..9f00aed61 --- /dev/null +++ b/e2e/paths/item-module/04_create_item_niche.spec.js @@ -0,0 +1,70 @@ +import selectors from '../../helpers/selectors.js'; +import createNightmare from '../../helpers/helpers'; + +describe('create item niche path', () => { + const nightmare = createNightmare(); + + it('should access to the items index by clicking the items button', () => { + return nightmare + .click(selectors.moduleAccessView.itemsSectionButton) + .wait(selectors.itemsIndex.createItemButton) + .parsedUrl() + .then(url => { + expect(url.hash).toEqual('#!/item/list'); + }); + }); + + it('should search for the item Gem of Time', () => { + return nightmare + .wait(selectors.itemsIndex.searchResult) + .type(selectors.itemsIndex.searchItemInput, 'Gem of Time') + .click(selectors.itemsIndex.searchButton) + .waitForNumberOfElements(selectors.itemsIndex.searchResult, 1) + .countSearchResults(selectors.itemsIndex.searchResult) + .then(result => { + expect(result).toEqual(1); + }); + }); + + it(`should click on the search result to access to the item niches`, () => { + return nightmare + .waitForTextInElement(selectors.itemsIndex.searchResult, 'Gem of Time') + .waitToClick(selectors.itemsIndex.searchResult) + .waitToClick(selectors.itemNiches.nicheButton) + .waitForURL('niche') + .url() + .then(url => { + expect(url).toContain('niche'); + }); + }); + + it(`should click create a new niche, edit another and delete a former one`, () => { + return nightmare + .waitToClick(selectors.itemNiches.addNicheButton) + .waitToClick(selectors.itemNiches.firstWarehouseSelect) + .waitToClick(selectors.itemNiches.firstWarehouseSelectSecondOption) + .clearInput(selectors.itemNiches.firstCodeInput) + .type(selectors.itemNiches.firstCodeInput, 'New Location') + .waitToClick(selectors.itemNiches.secondNicheRemoveButton) + .waitToClick(selectors.itemNiches.thirdWarehouseSelect) + .waitToClick(selectors.itemNiches.thirdWarehouseSelectFourthOption) + .type(selectors.itemNiches.thirdCodeInput, 'a code') + .click(selectors.itemNiches.submitNichesButton) + .waitForSnackbar() + .then(result => { + expect(result).toContain('Data saved!'); + }); + }); + + it(`should confirm the remaining niches are for the second third and fourth warehouses`, () => { + return nightmare + .click(selectors.itemBasicData.basicDataButton) + .wait(selectors.itemBasicData.nameInput) + .click(selectors.itemNiches.nicheButton) + .wait(200) + .getInputValue(selectors.itemNiches.thirdCodeInput) + .then(result => { + expect(result).toEqual('a code'); + }); + }); +}); diff --git a/e2e/paths/item-module/06_create_item_barcode.spec.js b/e2e/paths/item-module/06_create_item_barcode.spec.js index c72b52956..6767d9133 100644 --- a/e2e/paths/item-module/06_create_item_barcode.spec.js +++ b/e2e/paths/item-module/06_create_item_barcode.spec.js @@ -8,7 +8,7 @@ describe('create item barcodes path', () => { return nightmare .click(selectors.moduleAccessView.itemsSectionButton) .wait(selectors.itemsIndex.createItemButton) - .urlParsed() + .parsedUrl() .then(url => { expect(url.hash).toEqual('#!/item/list'); });