#604 e2e ticket.sale excludid as its in progress

This commit is contained in:
Carlos Jimenez 2018-09-10 13:38:14 +02:00
parent a3d63825d9
commit 2179572620
1 changed files with 657 additions and 0 deletions

View File

@ -0,0 +1,657 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/helpers';
// #603 in progress
xdescribe('Ticket Edit sale path', () => {
const nightmare = createNightmare();
beforeAll(() => {
return nightmare
.waitForLogin('salesPerson');
});
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/index');
});
});
it('should search for a specific ticket', () => {
return nightmare
.wait(selectors.ticketsIndex.searchResult)
.type(selectors.ticketsIndex.searchTicketInput, 'id:16')
.click(selectors.ticketsIndex.searchButton)
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
.countElement(selectors.ticketsIndex.searchResult)
.then(result => {
expect(result).toEqual(1);
});
});
it(`should click on the search result to access to the ticket Sale`, () => {
return nightmare
.waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21')
.waitToClick(selectors.ticketsIndex.searchResult)
.waitToClick(selectors.ticketSales.saleButton)
.waitForURL('/sale')
.url()
.then(url => {
expect(url).toContain('/sale');
});
});
describe('Before tests begings', () => {
it(`should check the quantity in the 1st line which we will be using in the further tests`, () => {
return nightmare
.wait(selectors.ticketSales.firstSaleText)
.getInputValue(selectors.ticketSales.firstSaleQuantity)
.then(value => {
expect(value).toEqual('5');
});
});
it(`should check the Price in the 1st line which we will be using in the further tests`, () => {
return nightmare
.wait(selectors.ticketSales.firstSaleText)
.getInnerText(selectors.ticketSales.firstSalePrice)
.then(value => {
expect(value).toEqual('€9.60');
});
});
it(`should check the Discount in the 1st line which we will be using in the further tests`, () => {
return nightmare
.wait(selectors.ticketSales.firstSaleText)
.getInnerText(selectors.ticketSales.firstSaleDiscount)
.then(value => {
expect(value).toEqual('0 %');
});
});
it(`should check the Import in the 1st line which we will be using in the further tests`, () => {
return nightmare
.wait(selectors.ticketSales.firstSaleText)
.getInnerText(selectors.ticketSales.firstSaleImport)
.then(value => {
expect(value).toEqual('€48.00');
});
});
it(`should count the ticket lines to verify there are 4 for further testing`, () => {
return nightmare
.countElement(selectors.ticketSales.saleLine)
.then(result => {
expect(result).toEqual(4);
});
});
});
it(`should check the zoomed image isnt present`, () => {
return nightmare
.countElement(selectors.ticketSales.firstSaleZoomedImage)
.then(result => {
expect(result).toEqual(0);
});
});
it(`should click on the thumbnail image of the 1st sale and see the zoomed image`, () => {
return nightmare
.waitToClick(selectors.ticketSales.firstSaleThumbnailImage)
.countElement(selectors.ticketSales.firstSaleZoomedImage)
.then(result => {
expect(result).toEqual(1);
});
});
it(`should click on the zoomed image to close it`, () => {
return nightmare
.waitToClick(selectors.ticketSales.firstSaleZoomedImage)
.countElement(selectors.ticketSales.firstSaleZoomedImage)
.then(result => {
expect(result).toEqual(0);
});
});
it(`should confirm the item descriptor insnt visible yet`, () => {
return nightmare
.isVisible(selectors.ticketSales.saleDescriptorPopover)
.then(result => {
expect(result).toBeFalsy();
});
});
it(`should click on the first sale ID making the item descriptor visible`, () => {
return nightmare
.waitToClick(selectors.ticketSales.firstSaleID)
.isVisible(selectors.ticketSales.saleDescriptorPopover)
.then(result => {
expect(result).toBeTruthy();
});
});
it(`should click on the descriptor image of the 1st sale and see the zoomed image`, () => {
return nightmare
.waitToClick('vn-item-descriptor img')
.countElement(selectors.ticketSales.firstSaleZoomedImage)
.then(result => {
expect(result).toEqual(1);
});
});
it(`should click on the zoomed image to close it`, () => {
return nightmare
.waitToClick(selectors.ticketSales.firstSaleZoomedImage)
.countElement(selectors.ticketSales.firstSaleZoomedImage)
.then(result => {
expect(result).toEqual(0);
});
});
it(`should click on the summary icon of the item-descriptor to access to the item summary`, () => {
return nightmare
.waitToClick(selectors.ticketSales.saleDescriptorPopoverSummaryButton)
.waitForURL('/summary')
.url()
.then(url => {
expect(url).toContain('/summary');
});
});
it('should return to ticket sales section', () => {
return nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.ticketsButton)
.wait(selectors.ticketsIndex.createTicketButton)
.wait(selectors.ticketsIndex.searchResult)
.type(selectors.ticketsIndex.searchTicketInput, 'id:16')
.click(selectors.ticketsIndex.searchButton)
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
.waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21')
.waitToClick(selectors.ticketsIndex.searchResult)
.waitToClick(selectors.ticketSales.saleButton)
.waitForURL('/sale')
.url()
.then(url => {
expect(url).toContain('/sale');
});
});
it('should try to add a higher quantity value and then receive an error', () => {
return nightmare
.waitToClick(selectors.ticketSales.firstSaleQuantityClearInput)
.type(selectors.ticketSales.firstSaleQuantity, '9\u000d')
.waitForLastSnackbar()
.then(result => {
expect(result).toEqual('The new quantity should be smaller than the old one');
});
});
it('should remove 1 from quantity', () => {
return nightmare
.waitToClick(selectors.ticketSales.firstSaleQuantityClearInput)
.type(selectors.ticketSales.firstSaleQuantity, '4\u000d')
.waitForLastSnackbar()
.then(result => {
expect(result).toEqual('Data saved!');
});
});
it('should update the price', () => {
return nightmare
.waitToClick(selectors.ticketSales.firstSalePrice)
.wait(selectors.ticketSales.firstSalePriceInput)
.type(selectors.ticketSales.firstSalePriceInput, 5)
.type('body', '\u000d') // simulates enter
.waitForLastSnackbar()
.then(result => {
expect(result).toEqual('Data saved!');
});
});
it('should confirm the price have been updated', () => {
return nightmare
.getInnerText(selectors.ticketSales.firstSalePrice)
.then(result => {
expect(result).toContain('€5.00');
});
});
it('should confirm the total price for that item have been updated', () => {
return nightmare
.getInnerText(selectors.ticketSales.firstSaleImport)
.then(result => {
expect(result).toContain('€20.00');
});
});
it('should update the discount', () => {
return nightmare
.waitToClick(selectors.ticketSales.firstSaleDiscount)
.wait('vn-textfield[label="Discount"] > div[class="container selected"]') // a function selects the text after it's loaded
.type(selectors.ticketSales.firstSaleDiscountInput, 50)
.type('body', '\u000d') // simulates enter
.waitForLastSnackbar()
.then(result => {
expect(result).toEqual('Data saved!');
});
});
it('should confirm the discount have been updated', () => {
return nightmare
.waitForTextInElement(selectors.ticketSales.firstSaleDiscount, '50 %')
.getInnerText(selectors.ticketSales.firstSaleDiscount)
.then(result => {
expect(result).toContain('50 %');
});
});
it('should confirm the total import for that item have been updated', () => {
return nightmare
.waitForTextInElement(selectors.ticketSales.firstSaleImport, '€10.00')
.getInnerText(selectors.ticketSales.firstSaleImport)
.then(result => {
expect(result).toContain('€10.00');
});
});
it('should select the third sale and delete it', () => {
return nightmare
.waitToClick(selectors.ticketSales.thirdSaleCheckbox)
.waitToClick(selectors.ticketSales.deleteSaleButton)
.waitToClick(selectors.ticketSales.acceptDeleteButton)
.waitForLastSnackbar()
.then(result => {
expect(result).toEqual('Data saved!');
});
});
it(`should confirm the third sale was deleted`, () => {
return nightmare
.countElement(selectors.ticketSales.saleLine)
.then(result => {
expect(result).toEqual(3);
});
});
it('should select the third sale and attempt to send it to a frozen client ticket', () => {
return nightmare
.waitToClick(selectors.ticketSales.thirdSaleCheckbox)
.waitToClick(selectors.ticketSales.transferSaleButton)
.wait(selectors.ticketSales.moveToTicketInput)
.type(selectors.ticketSales.moveToTicketInput, 2)
.waitToClick(selectors.ticketSales.moveToTicketButton)
.waitForLastSnackbar()
.then(result => {
expect(result).toEqual(`The sales of that ticket can't be modified`);
});
});
it('should transfer the sale to a valid ticket', () => {
return nightmare
.waitToClick(selectors.ticketSales.moveToTicketInputClearButton)
.type(selectors.ticketSales.moveToTicketInput, 12)
.waitToClick(selectors.ticketSales.moveToTicketButton)
.waitForURL('ticket/12/sale')
.url()
.then(result => {
expect(result).toContain(`ticket/12/sale`);
});
});
it('should confirm the transfered line is the correct one', () => {
return nightmare
.wait(selectors.ticketSales.firstSaleText)
.getInnerText(selectors.ticketSales.firstSaleText)
.then(result => {
expect(result).toContain(`Mark I`);
});
});
it('should go back to the original ticket sales section', () => {
return nightmare
.waitToClick(selectors.itemsIndex.goBackToModuleIndexButton)
.wait(selectors.ticketsIndex.searchResult)
.type(selectors.ticketsIndex.searchTicketInput, 'id:16')
.click(selectors.ticketsIndex.searchButton)
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
.waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21')
.waitToClick(selectors.ticketsIndex.searchResult)
.waitToClick(selectors.ticketSales.saleButton)
.waitForURL('/sale')
.url()
.then(url => {
expect(url).toContain('/sale');
});
});
it(`should confirm the original ticket has only two lines now`, () => {
return nightmare
.wait(selectors.ticketSales.saleLine)
.countElement(selectors.ticketSales.saleLine)
.then(result => {
expect(result).toEqual(2);
});
});
it('should go back to the receiver ticket sales section', () => {
return nightmare
.waitToClick(selectors.itemsIndex.goBackToModuleIndexButton)
.wait(selectors.ticketsIndex.searchResult)
.type(selectors.ticketsIndex.searchTicketInput, 'id:12')
.click(selectors.ticketsIndex.searchButton)
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
.waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21')
.waitToClick(selectors.ticketsIndex.searchResult)
.waitToClick(selectors.ticketSales.saleButton)
.waitForURL('/sale')
.url()
.then(url => {
expect(url).toContain('/sale');
});
});
it('should transfer the sale back to the original ticket', () => {
return nightmare
.waitToClick(selectors.ticketSales.firstSaleCheckbox)
.waitToClick(selectors.ticketSales.transferSaleButton)
.wait(selectors.ticketSales.moveToTicketInput)
.type(selectors.ticketSales.moveToTicketInput, 16)
.waitToClick(selectors.ticketSales.moveToTicketButton)
.waitForURL('ticket/16/sale')
.url()
.then(result => {
expect(result).toContain(`ticket/16/sale`);
});
});
it('should confirm the original ticket received the line', () => {
return nightmare
.wait(selectors.ticketSales.saleLine)
.countElement(selectors.ticketSales.saleLine)
.then(result => {
expect(result).toEqual(3);
});
});
it('should select the second and third sale and tranfer them to a new ticket then get to the ticket index', () => {
return nightmare
.waitToClick(selectors.ticketSales.secondSaleCheckbox)
.waitToClick(selectors.ticketSales.thirdSaleCheckbox)
.waitToClick(selectors.ticketSales.transferSaleButton)
.waitToClick(selectors.ticketSales.moveToNewTicketButton)
.waitForLogin('salesPerson')
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.ticketsButton)
.wait(selectors.ticketsIndex.createTicketButton)
.parsedUrl()
.then(url => {
expect(url.hash).toEqual('#!/ticket/index');
});
});
it('should search for a specific created ticket', () => {
return nightmare
.wait(selectors.ticketsIndex.searchResult)
.type(selectors.ticketsIndex.searchTicketInput, 'id:22')
.click(selectors.ticketsIndex.searchButton)
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
.countElement(selectors.ticketsIndex.searchResult)
.then(result => {
expect(result).toEqual(1);
});
});
it(`should click on the search result to access to the ticket Sale`, () => {
return nightmare
.waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21')
.waitToClick(selectors.ticketsIndex.searchResult)
.waitToClick(selectors.ticketSales.saleButton)
.waitForURL('/sale')
.url()
.then(url => {
expect(url).toContain('/sale');
});
});
it('should confirm the new ticket received both lines', () => {
return nightmare
.countElement(selectors.ticketSales.saleLine)
.then(result => {
expect(result).toEqual(2);
});
});
it('should check the first sale reserved icon isnt visible', () => {
return nightmare
.isVisible(selectors.ticketSales.firstSaleReservedIcon)
.then(result => {
expect(result).toBeFalsy();
});
});
it('should mark the first sale as reserved', () => {
return nightmare
.waitToClick(selectors.ticketSales.firstSaleCheckbox)
.waitToClick(selectors.ticketSales.moreMenuButton)
.waitToClick(selectors.ticketSales.moreMenuReseveOption)
.waitForClassNotPresent(selectors.ticketSales.firstSaleReservedIcon, 'ng-hide')
.isVisible(selectors.ticketSales.firstSaleReservedIcon)
.then(result => {
expect(result).toBeTruthy();
});
});
it('should unmark the first sale as reserved', () => {
return nightmare
.waitToClick(selectors.ticketSales.firstSaleCheckbox)
.waitToClick(selectors.ticketSales.moreMenuButton)
.waitToClick(selectors.ticketSales.moreMenuUnmarkResevedOption)
.waitForClassPresent(selectors.ticketSales.firstSaleReservedIcon, 'ng-hide')
.isVisible(selectors.ticketSales.firstSaleReservedIcon)
.then(result => {
expect(result).toBeFalsy();
});
});
it('should update all sales discount', () => {
return nightmare
.waitToClick(selectors.ticketSales.selectAllSalesCheckbox)
.waitToClick(selectors.ticketSales.moreMenuButton)
.waitToClick(selectors.ticketSales.moreMenuUpdateDiscount)
.wait(selectors.ticketSales.moreMenuUpdateDiscountInput)
.type(selectors.ticketSales.moreMenuUpdateDiscountInput, 100)
.type('body', '\u000d') // simulates enter
.waitForTextInElement(selectors.ticketSales.totalImport, '€0.00')
.getInnerText(selectors.ticketSales.totalImport)
.then(result => {
expect(result).toEqual('€0.00');
});
});
it('should log in as Production role and go to the ticket index', () => {
return nightmare
.waitToClick(selectors.globalItems.logOutButton)
.waitForLogin('production')
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.ticketsButton)
.wait(selectors.ticketsIndex.createTicketButton)
.parsedUrl()
.then(url => {
expect(url.hash).toEqual('#!/ticket/index');
});
});
it('should now search for a specific ticket', () => {
return nightmare
.wait(selectors.ticketsIndex.searchResult)
.type(selectors.ticketsIndex.searchTicketInput, 'id:16')
.click(selectors.ticketsIndex.searchButton)
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
.countElement(selectors.ticketsIndex.searchResult)
.then(result => {
expect(result).toEqual(1);
});
});
it(`should now click on the search result to access to the ticket Tracking`, () => {
return nightmare
.waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21')
.waitToClick(selectors.ticketsIndex.searchResult)
.waitToClick(selectors.ticketTracking.trackingButton)
.waitForURL('/tracking/index')
.url()
.then(url => {
expect(url).toContain('/tracking/index');
});
});
it(`should click on the edit ticket tracking state button`, () => {
return nightmare
.waitToClick(selectors.ticketTracking.createStateButton)
.waitForURL('/tracking/edit')
.url()
.then(url => {
expect(url).toContain('/tracking/edit');
});
});
it(`should set the state of the ticket to preparation`, () => {
return nightmare
.waitToClick(selectors.ticketTracking.stateSelect)
.wait(selectors.ticketTracking.stateSelectInput)
.type(selectors.ticketTracking.stateSelectInput, 'Preparación')
.waitToClick(selectors.ticketTracking.stateSelectFirstResult)
.waitForTextInInput(selectors.ticketTracking.stateSelectInput, 'Preparación')
.click(selectors.ticketTracking.saveButton)
.waitForURL('/tracking/index')
.url()
.then(url => {
expect(url).toContain('/tracking/index');
});
});
it(`should click on the ticket Sale menu button`, () => {
return nightmare
.waitToClick(selectors.ticketSales.saleButton)
.waitForURL('/sale')
.url()
.then(url => {
expect(url).toContain('/sale');
});
});
describe('when state is preparation and loged as Production', () => {
it(`should not be able to edit the sale price`, () => {
return nightmare
.waitToClick(selectors.ticketSales.firstSalePrice)
.exists(selectors.ticketSales.firstSalePriceInput)
.then(result => {
expect(result).toBeFalsy();
});
});
it(`should not be able to edit the sale discount`, () => {
return nightmare
.waitToClick(selectors.ticketSales.firstSaleDiscount)
.exists(selectors.ticketSales.firstSaleDiscountInput)
.then(result => {
expect(result).toBeFalsy();
});
});
it(`should not be able to edit the sale state`, () => {
return nightmare
.waitToClick(selectors.ticketSales.stateMenuButton)
.exists(selectors.ticketSales.stateMenuOptions)
.then(result => {
expect(result).toBeFalsy();
});
});
it('should log in as salesPerson role and go to the ticket index', () => {
return nightmare
.waitToClick(selectors.globalItems.logOutButton)
.waitForLogin('salesPerson')
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.ticketsButton)
.wait(selectors.ticketsIndex.createTicketButton)
.parsedUrl()
.then(url => {
expect(url.hash).toEqual('#!/ticket/index');
});
});
it('should again search for a specific ticket', () => {
return nightmare
.wait(selectors.ticketsIndex.searchResult)
.type(selectors.ticketsIndex.searchTicketInput, 'id:16')
.click(selectors.ticketsIndex.searchButton)
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
.countElement(selectors.ticketsIndex.searchResult)
.then(result => {
expect(result).toEqual(1);
});
});
it(`should again click on the search result to access to the ticket Sales`, () => {
return nightmare
.waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21')
.waitToClick(selectors.ticketsIndex.searchResult)
.waitToClick(selectors.ticketSales.saleButton)
.waitForURL('/sale')
.url()
.then(url => {
expect(url).toContain('/sale');
});
});
});
describe('when state is preparation and loged as salesPerson', () => {
it(`shouldnt be able to edit the sale price`, () => {
return nightmare
.waitToClick(selectors.ticketSales.firstSalePrice)
.exists(selectors.ticketSales.firstSalePriceInput)
.then(result => {
expect(result).toBeFalsy();
});
});
it(`shouldnt be able to edit the sale discount`, () => {
return nightmare
.waitToClick(selectors.ticketSales.firstSaleDiscount)
.exists(selectors.ticketSales.firstSaleDiscountInput)
.then(result => {
expect(result).toBeFalsy();
});
});
it(`shouldnt be able to edit the sale state`, () => {
return nightmare
.waitToClick(selectors.ticketSales.stateMenuButton)
.exists(selectors.ticketSales.stateMenuOptions)
.then(result => {
expect(result).toBeFalsy();
});
});
it(`should be able to delete the ticket`, () => {
// return nightmare
// .waitToClick(selectors.ticketSales.moreMenuButton)
// .waitToClick(selectors.ticketSales.moreMenuDeleteOption)
// .exists(selectors.ticketSales.stateMenuOptions)
// .then(result => {
// expect(result).toBeFalsy();
// });
});
});
});