salix/e2e/paths/05-ticket-module/05_tracking_state.spec.js

86 lines
3.5 KiB
JavaScript
Raw Normal View History

2018-04-05 12:14:34 +00:00
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
2018-04-05 12:14:34 +00:00
2018-12-19 07:42:07 +00:00
describe('Ticket Create new tracking state path', () => {
let browser;
let page;
afterAll(async() => {
await browser.close();
});
2018-12-19 07:42:07 +00:00
2019-01-22 14:55:58 +00:00
describe('as production', () => {
it('should log into the ticket 1 tracking', async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('production', 'ticket');
await page.accessToSearchResult('1');
await page.accessToSection('ticket.card.tracking.index');
2019-01-22 14:55:58 +00:00
});
2018-12-19 07:42:07 +00:00
2019-01-22 14:55:58 +00:00
it('should access to the create state view by clicking the create floating button', async() => {
2020-01-26 23:48:00 +00:00
await page.waitForContentLoaded();
await page.waitToClick(selectors.ticketTracking.createStateButton);
await page.waitForSelector(selectors.createStateView.stateAutocomplete, {visible: true});
let url = await page.parsedUrl();
2019-02-04 13:47:55 +00:00
2019-01-22 14:55:58 +00:00
expect(url.hash).toContain('tracking/edit');
});
2018-12-19 07:42:07 +00:00
2019-01-22 14:55:58 +00:00
it(`should attempt create a new state but receive an error if state is empty`, async() => {
await page.waitToClick(selectors.createStateView.saveStateButton);
let result = await page.waitForLastSnackbar();
2019-01-22 14:55:58 +00:00
expect(result).toEqual('State cannot be blank');
});
it(`should create a new state`, async() => {
await page.autocompleteSearch(selectors.createStateView.stateAutocomplete, '¿Fecha?');
await page.waitToClick(selectors.createStateView.saveStateButton);
let result = await page.waitForLastSnackbar();
2018-12-19 07:42:07 +00:00
2019-01-22 14:55:58 +00:00
expect(result).toEqual('Data saved!');
});
2018-12-19 07:42:07 +00:00
});
2019-01-22 14:55:58 +00:00
describe('as salesPerson', () => {
it('should now log into the ticket 1 tracking', async() => {
await page.loginAndModule('salesPerson', 'ticket');
await page.accessToSearchResult('1');
await page.accessToSection('ticket.card.tracking.index');
2019-01-22 14:55:58 +00:00
});
it('should now access to the create state view by clicking the create floating button', async() => {
await page.waitToClick(selectors.ticketTracking.createStateButton);
await page.waitForURL('tracking/edit');
let url = await page.parsedUrl();
2019-01-22 14:55:58 +00:00
expect(url.hash).toContain('tracking/edit');
});
it(`should attemp to create an state for which salesPerson doesn't have permissions`, async() => {
await page.waitFor(1500);
await page.autocompleteSearch(selectors.createStateView.stateAutocomplete, 'Encajado');
await page.waitToClick(selectors.createStateView.saveStateButton);
let result = await page.waitForLastSnackbar();
2019-01-22 14:55:58 +00:00
2019-01-29 20:00:27 +00:00
expect(result).toEqual(`You don't have enough privileges`);
2019-01-22 14:55:58 +00:00
});
2019-08-19 05:56:20 +00:00
it(`should make sure the worker gets autocomplete uppon selecting the assigned state`, async() => {
await page.autocompleteSearch(selectors.createStateView.stateAutocomplete, 'asignado');
let result = await page
.waitToGetProperty(selectors.createStateView.workerAutocomplete, 'value');
2019-01-22 14:55:58 +00:00
2019-08-19 05:56:20 +00:00
expect(result).toEqual('salesPersonNick');
2019-01-22 14:55:58 +00:00
});
2018-12-19 07:42:07 +00:00
2019-08-19 05:56:20 +00:00
it(`should succesfully create a valid state`, async() => {
await page.waitToClick(selectors.createStateView.saveStateButton);
let result = await page.waitForLastSnackbar();
2018-12-19 07:42:07 +00:00
2019-01-22 14:55:58 +00:00
expect(result).toEqual('Data saved!');
});
2018-04-05 12:14:34 +00:00
});
});