2019-01-16 07:52:56 +00:00
|
|
|
import selectors from '../../helpers/selectors.js';
|
|
|
|
import createNightmare from '../../helpers/nightmare';
|
|
|
|
|
2019-02-07 13:33:52 +00:00
|
|
|
describe('Ticket create path', () => {
|
2019-01-16 07:52:56 +00:00
|
|
|
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');
|
|
|
|
});
|
|
|
|
|
2019-01-24 13:03:01 +00:00
|
|
|
it('should attempt to create a ticket for a frozen client but fail', async() => {
|
2019-01-16 07:52:56 +00:00
|
|
|
const result = await nightmare
|
|
|
|
.autocompleteSearch(selectors.createTicketView.clientAutocomplete, 'Bruce Banner')
|
|
|
|
.autocompleteSearch(selectors.createTicketView.addressAutocomplete, 'Bruce Banner')
|
2019-05-02 09:23:54 +00:00
|
|
|
.datePicker(selectors.createTicketView.deliveryDateInput, 1, null)
|
2019-01-16 07:52:56 +00:00
|
|
|
.autocompleteSearch(selectors.createTicketView.warehouseAutocomplete, 'Warehouse One')
|
2019-05-30 12:17:11 +00:00
|
|
|
.autocompleteSearch(selectors.createTicketView.agencyAutocomplete, 'Silla247')
|
2019-06-11 10:23:55 +00:00
|
|
|
.wait(1999)
|
2019-01-16 07:52:56 +00:00
|
|
|
.waitToClick(selectors.createTicketView.createButton)
|
|
|
|
.waitForLastSnackbar();
|
|
|
|
|
2019-02-07 13:33:52 +00:00
|
|
|
expect(result).toMatch(/You can't create a ticket for a inactive|frozen client/);
|
2019-01-16 07:52:56 +00:00
|
|
|
});
|
|
|
|
|
2019-01-23 14:34:16 +00:00
|
|
|
it('should succeed to create a ticket for a valid client', async() => {
|
2019-01-16 07:52:56 +00:00
|
|
|
const result = await nightmare
|
|
|
|
.autocompleteSearch(selectors.createTicketView.clientAutocomplete, 'Tony Stark')
|
|
|
|
.autocompleteSearch(selectors.createTicketView.addressAutocomplete, 'Tony Stark')
|
|
|
|
.autocompleteSearch(selectors.createTicketView.warehouseAutocomplete, 'Warehouse One')
|
2019-05-30 12:17:11 +00:00
|
|
|
.autocompleteSearch(selectors.createTicketView.agencyAutocomplete, 'Silla247')
|
2019-01-16 07:52:56 +00:00
|
|
|
.waitToClick(selectors.createTicketView.createButton)
|
|
|
|
.waitForLastSnackbar();
|
|
|
|
|
2019-01-24 13:03:01 +00:00
|
|
|
expect(result).toEqual('Data saved!');
|
2019-01-16 07:52:56 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
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');
|
|
|
|
});
|
|
|
|
});
|