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

42 lines
1.5 KiB
JavaScript

import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
describe('Ticket create path', () => {
const nightmare = createNightmare();
beforeAll(() => {
nightmare
.loginAndModule('employee', 'ticket');
});
it('should open the new ticket form', async() => {
const url = await nightmare
.waitToClick(selectors.ticketsIndex.newTicketButton)
.wait(selectors.createTicketView.clientAutocomplete)
.parsedUrl();
expect(url.hash).toEqual('#!/ticket/create');
});
it('should succeed to create a ticket', async() => {
const result = await nightmare
.autocompleteSearch(selectors.createTicketView.clientAutocomplete, 'Tony Stark')
.autocompleteSearch(selectors.createTicketView.addressAutocomplete, 'Tony Stark')
.datePicker(selectors.createTicketView.deliveryDateInput, 1, null)
.autocompleteSearch(selectors.createTicketView.warehouseAutocomplete, 'Warehouse One')
.autocompleteSearch(selectors.createTicketView.agencyAutocomplete, 'Silla247')
.waitToClick(selectors.createTicketView.createButton)
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should check the url is now the summary of the ticket', async() => {
const url = await nightmare
.waitForURL('/summary')
.parsedUrl();
expect(url.hash).toContain('/summary');
});
});