salix/e2e/paths/ticket-module/05_create_new_tracking_stat...

98 lines
3.9 KiB
JavaScript
Raw Normal View History

2018-04-05 12:14:34 +00:00
import selectors from '../../helpers/selectors.js';
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
.waitToClick(selectors.ticketTracking.createStateButton)
.wait(selectors.createStateView.stateAutocomplete)
.parsedUrl();
2018-12-19 07:42:07 +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
.click(selectors.createStateView.saveStateButton)
.waitForLastSnackbar();
expect(result).toEqual('State cannot be blank');
});
it(`should attempt create a new state then clear and save it`, async() => {
let result = await nightmare
.autocompleteSearch(selectors.createStateView.stateAutocomplete, '¿Fecha?')
.waitToClick(selectors.createStateView.clearStateInputButton)
.waitToClick(selectors.createStateView.saveStateButton)
.waitForLastSnackbar();
expect(result).toEqual('State cannot be blank');
});
2018-12-19 07:42:07 +00:00
2019-01-22 14:55:58 +00:00
it(`should create a new state`, async() => {
let result = await nightmare
.autocompleteSearch(selectors.createStateView.stateAutocomplete, '¿Fecha?')
.click(selectors.createStateView.saveStateButton)
.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
.autocompleteSearch(selectors.createStateView.stateAutocomplete, '¿Fecha?')
.click(selectors.createStateView.saveStateButton)
.waitForLastSnackbar();
expect(result).toEqual(`You don't have enough privileges to change the state of this ticket`);
});
it(`should attempt to create an state for the type salesPerson has rights but fail as worker is blank`, async() => {
let result = await nightmare
.autocompleteSearch(selectors.createStateView.stateAutocomplete, 'asignado')
.click(selectors.createStateView.saveStateButton)
.waitForLastSnackbar();
expect(result).toEqual(`Worker cannot be blank`);
});
2018-12-19 07:42:07 +00:00
2019-01-22 14:55:58 +00:00
it(`should create a new state with all it's data`, async() => {
let result = await nightmare
.autocompleteSearch(selectors.createStateView.workerAutocomplete, 'accessory')
.click(selectors.createStateView.saveStateButton)
.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
});
});