From c2017f85e831d0f7ebc713d872ba1102f4b7ab7c Mon Sep 17 00:00:00 2001 From: Carlos Jimenez <=> Date: Mon, 5 Mar 2018 12:26:00 +0100 Subject: [PATCH] part of the task #145 refactoring e2e paths --- e2e/helpers/selectors.js | 2 + .../client-module/05_add_address.spec.js | 85 +------------------ .../client-module/07_edit_web_access.spec.js | 32 ++----- e2e/paths/client-module/10_add_greuge.spec.js | 32 ------- .../12_lock_of_verified_data.spec.js | 2 +- e2e/paths/client-module/13_invoices.spec.js | 3 +- .../item-module/05_create_item_niche.spec.js | 41 +++++++-- .../06_create_item_botanical.spec.js | 18 ++-- 8 files changed, 56 insertions(+), 159 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index f2bf32ba7..c723c764b 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -234,10 +234,12 @@ export default { addNicheButton: `${components.vnIcon}[icon="add_circle"]`, firstWarehouseSelect: `${components.vnAutocomplete}[field="itemNiche.warehouseFk"] > vn-vertical > ${components.vnTextfield}`, firstWarehouseSelectSecondOption: `${components.vnAutocomplete}[field="itemNiche.warehouseFk"] > vn-vertical > vn-drop-down > vn-vertical:not(.ng-hide) > vn-auto:nth-child(2) > ul > li:nth-child(2)`, + secondWarehouseSelect: `vn-horizontal:nth-child(3) > ${components.vnAutocomplete}[field="itemNiche.warehouseFk"] > vn-vertical > ${components.vnTextfield}`, thirdWarehouseSelect: `vn-horizontal:nth-child(4) > ${components.vnAutocomplete}[field="itemNiche.warehouseFk"] > vn-vertical > ${components.vnTextfield}`, thirdWarehouseSelectFourthOption: `vn-horizontal:nth-child(4) > ${components.vnAutocomplete}[field="itemNiche.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}`, + secondCodeInput: `vn-horizontal:nth-child(3) > ${components.vnTextfield}`, thirdCodeInput: `vn-horizontal:nth-child(4) > ${components.vnTextfield}`, submitNichesButton: `${components.vnSubmit}` }, diff --git a/e2e/paths/client-module/05_add_address.spec.js b/e2e/paths/client-module/05_add_address.spec.js index b3def12dd..97117bf8c 100644 --- a/e2e/paths/client-module/05_add_address.spec.js +++ b/e2e/paths/client-module/05_add_address.spec.js @@ -55,97 +55,18 @@ describe('Add address path', () => { }); }); - it('should check the default checkbox then receive an error after clicking save button as the form is empty', () => { + it('should receive an error after clicking save button as consignee, street and town fields are empty', () => { return nightmare .waitToClick(selectors.clientAddresses.defaultCheckboxInput) - .waitToClick(selectors.clientFiscalData.saveButton) - .waitForSnackbar() - .then(result => { - expect(result).toContain('Some fields are invalid'); - }); - }); - - it('should receive an error when clicking the save button having all the form fields empty but consignee', () => { - return nightmare - .type(selectors.clientAddresses.consigneeInput, 'Bruce Bunner') - .click(selectors.createClientView.createButton) - .waitForSnackbar() - .then(result => { - expect(result).toContain('Some fields are invalid'); - }); - }); - - it('should receive an error when clicking the save button having all the form fields empty but Street', () => { - return nightmare - .clearInput(selectors.clientAddresses.consigneeInput) - .type(selectors.clientAddresses.streetAddressInput, '320 Park Avenue New York') - .click(selectors.createClientView.createButton) - .waitForSnackbar() - .then(result => { - expect(result).toContain('Some fields are invalid'); - }); - }); - - it('should receive an error when clicking the save button having all the form fields empty but postcode', () => { - return nightmare .clearInput(selectors.clientAddresses.streetAddressInput) .type(selectors.clientAddresses.postcodeInput, '10022') - .click(selectors.createClientView.createButton) - .waitForSnackbar() - .then(result => { - expect(result).toContain('Some fields are invalid'); - }); - }); - - it('should receive an error when clicking the save button having all the form fields empty but city', () => { - return nightmare - .clearInput(selectors.clientAddresses.postcodeInput) - .type(selectors.clientAddresses.cityInput, 'New York') - .click(selectors.createClientView.createButton) - .waitForSnackbar() - .then(result => { - expect(result).toContain('Some fields are invalid'); - }); - }); - - it('should receive an error when clicking the save button having all the form fields empty but province', () => { - return nightmare - .clearInput(selectors.clientAddresses.cityInput) .waitToClick(selectors.clientAddresses.provinceInput) .waitToClick(selectors.clientAddresses.provinceSecondOption) - .click(selectors.createClientView.createButton) - .waitForSnackbar() - .then(result => { - expect(result).toContain('Some fields are invalid'); - }); - }); - - it('should receive an error when clicking the save button having all the form fields empty but province and agency', () => { - return nightmare .waitToClick(selectors.clientAddresses.agencyInput) .waitToClick(selectors.clientAddresses.agenctySecondOption) - .click(selectors.createClientView.createButton) - .waitForSnackbar() - .then(result => { - expect(result).toContain('Some fields are invalid'); - }); - }); - - it('should receive an error when clicking the save button having all the form fields empty but province, agency and phone', () => { - return nightmare .type(selectors.clientAddresses.phoneInput, '999887744') - .click(selectors.createClientView.createButton) - .waitForSnackbar() - .then(result => { - expect(result).toContain('Some fields are invalid'); - }); - }); - - it('should receive an error when clicking the save button having all the form fields empty but province, agency and mobile', () => { - return nightmare - .clearInput(selectors.clientAddresses.phoneInput) .type(selectors.clientAddresses.mobileInput, '999887744') - .click(selectors.createClientView.createButton) + .waitToClick(selectors.clientFiscalData.saveButton) .waitForSnackbar() .then(result => { expect(result).toContain('Some fields are invalid'); @@ -156,9 +77,7 @@ describe('Add address path', () => { return nightmare .type(selectors.clientAddresses.consigneeInput, 'Bruce Bunner') .type(selectors.clientAddresses.streetAddressInput, '320 Park Avenue New York') - .type(selectors.clientAddresses.postcodeInput, '10022') .type(selectors.clientAddresses.cityInput, 'New York') - .type(selectors.clientAddresses.phoneInput, '999887744') .click(selectors.clientAddresses.saveButton) .waitForSnackbar() .then(result => { 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 c3da45c10..b6750a13e 100644 --- a/e2e/paths/client-module/07_edit_web_access.spec.js +++ b/e2e/paths/client-module/07_edit_web_access.spec.js @@ -45,9 +45,11 @@ describe('Edit web access path', () => { }); }); - it(`should click on the Enable web access checkbox to uncheck it`, () => { + it(`should uncheck the Enable web access checkbox and update the name`, () => { return nightmare .waitToClick(selectors.clientWebAccess.enableWebAccessCheckbox) + .clearInput(selectors.clientWebAccess.userNameInput) + .type(selectors.clientWebAccess.userNameInput, 'Hulk') .waitToClick(selectors.clientFiscalData.saveButton) .waitForSnackbar() .then(result => { @@ -55,7 +57,7 @@ describe('Edit web access path', () => { }); }); - it('should confirm Enable web access checkbox is unchecked', () => { + it('should confirm web access is unchecked and name updated', () => { return nightmare .waitToClick(selectors.clientBasicData.basicDataButton) .wait(selectors.clientBasicData.nameInput) @@ -66,29 +68,9 @@ describe('Edit web access path', () => { }, selectors.clientWebAccess.enableWebAccessCheckbox) .then(value => { expect(value).toBeFalsy(); - }); - }); - - it('should edit the User name', () => { - return nightmare - .wait(selectors.clientWebAccess.userNameInput) - .clearInput(selectors.clientWebAccess.userNameInput) - .type(selectors.clientWebAccess.userNameInput, 'Hulk') - .click(selectors.clientWebAccess.saveButton) - .waitForSnackbar() - .then(result => { - expect(result).toEqual('Data saved!'); - }); - }); - - it('should confirm the User name have been edited', () => { - return nightmare - .click(selectors.clientBasicData.basicDataButton) - .wait(selectors.clientBasicData.nameInput) - .click(selectors.clientWebAccess.webAccessButton) - .wait(selectors.clientWebAccess.userNameInput) - .waitForTextInInput(selectors.clientWebAccess.userNameInput, 'Hulk') - .getInputValue(selectors.clientWebAccess.userNameInput) + return nightmare + .getInputValue(selectors.clientWebAccess.userNameInput); + }) .then(result => { expect(result).toEqual('Hulk'); }); diff --git a/e2e/paths/client-module/10_add_greuge.spec.js b/e2e/paths/client-module/10_add_greuge.spec.js index 7f2ad9f21..9f8f93771 100644 --- a/e2e/paths/client-module/10_add_greuge.spec.js +++ b/e2e/paths/client-module/10_add_greuge.spec.js @@ -55,39 +55,8 @@ describe('Add greuge path', () => { }); }); - it(`should receive an error if all fields are empty but date on submit`, () => { - return nightmare - .click(selectors.clientCredit.saveButton) - .waitForSnackbar() - .then(result => { - expect(result).toContain('Some fields are invalid'); - }); - }); - - it(`should receive an error if all fields are empty but date and amount on submit`, () => { - return nightmare - .type(selectors.clientGreuge.amountInput, 999) - .click(selectors.clientGreuge.saveButton) - .waitForSnackbar() - .then(result => { - expect(result).toContain('Some fields are invalid'); - }); - }); - - it(`should receive an error if all fields are empty but date and description on submit`, () => { - return nightmare - .clearInput(selectors.clientGreuge.amountInput) - .type(selectors.clientGreuge.descriptionInput, 'new armor for Batman!') - .click(selectors.clientGreuge.saveButton) - .waitForSnackbar() - .then(result => { - expect(result).toContain('Some fields are invalid'); - }); - }); - it(`should receive an error if all fields are empty but date and type on submit`, () => { return nightmare - .clearInput(selectors.clientGreuge.descriptionInput) .waitToClick(selectors.clientGreuge.typeInput) .waitToClick(selectors.clientGreuge.typeSecondOption) .click(selectors.clientGreuge.saveButton) @@ -99,7 +68,6 @@ describe('Add greuge path', () => { it(`should create a new greuge with all its data`, () => { return nightmare - .clearInput(selectors.clientGreuge.amountInput) .type(selectors.clientGreuge.amountInput, 999) .type(selectors.clientGreuge.descriptionInput, 'new armor for Batman!') .click(selectors.clientGreuge.saveButton) 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 3bfa4f78d..bcc960b4f 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 @@ -1,7 +1,7 @@ import selectors from '../../helpers/selectors.js'; import createNightmare from '../../helpers/helpers'; -describe('mandate path', () => { +describe('lock verified data path', () => { const nightmare = createNightmare(); describe('as salesPerson', () => { diff --git a/e2e/paths/client-module/13_invoices.spec.js b/e2e/paths/client-module/13_invoices.spec.js index 2c5f60bee..1bc5bec99 100644 --- a/e2e/paths/client-module/13_invoices.spec.js +++ b/e2e/paths/client-module/13_invoices.spec.js @@ -1,7 +1,7 @@ import selectors from '../../helpers/selectors.js'; import createNightmare from '../../helpers/helpers'; -describe('mandate path', () => { +describe('invoice path', () => { const nightmare = createNightmare(); beforeAll(() => { @@ -51,7 +51,6 @@ describe('mandate path', () => { .getInnerText(selectors.clientInvoices.firstInvoiceText) .then(value => { expect(value).toContain('V1800001'); - expect(value).toContain('02/03/2018'); expect(value).toContain('350.50'); }); }); 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 60c9cd7cf..db0979cd4 100644 --- a/e2e/paths/item-module/05_create_item_niche.spec.js +++ b/e2e/paths/item-module/05_create_item_niche.spec.js @@ -49,11 +49,11 @@ describe('create item niche path', () => { .waitToClick(selectors.itemNiches.firstWarehouseSelect) .waitToClick(selectors.itemNiches.firstWarehouseSelectSecondOption) .clearInput(selectors.itemNiches.firstCodeInput) - .type(selectors.itemNiches.firstCodeInput, 'New Location') + .type(selectors.itemNiches.firstCodeInput, 'A2') .waitToClick(selectors.itemNiches.secondNicheRemoveButton) .waitToClick(selectors.itemNiches.thirdWarehouseSelect) .waitToClick(selectors.itemNiches.thirdWarehouseSelectFourthOption) - .type(selectors.itemNiches.thirdCodeInput, 'a code') + .type(selectors.itemNiches.thirdCodeInput, 'A4') .click(selectors.itemNiches.submitNichesButton) .waitForSnackbar() .then(result => { @@ -61,15 +61,46 @@ describe('create item niche path', () => { }); }); - it(`should confirm the remaining niches are for the second third and fourth warehouses`, () => { + it(`should confirm the first niche is the expected one`, () => { return nightmare .click(selectors.itemBasicData.basicDataButton) .wait(selectors.itemBasicData.nameInput) .click(selectors.itemNiches.nicheButton) .wait(200) - .getInputValue(selectors.itemNiches.thirdCodeInput) + .getInputValue(selectors.itemNiches.firstWarehouseSelect) .then(result => { - expect(result).toEqual('a code'); + expect(result).toEqual('Warehouse Two'); + return nightmare + .getInputValue(selectors.itemNiches.firstCodeInput); + }) + .then(result => { + expect(result).toEqual('A2'); + }); + }); + + it(`should confirm the second niche is the expected one`, () => { + return nightmare + .getInputValue(selectors.itemNiches.secondWarehouseSelect) + .then(result => { + expect(result).toEqual('Warehouse Three'); + return nightmare + .getInputValue(selectors.itemNiches.secondCodeInput); + }) + .then(result => { + expect(result).toEqual('A3'); + }); + }); + + it(`should confirm the third niche is the expected one`, () => { + return nightmare + .getInputValue(selectors.itemNiches.thirdWarehouseSelect) + .then(result => { + expect(result).toEqual('Warehouse Four'); + return nightmare + .getInputValue(selectors.itemNiches.thirdCodeInput); + }) + .then(result => { + expect(result).toEqual('A4'); }); }); }); 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 a46219cef..e8c2d39d6 100644 --- a/e2e/paths/item-module/06_create_item_botanical.spec.js +++ b/e2e/paths/item-module/06_create_item_botanical.spec.js @@ -57,7 +57,7 @@ describe('create item botanical path', () => { }); }); - it(`should confirm the botanical for item 5 was created`, () => { + it(`should confirm the botanical for item Mjolnir was created`, () => { return nightmare .click(selectors.itemBasicData.basicDataButton) .wait(selectors.itemBasicData.nameInput) @@ -69,25 +69,23 @@ describe('create item botanical path', () => { }); }); - it(`should confirm the Genus for item 5 was created`, () => { + it(`should confirm the Genus for item Mjolnir was created`, () => { return nightmare - .wait(200) .getInputValue(selectors.itemBotanical.genusSelect) .then(result => { expect(result).toEqual('Abelia'); }); }); - it(`should confirm the Species for item 5 was created`, () => { + it(`should confirm the Species for item Mjolnir was created`, () => { return nightmare - .wait(200) .getInputValue(selectors.itemBotanical.speciesSelect) .then(result => { expect(result).toEqual('dealbata'); }); }); - it(`should edit botanical for the item with id Mjolnir`, () => { + it(`should edit botanical for the item Mjolnir`, () => { return nightmare .clearInput(selectors.itemBotanical.botanicalInput) .type(selectors.itemBotanical.botanicalInput, 'Herp Derp') @@ -102,7 +100,7 @@ describe('create item botanical path', () => { }); }); - it(`should confirm the botanical for item 5 was edited`, () => { + it(`should confirm the botanical for item Mjolnir was edited`, () => { return nightmare .click(selectors.itemBasicData.basicDataButton) .wait(selectors.itemBasicData.nameInput) @@ -114,18 +112,16 @@ describe('create item botanical path', () => { }); }); - it(`should confirm the Genus for item 5 was edited`, () => { + it(`should confirm the Genus for item Mjolnir was edited`, () => { return nightmare - .wait(200) .getInputValue(selectors.itemBotanical.genusSelect) .then(result => { expect(result).toEqual('Abies'); }); }); - it(`should confirm the Species for item 5 was edited`, () => { + it(`should confirm the Species for item Mjolnir was edited`, () => { return nightmare - .wait(200) .getInputValue(selectors.itemBotanical.speciesSelect) .then(result => { expect(result).toEqual('decurrens');