From 398f66defc154ef8e2c13946b0336d53900a2c27 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez <=> Date: Fri, 23 Feb 2018 09:42:19 +0100 Subject: [PATCH] e2e path for item clone --- e2e/helpers/selectors.js | 2 + e2e/paths/item-module/01_item_summary.spec.js | 2 +- e2e/paths/item-module/08_item_clone.spec.js | 52 +++++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 e2e/paths/item-module/08_item_clone.spec.js diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 4a264e9a9..d6876bf5b 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -137,6 +137,8 @@ export default { createItemButton: `${components.vnFloatButton}`, searchResult: `${components.vnItemProduct} > vn-horizontal > vn-one`, searchResultPreviewButton: `${components.vnItemProduct}:nth-child(1) > vn-horizontal > vn-horizontal > vn-one:nth-child(2) > vn-icon > i`, + searchResultCloneButton: `${components.vnItemProduct} > vn-horizontal > vn-horizontal > vn-one:nth-child(1) > vn-icon > i`, + acceptClonationAlertButton: `vn-dialog.ng-isolate-scope.vn-dialog.shown > div > form > div.buttons > tpl-buttons > button:nth-child(2)`, searchItemInput: `${components.vnTextfield}`, 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' diff --git a/e2e/paths/item-module/01_item_summary.spec.js b/e2e/paths/item-module/01_item_summary.spec.js index cf8e4e04a..e4142cf60 100644 --- a/e2e/paths/item-module/01_item_summary.spec.js +++ b/e2e/paths/item-module/01_item_summary.spec.js @@ -14,7 +14,7 @@ describe('Item summary path', () => { }); }); - it('should search for the item Gem of Mind', () => { + it('should search for the item Gem of Time', () => { return nightmare .wait(selectors.itemsIndex.searchResult) .type(selectors.itemsIndex.searchItemInput, 'Gem of Time') diff --git a/e2e/paths/item-module/08_item_clone.spec.js b/e2e/paths/item-module/08_item_clone.spec.js new file mode 100644 index 000000000..398bceddf --- /dev/null +++ b/e2e/paths/item-module/08_item_clone.spec.js @@ -0,0 +1,52 @@ +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); + }); + }); +});