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-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();
|
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);
|
|
|
|
const result = await page.waitForLastSnackbar();
|
2018-10-30 07:51:18 +00:00
|
|
|
|
|
|
|
expect(result).toEqual('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', () => {
|
2019-12-31 11:00:16 +00:00
|
|
|
beforeAll(async() => {
|
|
|
|
await page.loginAndModule('salesASsistant', 'client');
|
|
|
|
await page.accessToSearchResult('Ptonomy Wallace');
|
|
|
|
await page.accessToSection('client.card.basicData');
|
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-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).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');
|
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);
|
|
|
|
const result = await page.waitForLastSnackbar();
|
2018-10-30 07:51:18 +00:00
|
|
|
|
|
|
|
expect(result).toEqual('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
|
|
|
|
2019-04-17 06:21:58 +00:00
|
|
|
expect(result).toEqual('replenisherNick');
|
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
|
|
|
});
|
|
|
|
});
|