From b3ec161b0088fc9bcab0f9ecb5d9ce0c55356221 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez <=> Date: Tue, 27 Feb 2018 19:00:46 +0100 Subject: [PATCH] e2e path for item tags #121 --- e2e/helpers/selectors.js | 24 +++- .../item-module/04_create_item_tags.spec.js | 115 ++++++++++++++++++ 2 files changed, 136 insertions(+), 3 deletions(-) create mode 100644 e2e/paths/item-module/04_create_item_tags.spec.js diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 5b3c5c7d1..21f490eac 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -181,6 +181,27 @@ export default { expenceSelectOptionTwo: `${components.vnAutocomplete}[field="$ctrl.item.expenceFk"] > vn-vertical > vn-drop-down > vn-vertical:not(.ng-hide) > vn-auto:nth-child(2) > ul > li:nth-child(2)`, submitBasicDataButton: `${components.vnSubmit}` }, + itemTags: { + tagsButton: `${components.vnMenuItem}[ui-sref="item.card.tags"]`, + firstTagSelect: `vn-horizontal:nth-child(3) > ${components.vnAutocomplete}[field="itemTag.tagFk"] > vn-vertical > ${components.vnTextfield}`, + firstTagSelectOptionOne: `vn-horizontal:nth-child(3) > ${components.vnAutocomplete}[field="itemTag.tagFk"] > vn-vertical > vn-drop-down > vn-vertical:not(.ng-hide) > vn-auto:nth-child(2) > ul > li:nth-child(1)`, + firstValueInput: `vn-horizontal:nth-child(3) > ${components.vnTextfield}`, + secondTagSelect: `vn-horizontal:nth-child(4) > ${components.vnAutocomplete}[field="itemTag.tagFk"] > vn-vertical > ${components.vnTextfield}`, + secondTagSelectOptionOne: `vn-horizontal:nth-child(4) > ${components.vnAutocomplete}[field="itemTag.tagFk"] > vn-vertical > vn-drop-down > vn-vertical:not(.ng-hide) > vn-auto:nth-child(2) > ul > li:nth-child(1)`, + secondValueInput: `vn-horizontal:nth-child(4) > ${components.vnTextfield}`, + thirdTagSelect: `vn-horizontal:nth-child(5) > ${components.vnAutocomplete}[field="itemTag.tagFk"] > vn-vertical > ${components.vnTextfield}`, + thirdTagSelectOptionOne: `vn-horizontal:nth-child(5) > ${components.vnAutocomplete}[field="itemTag.tagFk"] > vn-vertical > vn-drop-down > vn-vertical:not(.ng-hide) > vn-auto:nth-child(2) > ul > li:nth-child(1)`, + thirdValueInput: `vn-horizontal:nth-child(5) > ${components.vnTextfield}`, + fourthTagSelect: `vn-horizontal:nth-child(6) > ${components.vnAutocomplete}[field="itemTag.tagFk"] > vn-vertical > ${components.vnTextfield}`, + fourthTagSelectOptionOne: `vn-horizontal:nth-child(6) > ${components.vnAutocomplete}[field="itemTag.tagFk"] > vn-vertical > vn-drop-down > vn-vertical:not(.ng-hide) > vn-auto:nth-child(2) > ul > li:nth-child(1)`, + fourthValueInput: `vn-horizontal:nth-child(6) > ${components.vnTextfield}`, + fifthRemoveTagButton: `vn-horizontal:nth-child(7) > vn-one > ${components.vnIcon}[icon="remove_circle_outline"]`, + addItemTagButton: `${components.vnIcon}[icon="add_circle"]`, + fifthTagSelect: `vn-horizontal:nth-child(7) > ${components.vnAutocomplete}[field="itemTag.tagFk"] > vn-vertical > ${components.vnTextfield}`, + fifthTagSelectOptionFive: `vn-horizontal:nth-child(7) > ${components.vnAutocomplete}[field="itemTag.tagFk"] > vn-vertical > vn-drop-down > vn-vertical:not(.ng-hide) > vn-auto:nth-child(2) > ul > li:nth-child(5)`, + fifthValueInput: `vn-horizontal:nth-child(7) > ${components.vnTextfield}`, + submitItemTagsButton: `${components.vnSubmit}` + }, itemTax: { taxButton: `${components.vnMenuItem}[ui-sref="item.card.tax"]`, firstClassSelect: `vn-horizontal:nth-child(2) > ${components.vnAutocomplete}[field="tax.taxClassFk"] > vn-vertical > ${components.vnTextfield}`, @@ -221,9 +242,6 @@ export default { speciesSelectOptionTwo: `${components.vnAutocomplete}[field="$ctrl.botanical.specieFk"] > vn-vertical > vn-drop-down > vn-vertical:not(.ng-hide) > vn-auto:nth-child(2) > ul > li:nth-child(2)`, submitBotanicalButton: `${components.vnSubmit}` }, - itemTags: { - tagsButton: `${components.vnMenuItem}[ui-sref="item.card.tags"]` - }, itemSummary: { basicData: `${components.vnItemSummary} > vn-horizontal:nth-child(1) > vn-one:nth-child(2) > vn-vertical > p:nth-child(2)`, tags: `${components.vnItemSummary} > vn-horizontal:nth-child(1) > vn-one:nth-child(3) > vn-vertical > p`, diff --git a/e2e/paths/item-module/04_create_item_tags.spec.js b/e2e/paths/item-module/04_create_item_tags.spec.js new file mode 100644 index 000000000..a9bb929f6 --- /dev/null +++ b/e2e/paths/item-module/04_create_item_tags.spec.js @@ -0,0 +1,115 @@ +import selectors from '../../helpers/selectors.js'; +import createNightmare from '../../helpers/helpers'; + +describe('create item tags 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 tags`, () => { + return nightmare + .waitForTextInElement(selectors.itemsIndex.searchResult, 'Gem of Time') + .waitToClick(selectors.itemsIndex.searchResult) + .waitToClick(selectors.itemTags.tagsButton) + .waitForURL('tags') + .url() + .then(url => { + expect(url).toContain('tags'); + }); + }); + + it(`should create a new tag, edit another and delete a former one`, () => { + return nightmare + .waitToClick(selectors.itemTags.firstTagSelect) + .waitToClick(selectors.itemTags.firstTagSelectOptionOne) + .clearInput(selectors.itemTags.firstValueInput) + .type(selectors.itemTags.firstValueInput, 'Dark Blue') + .waitToClick(selectors.itemTags.fifthRemoveTagButton) + .waitToClick(selectors.itemTags.addItemTagButton) + .waitToClick(selectors.itemTags.fifthTagSelect) + .waitToClick(selectors.itemTags.fifthTagSelectOptionFive) + .type(selectors.itemTags.fifthValueInput, 'Thanos') + .click(selectors.itemTags.submitItemTagsButton) + .waitForSnackbar() + .then(result => { + expect(result).toContain('Data saved!'); + }); + }); + + it(`should confirm the remaining tags are the expected ones`, () => { + return nightmare + .click(selectors.itemBasicData.basicDataButton) + .wait(selectors.itemBasicData.nameInput) + .click(selectors.itemTags.tagsButton) + .wait(200) + .getInputValue(selectors.itemTags.firstTagSelect) + .then(result => { + expect(result).toEqual('Owner'); + return nightmare + .getInputValue(selectors.itemTags.firstValueInput); + }) + .then(result => { + expect(result).toEqual('Thanos'); + return nightmare + .getInputValue(selectors.itemTags.secondTagSelect); + }) + .then(result => { + expect(result).toEqual('Color'); + return nightmare + .getInputValue(selectors.itemTags.secondValueInput); + }) + .then(result => { + expect(result).toEqual('Dark Blue'); + return nightmare + .getInputValue(selectors.itemTags.thirdTagSelect); + }) + .then(result => { + expect(result).toEqual('Location'); + return nightmare + .getInputValue(selectors.itemTags.thirdValueInput); + }) + .then(result => { + expect(result).toEqual('Gamoras hideout'); + return nightmare + .getInputValue(selectors.itemTags.fourthTagSelect); + }) + .then(result => { + expect(result).toEqual('Shape'); + return nightmare + .getInputValue(selectors.itemTags.fourthValueInput); + }) + .then(result => { + expect(result).toEqual('round'); + return nightmare + .getInputValue(selectors.itemTags.fifthTagSelect); + }) + .then(result => { + expect(result).toEqual('Power'); + return nightmare + .getInputValue(selectors.itemTags.fifthValueInput); + }) + .then(result => { + expect(result).toEqual('Manipulates time'); + }); + }); +});