#1253 e2e route.create

This commit is contained in:
Carlos Jimenez Ruiz 2019-03-29 16:29:18 +01:00
parent d70a9dee1d
commit a16a45842f
3 changed files with 83 additions and 0 deletions

View File

@ -552,6 +552,20 @@ export default {
passwordInput: 'vn-worker-pbx vn-textfield[model="$ctrl.worker.sip.secret"] input',
saveButton: 'vn-worker-pbx vn-submit[label="Save"] input'
},
routeIndex: {
addNewRouteButton: 'vn-route-index > a[ui-sref="route.create"]'
},
createRouteView: {
workerAutocomplete: 'vn-route-create vn-autocomplete[field="$ctrl.route.workerFk"]',
createdDatePicker: 'vn-route-create vn-date-picker[model="$ctrl.route.created"] > div > input',
vehicleAutoComplete: 'vn-route-create vn-autocomplete[field="$ctrl.route.vehicleFk"]',
agencyAutoComplete: 'vn-route-create vn-autocomplete[field="$ctrl.route.agencyModeFk"]',
descriptionInput: 'vn-route-create vn-textfield[field="$ctrl.route.description"] input',
submitButton: 'vn-route-create vn-submit > input[type="submit"]'
},
routeSummary: {
routeId: 'vn-route-summary > vn-card > div > vn-horizontal > vn-one:nth-child(1) > vn-label-value:nth-child(1) > section > span'
},
routeBasicData: {
workerAutoComplete: 'vn-route-basic-data vn-autocomplete[field="$ctrl.route.workerFk"]',
vehicleAutoComplete: 'vn-route-basic-data vn-autocomplete[field="$ctrl.route.vehicleFk"]',

View File

@ -0,0 +1,69 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
fdescribe('Route create path', () => {
const nightmare = createNightmare();
describe('as employee', () => {
beforeAll(() => {
nightmare
.loginAndModule('employee', 'route');
});
it('should click on the add new route button and open the creation form', async() => {
const url = await nightmare
.waitToClick(selectors.routeIndex.addNewRouteButton)
.wait(selectors.createRouteView.workerAutocomplete)
.parsedUrl();
expect(url.hash).toEqual('#!/route/create');
});
it(`should attempt to create a new route but fail since employee has no access rights`, async() => {
const result = await nightmare
.write(selectors.createRouteView.descriptionInput, 'faster faster!!')
.waitToClick(selectors.createRouteView.submitButton)
.waitForLastSnackbar();
expect(result).toEqual('Access denied');
});
});
describe('as delivery', () => {
beforeAll(() => {
nightmare
.login('delivery')
.selectModule('route')
.changeLanguageToEnglish();
});
it('should again click on the add new route button and open the creation form', async() => {
const url = await nightmare
.waitToClick(selectors.routeIndex.addNewRouteButton)
.wait(selectors.createRouteView.workerAutocomplete)
.parsedUrl();
expect(url.hash).toEqual('#!/route/create');
});
it(`should create a new route`, async() => {
const result = await nightmare
.autocompleteSearch(selectors.createRouteView.workerAutocomplete, 'teamManagerNick')
.datePicker(selectors.createRouteView.createdDatePicker, 0)
.autocompleteSearch(selectors.createRouteView.vehicleAutoComplete, '4444-IMK')
.autocompleteSearch(selectors.createRouteView.agencyAutoComplete, 'Teleportation device')
.write(selectors.createRouteView.descriptionInput, 'faster faster!!')
.waitToClick(selectors.createRouteView.submitButton)
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it(`should confirm the redirection to the created route summary`, async() => {
const url = await nightmare
.wait(selectors.routeSummary.routeId)
.parsedUrl();
expect(url.hash).toContain('/summary');
});
});
});