2018-02-15 11:28:05 +00:00
|
|
|
import selectors from '../../helpers/selectors.js';
|
2018-10-24 08:57:14 +00:00
|
|
|
import createNightmare from '../../helpers/nightmare';
|
2017-12-13 10:25:50 +00:00
|
|
|
|
2018-11-20 13:22:00 +00:00
|
|
|
describe('Client Add address path', () => {
|
|
|
|
const nightmare = createNightmare();
|
|
|
|
|
|
|
|
beforeAll(() => {
|
|
|
|
nightmare
|
2018-12-02 23:45:34 +00:00
|
|
|
.loginAndModule('employee', 'client')
|
|
|
|
.accessToSearchResult('Bruce Banner')
|
|
|
|
.accessToSection('client.card.address.index');
|
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() => {
|
2018-11-20 13:22:00 +00:00
|
|
|
const url = await nightmare
|
|
|
|
.waitToClick(selectors.clientAddresses.createAddress)
|
|
|
|
.waitForURL('address/create')
|
2018-11-22 14:44:33 +00:00
|
|
|
.parsedUrl();
|
2018-11-20 13:22:00 +00:00
|
|
|
|
2018-11-22 14:44:33 +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() => {
|
2018-11-20 13:22:00 +00:00
|
|
|
const result = await nightmare
|
|
|
|
.waitToClick(selectors.clientAddresses.defaultCheckboxInput)
|
|
|
|
.clearInput(selectors.clientAddresses.streetAddressInput)
|
2019-01-23 14:34:16 +00:00
|
|
|
.write(selectors.clientAddresses.postcodeInput, '10022')
|
2019-01-07 08:33:07 +00:00
|
|
|
.autocompleteSearch(selectors.clientAddresses.provinceAutocomplete, 'Province four')
|
|
|
|
.autocompleteSearch(selectors.clientAddresses.agencyAutocomplete, 'Entanglement')
|
2019-01-23 14:34:16 +00:00
|
|
|
.write(selectors.clientAddresses.phoneInput, '999887744')
|
|
|
|
.write(selectors.clientAddresses.mobileInput, '999887744')
|
2018-11-20 13:22:00 +00:00
|
|
|
.waitToClick(selectors.clientFiscalData.saveButton)
|
|
|
|
.waitForLastSnackbar();
|
|
|
|
|
|
|
|
expect(result).toEqual('Some fields are invalid');
|
|
|
|
});
|
|
|
|
|
2019-01-07 08:33:07 +00:00
|
|
|
it(`should create a new address with all it's data`, async() => {
|
2018-11-20 13:22:00 +00:00
|
|
|
const result = await nightmare
|
2019-01-23 14:34:16 +00:00
|
|
|
.write(selectors.clientAddresses.consigneeInput, 'Bruce Bunner')
|
|
|
|
.write(selectors.clientAddresses.streetAddressInput, '320 Park Avenue New York')
|
|
|
|
.write(selectors.clientAddresses.cityInput, 'New York')
|
2019-01-23 15:00:56 +00:00
|
|
|
.waitToClick(selectors.clientAddresses.saveButton)
|
2018-11-20 13:22:00 +00:00
|
|
|
.waitForLastSnackbar();
|
|
|
|
|
|
|
|
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() => {
|
2018-11-20 13:22:00 +00:00
|
|
|
const result = await nightmare
|
|
|
|
.waitToClick(selectors.clientAddresses.addressesButton)
|
2018-11-22 11:34:20 +00:00
|
|
|
.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() => {
|
2018-11-20 13:22:00 +00:00
|
|
|
const result = await nightmare
|
|
|
|
.waitToClick(selectors.clientAddresses.secondMakeDefaultStar)
|
|
|
|
.waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand')
|
2018-11-22 11:34:20 +00:00
|
|
|
.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() => {
|
2018-11-20 13:22:00 +00:00
|
|
|
const url = await nightmare
|
|
|
|
.waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand')
|
|
|
|
.waitToClick(selectors.clientAddresses.firstEditButton)
|
|
|
|
.waitForURL('/edit')
|
2018-11-22 14:44:33 +00:00
|
|
|
.parsedUrl();
|
2018-11-20 13:22:00 +00:00
|
|
|
|
2018-11-22 14:44:33 +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() => {
|
2018-11-20 13:22:00 +00:00
|
|
|
const result = await nightmare
|
|
|
|
.waitToClick(selectors.clientAddresses.activeCheckbox)
|
|
|
|
.waitToClick(selectors.clientAddresses.saveButton)
|
|
|
|
.waitForLastSnackbar();
|
|
|
|
|
|
|
|
expect(result).toEqual('The default consignee can not be unchecked');
|
2017-12-13 16:25:07 +00:00
|
|
|
});
|
2019-01-23 14:34:16 +00:00
|
|
|
|
|
|
|
// this "it" should be removed if the watcher doesn't prevent the navigation upon state changes
|
|
|
|
it(`should go back to the addreses section by clicking the cancel button`, async() => {
|
|
|
|
const url = await nightmare
|
|
|
|
.waitToClick(selectors.clientAddresses.cancelEditAddressButton)
|
|
|
|
.waitToClick('vn-confirm button[response="ACCEPT"]')
|
|
|
|
.waitForURL('address/index')
|
|
|
|
.parsedUrl();
|
|
|
|
|
|
|
|
expect(url.hash).toContain('address/index');
|
|
|
|
});
|
2017-12-13 10:25:50 +00:00
|
|
|
});
|