salix/e2e/paths/02-client-module/01_create_client.spec.js

124 lines
5.6 KiB
JavaScript
Raw Normal View History

import selectors from '../../helpers/selectors';
import getBrowser from '../../helpers/puppeteer';
2019-12-31 11:00:16 +00:00
describe('Client create path', async() => {
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');
});
2018-11-20 13:22:00 +00:00
2019-12-12 07:37:35 +00:00
afterAll(async() => {
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() => {
2019-12-12 07:37:35 +00:00
await page.write(selectors.clientsIndex.searchClientInput, 'Carol Danvers');
await page.waitToClick(selectors.clientsIndex.searchButton);
await page.waitForNumberOfElements(selectors.clientsIndex.searchResult, 0);
const result = await page.countElement(selectors.clientsIndex.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);
await page.wait(selectors.createClientView.createButton);
const url = await page.parsedUrl();
2018-11-20 13:22:00 +00:00
expect(url.hash).toEqual('#!/client/create');
});
2019-01-07 08:33:07 +00:00
it('should receive an error when clicking the create button having all the form fields empty', async() => {
2019-12-12 07:37:35 +00:00
await page.waitToClick(selectors.createClientView.createButton);
const result = await page.waitForLastSnackbar();
2018-11-20 13:22:00 +00:00
expect(result).toEqual('Some fields are invalid');
});
2019-01-07 08:33:07 +00:00
it('should receive an error when clicking the create button having name and Business name fields empty', async() => {
2019-12-12 07:37:35 +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.autocompleteSearch(selectors.createClientView.salesPersonAutocomplete, 'replenisher');
await page.waitToClick(selectors.createClientView.createButton);
const result = await page.waitForLastSnackbar();
2018-11-20 13:22:00 +00:00
expect(result).toEqual('Some fields are invalid');
});
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.waitForContentLoaded();
2019-12-12 07:37:35 +00:00
await page.autocompleteSearch(selectors.createClientView.country, 'España');
await page.autocompleteSearch(selectors.createClientView.province, 'Province one');
await page.write(selectors.createClientView.city, 'Valencia');
await page.write(selectors.createClientView.postcode, '46000');
await page.clearInput(selectors.createClientView.email);
await page.write(selectors.createClientView.email, 'incorrect email format');
await page.waitToClick(selectors.createClientView.createButton);
const result = await page.waitForLastSnackbar();
2018-11-20 13:22:00 +00:00
expect(result).toEqual('Some fields are invalid');
});
it(`should attempt to create a new user with all it's data but wrong postal code`, async() => {
2019-12-12 07:37:35 +00:00
await page.clearInput(selectors.createClientView.email);
await page.write(selectors.createClientView.email, 'CarolDanvers@verdnatura.es');
await page.clearInput(selectors.createClientView.postcode);
await page.write(selectors.createClientView.postcode, '479999');
await page.waitToClick(selectors.createClientView.createButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual(`The postcode doesn't exists. Ensure you put the correct format`);
});
it(`should check for autocompleted city, province and country`, async() => {
2019-12-12 07:37:35 +00:00
const clientCity = await page
.waitToGetProperty(`${selectors.createClientView.city} input`, 'value');
2019-12-12 07:37:35 +00:00
const clientProvince = await page
.waitToGetProperty(`${selectors.createClientView.province} input`, 'value');
2019-12-12 07:37:35 +00:00
const clientCountry = await page
.waitToGetProperty(`${selectors.createClientView.country} input`, 'value');
expect(clientCity).toEqual('Valencia');
expect(clientProvince).toEqual('Province one');
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);
await page.write(selectors.createClientView.postcode, '46000');
await page.waitToClick(selectors.createClientView.createButton);
const result = await page.waitForLastSnackbar();
2018-11-20 13:22:00 +00:00
expect(result).toEqual('Data saved!');
});
2019-01-07 08:33:07 +00:00
it('should click on the Clients button of the top bar menu', async() => {
await page.waitFor(500);
2019-12-12 07:37:35 +00:00
await page.waitToClick(selectors.globalItems.applicationsMenuButton);
await page.wait(selectors.globalItems.applicationsMenuVisible);
await page.waitToClick(selectors.globalItems.clientsButton);
await page.wait(selectors.clientsIndex.createClientButton);
const url = await page.parsedUrl();
2018-11-20 13:22:00 +00:00
expect(url.hash).toEqual('#!/client/index');
});
2019-01-07 08:33:07 +00:00
it(`should search for the user Carol Danvers to confirm it exists`, async() => {
2020-01-26 23:48:00 +00:00
await page.waitForContentLoaded();
2019-12-31 11:00:16 +00:00
await page.accessToSearchResult('Carol Danvers');
2020-01-26 23:48:00 +00:00
await page.waitForURL('#!/client/114/summary');
2019-12-31 11:00:16 +00:00
const url = await page.parsedUrl();
2018-11-20 13:22:00 +00:00
2019-12-31 11:00:16 +00:00
expect(url.hash).toEqual('#!/client/114/summary');
2017-10-29 14:49:44 +00:00
});
2017-09-11 14:12:32 +00:00
});