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-11-23 17:28:39 +00:00
|
|
|
await page.waitForTimeout(500);
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.waitToClick(selectors.routeIndex.addNewRouteButton);
|
2020-03-24 15:49:36 +00:00
|
|
|
await page.waitForState('route.create');
|
2019-03-29 15:29:18 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it(`should attempt to create a new route but fail since employee has no access rights`, async() => {
|
2020-02-03 14:55:11 +00:00
|
|
|
await page.write(selectors.createRouteView.description, 'faster faster!!');
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.waitToClick(selectors.createRouteView.submitButton);
|
2020-04-08 09:24:40 +00:00
|
|
|
const message = await page.waitForSnackbar();
|
2019-03-29 15:29:18 +00:00
|
|
|
|
2020-11-10 11:06:21 +00:00
|
|
|
expect(message.text).toContain('Access denied');
|
2019-03-29 15:29:18 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('as delivery', () => {
|
2020-01-23 15:01:29 +00:00
|
|
|
beforeAll(async() => {
|
|
|
|
await page.login('delivery');
|
|
|
|
await page.selectModule('route');
|
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);
|
2020-03-24 15:49:36 +00:00
|
|
|
await page.waitForState('route.create');
|
2019-03-29 15:29:18 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it(`should create a new route`, async() => {
|
2020-02-03 14:55:11 +00:00
|
|
|
await page.autocompleteSearch(selectors.createRouteView.worker, 'teamManagerNick');
|
2020-03-23 22:57:11 +00:00
|
|
|
await page.pickDate(selectors.createRouteView.createdDatePicker);
|
2020-02-03 14:55:11 +00:00
|
|
|
await page.autocompleteSearch(selectors.createRouteView.vehicleAuto, '4444-IMK');
|
|
|
|
await page.autocompleteSearch(selectors.createRouteView.agency, 'Teleportation device');
|
|
|
|
await page.write(selectors.createRouteView.description, 'faster faster!!');
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.waitToClick(selectors.createRouteView.submitButton);
|
2020-04-08 09:24:40 +00:00
|
|
|
const message = await page.waitForSnackbar();
|
2019-03-29 15:29:18 +00:00
|
|
|
|
2020-11-10 11:06:21 +00:00
|
|
|
expect(message.text).toContain('Data saved!');
|
2019-03-29 15:29:18 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it(`should confirm the redirection to the created route summary`, async() => {
|
2020-03-24 15:49:36 +00:00
|
|
|
await page.waitForState('route.card.summary');
|
2019-03-29 15:29:18 +00:00
|
|
|
});
|
2020-12-24 12:15:14 +00:00
|
|
|
|
|
|
|
it(`should navigate back to the route index`, async() => {
|
|
|
|
await page.waitToClick(selectors.globalItems.returnToModuleIndexButton);
|
|
|
|
await page.waitForState('route.index');
|
|
|
|
});
|
|
|
|
|
2020-12-28 13:13:22 +00:00
|
|
|
let count;
|
2020-12-24 15:48:56 +00:00
|
|
|
it(`should count the amount of routes before clonation`, async() => {
|
2020-12-28 13:13:22 +00:00
|
|
|
await page.waitForFunction(selector => {
|
|
|
|
return document.querySelectorAll(selector).length > 6;
|
|
|
|
}, {}, selectors.routeIndex.anyResult);
|
|
|
|
count = await page.countElement(selectors.routeIndex.anyResult);
|
2020-12-24 15:48:56 +00:00
|
|
|
|
2020-12-28 13:13:22 +00:00
|
|
|
expect(count).toBeGreaterThanOrEqual(7);
|
2020-12-24 15:48:56 +00:00
|
|
|
});
|
|
|
|
|
2020-12-24 12:15:14 +00:00
|
|
|
it(`should clone the first route`, async() => {
|
2020-12-31 08:17:55 +00:00
|
|
|
await page.waitForTimeout(1000); // needs time for the index to show all items
|
2020-12-24 12:15:14 +00:00
|
|
|
await page.waitToClick(selectors.routeIndex.firstRouteCheckbox);
|
|
|
|
await page.waitToClick(selectors.routeIndex.cloneButton);
|
|
|
|
await page.waitToClick(selectors.routeIndex.submitClonationButton);
|
|
|
|
const message = await page.waitForSnackbar();
|
|
|
|
|
|
|
|
expect(message.text).toContain('Data saved!');
|
|
|
|
});
|
|
|
|
|
2020-12-24 15:48:56 +00:00
|
|
|
it(`should reload the section and count the amount of routes after clonation`, async() => {
|
2020-12-28 13:13:22 +00:00
|
|
|
await page.waitForNumberOfElements(selectors.routeIndex.anyResult, count + 1);
|
2020-12-24 15:48:56 +00:00
|
|
|
const result = await page.countElement(selectors.routeIndex.anyResult);
|
|
|
|
|
2020-12-28 13:13:22 +00:00
|
|
|
expect(result).toEqual(count + 1);
|
2020-12-24 12:15:14 +00:00
|
|
|
});
|
2019-03-29 15:29:18 +00:00
|
|
|
});
|
|
|
|
});
|