2019-03-29 15:29:18 +00:00
|
|
|
import selectors from '../../helpers/selectors.js';
|
2020-01-23 15:01:29 +00:00
|
|
|
import getBrowser from '../../helpers/puppeteer';
|
2019-03-29 15:29:18 +00:00
|
|
|
|
2019-03-29 15:30:04 +00:00
|
|
|
describe('Route create path', () => {
|
2020-01-23 15:01:29 +00:00
|
|
|
let browser;
|
|
|
|
let page;
|
|
|
|
|
|
|
|
beforeAll(async() => {
|
|
|
|
browser = await getBrowser();
|
|
|
|
page = browser.page;
|
|
|
|
await page.loginAndModule('employee', 'route');
|
|
|
|
});
|
2019-03-29 15:29:18 +00:00
|
|
|
|
2020-01-23 15:01:29 +00:00
|
|
|
afterAll(async() => {
|
|
|
|
await browser.close();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('as employee', () => {
|
2019-03-29 15:29:18 +00:00
|
|
|
it('should click on the add new route button and open the creation form', async() => {
|
2020-01-27 17:35:39 +00:00
|
|
|
await page.waitForContentLoaded();
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.waitToClick(selectors.routeIndex.addNewRouteButton);
|
|
|
|
await page.wait(selectors.createRouteView.workerAutocomplete);
|
|
|
|
const url = await page.parsedUrl();
|
2019-03-29 15:29:18 +00:00
|
|
|
|
|
|
|
expect(url.hash).toEqual('#!/route/create');
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`should attempt to create a new route but fail since employee has no access rights`, async() => {
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.write(selectors.createRouteView.descriptionInput, 'faster faster!!');
|
|
|
|
await page.waitToClick(selectors.createRouteView.submitButton);
|
|
|
|
const result = await page.waitForLastSnackbar();
|
2019-03-29 15:29:18 +00:00
|
|
|
|
|
|
|
expect(result).toEqual('Access denied');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('as delivery', () => {
|
2020-01-23 15:01:29 +00:00
|
|
|
beforeAll(async() => {
|
|
|
|
await page.login('delivery');
|
|
|
|
await page.selectModule('route');
|
|
|
|
await page.changeLanguageToEnglish();
|
2019-03-29 15:29:18 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should again click on the add new route button and open the creation form', async() => {
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.waitToClick(selectors.routeIndex.addNewRouteButton);
|
|
|
|
await page.wait(selectors.createRouteView.workerAutocomplete);
|
|
|
|
const url = await page.parsedUrl();
|
2019-03-29 15:29:18 +00:00
|
|
|
|
|
|
|
expect(url.hash).toEqual('#!/route/create');
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`should create a new route`, async() => {
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.autocompleteSearch(selectors.createRouteView.workerAutocomplete, 'teamManagerNick');
|
|
|
|
await page.datePicker(selectors.createRouteView.createdDatePicker, 0, null);
|
|
|
|
await page.autocompleteSearch(selectors.createRouteView.vehicleAutoComplete, '4444-IMK');
|
|
|
|
await page.autocompleteSearch(selectors.createRouteView.agencyAutoComplete, 'Teleportation device');
|
|
|
|
await page.write(selectors.createRouteView.descriptionInput, 'faster faster!!');
|
|
|
|
await page.waitToClick(selectors.createRouteView.submitButton);
|
|
|
|
const result = await page.waitForLastSnackbar();
|
2019-03-29 15:29:18 +00:00
|
|
|
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`should confirm the redirection to the created route summary`, async() => {
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.wait(selectors.routeSummary.routeId);
|
|
|
|
const url = await page.parsedUrl();
|
2019-03-29 15:29:18 +00:00
|
|
|
|
|
|
|
expect(url.hash).toContain('/summary');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|