salix/e2e/paths/edit_fiscal_data.spec.js

256 lines
8.9 KiB
JavaScript
Raw Normal View History

import config from '../helpers/config.js';
import createNightmare from '../helpers/nightmare';
import selectors from '../helpers/selectors.js';
import {catchErrors} from '../../services/utils/jasmineHelpers';
const nightmare = createNightmare();
const moduleAccessViewHashURL = '#!/';
describe('Edit fiscalData path', () => {
describe('warm up', () => {
it('should warm up login and fixtures', done => {
nightmare
.login()
.waitForURL(moduleAccessViewHashURL)
.waitToClick(selectors.globalItems.logOutButton)
.then(() => {
done();
})
.catch(catchErrors(done));
});
});
it('should log in', done => {
nightmare
.login()
.waitForURL(moduleAccessViewHashURL)
.url()
.then(url => {
2017-11-08 14:43:34 +00:00
expect(url).toEqual(config.url + moduleAccessViewHashURL);
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 => {
2017-11-08 14:43:34 +00:00
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 => {
2017-11-08 14:43:34 +00:00
expect(result).toEqual(1);
done();
})
.catch(catchErrors(done));
});
it(`should click on the search result to access to the client's fiscal data`, done => {
nightmare
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner')
.waitToClick(selectors.clientsIndex.searchResult)
.waitToClick(selectors.fiscalData.fiscalDataButton)
.waitForURL('fiscal-data')
.url()
.then(url => {
expect(url).toContain('fiscal-data');
done();
})
.catch(catchErrors(done));
});
it('should uncheck the hasToInvoice checkbox', done => {
nightmare
2017-11-06 09:46:32 +00:00
.waitToClick(selectors.fiscalData.hasToInvoiceCheckboxLabel)
.waitToClick(selectors.fiscalData.saveButton)
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
expect(result).toEqual('¡Datos guardados!');
done();
})
.catch(catchErrors(done));
});
it('should confirm hasToInvoice checkbox is unchecked', done => {
nightmare
.waitForSnackbarReset()
.waitToClick(selectors.basicData.basicDataButton)
.wait(selectors.basicData.nameInput)
.waitToClick(selectors.fiscalData.fiscalDataButton)
2017-11-06 09:46:32 +00:00
.wait(selectors.fiscalData.hasToInvoiceCheckboxLabel)
.evaluate(selector => {
return document.querySelector(selector).checked;
2017-11-08 14:43:34 +00:00
}, selectors.fiscalData.hasToInvoiceCheckboxLabel)
.then(value => {
expect(value).toBeFalsy();
done();
})
.catch(catchErrors(done));
});
it('should uncheck the invoiceByMail checkbox', done => {
2017-11-08 14:43:34 +00:00
nightmare
.waitToClick(selectors.fiscalData.invoiceByMailCheckboxLabel)
.waitToClick(selectors.fiscalData.saveButton)
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
expect(result).toEqual('¡Datos guardados!');
2017-11-08 14:43:34 +00:00
done();
})
.catch(catchErrors(done));
});
it('should confirm invoiceByMail checkbox is unchecked', done => {
2017-11-08 14:43:34 +00:00
nightmare
.waitForSnackbarReset()
.waitToClick(selectors.basicData.basicDataButton)
.wait(selectors.basicData.nameInput)
.waitToClick(selectors.fiscalData.fiscalDataButton)
.wait(selectors.fiscalData.invoiceByMailCheckboxLabel)
.evaluate(selector => {
return document.querySelector(selector).checked;
}, selectors.fiscalData.invoiceByMailCheckboxLabel)
.then(value => {
expect(value).toBeFalsy();
done();
})
.catch(catchErrors(done));
});
it('should edit the address', done => {
nightmare
.wait(selectors.fiscalData.addressInput)
.clearInput(selectors.fiscalData.addressInput)
.type(selectors.fiscalData.addressInput, 'Alpha Flight Low-Orbit')
.click(selectors.fiscalData.saveButton)
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
expect(result).toEqual('¡Datos guardados!');
done();
})
.catch(catchErrors(done));
});
it('should confirm the address have been edited', done => {
nightmare
.waitForSnackbarReset()
.click(selectors.basicData.basicDataButton)
.wait(selectors.basicData.nameInput)
.click(selectors.fiscalData.fiscalDataButton)
.wait(selectors.fiscalData.addressInput)
.getInputValue(selectors.fiscalData.addressInput)
.then(result => {
expect(result).toEqual('Alpha Flight Low-Orbit');
done();
})
.catch(catchErrors(done));
});
it('should edit the city', done => {
nightmare
.wait(selectors.fiscalData.cityInput)
.clearInput(selectors.fiscalData.cityInput)
.type(selectors.fiscalData.cityInput, 'N/A')
.click(selectors.fiscalData.saveButton)
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
expect(result).toEqual('¡Datos guardados!');
done();
})
.catch(catchErrors(done));
});
it('should confirm the city have been edited', done => {
nightmare
.waitForSnackbarReset()
.click(selectors.basicData.basicDataButton)
.wait(selectors.basicData.nameInput)
.click(selectors.fiscalData.fiscalDataButton)
.wait(selectors.fiscalData.cityInput)
.getInputValue(selectors.fiscalData.cityInput)
.then(result => {
expect(result).toEqual('N/A');
done();
})
.catch(catchErrors(done));
});
it('should edit the postcode', done => {
nightmare
.wait(selectors.fiscalData.postcodeInput)
.clearInput(selectors.fiscalData.postcodeInput)
.type(selectors.fiscalData.postcodeInput, '12345')
.click(selectors.fiscalData.saveButton)
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
expect(result).toEqual('¡Datos guardados!');
done();
})
.catch(catchErrors(done));
});
it('should confirm the postcode have been edited', done => {
nightmare
.waitForSnackbarReset()
.click(selectors.basicData.basicDataButton)
.wait(selectors.basicData.nameInput)
.click(selectors.fiscalData.fiscalDataButton)
.wait(selectors.fiscalData.postcodeInput)
.getInputValue(selectors.fiscalData.postcodeInput)
.then(result => {
expect(result).toEqual('12345');
done();
})
.catch(catchErrors(done));
});
// it(`should edit the province`, done => {
// nightmare
// .waitToClick(selectors.fiscalData.provinceInput)
// .waitToClick(selectors.fiscalData.provinceInput)
// .waitToClick(selectors.fiscalData.provinceMetropolisOption)
// .waitToClick(selectors.fiscalData.saveButton)
// .wait(selectors.globalItems.snackbarIsActive)
// .getInnerText(selectors.globalItems.snackbarIsActive)
// .then(result => {
// expect(result).toEqual(`¡Datos guardados!`);
// done();
// })
// .catch(catchErrors(done));
// });
// it(`should confirm the province have been selected`, done => {
// nightmare
// .waitForSnackbarReset()
// .click(selectors.fiscalData.fiscalDataButton)
// .wait(selectors.fiscalData.addressInput)
// .click(selectors.fiscalData.basicDataButton)
// .wait(100)
// .getInputValue(selectors.fiscalData.provinceInput)
// .then(result => {
// expect(result).toEqual('Province two');
// done();
// })
// .catch(catchErrors(done));
// });
});