#875 e2e ticket create

This commit is contained in:
Carlos Jimenez 2019-01-16 08:52:56 +01:00
parent c766e27a19
commit 8ea3278a10
3 changed files with 85 additions and 2 deletions

View File

@ -329,6 +329,36 @@ let actions = {
.catch(() => {
done(new Error(`.autocompleteSearch() for ${autocompleteSelector}, timed out`));
});
},
datePicker: function(datePickerSelector, changeMonth, done) {
this.wait(datePickerSelector)
.mousedown(datePickerSelector)
.wait('div.flatpickr-calendar.open');
if (changeMonth > 0)
this.mousedown('body > div > div.flatpickr-months > span.flatpickr-next-month > svg');
if (changeMonth < 0)
this.mousedown('body > div > div.flatpickr-months > span.flatpickr-prev-month > svg');
const daySelector = 'div.flatpickr-calendar.open span.flatpickr-day:nth-child(16)';
this.wait(selector => {
return document.querySelector(selector);
}, daySelector)
.evaluate(selector => {
let event = new MouseEvent('mousedown', {
bubbles: true,
cancelable: true,
view: window
});
document.querySelector(selector).dispatchEvent(event);
}, daySelector)
.then(done)
.catch(() => {
done(new Error(`.datePicker(), for ${daySelector} timed out`));
});
}
};

View File

@ -0,0 +1,54 @@
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 atempt to create a ticket for a frozen client but fail', async() => {
const result = await nightmare
.autocompleteSearch(selectors.createTicketView.clientAutocomplete, 'Bruce Banner')
.autocompleteSearch(selectors.createTicketView.addressAutocomplete, 'Bruce Banner')
.datePicker(selectors.createTicketView.deliveryDateInput, 1)
.autocompleteSearch(selectors.createTicketView.warehouseAutocomplete, 'Warehouse One')
.autocompleteSearch(selectors.createTicketView.agencyAutocomplete, 'inhouse pickup')
.waitToClick(selectors.createTicketView.createButton)
.waitForLastSnackbar();
expect(result).toEqual(`You can't create a ticket for a inactive client`);
});
it('should suceed to create a ticket for a valid client', async() => {
const result = await nightmare
.autocompleteSearch(selectors.createTicketView.clientAutocomplete, 'Tony Stark')
.autocompleteSearch(selectors.createTicketView.addressAutocomplete, 'Tony Stark')
.datePicker(selectors.createTicketView.deliveryDateInput, 1)
.autocompleteSearch(selectors.createTicketView.warehouseAutocomplete, 'Warehouse One')
.autocompleteSearch(selectors.createTicketView.agencyAutocomplete, 'inhouse pickup')
.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');
});
});

View File

@ -27,7 +27,6 @@
ini-options="{enableTime: false}">
</vn-date-picker>
<vn-autocomplete
vn-one
disabled="!$ctrl.clientFk || !$ctrl.landed"
field="$ctrl.warehouseFk"
url="/agency/api/Warehouses"