diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 5ba01db0e..5b3c5c7d1 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -153,7 +153,21 @@ export default { searchButton: `${components.vnSearchBar} > vn-icon-button > button`, closeItemSummaryPreview: 'body > vn-app > vn-vertical > vn-vertical > ui-view > vn-item-list:nth-child(1) > div > vn-dialog > div > button > vn-icon' }, + itemCreateView: { + name: `${components.vnTextfield}[name="name"]`, + typeSelect: `${components.vnAutocomplete}[field="$ctrl.item.typeFk"] > vn-vertical > ${components.vnTextfield}`, + typeSelectOptionOne: `${components.vnAutocomplete}[field="$ctrl.item.typeFk"] > vn-vertical > vn-drop-down > vn-vertical > vn-auto > ul > li:nth-child(2)`, + intrastatSelect: `${components.vnAutocomplete}[field="$ctrl.item.intrastatFk"] > vn-vertical > ${components.vnTextfield}`, + intrastatSelectOptionOne: `${components.vnAutocomplete}[field="$ctrl.item.intrastatFk"] > vn-vertical > vn-drop-down > vn-vertical > vn-auto > ul > li:nth-child(2)`, + originSelect: `${components.vnAutocomplete}[field="$ctrl.item.originFk"] > vn-vertical > ${components.vnTextfield}`, + originSelectOptionOne: `${components.vnAutocomplete}[field="$ctrl.item.originFk"] > vn-vertical > vn-drop-down > vn-vertical > vn-auto > ul > li:nth-child(2)`, + expenceSelect: `${components.vnAutocomplete}[field="$ctrl.item.expenceFk"] > vn-vertical > ${components.vnTextfield}`, + expenceSelectOptionOne: `${components.vnAutocomplete}[field="$ctrl.item.expenceFk"] > vn-vertical > vn-drop-down > vn-vertical > vn-auto > ul > li:nth-child(2)`, + createButton: `${components.vnSubmit}` + + }, itemBasicData: { + goToItemIndexButton: 'body > vn-app > vn-vertical > vn-vertical > ui-view > vn-item-card > vn-main-block > vn-horizontal > vn-auto > vn-item-descriptor > vn-card > div > vn-vertical > vn-auto.descriptor-header.pointer > img', basicDataButton: `${components.vnMenuItem}[ui-sref="item.card.data"]`, typeSelect: `${components.vnAutocomplete}[field="$ctrl.item.typeFk"] > vn-vertical > ${components.vnTextfield}`, typeSelectOptionTwo: `${components.vnAutocomplete}[field="$ctrl.item.typeFk"] > vn-vertical > vn-drop-down > vn-vertical:not(.ng-hide) > vn-auto:nth-child(2) > ul > li:nth-child(2)`, 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 6b034b36d..8727f591d 100644 --- a/e2e/paths/client-module/02_edit_basic_data.spec.js +++ b/e2e/paths/client-module/02_edit_basic_data.spec.js @@ -179,7 +179,7 @@ describe('Edit basicData path', () => { .wait(200) .getInputValue(selectors.clientBasicData.salesPersonInput) .then(result => { - expect(result).toEqual('account account'); + expect(result).toEqual('accessory accessory'); }); }); diff --git a/e2e/paths/client-module/05_add_address.spec.js b/e2e/paths/client-module/05_add_address.spec.js index efec6cd32..2bb2845ab 100644 --- a/e2e/paths/client-module/05_add_address.spec.js +++ b/e2e/paths/client-module/05_add_address.spec.js @@ -198,7 +198,7 @@ describe('Add address path', () => { .waitToClick(selectors.clientAddresses.saveButton) .waitForSnackbar() .then(result => { - expect(result).toContain('Error'); + expect(result).toContain('Some fields are invalid'); }); }); }); 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 55760a4db..8dafce475 100644 --- a/e2e/paths/client-module/06_add_address_notes.spec.js +++ b/e2e/paths/client-module/06_add_address_notes.spec.js @@ -16,10 +16,10 @@ describe('Add address notes path', () => { }); }); - it('should search for the user Bruce Banner', () => { + it('should search for the user Petter Parker', () => { return nightmare .wait(selectors.clientsIndex.searchResult) - .type(selectors.clientsIndex.searchClientInput, 'Bruce Banner') + .type(selectors.clientsIndex.searchClientInput, 'Petter Parker') .click(selectors.clientsIndex.searchButton) .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) .countSearchResults(selectors.clientsIndex.searchResult) @@ -30,7 +30,7 @@ describe('Add address notes path', () => { it(`should click on the search result to access to the client addresses`, () => { return nightmare - .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner') + .waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker') .waitToClick(selectors.clientsIndex.searchResult) .waitToClick(selectors.clientAddresses.addressesButton) .waitForURL('addresses/list') @@ -42,7 +42,7 @@ describe('Add address notes path', () => { it(`should click on the edit icon of the default address`, () => { return nightmare - .waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand') + .waitForTextInElement(selectors.clientAddresses.defaultAddress, '20 Ingram Street') .waitToClick(selectors.clientAddresses.firstEditButton) .waitForURL('/edit') .url() @@ -51,13 +51,41 @@ describe('Add address notes path', () => { }); }); - // it('should add as many notes as observation types', () => { - // return nightmare - // .waitToClick(selectors.clientAddresses.defaultCheckboxInput) - // .waitToClick(selectors.clientFiscalData.saveButton) - // .waitForSnackbar() - // .then(result => { - // expect(result).toContain('Some fields are invalid'); - // }) - // }); + it('should not save a description without observation type', () => { + return nightmare + .wait(selectors.clientAddresses.firstObservationDescriptionInput) + .type(selectors.clientAddresses.firstObservationDescriptionInput, 'first description') + .waitToClick(selectors.clientAddresses.saveButton) + .waitForSnackbar() + .then(result => { + expect(result).toContain('No changes to save'); + }); + }); + + it('should not save an observation type without description type', () => { + return nightmare + .clearInput(selectors.clientAddresses.firstObservationDescriptionInput) + .waitToClick(selectors.clientAddresses.firstObservationTypeSelect) + .waitToClick(selectors.clientAddresses.firstObservationTypeSelectOptionOne) + .waitForTextInInput(selectors.clientAddresses.firstObservationTypeSelect, 'observation one') + .waitToClick(selectors.clientAddresses.saveButton) + .waitForSnackbar() + .then(result => { + expect(result).toContain('No changes to save'); + }); + }); + + it('should show an error if there are empty fields', () => { + return nightmare + .type(selectors.clientAddresses.firstObservationDescriptionInput, 'first description') + .waitToClick(selectors.clientAddresses.addAddressNoteButton) + .wait(selectors.clientAddresses.secondObservationDescriptionInput) + .type(selectors.clientAddresses.secondObservationDescriptionInput, 'second description') + .waitToClick(selectors.clientAddresses.saveButton) + .waitForSnackbar() + .then(result => { + expect(result).toContain('No changes to save'); + }); + }); }); + diff --git a/e2e/paths/item-module/08_item_clone.spec.js b/e2e/paths/item-module/08_item_clone.spec.js deleted file mode 100644 index 398bceddf..000000000 --- a/e2e/paths/item-module/08_item_clone.spec.js +++ /dev/null @@ -1,52 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import createNightmare from '../../helpers/helpers'; - -describe('Item clone 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 Iron Patriot', () => { - return nightmare - .wait(selectors.itemsIndex.searchResult) - .type(selectors.itemsIndex.searchItemInput, 'Iron Patriot') - .click(selectors.itemsIndex.searchButton) - .waitForNumberOfElements(selectors.itemsIndex.searchResult, 1) - .countSearchResults(selectors.itemsIndex.searchResult) - .then(result => { - expect(result).toEqual(1); - }); - }); - - it(`should clone the Iron Patriot`, () => { - return nightmare - .waitForTextInElement(selectors.itemsIndex.searchResult, 'Iron Patriot') - .click(selectors.itemsIndex.searchResultCloneButton) - .waitToClick(selectors.itemsIndex.acceptClonationAlertButton) - .waitForURL('tags') - .parsedUrl() - .then(url => { - expect(url.hash).toContain('tags'); - }); - }); - - it('should search for the item Iron Patriot and find two', () => { - return nightmare - .wait(selectors.itemsIndex.searchResult) - .type(selectors.itemsIndex.searchItemInput, 'Iron Patriot') - .click(selectors.itemsIndex.searchButton) - .waitForNumberOfElements(selectors.itemsIndex.searchResult, 2) - .countSearchResults(selectors.itemsIndex.searchResult) - .then(result => { - expect(result).toEqual(2); - }); - }); -}); 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 new file mode 100644 index 000000000..09c5e9197 --- /dev/null +++ b/e2e/paths/item-module/08_item_create_and_clone.spec.js @@ -0,0 +1,134 @@ +import selectors from '../../helpers/selectors.js'; +import createNightmare from '../../helpers/helpers'; + +describe('Item', () => { + const nightmare = createNightmare(); + describe('create path', () => { + 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 Infinity Gauntlet to confirm it isn't created yet`, () => { + return nightmare + .wait(selectors.itemsIndex.searchResult) + .type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet') + .click(selectors.itemsIndex.searchButton) + .waitForNumberOfElements(selectors.itemsIndex.searchResult, 0) + .countSearchResults(selectors.itemsIndex.searchResult) + .then(result => { + expect(result).toEqual(0); + }); + }); + + it('should access to the create item view by clicking the create floating button', () => { + return nightmare + .click(selectors.itemsIndex.createItemButton) + .wait(selectors.itemCreateView.createButton) + .parsedUrl() + .then(url => { + expect(url.hash).toEqual('#!/item/create'); + }); + }); + + it('should create the Infinity Gauntlet item', () => { + return nightmare + .type(selectors.itemCreateView.name, 'Infinity Gauntlet') + .waitToClick(selectors.itemCreateView.typeSelect) + .waitToClick(selectors.itemCreateView.typeSelectOptionOne) + .waitToClick(selectors.itemCreateView.intrastatSelect) + .waitToClick(selectors.itemCreateView.intrastatSelectOptionOne) + .waitToClick(selectors.itemCreateView.originSelect) + .waitToClick(selectors.itemCreateView.originSelectOptionOne) + .waitToClick(selectors.itemCreateView.expenceSelect) + .waitToClick(selectors.itemCreateView.expenceSelectOptionOne) + .click(selectors.itemCreateView.createButton) + .waitForSnackbar() + .then(result => { + expect(result).toContain('Data saved!'); + }); + }); + + it('should confirm Infinity Gauntlet item was created', () => { + return nightmare + .wait(selectors.itemBasicData.nameInput) + .getInputValue(selectors.itemBasicData.nameInput) + .then(result => { + expect(result).toBe('Infinity Gauntlet'); + return nightmare + .getInputValue(selectors.itemBasicData.typeSelect); + }) + .then(result => { + expect(result).toBe('Crisantemo'); + return nightmare + .getInputValue(selectors.itemBasicData.intrastatSelect); + }) + .then(result => { + expect(result).toBe('Plantas vivas: Esqueje/injerto, Vid'); + return nightmare + .getInputValue(selectors.itemBasicData.originSelect); + }) + .then(result => { + expect(result).toBe('Spain'); + return nightmare + .getInputValue(selectors.itemBasicData.expenceSelect); + }) + .then(result => { + expect(result).toBe('loan'); + }); + }); + }); + + describe('clone path', () => { + it('should access to the items index by clicking the items button', () => { + return nightmare + .click(selectors.itemBasicData.goToItemIndexButton) + .wait(selectors.itemsIndex.createItemButton) + .parsedUrl() + .then(url => { + expect(url.hash).toEqual('#!/item/list'); + }); + }); + + it(`should search for the item Infinity Gauntlet`, () => { + return nightmare + .wait(selectors.itemsIndex.searchResult) + .type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet') + .click(selectors.itemsIndex.searchButton) + .waitForNumberOfElements(selectors.itemsIndex.searchResult, 1) + .countSearchResults(selectors.itemsIndex.searchResult) + .then(result => { + expect(result).toEqual(1); + }); + }); + + it(`should clone the Infinity Gauntlet`, () => { + return nightmare + .waitForTextInElement(selectors.itemsIndex.searchResult, 'Infinity Gauntlet') + .click(selectors.itemsIndex.searchResultCloneButton) + .waitToClick(selectors.itemsIndex.acceptClonationAlertButton) + .waitForURL('tags') + .parsedUrl() + .then(url => { + expect(url.hash).toContain('tags'); + }); + }); + + it('should search for the item Infinity Gauntlet and find two', () => { + return nightmare + .wait(selectors.itemsIndex.searchResult) + .type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet') + .click(selectors.itemsIndex.searchButton) + .waitForNumberOfElements(selectors.itemsIndex.searchResult, 2) + .countSearchResults(selectors.itemsIndex.searchResult) + .then(result => { + expect(result).toEqual(2); + }); + }); + }); +});