salix/e2e/paths/05-ticket/14_create_ticket.spec.js

70 lines
2.8 KiB
JavaScript
Raw Normal View History

2019-01-16 07:52:56 +00:00
import selectors from '../../helpers/selectors.js';
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', () => {
let browser;
let page;
2023-01-16 14:18:24 +00:00
let nextMonth = Date.vnNew();
2020-06-10 14:51:04 +00:00
nextMonth.setMonth(nextMonth.getMonth() + 1);
2019-01-16 07:52:56 +00:00
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
2023-07-19 12:14:35 +00:00
await page.loginAndModule('salesPerson', 'ticket');
});
afterAll(async() => {
await browser.close();
2019-01-16 07:52:56 +00:00
});
it('should open the new ticket form', async() => {
await page.waitToClick(selectors.ticketsIndex.newTicketButton);
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');
2022-06-22 10:40:11 +00:00
await page.autocompleteSearch(selectors.createTicketView.agency, 'Gotham247');
2020-06-10 14:51:04 +00:00
await page.waitToClick(selectors.createTicketView.createButton);
const message = await page.waitForSnackbar();
2020-11-10 11:06:21 +00:00
expect(message.text).toContain('Data saved!');
2020-06-10 14:51:04 +00:00
});
it('should check the url is now the summary of the ticket', async() => {
await page.waitForState('ticket.card.summary');
});
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-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');
await page.pickDate(selectors.createTicketView.deliveryDate, nextMonth);
2020-02-03 14:55:11 +00:00
await page.autocompleteSearch(selectors.createTicketView.warehouse, 'Warehouse One');
2022-06-22 10:40:11 +00:00
await page.autocompleteSearch(selectors.createTicketView.agency, 'Gotham247');
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-11-10 11:06:21 +00:00
expect(message.text).toContain('Data saved!');
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() => {
await page.waitForState('ticket.card.summary');
2019-01-16 07:52:56 +00:00
});
2020-06-10 14:51:04 +00:00
it('should delete the current ticket', async() => {
await page.waitToClick(selectors.ticketDescriptor.moreMenu);
await page.waitToClick(selectors.ticketDescriptor.moreMenuDeleteTicket);
2020-10-13 13:40:55 +00:00
await page.waitToClick(selectors.ticketDescriptor.acceptDialog);
2020-06-10 14:51:04 +00:00
const message = await page.waitForSnackbar();
2020-11-10 11:06:21 +00:00
expect(message.text).toContain('Ticket deleted. You can undo this action within the first hour');
2020-06-10 14:51:04 +00:00
});
2019-01-16 07:52:56 +00:00
});