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

165 lines
6.9 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() => {
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();
});
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');
await page.autocompleteSearch(selectors.clientBasicData.transferor, 'Max Eisenhardt');
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!');
});
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');
});
it('should confirm the previous client have been selected', async() => {
const result = await page
.waitToGetProperty(selectors.clientBasicData.transferor, 'value');
expect(result).toEqual('Max Eisenhardt');
});
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');
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!');
});
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
2021-04-14 06:49:10 +00:00
expect(result).toEqual('salesPersonNick');
});
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');
});
});
});