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

85 lines
3.4 KiB
JavaScript

import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
describe('Ticket Create new tracking state path', () => {
let browser;
let page;
afterAll(async() => {
await browser.close();
});
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');
});
it('should access to the create state view by clicking the create floating button', async() => {
await page.waitToClick(selectors.ticketTracking.createStateButton);
await page.waitForSelector(selectors.createStateView.state, {visible: true});
let url = await page.parsedUrl();
expect(url.hash).toContain('tracking/edit');
});
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();
expect(result).toEqual('State cannot be blank');
});
it(`should create a new state`, async() => {
await page.autocompleteSearch(selectors.createStateView.state, '¿Fecha?');
await page.waitToClick(selectors.createStateView.saveStateButton);
let result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
});
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');
});
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();
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.state, 'Encajado');
await page.waitToClick(selectors.createStateView.saveStateButton);
let result = await page.waitForLastSnackbar();
expect(result).toEqual(`You don't have enough privileges`);
});
it(`should make sure the worker gets autocomplete uppon selecting the assigned state`, async() => {
await page.autocompleteSearch(selectors.createStateView.state, 'asignado');
let result = await page
.waitToGetProperty(selectors.createStateView.worker, 'value');
expect(result).toEqual('salesPersonNick');
});
it(`should succesfully create a valid state`, async() => {
await page.waitToClick(selectors.createStateView.saveStateButton);
let result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
});
});