112 lines
5.0 KiB
JavaScript
112 lines
5.0 KiB
JavaScript
import selectors from '../../helpers/selectors';
|
|
import getBrowser from '../../helpers/puppeteer';
|
|
|
|
describe('Client create path', () => {
|
|
let browser;
|
|
let page;
|
|
|
|
beforeAll(async() => {
|
|
browser = await getBrowser();
|
|
page = browser.page;
|
|
await page.loginAndModule('employee', 'client');
|
|
});
|
|
|
|
afterAll(async() => {
|
|
await browser.close();
|
|
});
|
|
|
|
it(`should search for the user Carol Danvers to confirm it isn't created yet`, async() => {
|
|
await page.doSearch('Carol Danvers');
|
|
const result = await page.countElement(selectors.clientsIndex.searchResult);
|
|
|
|
expect(result).toEqual(0);
|
|
});
|
|
|
|
it('should now access to the create client view by clicking the create-client floating button', async() => {
|
|
await page.waitToClick(selectors.clientsIndex.createClientButton);
|
|
await page.waitForState('client.create');
|
|
});
|
|
|
|
it('should receive an error when clicking the create button having all the form fields empty', async() => {
|
|
await page.waitToClick(selectors.createClientView.createButton);
|
|
const message = await page.waitForSnackbar();
|
|
|
|
expect(message.text).toBe('Some fields are invalid');
|
|
});
|
|
|
|
it('should receive an error when clicking the create button having name and Business name fields empty', async() => {
|
|
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.salesPerson, 'replenisher');
|
|
await page.waitToClick(selectors.createClientView.createButton);
|
|
const message = await page.waitForSnackbar();
|
|
|
|
expect(message.text).toBe('Some fields are invalid');
|
|
});
|
|
|
|
it(`should attempt to create a new user with all it's data but wrong email`, async() => {
|
|
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.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 message = await page.waitForSnackbar();
|
|
|
|
expect(message.text).toBe('Some fields are invalid');
|
|
});
|
|
|
|
it(`should attempt to create a new user with all it's data but wrong postal code`, async() => {
|
|
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 message = await page.waitForSnackbar();
|
|
|
|
expect(message.text).toBe(`The postcode doesn't exist. Please enter a correct one`);
|
|
});
|
|
|
|
it(`should check for autocompleted city, province and country`, async() => {
|
|
const clientCity = await page
|
|
.waitToGetProperty(selectors.createClientView.city, 'value');
|
|
|
|
const clientProvince = await page
|
|
.waitToGetProperty(selectors.createClientView.province, 'value');
|
|
|
|
const clientCountry = await page
|
|
.waitToGetProperty(selectors.createClientView.country, 'value');
|
|
|
|
expect(clientCity).toEqual('Valencia');
|
|
expect(clientProvince).toContain('Province one');
|
|
expect(clientCountry).toEqual('España');
|
|
});
|
|
|
|
it(`should create a new user with all correct data`, async() => {
|
|
await page.clearInput(selectors.createClientView.postcode);
|
|
await page.write(selectors.createClientView.postcode, '46000');
|
|
await page.waitToClick(selectors.createClientView.createButton);
|
|
const message = await page.waitForSnackbar();
|
|
|
|
expect(message.type).toBe('success');
|
|
});
|
|
|
|
it('should click on the Clients button of the top bar menu', async() => {
|
|
await page.waitToClick(selectors.globalItems.applicationsMenuButton);
|
|
await page.wait(selectors.globalItems.applicationsMenuVisible);
|
|
await page.waitToClick(selectors.globalItems.clientsButton);
|
|
await page.wait(selectors.clientsIndex.createClientButton);
|
|
await page.waitForState('client.index');
|
|
});
|
|
|
|
it(`should search for the user Carol Danvers to confirm it exists`, async() => {
|
|
await page.accessToSearchResult('Carol Danvers');
|
|
await page.waitForState('client.card.summary');
|
|
});
|
|
});
|