426 lines
19 KiB
JavaScript
426 lines
19 KiB
JavaScript
import selectors from '../../../helpers/selectors.js';
|
|
import getBrowser from '../../../helpers/puppeteer';
|
|
|
|
describe('Ticket Edit sale path', () => {
|
|
let browser;
|
|
let page;
|
|
|
|
beforeAll(async() => {
|
|
browser = await getBrowser();
|
|
page = browser.page;
|
|
await page.loginAndModule('salesPerson', 'ticket');
|
|
await page.accessToSearchResult('16');
|
|
await page.accessToSection('ticket.card.sale');
|
|
});
|
|
|
|
afterAll(async() => {
|
|
await browser.close();
|
|
});
|
|
|
|
it(`should click on the first sale claim icon to navigate over there`, async() => {
|
|
await page.waitToClick(selectors.ticketSales.firstSaleClaimIcon);
|
|
await page.waitForState('claim.card.basicData');
|
|
});
|
|
|
|
it('should navigate to the tickets index', async() => {
|
|
await page.waitToClick(selectors.globalItems.applicationsMenuButton);
|
|
await page.waitForSelector(selectors.globalItems.applicationsMenuVisible);
|
|
await page.waitToClick(selectors.globalItems.ticketsButton);
|
|
await page.waitForState('ticket.index');
|
|
});
|
|
|
|
it(`should search for a ticket and then navigate to it's sales`, async() => {
|
|
await page.accessToSearchResult('16');
|
|
await page.accessToSection('ticket.card.sale');
|
|
});
|
|
|
|
it(`should set the ticket as libre`, async() => {
|
|
const searchValue = 'libre';
|
|
await page.waitToClick(selectors.ticketSales.stateMenuButton);
|
|
await page.write(selectors.ticketSales.moreMenuState, searchValue);
|
|
try {
|
|
await page.waitForFunction(searchValue => {
|
|
const element = document.querySelector('li.active');
|
|
if (element)
|
|
return element.innerText.toLowerCase().includes(searchValue.toLowerCase());
|
|
}, {}, searchValue);
|
|
} catch (error) {
|
|
const builtSelector = await page.selectorFormater(selectors.ticketSales.moreMenuState);
|
|
const inputValue = await page.evaluate(() => {
|
|
return document.querySelector('.vn-drop-down.shown vn-textfield input').value;
|
|
});
|
|
throw new Error(`${builtSelector} value is ${inputValue}! ${error}`);
|
|
}
|
|
await page.waitForState('ticket.card.sale');
|
|
await page.keyboard.press('Enter');
|
|
const message = await page.waitForSnackbar();
|
|
|
|
expect(message.text).toContain('Data saved!');
|
|
});
|
|
|
|
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.text).toContain('Data saved!');
|
|
});
|
|
|
|
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');
|
|
});
|
|
|
|
it(`should check the zoomed image isn't present`, async() => {
|
|
const result = await page.countElement(selectors.ticketSales.firstSaleZoomedImage);
|
|
|
|
expect(result).toEqual(0);
|
|
});
|
|
|
|
it(`should click on the thumbnail image of the 1st sale and see the zoomed image`, async() => {
|
|
await page.waitToClick(selectors.ticketSales.firstSaleThumbnailImage);
|
|
const result = await page.countElement(selectors.ticketSales.firstSaleZoomedImage);
|
|
|
|
expect(result).toEqual(1);
|
|
});
|
|
|
|
it(`should click on the zoomed image to close it`, async() => {
|
|
await page.waitToClick(selectors.ticketSales.firstSaleZoomedImage);
|
|
const result = await page.countElement(selectors.ticketSales.firstSaleZoomedImage);
|
|
|
|
expect(result).toEqual(0);
|
|
});
|
|
|
|
it(`should click on the first sale ID making now the item descriptor visible`, async() => {
|
|
await page.waitToClick(selectors.ticketSales.firstSaleId);
|
|
await page.waitImgLoad(selectors.ticketSales.firstSaleDescriptorImage);
|
|
const visible = await page.isVisible(selectors.ticketSales.saleDescriptorPopover);
|
|
|
|
expect(visible).toBeTruthy();
|
|
});
|
|
|
|
it(`should click on the descriptor image of the 1st sale and see the zoomed image`, async() => {
|
|
await page.waitToClick('vn-item-descriptor img');
|
|
const result = await page.countElement(selectors.ticketSales.firstSaleZoomedImage);
|
|
|
|
expect(result).toEqual(1);
|
|
});
|
|
|
|
it(`should now click on the zoomed image to close it`, async() => {
|
|
await page.waitToClick(selectors.ticketSales.firstSaleZoomedImage);
|
|
const result = await page.countElement(selectors.ticketSales.firstSaleZoomedImage);
|
|
|
|
expect(result).toEqual(0);
|
|
});
|
|
|
|
it(`should click on the summary icon of the item-descriptor to access to the item summary`, async() => {
|
|
await page.waitToClick(selectors.ticketSales.saleDescriptorPopoverSummaryButton);
|
|
await page.waitForState('item.card.summary');
|
|
});
|
|
|
|
it('should return to ticket sales section', async() => {
|
|
await page.waitToClick(selectors.globalItems.applicationsMenuButton);
|
|
await page.waitForSelector(selectors.globalItems.applicationsMenuVisible);
|
|
await page.waitToClick(selectors.globalItems.ticketsButton);
|
|
await page.accessToSearchResult('16');
|
|
await page.accessToSection('ticket.card.sale');
|
|
});
|
|
|
|
it('should try to add a higher quantity value and then receive an error', async() => {
|
|
await page.waitToClick(selectors.ticketSales.firstSaleQuantityCell);
|
|
await page.type(selectors.ticketSales.firstSaleQuantity, '11\u000d');
|
|
const message = await page.waitForSnackbar();
|
|
|
|
expect(message.text).toContain('The new quantity should be smaller than the old one');
|
|
});
|
|
|
|
it('should remove 1 from the first sale quantity', async() => {
|
|
await page.waitToClick(selectors.ticketSales.firstSaleQuantityCell);
|
|
await page.waitForSelector(selectors.ticketSales.firstSaleQuantity);
|
|
await page.type(selectors.ticketSales.firstSaleQuantity, '9\u000d');
|
|
const message = await page.waitForSnackbar();
|
|
|
|
expect(message.text).toContain('Data saved!');
|
|
});
|
|
|
|
it('should update the price', async() => {
|
|
await page.waitToClick(selectors.ticketSales.firstSalePrice);
|
|
await page.waitForSelector(selectors.ticketSales.firstSalePriceInput);
|
|
await page.type(selectors.ticketSales.firstSalePriceInput, '5\u000d');
|
|
const message = await page.waitForSnackbar();
|
|
|
|
expect(message.text).toContain('Data saved!');
|
|
});
|
|
|
|
it('should confirm the price have been updated', async() => {
|
|
const result = await page.waitToGetProperty(selectors.ticketSales.firstSalePrice, 'innerText');
|
|
|
|
expect(result).toContain('5.00');
|
|
});
|
|
|
|
it('should confirm the total price for that item have been updated', async() => {
|
|
const result = await page.waitToGetProperty(selectors.ticketSales.firstSaleImport, 'innerText');
|
|
|
|
expect(result).toContain('45.00');
|
|
});
|
|
|
|
it('should update the discount', async() => {
|
|
await page.waitToClick(selectors.ticketSales.firstSaleDiscount);
|
|
await page.waitForSelector(selectors.ticketSales.firstSaleDiscountInput);
|
|
await page.type(selectors.ticketSales.firstSaleDiscountInput, '50\u000d');
|
|
const message = await page.waitForSnackbar();
|
|
|
|
expect(message.text).toContain('Data saved!');
|
|
});
|
|
|
|
it('should confirm the discount have been updated', async() => {
|
|
await page.waitForTextInElement(selectors.ticketSales.firstSaleDiscount, '50.00%');
|
|
const result = await page.waitToGetProperty(selectors.ticketSales.firstSaleDiscount, 'innerText');
|
|
|
|
expect(result).toContain('50.00%');
|
|
});
|
|
|
|
it('should confirm the total import for that item have been updated', async() => {
|
|
await page.waitForTextInElement(selectors.ticketSales.firstSaleImport, '22.50');
|
|
const result = await page.waitToGetProperty(selectors.ticketSales.firstSaleImport, 'innerText');
|
|
|
|
expect(result).toContain('22.50');
|
|
});
|
|
|
|
it('should recalculate price of sales', async() => {
|
|
await page.waitToClick(selectors.ticketSales.firstSaleCheckbox);
|
|
await page.waitToClick(selectors.ticketSales.secondSaleCheckbox);
|
|
|
|
await page.waitToClick(selectors.ticketSales.moreMenu);
|
|
await page.waitToClick(selectors.ticketSales.moreMenuRecalculatePrice);
|
|
const message = await page.waitForSnackbar();
|
|
|
|
expect(message.text).toContain('Data saved!');
|
|
});
|
|
|
|
it('should log in as salesAssistant and navigate to ticket sales', async() => {
|
|
await page.loginAndModule('salesAssistant', 'ticket');
|
|
await page.accessToSearchResult('16');
|
|
await page.accessToSection('ticket.card.sale');
|
|
});
|
|
|
|
it('should select the third sale and create a pay back', async() => {
|
|
await page.waitToClick(selectors.ticketSales.firstSaleCheckbox);
|
|
await page.waitToClick(selectors.ticketSales.moreMenu);
|
|
await page.waitToClick(selectors.ticketSales.moreMenuPayBack);
|
|
await page.waitForState('ticket.card.sale');
|
|
});
|
|
|
|
it('should select the third sale and create a claim of it', async() => {
|
|
await page.accessToSearchResult('16');
|
|
await page.accessToSection('ticket.card.sale');
|
|
await page.waitToClick(selectors.ticketSales.thirdSaleCheckbox);
|
|
await page.waitToClick(selectors.ticketSales.moreMenu);
|
|
await page.waitToClick(selectors.ticketSales.moreMenuCreateClaim);
|
|
await page.waitForState('claim.card.basicData');
|
|
});
|
|
|
|
it('should click on the Claims button of the top bar menu', async() => {
|
|
await page.waitToClick(selectors.globalItems.applicationsMenuButton);
|
|
await page.waitForSelector(selectors.globalItems.applicationsMenuVisible);
|
|
await page.waitToClick(selectors.globalItems.claimsButton);
|
|
await page.waitForState('claim.index');
|
|
});
|
|
|
|
it('should search for the claim with id 4', async() => {
|
|
await page.accessToSearchResult('4');
|
|
await page.waitForState('claim.card.summary');
|
|
});
|
|
|
|
it('should click the Tickets button of the top bar menu', async() => {
|
|
await page.waitToClick(selectors.globalItems.applicationsMenuButton);
|
|
await page.waitForSelector(selectors.globalItems.applicationsMenuVisible);
|
|
await page.waitToClick(selectors.globalItems.ticketsButton);
|
|
await page.waitForState('ticket.index');
|
|
});
|
|
|
|
it('should search for a ticket then access to the sales section', async() => {
|
|
await page.accessToSearchResult('16');
|
|
await page.accessToSection('ticket.card.sale');
|
|
});
|
|
|
|
it('should select the third sale and delete it', async() => {
|
|
await page.waitToClick(selectors.ticketSales.thirdSaleCheckbox);
|
|
await page.waitToClick(selectors.ticketSales.deleteSaleButton);
|
|
await page.waitToClick(selectors.globalItems.acceptButton);
|
|
await page.waitForSpinnerLoad();
|
|
const message = await page.waitForSnackbar();
|
|
|
|
expect(message.text).toContain('Data saved!');
|
|
});
|
|
|
|
it(`should confirm the third sale was deleted`, async() => {
|
|
const result = await page.countElement(selectors.ticketSales.saleLine);
|
|
|
|
expect(result).toEqual(3);
|
|
});
|
|
|
|
it('should select the second sale and transfer it to a valid ticket', async() => {
|
|
const targetTicketId = '12';
|
|
|
|
await page.waitToClick(selectors.ticketSales.secondSaleCheckbox);
|
|
await page.waitToClick(selectors.ticketSales.transferSaleButton);
|
|
await page.waitToClick(selectors.ticketSales.transferQuantityCell);
|
|
await page.type(selectors.ticketSales.transferQuantityInput, '10\u000d');
|
|
await page.type(selectors.ticketSales.moveToTicketInput, targetTicketId);
|
|
await page.waitToClick(selectors.ticketSales.moveToTicketButton);
|
|
await page.expectURL(`ticket/${targetTicketId}/sale`);
|
|
});
|
|
|
|
it('should confirm the transfered line is the correct one', async() => {
|
|
await page.waitForSelector(selectors.ticketSales.secondSaleText);
|
|
const result = await page.waitToGetProperty(selectors.ticketSales.secondSaleText, 'innerText');
|
|
|
|
expect(result).toContain(`Melee weapon heavy shield`);
|
|
});
|
|
|
|
it('should confirm the transfered quantity is the correct one', async() => {
|
|
const result = await page.waitToGetProperty(selectors.ticketSales.secondSaleQuantityCell, 'innerText');
|
|
|
|
expect(result).toContain('10');
|
|
});
|
|
|
|
it('should go back to the original ticket sales section', async() => {
|
|
await page.waitToClick(selectors.ticketDescriptor.goBackToModuleIndexButton);
|
|
await page.accessToSearchResult('16');
|
|
await page.accessToSection('ticket.card.sale');
|
|
});
|
|
|
|
it(`should confirm the original ticket has still three lines`, async() => {
|
|
await page.waitForSelector(selectors.ticketSales.saleLine);
|
|
const result = await page.countElement(selectors.ticketSales.saleLine);
|
|
|
|
expect(result).toEqual(3);
|
|
});
|
|
|
|
it(`should confirm the second sale quantity is now half of it's original value after the transfer`, async() => {
|
|
const result = await page.waitToGetProperty(selectors.ticketSales.secondSaleQuantityCell, 'innerText');
|
|
|
|
expect(result).toContain('10');
|
|
});
|
|
|
|
it('should go back to the receiver ticket sales section', async() => {
|
|
await page.waitToClick(selectors.ticketDescriptor.goBackToModuleIndexButton);
|
|
await page.accessToSearchResult('12');
|
|
await page.accessToSection('ticket.card.sale');
|
|
});
|
|
|
|
it('should transfer the sale back to the original ticket', async() => {
|
|
const targetTicketId = '16';
|
|
|
|
await page.waitToClick(selectors.ticketSales.secondSaleCheckbox);
|
|
await page.waitToClick(selectors.ticketSales.transferSaleButton);
|
|
await page.type(selectors.ticketSales.moveToTicketInput, targetTicketId);
|
|
await page.waitToClick(selectors.ticketSales.moveToTicketButton);
|
|
await page.expectURL(`ticket/${targetTicketId}/sale`);
|
|
});
|
|
|
|
it('should confirm the original ticket received the line', async() => {
|
|
const expectedLines = 4;
|
|
await page.waitForNumberOfElements(selectors.ticketSales.saleLine, expectedLines);
|
|
const result = await page.countElement(selectors.ticketSales.saleLine);
|
|
|
|
expect(result).toEqual(expectedLines);
|
|
});
|
|
|
|
it(`should throw an error when attempting to create a ticket for an inactive client`, async() => {
|
|
await page.waitToClick(selectors.ticketSales.firstSaleCheckbox);
|
|
await page.waitToClick(selectors.ticketSales.transferSaleButton);
|
|
await page.waitToClick(selectors.ticketSales.moveToNewTicketButton);
|
|
const message = await page.waitForSnackbar();
|
|
|
|
expect(message.text).toContain(`You can't create a ticket for a inactive client`);
|
|
|
|
await page.closePopup();
|
|
});
|
|
|
|
it('should go now to the ticket sales section of an active, not frozen client', async() => {
|
|
await page.waitToClick(selectors.ticketDescriptor.goBackToModuleIndexButton);
|
|
await page.accessToSearchResult('13');
|
|
await page.accessToSection('ticket.card.sale');
|
|
});
|
|
|
|
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';
|
|
|
|
await page.waitToClick(selectors.ticketSales.selectAllSalesCheckbox);
|
|
await page.waitToClick(selectors.ticketSales.transferSaleButton);
|
|
await page.waitToClick(selectors.ticketSales.moveToNewTicketButton);
|
|
await page.evaluate((selector, ticketId) => {
|
|
return document.querySelector(selector).innerText.toLowerCase().indexOf(`#${ticketId}`) == -1;
|
|
}, selectors.ticketDescriptor.id, senderTicketId);
|
|
await page.waitForState('ticket.card.sale');
|
|
});
|
|
|
|
it('should confirm the new ticket received the line', async() => {
|
|
const expectedLines = 1;
|
|
const result = await page.countElement(selectors.ticketSales.saleLine);
|
|
|
|
expect(result).toEqual(expectedLines);
|
|
});
|
|
|
|
it('should check the first sale reserved icon isnt visible', async() => {
|
|
const result = await page.isVisible(selectors.ticketSales.firstSaleReservedIcon);
|
|
|
|
expect(result).toBeFalsy();
|
|
});
|
|
|
|
it('should mark the first sale as reserved', async() => {
|
|
await page.waitToClick(selectors.ticketSales.firstSaleCheckbox);
|
|
|
|
await page.waitToClick(selectors.ticketSales.moreMenu);
|
|
await page.waitToClick(selectors.ticketSales.moreMenuReserve);
|
|
await page.closePopup();
|
|
await page.waitForClassNotPresent(selectors.ticketSales.firstSaleReservedIcon, 'ng-hide');
|
|
const result = await page.isVisible(selectors.ticketSales.firstSaleReservedIcon);
|
|
|
|
expect(result).toBeTruthy();
|
|
});
|
|
|
|
it('should unmark the first sale as reserved', async() => {
|
|
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);
|
|
|
|
expect(result).toBeFalsy();
|
|
});
|
|
|
|
// tickets no longer update their totals instantly, a task performed ever 5-10 mins does it. disabled this test until it changes.
|
|
xit('should update all sales discount', async() => {
|
|
await page.closePopup();
|
|
await page.waitToClick(selectors.ticketSales.moreMenu);
|
|
await page.waitToClick(selectors.ticketSales.moreMenuUpdateDiscount);
|
|
await page.waitForSelector(selectors.ticketSales.moreMenuUpdateDiscountInput);
|
|
await page.type(selectors.ticketSales.moreMenuUpdateDiscountInput, '100');
|
|
await page.keyboard.press('Enter');
|
|
await page.waitForTextInElement(selectors.ticketSales.totalImport, '0.00');
|
|
const result = await page.waitToGetProperty(selectors.ticketSales.totalImport, 'innerText');
|
|
|
|
expect(result).toContain('0.00');
|
|
});
|
|
|
|
it('should log in as Production role and go to a target ticket summary', async() => {
|
|
await page.loginAndModule('production', 'ticket');
|
|
await page.accessToSearchResult('13');
|
|
await page.waitForState('ticket.card.summary');
|
|
});
|
|
|
|
it(`should check the ticket is deleted`, async() => {
|
|
await page.waitForSelector(selectors.ticketDescriptor.isDeletedIcon);
|
|
});
|
|
});
|