2018-04-05 12:14:34 +00:00
|
|
|
import selectors from '../../helpers/selectors.js';
|
2018-10-24 08:57:14 +00:00
|
|
|
import createNightmare from '../../helpers/nightmare';
|
2018-04-05 12:14:34 +00:00
|
|
|
|
2018-12-19 07:42:07 +00:00
|
|
|
describe('Ticket Create new tracking state path', () => {
|
|
|
|
const nightmare = createNightmare();
|
|
|
|
|
2019-01-22 14:55:58 +00:00
|
|
|
describe('as production', () => {
|
|
|
|
beforeAll(() => {
|
|
|
|
return nightmare
|
|
|
|
.loginAndModule('production', 'ticket')
|
|
|
|
.accessToSearchResult('id:1')
|
|
|
|
.accessToSection('ticket.card.tracking.index');
|
|
|
|
});
|
2018-12-19 07:42:07 +00:00
|
|
|
|
2019-01-22 14:55:58 +00:00
|
|
|
it('should access to the create state view by clicking the create floating button', async() => {
|
|
|
|
let url = await nightmare
|
2019-02-04 13:47:55 +00:00
|
|
|
.clickIfVisible(selectors.ticketTracking.createStateButton)
|
2019-01-22 14:55:58 +00:00
|
|
|
.wait(selectors.createStateView.stateAutocomplete)
|
|
|
|
.parsedUrl();
|
2018-12-19 07:42:07 +00:00
|
|
|
|
2019-02-04 13:47:55 +00:00
|
|
|
|
2019-01-22 14:55:58 +00:00
|
|
|
expect(url.hash).toContain('tracking/edit');
|
|
|
|
});
|
2018-12-19 07:42:07 +00:00
|
|
|
|
2019-01-22 14:55:58 +00:00
|
|
|
it(`should attempt create a new state but receive an error if state is empty`, async() => {
|
|
|
|
let result = await nightmare
|
2019-01-23 14:33:25 +00:00
|
|
|
.waitToClick(selectors.createStateView.saveStateButton)
|
2019-01-22 14:55:58 +00:00
|
|
|
.waitForLastSnackbar();
|
|
|
|
|
|
|
|
expect(result).toEqual('State cannot be blank');
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`should create a new state`, async() => {
|
|
|
|
let result = await nightmare
|
|
|
|
.autocompleteSearch(selectors.createStateView.stateAutocomplete, '¿Fecha?')
|
2019-01-23 15:00:56 +00:00
|
|
|
.waitToClick(selectors.createStateView.saveStateButton)
|
2019-01-22 14:55:58 +00:00
|
|
|
.waitForLastSnackbar();
|
2018-12-19 07:42:07 +00:00
|
|
|
|
2019-01-22 14:55:58 +00:00
|
|
|
expect(result).toEqual('Data saved!');
|
|
|
|
});
|
2018-12-19 07:42:07 +00:00
|
|
|
});
|
|
|
|
|
2019-01-22 14:55:58 +00:00
|
|
|
describe('as salesPerson', () => {
|
|
|
|
beforeAll(() => {
|
|
|
|
return nightmare
|
|
|
|
.loginAndModule('salesPerson', 'ticket')
|
|
|
|
.accessToSearchResult('id:1')
|
|
|
|
.accessToSection('ticket.card.tracking.index');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should now access to the create state view by clicking the create floating button', async() => {
|
|
|
|
let url = await nightmare
|
|
|
|
.waitToClick(selectors.ticketTracking.createStateButton)
|
|
|
|
.wait(selectors.createStateView.stateAutocomplete)
|
|
|
|
.parsedUrl();
|
|
|
|
|
|
|
|
expect(url.hash).toContain('tracking/edit');
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`should attemp to create an state for which salesPerson doesn't have permissions`, async() => {
|
|
|
|
let result = await nightmare
|
2019-02-01 16:11:14 +00:00
|
|
|
.autocompleteSearch(selectors.createStateView.stateAutocomplete, 'Encajado')
|
2019-01-23 15:00:56 +00:00
|
|
|
.waitToClick(selectors.createStateView.saveStateButton)
|
2019-01-22 14:55:58 +00:00
|
|
|
.waitForLastSnackbar();
|
|
|
|
|
2019-01-29 20:00:27 +00:00
|
|
|
expect(result).toEqual(`You don't have enough privileges`);
|
2019-01-22 14:55:58 +00:00
|
|
|
});
|
|
|
|
|
2019-08-19 05:56:20 +00:00
|
|
|
it(`should make sure the worker gets autocomplete uppon selecting the assigned state`, async() => {
|
2019-01-22 14:55:58 +00:00
|
|
|
let result = await nightmare
|
|
|
|
.autocompleteSearch(selectors.createStateView.stateAutocomplete, 'asignado')
|
2019-08-19 05:56:20 +00:00
|
|
|
.waitToGetProperty(`${selectors.createStateView.workerAutocomplete} input`, 'value');
|
2019-01-22 14:55:58 +00:00
|
|
|
|
2019-08-19 05:56:20 +00:00
|
|
|
expect(result).toEqual('salesPersonNick');
|
2019-01-22 14:55:58 +00:00
|
|
|
});
|
2018-12-19 07:42:07 +00:00
|
|
|
|
2019-08-19 05:56:20 +00:00
|
|
|
it(`should succesfully create a valid state`, async() => {
|
2019-01-22 14:55:58 +00:00
|
|
|
let result = await nightmare
|
2019-01-23 15:00:56 +00:00
|
|
|
.waitToClick(selectors.createStateView.saveStateButton)
|
2019-01-22 14:55:58 +00:00
|
|
|
.waitForLastSnackbar();
|
2018-12-19 07:42:07 +00:00
|
|
|
|
2019-01-22 14:55:58 +00:00
|
|
|
expect(result).toEqual('Data saved!');
|
|
|
|
});
|
2018-04-05 12:14:34 +00:00
|
|
|
});
|
|
|
|
});
|