2018-02-15 11:28:05 +00:00
|
|
|
import selectors from '../../helpers/selectors.js';
|
2018-02-20 09:00:19 +00:00
|
|
|
import createNightmare from '../../helpers/helpers';
|
2017-12-13 10:25:50 +00:00
|
|
|
|
2018-04-05 06:55:47 +00:00
|
|
|
describe('Client', () => {
|
|
|
|
describe('Add address path', () => {
|
|
|
|
const nightmare = createNightmare();
|
2017-12-13 10:25:50 +00:00
|
|
|
|
2018-04-05 06:55:47 +00:00
|
|
|
beforeAll(() => {
|
|
|
|
return nightmare
|
2018-10-11 07:14:26 +00:00
|
|
|
.waitForLogin('employee');
|
2018-04-05 06:55:47 +00:00
|
|
|
});
|
2018-03-02 11:15:17 +00:00
|
|
|
|
2018-10-22 15:12:41 +00:00
|
|
|
it('should click on the Clients button of the top bar menu', done => {
|
2018-04-05 06:55:47 +00:00
|
|
|
return nightmare
|
|
|
|
.waitToClick(selectors.globalItems.applicationsMenuButton)
|
|
|
|
.wait(selectors.globalItems.applicationsMenuVisible)
|
|
|
|
.waitToClick(selectors.globalItems.clientsButton)
|
|
|
|
.wait(selectors.clientsIndex.createClientButton)
|
|
|
|
.parsedUrl()
|
|
|
|
.then(url => {
|
2018-05-23 12:26:51 +00:00
|
|
|
expect(url.hash).toEqual('#!/client/index');
|
2018-10-22 15:12:41 +00:00
|
|
|
done();
|
|
|
|
}).catch(done.fail);
|
2018-02-20 09:00:19 +00:00
|
|
|
});
|
2017-12-13 10:25:50 +00:00
|
|
|
|
2018-10-22 15:12:41 +00:00
|
|
|
it('should search for the user Bruce Banner', done => {
|
2018-04-05 06:55:47 +00:00
|
|
|
return nightmare
|
|
|
|
.wait(selectors.clientsIndex.searchResult)
|
|
|
|
.type(selectors.clientsIndex.searchClientInput, 'Bruce Banner')
|
|
|
|
.click(selectors.clientsIndex.searchButton)
|
|
|
|
.waitForNumberOfElements(selectors.clientsIndex.searchResult, 1)
|
2018-08-02 12:04:46 +00:00
|
|
|
.countElement(selectors.clientsIndex.searchResult)
|
2018-04-05 06:55:47 +00:00
|
|
|
.then(result => {
|
|
|
|
expect(result).toEqual(1);
|
2018-10-22 15:12:41 +00:00
|
|
|
done();
|
|
|
|
}).catch(done.fail);
|
2018-02-20 09:00:19 +00:00
|
|
|
});
|
2017-12-13 10:25:50 +00:00
|
|
|
|
2018-10-22 15:12:41 +00:00
|
|
|
it(`should click on the search result to access to the client addresses`, done => {
|
2018-04-05 06:55:47 +00:00
|
|
|
return nightmare
|
|
|
|
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner')
|
|
|
|
.waitToClick(selectors.clientsIndex.searchResult)
|
|
|
|
.waitToClick(selectors.clientAddresses.addressesButton)
|
2018-05-23 12:26:51 +00:00
|
|
|
.waitForURL('address/index')
|
2018-04-05 06:55:47 +00:00
|
|
|
.url()
|
|
|
|
.then(url => {
|
2018-05-23 12:26:51 +00:00
|
|
|
expect(url).toContain('address/index');
|
2018-10-22 15:12:41 +00:00
|
|
|
done();
|
|
|
|
}).catch(done.fail);
|
2018-02-20 09:00:19 +00:00
|
|
|
});
|
2017-12-13 10:25:50 +00:00
|
|
|
|
2018-10-22 15:12:41 +00:00
|
|
|
it(`should click on the add new address button to access to the new address form`, done => {
|
2018-04-05 06:55:47 +00:00
|
|
|
return nightmare
|
|
|
|
.waitToClick(selectors.clientAddresses.createAddress)
|
2018-05-23 12:26:51 +00:00
|
|
|
.waitForURL('address/create')
|
2018-04-05 06:55:47 +00:00
|
|
|
.url()
|
|
|
|
.then(url => {
|
2018-05-23 12:26:51 +00:00
|
|
|
expect(url).toContain('address/create');
|
2018-10-22 15:12:41 +00:00
|
|
|
done();
|
|
|
|
}).catch(done.fail);
|
2018-02-20 09:00:19 +00:00
|
|
|
});
|
2017-12-13 10:25:50 +00:00
|
|
|
|
2018-10-22 15:12:41 +00:00
|
|
|
it(`should return to the addreses section by clicking the cancel button`, done => {
|
2018-04-22 14:25:44 +00:00
|
|
|
return nightmare
|
|
|
|
.waitToClick(selectors.clientAddresses.cancelButton)
|
2018-05-23 12:26:51 +00:00
|
|
|
.waitForURL('address/index')
|
2018-04-22 14:25:44 +00:00
|
|
|
.url()
|
|
|
|
.then(url => {
|
2018-05-23 12:26:51 +00:00
|
|
|
expect(url).toContain('address/index');
|
2018-10-22 15:12:41 +00:00
|
|
|
done();
|
|
|
|
}).catch(done.fail);
|
2018-04-22 14:25:44 +00:00
|
|
|
});
|
|
|
|
|
2018-10-22 15:12:41 +00:00
|
|
|
it(`should now click on the add new address button to access to the new address form`, done => {
|
2018-04-22 14:25:44 +00:00
|
|
|
return nightmare
|
|
|
|
.waitToClick(selectors.clientAddresses.createAddress)
|
2018-05-23 12:26:51 +00:00
|
|
|
.waitForURL('address/create')
|
2018-04-22 14:25:44 +00:00
|
|
|
.url()
|
|
|
|
.then(url => {
|
2018-05-23 12:26:51 +00:00
|
|
|
expect(url).toContain('address/create');
|
2018-10-22 15:12:41 +00:00
|
|
|
done();
|
|
|
|
}).catch(done.fail);
|
2018-04-22 14:25:44 +00:00
|
|
|
});
|
|
|
|
|
2018-10-22 15:12:41 +00:00
|
|
|
it('should receive an error after clicking save button as consignee, street and town fields are empty', done => {
|
2018-04-05 06:55:47 +00:00
|
|
|
return nightmare
|
|
|
|
.waitToClick(selectors.clientAddresses.defaultCheckboxInput)
|
|
|
|
.clearInput(selectors.clientAddresses.streetAddressInput)
|
|
|
|
.type(selectors.clientAddresses.postcodeInput, '10022')
|
|
|
|
.waitToClick(selectors.clientAddresses.provinceInput)
|
|
|
|
.waitToClick(selectors.clientAddresses.provinceSecondOption)
|
|
|
|
.waitToClick(selectors.clientAddresses.agencyInput)
|
|
|
|
.waitToClick(selectors.clientAddresses.agenctySecondOption)
|
|
|
|
.type(selectors.clientAddresses.phoneInput, '999887744')
|
|
|
|
.type(selectors.clientAddresses.mobileInput, '999887744')
|
|
|
|
.waitToClick(selectors.clientFiscalData.saveButton)
|
2018-09-17 08:50:15 +00:00
|
|
|
.waitForLastSnackbar()
|
2018-04-05 06:55:47 +00:00
|
|
|
.then(result => {
|
2018-09-17 08:50:15 +00:00
|
|
|
expect(result).toEqual('Some fields are invalid');
|
2018-10-22 15:12:41 +00:00
|
|
|
done();
|
|
|
|
}).catch(done.fail);
|
2018-02-20 09:00:19 +00:00
|
|
|
});
|
2017-12-13 10:25:50 +00:00
|
|
|
|
2018-10-22 15:12:41 +00:00
|
|
|
it(`should create a new address with all it's data`, done => {
|
2018-04-05 06:55:47 +00:00
|
|
|
return nightmare
|
|
|
|
.type(selectors.clientAddresses.consigneeInput, 'Bruce Bunner')
|
|
|
|
.type(selectors.clientAddresses.streetAddressInput, '320 Park Avenue New York')
|
|
|
|
.type(selectors.clientAddresses.cityInput, 'New York')
|
|
|
|
.click(selectors.clientAddresses.saveButton)
|
2018-09-17 08:50:15 +00:00
|
|
|
.waitForLastSnackbar()
|
2018-04-05 06:55:47 +00:00
|
|
|
.then(result => {
|
2018-09-17 08:50:15 +00:00
|
|
|
expect(result).toEqual('Data saved!');
|
2018-10-22 15:12:41 +00:00
|
|
|
done();
|
|
|
|
}).catch(done.fail);
|
2018-02-20 09:00:19 +00:00
|
|
|
});
|
2017-12-13 10:25:50 +00:00
|
|
|
|
2018-10-22 15:12:41 +00:00
|
|
|
it(`should click on the addresses button confirm the new address exists and it's the default one`, done => {
|
2018-04-05 06:55:47 +00:00
|
|
|
return nightmare
|
|
|
|
.waitToClick(selectors.clientAddresses.addressesButton)
|
|
|
|
.wait(selectors.clientAddresses.defaultAddress)
|
|
|
|
.getInnerText(selectors.clientAddresses.defaultAddress)
|
|
|
|
.then(result => {
|
|
|
|
expect(result).toContain('320 Park Avenue New York');
|
2018-10-22 15:12:41 +00:00
|
|
|
done();
|
|
|
|
}).catch(done.fail);
|
2018-02-20 09:00:19 +00:00
|
|
|
});
|
2017-12-13 10:25:50 +00:00
|
|
|
|
2018-10-22 15:12:41 +00:00
|
|
|
it(`should click on the make default icon of the second address then confirm it is the default one now`, done => {
|
2018-04-05 06:55:47 +00:00
|
|
|
return nightmare
|
|
|
|
.waitToClick(selectors.clientAddresses.secondMakeDefaultStar)
|
|
|
|
.waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand')
|
|
|
|
.getInnerText(selectors.clientAddresses.defaultAddress)
|
|
|
|
.then(result => {
|
|
|
|
expect(result).toContain('Somewhere in Thailand');
|
2018-10-22 15:12:41 +00:00
|
|
|
done();
|
|
|
|
}).catch(done.fail);
|
2018-02-20 09:00:19 +00:00
|
|
|
});
|
2017-12-13 10:25:50 +00:00
|
|
|
|
2018-10-22 15:12:41 +00:00
|
|
|
it(`should click on the edit icon of the default address`, done => {
|
2018-04-05 06:55:47 +00:00
|
|
|
return nightmare
|
|
|
|
.waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand')
|
|
|
|
.waitToClick(selectors.clientAddresses.firstEditButton)
|
|
|
|
.waitForURL('/edit')
|
|
|
|
.url()
|
|
|
|
.then(result => {
|
|
|
|
expect(result).toContain('/edit');
|
2018-10-22 15:12:41 +00:00
|
|
|
done();
|
|
|
|
}).catch(done.fail);
|
2018-02-20 09:00:19 +00:00
|
|
|
});
|
2017-12-13 10:25:50 +00:00
|
|
|
|
2018-10-22 15:12:41 +00:00
|
|
|
it(`should click on the active checkbox and receive an error to save it because it is the default address`, done => {
|
2018-04-05 06:55:47 +00:00
|
|
|
return nightmare
|
|
|
|
.waitToClick(selectors.clientAddresses.activeCheckbox)
|
|
|
|
.waitToClick(selectors.clientAddresses.saveButton)
|
2018-09-17 08:50:15 +00:00
|
|
|
.waitForLastSnackbar()
|
2018-04-05 06:55:47 +00:00
|
|
|
.then(result => {
|
2018-09-17 08:50:15 +00:00
|
|
|
expect(result).toEqual('The default consignee can not be unchecked');
|
2018-10-22 15:12:41 +00:00
|
|
|
done();
|
|
|
|
}).catch(done.fail);
|
2018-02-20 09:00:19 +00:00
|
|
|
});
|
2017-12-13 16:25:07 +00:00
|
|
|
});
|
2017-12-13 10:25:50 +00:00
|
|
|
});
|