salix/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js

389 lines
17 KiB
JavaScript
Raw Normal View History

2019-09-06 09:43:15 +00:00
import selectors from '../../../helpers/selectors.js';
2020-01-26 23:48:00 +00:00
import getBrowser from '../../../helpers/puppeteer';
2020-07-02 07:35:52 +00:00
describe('Ticket Edit sale path', () => {
let browser;
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
2020-01-26 23:48:00 +00:00
await page.loginAndModule('salesPerson', 'ticket');
2020-07-02 07:35:52 +00:00
await page.accessToSearchResult('16');
2020-01-26 23:48:00 +00:00
await page.accessToSection('ticket.card.sale');
2018-11-07 07:38:09 +00:00
});
afterAll(async() => {
await browser.close();
});
2019-06-27 06:41:07 +00:00
it(`should click on the first sale claim icon to navigate over there`, async() => {
2020-04-08 09:24:40 +00:00
await page.waitToClick(selectors.ticketSales.firstSaleClaimIcon);
2020-07-02 07:35:52 +00:00
await page.waitForState('claim.card.basicData');
2018-11-07 07:38:09 +00:00
});
2019-06-27 06:41:07 +00:00
it('should navigate to the tickets index', async() => {
2020-04-08 09:24:40 +00:00
await page.waitToClick(selectors.globalItems.applicationsMenuButton);
await page.wait(selectors.globalItems.applicationsMenuVisible);
await page.waitToClick(selectors.globalItems.ticketsButton);
2020-07-02 07:35:52 +00:00
await page.waitForState('ticket.index');
});
2019-06-27 06:41:07 +00:00
it(`should search for a ticket and then navigate to it's sales`, async() => {
2020-07-02 07:35:52 +00:00
await page.accessToSearchResult('16');
2020-04-08 09:24:40 +00:00
await page.accessToSection('ticket.card.sale');
2020-07-02 07:35:52 +00:00
});
it(`should set the ticket as libre`, async() => {
await page.waitToClick(selectors.ticketSales.stateMenuButton);
await page.write('body > div > div > div.content > div.filter.ng-scope > vn-textfield', 'libre');
await page.waitFor(500);
await page.keyboard.press('Enter');
const message = await page.waitForSnackbar();
expect(message.type).toBe('success');
});
2018-11-07 07:38:09 +00:00
2020-07-02 07:35:52 +00:00
it(`should check it's state is libre now`, async() => {
await page.waitForTextInElement(selectors.ticketDescriptor.stateLabelValue, 'Libre');
const result = await page.waitToGetProperty(selectors.ticketDescriptor.stateLabelValue, 'innerText');
expect(result).toEqual('State Libre');
});
it(`should set the ticket as OK`, async() => {
await page.waitToClick(selectors.ticketSales.setOk);
const message = await page.waitForSnackbar();
expect(message.type).toBe('success');
});
it(`should check it's state is OK now`, async() => {
await page.waitForTextInElement(selectors.ticketDescriptor.stateLabelValue, 'OK');
const result = await page.waitToGetProperty(selectors.ticketDescriptor.stateLabelValue, 'innerText');
expect(result).toEqual('State OK');
2018-10-25 14:44:03 +00:00
});
2019-06-27 06:41:07 +00:00
it(`should check the zoomed image isn't present`, async() => {
2020-04-08 09:24:40 +00:00
const result = await page.countElement(selectors.ticketSales.firstSaleZoomedImage);
2018-11-07 07:38:09 +00:00
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() => {
2020-07-02 07:35:52 +00:00
await page.waitToClick(selectors.ticketSales.firstSaleThumbnailImage);
2020-04-08 09:24:40 +00:00
const result = await page.countElement(selectors.ticketSales.firstSaleZoomedImage);
2018-11-07 07:38:09 +00:00
expect(result).toEqual(1);
});
2019-01-07 08:33:07 +00:00
it(`should click on the zoomed image to close it`, async() => {
2020-07-02 07:35:52 +00:00
await page.waitToClick(selectors.ticketSales.firstSaleZoomedImage);
2020-04-08 09:24:40 +00:00
const result = await page.countElement(selectors.ticketSales.firstSaleZoomedImage);
2018-11-07 07:38:09 +00:00
expect(result).toEqual(0);
});
2020-07-02 07:35:52 +00:00
it(`should click on the first sale ID making now the item descriptor visible`, async() => {
2020-04-08 09:24:40 +00:00
await page.waitToClick(selectors.ticketSales.firstSaleId);
await page.waitImgLoad(selectors.ticketSales.firstSaleDescriptorImage);
const visible = await page.isVisible(selectors.ticketSales.saleDescriptorPopover);
2018-11-07 07:38:09 +00:00
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() => {
2020-07-02 07:35:52 +00:00
await page.waitToClick('vn-item-descriptor img');
2020-04-08 09:24:40 +00:00
const result = await page.countElement(selectors.ticketSales.firstSaleZoomedImage);
2018-11-07 07:38:09 +00:00
expect(result).toEqual(1);
});
2019-02-04 14:40:57 +00:00
it(`should now click on the zoomed image to close it`, async() => {
2020-07-02 07:35:52 +00:00
await page.waitToClick(selectors.ticketSales.firstSaleZoomedImage);
2020-04-08 09:24:40 +00:00
const result = await page.countElement(selectors.ticketSales.firstSaleZoomedImage);
2018-11-07 07:38:09 +00:00
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() => {
2020-04-08 09:24:40 +00:00
await page.waitToClick(selectors.ticketSales.saleDescriptorPopoverSummaryButton);
2020-07-02 07:35:52 +00:00
await page.waitForState('item.card.summary');
});
2019-01-07 08:33:07 +00:00
it('should return to ticket sales section', async() => {
2020-04-08 09:24:40 +00:00
await page.waitToClick(selectors.globalItems.applicationsMenuButton);
await page.wait(selectors.globalItems.applicationsMenuVisible);
await page.waitToClick(selectors.globalItems.ticketsButton);
2020-07-02 07:35:52 +00:00
await page.accessToSearchResult('16');
2020-04-08 09:24:40 +00:00
await page.accessToSection('ticket.card.sale');
});
2019-01-07 08:33:07 +00:00
it('should try to add a higher quantity value and then receive an error', async() => {
2020-07-02 07:35:52 +00:00
await page.waitToClick(selectors.ticketSales.firstSaleQuantityCell);
await page.type(selectors.ticketSales.firstSaleQuantity, '11\u000d');
2020-04-08 09:24:40 +00:00
const message = await page.waitForSnackbar();
2018-11-07 07:38:09 +00:00
2020-04-08 09:24:40 +00:00
expect(message.text).toBe('The new quantity should be smaller than the old one');
});
2019-06-27 06:41:07 +00:00
it('should remove 1 from the first sale quantity', async() => {
2020-07-02 07:35:52 +00:00
await page.waitFor(500);
await page.waitToClick(selectors.ticketSales.firstSaleQuantityCell);
await page.waitFor(selectors.ticketSales.firstSaleQuantity);
await page.type(selectors.ticketSales.firstSaleQuantity, '9\u000d');
2020-04-08 09:24:40 +00:00
const message = await page.waitForSnackbar();
2018-11-07 07:38:09 +00:00
2020-04-08 09:24:40 +00:00
expect(message.type).toBe('success');
});
2019-01-07 08:33:07 +00:00
it('should update the price', async() => {
2020-07-02 07:35:52 +00:00
await page.waitToClick(selectors.ticketSales.firstSalePrice);
await page.waitFor(selectors.ticketSales.firstSalePriceInput);
await page.type(selectors.ticketSales.firstSalePriceInput, '5\u000d');
2020-04-08 09:24:40 +00:00
const message = await page.waitForSnackbar();
2018-11-07 07:38:09 +00:00
2020-04-08 09:24:40 +00:00
expect(message.type).toBe('success');
});
2019-01-07 08:33:07 +00:00
it('should confirm the price have been updated', async() => {
2020-07-02 07:35:52 +00:00
const result = await page.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() => {
2020-04-08 09:24:40 +00:00
const result = await page.waitToGetProperty(selectors.ticketSales.firstSaleImport, 'innerText');
2018-11-07 07:38:09 +00:00
2019-06-27 06:41:07 +00:00
expect(result).toContain('45.00');
});
2019-01-07 08:33:07 +00:00
it('should update the discount', async() => {
2020-07-02 07:35:52 +00:00
await page.waitToClick(selectors.ticketSales.firstSaleDiscount);
await page.waitFor(selectors.ticketSales.firstSaleDiscountInput);
await page.type(selectors.ticketSales.firstSaleDiscountInput, '50\u000d');
2020-04-08 09:24:40 +00:00
const message = await page.waitForSnackbar();
2018-11-07 07:38:09 +00:00
2020-04-08 09:24:40 +00:00
expect(message.type).toBe('success');
});
2019-01-07 08:33:07 +00:00
it('should confirm the discount have been updated', async() => {
2020-07-02 07:35:52 +00:00
await page.waitForTextInElement(selectors.ticketSales.firstSaleDiscount, '50.00%');
const result = await page.waitToGetProperty(selectors.ticketSales.firstSaleDiscount, 'innerText');
2018-11-07 07:38:09 +00:00
2020-01-16 12:39:32 +00:00
expect(result).toContain('50.00%');
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() => {
2020-04-08 09:24:40 +00:00
await page.waitForTextInElement(selectors.ticketSales.firstSaleImport, '22.50');
const result = await page.waitToGetProperty(selectors.ticketSales.firstSaleImport, 'innerText');
2018-11-07 07:38:09 +00:00
2019-06-27 06:41:07 +00:00
expect(result).toContain('22.50');
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() => {
2020-04-08 09:24:40 +00:00
await page.waitToClick(selectors.ticketSales.thirdSaleCheckbox);
await page.waitToClick(selectors.ticketSales.moreMenu);
await page.waitToClick(selectors.ticketSales.moreMenuCreateClaim);
2020-07-02 07:35:52 +00:00
await page.waitForState('claim.card.basicData');
});
2019-01-07 08:33:07 +00:00
it('should click on the Claims button of the top bar menu', async() => {
2020-04-08 09:24:40 +00:00
await page.waitToClick(selectors.globalItems.applicationsMenuButton);
await page.wait(selectors.globalItems.applicationsMenuVisible);
await page.waitToClick(selectors.globalItems.claimsButton);
2020-07-02 07:35:52 +00:00
await page.waitForState('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() => {
2020-07-02 07:35:52 +00:00
await page.accessToSearchResult('4');
await page.waitForState('claim.card.summary');
});
2019-01-07 08:33:07 +00:00
it('should click the Tickets button of the top bar menu', async() => {
2020-04-08 09:24:40 +00:00
await page.waitToClick(selectors.globalItems.applicationsMenuButton);
await page.wait(selectors.globalItems.applicationsMenuVisible);
await page.waitToClick(selectors.globalItems.ticketsButton);
2020-07-02 07:35:52 +00:00
await page.waitForState('ticket.index');
2018-10-25 14:44:03 +00:00
});
2019-06-27 06:41:07 +00:00
it('should search for a ticket then access to the sales section', async() => {
2020-07-02 07:35:52 +00:00
await page.accessToSearchResult('16');
2020-04-08 09:24:40 +00:00
await page.accessToSection('ticket.card.sale');
2020-07-09 12:14:11 +00:00
await page.wait(2000);
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() => {
2020-04-08 09:24:40 +00:00
await page.waitToClick(selectors.ticketSales.thirdSaleCheckbox);
2020-07-09 12:14:11 +00:00
await page.wait(2000);
2020-04-08 09:24:40 +00:00
await page.waitToClick(selectors.ticketSales.deleteSaleButton);
2020-07-09 12:14:11 +00:00
await page.wait(2000);
2020-10-01 06:53:31 +00:00
await page.waitToClick(selectors.globalItems.acceptButton);
2020-07-09 12:14:11 +00:00
await page.wait(2000);
2020-04-08 09:24:40 +00:00
await page.waitForSpinnerLoad();
const message = await page.waitForSnackbar();
2018-11-07 07:38:09 +00:00
2020-04-08 09:24:40 +00:00
expect(message.type).toBe('success');
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() => {
2020-04-08 09:24:40 +00:00
const result = await page.countElement(selectors.ticketSales.saleLine);
2018-11-07 07:38:09 +00:00
expect(result).toEqual(3);
});
it('should select the second sale and transfer it to a valid ticket', async() => {
2020-07-02 07:35:52 +00:00
const targetTicketId = '12';
2019-06-27 06:41:07 +00:00
2020-04-08 09:24:40 +00:00
await page.waitToClick(selectors.ticketSales.secondSaleCheckbox);
await page.waitToClick(selectors.ticketSales.transferSaleButton);
2020-07-02 07:35:52 +00:00
await page.waitToClick(selectors.ticketSales.transferQuantityCell);
await page.type(selectors.ticketSales.transferQuantityInput, '10\u000d');
await page.type(selectors.ticketSales.moveToTicketInput, targetTicketId);
2020-04-08 09:24:40 +00:00
await page.waitToClick(selectors.ticketSales.moveToTicketButton);
2020-07-02 07:35:52 +00:00
await page.expectURL(`ticket/${targetTicketId}/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() => {
2020-04-08 09:24:40 +00:00
await page.wait(selectors.ticketSales.secondSaleText);
const result = await page.waitToGetProperty(selectors.ticketSales.secondSaleText, 'innerText');
2018-11-07 07:38:09 +00:00
expect(result).toContain(`Melee weapon heavy shield`);
});
it('should confirm the transfered quantity is the correct one', async() => {
2020-04-08 09:24:40 +00:00
const result = await page.waitToGetProperty(selectors.ticketSales.secondSaleQuantityCell, 'innerText');
expect(result).toContain('10');
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() => {
2020-04-08 09:24:40 +00:00
await page.waitToClick(selectors.ticketDescriptor.goBackToModuleIndexButton);
2020-07-02 07:35:52 +00:00
await page.accessToSearchResult('16');
2020-04-08 09:24:40 +00:00
await page.accessToSection('ticket.card.sale');
2018-10-25 14:44:03 +00:00
});
it(`should confirm the original ticket has still three lines`, async() => {
2020-04-08 09:24:40 +00:00
await page.wait(selectors.ticketSales.saleLine);
const result = await page.countElement(selectors.ticketSales.saleLine);
2018-11-07 07:38:09 +00:00
expect(result).toEqual(3);
});
it(`should confirm the second sale quantity is now half of it's original value after the transfer`, async() => {
2020-04-08 09:24:40 +00:00
const result = await page.waitToGetProperty(selectors.ticketSales.secondSaleQuantityCell, 'innerText');
expect(result).toContain('10');
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() => {
2020-04-08 09:24:40 +00:00
await page.waitToClick(selectors.ticketDescriptor.goBackToModuleIndexButton);
2020-07-02 07:35:52 +00:00
await page.accessToSearchResult('12');
2020-04-08 09:24:40 +00:00
await page.accessToSection('ticket.card.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() => {
2020-07-02 07:35:52 +00:00
const targetTicketId = '16';
2019-06-27 06:41:07 +00:00
2020-04-08 09:24:40 +00:00
await page.waitToClick(selectors.ticketSales.secondSaleCheckbox);
await page.waitToClick(selectors.ticketSales.transferSaleButton);
2020-07-02 07:35:52 +00:00
await page.type(selectors.ticketSales.moveToTicketInput, targetTicketId);
2020-04-08 09:24:40 +00:00
await page.waitToClick(selectors.ticketSales.moveToTicketButton);
2020-07-02 07:35:52 +00:00
await page.expectURL(`ticket/${targetTicketId}/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() => {
const expectedLines = 4;
2020-04-08 09:24:40 +00:00
await page.waitForNumberOfElements(selectors.ticketSales.saleLine, expectedLines);
const result = await page.countElement(selectors.ticketSales.saleLine);
2018-11-07 07:38:09 +00:00
expect(result).toEqual(expectedLines);
2018-10-25 14:44:03 +00:00
});
2019-06-27 06:41:07 +00:00
it(`should throw an error when attempting to create a ticket for an inactive client`, async() => {
2020-04-08 09:24:40 +00:00
await page.waitToClick(selectors.ticketSales.firstSaleCheckbox);
await page.waitToClick(selectors.ticketSales.transferSaleButton);
await page.waitToClick(selectors.ticketSales.moveToNewTicketButton);
const message = await page.waitForSnackbar();
2019-06-27 06:41:07 +00:00
2020-04-08 09:24:40 +00:00
expect(message.text).toBe(`You can't create a ticket for a inactive client`);
2020-07-02 07:35:52 +00:00
await page.closePopup();
2019-06-27 06:41:07 +00:00
});
it('should go now to the ticket sales section of an active, not frozen client', async() => {
2020-04-08 09:24:40 +00:00
await page.waitToClick(selectors.ticketDescriptor.goBackToModuleIndexButton);
2020-07-02 07:35:52 +00:00
await page.accessToSearchResult('13');
2020-04-08 09:24:40 +00:00
await page.accessToSection('ticket.card.sale');
2018-11-29 13:24:57 +00:00
});
2019-06-27 06:41:07 +00:00
it(`should select all sales, tranfer them to a new ticket and delete the sender ticket as it would've been left empty`, async() => {
2020-07-02 07:35:52 +00:00
const senderTicketId = '13';
2019-06-27 06:41:07 +00:00
2020-04-08 09:24:40 +00:00
await page.waitToClick(selectors.ticketSales.selectAllSalesCheckbox);
await page.waitToClick(selectors.ticketSales.transferSaleButton);
await page.waitToClick(selectors.ticketSales.moveToNewTicketButton);
2020-07-02 07:35:52 +00:00
await page.evaluate((selector, ticketId) => {
return document.querySelector(selector).innerText.toLowerCase().indexOf(`#${ticketId}`) == -1;
}, selectors.ticketDescriptor.id, senderTicketId);
await page.waitForState('ticket.card.sale');
});
2019-06-27 06:41:07 +00:00
it('should confirm the new ticket received the line', async() => {
2020-04-08 09:24:40 +00:00
const result = await page.countElement(selectors.ticketSales.saleLine);
2018-11-07 07:38:09 +00:00
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() => {
2020-04-08 09:24:40 +00:00
const result = await page.isVisible(selectors.ticketSales.firstSaleReservedIcon);
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('should mark the first sale as reserved', async() => {
2020-04-08 09:24:40 +00:00
await page.waitToClick(selectors.ticketSales.firstSaleCheckbox);
await page.waitToClick(selectors.ticketSales.moreMenu);
await page.waitToClick(selectors.ticketSales.moreMenuReserve);
2020-07-02 07:35:52 +00:00
await page.closePopup();
2020-04-08 09:24:40 +00:00
await page.waitForClassNotPresent(selectors.ticketSales.firstSaleReservedIcon, 'ng-hide');
const result = await page.isVisible(selectors.ticketSales.firstSaleReservedIcon);
2018-11-07 07:38:09 +00:00
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() => {
2020-04-08 09:24:40 +00:00
await page.waitToClick(selectors.ticketSales.moreMenu);
await page.waitToClick(selectors.ticketSales.moreMenuUnmarkReseved);
await page.waitForClassPresent(selectors.ticketSales.firstSaleReservedIcon, 'ng-hide');
const result = await page.isVisible(selectors.ticketSales.firstSaleReservedIcon);
2018-11-07 07:38:09 +00:00
expect(result).toBeFalsy();
});
2019-01-07 08:33:07 +00:00
it('should update all sales discount', async() => {
2020-07-02 07:35:52 +00:00
await page.closePopup();
2020-04-08 09:24:40 +00:00
await page.waitToClick(selectors.ticketSales.moreMenu);
await page.waitToClick(selectors.ticketSales.moreMenuUpdateDiscount);
2020-07-02 07:35:52 +00:00
await page.waitForSelector(selectors.ticketSales.moreMenuUpdateDiscountInput);
await page.type(selectors.ticketSales.moreMenuUpdateDiscountInput, '100');
await page.keyboard.press('Enter');
2020-04-08 09:24:40 +00:00
await page.waitForTextInElement(selectors.ticketSales.totalImport, '0.00');
const result = await page.waitToGetProperty(selectors.ticketSales.totalImport, 'innerText');
2018-11-07 07:38:09 +00:00
expect(result).toContain('0.00');
});
2019-06-27 06:41:07 +00:00
it('should log in as Production role and go to a target ticket summary', async() => {
2020-04-08 09:24:40 +00:00
await page.loginAndModule('production', 'ticket');
2020-07-02 07:35:52 +00:00
await page.accessToSearchResult('13');
await page.waitForState('ticket.card.summary');
2018-10-25 14:44:03 +00:00
});
2020-07-02 07:35:52 +00:00
it(`should check the ticket is deleted`, async() => {
await page.waitForSelector(selectors.ticketDescriptor.isDeletedIcon);
await page.waitForClassPresent(selectors.ticketDescriptor.isDeletedIcon, 'bright');
2018-11-08 14:20:42 +00:00
});
});