2018-02-15 11:28:05 +00:00
|
|
|
import config from '../../helpers/config.js';
|
|
|
|
import createNightmare from '../../helpers/nightmare';
|
|
|
|
import selectors from '../../helpers/selectors.js';
|
|
|
|
import {catchErrors} from '../../../services/utils/jasmineHelpers';
|
2017-12-13 10:25:50 +00:00
|
|
|
const nightmare = createNightmare();
|
|
|
|
const moduleAccessViewHashURL = '#!/';
|
|
|
|
|
|
|
|
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
|
|
|
|
|
2018-02-12 12:19:54 +00:00
|
|
|
describe('Add address path', () => {
|
2017-12-13 10:25:50 +00:00
|
|
|
it('should log in', done => {
|
|
|
|
nightmare
|
|
|
|
.login()
|
|
|
|
.waitForURL(moduleAccessViewHashURL)
|
|
|
|
.url()
|
|
|
|
.then(url => {
|
|
|
|
expect(url).toEqual(config.url + moduleAccessViewHashURL);
|
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should make sure the language is English', done => {
|
|
|
|
nightmare
|
|
|
|
.changeLanguageToEnglish()
|
|
|
|
.then(() => {
|
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should click on the Clients button of the top bar menu', done => {
|
|
|
|
nightmare
|
|
|
|
.waitToClick(selectors.globalItems.applicationsMenuButton)
|
|
|
|
.wait(selectors.globalItems.applicationsMenuVisible)
|
|
|
|
.waitToClick(selectors.globalItems.clientsButton)
|
|
|
|
.wait(selectors.clientsIndex.createClientButton)
|
|
|
|
.url()
|
|
|
|
.then(url => {
|
|
|
|
expect(url).toEqual(config.url + '#!/clients');
|
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should search for the user Bruce Banner', done => {
|
|
|
|
nightmare
|
|
|
|
.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);
|
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
|
|
|
});
|
|
|
|
|
2018-02-12 12:19:54 +00:00
|
|
|
it(`should click on the search result to access to the client addresses`, done => {
|
2017-12-13 10:25:50 +00:00
|
|
|
nightmare
|
|
|
|
.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');
|
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`should click on the add new address button to access to the new address form`, done => {
|
|
|
|
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');
|
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should check the default checkbox then receive an error after clicking save button as the form is empty', done => {
|
|
|
|
nightmare
|
2018-02-15 11:28:05 +00:00
|
|
|
.waitToClick(selectors.clientAddresses.defaultCheckboxInput)
|
|
|
|
.waitToClick(selectors.clientFiscalData.saveButton)
|
2018-01-09 12:51:41 +00:00
|
|
|
.wait(selectors.globalItems.snackbarIsActive)
|
|
|
|
.getInnerText(selectors.globalItems.snackbarIsActive)
|
|
|
|
.then(result => {
|
2018-01-11 12:16:39 +00:00
|
|
|
expect(result).toContain('Some fields are invalid');
|
2018-01-09 12:51:41 +00:00
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
2017-12-13 10:25:50 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should receive an error when clicking the save button having all the form fields empty but consignee', done => {
|
|
|
|
nightmare
|
|
|
|
.waitForSnackbarReset()
|
2018-02-15 11:28:05 +00:00
|
|
|
.type(selectors.clientAddresses.consigneeInput, 'Bruce Bunner')
|
2017-12-13 10:25:50 +00:00
|
|
|
.click(selectors.createClientView.createButton)
|
|
|
|
.wait(selectors.globalItems.snackbarIsActive)
|
|
|
|
.getInnerText(selectors.globalItems.snackbarIsActive)
|
|
|
|
.then(result => {
|
2018-01-11 12:16:39 +00:00
|
|
|
expect(result).toContain('Some fields are invalid');
|
2017-12-13 10:25:50 +00:00
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should receive an error when clicking the save button having all the form fields empty but Street', done => {
|
|
|
|
nightmare
|
|
|
|
.waitForSnackbarReset()
|
2018-02-15 11:28:05 +00:00
|
|
|
.clearInput(selectors.clientAddresses.consigneeInput)
|
|
|
|
.type(selectors.clientAddresses.streetAddressInput, '320 Park Avenue New York')
|
2017-12-13 10:25:50 +00:00
|
|
|
.click(selectors.createClientView.createButton)
|
|
|
|
.wait(selectors.globalItems.snackbarIsActive)
|
|
|
|
.getInnerText(selectors.globalItems.snackbarIsActive)
|
|
|
|
.then(result => {
|
2018-01-11 12:16:39 +00:00
|
|
|
expect(result).toContain('Some fields are invalid');
|
2017-12-13 10:25:50 +00:00
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should receive an error when clicking the save button having all the form fields empty but postcode', done => {
|
|
|
|
nightmare
|
|
|
|
.waitForSnackbarReset()
|
2018-02-15 11:28:05 +00:00
|
|
|
.clearInput(selectors.clientAddresses.streetAddressInput)
|
|
|
|
.type(selectors.clientAddresses.postcodeInput, '10022')
|
2017-12-13 10:25:50 +00:00
|
|
|
.click(selectors.createClientView.createButton)
|
|
|
|
.wait(selectors.globalItems.snackbarIsActive)
|
|
|
|
.getInnerText(selectors.globalItems.snackbarIsActive)
|
|
|
|
.then(result => {
|
2018-01-11 12:16:39 +00:00
|
|
|
expect(result).toContain('Some fields are invalid');
|
2017-12-13 10:25:50 +00:00
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should receive an error when clicking the save button having all the form fields empty but city', done => {
|
|
|
|
nightmare
|
|
|
|
.waitForSnackbarReset()
|
2018-02-15 11:28:05 +00:00
|
|
|
.clearInput(selectors.clientAddresses.postcodeInput)
|
|
|
|
.type(selectors.clientAddresses.cityInput, 'New York')
|
2017-12-13 10:25:50 +00:00
|
|
|
.click(selectors.createClientView.createButton)
|
|
|
|
.wait(selectors.globalItems.snackbarIsActive)
|
|
|
|
.getInnerText(selectors.globalItems.snackbarIsActive)
|
|
|
|
.then(result => {
|
2018-01-11 12:16:39 +00:00
|
|
|
expect(result).toContain('Some fields are invalid');
|
2017-12-13 10:25:50 +00:00
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should receive an error when clicking the save button having all the form fields empty but province', done => {
|
|
|
|
nightmare
|
|
|
|
.waitForSnackbarReset()
|
2018-02-15 11:28:05 +00:00
|
|
|
.clearInput(selectors.clientAddresses.cityInput)
|
|
|
|
.waitToClick(selectors.clientAddresses.provinceInput)
|
|
|
|
.waitToClick(selectors.clientAddresses.provinceSecondOption)
|
2017-12-13 10:25:50 +00:00
|
|
|
.click(selectors.createClientView.createButton)
|
|
|
|
.wait(selectors.globalItems.snackbarIsActive)
|
|
|
|
.getInnerText(selectors.globalItems.snackbarIsActive)
|
|
|
|
.then(result => {
|
2018-01-11 12:16:39 +00:00
|
|
|
expect(result).toContain('Some fields are invalid');
|
2017-12-13 10:25:50 +00:00
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should receive an error when clicking the save button having all the form fields empty but province and agency', done => {
|
|
|
|
nightmare
|
|
|
|
.waitForSnackbarReset()
|
2018-02-15 11:28:05 +00:00
|
|
|
.waitToClick(selectors.clientAddresses.agencyInput)
|
|
|
|
.waitToClick(selectors.clientAddresses.agenctySecondOption)
|
2017-12-13 10:25:50 +00:00
|
|
|
.click(selectors.createClientView.createButton)
|
|
|
|
.wait(selectors.globalItems.snackbarIsActive)
|
|
|
|
.getInnerText(selectors.globalItems.snackbarIsActive)
|
|
|
|
.then(result => {
|
2018-01-11 12:16:39 +00:00
|
|
|
expect(result).toContain('Some fields are invalid');
|
2017-12-13 10:25:50 +00:00
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should receive an error when clicking the save button having all the form fields empty but province, agency and phone', done => {
|
|
|
|
nightmare
|
|
|
|
.waitForSnackbarReset()
|
2018-02-15 11:28:05 +00:00
|
|
|
.type(selectors.clientAddresses.phoneInput, '999887744')
|
2017-12-13 10:25:50 +00:00
|
|
|
.click(selectors.createClientView.createButton)
|
|
|
|
.wait(selectors.globalItems.snackbarIsActive)
|
|
|
|
.getInnerText(selectors.globalItems.snackbarIsActive)
|
|
|
|
.then(result => {
|
2018-01-11 12:16:39 +00:00
|
|
|
expect(result).toContain('Some fields are invalid');
|
2017-12-13 10:25:50 +00:00
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should receive an error when clicking the save button having all the form fields empty but province, agency and mobile', done => {
|
|
|
|
nightmare
|
|
|
|
.waitForSnackbarReset()
|
2018-02-15 11:28:05 +00:00
|
|
|
.clearInput(selectors.clientAddresses.phoneInput)
|
|
|
|
.type(selectors.clientAddresses.mobileInput, '999887744')
|
2017-12-13 10:25:50 +00:00
|
|
|
.click(selectors.createClientView.createButton)
|
|
|
|
.wait(selectors.globalItems.snackbarIsActive)
|
|
|
|
.getInnerText(selectors.globalItems.snackbarIsActive)
|
|
|
|
.then(result => {
|
2018-01-11 12:16:39 +00:00
|
|
|
expect(result).toContain('Some fields are invalid');
|
2017-12-13 10:25:50 +00:00
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`should create a new address with all it's data`, done => {
|
|
|
|
nightmare
|
|
|
|
.waitForSnackbarReset()
|
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.postcodeInput, '10022')
|
|
|
|
.type(selectors.clientAddresses.cityInput, 'New York')
|
|
|
|
.type(selectors.clientAddresses.phoneInput, '999887744')
|
|
|
|
.click(selectors.clientAddresses.saveButton)
|
2017-12-13 10:25:50 +00:00
|
|
|
.wait(selectors.globalItems.snackbarIsActive)
|
|
|
|
.getInnerText(selectors.globalItems.snackbarIsActive)
|
|
|
|
.then(result => {
|
|
|
|
expect(result).toContain('Data saved!');
|
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`should click on the addresses button confirm the new address exists and it's the default one`, done => {
|
|
|
|
nightmare
|
|
|
|
.waitForSnackbarReset()
|
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');
|
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`should click on the make default icon of the second address then confirm it is the default one now`, done => {
|
|
|
|
nightmare
|
|
|
|
.waitForSnackbarReset()
|
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');
|
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`should click on the edit icon of the default address`, done => {
|
|
|
|
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');
|
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
|
|
|
});
|
|
|
|
|
2017-12-13 16:25:07 +00:00
|
|
|
it(`should click on the active checkbox and receive an error to save it becouse it is the default address`, done => {
|
|
|
|
nightmare
|
|
|
|
.waitForSnackbarReset()
|
2018-02-15 11:28:05 +00:00
|
|
|
.waitToClick(selectors.clientAddresses.activeCheckbox)
|
|
|
|
.waitToClick(selectors.clientAddresses.saveButton)
|
2017-12-13 16:25:07 +00:00
|
|
|
.wait(selectors.globalItems.snackbarIsActive)
|
|
|
|
.getInnerText(selectors.globalItems.snackbarIsActive)
|
|
|
|
.then(result => {
|
2017-12-15 12:35:36 +00:00
|
|
|
expect(result).toContain('Error');
|
2017-12-13 16:25:07 +00:00
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
|
|
|
});
|
2017-12-13 10:25:50 +00:00
|
|
|
});
|