2018-02-20 09:00:19 +00:00
|
|
|
import selectors from '../../helpers/selectors';
|
2020-01-14 08:20:14 +00:00
|
|
|
import getBrowser from '../../helpers/puppeteer';
|
2017-12-13 10:25:50 +00:00
|
|
|
|
2020-03-25 19:44:59 +00:00
|
|
|
describe('Client create path', () => {
|
2020-01-14 08:20:14 +00:00
|
|
|
let browser;
|
2019-12-12 07:37:35 +00:00
|
|
|
let page;
|
2020-03-25 19:44:59 +00:00
|
|
|
|
2019-12-12 07:37:35 +00:00
|
|
|
beforeAll(async() => {
|
2020-01-14 08:20:14 +00:00
|
|
|
browser = await getBrowser();
|
|
|
|
page = browser.page;
|
2020-10-19 18:49:38 +00:00
|
|
|
await page.loginAndModule(' deliveryBoss', 'client');
|
2019-12-12 07:37:35 +00:00
|
|
|
});
|
2018-11-20 13:22:00 +00:00
|
|
|
|
2019-12-12 07:37:35 +00:00
|
|
|
afterAll(async() => {
|
2020-01-14 08:20:14 +00:00
|
|
|
await browser.close();
|
2018-11-20 13:22:00 +00:00
|
|
|
});
|
|
|
|
|
2019-01-07 08:33:07 +00:00
|
|
|
it(`should search for the user Carol Danvers to confirm it isn't created yet`, async() => {
|
2020-03-31 16:33:48 +00:00
|
|
|
await page.doSearch('Carol Danvers');
|
2020-10-01 06:53:31 +00:00
|
|
|
const result = await page.countElement(selectors.globalItems.searchResult);
|
2018-11-20 13:22:00 +00:00
|
|
|
|
|
|
|
expect(result).toEqual(0);
|
|
|
|
});
|
|
|
|
|
2019-01-07 08:33:07 +00:00
|
|
|
it('should now access to the create client view by clicking the create-client floating button', async() => {
|
2019-12-12 07:37:35 +00:00
|
|
|
await page.waitToClick(selectors.clientsIndex.createClientButton);
|
2020-03-23 22:57:11 +00:00
|
|
|
await page.waitForState('client.create');
|
2018-11-20 13:22:00 +00:00
|
|
|
});
|
|
|
|
|
2021-11-12 12:10:11 +00:00
|
|
|
it('should receive an error when clicking the create button having name and Business name fields empty',
|
|
|
|
async() => {
|
2021-11-18 11:15:37 +00:00
|
|
|
await page.autocompleteSearch(selectors.createClientView.salesPerson, 'salesPerson');
|
|
|
|
await page.autocompleteSearch(selectors.createClientView.businessType, 'florist');
|
2021-11-12 12:10:11 +00:00
|
|
|
await page.write(selectors.createClientView.taxNumber, '74451390E');
|
|
|
|
await page.write(selectors.createClientView.userName, 'CaptainMarvel');
|
|
|
|
await page.write(selectors.createClientView.email, 'CarolDanvers@verdnatura.es');
|
|
|
|
await page.waitToClick(selectors.createClientView.createButton);
|
|
|
|
const message = await page.waitForSnackbar();
|
|
|
|
|
|
|
|
expect(message.text).toContain('Some fields are invalid');
|
|
|
|
}
|
|
|
|
);
|
2018-11-20 13:22:00 +00:00
|
|
|
|
2020-10-19 18:49:38 +00:00
|
|
|
it(`should create a new province`, async() => {
|
|
|
|
await page.waitToClick(selectors.createClientView.addPostCode);
|
|
|
|
await page.waitToClick(selectors.createClientView.addProvince);
|
|
|
|
await page.write(selectors.createClientView.newProvinceName, 'Massachusetts');
|
2021-09-02 09:56:59 +00:00
|
|
|
await page.autocompleteSearch(selectors.createClientView.newProvinceAutonomy, 'Autonomy one');
|
2020-10-19 18:49:38 +00:00
|
|
|
await page.waitToClick(selectors.createClientView.saveNewProvicenButton);
|
|
|
|
const message = await page.waitForSnackbar();
|
|
|
|
|
2020-11-10 11:06:21 +00:00
|
|
|
expect(message.text).toContain('The province has been created');
|
2020-10-19 18:49:38 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it(`should create a new city`, async() => {
|
|
|
|
await page.waitToClick(selectors.createClientView.addCity);
|
|
|
|
await page.write(selectors.createClientView.newCityName, 'Boston');
|
|
|
|
await page.autocompleteSearch(selectors.createClientView.newCityProvince, 'Massachusetts');
|
|
|
|
await page.waitToClick(selectors.createClientView.saveNewCityButton);
|
|
|
|
const message = await page.waitForSnackbar();
|
|
|
|
|
2020-11-10 11:06:21 +00:00
|
|
|
expect(message.text).toContain('The city has been created');
|
2020-10-19 18:49:38 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it(`should create a new post code`, async() => {
|
|
|
|
await page.write(selectors.createClientView.newPostcode, '61616');
|
|
|
|
await page.waitToClick(selectors.createClientView.saveNewPoscode);
|
|
|
|
|
|
|
|
const message = await page.waitForSnackbar();
|
|
|
|
|
2020-11-10 11:06:21 +00:00
|
|
|
expect(message.text).toContain('The postcode has been created. You can save the data now');
|
2020-10-19 18:49:38 +00:00
|
|
|
});
|
|
|
|
|
2019-01-07 08:33:07 +00:00
|
|
|
it(`should attempt to create a new user with all it's data but wrong email`, async() => {
|
2019-12-12 07:37:35 +00:00
|
|
|
await page.write(selectors.createClientView.name, 'Carol Danvers');
|
|
|
|
await page.write(selectors.createClientView.socialName, 'AVG tax');
|
|
|
|
await page.write(selectors.createClientView.street, 'Many places');
|
|
|
|
await page.clearInput(selectors.createClientView.email);
|
|
|
|
await page.write(selectors.createClientView.email, 'incorrect email format');
|
|
|
|
await page.waitToClick(selectors.createClientView.createButton);
|
2020-04-08 09:24:40 +00:00
|
|
|
const message = await page.waitForSnackbar();
|
2018-11-20 13:22:00 +00:00
|
|
|
|
2020-11-10 11:06:21 +00:00
|
|
|
expect(message.text).toContain('Some fields are invalid');
|
2018-11-20 13:22:00 +00:00
|
|
|
});
|
|
|
|
|
2021-11-12 12:10:11 +00:00
|
|
|
it(`should attempt to create a new user with all it's data but wrong business type`, async() => {
|
2019-12-12 07:37:35 +00:00
|
|
|
await page.clearInput(selectors.createClientView.email);
|
|
|
|
await page.write(selectors.createClientView.email, 'CarolDanvers@verdnatura.es');
|
2021-11-12 12:10:11 +00:00
|
|
|
await page.clearInput(selectors.createClientView.businessType);
|
|
|
|
await page.waitToClick(selectors.createClientView.createButton);
|
|
|
|
const message = await page.waitForSnackbar();
|
|
|
|
|
2021-11-18 11:15:37 +00:00
|
|
|
expect(message.text).toContain('The type of business must be filled in basic data');
|
|
|
|
});
|
2021-11-12 12:10:11 +00:00
|
|
|
|
|
|
|
it(`should attempt to create a new user with all it's data but wrong postal code`, async() => {
|
|
|
|
await page.autocompleteSearch(selectors.createClientView.businessType, 'florist');
|
2019-12-12 07:37:35 +00:00
|
|
|
await page.clearInput(selectors.createClientView.postcode);
|
|
|
|
await page.write(selectors.createClientView.postcode, '479999');
|
|
|
|
await page.waitToClick(selectors.createClientView.createButton);
|
2020-04-08 09:24:40 +00:00
|
|
|
const message = await page.waitForSnackbar();
|
2019-10-04 11:13:14 +00:00
|
|
|
|
2020-11-10 11:06:21 +00:00
|
|
|
expect(message.text).toContain(`The postcode doesn't exist. Please enter a correct one`);
|
2019-10-04 11:13:14 +00:00
|
|
|
});
|
|
|
|
|
2019-06-13 11:08:11 +00:00
|
|
|
it(`should check for autocompleted city, province and country`, async() => {
|
2019-12-12 07:37:35 +00:00
|
|
|
const clientCity = await page
|
2020-01-29 13:54:07 +00:00
|
|
|
.waitToGetProperty(selectors.createClientView.city, 'value');
|
2019-06-13 11:08:11 +00:00
|
|
|
|
2019-12-12 07:37:35 +00:00
|
|
|
const clientProvince = await page
|
2020-01-29 13:54:07 +00:00
|
|
|
.waitToGetProperty(selectors.createClientView.province, 'value');
|
2019-06-13 11:08:11 +00:00
|
|
|
|
2019-12-12 07:37:35 +00:00
|
|
|
const clientCountry = await page
|
2020-01-29 13:54:07 +00:00
|
|
|
.waitToGetProperty(selectors.createClientView.country, 'value');
|
2019-06-13 11:08:11 +00:00
|
|
|
|
2020-10-19 18:49:38 +00:00
|
|
|
expect(clientCity).toEqual('Boston');
|
|
|
|
expect(clientProvince).toContain('Massachusetts');
|
2019-06-13 11:08:11 +00:00
|
|
|
expect(clientCountry).toEqual('España');
|
|
|
|
});
|
|
|
|
|
2019-01-07 08:33:07 +00:00
|
|
|
it(`should create a new user with all correct data`, async() => {
|
2019-12-12 07:37:35 +00:00
|
|
|
await page.clearInput(selectors.createClientView.postcode);
|
2020-10-19 18:49:38 +00:00
|
|
|
await page.write(selectors.createClientView.postcode, '61616');
|
2019-12-12 07:37:35 +00:00
|
|
|
await page.waitToClick(selectors.createClientView.createButton);
|
2020-03-25 19:44:59 +00:00
|
|
|
const message = await page.waitForSnackbar();
|
2018-11-20 13:22:00 +00:00
|
|
|
|
2020-11-10 11:06:21 +00:00
|
|
|
expect(message.text).toContain('Data saved!');
|
2018-11-20 13:22:00 +00:00
|
|
|
});
|
|
|
|
|
2019-01-07 08:33:07 +00:00
|
|
|
it('should click on the Clients button of the top bar menu', async() => {
|
2019-12-12 07:37:35 +00:00
|
|
|
await page.waitToClick(selectors.globalItems.applicationsMenuButton);
|
2020-11-23 17:28:39 +00:00
|
|
|
await page.waitForSelector(selectors.globalItems.applicationsMenuVisible);
|
2019-12-12 07:37:35 +00:00
|
|
|
await page.waitToClick(selectors.globalItems.clientsButton);
|
2020-11-23 17:28:39 +00:00
|
|
|
await page.waitForSelector(selectors.clientsIndex.createClientButton);
|
2020-03-24 15:51:21 +00:00
|
|
|
await page.waitForState('client.index');
|
2018-11-20 13:22:00 +00:00
|
|
|
});
|
|
|
|
|
2019-01-07 08:33:07 +00:00
|
|
|
it(`should search for the user Carol Danvers to confirm it exists`, async() => {
|
2019-12-31 11:00:16 +00:00
|
|
|
await page.accessToSearchResult('Carol Danvers');
|
2020-03-24 15:49:36 +00:00
|
|
|
await page.waitForState('client.card.summary');
|
2017-10-29 14:49:44 +00:00
|
|
|
});
|
2017-09-11 14:12:32 +00:00
|
|
|
});
|