99 lines
4.4 KiB
JavaScript
99 lines
4.4 KiB
JavaScript
import selectors from '../../helpers/selectors';
|
|
import getBrowser from '../../helpers/puppeteer';
|
|
|
|
describe('Client Add address path', () => {
|
|
let browser;
|
|
let page;
|
|
beforeAll(async() => {
|
|
browser = await getBrowser();
|
|
page = browser.page;
|
|
await page.loginAndModule('employee', 'client');
|
|
await page.accessToSearchResult('Bruce Banner');
|
|
await page.accessToSection('client.card.address.index');
|
|
});
|
|
|
|
afterAll(async() => {
|
|
browser.close();
|
|
});
|
|
|
|
it(`should click on the add new address button to access to the new address form`, async() => {
|
|
await page.waitToClick(selectors.clientAddresses.createAddress);
|
|
await page.waitForURL('address/create');
|
|
const url = await page.parsedUrl();
|
|
|
|
expect(url.hash).toContain('address/create');
|
|
});
|
|
|
|
it('should receive an error after clicking save button as consignee, street and town fields are empty', async() => {
|
|
await page.waitToClick(selectors.clientAddresses.defaultCheckboxInput);
|
|
await page.autocompleteSearch(selectors.clientAddresses.provinceAutocomplete, 'Province one');
|
|
await page.write(selectors.clientAddresses.cityInput, 'Valencia');
|
|
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();
|
|
|
|
expect(result).toEqual('Some fields are invalid');
|
|
});
|
|
|
|
it(`should create a new address with all it's data`, async() => {
|
|
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();
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
});
|
|
|
|
it(`should click on the first address button to confirm the new address exists and it's the default one`, async() => {
|
|
const result = await page.waitToGetProperty(selectors.clientAddresses.defaultAddress, 'innerText');
|
|
|
|
expect(result).toContain('320 Park Avenue New York');
|
|
});
|
|
|
|
it(`should click on the make default icon of the second address`, async() => {
|
|
await page.waitToClick(selectors.clientAddresses.secondMakeDefaultStar);
|
|
const result = await page.waitForLastSnackbar();
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
});
|
|
|
|
it(`should confirm the default address is the expected one`, async() => {
|
|
await page.waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand');
|
|
const result = await page.waitToGetProperty(selectors.clientAddresses.defaultAddress, 'innerText');
|
|
|
|
expect(result).toContain('Somewhere in Thailand');
|
|
});
|
|
|
|
it(`should click on the edit icon of the default address`, async() => {
|
|
await page.waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand');
|
|
await page.waitToClick(selectors.clientAddresses.firstEditAddress);
|
|
await page.waitForURL('/edit');
|
|
const url = await page.parsedUrl();
|
|
|
|
expect(url.hash).toContain('/edit');
|
|
});
|
|
|
|
it(`should click on the active checkbox and receive an error to save it because it is the default address`, async() => {
|
|
await page.waitForWatcherData(selectors.clientAddresses.watcher);
|
|
await page.waitToClick(selectors.clientAddresses.activeCheckbox);
|
|
await page.waitToClick(selectors.clientAddresses.saveButton);
|
|
const result = await page.waitForLastSnackbar();
|
|
|
|
expect(result).toEqual('The default consignee can not be unchecked');
|
|
});
|
|
|
|
it(`should go back to the addreses section by clicking the cancel button`, async() => {
|
|
page.waitToClick(selectors.clientAddresses.cancelEditAddressButton);
|
|
await Promise.all([
|
|
page.waitForNavigation({waitUntil: ['load', 'networkidle0', 'domcontentloaded']}),
|
|
page.waitToClick('.vn-confirm.shown button[response="accept"]')
|
|
]);
|
|
const url = await page.parsedUrl();
|
|
|
|
expect(url.hash).toContain('address/index');
|
|
});
|
|
});
|