70 lines
2.7 KiB
JavaScript
70 lines
2.7 KiB
JavaScript
|
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');
|
||
|
});
|
||
|
});
|
||
|
});
|