#1020 modificar e2e ticket.tracking

This commit is contained in:
Carlos Jimenez Ruiz 2019-01-22 15:55:58 +01:00
parent ea0e56e6a6
commit dc46ede513
4 changed files with 85 additions and 35 deletions

View File

@ -12,7 +12,7 @@ export default function createNightmare(width = 1280, height = 720) {
nightmare.on('console', (type, message, ...args) => { nightmare.on('console', (type, message, ...args) => {
if (type === 'error') if (type === 'error')
fail(message); throw new Error(message);
else else
console[type](message, ...args); console[type](message, ...args);
}); });

View File

@ -192,7 +192,7 @@ export default {
moreMenu: `vn-item-descriptor vn-icon-menu > div > vn-icon`, moreMenu: `vn-item-descriptor vn-icon-menu > div > vn-icon`,
moreMenuRegularizeButton: `vn-item-descriptor vn-icon-menu > div > vn-drop-down > vn-popover ul > li:nth-child(1)`, moreMenuRegularizeButton: `vn-item-descriptor vn-icon-menu > div > vn-drop-down > vn-popover ul > li:nth-child(1)`,
regularizeQuantityInput: `vn-item-descriptor > vn-dialog > div > form > div.body > tpl-body > div > vn-textfield > div > div > div.infix > input`, regularizeQuantityInput: `vn-item-descriptor > vn-dialog > div > form > div.body > tpl-body > div > vn-textfield > div > div > div.infix > input`,
regularizeWarehouseAutocomplete: `#warehouse`, regularizeWarehouseAutocomplete: 'vn-item-descriptor > vn-dialog vn-autocomplete[field="$ctrl.warehouseFk"]',
regularizeSaveButton: `vn-item-descriptor > vn-dialog > div > form > div.buttons > tpl-buttons > button` regularizeSaveButton: `vn-item-descriptor > vn-dialog > div > form > div.buttons > tpl-buttons > button`
}, },
itemBasicData: { itemBasicData: {
@ -439,6 +439,7 @@ export default {
}, },
createStateView: { createStateView: {
stateAutocomplete: `vn-autocomplete[field="$ctrl.stateFk"]`, stateAutocomplete: `vn-autocomplete[field="$ctrl.stateFk"]`,
workerAutocomplete: `vn-autocomplete[field="$ctrl.workerFk"]`,
clearStateInputButton: `vn-autocomplete[field="$ctrl.stateFk"] > div > div > div > vn-icon > i`, clearStateInputButton: `vn-autocomplete[field="$ctrl.stateFk"] > div > div > div > vn-icon > i`,
saveStateButton: `${components.vnSubmit}` saveStateButton: `${components.vnSubmit}`
}, },

View File

@ -4,47 +4,94 @@ import createNightmare from '../../helpers/nightmare';
describe('Ticket Create new tracking state path', () => { describe('Ticket Create new tracking state path', () => {
const nightmare = createNightmare(); const nightmare = createNightmare();
beforeAll(() => { describe('as production', () => {
return nightmare beforeAll(() => {
.loginAndModule('production', 'ticket') return nightmare
.accessToSearchResult('id:1') .loginAndModule('production', 'ticket')
.accessToSection('ticket.card.tracking.index'); .accessToSearchResult('id:1')
.accessToSection('ticket.card.tracking.index');
});
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();
expect(url.hash).toContain('tracking/edit');
});
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');
});
it(`should create a new state`, async() => {
let result = await nightmare
.autocompleteSearch(selectors.createStateView.stateAutocomplete, '¿Fecha?')
.click(selectors.createStateView.saveStateButton)
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
}); });
it('should access to the create state view by clicking the create floating button', async() => { describe('as salesPerson', () => {
let url = await nightmare beforeAll(() => {
.waitToClick(selectors.ticketTracking.createStateButton) return nightmare
.wait(selectors.createStateView.stateAutocomplete) .loginAndModule('salesPerson', 'ticket')
.parsedUrl(); .accessToSearchResult('id:1')
.accessToSection('ticket.card.tracking.index');
});
expect(url.hash).toContain('tracking/edit'); 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();
it(`should attempt create a new state but receive an error if state is empty`, async() => { expect(url.hash).toContain('tracking/edit');
let result = await nightmare });
.click(selectors.createStateView.saveStateButton)
.waitForLastSnackbar();
expect(result).toEqual('State cannot be blank'); 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();
it(`should attempt create a new state then clear and save it`, async() => { expect(result).toEqual(`You don't have enough privileges to change the state of this ticket`);
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'); 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`);
});
it(`should create a new state`, async() => { it(`should create a new state with all it's data`, async() => {
let result = await nightmare let result = await nightmare
.autocompleteSearch(selectors.createStateView.stateAutocomplete, '¿Fecha?') .autocompleteSearch(selectors.createStateView.workerAutocomplete, 'accessory')
.click(selectors.createStateView.saveStateButton) .click(selectors.createStateView.saveStateButton)
.waitForLastSnackbar(); .waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
});
}); });
}); });

View File

@ -27,5 +27,7 @@
"Agency cannot be blank": "Agency cannot be blank", "Agency cannot be blank": "Agency cannot be blank",
"The IBAN does not have the correct format": "The IBAN does not have the correct format", "The IBAN does not have the correct format": "The IBAN does not have the correct format",
"You can't make changes on the basic data of an confirmed order or with rows": "You can't make changes on the basic data of an confirmed order or with rows", "You can't make changes on the basic data of an confirmed order or with rows": "You can't make changes on the basic data of an confirmed order or with rows",
"You can't create a ticket for a inactive client": "You can't create a ticket for a inactive client" "You can't create a ticket for a inactive client": "You can't create a ticket for a inactive client",
"Worker cannot be blank": "Worker cannot be blank",
"You don't have enough privileges to change the state of this ticket": "You don't have enough privileges to change the state of this ticket"
} }