119 lines
5.4 KiB
JavaScript
119 lines
5.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() => {
|
|
await 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.waitForState('client.card.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.defaultCheckbox);
|
|
await page.write(selectors.clientAddresses.postcode, 'EC170150');
|
|
await page.autocompleteSearch(selectors.clientAddresses.agency, 'Entanglement');
|
|
await page.write(selectors.clientAddresses.phone, '999887744');
|
|
await page.write(selectors.clientAddresses.mobileInput, '999887744');
|
|
await page.waitToClick(selectors.clientFiscalData.saveButton);
|
|
const message = await page.waitForSnackbar();
|
|
|
|
expect(message.text).toBe('Some fields are invalid');
|
|
});
|
|
|
|
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');
|
|
});
|
|
|
|
it(`should receive an error after clicking save button as consignee, incoterms and customsAgent are empty`, async() => {
|
|
await page.write(selectors.clientAddresses.consignee, 'Bruce Bunner');
|
|
await page.write(selectors.clientAddresses.streetAddress, '320 Park Avenue New York');
|
|
await page.waitToClick(selectors.clientAddresses.saveButton);
|
|
const message = await page.waitForSnackbar();
|
|
|
|
expect(message.text).toBe('Incoterms is required for a non UEE member');
|
|
});
|
|
|
|
it(`should receive an error after clicking save button as customsAgent is empty`, async() => {
|
|
await page.autocompleteSearch(selectors.clientAddresses.incoterms, 'Free Alongside Ship');
|
|
await page.waitToClick(selectors.clientAddresses.saveButton);
|
|
const message = await page.waitForSnackbar();
|
|
|
|
expect(message.text).toBe('Customs agent is required for a non UEE member');
|
|
});
|
|
|
|
it(`should create a new address with all it's data`, async() => {
|
|
await page.autocompleteSearch(selectors.clientAddresses.customsAgent, 'Agent one');
|
|
await page.waitToClick(selectors.clientAddresses.saveButton);
|
|
const message = await page.waitForSnackbar();
|
|
|
|
expect(message.type).toBe('success');
|
|
});
|
|
|
|
it(`should navigate back to the addresses index`, async() => {
|
|
await page.waitForState('client.card.address.index');
|
|
});
|
|
|
|
it(`should confirm the new address exists and it's the default one`, async() => {
|
|
await page.waitFor(2000); // needs more than a single second to load the section
|
|
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 message = await page.waitForSnackbar();
|
|
|
|
expect(message.type).toBe('success');
|
|
});
|
|
|
|
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.waitForState('client.card.address.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 message = await page.waitForSnackbar();
|
|
|
|
expect(message.text).toBe('The default consignee can not be unchecked');
|
|
});
|
|
|
|
it(`should go back to the addreses section by clicking the cancel button`, async() => {
|
|
await page.waitForSelector('#shapes .shown', {hidden: true});
|
|
await page.waitToClick(selectors.clientAddresses.cancelEditAddressButton);
|
|
await page.waitToClick('.vn-confirm.shown button[response="accept"]');
|
|
await page.waitForState('client.card.address.index');
|
|
});
|
|
});
|