salix/e2e/paths/02-client/02_edit_basic_data.spec.js

157 lines
6.5 KiB
JavaScript
Raw Normal View History

import selectors from '../../helpers/selectors';
import getBrowser from '../../helpers/puppeteer';
describe('Client Edit basicData path', () => {
let browser;
2019-12-12 07:37:35 +00:00
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
2019-12-12 07:37:35 +00:00
await page.loginAndModule('employee', 'client');
2019-12-31 11:00:16 +00:00
await page.accessToSearchResult('Bruce Wayne');
await page.accessToSection('client.card.basicData');
});
2019-12-12 07:37:35 +00:00
afterAll(async() => {
await browser.close();
});
2019-12-12 07:37:35 +00:00
describe('as employee', () => {
2019-01-07 08:33:07 +00:00
it('should not be able to change the salesPerson', async() => {
2020-02-03 14:55:11 +00:00
await page.wait(selectors.clientBasicData.name);
2019-12-31 11:00:16 +00:00
const result = await page.evaluate(selector => {
return document.querySelector(selector).disabled;
2020-02-03 14:55:11 +00:00
}, `${selectors.clientBasicData.salesPerson} input`);
2018-10-30 07:51:18 +00:00
expect(result).toBeTruthy();
});
2019-01-07 08:33:07 +00:00
it('should edit the client basic data but leave salesPerson untainted', async() => {
2020-02-03 14:55:11 +00:00
await page.clearInput(selectors.clientBasicData.name);
await page.write(selectors.clientBasicData.name, 'Ptonomy Wallace');
await page.clearInput(selectors.clientBasicData.contact);
await page.write(selectors.clientBasicData.contact, 'David Haller');
await page.clearInput(selectors.clientBasicData.email);
await page.write(selectors.clientBasicData.email, 'PWallace@verdnatura.es');
await page.autocompleteSearch(selectors.clientBasicData.channel, 'Rumors on the streets');
2019-12-31 11:00:16 +00:00
await page.waitToClick(selectors.clientBasicData.saveButton);
2020-04-08 09:24:40 +00:00
const message = await page.waitForSnackbar();
2018-10-30 07:51:18 +00:00
2020-10-30 16:09:11 +00:00
expect(message.text).toBe('Data saved!');
});
2019-01-07 08:33:07 +00:00
it('should confirm the name have been edited', async() => {
2019-12-31 11:00:16 +00:00
await page.reloadSection('client.card.basicData');
2020-02-03 14:55:11 +00:00
const result = await page.waitToGetProperty(selectors.clientBasicData.name, 'value');
2018-10-30 07:51:18 +00:00
expect(result).toEqual('Ptonomy Wallace');
});
2019-01-07 08:33:07 +00:00
it('should confirm the contact name have been edited', async() => {
2019-12-31 11:00:16 +00:00
const result = await page
2020-02-03 14:55:11 +00:00
.waitToGetProperty(selectors.clientBasicData.contact, 'value');
2018-10-30 07:51:18 +00:00
expect(result).toEqual('David Haller');
});
2019-01-07 08:33:07 +00:00
it('should confirm the email have been edited', async() => {
2019-12-31 11:00:16 +00:00
const result = await page
2020-02-03 14:55:11 +00:00
.waitToGetProperty(selectors.clientBasicData.email, 'value');
2018-10-30 07:51:18 +00:00
expect(result).toEqual('PWallace@verdnatura.es');
});
2019-01-07 08:33:07 +00:00
it('should confirm the channel have been selected', async() => {
2019-12-31 11:00:16 +00:00
const result = await page
2020-02-03 14:55:11 +00:00
.waitToGetProperty(selectors.clientBasicData.channel, 'value');
2018-10-30 07:51:18 +00:00
expect(result).toEqual('Rumors on the streets');
});
2019-12-12 07:37:35 +00:00
});
2018-11-29 10:06:57 +00:00
describe('as salesAssistant', () => {
it('should navigate to a client basic data', async() => {
2019-12-31 11:00:16 +00:00
await page.loginAndModule('salesASsistant', 'client');
await page.accessToSearchResult('Ptonomy Wallace');
await page.accessToSection('client.card.basicData');
2020-02-12 06:31:46 +00:00
});
2019-01-07 08:33:07 +00:00
it('should be able to change the salesPerson', async() => {
await page.waitForSelector(selectors.clientBasicData.name);
2019-12-31 11:00:16 +00:00
const result = await page.evaluate(selector => {
return document.querySelector(selector).disabled;
2020-02-03 14:55:11 +00:00
}, `${selectors.clientBasicData.salesPerson} input`);
2018-10-30 07:51:18 +00:00
expect(result).toBeFalsy();
});
2019-01-07 08:33:07 +00:00
it('should edit the client basic data including salesPerson', async() => {
2020-02-03 14:55:11 +00:00
await page.clearInput(selectors.clientBasicData.name);
await page.write(selectors.clientBasicData.name, 'Ororo Munroe');
await page.clearInput(selectors.clientBasicData.contact);
await page.write(selectors.clientBasicData.contact, 'Black Panther');
await page.clearInput(selectors.clientBasicData.email);
await page.write(selectors.clientBasicData.email, 'Storm@verdnatura.es');
2020-02-06 12:00:41 +00:00
await page.clearInput(selectors.clientBasicData.phone);
await page.write(selectors.clientBasicData.phone, '333333333');
await page.clearInput(selectors.clientBasicData.mobile);
await page.write(selectors.clientBasicData.mobile, '444444444');
2020-02-03 14:55:11 +00:00
await page.autocompleteSearch(selectors.clientBasicData.salesPerson, 'replenisherNick');
await page.autocompleteSearch(selectors.clientBasicData.channel, 'Metropolis newspaper');
2019-12-31 11:00:16 +00:00
await page.waitToClick(selectors.clientBasicData.saveButton);
2020-04-08 09:24:40 +00:00
const message = await page.waitForSnackbar();
2018-10-30 07:51:18 +00:00
2020-10-30 16:09:11 +00:00
expect(message.text).toBe('Data saved!');
});
2019-01-07 08:33:07 +00:00
it('should now confirm the name have been edited', async() => {
2019-12-31 11:00:16 +00:00
await page.reloadSection('client.card.basicData');
2020-02-03 14:55:11 +00:00
const result = await page.waitToGetProperty(selectors.clientBasicData.name, 'value');
2018-10-30 07:51:18 +00:00
expect(result).toEqual('Ororo Munroe');
});
2019-01-07 08:33:07 +00:00
it('should now confirm the contact name have been edited', async() => {
2019-12-31 11:00:16 +00:00
const result = await page
2020-02-03 14:55:11 +00:00
.waitToGetProperty(selectors.clientBasicData.contact, 'value');
2018-10-30 07:51:18 +00:00
expect(result).toEqual('Black Panther');
});
2019-01-07 08:33:07 +00:00
it('should now confirm the email have been edited', async() => {
2019-12-31 11:00:16 +00:00
const result = await page
2020-02-03 14:55:11 +00:00
.waitToGetProperty(selectors.clientBasicData.email, 'value');
2018-10-30 07:51:18 +00:00
expect(result).toEqual('Storm@verdnatura.es');
});
2020-02-06 12:00:41 +00:00
it('should now confirm the phone have been edited', async() => {
const result = await page
.waitToGetProperty(selectors.clientBasicData.phone, 'value');
expect(result).toEqual('333333333');
});
it('should now confirm the mobile have been edited', async() => {
const result = await page
.waitToGetProperty(selectors.clientBasicData.mobile, 'value');
expect(result).toEqual('444444444');
});
2019-01-07 08:33:07 +00:00
it('should confirm the sales person have been selected', async() => {
2019-12-31 11:00:16 +00:00
const result = await page
2020-02-03 14:55:11 +00:00
.waitToGetProperty(selectors.clientBasicData.salesPerson, 'value');
2018-10-30 07:51:18 +00:00
2019-04-17 06:21:58 +00:00
expect(result).toEqual('replenisherNick');
});
2019-01-07 08:33:07 +00:00
it('should now confirm the channel have been selected', async() => {
2019-12-31 11:00:16 +00:00
const result = await page
2020-02-03 14:55:11 +00:00
.waitToGetProperty(selectors.clientBasicData.channel, 'value');
2018-10-30 07:51:18 +00:00
expect(result).toEqual('Metropolis newspaper');
});
});
});