diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index c6c8cb6a3..27cfde167 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -6,6 +6,7 @@ export default { applicationsMenuButton: `#apps`, applicationsMenuVisible: `vn-main-menu [vn-id="apps-menu"] ul`, clientsButton: `vn-main-menu [vn-id="apps-menu"] ul > li[ui-sref="client.index"]`, + itemsButton: `vn-main-menu [vn-id="apps-menu"] ul > li[ui-sref="item.index"]`, ticketsButton: `vn-main-menu [vn-id="apps-menu"] ul > li[ui-sref="ticket.index"]`, claimsButton: `vn-main-menu [vn-id="apps-menu"] ul > li[ui-sref="claim.index"]` }, @@ -190,6 +191,14 @@ export default { createButton: `${components.vnSubmit}`, cancelButton: `button[ui-sref="item.index"]` }, + itemDescriptor: { + moreMenu: `vn-item-descriptor > vn-card > div vn-icon-menu > div > vn-icon`, + moreMenuRegularizeButton: `vn-item-descriptor vn-icon-menu > div > vn-drop-down > vn-popover ul > li:nth-child(1)`, + regularizeQuantityInput: `vn-item-descriptor > vn-dialog > div > form > div.body > tpl-body > div > vn-textfield > div > div > div.infix > input`, + regularizeWarehouseSelect: `#warehouse > div > div > input`, + regularizeWarehouseSelectSecondOption: `#warehouse > vn-drop-down > vn-popover > div > div.content > div > div.list > ul > li:nth-child(2)`, + regularizeSaveButton: `vn-item-descriptor > vn-dialog > div > form > div.buttons > tpl-buttons > button` + }, itemBasicData: { goToItemIndexButton: 'vn-item-descriptor [ui-sref="item.index"]', basicDataButton: `vn-left-menu a[ui-sref="item.card.data"]`, @@ -287,6 +296,11 @@ export default { botanical: `vn-item-summary vn-vertical[name="botanical"]`, barcode: `vn-item-summary vn-vertical[name="barcode"]` }, + ticketSummary: { + sale: 'vn-ticket-summary > vn-card > div > vn-vertical > vn-horizontal > table > tbody > tr', + firstSaleQuantity: 'vn-ticket-summary > vn-card > div > vn-vertical > vn-horizontal:nth-child(3) > table > tbody > tr > td:nth-child(4)', + firstSaleDiscount: 'vn-ticket-summary > vn-card > div > vn-vertical > vn-horizontal:nth-child(3) > table > tbody > tr > td:nth-child(6)' + }, ticketsIndex: { searchResult: `vn-ticket-index vn-card > div > vn-table > div > vn-tbody > a.vn-tr`, searchResultDate: `vn-ticket-index vn-table vn-tbody > a:nth-child(1) > vn-td:nth-child(4)`, 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 index 42b77d15d..ab333dc86 100644 --- a/e2e/paths/item-module/08_item_create_and_clone.spec.js +++ b/e2e/paths/item-module/08_item_create_and_clone.spec.js @@ -1,7 +1,7 @@ import selectors from '../../helpers/selectors.js'; import createNightmare from '../../helpers/nightmare'; -describe('Item Create path', () => { +describe('Item', () => { const nightmare = createNightmare(); describe('Create path', () => { beforeAll(() => { diff --git a/e2e/paths/item-module/09_regularize_item.spec.js b/e2e/paths/item-module/09_regularize_item.spec.js new file mode 100644 index 000000000..116a825d4 --- /dev/null +++ b/e2e/paths/item-module/09_regularize_item.spec.js @@ -0,0 +1,187 @@ +import selectors from '../../helpers/selectors.js'; +import createNightmare from '../../helpers/nightmare'; + +fdescribe('Item regularize path', () => { + const nightmare = createNightmare(); + beforeAll(() => { + return nightmare + .waitForLogin('developer'); + }); + + it('should access to the items index by clicking the items button', async () => { + const url = await nightmare + .click(selectors.moduleAccessView.itemsSectionButton) + .wait(selectors.itemsIndex.createItemButton) + .parsedUrl(); + + expect(url.hash).toEqual('#!/item/index'); + }); + + it('should search for the item Gem of Time', async () => { + const resultCount = await nightmare + .wait(selectors.itemsIndex.searchResult) + .type(selectors.itemsIndex.searchItemInput, 'Gem of Time') + .click(selectors.itemsIndex.searchButton) + .waitForNumberOfElements(selectors.itemsIndex.searchResult, 1) + .countElement(selectors.itemsIndex.searchResult); + + expect(resultCount).toEqual(1); + }); + + it(`should click on the search result to access to the item tax`, async () => { + const url = await nightmare + .waitForTextInElement(selectors.itemsIndex.searchResult, 'Gem of Time') + .waitToClick(selectors.itemsIndex.searchResult) + .waitForURL('/summary') + .url(); + + expect(url).toContain('/summary'); + }); + + it('should regularize the item', async () => { + const result = await nightmare + .waitToClick(selectors.itemDescriptor.moreMenu) + .waitToClick(selectors.itemDescriptor.moreMenuRegularizeButton) + .wait(selectors.itemDescriptor.regularizeQuantityInput) + .type(selectors.itemDescriptor.regularizeQuantityInput, 100) + .waitToClick(selectors.itemDescriptor.regularizeWarehouseSelect) + .waitToClick(selectors.itemDescriptor.regularizeWarehouseSelectSecondOption) + .waitToClick(selectors.itemDescriptor.regularizeSaveButton) + .waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); + }); + + it('should click on the Tickets button of the top bar menu', async () => { + const url = await nightmare + .waitToClick(selectors.globalItems.applicationsMenuButton) + .wait(selectors.globalItems.applicationsMenuVisible) + .waitToClick(selectors.globalItems.ticketsButton) + .wait(selectors.ticketsIndex.searchResult) + .parsedUrl(); + + expect(url.hash).toEqual('#!/ticket/index'); + }); + + it('should search for the ticket with id 22', async () => { + const result = await nightmare + .wait(selectors.ticketsIndex.searchTicketInput) + .type(selectors.ticketsIndex.searchTicketInput, 'id:22') + .click(selectors.ticketsIndex.searchButton) + .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) + .countElement(selectors.ticketsIndex.searchResult); + + expect(result).toEqual(1); + }); + + it(`should click on the search result to access to the ticket summary`, async () => { + const url = await nightmare + .waitForTextInElement(selectors.ticketsIndex.searchResult, '22') + .waitToClick(selectors.ticketsIndex.searchResult) + .waitForURL('/summary') + .url(); + + expect(url).toContain('/summary'); + }); + + it(`should check the ticket sale quantity is showing a negative value`, async () => { + const result = await nightmare + .waitForTextInElement(selectors.ticketSummary.firstSaleQuantity, '-17') + .getInnerText(selectors.ticketSummary.firstSaleQuantity); + + expect(result).toContain('-17'); + }); + + it(`should check the ticket sale discount is 100%`, async () => { + const result = await nightmare + .getInnerText(selectors.ticketSummary.firstSaleDiscount); + + expect(result).toContain('100 %'); + }); + + it('should now click on the Items button of the top bar menu', async () => { + const url = await nightmare + .waitToClick(selectors.globalItems.applicationsMenuButton) + .wait(selectors.globalItems.applicationsMenuVisible) + .waitToClick(selectors.globalItems.itemsButton) + .wait(selectors.itemsIndex.searchResult) + .parsedUrl(); + + expect(url.hash).toEqual('#!/item/index'); + }); + + it('should search for the item Gem of Time once again', async () => { + const resultCount = await nightmare + .wait(selectors.itemsIndex.searchResult) + .type(selectors.itemsIndex.searchItemInput, 'Gem of Time') + .click(selectors.itemsIndex.searchButton) + .waitForNumberOfElements(selectors.itemsIndex.searchResult, 1) + .countElement(selectors.itemsIndex.searchResult); + + expect(resultCount).toEqual(1); + }); + + it(`should click on the search result to access to the item tax`, async () => { + const url = await nightmare + .waitForTextInElement(selectors.itemsIndex.searchResult, 'Gem of Time') + .waitToClick(selectors.itemsIndex.searchResult) + .waitForURL('/summary') + .url(); + + expect(url).toContain('/summary'); + }); + + it('should regularize the item once more', async () => { + const result = await nightmare + .waitToClick(selectors.itemDescriptor.moreMenu) + .waitToClick(selectors.itemDescriptor.moreMenuRegularizeButton) + .wait(selectors.itemDescriptor.regularizeQuantityInput) + .type(selectors.itemDescriptor.regularizeQuantityInput, 100) + .waitToClick(selectors.itemDescriptor.regularizeWarehouseSelect) + .waitToClick(selectors.itemDescriptor.regularizeWarehouseSelectSecondOption) + .waitToClick(selectors.itemDescriptor.regularizeSaveButton) + .waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); + }); + + it('should again click on the Tickets button of the top bar menu', async () => { + const url = await nightmare + .waitToClick(selectors.globalItems.applicationsMenuButton) + .wait(selectors.globalItems.applicationsMenuVisible) + .waitToClick(selectors.globalItems.ticketsButton) + .wait(selectors.ticketsIndex.searchResult) + .parsedUrl(); + + expect(url.hash).toEqual('#!/ticket/index'); + }); + + it('should search for the ticket with id 22 once again', async () => { + const result = await nightmare + .wait(selectors.ticketsIndex.searchTicketInput) + .type(selectors.ticketsIndex.searchTicketInput, 'id:22') + .click(selectors.ticketsIndex.searchButton) + .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) + .countElement(selectors.ticketsIndex.searchResult); + + expect(result).toEqual(1); + }); + + it(`should now click on the search result to access to the ticket summary`, async () => { + const url = await nightmare + .waitForTextInElement(selectors.ticketsIndex.searchResult, '22') + .waitToClick(selectors.ticketsIndex.searchResult) + .waitForURL('/summary') + .url(); + + expect(url).toContain('/summary'); + }); + + it(`should check the ticket contains now two sales`, async () => { + const result = await nightmare + .waitForTextInElement(selectors.ticketSummary.firstSaleQuantity, '-17') + .countElement(selectors.ticketSummary.sale); + + expect(result).toEqual(2); + }); +});