salix/e2e/paths/08-route-module/01_create.spec.js

69 lines
2.5 KiB
JavaScript

import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
describe('Route create path', () => {
let browser;
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('employee', 'route');
});
afterAll(async() => {
await browser.close();
});
describe('as employee', () => {
it('should click on the add new route button and open the creation form', async() => {
await page.waitForContentLoaded();
await page.waitToClick(selectors.routeIndex.addNewRouteButton);
let url = await page.expectURL('#!/route/create');
expect(url).toBe(true);
});
it(`should attempt to create a new route but fail since employee has no access rights`, async() => {
await page.write(selectors.createRouteView.description, 'faster faster!!');
await page.waitToClick(selectors.createRouteView.submitButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Access denied');
});
});
describe('as delivery', () => {
beforeAll(async() => {
await page.login('delivery');
await page.selectModule('route');
await page.changeLanguageToEnglish();
});
it('should again click on the add new route button and open the creation form', async() => {
await page.waitToClick(selectors.routeIndex.addNewRouteButton);
let url = await page.expectURL('#!/route/create');
expect(url).toBe(true);
});
it(`should create a new route`, async() => {
await page.autocompleteSearch(selectors.createRouteView.worker, 'teamManagerNick');
await page.datePicker(selectors.createRouteView.createdDatePicker, 0, null);
await page.autocompleteSearch(selectors.createRouteView.vehicleAuto, '4444-IMK');
await page.autocompleteSearch(selectors.createRouteView.agency, 'Teleportation device');
await page.write(selectors.createRouteView.description, 'faster faster!!');
await page.waitToClick(selectors.createRouteView.submitButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it(`should confirm the redirection to the created route summary`, async() => {
let url = await page.expectURL('/summary');
expect(url).toBe(true);
});
});
});