salix/e2e/paths/04-ticket-module/07_edit_sale.spec.js

622 lines
25 KiB
JavaScript
Raw Normal View History

import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
// #1186 repearar e2e ticket.sale, item.regularize.
xdescribe('Ticket Edit sale path', () => {
const nightmare = createNightmare();
beforeAll(() => {
2018-11-07 07:38:09 +00:00
nightmare
.loginAndModule('salesPerson', 'ticket')
2019-02-07 13:33:52 +00:00
.accessToSearchResult('16')
.accessToSection('ticket.card.sale');
2018-11-07 07:38:09 +00:00
});
2019-01-22 12:53:42 +00:00
it(`should click on the second claim id to navigate over there`, async() => {
2018-11-07 07:38:09 +00:00
const url = await nightmare
2019-01-31 16:01:33 +00:00
.waitToClick(selectors.ticketSales.secondSaleClaimIcon)
2019-01-07 08:33:07 +00:00
.wait(selectors.claimBasicData.claimStateAutocomplete)
2018-11-07 07:38:09 +00:00
.parsedUrl();
expect(url.hash).toEqual('#!/claim/2/basic-data');
});
2019-01-07 08:33:07 +00:00
it('should now click on the Tickets button of the top bar menu', async() => {
2018-11-07 07:38:09 +00:00
const url = await nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.ticketsButton)
.wait(selectors.ticketsIndex.searchTicketInput)
2018-11-07 07:38:09 +00:00
.parsedUrl();
expect(url.hash).toEqual('#!/ticket/index');
});
2019-01-07 08:33:07 +00:00
it('should again search for a specific ticket', async() => {
2018-11-07 07:38:09 +00:00
const result = await nightmare
2019-02-07 13:33:52 +00:00
.write(selectors.ticketsIndex.searchTicketInput, '16')
2019-01-23 15:00:56 +00:00
.waitToClick(selectors.ticketsIndex.searchButton)
2018-10-25 14:44:03 +00:00
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
2018-11-07 07:38:09 +00:00
.countElement(selectors.ticketsIndex.searchResult);
expect(result).toEqual(1);
});
2019-01-07 08:33:07 +00:00
it(`should now click on the search result to access to the ticket Sale`, async() => {
2018-11-07 07:38:09 +00:00
const url = await nightmare
2018-10-25 14:44:03 +00:00
.waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21')
.waitToClick(selectors.ticketsIndex.searchResult)
.waitToClick(selectors.ticketSales.saleButton)
.waitForURL('/sale')
.parsedUrl();
2018-11-07 07:38:09 +00:00
expect(url.hash).toContain('/sale');
2018-10-25 14:44:03 +00:00
});
2019-01-07 08:33:07 +00:00
it(`should check the zoomed image isnt present`, async() => {
2018-11-07 07:38:09 +00:00
const result = await nightmare
.countElement(selectors.ticketSales.firstSaleZoomedImage);
expect(result).toEqual(0);
2018-10-25 14:44:03 +00:00
});
2019-01-07 08:33:07 +00:00
it(`should click on the thumbnail image of the 1st sale and see the zoomed image`, async() => {
2018-11-07 07:38:09 +00:00
const result = await nightmare
2019-02-04 13:47:55 +00:00
.clickIfVisible(selectors.ticketSales.firstSaleThumbnailImage)
2018-11-07 07:38:09 +00:00
.countElement(selectors.ticketSales.firstSaleZoomedImage);
expect(result).toEqual(1);
});
2019-01-07 08:33:07 +00:00
it(`should click on the zoomed image to close it`, async() => {
2018-11-07 07:38:09 +00:00
const result = await nightmare
2019-02-04 14:40:57 +00:00
.wait(1000)
2019-02-04 13:47:55 +00:00
.clickIfVisible(selectors.ticketSales.firstSaleZoomedImage)
2018-11-07 07:38:09 +00:00
.countElement(selectors.ticketSales.firstSaleZoomedImage);
expect(result).toEqual(0);
});
2019-01-07 08:33:07 +00:00
it(`should confirm the item descriptor insnt visible yet`, async() => {
2018-11-07 07:38:09 +00:00
const visible = await nightmare
.isVisible(selectors.ticketSales.saleDescriptorPopover);
expect(visible).toBeFalsy();
});
2019-01-07 08:33:07 +00:00
it(`should click on the first sale ID making the item descriptor visible`, async() => {
2018-11-07 07:38:09 +00:00
const visible = await nightmare
2018-10-25 14:44:03 +00:00
.waitToClick(selectors.ticketSales.firstSaleID)
2019-02-07 08:07:00 +00:00
.waitImgLoad(selectors.ticketSales.firstSaleDescriptorImage)
2018-11-07 07:38:09 +00:00
.isVisible(selectors.ticketSales.saleDescriptorPopover);
expect(visible).toBeTruthy();
});
2019-01-07 08:33:07 +00:00
it(`should click on the descriptor image of the 1st sale and see the zoomed image`, async() => {
2018-11-07 07:38:09 +00:00
const result = await nightmare
2019-02-04 13:47:55 +00:00
.clickIfVisible('vn-item-descriptor img')
2018-11-07 07:38:09 +00:00
.countElement(selectors.ticketSales.firstSaleZoomedImage);
expect(result).toEqual(1);
});
2019-02-04 14:40:57 +00:00
it(`should now click on the zoomed image to close it`, async() => {
2018-11-07 07:38:09 +00:00
const result = await nightmare
2019-02-04 13:47:55 +00:00
.clickIfVisible(selectors.ticketSales.firstSaleZoomedImage)
2018-11-07 07:38:09 +00:00
.countElement(selectors.ticketSales.firstSaleZoomedImage);
expect(result).toEqual(0);
});
2019-01-07 08:33:07 +00:00
it(`should click on the summary icon of the item-descriptor to access to the item summary`, async() => {
2018-11-07 07:38:09 +00:00
const url = await nightmare
2018-10-25 14:44:03 +00:00
.waitToClick(selectors.ticketSales.saleDescriptorPopoverSummaryButton)
.waitForURL('/summary')
.parsedUrl();
2018-11-07 07:38:09 +00:00
expect(url.hash).toContain('/summary');
});
2019-01-07 08:33:07 +00:00
it('should return to ticket sales section', async() => {
2018-11-07 07:38:09 +00:00
const url = await nightmare
2018-10-25 14:44:03 +00:00
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.ticketsButton)
2019-02-07 13:33:52 +00:00
.write(selectors.ticketsIndex.searchTicketInput, '16')
2019-01-23 15:00:56 +00:00
.waitToClick(selectors.ticketsIndex.searchButton)
2018-10-25 14:44:03 +00:00
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
.waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21')
.waitToClick(selectors.ticketsIndex.searchResult)
.waitToClick(selectors.ticketSales.saleButton)
.waitForURL('/sale')
.parsedUrl();
2018-11-07 07:38:09 +00:00
expect(url.hash).toContain('/sale');
});
2019-01-07 08:33:07 +00:00
it('should try to add a higher quantity value and then receive an error', async() => {
2018-11-07 07:38:09 +00:00
const result = await nightmare
2019-02-26 16:32:32 +00:00
.waitToFocus(selectors.ticketSales.firstSaleQuantityCell)
2019-01-23 14:33:25 +00:00
.write(selectors.ticketSales.firstSaleQuantity, '9\u000d')
2018-11-07 07:38:09 +00:00
.waitForLastSnackbar();
expect(result).toEqual('The new quantity should be smaller than the old one');
});
2019-01-07 08:33:07 +00:00
it('should remove 1 from quantity', async() => {
2018-11-07 07:38:09 +00:00
const result = await nightmare
2019-02-26 16:32:32 +00:00
.waitToFocus(selectors.ticketSales.firstSaleQuantityCell)
2019-01-23 14:33:25 +00:00
.write(selectors.ticketSales.firstSaleQuantity, '4\u000d')
2018-11-07 07:38:09 +00:00
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
2019-01-07 08:33:07 +00:00
it('should update the price', async() => {
2018-11-07 07:38:09 +00:00
const result = await nightmare
2018-10-25 14:44:03 +00:00
.waitToClick(selectors.ticketSales.firstSalePrice)
2019-02-19 11:28:39 +00:00
.write(selectors.ticketSales.firstSalePriceInput, '5\u000d')
2018-11-07 07:38:09 +00:00
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
2019-01-07 08:33:07 +00:00
it('should confirm the price have been updated', async() => {
2018-11-07 07:38:09 +00:00
const result = await nightmare
.waitToGetProperty(selectors.ticketSales.firstSalePrice, 'innerText');
2018-11-07 07:38:09 +00:00
expect(result).toContain('5.00');
});
2019-01-07 08:33:07 +00:00
it('should confirm the total price for that item have been updated', async() => {
2018-11-07 07:38:09 +00:00
const result = await nightmare
.waitToGetProperty(selectors.ticketSales.firstSaleImport, 'innerText');
2018-11-07 07:38:09 +00:00
expect(result).toContain('20.00');
});
2019-01-07 08:33:07 +00:00
it('should update the discount', async() => {
2018-11-07 07:38:09 +00:00
const result = await nightmare
2018-10-25 14:44:03 +00:00
.waitToClick(selectors.ticketSales.firstSaleDiscount)
2019-02-19 11:28:39 +00:00
.write(selectors.ticketSales.firstSaleDiscountInput, '50\u000d')
// .write('body', '\u000d') // simulates enter
2018-11-07 07:38:09 +00:00
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
2019-01-07 08:33:07 +00:00
it('should confirm the discount have been updated', async() => {
2018-11-07 07:38:09 +00:00
const result = await nightmare
2018-10-25 14:44:03 +00:00
.waitForTextInElement(selectors.ticketSales.firstSaleDiscount, '50 %')
.waitToGetProperty(selectors.ticketSales.firstSaleDiscount, 'innerText');
2018-11-07 07:38:09 +00:00
expect(result).toContain('50 %');
2018-10-25 14:44:03 +00:00
});
2019-01-07 08:33:07 +00:00
it('should confirm the total import for that item have been updated', async() => {
2018-11-07 07:38:09 +00:00
const result = await nightmare
2018-10-25 14:44:03 +00:00
.waitForTextInElement(selectors.ticketSales.firstSaleImport, '10.00')
.waitToGetProperty(selectors.ticketSales.firstSaleImport, 'innerText');
2018-11-07 07:38:09 +00:00
expect(result).toContain('10.00');
2018-10-25 14:44:03 +00:00
});
2019-01-07 08:33:07 +00:00
it('should select the third sale and create a claim of it', async() => {
2018-11-07 07:38:09 +00:00
const url = await nightmare
2018-10-25 14:44:03 +00:00
.waitToClick(selectors.ticketSales.thirdSaleCheckbox)
.waitToClick(selectors.ticketSales.moreMenuButton)
.waitToClick(selectors.ticketSales.moreMenuCreateClaim)
2019-01-07 08:33:07 +00:00
.wait(selectors.claimBasicData.claimStateAutocomplete)
2018-11-07 07:38:09 +00:00
.parsedUrl();
expect(url.hash).toEqual('#!/claim/5/basic-data');
});
2019-01-07 08:33:07 +00:00
it('should click on the Claims button of the top bar menu', async() => {
2018-11-07 07:38:09 +00:00
const url = await nightmare
2018-10-25 14:44:03 +00:00
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.claimsButton)
.wait(selectors.claimsIndex.searchClaimInput)
2018-11-07 07:38:09 +00:00
.parsedUrl();
expect(url.hash).toEqual('#!/claim/index');
2018-10-25 14:44:03 +00:00
});
2019-01-07 08:33:07 +00:00
it('should search for the claim with id 4', async() => {
2018-11-07 07:38:09 +00:00
const result = await nightmare
2019-01-23 14:33:25 +00:00
.write(selectors.claimsIndex.searchClaimInput, 4)
2019-01-23 15:00:56 +00:00
.waitToClick(selectors.claimsIndex.searchButton)
2018-10-25 14:44:03 +00:00
.waitForNumberOfElements(selectors.claimsIndex.searchResult, 1)
2018-11-07 07:38:09 +00:00
.countElement(selectors.claimsIndex.searchResult);
expect(result).toEqual(1);
});
2019-01-07 08:33:07 +00:00
it('should click the Tickets button of the top bar menu', async() => {
2018-11-07 07:38:09 +00:00
const url = await nightmare
2018-10-25 14:44:03 +00:00
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.ticketsButton)
.wait(selectors.ticketsIndex.searchTicketInput)
2018-11-07 07:38:09 +00:00
.parsedUrl();
expect(url.hash).toEqual('#!/ticket/index');
2018-10-25 14:44:03 +00:00
});
2019-01-07 08:33:07 +00:00
it('should search the ticket', async() => {
2018-11-07 07:38:09 +00:00
const result = await nightmare
2019-02-07 13:33:52 +00:00
.write(selectors.ticketsIndex.searchTicketInput, '16')
2019-01-23 15:00:56 +00:00
.waitToClick(selectors.ticketsIndex.searchButton)
2018-10-25 14:44:03 +00:00
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
2018-11-07 07:38:09 +00:00
.countElement(selectors.ticketsIndex.searchResult);
expect(result).toEqual(1);
});
2019-01-07 08:33:07 +00:00
it(`should click on the result to access to the ticket Sale`, async() => {
2018-11-07 07:38:09 +00:00
const url = await nightmare
2018-10-25 14:44:03 +00:00
.waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21')
.waitToClick(selectors.ticketsIndex.searchResult)
.waitToClick(selectors.ticketSales.saleButton)
.waitForURL('/sale')
.parsedUrl();
2018-11-07 07:38:09 +00:00
expect(url.hash).toContain('/sale');
2018-10-22 15:12:41 +00:00
});
2019-01-07 08:33:07 +00:00
it('should select the third sale and delete it', async() => {
2018-11-07 07:38:09 +00:00
const result = await nightmare
2018-10-25 14:44:03 +00:00
.waitToClick(selectors.ticketSales.thirdSaleCheckbox)
.waitToClick(selectors.ticketSales.deleteSaleButton)
.waitToClick(selectors.ticketSales.acceptDeleteLineButton)
2018-11-07 07:38:09 +00:00
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
2018-10-25 14:44:03 +00:00
});
2018-10-22 15:12:41 +00:00
2019-01-07 08:33:07 +00:00
it(`should confirm the third sale was deleted`, async() => {
2018-11-07 07:38:09 +00:00
const result = await nightmare
.countElement(selectors.ticketSales.saleLine);
expect(result).toEqual(3);
});
2019-01-07 08:33:07 +00:00
it('should select the third sale and attempt to send it to a frozen client ticket', async() => {
2018-11-07 07:38:09 +00:00
const result = await nightmare
2018-10-25 14:44:03 +00:00
.waitToClick(selectors.ticketSales.thirdSaleCheckbox)
.waitToClick(selectors.ticketSales.transferSaleButton)
2019-01-23 14:33:25 +00:00
.write(selectors.ticketSales.moveToTicketInput, 2)
2018-10-25 14:44:03 +00:00
.waitToClick(selectors.ticketSales.moveToTicketButton)
2018-11-07 07:38:09 +00:00
.waitForLastSnackbar();
expect(result).toEqual(`The sales of this ticket can't be modified`);
2018-10-25 14:44:03 +00:00
});
it('should transfer the third sale to a valid ticket', async() => {
2018-11-07 07:38:09 +00:00
const result = await nightmare
2018-10-25 14:44:03 +00:00
.waitToClick(selectors.ticketSales.moveToTicketInputClearButton)
2019-01-23 14:33:25 +00:00
.write(selectors.ticketSales.moveToTicketInput, 12)
2018-10-25 14:44:03 +00:00
.waitToClick(selectors.ticketSales.moveToTicketButton)
.waitForURL('ticket/12/sale')
.parsedUrl();
2018-11-07 07:38:09 +00:00
expect(result.hash).toContain(`ticket/12/sale`);
2018-10-25 14:44:03 +00:00
});
2019-01-07 08:33:07 +00:00
it('should confirm the transfered line is the correct one', async() => {
2018-11-07 07:38:09 +00:00
const result = await nightmare
2018-10-25 14:44:03 +00:00
.wait(selectors.ticketSales.firstSaleText)
.waitToGetProperty(selectors.ticketSales.firstSaleText, 'innerText');
2018-11-07 07:38:09 +00:00
2019-03-27 07:44:15 +00:00
expect(result).toContain(`Melee weapon heavy shield 1x0.5m`);
2018-10-25 14:44:03 +00:00
});
2019-01-07 08:33:07 +00:00
it('should go back to the original ticket sales section', async() => {
2018-11-07 07:38:09 +00:00
const url = await nightmare
2018-10-25 14:44:03 +00:00
.waitToClick(selectors.itemsIndex.goBackToModuleIndexButton)
2019-02-19 11:28:39 +00:00
.write(selectors.ticketsIndex.searchTicketInput, '16')
2019-01-23 15:00:56 +00:00
.waitToClick(selectors.ticketsIndex.searchButton)
2018-10-25 14:44:03 +00:00
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
.waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21')
.waitToClick(selectors.ticketsIndex.searchResult)
.waitToClick(selectors.ticketSales.saleButton)
.waitForURL('/sale')
.parsedUrl();
2018-11-07 07:38:09 +00:00
expect(url.hash).toContain('/sale');
2018-10-25 14:44:03 +00:00
});
2019-01-07 08:33:07 +00:00
it(`should confirm the original ticket has only two lines now`, async() => {
2018-11-07 07:38:09 +00:00
const result = await nightmare
2018-10-25 14:44:03 +00:00
.wait(selectors.ticketSales.saleLine)
2018-11-07 07:38:09 +00:00
.countElement(selectors.ticketSales.saleLine);
expect(result).toEqual(2);
2018-10-25 14:44:03 +00:00
});
2019-01-07 08:33:07 +00:00
it('should go back to the receiver ticket sales section', async() => {
2018-11-07 07:38:09 +00:00
const url = await nightmare
2018-10-25 14:44:03 +00:00
.waitToClick(selectors.itemsIndex.goBackToModuleIndexButton)
2019-01-23 14:33:25 +00:00
.write(selectors.ticketsIndex.searchTicketInput, 'id:12')
2019-01-23 15:00:56 +00:00
.waitToClick(selectors.ticketsIndex.searchButton)
2018-10-25 14:44:03 +00:00
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
.waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21')
.waitToClick(selectors.ticketsIndex.searchResult)
.waitToClick(selectors.ticketSales.saleButton)
.waitForURL('/sale')
.parsedUrl();
2018-11-07 07:38:09 +00:00
expect(url.hash).toContain('/sale');
2018-10-25 14:44:03 +00:00
});
2019-01-07 08:33:07 +00:00
it('should transfer the sale back to the original ticket', async() => {
2018-11-07 07:38:09 +00:00
const result = await nightmare
2018-10-25 14:44:03 +00:00
.waitToClick(selectors.ticketSales.firstSaleCheckbox)
.waitToClick(selectors.ticketSales.transferSaleButton)
.write(selectors.ticketSales.moveToTicketInput, '16')
2018-10-25 14:44:03 +00:00
.waitToClick(selectors.ticketSales.moveToTicketButton)
.waitForURL('ticket/16/sale')
.parsedUrl();
2018-11-07 07:38:09 +00:00
expect(result.hash).toContain(`ticket/16/sale`);
2018-10-25 14:44:03 +00:00
});
2019-01-07 08:33:07 +00:00
it('should confirm the original ticket received the line', async() => {
2018-11-07 07:38:09 +00:00
const result = await nightmare
// .waitForNumberOfElements(selectors.ticketSales.saleLine, 3)
2018-11-07 07:38:09 +00:00
.countElement(selectors.ticketSales.saleLine);
expect(result).toEqual(3);
2018-10-25 14:44:03 +00:00
});
2019-01-14 10:19:39 +00:00
it('should now go back to the original ticket sales section', async() => {
2018-11-29 13:24:57 +00:00
const url = await nightmare
.waitToClick(selectors.itemsIndex.goBackToModuleIndexButton)
2019-01-23 14:33:25 +00:00
.write(selectors.ticketsIndex.searchTicketInput, 'id:8')
2019-01-23 15:00:56 +00:00
.waitToClick(selectors.ticketsIndex.searchButton)
2018-11-29 13:24:57 +00:00
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
.waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 24')
.waitToClick(selectors.ticketsIndex.searchResult)
.waitToClick(selectors.ticketSales.saleButton)
.waitForURL('/sale')
.parsedUrl();
expect(url.hash).toContain('/sale');
});
2019-01-07 08:33:07 +00:00
it('should select the second and third sale and tranfer them to a new ticket then get to the ticket index', async() => {
2018-11-07 07:38:09 +00:00
const url = await nightmare
2018-11-29 13:24:57 +00:00
.waitToClick(selectors.ticketSales.firstSaleCheckbox)
2018-10-25 14:44:03 +00:00
.waitToClick(selectors.ticketSales.transferSaleButton)
.waitToClick(selectors.ticketSales.moveToNewTicketButton)
2019-01-23 14:33:25 +00:00
.resetLogin()
.waitForLogin('salesPerson')
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.ticketsButton)
.wait(selectors.ticketsIndex.searchTicketInput)
2018-11-07 07:38:09 +00:00
.parsedUrl();
expect(url.hash).toEqual('#!/ticket/index');
2018-10-25 14:44:03 +00:00
});
2019-01-07 08:33:07 +00:00
it('should search for a specific created ticket', async() => {
2018-11-07 07:38:09 +00:00
const result = await nightmare
2019-01-23 14:33:25 +00:00
.write(selectors.ticketsIndex.searchTicketInput, 'nickname:(address 24) stateFk:2')
2019-01-23 15:00:56 +00:00
.waitToClick(selectors.ticketsIndex.searchButton)
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
2018-11-07 07:38:09 +00:00
.countElement(selectors.ticketsIndex.searchResult);
expect(result).toEqual(1);
2018-10-25 14:44:03 +00:00
});
2019-01-07 08:33:07 +00:00
it(`should click on the search result to access to the ticket Sale once more`, async() => {
2018-11-07 07:38:09 +00:00
const url = await nightmare
2018-11-29 13:24:57 +00:00
.waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 24')
.waitToClick(selectors.ticketsIndex.searchResult)
.waitToClick(selectors.ticketSales.saleButton)
.waitForURL('/sale')
.parsedUrl();
2018-11-07 07:38:09 +00:00
expect(url.hash).toContain('/sale');
});
2019-01-07 08:33:07 +00:00
it('should confirm the new ticket received both lines', async() => {
2018-11-07 07:38:09 +00:00
const result = await nightmare
.countElement(selectors.ticketSales.saleLine);
2018-11-29 13:24:57 +00:00
expect(result).toEqual(1);
2018-10-25 14:44:03 +00:00
});
2019-01-07 08:33:07 +00:00
it('should check the first sale reserved icon isnt visible', async() => {
2018-11-07 07:38:09 +00:00
const result = await nightmare
.isVisible(selectors.ticketSales.firstSaleReservedIcon);
expect(result).toBeFalsy();
2018-10-25 14:44:03 +00:00
});
2019-01-07 08:33:07 +00:00
it('should mark the first sale as reserved', async() => {
2018-11-07 07:38:09 +00:00
const result = await nightmare
2018-10-25 14:44:03 +00:00
.waitToClick(selectors.ticketSales.firstSaleCheckbox)
.waitToClick(selectors.ticketSales.moreMenuButton)
.waitToClick(selectors.ticketSales.moreMenuReseveOption)
.waitForClassNotPresent(selectors.ticketSales.firstSaleReservedIcon, 'ng-hide')
2018-11-07 07:38:09 +00:00
.isVisible(selectors.ticketSales.firstSaleReservedIcon);
expect(result).toBeTruthy();
2018-10-25 14:44:03 +00:00
});
2019-01-07 08:33:07 +00:00
it('should unmark the first sale as reserved', async() => {
2018-11-07 07:38:09 +00:00
const result = await nightmare
2018-10-25 14:44:03 +00:00
.waitToClick(selectors.ticketSales.firstSaleCheckbox)
.waitToClick(selectors.ticketSales.moreMenuButton)
.waitToClick(selectors.ticketSales.moreMenuUnmarkResevedOption)
.waitForClassPresent(selectors.ticketSales.firstSaleReservedIcon, 'ng-hide')
2018-11-07 07:38:09 +00:00
.isVisible(selectors.ticketSales.firstSaleReservedIcon);
expect(result).toBeFalsy();
});
2019-01-07 08:33:07 +00:00
it('should update all sales discount', async() => {
2018-11-07 07:38:09 +00:00
const result = await nightmare
.waitToClick(selectors.ticketSales.selectAllSalesCheckbox)
.waitToClick(selectors.ticketSales.moreMenuButton)
.waitToClick(selectors.ticketSales.moreMenuUpdateDiscount)
2019-01-23 14:33:25 +00:00
.write(selectors.ticketSales.moreMenuUpdateDiscountInput, 100)
.write('body', '\u000d')
2018-11-07 07:38:09 +00:00
.waitForTextInElement(selectors.ticketSales.totalImport, '0.00')
.waitToGetProperty(selectors.ticketSales.totalImport, 'innerText');
2018-11-07 07:38:09 +00:00
expect(result).toContain('0.00');
});
2019-01-07 08:33:07 +00:00
it('should log in as Production role and go to the ticket index', async() => {
2018-11-07 07:38:09 +00:00
const url = await nightmare
2018-10-25 14:44:03 +00:00
.waitForLogin('production')
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.ticketsButton)
.wait(selectors.ticketsIndex.searchTicketInput)
2018-11-07 07:38:09 +00:00
.parsedUrl();
expect(url.hash).toEqual('#!/ticket/index');
2018-10-25 14:44:03 +00:00
});
2019-01-07 08:33:07 +00:00
it('should now search for a specific ticket', async() => {
2018-11-07 07:38:09 +00:00
const result = await nightmare
2019-02-19 11:28:39 +00:00
.write(selectors.ticketsIndex.searchTicketInput, '16')
2019-01-23 15:00:56 +00:00
.waitToClick(selectors.ticketsIndex.searchButton)
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
2018-11-07 07:38:09 +00:00
.countElement(selectors.ticketsIndex.searchResult);
expect(result).toEqual(1);
2018-10-25 14:44:03 +00:00
});
2019-01-07 08:33:07 +00:00
it(`should now click on the search result to access to the ticket Tracking`, async() => {
2018-11-07 07:38:09 +00:00
const url = await nightmare
2018-10-25 14:44:03 +00:00
.waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21')
.waitToClick(selectors.ticketsIndex.searchResult)
2018-10-25 14:44:03 +00:00
.waitToClick(selectors.ticketTracking.trackingButton)
.waitForURL('/tracking/index')
.parsedUrl();
2018-11-07 07:38:09 +00:00
expect(url.hash).toContain('/tracking/index');
2018-10-25 14:44:03 +00:00
});
2019-01-07 08:33:07 +00:00
it(`should click on the edit ticket tracking state button`, async() => {
2018-11-07 07:38:09 +00:00
const url = await nightmare
2018-10-25 14:44:03 +00:00
.waitToClick(selectors.ticketTracking.createStateButton)
.waitForURL('/tracking/edit')
.parsedUrl();
2018-11-07 07:38:09 +00:00
expect(url.hash).toContain('/tracking/edit');
2018-10-25 14:44:03 +00:00
});
2019-01-07 08:33:07 +00:00
it(`should set the state of the ticket to preparation`, async() => {
2018-11-07 07:38:09 +00:00
const url = await nightmare
2019-01-07 09:55:23 +00:00
.autocompleteSearch(selectors.ticketTracking.stateAutocomplete, 'Preparación')
2019-01-23 15:00:56 +00:00
.waitToClick(selectors.ticketTracking.saveButton)
2018-10-25 14:44:03 +00:00
.waitForURL('/tracking/index')
.parsedUrl();
2018-11-07 07:38:09 +00:00
expect(url.hash).toContain('/tracking/index');
2018-10-25 14:44:03 +00:00
});
2019-01-07 08:33:07 +00:00
it(`should click on the ticket Sale menu button`, async() => {
2018-11-07 07:38:09 +00:00
const url = await nightmare
.waitToClick(selectors.ticketSales.saleButton)
.waitForURL('/sale')
.parsedUrl();
2018-11-07 07:38:09 +00:00
expect(url.hash).toContain('/sale');
2018-10-25 14:44:03 +00:00
});
describe('when state is preparation and loged as Production', () => {
2019-01-07 08:33:07 +00:00
it(`should not be able to edit the sale price`, async() => {
2018-11-07 07:38:09 +00:00
const result = await nightmare
2019-02-20 16:52:36 +00:00
.wait(selectors.ticketSales.firstSaleID)
.exists(selectors.ticketSales.firstSalePrice);
2018-11-07 07:38:09 +00:00
expect(result).toBeFalsy();
});
2019-01-07 08:33:07 +00:00
it(`should not be able to edit the sale discount`, async() => {
2018-11-07 07:38:09 +00:00
const result = await nightmare
2019-02-20 16:52:36 +00:00
.waitToClick(selectors.ticketSales.firstSaleID)
.exists(selectors.ticketSales.firstSaleDiscount);
2018-11-07 07:38:09 +00:00
expect(result).toBeFalsy();
});
2019-01-07 08:33:07 +00:00
it(`should not be able to edit the sale state`, async() => {
2018-11-07 07:38:09 +00:00
const result = await nightmare
2018-10-25 14:44:03 +00:00
.waitToClick(selectors.ticketSales.stateMenuButton)
2018-11-07 07:38:09 +00:00
.exists(selectors.ticketSales.stateMenuOptions);
expect(result).toBeFalsy();
});
2019-01-07 08:33:07 +00:00
it('should log in as salesPerson role and go to the ticket index', async() => {
2018-11-07 07:38:09 +00:00
const url = await nightmare
2018-10-25 14:44:03 +00:00
.waitForLogin('salesPerson')
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.ticketsButton)
.wait(selectors.ticketsIndex.searchTicketInput)
2018-11-07 07:38:09 +00:00
.parsedUrl();
expect(url.hash).toEqual('#!/ticket/index');
2018-10-25 14:44:03 +00:00
});
2019-01-07 08:33:07 +00:00
it('should once again search for a specific ticket', async() => {
2018-11-07 07:38:09 +00:00
const result = await nightmare
2019-02-19 11:28:39 +00:00
.write(selectors.ticketsIndex.searchTicketInput, '16')
2019-01-23 15:00:56 +00:00
.waitToClick(selectors.ticketsIndex.searchButton)
2018-10-25 14:44:03 +00:00
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
2018-11-07 07:38:09 +00:00
.countElement(selectors.ticketsIndex.searchResult);
expect(result).toEqual(1);
2018-10-25 14:44:03 +00:00
});
2018-11-14 14:12:09 +00:00
2019-01-07 08:33:07 +00:00
it(`should click on the search result to access to the ticket Sale once again`, async() => {
2018-11-14 14:12:09 +00:00
const url = await nightmare
.waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21')
.waitToClick(selectors.ticketsIndex.searchResult)
.waitToClick(selectors.ticketSales.saleButton)
.waitForURL('/sale')
.parsedUrl();
2018-11-14 14:12:09 +00:00
expect(url.hash).toContain('/sale');
2018-11-14 14:12:09 +00:00
});
2018-10-25 14:44:03 +00:00
});
describe('when state is preparation and loged as salesPerson', () => {
2019-01-07 08:33:07 +00:00
it(`shouldnt be able to edit the sale price`, async() => {
2018-11-07 07:38:09 +00:00
const result = await nightmare
2019-02-26 16:32:32 +00:00
.waitToClick(selectors.ticketSales.firstSaleID)
.exists(selectors.ticketSales.firstSalePrice);
2018-11-07 07:38:09 +00:00
expect(result).toBeFalsy();
2018-10-25 14:44:03 +00:00
});
2019-01-07 08:33:07 +00:00
it(`shouldnt be able to edit the sale discount`, async() => {
2018-11-07 07:38:09 +00:00
const result = await nightmare
2019-02-26 16:32:32 +00:00
.waitToClick(selectors.ticketSales.firstSaleID)
.exists(selectors.ticketSales.firstSaleDiscount);
2018-11-07 07:38:09 +00:00
expect(result).toBeFalsy();
2018-10-25 14:44:03 +00:00
});
2019-01-07 08:33:07 +00:00
it(`shouldnt be able to edit the sale state`, async() => {
2018-11-07 07:38:09 +00:00
const result = await nightmare
2018-10-25 14:44:03 +00:00
.waitToClick(selectors.ticketSales.stateMenuButton)
2018-11-07 07:38:09 +00:00
.exists(selectors.ticketSales.stateMenuOptions);
expect(result).toBeFalsy();
2018-10-25 14:44:03 +00:00
});
2018-11-08 14:20:42 +00:00
});
});