137 lines
5.7 KiB
JavaScript
137 lines
5.7 KiB
JavaScript
import selectors from '../../helpers/selectors.js';
|
|
import createNightmare from '../../helpers/nightmare';
|
|
|
|
describe('Client Add address path', () => {
|
|
const nightmare = createNightmare();
|
|
|
|
beforeAll(() => {
|
|
nightmare
|
|
.waitForLogin('employee');
|
|
});
|
|
|
|
it('should click on the Clients button of the top bar menu', async () => {
|
|
const url = await nightmare
|
|
.waitToClick(selectors.globalItems.applicationsMenuButton)
|
|
.wait(selectors.globalItems.applicationsMenuVisible)
|
|
.waitToClick(selectors.globalItems.clientsButton)
|
|
.wait(selectors.clientsIndex.createClientButton)
|
|
.parsedUrl();
|
|
|
|
expect(url.hash).toEqual('#!/client/index');
|
|
});
|
|
|
|
it('should search for the user Bruce Banner', async () => {
|
|
const resultCount = await nightmare
|
|
.wait(selectors.clientsIndex.searchResult)
|
|
.type(selectors.clientsIndex.searchClientInput, 'Bruce Banner')
|
|
.click(selectors.clientsIndex.searchButton)
|
|
.waitForNumberOfElements(selectors.clientsIndex.searchResult, 1)
|
|
.countElement(selectors.clientsIndex.searchResult);
|
|
|
|
expect(resultCount).toEqual(1);
|
|
});
|
|
|
|
it(`should click on the search result to access to the client addresses`, async () => {
|
|
const url = await nightmare
|
|
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner')
|
|
.waitToClick(selectors.clientsIndex.searchResult)
|
|
.waitToClick(selectors.clientAddresses.addressesButton)
|
|
.waitForURL('address/index')
|
|
.url();
|
|
|
|
expect(url).toContain('address/index');
|
|
});
|
|
|
|
it(`should click on the add new address button to access to the new address form`, async () => {
|
|
const url = await nightmare
|
|
.waitToClick(selectors.clientAddresses.createAddress)
|
|
.waitForURL('address/create')
|
|
.url();
|
|
|
|
expect(url).toContain('address/create');
|
|
});
|
|
|
|
it(`should return to the addreses section by clicking the cancel button`, async () => {
|
|
const url = await nightmare
|
|
.waitToClick(selectors.clientAddresses.cancelButton)
|
|
.waitForURL('address/index')
|
|
.url();
|
|
|
|
expect(url).toContain('address/index');
|
|
});
|
|
|
|
it(`should now click on the add new address button to access to the new address form`, async () => {
|
|
const url = await nightmare
|
|
.waitToClick(selectors.clientAddresses.createAddress)
|
|
.waitForURL('address/create')
|
|
.url();
|
|
|
|
expect(url).toContain('address/create');
|
|
});
|
|
|
|
it('should receive an error after clicking save button as consignee, street and town fields are empty', async () => {
|
|
const result = await 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)
|
|
.waitForLastSnackbar();
|
|
|
|
expect(result).toEqual('Some fields are invalid');
|
|
});
|
|
|
|
it(`should create a new address with all it's data`, async () => {
|
|
const result = await 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)
|
|
.waitForLastSnackbar();
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
});
|
|
|
|
it(`should click on the addresses button confirm the new address exists and it's the default one`, async () => {
|
|
const result = await nightmare
|
|
.waitToClick(selectors.clientAddresses.addressesButton)
|
|
.wait(selectors.clientAddresses.defaultAddress)
|
|
.getInnerText(selectors.clientAddresses.defaultAddress);
|
|
|
|
expect(result).toContain('320 Park Avenue New York');
|
|
});
|
|
|
|
it(`should click on the make default icon of the second address then confirm it is the default one now`, async () => {
|
|
const result = await nightmare
|
|
.waitToClick(selectors.clientAddresses.secondMakeDefaultStar)
|
|
.waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand')
|
|
.getInnerText(selectors.clientAddresses.defaultAddress);
|
|
|
|
expect(result).toContain('Somewhere in Thailand');
|
|
});
|
|
|
|
it(`should click on the edit icon of the default address`, async () => {
|
|
const url = await nightmare
|
|
.waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand')
|
|
.waitToClick(selectors.clientAddresses.firstEditButton)
|
|
.waitForURL('/edit')
|
|
.url();
|
|
|
|
expect(url).toContain('/edit');
|
|
});
|
|
|
|
it(`should click on the active checkbox and receive an error to save it because it is the default address`, async () => {
|
|
const result = await nightmare
|
|
.waitToClick(selectors.clientAddresses.activeCheckbox)
|
|
.waitToClick(selectors.clientAddresses.saveButton)
|
|
.waitForLastSnackbar();
|
|
|
|
expect(result).toEqual('The default consignee can not be unchecked');
|
|
});
|
|
});
|