#1387 e2e Ticket Edit sale path
gitea/salix/dev This commit looks good Details

This commit is contained in:
Carlos Jimenez Ruiz 2019-06-27 08:41:07 +02:00
parent 5270693bdd
commit d94ca9c538
3 changed files with 117 additions and 235 deletions

View File

@ -394,9 +394,9 @@ export default {
firstSaleQuantityCell: 'vn-ticket-sale vn-tr:nth-child(1) > vn-td-editable', firstSaleQuantityCell: 'vn-ticket-sale vn-tr:nth-child(1) > vn-td-editable',
firstSaleQuantityClearInput: 'vn-textfield[model="sale.quantity"] div.suffix > i', firstSaleQuantityClearInput: 'vn-textfield[model="sale.quantity"] div.suffix > i',
firstSaleID: 'vn-ticket-sale:nth-child(1) vn-td:nth-child(4) > span', firstSaleID: 'vn-ticket-sale:nth-child(1) vn-td:nth-child(4) > span',
firstSalePrice: 'vn-ticket-sale:nth-child(1) vn-tr:nth-child(1) > vn-td:nth-child(7) > span', firstSalePrice: 'vn-ticket-sale:nth-child(1) vn-tr:nth-child(1) > vn-td:nth-child(7)',
firstSalePriceInput: 'vn-ticket-sale:nth-child(1) vn-popover.edit.dialog-summary.ng-isolate-scope.vn-popover.shown vn-input-number input', firstSalePriceInput: 'vn-ticket-sale:nth-child(1) vn-popover.edit.dialog-summary.ng-isolate-scope.vn-popover.shown vn-input-number input',
firstSaleDiscount: 'vn-ticket-sale:nth-child(1) vn-td:nth-child(8) > span', firstSaleDiscount: 'vn-ticket-sale:nth-child(1) vn-td:nth-child(8)',
firstSaleDiscountInput: 'vn-ticket-sale:nth-child(1) vn-ticket-sale-edit-discount vn-input-number input', firstSaleDiscountInput: 'vn-ticket-sale:nth-child(1) vn-ticket-sale-edit-discount vn-input-number input',
firstSaleImport: 'vn-ticket-sale:nth-child(1) vn-td:nth-child(9)', firstSaleImport: 'vn-ticket-sale:nth-child(1) vn-td:nth-child(9)',
firstSaleReservedIcon: 'vn-ticket-sale vn-tr:nth-child(1) > vn-td:nth-child(2) > vn-icon:nth-child(3)', firstSaleReservedIcon: 'vn-ticket-sale vn-tr:nth-child(1) > vn-td:nth-child(2) > vn-icon:nth-child(3)',

View File

@ -1,28 +1,26 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare'; import createNightmare from '../../helpers/nightmare';
// #1387 e2e Ticket Edit sale path describe('Ticket Edit sale path', () => {
xdescribe('Ticket Edit sale path', () => {
const nightmare = createNightmare(); const nightmare = createNightmare();
beforeAll(() => { beforeAll(() => {
nightmare nightmare
.loginAndModule('salesPerson', 'ticket') .loginAndModule('salesPerson', 'ticket')
.accessToSearchResult('16') .accessToSearchResult(16)
.accessToSection('ticket.card.sale'); .accessToSection('ticket.card.sale');
}); });
it(`should click on the second claim id to navigate over there`, async() => { it(`should click on the first sale claim icon to navigate over there`, async() => {
const url = await nightmare const url = await nightmare
.waitToClick(selectors.ticketSales.secondSaleClaimIcon) .waitToClick(selectors.ticketSales.firstSaleClaimIcon)
.wait(selectors.claimBasicData.claimStateAutocomplete) .wait(selectors.claimBasicData.claimStateAutocomplete)
.parsedUrl(); .parsedUrl();
expect(url.hash).toEqual('#!/claim/2/basic-data'); expect(url.hash).toEqual('#!/claim/2/basic-data');
}); });
it('should navigate to the tickets index', async() => {
it('should now click on the Tickets button of the top bar menu', async() => {
const url = await nightmare const url = await nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton) .waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible) .wait(selectors.globalItems.applicationsMenuVisible)
@ -33,28 +31,17 @@ xdescribe('Ticket Edit sale path', () => {
expect(url.hash).toEqual('#!/ticket/index'); expect(url.hash).toEqual('#!/ticket/index');
}); });
it('should again search for a specific ticket', async() => { it(`should search for a ticket and then navigate to it's sales`, async() => {
const result = await nightmare
.write(selectors.ticketsIndex.searchTicketInput, '16')
.waitToClick(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 Sale`, async() => {
const url = await nightmare const url = await nightmare
.waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21') .accessToSearchResult(16)
.waitToClick(selectors.ticketsIndex.searchResult) .accessToSection('ticket.card.sale')
.waitToClick(selectors.ticketSales.saleButton)
.waitForURL('/sale') .waitForURL('/sale')
.parsedUrl(); .parsedUrl();
expect(url.hash).toContain('/sale'); expect(url.hash).toContain('/sale');
}); });
it(`should check the zoomed image isnt present`, async() => { it(`should check the zoomed image isn't present`, async() => {
const result = await nightmare const result = await nightmare
.countElement(selectors.ticketSales.firstSaleZoomedImage); .countElement(selectors.ticketSales.firstSaleZoomedImage);
@ -71,7 +58,7 @@ xdescribe('Ticket Edit sale path', () => {
it(`should click on the zoomed image to close it`, async() => { it(`should click on the zoomed image to close it`, async() => {
const result = await nightmare const result = await nightmare
.wait(1000) .wait(100)
.clickIfVisible(selectors.ticketSales.firstSaleZoomedImage) .clickIfVisible(selectors.ticketSales.firstSaleZoomedImage)
.countElement(selectors.ticketSales.firstSaleZoomedImage); .countElement(selectors.ticketSales.firstSaleZoomedImage);
@ -124,12 +111,8 @@ xdescribe('Ticket Edit sale path', () => {
.waitToClick(selectors.globalItems.applicationsMenuButton) .waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible) .wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.ticketsButton) .waitToClick(selectors.globalItems.ticketsButton)
.write(selectors.ticketsIndex.searchTicketInput, '16') .accessToSearchResult(16)
.waitToClick(selectors.ticketsIndex.searchButton) .accessToSection('ticket.card.sale')
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
.waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21')
.waitToClick(selectors.ticketsIndex.searchResult)
.waitToClick(selectors.ticketSales.saleButton)
.waitForURL('/sale') .waitForURL('/sale')
.parsedUrl(); .parsedUrl();
@ -138,17 +121,17 @@ xdescribe('Ticket Edit sale path', () => {
it('should try to add a higher quantity value and then receive an error', async() => { it('should try to add a higher quantity value and then receive an error', async() => {
const result = await nightmare const result = await nightmare
.waitToFocus(selectors.ticketSales.firstSaleQuantityCell) .focusElement(selectors.ticketSales.firstSaleQuantityCell)
.write(selectors.ticketSales.firstSaleQuantity, '9\u000d') .write(selectors.ticketSales.firstSaleQuantity, '11\u000d')
.waitForLastSnackbar(); .waitForLastSnackbar();
expect(result).toEqual('The new quantity should be smaller than the old one'); expect(result).toEqual('The new quantity should be smaller than the old one');
}); });
it('should remove 1 from quantity', async() => { it('should remove 1 from the first sale quantity', async() => {
const result = await nightmare const result = await nightmare
.waitToFocus(selectors.ticketSales.firstSaleQuantityCell) .focusElement(selectors.ticketSales.firstSaleQuantityCell)
.write(selectors.ticketSales.firstSaleQuantity, '4\u000d') .write(selectors.ticketSales.firstSaleQuantity, '9\u000d')
.waitForLastSnackbar(); .waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
@ -156,7 +139,7 @@ xdescribe('Ticket Edit sale path', () => {
it('should update the price', async() => { it('should update the price', async() => {
const result = await nightmare const result = await nightmare
.waitToClick(selectors.ticketSales.firstSalePrice) .waitToClick(`${selectors.ticketSales.firstSalePrice} > span`)
.write(selectors.ticketSales.firstSalePriceInput, '5\u000d') .write(selectors.ticketSales.firstSalePriceInput, '5\u000d')
.waitForLastSnackbar(); .waitForLastSnackbar();
@ -165,7 +148,7 @@ xdescribe('Ticket Edit sale path', () => {
it('should confirm the price have been updated', async() => { it('should confirm the price have been updated', async() => {
const result = await nightmare const result = await nightmare
.waitToGetProperty(selectors.ticketSales.firstSalePrice, 'innerText'); .waitToGetProperty(`${selectors.ticketSales.firstSalePrice} span`, 'innerText');
expect(result).toContain('5.00'); expect(result).toContain('5.00');
}); });
@ -174,14 +157,13 @@ xdescribe('Ticket Edit sale path', () => {
const result = await nightmare const result = await nightmare
.waitToGetProperty(selectors.ticketSales.firstSaleImport, 'innerText'); .waitToGetProperty(selectors.ticketSales.firstSaleImport, 'innerText');
expect(result).toContain('20.00'); expect(result).toContain('45.00');
}); });
it('should update the discount', async() => { it('should update the discount', async() => {
const result = await nightmare const result = await nightmare
.waitToClick(selectors.ticketSales.firstSaleDiscount) .waitToClick(`${selectors.ticketSales.firstSaleDiscount} > span`)
.write(selectors.ticketSales.firstSaleDiscountInput, '50\u000d') .write(selectors.ticketSales.firstSaleDiscountInput, '50\u000d')
// .write('body', '\u000d') // simulates enter
.waitForLastSnackbar(); .waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
@ -189,29 +171,29 @@ xdescribe('Ticket Edit sale path', () => {
it('should confirm the discount have been updated', async() => { it('should confirm the discount have been updated', async() => {
const result = await nightmare const result = await nightmare
.waitForTextInElement(selectors.ticketSales.firstSaleDiscount, '50 %') .waitForTextInElement(`${selectors.ticketSales.firstSaleDiscount} > span`, '50 %')
.waitToGetProperty(selectors.ticketSales.firstSaleDiscount, 'innerText'); .waitToGetProperty(`${selectors.ticketSales.firstSaleDiscount} > span`, 'innerText');
expect(result).toContain('50 %'); expect(result).toContain('50 %');
}); });
it('should confirm the total import for that item have been updated', async() => { it('should confirm the total import for that item have been updated', async() => {
const result = await nightmare const result = await nightmare
.waitForTextInElement(selectors.ticketSales.firstSaleImport, '10.00') .waitForTextInElement(selectors.ticketSales.firstSaleImport, '22.50')
.waitToGetProperty(selectors.ticketSales.firstSaleImport, 'innerText'); .waitToGetProperty(selectors.ticketSales.firstSaleImport, 'innerText');
expect(result).toContain('10.00'); expect(result).toContain('22.50');
}); });
it('should select the third sale and create a claim of it', async() => { it('should select the third sale and create a claim of it', async() => {
const url = await nightmare const url = await nightmare
.waitToClick(selectors.ticketSales.thirdSaleCheckbox) .waitToClick(selectors.ticketSales.thirdSaleCheckbox)
.waitToClick(selectors.ticketSales.moreMenuButton) .waitToClick(selectors.ticketSales.moreMenu)
.waitToClick(selectors.ticketSales.moreMenuCreateClaim) .waitToClick(selectors.ticketSales.moreMenuCreateClaim)
.wait(selectors.claimBasicData.claimStateAutocomplete) .wait(selectors.claimBasicData.claimStateAutocomplete)
.parsedUrl(); .parsedUrl();
expect(url.hash).toEqual('#!/claim/5/basic-data'); expect(url.hash).toContain('basic-data');
}); });
it('should click on the Claims button of the top bar menu', async() => { it('should click on the Claims button of the top bar menu', async() => {
@ -246,21 +228,10 @@ xdescribe('Ticket Edit sale path', () => {
expect(url.hash).toEqual('#!/ticket/index'); expect(url.hash).toEqual('#!/ticket/index');
}); });
it('should search the ticket', async() => { it('should search for a ticket then access to the sales section', async() => {
const result = await nightmare
.write(selectors.ticketsIndex.searchTicketInput, '16')
.waitToClick(selectors.ticketsIndex.searchButton)
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
.countElement(selectors.ticketsIndex.searchResult);
expect(result).toEqual(1);
});
it(`should click on the result to access to the ticket Sale`, async() => {
const url = await nightmare const url = await nightmare
.waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21') .accessToSearchResult(16)
.waitToClick(selectors.ticketsIndex.searchResult) .accessToSection('ticket.card.sale')
.waitToClick(selectors.ticketSales.saleButton)
.waitForURL('/sale') .waitForURL('/sale')
.parsedUrl(); .parsedUrl();
@ -284,45 +255,33 @@ xdescribe('Ticket Edit sale path', () => {
expect(result).toEqual(3); expect(result).toEqual(3);
}); });
it('should select the third sale and attempt to send it to a frozen client ticket', async() => { it('should select the third sale and transfer it to a valid ticket', async() => {
const targetTicketId = 12;
const result = await nightmare const result = await nightmare
.waitToClick(selectors.ticketSales.thirdSaleCheckbox) .waitToClick(selectors.ticketSales.thirdSaleCheckbox)
.waitToClick(selectors.ticketSales.transferSaleButton) .waitToClick(selectors.ticketSales.transferSaleButton)
.write(selectors.ticketSales.moveToTicketInput, 2) .write(selectors.ticketSales.moveToTicketInput, targetTicketId)
.waitToClick(selectors.ticketSales.moveToTicketButton) .waitToClick(selectors.ticketSales.moveToTicketButton)
.waitForLastSnackbar(); .waitForURL(`ticket/${targetTicketId}/sale`)
expect(result).toEqual(`The sales of this ticket can't be modified`);
});
it('should transfer the third sale to a valid ticket', async() => {
const result = await nightmare
.waitToClick(selectors.ticketSales.moveToTicketInputClearButton)
.write(selectors.ticketSales.moveToTicketInput, 12)
.waitToClick(selectors.ticketSales.moveToTicketButton)
.waitForURL('ticket/12/sale')
.parsedUrl(); .parsedUrl();
expect(result.hash).toContain(`ticket/12/sale`); expect(result.hash).toContain(`ticket/${targetTicketId}/sale`);
}); });
it('should confirm the transfered line is the correct one', async() => { it('should confirm the transfered line is the correct one', async() => {
const result = await nightmare const result = await nightmare
.wait(selectors.ticketSales.firstSaleText) .wait(selectors.ticketSales.secondSaleText)
.waitToGetProperty(selectors.ticketSales.firstSaleText, 'innerText'); .waitToGetProperty(selectors.ticketSales.secondSaleText, 'innerText');
expect(result).toContain(`Melee weapon heavy shield 1x0.5m`); expect(result).toContain(`Ranged weapon longbow 2m`);
}); });
it('should go back to the original ticket sales section', async() => { it('should go back to the original ticket sales section', async() => {
const url = await nightmare const url = await nightmare
.waitToClick(selectors.itemsIndex.goBackToModuleIndexButton) .waitToClick(selectors.ticketDescriptor.goBackToModuleIndexButton)
.write(selectors.ticketsIndex.searchTicketInput, '16') .accessToSearchResult(16)
.waitToClick(selectors.ticketsIndex.searchButton) .accessToSection('ticket.card.sale')
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
.waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21')
.waitToClick(selectors.ticketsIndex.searchResult)
.waitToClick(selectors.ticketSales.saleButton)
.waitForURL('/sale') .waitForURL('/sale')
.parsedUrl(); .parsedUrl();
@ -339,13 +298,9 @@ xdescribe('Ticket Edit sale path', () => {
it('should go back to the receiver ticket sales section', async() => { it('should go back to the receiver ticket sales section', async() => {
const url = await nightmare const url = await nightmare
.waitToClick(selectors.itemsIndex.goBackToModuleIndexButton) .waitToClick(selectors.ticketDescriptor.goBackToModuleIndexButton)
.write(selectors.ticketsIndex.searchTicketInput, 'id:12') .accessToSearchResult(12)
.waitToClick(selectors.ticketsIndex.searchButton) .accessToSection('ticket.card.sale')
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
.waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21')
.waitToClick(selectors.ticketsIndex.searchResult)
.waitToClick(selectors.ticketSales.saleButton)
.waitForURL('/sale') .waitForURL('/sale')
.parsedUrl(); .parsedUrl();
@ -353,78 +308,66 @@ xdescribe('Ticket Edit sale path', () => {
}); });
it('should transfer the sale back to the original ticket', async() => { it('should transfer the sale back to the original ticket', async() => {
const targetTicketId = 16;
const result = await nightmare const result = await nightmare
.waitToClick(selectors.ticketSales.firstSaleCheckbox) .waitToClick(selectors.ticketSales.secondSaleCheckbox)
.waitToClick(selectors.ticketSales.transferSaleButton) .waitToClick(selectors.ticketSales.transferSaleButton)
.write(selectors.ticketSales.moveToTicketInput, '16') .write(selectors.ticketSales.moveToTicketInput, targetTicketId)
.waitToClick(selectors.ticketSales.moveToTicketButton) .waitToClick(selectors.ticketSales.moveToTicketButton)
.waitForURL('ticket/16/sale') .waitForURL(`ticket/${targetTicketId}/sale`)
.parsedUrl(); .parsedUrl();
expect(result.hash).toContain(`ticket/16/sale`); expect(result.hash).toContain(`ticket/${targetTicketId}/sale`);
}); });
it('should confirm the original ticket received the line', async() => { it('should confirm the original ticket received the line', async() => {
const result = await nightmare const result = await nightmare
// .waitForNumberOfElements(selectors.ticketSales.saleLine, 3) .waitForNumberOfElements(selectors.ticketSales.saleLine, 3)
.countElement(selectors.ticketSales.saleLine); .countElement(selectors.ticketSales.saleLine);
expect(result).toEqual(3); expect(result).toEqual(3);
}); });
it('should now go back to the original ticket sales section', async() => { it(`should throw an error when attempting to create a ticket for an inactive client`, async() => {
const result = await nightmare
.waitToClick(selectors.ticketSales.firstSaleCheckbox)
.waitToClick(selectors.ticketSales.transferSaleButton)
.waitToClick(selectors.ticketSales.moveToNewTicketButton)
.waitToClick(selectors.ticketSales.acceptDeleteTicketButton)
.waitForLastSnackbar();
expect(result).toEqual(`You can't create a ticket for a inactive client`);
});
it('should go now to the ticket sales section of an active, not frozen client', async() => {
const url = await nightmare const url = await nightmare
.waitToClick(selectors.itemsIndex.goBackToModuleIndexButton) .waitToClick(selectors.ticketDescriptor.goBackToModuleIndexButton)
.write(selectors.ticketsIndex.searchTicketInput, 'id:8') .accessToSearchResult(13)
.waitToClick(selectors.ticketsIndex.searchButton) .accessToSection('ticket.card.sale')
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
.waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 24')
.waitToClick(selectors.ticketsIndex.searchResult)
.waitToClick(selectors.ticketSales.saleButton)
.waitForURL('/sale') .waitForURL('/sale')
.parsedUrl(); .parsedUrl();
expect(url.hash).toContain('/sale'); expect(url.hash).toContain('/sale');
}); });
it('should select the second and third sale and tranfer them to a new ticket then get to the ticket index', async() => { it(`should select all sales, tranfer them to a new ticket and delete the sender ticket as it would've been left empty`, async() => {
const senderTicketId = 13;
const url = await nightmare const url = await nightmare
.waitToClick(selectors.ticketSales.firstSaleCheckbox) .waitToClick(selectors.ticketSales.firstSaleCheckbox)
.waitToClick(selectors.ticketSales.transferSaleButton) .waitToClick(selectors.ticketSales.transferSaleButton)
.waitToClick(selectors.ticketSales.moveToNewTicketButton) .waitToClick(selectors.ticketSales.moveToNewTicketButton)
.resetLogin() .waitToClick(selectors.ticketSales.acceptDeleteTicketButton)
.waitForLogin('salesPerson') .wait((selector, ticketId) => {
.waitToClick(selectors.globalItems.applicationsMenuButton) return document.querySelector(selector).innerText.toLowerCase().indexOf(`${ticketId}`) == -1;
.wait(selectors.globalItems.applicationsMenuVisible) }, selectors.ticketDescriptor.idLabelValue, senderTicketId)
.waitToClick(selectors.globalItems.ticketsButton)
.wait(selectors.ticketsIndex.searchTicketInput)
.parsedUrl();
expect(url.hash).toEqual('#!/ticket/index');
});
it('should search for a specific created ticket', async() => {
const result = await nightmare
.write(selectors.ticketsIndex.searchTicketInput, 'nickname:(address 24) stateFk:2')
.waitToClick(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 Sale once more`, async() => {
const url = await nightmare
.waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 24')
.waitToClick(selectors.ticketsIndex.searchResult)
.waitToClick(selectors.ticketSales.saleButton)
.waitForURL('/sale')
.parsedUrl(); .parsedUrl();
expect(url.hash).toContain('/sale'); expect(url.hash).toContain('/sale');
}); });
it('should confirm the new ticket received both lines', async() => { it('should confirm the new ticket received the line', async() => {
const result = await nightmare const result = await nightmare
.countElement(selectors.ticketSales.saleLine); .countElement(selectors.ticketSales.saleLine);
@ -441,8 +384,8 @@ xdescribe('Ticket Edit sale path', () => {
it('should mark the first sale as reserved', async() => { it('should mark the first sale as reserved', async() => {
const result = await nightmare const result = await nightmare
.waitToClick(selectors.ticketSales.firstSaleCheckbox) .waitToClick(selectors.ticketSales.firstSaleCheckbox)
.waitToClick(selectors.ticketSales.moreMenuButton) .waitToClick(selectors.ticketSales.moreMenu)
.waitToClick(selectors.ticketSales.moreMenuReseveOption) .waitToClick(selectors.ticketSales.moreMenuReserve)
.waitForClassNotPresent(selectors.ticketSales.firstSaleReservedIcon, 'ng-hide') .waitForClassNotPresent(selectors.ticketSales.firstSaleReservedIcon, 'ng-hide')
.isVisible(selectors.ticketSales.firstSaleReservedIcon); .isVisible(selectors.ticketSales.firstSaleReservedIcon);
@ -451,9 +394,8 @@ xdescribe('Ticket Edit sale path', () => {
it('should unmark the first sale as reserved', async() => { it('should unmark the first sale as reserved', async() => {
const result = await nightmare const result = await nightmare
.waitToClick(selectors.ticketSales.firstSaleCheckbox) .waitToClick(selectors.ticketSales.moreMenu)
.waitToClick(selectors.ticketSales.moreMenuButton) .waitToClick(selectors.ticketSales.moreMenuUnmarkReseved)
.waitToClick(selectors.ticketSales.moreMenuUnmarkResevedOption)
.waitForClassPresent(selectors.ticketSales.firstSaleReservedIcon, 'ng-hide') .waitForClassPresent(selectors.ticketSales.firstSaleReservedIcon, 'ng-hide')
.isVisible(selectors.ticketSales.firstSaleReservedIcon); .isVisible(selectors.ticketSales.firstSaleReservedIcon);
@ -462,8 +404,7 @@ xdescribe('Ticket Edit sale path', () => {
it('should update all sales discount', async() => { it('should update all sales discount', async() => {
const result = await nightmare const result = await nightmare
.waitToClick(selectors.ticketSales.selectAllSalesCheckbox) .waitToClick(selectors.ticketSales.moreMenu)
.waitToClick(selectors.ticketSales.moreMenuButton)
.waitToClick(selectors.ticketSales.moreMenuUpdateDiscount) .waitToClick(selectors.ticketSales.moreMenuUpdateDiscount)
.write(selectors.ticketSales.moreMenuUpdateDiscountInput, 100) .write(selectors.ticketSales.moreMenuUpdateDiscountInput, 100)
.write('body', '\u000d') .write('body', '\u000d')
@ -473,80 +414,39 @@ xdescribe('Ticket Edit sale path', () => {
expect(result).toContain('0.00'); expect(result).toContain('0.00');
}); });
it('should log in as Production role and go to the ticket index', async() => { it('should log in as Production role and go to a target ticket summary', async() => {
const url = await nightmare const url = await nightmare
.waitForLogin('production') .loginAndModule('production', 'ticket')
.waitToClick(selectors.globalItems.applicationsMenuButton) .accessToSearchResult(13)
.wait(selectors.globalItems.applicationsMenuVisible) .waitForURL('/summary')
.waitToClick(selectors.globalItems.ticketsButton)
.wait(selectors.ticketsIndex.searchTicketInput)
.parsedUrl(); .parsedUrl();
expect(url.hash).toEqual('#!/ticket/index'); expect(url.hash).toContain('/summary');
}); });
it('should now search for a specific ticket', async() => { it(`should check it's state is deleted`, async() => {
const result = await nightmare const result = await nightmare
.write(selectors.ticketsIndex.searchTicketInput, '16') .waitToGetProperty(selectors.ticketDescriptor.stateLabelValue, 'innerText');
.waitToClick(selectors.ticketsIndex.searchButton)
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
.countElement(selectors.ticketsIndex.searchResult);
expect(result).toEqual(1); expect(result).toEqual('State Eliminado');
});
it(`should now click on the search result to access to the ticket Tracking`, async() => {
const url = await nightmare
.waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21')
.waitToClick(selectors.ticketsIndex.searchResult)
.waitToClick(selectors.ticketTracking.trackingButton)
.waitForURL('/tracking/index')
.parsedUrl();
expect(url.hash).toContain('/tracking/index');
});
it(`should click on the edit ticket tracking state button`, async() => {
const url = await nightmare
.waitToClick(selectors.ticketTracking.createStateButton)
.waitForURL('/tracking/edit')
.parsedUrl();
expect(url.hash).toContain('/tracking/edit');
});
it(`should set the state of the ticket to preparation`, async() => {
const url = await nightmare
.autocompleteSearch(selectors.ticketTracking.stateAutocomplete, 'Preparación')
.waitToClick(selectors.ticketTracking.saveButton)
.waitForURL('/tracking/index')
.parsedUrl();
expect(url.hash).toContain('/tracking/index');
});
it(`should click on the ticket Sale menu button`, async() => {
const url = await nightmare
.waitToClick(selectors.ticketSales.saleButton)
.waitForURL('/sale')
.parsedUrl();
expect(url.hash).toContain('/sale');
}); });
describe('when state is preparation and loged as Production', () => { describe('when state is preparation and loged as Production', () => {
it(`should not be able to edit the sale price`, async() => { it(`should not be able to edit the sale price`, async() => {
const result = await nightmare const result = await nightmare
.wait(selectors.ticketSales.firstSaleID) .waitToClick(selectors.ticketDescriptor.goBackToModuleIndexButton)
.exists(selectors.ticketSales.firstSalePrice); .accessToSearchResult(8)
.accessToSection('ticket.card.sale')
.waitToClick(selectors.ticketSales.firstSalePrice)
.exists(selectors.ticketSales.firstSalePriceInput);
expect(result).toBeFalsy(); expect(result).toBeFalsy();
}); });
it(`should not be able to edit the sale discount`, async() => { it(`should not be able to edit the sale discount`, async() => {
const result = await nightmare const result = await nightmare
.waitToClick(selectors.ticketSales.firstSaleID) .waitToClick(selectors.ticketSales.firstSaleDiscount)
.exists(selectors.ticketSales.firstSaleDiscount); .exists(selectors.ticketSales.firstSaleDiscountInput);
expect(result).toBeFalsy(); expect(result).toBeFalsy();
}); });
@ -559,33 +459,11 @@ xdescribe('Ticket Edit sale path', () => {
expect(result).toBeFalsy(); expect(result).toBeFalsy();
}); });
it('should log in as salesPerson role and go to the ticket index', async() => { it('should log in as salesPerson then go to the sales of a target ticket', async() => {
const url = await nightmare const url = await nightmare
.waitForLogin('salesPerson') .loginAndModule('salesPerson', 'ticket')
.waitToClick(selectors.globalItems.applicationsMenuButton) .accessToSearchResult(8)
.wait(selectors.globalItems.applicationsMenuVisible) .accessToSection('ticket.card.sale')
.waitToClick(selectors.globalItems.ticketsButton)
.wait(selectors.ticketsIndex.searchTicketInput)
.parsedUrl();
expect(url.hash).toEqual('#!/ticket/index');
});
it('should once again search for a specific ticket', async() => {
const result = await nightmare
.write(selectors.ticketsIndex.searchTicketInput, '16')
.waitToClick(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 Sale once again`, async() => {
const url = await nightmare
.waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21')
.waitToClick(selectors.ticketsIndex.searchResult)
.waitToClick(selectors.ticketSales.saleButton)
.waitForURL('/sale') .waitForURL('/sale')
.parsedUrl(); .parsedUrl();
@ -594,23 +472,23 @@ xdescribe('Ticket Edit sale path', () => {
}); });
describe('when state is preparation and loged as salesPerson', () => { describe('when state is preparation and loged as salesPerson', () => {
it(`shouldnt be able to edit the sale price`, async() => { it(`shouldn't be able to edit the sale price`, async() => {
const result = await nightmare const result = await nightmare
.waitToClick(selectors.ticketSales.firstSaleID) .waitToClick(selectors.ticketSales.firstSalePrice)
.exists(selectors.ticketSales.firstSalePrice); .exists(selectors.ticketSales.firstSalePriceInput);
expect(result).toBeFalsy(); expect(result).toBeFalsy();
}); });
it(`shouldnt be able to edit the sale discount`, async() => { it(`should be able to edit the sale discount`, async() => {
const result = await nightmare const result = await nightmare
.waitToClick(selectors.ticketSales.firstSaleID) .waitToClick(selectors.ticketSales.firstSaleDiscount)
.exists(selectors.ticketSales.firstSaleDiscount); .exists(selectors.ticketSales.firstSaleDiscountInput);
expect(result).toBeFalsy(); expect(result).toBeFalsy();
}); });
it(`shouldnt be able to edit the sale state`, async() => { it(`should not be able to edit the sale state`, async() => {
const result = await nightmare const result = await nightmare
.waitToClick(selectors.ticketSales.stateMenuButton) .waitToClick(selectors.ticketSales.stateMenuButton)
.exists(selectors.ticketSales.stateMenuOptions); .exists(selectors.ticketSales.stateMenuOptions);

View File

@ -3,7 +3,7 @@ import createNightmare from '../../helpers/nightmare';
describe('Ticket services path', () => { describe('Ticket services path', () => {
const nightmare = createNightmare(); const nightmare = createNightmare();
const invoicedTicketId = 10; const invoicedTicketId = 1;
describe('as employee', () => { describe('as employee', () => {
beforeAll(() => { beforeAll(() => {
@ -36,12 +36,16 @@ describe('Ticket services path', () => {
}); });
describe('as administrative', () => { describe('as administrative', () => {
let editableTicketId = 13; let editableTicketId = 16;
beforeAll(() => { it('should navigate to the services of a target ticket', async() => {
nightmare const url = await nightmare
.loginAndModule('administrative', 'ticket') .loginAndModule('administrative', 'ticket')
.accessToSearchResult(editableTicketId) .accessToSearchResult(editableTicketId)
.accessToSection('ticket.card.service'); .accessToSection('ticket.card.service')
.waitForURL('/service')
.parsedUrl();
expect(url.hash).toContain('/service');
}); });
it('should click on the add button to prepare the form to create a new service', async() => { it('should click on the add button to prepare the form to create a new service', async() => {