2020-01-14 08:20:14 +00:00
|
|
|
import selectors from '../../helpers/selectors';
|
|
|
|
import getBrowser from '../../helpers/puppeteer';
|
2017-12-13 10:25:50 +00:00
|
|
|
|
2018-11-20 13:22:00 +00:00
|
|
|
describe('Client Add address path', () => {
|
2020-01-14 08:20:14 +00:00
|
|
|
let browser;
|
2019-12-31 11:00:16 +00:00
|
|
|
let page;
|
|
|
|
beforeAll(async() => {
|
2020-01-14 08:20:14 +00:00
|
|
|
browser = await getBrowser();
|
|
|
|
page = browser.page;
|
2019-12-31 11:00:16 +00:00
|
|
|
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() => {
|
2020-01-14 08:40:50 +00:00
|
|
|
await browser.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() => {
|
2020-11-23 17:28:39 +00:00
|
|
|
await page.waitForTimeout(500);
|
2019-12-31 11:00:16 +00:00
|
|
|
await page.waitToClick(selectors.clientAddresses.createAddress);
|
2020-03-24 15:49:36 +00:00
|
|
|
await page.waitForState('client.card.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() => {
|
2020-02-03 14:55:11 +00:00
|
|
|
await page.waitToClick(selectors.clientAddresses.defaultCheckbox);
|
2020-03-02 08:30:54 +00:00
|
|
|
await page.write(selectors.clientAddresses.postcode, 'EC170150');
|
2020-02-03 14:55:11 +00:00
|
|
|
await page.autocompleteSearch(selectors.clientAddresses.agency, 'Entanglement');
|
|
|
|
await page.write(selectors.clientAddresses.phone, '999887744');
|
2019-12-31 11:00:16 +00:00
|
|
|
await page.write(selectors.clientAddresses.mobileInput, '999887744');
|
|
|
|
await page.waitToClick(selectors.clientFiscalData.saveButton);
|
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
|
|
|
});
|
|
|
|
|
2020-03-02 08:30:54 +00:00
|
|
|
it('should confirm that the city and province are propertly filled', async() => {
|
|
|
|
const city = await page
|
|
|
|
.waitToGetProperty(selectors.clientAddresses.city, 'value');
|
|
|
|
|
|
|
|
const province = await page
|
|
|
|
.waitToGetProperty(selectors.clientAddresses.province, 'value');
|
|
|
|
|
|
|
|
expect(city).toEqual('Quito');
|
|
|
|
expect(province).toContain('Province five');
|
|
|
|
});
|
2020-01-28 10:56:26 +00:00
|
|
|
|
2022-07-01 07:15:07 +00:00
|
|
|
it(`should throw after clicking save button as consignee, incoterms and customsAgent are empty`, async() => {
|
2020-02-03 14:55:11 +00:00
|
|
|
await page.write(selectors.clientAddresses.consignee, 'Bruce Bunner');
|
|
|
|
await page.write(selectors.clientAddresses.streetAddress, '320 Park Avenue New York');
|
2019-12-31 11:00:16 +00:00
|
|
|
await page.waitToClick(selectors.clientAddresses.saveButton);
|
2020-04-08 09:24:40 +00:00
|
|
|
const message = await page.waitForSnackbar();
|
2018-11-20 13:22:00 +00:00
|
|
|
|
2024-05-21 08:19:21 +00:00
|
|
|
expect(message.text).toContain('Incoterms and Customs agent are required for a non UEE member');
|
2020-01-28 10:56:26 +00:00
|
|
|
});
|
|
|
|
|
2020-02-25 15:36:29 +00:00
|
|
|
it(`should receive an error after clicking save button as customsAgent is empty`, async() => {
|
2020-02-03 14:55:11 +00:00
|
|
|
await page.autocompleteSearch(selectors.clientAddresses.incoterms, 'Free Alongside Ship');
|
2020-01-28 10:56:26 +00:00
|
|
|
await page.waitToClick(selectors.clientAddresses.saveButton);
|
2020-04-08 09:24:40 +00:00
|
|
|
const message = await page.waitForSnackbar();
|
2020-01-28 10:56:26 +00:00
|
|
|
|
2020-11-10 11:06:21 +00:00
|
|
|
expect(message.text).toContain('Customs agent is required for a non UEE member');
|
2020-01-28 10:56:26 +00:00
|
|
|
});
|
|
|
|
|
2020-05-28 07:54:31 +00:00
|
|
|
it(`should create a new custom agent and then save the address`, async() => {
|
|
|
|
await page.waitToClick(selectors.clientAddresses.addNewCustomsAgent);
|
|
|
|
await page.write(selectors.clientAddresses.newCustomsAgentFiscalID, 'ID');
|
|
|
|
await page.write(selectors.clientAddresses.newCustomsAgentFiscalName, 'name');
|
|
|
|
await page.write(selectors.clientAddresses.newCustomsAgentStreet, 'street');
|
|
|
|
await page.write(selectors.clientAddresses.newCustomsAgentPhone, '555555555');
|
|
|
|
await page.waitToClick(selectors.clientAddresses.saveNewCustomsAgentButton);
|
|
|
|
|
2020-01-28 10:56:26 +00:00
|
|
|
await page.waitToClick(selectors.clientAddresses.saveButton);
|
2020-04-08 09:24:40 +00:00
|
|
|
const message = await page.waitForSnackbar();
|
2020-01-28 10:56:26 +00:00
|
|
|
|
2020-11-10 11:06:21 +00:00
|
|
|
expect(message.text).toContain('Data saved!');
|
2018-11-20 13:22:00 +00:00
|
|
|
});
|
|
|
|
|
2020-02-25 15:36:29 +00:00
|
|
|
it(`should navigate back to the addresses index`, async() => {
|
2020-03-24 15:49:36 +00:00
|
|
|
await page.waitForState('client.card.address.index');
|
2020-02-25 15:36:29 +00:00
|
|
|
});
|
|
|
|
|
2020-02-21 09:26:40 +00:00
|
|
|
it(`should 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');
|
|
|
|
});
|
|
|
|
|
2020-02-27 09:58:58 +00:00
|
|
|
it('should click on the make default icon of the second address', async() => {
|
2019-12-31 11:00:16 +00:00
|
|
|
await page.waitToClick(selectors.clientAddresses.secondMakeDefaultStar);
|
2020-04-08 09:24:40 +00:00
|
|
|
const message = await page.waitForSnackbar();
|
2020-01-14 08:20:14 +00:00
|
|
|
|
2020-11-10 11:06:21 +00:00
|
|
|
expect(message.text).toContain('Data saved!');
|
2020-01-14 08:20:14 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it(`should confirm the default address is the expected one`, async() => {
|
2020-11-02 07:26:53 +00:00
|
|
|
await page.waitForTextInElement(selectors.clientAddresses.defaultAddress, 'somewhere in new york');
|
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
|
|
|
|
2020-11-02 07:26:53 +00:00
|
|
|
expect(result).toContain('Somewhere in New York');
|
2018-11-20 13:22:00 +00:00
|
|
|
});
|
|
|
|
|
2019-01-07 08:33:07 +00:00
|
|
|
it(`should click on the edit icon of the default address`, async() => {
|
2020-11-02 07:26:53 +00:00
|
|
|
await page.waitForTextInElement(selectors.clientAddresses.defaultAddress, 'somewhere in new york');
|
2019-12-31 11:00:16 +00:00
|
|
|
await page.waitToClick(selectors.clientAddresses.firstEditAddress);
|
2020-03-24 15:49:36 +00:00
|
|
|
await page.waitForState('client.card.address.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);
|
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('The default consignee can not be unchecked');
|
2017-12-13 16:25:07 +00:00
|
|
|
});
|
2019-01-23 14:34:16 +00:00
|
|
|
|
|
|
|
it(`should go back to the addreses section by clicking the cancel button`, async() => {
|
2020-02-25 15:36:29 +00:00
|
|
|
await page.waitForSelector('#shapes .shown', {hidden: true});
|
2020-01-16 12:40:51 +00:00
|
|
|
await page.waitToClick(selectors.clientAddresses.cancelEditAddressButton);
|
|
|
|
await page.waitToClick('.vn-confirm.shown button[response="accept"]');
|
2020-03-24 15:49:36 +00:00
|
|
|
await page.waitForState('client.card.address.index');
|
2019-01-23 14:34:16 +00:00
|
|
|
});
|
2017-12-13 10:25:50 +00:00
|
|
|
});
|