salix/e2e/paths/02-client-module/05_add_address.spec.js

111 lines
5.0 KiB
JavaScript
Raw Normal View History

import selectors from '../../helpers/selectors.js';
2019-12-12 07:37:35 +00:00
import openPage from '../../helpers/puppeteer';
2018-11-20 13:22:00 +00:00
describe('Client Add address path', () => {
2019-12-31 11:00:16 +00:00
let page;
beforeAll(async() => {
page = await openPage();
await page.loginAndModule('employee', 'client');
await page.accessToSearchResult('Bruce Banner');
await page.accessToSection('client.card.address.index');
});
2018-11-20 13:22:00 +00:00
2019-12-31 11:00:16 +00:00
afterAll(async() => {
page.close();
2018-11-20 13:22:00 +00:00
});
2019-01-07 08:33:07 +00:00
it(`should click on the add new address button to access to the new address form`, async() => {
2019-12-31 11:00:16 +00:00
await page.waitToClick(selectors.clientAddresses.createAddress);
await page.waitForURL('address/create');
const url = await page.parsedUrl();
2018-11-20 13:22:00 +00:00
expect(url.hash).toContain('address/create');
2018-11-20 13:22:00 +00:00
});
2019-01-07 08:33:07 +00:00
it('should receive an error after clicking save button as consignee, street and town fields are empty', async() => {
2019-12-31 11:00:16 +00:00
await page.waitToClick(selectors.clientAddresses.defaultCheckboxInput);
await page.clearInput(selectors.clientAddresses.streetAddressInput);
await page.autocompleteSearch(selectors.clientAddresses.provinceAutocomplete, 'Province one');
await page.clearInput(selectors.clientAddresses.cityInput);
await page.write(selectors.clientAddresses.cityInput, 'Valencia');
await page.clearInput(selectors.clientAddresses.postcodeInput);
await page.write(selectors.clientAddresses.postcodeInput, '46000');
await page.autocompleteSearch(selectors.clientAddresses.agencyAutocomplete, 'Entanglement');
await page.write(selectors.clientAddresses.phoneInput, '999887744');
await page.write(selectors.clientAddresses.mobileInput, '999887744');
await page.waitToClick(selectors.clientFiscalData.saveButton);
const result = await page.waitForLastSnackbar();
2018-11-20 13:22:00 +00:00
expect(result).toEqual('Some fields are invalid');
});
it('should confirm the postcode have been edited', async() => {
const result = await page.waitToGetProperty(`${selectors.clientAddresses.postcodeInput} input`, 'value');
expect(result).toContain('46000');
});
it('should confirm the city have been autocompleted', async() => {
const result = await page.waitToGetProperty(`${selectors.clientAddresses.cityInput} input`, 'value');
expect(result).toEqual('Valencia');
});
it(`should confirm the province have been autocompleted`, async() => {
2019-12-31 11:00:16 +00:00
const result = await page.waitToGetProperty(`${selectors.clientAddresses.provinceAutocomplete} input`, 'value');
expect(result).toEqual('Province one');
});
2019-01-07 08:33:07 +00:00
it(`should create a new address with all it's data`, async() => {
2019-12-31 11:00:16 +00:00
await page.write(selectors.clientAddresses.consigneeInput, 'Bruce Bunner');
await page.write(selectors.clientAddresses.streetAddressInput, '320 Park Avenue New York');
await page.waitToClick(selectors.clientAddresses.saveButton);
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 addresses button confirm the new address exists and it's the default one`, async() => {
2019-12-31 11:00:16 +00:00
const result = await page.waitToGetProperty(selectors.clientAddresses.defaultAddress, 'innerText');
2018-11-20 13:22:00 +00:00
expect(result).toContain('320 Park Avenue New York');
});
2019-01-07 08:33:07 +00:00
it(`should click on the make default icon of the second address then confirm it is the default one now`, async() => {
2019-12-31 11:00:16 +00:00
await page.waitToClick(selectors.clientAddresses.secondMakeDefaultStar);
await page.waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand');
const result = await page.waitToGetProperty(selectors.clientAddresses.defaultAddress, 'innerText');
2018-11-20 13:22:00 +00:00
expect(result).toContain('Somewhere in Thailand');
});
2019-01-07 08:33:07 +00:00
it(`should click on the edit icon of the default address`, async() => {
2019-12-31 11:00:16 +00:00
await page.waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand');
await page.waitToClick(selectors.clientAddresses.firstEditAddress);
await page.waitForURL('/edit');
const url = await page.parsedUrl();
2018-11-20 13:22:00 +00:00
expect(url.hash).toContain('/edit');
2018-11-20 13:22:00 +00:00
});
2019-01-07 08:33:07 +00:00
it(`should click on the active checkbox and receive an error to save it because it is the default address`, async() => {
2019-12-31 11:00:16 +00:00
await page.waitForWatcherData(selectors.clientAddresses.watcher);
await page.waitToClick(selectors.clientAddresses.activeCheckbox);
await page.waitToClick(selectors.clientAddresses.saveButton);
const result = await page.waitForLastSnackbar();
2018-11-20 13:22:00 +00:00
expect(result).toEqual('The default consignee can not be unchecked');
});
2019-01-23 14:34:16 +00:00
it(`should go back to the addreses section by clicking the cancel button`, async() => {
2019-12-31 11:00:16 +00:00
await page.waitToClick(selectors.clientAddresses.cancelEditAddressButton);
await page.waitToClick('.vn-confirm.shown button[response="accept"]');
await page.waitForURL('address/index');
const url = await page.parsedUrl();
2019-01-23 14:34:16 +00:00
expect(url.hash).toContain('address/index');
});
});