2019-01-16 07:52:56 +00:00
|
|
|
import selectors from '../../helpers/selectors.js';
|
2020-01-23 15:01:29 +00:00
|
|
|
import getBrowser from '../../helpers/puppeteer';
|
2019-01-16 07:52:56 +00:00
|
|
|
|
2019-02-07 13:33:52 +00:00
|
|
|
describe('Ticket create path', () => {
|
2020-01-23 15:01:29 +00:00
|
|
|
let browser;
|
|
|
|
let page;
|
2020-06-10 14:51:04 +00:00
|
|
|
let nextMonth = new Date();
|
|
|
|
nextMonth.setMonth(nextMonth.getMonth() + 1);
|
|
|
|
let stowawayTicketId;
|
2019-01-16 07:52:56 +00:00
|
|
|
|
2020-01-23 15:01:29 +00:00
|
|
|
beforeAll(async() => {
|
|
|
|
browser = await getBrowser();
|
|
|
|
page = browser.page;
|
|
|
|
await page.loginAndModule('employee', 'ticket');
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async() => {
|
|
|
|
await browser.close();
|
2019-01-16 07:52:56 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should open the new ticket form', async() => {
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.waitToClick(selectors.ticketsIndex.newTicketButton);
|
2020-03-24 15:49:36 +00:00
|
|
|
await page.waitForState('ticket.create');
|
2019-01-16 07:52:56 +00:00
|
|
|
});
|
|
|
|
|
2019-11-21 12:18:44 +00:00
|
|
|
it('should succeed to create a ticket', async() => {
|
2020-06-10 14:51:04 +00:00
|
|
|
await page.autocompleteSearch(selectors.createTicketView.client, 'Clark Kent');
|
|
|
|
await page.pickDate(selectors.createTicketView.deliveryDate, nextMonth);
|
|
|
|
await page.autocompleteSearch(selectors.createTicketView.warehouse, 'Warehouse Two');
|
|
|
|
await page.autocompleteSearch(selectors.createTicketView.agency, 'Silla247');
|
|
|
|
await page.waitToClick(selectors.createTicketView.createButton);
|
|
|
|
const message = await page.waitForSnackbar();
|
|
|
|
|
|
|
|
expect(message.type).toBe('success');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should check the url is now the summary of the ticket', async() => {
|
|
|
|
await page.waitForState('ticket.card.summary');
|
2020-06-11 07:20:44 +00:00
|
|
|
stowawayTicketId = await page.waitToGetProperty(selectors.ticketSummary.descriptorTicketId, 'innerText');
|
2020-06-10 14:51:04 +00:00
|
|
|
stowawayTicketId = stowawayTicketId.substring(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should again open the new ticket form', async() => {
|
|
|
|
await page.waitToClick(selectors.globalItems.returnToModuleIndexButton);
|
|
|
|
await page.waitToClick(selectors.ticketsIndex.newTicketButton);
|
|
|
|
await page.waitForState('ticket.create');
|
|
|
|
});
|
2020-03-23 22:57:11 +00:00
|
|
|
|
2020-06-10 14:51:04 +00:00
|
|
|
it('should succeed to create another ticket for the same client', async() => {
|
|
|
|
await page.autocompleteSearch(selectors.createTicketView.client, 'Clark Kent');
|
2020-03-23 22:57:11 +00:00
|
|
|
await page.pickDate(selectors.createTicketView.deliveryDate, nextMonth);
|
2020-02-03 14:55:11 +00:00
|
|
|
await page.autocompleteSearch(selectors.createTicketView.warehouse, 'Warehouse One');
|
|
|
|
await page.autocompleteSearch(selectors.createTicketView.agency, 'Silla247');
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.waitToClick(selectors.createTicketView.createButton);
|
2020-04-08 09:24:40 +00:00
|
|
|
const message = await page.waitForSnackbar();
|
2019-01-16 07:52:56 +00:00
|
|
|
|
2020-04-08 09:24:40 +00:00
|
|
|
expect(message.type).toBe('success');
|
2019-01-16 07:52:56 +00:00
|
|
|
});
|
|
|
|
|
2020-06-10 14:51:04 +00:00
|
|
|
it('should check the url is now the summary of the created ticket', async() => {
|
2020-03-24 15:49:36 +00:00
|
|
|
await page.waitForState('ticket.card.summary');
|
2019-01-16 07:52:56 +00:00
|
|
|
});
|
2020-06-10 14:51:04 +00:00
|
|
|
|
|
|
|
it('should make the previously created ticket the stowaway of the current ticket', async() => {
|
|
|
|
await page.waitToClick(selectors.ticketDescriptor.moreMenu);
|
|
|
|
await page.waitToClick(selectors.ticketDescriptor.moreMenuAddStowaway);
|
|
|
|
await page.waitToClick(selectors.ticketDescriptor.addStowawayDialogFirstTicket);
|
|
|
|
const message = await page.waitForSnackbar();
|
|
|
|
|
|
|
|
expect(message.type).toBe('success');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should delete the current ticket', async() => {
|
|
|
|
await page.waitToClick(selectors.ticketDescriptor.moreMenu);
|
|
|
|
await page.waitToClick(selectors.ticketDescriptor.moreMenuDeleteTicket);
|
|
|
|
await page.waitToClick(selectors.ticketDescriptor.acceptDeleteButton);
|
|
|
|
const message = await page.waitForSnackbar();
|
|
|
|
|
|
|
|
expect(message.type).toBe('success');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should search for the stowaway ticket of the previously deleted ticket', async() => {
|
|
|
|
await page.accessToSearchResult(stowawayTicketId);
|
|
|
|
const result = await page.countElement(selectors.ticketDescriptor.shipButton);
|
|
|
|
|
|
|
|
expect(result).toBe(0);
|
|
|
|
});
|
2019-01-16 07:52:56 +00:00
|
|
|
});
|