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-02-12 12:19:54 +00:00
|
|
|
describe('Add address path', () => {
|
2018-02-20 09:00:19 +00:00
|
|
|
const nightmare = createNightmare();
|
2017-12-13 10:25:50 +00:00
|
|
|
|
2018-03-02 11:15:17 +00:00
|
|
|
beforeAll(() => {
|
|
|
|
return nightmare
|
|
|
|
.waitForLogin('developer');
|
|
|
|
});
|
|
|
|
|
2018-02-20 09:00:19 +00:00
|
|
|
it('should click on the Clients button of the top bar menu', () => {
|
|
|
|
return nightmare
|
2017-12-13 10:25:50 +00:00
|
|
|
.waitToClick(selectors.globalItems.applicationsMenuButton)
|
|
|
|
.wait(selectors.globalItems.applicationsMenuVisible)
|
|
|
|
.waitToClick(selectors.globalItems.clientsButton)
|
|
|
|
.wait(selectors.clientsIndex.createClientButton)
|
2018-02-20 21:35:54 +00:00
|
|
|
.parsedUrl()
|
2017-12-13 10:25:50 +00:00
|
|
|
.then(url => {
|
2018-02-20 09:00:19 +00:00
|
|
|
expect(url.hash).toEqual('#!/clients');
|
|
|
|
});
|
2017-12-13 10:25:50 +00:00
|
|
|
});
|
|
|
|
|
2018-02-20 09:00:19 +00:00
|
|
|
it('should search for the user Bruce Banner', () => {
|
|
|
|
return nightmare
|
2017-12-13 10:25:50 +00:00
|
|
|
.wait(selectors.clientsIndex.searchResult)
|
|
|
|
.type(selectors.clientsIndex.searchClientInput, 'Bruce Banner')
|
|
|
|
.click(selectors.clientsIndex.searchButton)
|
|
|
|
.waitForNumberOfElements(selectors.clientsIndex.searchResult, 1)
|
|
|
|
.countSearchResults(selectors.clientsIndex.searchResult)
|
|
|
|
.then(result => {
|
|
|
|
expect(result).toEqual(1);
|
2018-02-20 09:00:19 +00:00
|
|
|
});
|
2017-12-13 10:25:50 +00:00
|
|
|
});
|
|
|
|
|
2018-02-20 09:00:19 +00:00
|
|
|
it(`should click on the search result to access to the client addresses`, () => {
|
|
|
|
return nightmare
|
2017-12-13 10:25:50 +00:00
|
|
|
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner')
|
|
|
|
.waitToClick(selectors.clientsIndex.searchResult)
|
2018-02-15 11:28:05 +00:00
|
|
|
.waitToClick(selectors.clientAddresses.addressesButton)
|
2017-12-13 10:25:50 +00:00
|
|
|
.waitForURL('addresses/list')
|
|
|
|
.url()
|
|
|
|
.then(url => {
|
|
|
|
expect(url).toContain('addresses/list');
|
2018-02-20 09:00:19 +00:00
|
|
|
});
|
2017-12-13 10:25:50 +00:00
|
|
|
});
|
|
|
|
|
2018-02-20 09:00:19 +00:00
|
|
|
it(`should click on the add new address button to access to the new address form`, () => {
|
|
|
|
return nightmare
|
2018-02-15 11:28:05 +00:00
|
|
|
.waitToClick(selectors.clientAddresses.createAddress)
|
2017-12-13 10:25:50 +00:00
|
|
|
.waitForURL('addresses/create')
|
|
|
|
.url()
|
|
|
|
.then(url => {
|
|
|
|
expect(url).toContain('addresses/create');
|
2018-02-20 09:00:19 +00:00
|
|
|
});
|
2017-12-13 10:25:50 +00:00
|
|
|
});
|
|
|
|
|
2018-03-05 11:26:00 +00:00
|
|
|
it('should receive an error after clicking save button as consignee, street and town fields are empty', () => {
|
2018-02-20 09:00:19 +00:00
|
|
|
return nightmare
|
2018-02-15 11:28:05 +00:00
|
|
|
.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')
|
2018-03-05 11:26:00 +00:00
|
|
|
.waitToClick(selectors.clientFiscalData.saveButton)
|
2018-02-20 09:00:19 +00:00
|
|
|
.waitForSnackbar()
|
2017-12-13 10:25:50 +00:00
|
|
|
.then(result => {
|
2018-01-11 12:16:39 +00:00
|
|
|
expect(result).toContain('Some fields are invalid');
|
2018-02-20 09:00:19 +00:00
|
|
|
});
|
2017-12-13 10:25:50 +00:00
|
|
|
});
|
|
|
|
|
2018-02-20 09:00:19 +00:00
|
|
|
it(`should create a new address with all it's data`, () => {
|
|
|
|
return nightmare
|
2018-02-15 11:28:05 +00:00
|
|
|
.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-02-20 09:00:19 +00:00
|
|
|
.waitForSnackbar()
|
2017-12-13 10:25:50 +00:00
|
|
|
.then(result => {
|
|
|
|
expect(result).toContain('Data saved!');
|
2018-02-20 09:00:19 +00:00
|
|
|
});
|
2017-12-13 10:25:50 +00:00
|
|
|
});
|
|
|
|
|
2018-02-20 09:00:19 +00:00
|
|
|
it(`should click on the addresses button confirm the new address exists and it's the default one`, () => {
|
|
|
|
return nightmare
|
2018-02-15 11:28:05 +00:00
|
|
|
.waitToClick(selectors.clientAddresses.addressesButton)
|
|
|
|
.wait(selectors.clientAddresses.defaultAddress)
|
|
|
|
.getInnerText(selectors.clientAddresses.defaultAddress)
|
2017-12-13 10:25:50 +00:00
|
|
|
.then(result => {
|
|
|
|
expect(result).toContain('320 Park Avenue New York');
|
2018-02-20 09:00:19 +00:00
|
|
|
});
|
2017-12-13 10:25:50 +00:00
|
|
|
});
|
|
|
|
|
2018-02-20 09:00:19 +00:00
|
|
|
it(`should click on the make default icon of the second address then confirm it is the default one now`, () => {
|
|
|
|
return nightmare
|
2018-02-15 11:28:05 +00:00
|
|
|
.waitToClick(selectors.clientAddresses.secondMakeDefaultStar)
|
|
|
|
.waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand')
|
|
|
|
.getInnerText(selectors.clientAddresses.defaultAddress)
|
2017-12-13 10:25:50 +00:00
|
|
|
.then(result => {
|
|
|
|
expect(result).toContain('Somewhere in Thailand');
|
2018-02-20 09:00:19 +00:00
|
|
|
});
|
2017-12-13 10:25:50 +00:00
|
|
|
});
|
|
|
|
|
2018-02-20 09:00:19 +00:00
|
|
|
it(`should click on the edit icon of the default address`, () => {
|
|
|
|
return nightmare
|
2018-02-15 11:28:05 +00:00
|
|
|
.waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand')
|
|
|
|
.waitToClick(selectors.clientAddresses.firstEditButton)
|
2017-12-13 10:25:50 +00:00
|
|
|
.waitForURL('/edit')
|
|
|
|
.url()
|
|
|
|
.then(result => {
|
|
|
|
expect(result).toContain('/edit');
|
2018-02-20 09:00:19 +00:00
|
|
|
});
|
2017-12-13 10:25:50 +00:00
|
|
|
});
|
|
|
|
|
2018-02-20 09:00:19 +00:00
|
|
|
it(`should click on the active checkbox and receive an error to save it becouse it is the default address`, () => {
|
|
|
|
return nightmare
|
2018-02-15 11:28:05 +00:00
|
|
|
.waitToClick(selectors.clientAddresses.activeCheckbox)
|
|
|
|
.waitToClick(selectors.clientAddresses.saveButton)
|
2018-02-20 09:00:19 +00:00
|
|
|
.waitForSnackbar()
|
2017-12-13 16:25:07 +00:00
|
|
|
.then(result => {
|
2018-03-08 11:23:51 +00:00
|
|
|
expect(result).toContain('Error:');
|
2018-02-20 09:00:19 +00:00
|
|
|
});
|
2017-12-13 16:25:07 +00:00
|
|
|
});
|
2017-12-13 10:25:50 +00:00
|
|
|
});
|