salix/e2e/paths/08-route/03_create.spec.js

62 lines
2.3 KiB
JavaScript
Raw Normal View History

2019-03-29 15:29:18 +00:00
import selectors from '../../helpers/selectors.js';
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', () => {
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
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-08-28 17:52:54 +00:00
await page.waitFor(500);
await page.waitToClick(selectors.routeIndex.addNewRouteButton);
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!!');
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-04-08 09:24:40 +00:00
expect(message.text).toBe('Access denied');
2019-03-29 15:29:18 +00:00
});
});
describe('as delivery', () => {
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() => {
await page.waitToClick(selectors.routeIndex.addNewRouteButton);
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');
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!!');
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-04-08 09:24:40 +00:00
expect(message.type).toBe('success');
2019-03-29 15:29:18 +00:00
});
it(`should confirm the redirection to the created route summary`, async() => {
await page.waitForState('route.card.summary');
2019-03-29 15:29:18 +00:00
});
});
});