From 7f4374ae640d5e2fcf827a84b43f03943018ab3f Mon Sep 17 00:00:00 2001 From: Carlos Jimenez <=> Date: Wed, 4 Apr 2018 11:56:07 +0200 Subject: [PATCH] #196 e2e sales e2e path --- e2e/helpers/selectors.js | 9 ++- e2e/paths/ticket-module/03_list_sale.spec.js | 73 ++++++++++++++++++++ 2 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 e2e/paths/ticket-module/03_list_sale.spec.js diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 84fbec4c67..9f09b3b738 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -7,7 +7,8 @@ export default { logOutButton: `#logout`, applicationsMenuButton: `#apps`, applicationsMenuVisible: `vn-main-menu [vn-id="apps-menu"] ul`, - clientsButton: `vn-main-menu [vn-id="apps-menu"] ul > li:nth-child(1)` + clientsButton: `vn-main-menu [vn-id="apps-menu"] ul > li:nth-child(1)`, + ticketsButton: `vn-main-menu [vn-id="apps-menu"] ul > li:nth-child(6)` }, moduleAccessView: { clientsSectionButton: `${components.vnModuleContainer}[ui-sref="clients"]`, @@ -294,5 +295,11 @@ export default { ticketPackages: { packagesButton: `${components.vnMenuItem}[ui-sref="ticket.card.package.index"]`, firstPackageSelect: `${components.vnAutocomplete}[label="Package"] input` + }, + ticketSales: { + saleButton: `${components.vnMenuItem}[ui-sref="ticket.card.sale"]`, + firstPackageSelect: `${components.vnAutocomplete}[label="Package"] input`, + firstSaleText: `table > tbody > tr:nth-child(1)`, + secondSaleText: `table > tbody > tr:nth-child(2)` } }; diff --git a/e2e/paths/ticket-module/03_list_sale.spec.js b/e2e/paths/ticket-module/03_list_sale.spec.js new file mode 100644 index 0000000000..a7dca061d6 --- /dev/null +++ b/e2e/paths/ticket-module/03_list_sale.spec.js @@ -0,0 +1,73 @@ +import selectors from '../../helpers/selectors.js'; +import createNightmare from '../../helpers/helpers'; + +describe('list sale path', () => { + const nightmare = createNightmare(); + + beforeAll(() => { + return nightmare + .waitForLogin('developer'); + }); + + it('should click on the Tickets button of the top bar menu', () => { + return nightmare + .waitToClick(selectors.globalItems.applicationsMenuButton) + .wait(selectors.globalItems.applicationsMenuVisible) + .waitToClick(selectors.globalItems.ticketsButton) + .wait(selectors.ticketsIndex.createTicketButton) + .parsedUrl() + .then(url => { + expect(url.hash).toEqual('#!/ticket/list'); + }); + }); + + it('should search for the ticket 1', () => { + return nightmare + .wait(selectors.ticketsIndex.searchResult) + .type(selectors.ticketsIndex.searchTicketInput, 1) + .click(selectors.ticketsIndex.searchButton) + .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) + .countSearchResults(selectors.ticketsIndex.searchResult) + .then(result => { + expect(result).toEqual(1); + }); + }); + + it(`should click on the search result to access to the ticket's sale`, () => { + return nightmare + .waitForTextInElement(selectors.ticketsIndex.searchResult, 'Batman') + .waitToClick(selectors.ticketsIndex.searchResult) + .waitToClick(selectors.ticketSales.saleButton) + .waitForURL('sale') + .url() + .then(url => { + expect(url).toContain('sale'); + }); + }); + + it('should confirm the fist ticket sale is the expected one', () => { + return nightmare + .wait(selectors.ticketSales.firstSaleText) + .getInnerText(selectors.ticketSales.firstSaleText) + .then(value => { + expect(value).toContain('Color Yellow'); + expect(value).toContain('2'); + expect(value).toContain('€1.50'); + expect(value).toContain('0 %'); + expect(value).toContain('€3.00'); + }); + }); + + it('should confirm the second ticket sale is the expected one', () => { + return nightmare + .wait(selectors.ticketSales.secondSaleText) + .getInnerText(selectors.ticketSales.secondSaleText) + .then(value => { + expect(value).toContain('Color Yellow'); + expect(value).toContain('5'); + expect(value).toContain('€1.50'); + expect(value).toContain('0 %'); + expect(value).toContain('€7.50'); + }); + }); +});