524 lines
20 KiB
JavaScript
524 lines
20 KiB
JavaScript
import selectors from '../../../helpers/selectors.js';
|
|
import getBrowser from '../../../helpers/puppeteer';
|
|
|
|
// #1632 [e2e] ticket.sale - Transferir líneas
|
|
xdescribe('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() => {
|
|
const url = await nightmare
|
|
.waitToClick(selectors.ticketSales.firstSaleClaimIcon)
|
|
.wait(selectors.claimBasicData.claimState)
|
|
.parsedUrl();
|
|
|
|
expect(url.hash).toEqual('#!/claim/2/basic-data');
|
|
});
|
|
|
|
it('should navigate to the tickets index', async() => {
|
|
const url = await nightmare
|
|
.waitToClick(selectors.globalItems.applicationsMenuButton)
|
|
.wait(selectors.globalItems.applicationsMenuVisible)
|
|
.waitToClick(selectors.globalItems.ticketsButton)
|
|
.wait(selectors.ticketsIndex.topbarSearch)
|
|
.parsedUrl();
|
|
|
|
expect(url.hash).toEqual('#!/ticket/index');
|
|
});
|
|
|
|
it(`should search for a ticket and then navigate to it's sales`, async() => {
|
|
const url = await nightmare
|
|
.accessToSearchResult(16)
|
|
.accessToSection('ticket.card.sale')
|
|
.waitForURL('/sale')
|
|
.parsedUrl();
|
|
|
|
expect(url.hash).toContain('/sale');
|
|
});
|
|
|
|
it(`should check the zoomed image isn't present`, async() => {
|
|
const result = await nightmare
|
|
.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() => {
|
|
const result = await nightmare
|
|
.clickIfVisible(selectors.ticketSales.firstSaleThumbnailImage)
|
|
.countElement(selectors.ticketSales.firstSaleZoomedImage);
|
|
|
|
expect(result).toEqual(1);
|
|
});
|
|
|
|
it(`should click on the zoomed image to close it`, async() => {
|
|
const result = await nightmare
|
|
.clickIfVisible(selectors.ticketSales.firstSaleZoomedImage)
|
|
.countElement(selectors.ticketSales.firstSaleZoomedImage);
|
|
|
|
expect(result).toEqual(0);
|
|
});
|
|
|
|
it(`should confirm the item descriptor insnt visible yet`, async() => {
|
|
const visible = await nightmare
|
|
.isVisible(selectors.ticketSales.saleDescriptorPopover);
|
|
|
|
expect(visible).toBeFalsy();
|
|
});
|
|
|
|
it(`should click on the first sale ID making the item descriptor visible`, async() => {
|
|
const visible = await nightmare
|
|
.waitToClick(selectors.ticketSales.firstSaleId)
|
|
.waitImgLoad(selectors.ticketSales.firstSaleDescriptorImage)
|
|
.isVisible(selectors.ticketSales.saleDescriptorPopover);
|
|
|
|
expect(visible).toBeTruthy();
|
|
});
|
|
|
|
it(`should click on the descriptor image of the 1st sale and see the zoomed image`, async() => {
|
|
const result = await nightmare
|
|
.clickIfVisible('vn-item-descriptor img')
|
|
.countElement(selectors.ticketSales.firstSaleZoomedImage);
|
|
|
|
expect(result).toEqual(1);
|
|
});
|
|
|
|
it(`should now click on the zoomed image to close it`, async() => {
|
|
const result = await nightmare
|
|
.clickIfVisible(selectors.ticketSales.firstSaleZoomedImage)
|
|
.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() => {
|
|
const url = await nightmare
|
|
.waitToClick(selectors.ticketSales.saleDescriptorPopoverSummaryButton)
|
|
.waitForURL('/summary')
|
|
.parsedUrl();
|
|
|
|
expect(url.hash).toContain('/summary');
|
|
});
|
|
|
|
it('should return to ticket sales section', async() => {
|
|
const url = await nightmare
|
|
.waitToClick(selectors.globalItems.applicationsMenuButton)
|
|
.wait(selectors.globalItems.applicationsMenuVisible)
|
|
.waitToClick(selectors.globalItems.ticketsButton)
|
|
.accessToSearchResult(16)
|
|
.accessToSection('ticket.card.sale')
|
|
.waitForURL('/sale')
|
|
.parsedUrl();
|
|
|
|
expect(url.hash).toContain('/sale');
|
|
});
|
|
|
|
it('should try to add a higher quantity value and then receive an error', async() => {
|
|
const result = await nightmare
|
|
.focusElement(selectors.ticketSales.firstSaleQuantityCell)
|
|
.write(selectors.ticketSales.firstSaleQuantity, '11\u000d')
|
|
.waitForLastSnackbar();
|
|
|
|
expect(result).toEqual('The new quantity should be smaller than the old one');
|
|
});
|
|
|
|
it('should remove 1 from the first sale quantity', async() => {
|
|
const result = await nightmare
|
|
.focusElement(selectors.ticketSales.firstSaleQuantityCell)
|
|
.write(selectors.ticketSales.firstSaleQuantity, '9\u000d')
|
|
.waitForLastSnackbar();
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
});
|
|
|
|
it('should update the price', async() => {
|
|
const result = await nightmare
|
|
.waitToClick(`${selectors.ticketSales.firstSalePrice} > span`)
|
|
.write(selectors.ticketSales.firstSalePriceInput, '5\u000d')
|
|
.waitForLastSnackbar();
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
});
|
|
|
|
it('should confirm the price have been updated', async() => {
|
|
const result = await nightmare
|
|
.waitToGetProperty(`${selectors.ticketSales.firstSalePrice} span`, 'innerText');
|
|
|
|
expect(result).toContain('5.00');
|
|
});
|
|
|
|
it('should confirm the total price for that item have been updated', async() => {
|
|
const result = await nightmare
|
|
.waitToGetProperty(selectors.ticketSales.firstSaleImport, 'innerText');
|
|
|
|
expect(result).toContain('45.00');
|
|
});
|
|
|
|
it('should update the discount', async() => {
|
|
const result = await nightmare
|
|
.waitToClick(`${selectors.ticketSales.firstSaleDiscount} > span`)
|
|
.write(selectors.ticketSales.firstSaleDiscountInput, '50\u000d')
|
|
.waitForLastSnackbar();
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
});
|
|
|
|
it('should confirm the discount have been updated', async() => {
|
|
const result = await nightmare
|
|
.waitForTextInElement(`${selectors.ticketSales.firstSaleDiscount} > span`, '50.00%')
|
|
.waitToGetProperty(`${selectors.ticketSales.firstSaleDiscount} > span`, 'innerText');
|
|
|
|
expect(result).toContain('50.00%');
|
|
});
|
|
|
|
it('should confirm the total import for that item have been updated', async() => {
|
|
const result = await nightmare
|
|
.waitForTextInElement(selectors.ticketSales.firstSaleImport, '22.50')
|
|
.waitToGetProperty(selectors.ticketSales.firstSaleImport, 'innerText');
|
|
|
|
expect(result).toContain('22.50');
|
|
});
|
|
|
|
it('should select the third sale and create a claim of it', async() => {
|
|
const url = await nightmare
|
|
.waitToClick(selectors.ticketSales.thirdSaleCheckbox)
|
|
.waitToClick(selectors.ticketSales.moreMenu)
|
|
.waitToClick(selectors.ticketSales.moreMenuCreateClaim)
|
|
.wait(selectors.claimBasicData.claimState)
|
|
.parsedUrl();
|
|
|
|
expect(url.hash).toContain('basic-data');
|
|
});
|
|
|
|
it('should click on the Claims button of the top bar menu', async() => {
|
|
const url = await nightmare
|
|
.waitToClick(selectors.globalItems.applicationsMenuButton)
|
|
.wait(selectors.globalItems.applicationsMenuVisible)
|
|
.waitToClick(selectors.globalItems.claimsButton)
|
|
.wait(selectors.claimsIndex.searchClaimInput)
|
|
.parsedUrl();
|
|
|
|
expect(url.hash).toEqual('#!/claim/index');
|
|
});
|
|
|
|
it('should search for the claim with id 4', async() => {
|
|
const result = await nightmare
|
|
.write(selectors.claimsIndex.searchClaimInput, 4)
|
|
.waitToClick(selectors.claimsIndex.searchButton)
|
|
.waitForNumberOfElements(selectors.claimsIndex.searchResult, 1)
|
|
.countElement(selectors.claimsIndex.searchResult);
|
|
|
|
expect(result).toEqual(1);
|
|
});
|
|
|
|
it('should click the Tickets button of the top bar menu', async() => {
|
|
const url = await nightmare
|
|
.waitToClick(selectors.globalItems.applicationsMenuButton)
|
|
.wait(selectors.globalItems.applicationsMenuVisible)
|
|
.waitToClick(selectors.globalItems.ticketsButton)
|
|
.wait(selectors.ticketsIndex.topbarSearch)
|
|
.parsedUrl();
|
|
|
|
expect(url.hash).toEqual('#!/ticket/index');
|
|
});
|
|
|
|
it('should search for a ticket then access to the sales section', async() => {
|
|
const url = await nightmare
|
|
.accessToSearchResult(16)
|
|
.accessToSection('ticket.card.sale')
|
|
.waitForURL('/sale')
|
|
.parsedUrl();
|
|
|
|
expect(url.hash).toContain('/sale');
|
|
});
|
|
|
|
it('should select the third sale and delete it', async() => {
|
|
const result = await nightmare
|
|
.waitToClick(selectors.ticketSales.thirdSaleCheckbox)
|
|
.waitToClick(selectors.ticketSales.deleteSaleButton)
|
|
.waitToClick(selectors.ticketSales.acceptDeleteLineButton)
|
|
.waitForSpinnerLoad()
|
|
.waitForLastSnackbar();
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
});
|
|
|
|
it(`should confirm the third sale was deleted`, async() => {
|
|
const result = await nightmare
|
|
.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;
|
|
|
|
const result = await nightmare
|
|
.waitToClick(selectors.ticketSales.secondSaleCheckbox)
|
|
.waitToClick(selectors.ticketSales.transferSaleButton)
|
|
.focusElement(selectors.ticketSales.transferQuantityCell)
|
|
.write(selectors.ticketSales.transferQuantityInput, '10\u000d')
|
|
.write(selectors.ticketSales.moveToTicketInput, targetTicketId)
|
|
.waitToClick(selectors.ticketSales.moveToTicketButton)
|
|
.waitForURL(`ticket/${targetTicketId}/sale`)
|
|
.parsedUrl();
|
|
|
|
expect(result.hash).toContain(`ticket/${targetTicketId}/sale`);
|
|
});
|
|
|
|
it('should confirm the transfered line is the correct one', async() => {
|
|
const result = await nightmare
|
|
.wait(selectors.ticketSales.secondSaleText)
|
|
.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 nightmare
|
|
.waitToGetProperty(selectors.ticketSales.secondSaleQuantityCell, 'innerText');
|
|
|
|
expect(result).toContain('10');
|
|
});
|
|
|
|
it('should go back to the original ticket sales section', async() => {
|
|
const url = await nightmare
|
|
.waitToClick(selectors.ticketDescriptor.goBackToModuleIndexButton)
|
|
.accessToSearchResult(16)
|
|
.accessToSection('ticket.card.sale')
|
|
.waitForURL('/sale')
|
|
.parsedUrl();
|
|
|
|
expect(url.hash).toContain('/sale');
|
|
});
|
|
|
|
it(`should confirm the original ticket has still three lines`, async() => {
|
|
const result = await nightmare
|
|
.wait(selectors.ticketSales.saleLine)
|
|
.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 nightmare
|
|
.waitToGetProperty(selectors.ticketSales.secondSaleQuantityCell, 'innerText');
|
|
|
|
expect(result).toContain('10');
|
|
});
|
|
|
|
it('should go back to the receiver ticket sales section', async() => {
|
|
const url = await nightmare
|
|
.waitToClick(selectors.ticketDescriptor.goBackToModuleIndexButton)
|
|
.accessToSearchResult(12)
|
|
.accessToSection('ticket.card.sale')
|
|
.waitForURL('/sale')
|
|
.parsedUrl();
|
|
|
|
expect(url.hash).toContain('/sale');
|
|
});
|
|
|
|
it('should transfer the sale back to the original ticket', async() => {
|
|
const targetTicketId = 16;
|
|
|
|
const result = await nightmare
|
|
.waitToClick(selectors.ticketSales.secondSaleCheckbox)
|
|
.waitToClick(selectors.ticketSales.transferSaleButton)
|
|
.write(selectors.ticketSales.moveToTicketInput, targetTicketId)
|
|
.waitToClick(selectors.ticketSales.moveToTicketButton)
|
|
.waitForURL(`ticket/${targetTicketId}/sale`)
|
|
.parsedUrl();
|
|
|
|
expect(result.hash).toContain(`ticket/${targetTicketId}/sale`);
|
|
});
|
|
|
|
it('should confirm the original ticket received the line', async() => {
|
|
const expectedLines = 4;
|
|
const result = await nightmare
|
|
.waitForNumberOfElements(selectors.ticketSales.saleLine, expectedLines)
|
|
.countElement(selectors.ticketSales.saleLine);
|
|
|
|
expect(result).toEqual(expectedLines);
|
|
});
|
|
|
|
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
|
|
.waitToClick(selectors.ticketDescriptor.goBackToModuleIndexButton)
|
|
.accessToSearchResult(13)
|
|
.accessToSection('ticket.card.sale')
|
|
.waitForURL('/sale')
|
|
.parsedUrl();
|
|
|
|
expect(url.hash).toContain('/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;
|
|
|
|
const url = await nightmare
|
|
.waitToClick(selectors.ticketSales.selectAllSalesCheckbox)
|
|
.waitToClick(selectors.ticketSales.transferSaleButton)
|
|
.waitToClick(selectors.ticketSales.moveToNewTicketButton)
|
|
.waitToClick(selectors.ticketSales.acceptDeleteTicketButton)
|
|
.wait((selector, ticketId) => {
|
|
return document.querySelector(selector).innerText.toLowerCase().indexOf(`${ticketId}`) == -1;
|
|
}, selectors.ticketDescriptor.idLabelValue, senderTicketId)
|
|
.parsedUrl();
|
|
|
|
expect(url.hash).toContain('/sale');
|
|
});
|
|
|
|
it('should confirm the new ticket received the line', async() => {
|
|
const result = await nightmare
|
|
.countElement(selectors.ticketSales.saleLine);
|
|
|
|
expect(result).toEqual(1);
|
|
});
|
|
|
|
it('should check the first sale reserved icon isnt visible', async() => {
|
|
const result = await nightmare
|
|
.isVisible(selectors.ticketSales.firstSaleReservedIcon);
|
|
|
|
expect(result).toBeFalsy();
|
|
});
|
|
|
|
it('should mark the first sale as reserved', async() => {
|
|
const result = await nightmare
|
|
.waitToClick(selectors.ticketSales.firstSaleCheckbox)
|
|
.waitToClick(selectors.ticketSales.moreMenu)
|
|
.waitToClick(selectors.ticketSales.moreMenuReserve)
|
|
.waitForClassNotPresent(selectors.ticketSales.firstSaleReservedIcon, 'ng-hide')
|
|
.isVisible(selectors.ticketSales.firstSaleReservedIcon);
|
|
|
|
expect(result).toBeTruthy();
|
|
});
|
|
|
|
it('should unmark the first sale as reserved', async() => {
|
|
const result = await nightmare
|
|
.waitToClick(selectors.ticketSales.moreMenu)
|
|
.waitToClick(selectors.ticketSales.moreMenuUnmarkReseved)
|
|
.waitForClassPresent(selectors.ticketSales.firstSaleReservedIcon, 'ng-hide')
|
|
.isVisible(selectors.ticketSales.firstSaleReservedIcon);
|
|
|
|
expect(result).toBeFalsy();
|
|
});
|
|
|
|
it('should update all sales discount', async() => {
|
|
const result = await nightmare
|
|
.waitToClick(selectors.ticketSales.moreMenu)
|
|
.waitToClick(selectors.ticketSales.moreMenuUpdateDiscount)
|
|
// .write(selectors.ticketSales.moreMenuUpdateDiscountInput, 100) can't find the selector on app (deleted the selector), menu option was removed?
|
|
.write('body', '\u000d')
|
|
.waitForTextInElement(selectors.ticketSales.totalImport, '0.00')
|
|
.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() => {
|
|
const url = await nightmare
|
|
.loginAndModule('production', 'ticket')
|
|
.accessToSearchResult(13)
|
|
.waitForURL('/summary')
|
|
.parsedUrl();
|
|
|
|
expect(url.hash).toContain('/summary');
|
|
});
|
|
|
|
it(`should check it's state is deleted`, async() => {
|
|
const result = await nightmare
|
|
.waitToGetProperty(selectors.ticketDescriptor.stateLabelValue, 'innerText');
|
|
|
|
expect(result).toEqual('State Eliminado');
|
|
});
|
|
|
|
describe('when state is preparation and loged as Production', () => {
|
|
it(`should not be able to edit the sale price`, async() => {
|
|
const result = await nightmare
|
|
.waitToClick(selectors.ticketDescriptor.goBackToModuleIndexButton)
|
|
.accessToSearchResult(8)
|
|
.accessToSection('ticket.card.sale')
|
|
.waitToClick(selectors.ticketSales.firstSalePrice)
|
|
.exists(selectors.ticketSales.firstSalePriceInput);
|
|
|
|
expect(result).toBeFalsy();
|
|
});
|
|
|
|
it(`should not be able to edit the sale discount`, async() => {
|
|
const result = await nightmare
|
|
.waitToClick(selectors.ticketSales.firstSaleDiscount)
|
|
.exists(selectors.ticketSales.firstSaleDiscountInput);
|
|
|
|
expect(result).toBeFalsy();
|
|
});
|
|
|
|
it(`should not be able to edit the sale state`, async() => {
|
|
const result = await nightmare
|
|
.waitToClick(selectors.ticketSales.stateMenuButton)
|
|
.exists(selectors.ticketSales.stateMenuOptions);
|
|
|
|
expect(result).toBeFalsy();
|
|
});
|
|
|
|
it('should log in as salesPerson then go to the sales of a target ticket', async() => {
|
|
const url = await nightmare
|
|
.loginAndModule('salesPerson', 'ticket')
|
|
.accessToSearchResult(8)
|
|
.accessToSection('ticket.card.sale')
|
|
.waitForURL('/sale')
|
|
.parsedUrl();
|
|
|
|
expect(url.hash).toContain('/sale');
|
|
});
|
|
});
|
|
|
|
describe('when state is preparation and loged as salesPerson', () => {
|
|
it(`shouldn't be able to edit the sale price`, async() => {
|
|
const result = await nightmare
|
|
.waitToClick(selectors.ticketSales.firstSalePrice)
|
|
.exists(selectors.ticketSales.firstSalePriceInput);
|
|
|
|
expect(result).toBeFalsy();
|
|
});
|
|
|
|
it(`should be able to edit the sale discount`, async() => {
|
|
const result = await nightmare
|
|
.waitToClick(selectors.ticketSales.firstSaleDiscount)
|
|
.exists(selectors.ticketSales.firstSaleDiscountInput);
|
|
|
|
expect(result).toBeFalsy();
|
|
});
|
|
|
|
it(`should not be able to edit the sale state`, async() => {
|
|
const result = await nightmare
|
|
.waitToClick(selectors.ticketSales.stateMenuButton)
|
|
.exists(selectors.ticketSales.stateMenuOptions);
|
|
|
|
expect(result).toBeFalsy();
|
|
});
|
|
});
|
|
});
|