2020-01-14 08:20:14 +00:00
|
|
|
import selectors from '../../helpers/selectors';
|
|
|
|
import getBrowser from '../../helpers/puppeteer';
|
2017-12-13 10:25:50 +00:00
|
|
|
|
2018-10-16 13:35:52 +00:00
|
|
|
describe('Client Edit basicData path', () => {
|
2020-01-14 08:20:14 +00:00
|
|
|
let browser;
|
2019-12-12 07:37:35 +00:00
|
|
|
let page;
|
|
|
|
beforeAll(async() => {
|
2020-01-14 08:20:14 +00:00
|
|
|
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');
|
2018-10-16 13:35:52 +00:00
|
|
|
});
|
|
|
|
|
2019-12-12 07:37:35 +00:00
|
|
|
afterAll(async() => {
|
2020-01-14 08:20:14 +00:00
|
|
|
await browser.close();
|
2017-11-03 17:32:58 +00:00
|
|
|
});
|
2019-12-12 07:37:35 +00:00
|
|
|
|
2019-12-31 10:40:15 +00:00
|
|
|
describe('as employee', () => {
|
2019-01-07 08:33:07 +00:00
|
|
|
it('should not be able to change the salesPerson', async() => {
|
2020-11-23 17:28:39 +00:00
|
|
|
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).toBeTruthy();
|
2018-10-16 13:35:52 +00:00
|
|
|
});
|
|
|
|
|
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-11-10 11:06:21 +00:00
|
|
|
expect(message.text).toContain('Data saved!');
|
2018-10-16 13:35:52 +00:00
|
|
|
});
|
|
|
|
|
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');
|
2018-10-16 13:35:52 +00:00
|
|
|
});
|
|
|
|
|
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');
|
2018-10-16 13:35:52 +00:00
|
|
|
});
|
|
|
|
|
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');
|
2018-10-16 13:35:52 +00:00
|
|
|
});
|
|
|
|
|
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');
|
2018-10-16 13:35:52 +00:00
|
|
|
});
|
2019-12-12 07:37:35 +00:00
|
|
|
});
|
|
|
|
|
2018-11-29 10:06:57 +00:00
|
|
|
describe('as salesAssistant', () => {
|
2020-02-12 06:21:53 +00:00
|
|
|
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
|
|
|
});
|
2018-10-16 13:35:52 +00:00
|
|
|
|
2019-01-07 08:33:07 +00:00
|
|
|
it('should be able to change the salesPerson', async() => {
|
2020-02-12 06:21:53 +00:00
|
|
|
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();
|
2018-10-16 13:35:52 +00:00
|
|
|
});
|
|
|
|
|
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');
|
2021-04-14 06:49:10 +00:00
|
|
|
await page.autocompleteSearch(selectors.clientBasicData.salesPerson, 'salesPerson');
|
2020-02-03 14:55:11 +00:00
|
|
|
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-11-10 11:06:21 +00:00
|
|
|
expect(message.text).toContain('Data saved!');
|
2018-02-20 09:00:19 +00:00
|
|
|
});
|
2017-11-03 17:32:58 +00:00
|
|
|
|
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');
|
2018-02-20 09:00:19 +00:00
|
|
|
});
|
2017-11-03 17:32:58 +00:00
|
|
|
|
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');
|
2018-02-20 09:00:19 +00:00
|
|
|
});
|
2017-11-03 17:32:58 +00:00
|
|
|
|
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');
|
2018-02-20 09:00:19 +00:00
|
|
|
});
|
2017-11-03 17:32:58 +00:00
|
|
|
|
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
|
|
|
|
2021-04-14 06:49:10 +00:00
|
|
|
expect(result).toEqual('salesPersonNick');
|
2018-02-20 09:00:19 +00:00
|
|
|
});
|
2017-11-03 17:32:58 +00:00
|
|
|
|
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');
|
2018-02-20 09:00:19 +00:00
|
|
|
});
|
2017-11-03 17:32:58 +00:00
|
|
|
});
|
|
|
|
});
|