2018-02-15 11:28:05 +00:00
|
|
|
import selectors from '../../helpers/selectors.js';
|
2018-10-24 08:57:14 +00:00
|
|
|
import createNightmare from '../../helpers/nightmare';
|
2017-12-13 10:25:50 +00:00
|
|
|
|
2018-10-31 10:58:10 +00:00
|
|
|
describe('Client Edit pay method path', () => {
|
|
|
|
const nightmare = createNightmare();
|
|
|
|
|
|
|
|
beforeAll(() => {
|
|
|
|
nightmare
|
2018-11-23 07:05:57 +00:00
|
|
|
.loginAndModule('administrative', 'client');
|
2018-10-31 10:58:10 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should search for the user Bruce Banner', async () => {
|
|
|
|
const resultCount = await nightmare
|
2018-11-21 13:30:32 +00:00
|
|
|
.wait(selectors.clientsIndex.searchClientInput)
|
2018-10-31 10:58:10 +00:00
|
|
|
.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's pay method`, async () => {
|
|
|
|
const url = await nightmare
|
|
|
|
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner')
|
|
|
|
.waitToClick(selectors.clientsIndex.searchResult)
|
|
|
|
.waitToClick(selectors.clientPayMethod.payMethodButton)
|
|
|
|
.waitForURL('billing-data')
|
2018-11-22 14:44:33 +00:00
|
|
|
.parsedUrl();
|
2018-10-31 10:58:10 +00:00
|
|
|
|
2018-11-22 14:44:33 +00:00
|
|
|
expect(url.hash).toContain('billing-data');
|
2018-10-31 10:58:10 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it(`should attempt to edit the Pay method without an IBAN but fail`, async () => {
|
|
|
|
const snackbarMessage = await nightmare
|
|
|
|
.waitToClick(selectors.clientPayMethod.payMethodInput)
|
|
|
|
.waitToClick(selectors.clientPayMethod.payMethodIBANOption)
|
|
|
|
.waitForTextInInput(selectors.clientPayMethod.payMethodInput, 'PayMethod with IBAN')
|
2018-11-21 10:53:18 +00:00
|
|
|
.waitToClick(selectors.clientPayMethod.swiftBicInput)
|
|
|
|
.waitToClick(selectors.clientPayMethod.firstSwiftBicOption)
|
|
|
|
.waitForTextInInput(selectors.clientPayMethod.swiftBicInput, 'BBKKESMMMMM')
|
2018-10-31 10:58:10 +00:00
|
|
|
.clearInput(selectors.clientPayMethod.dueDayInput)
|
|
|
|
.type(selectors.clientPayMethod.dueDayInput, '60')
|
|
|
|
.waitForTextInInput(selectors.clientPayMethod.dueDayInput, '60')
|
|
|
|
.waitToClick(selectors.clientPayMethod.receivedCoreLCRCheckbox)
|
|
|
|
.waitToClick(selectors.clientPayMethod.receivedCoreVNLCheckbox)
|
|
|
|
.waitToClick(selectors.clientPayMethod.receivedB2BVNLCheckbox)
|
|
|
|
.waitToClick(selectors.clientPayMethod.saveButton)
|
|
|
|
.waitForLastSnackbar();
|
|
|
|
|
|
|
|
expect(snackbarMessage).toEqual('That payment method requires an IBAN');
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`should add the IBAN but fail as it requires a BIC code`, async () => {
|
|
|
|
const snackbarMessage = await nightmare
|
|
|
|
.clearInput(selectors.clientPayMethod.IBANInput)
|
2018-11-22 11:53:11 +00:00
|
|
|
.type(selectors.clientPayMethod.IBANInput, 'ES91 2100 0418 4502 0005 1332')
|
|
|
|
.waitForTextInInput(selectors.clientPayMethod.IBANInput, 'ES91 2100 0418 4502 0005 1332')
|
2018-11-21 10:53:18 +00:00
|
|
|
.waitToClick(selectors.clientPayMethod.clearswiftBicButton)
|
2018-10-31 10:58:10 +00:00
|
|
|
.waitToClick(selectors.clientPayMethod.saveButton)
|
|
|
|
.waitForLastSnackbar();
|
|
|
|
|
|
|
|
expect(snackbarMessage).toEqual('That payment method requires a BIC');
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`should create a new BIC code`, async () => {
|
|
|
|
const newcode = await nightmare
|
|
|
|
.click(selectors.clientPayMethod.newBankEntityButton)
|
|
|
|
.type(selectors.clientPayMethod.newBankEntityName, 'Gotham City Banks')
|
|
|
|
.type(selectors.clientPayMethod.newBankEntityBIC, 'GTHMCT')
|
|
|
|
.click(selectors.clientPayMethod.acceptBankEntityButton)
|
2018-11-22 14:44:33 +00:00
|
|
|
.waitToGetProperty(selectors.clientPayMethod.swiftBicInput, 'value');
|
2018-10-31 10:58:10 +00:00
|
|
|
|
2018-11-22 14:44:33 +00:00
|
|
|
expect(newcode).toEqual('GTHMCT Gotham City Banks');
|
2018-10-31 10:58:10 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it(`should confirm the IBAN pay method is sucessfully saved`, async () => {
|
|
|
|
const payMethod = await nightmare
|
2018-11-22 14:44:33 +00:00
|
|
|
.waitToGetProperty(selectors.clientPayMethod.payMethodInput, 'value');
|
2018-10-31 10:58:10 +00:00
|
|
|
|
|
|
|
expect(payMethod).toEqual('PayMethod with IBAN');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should confirm the due day have been edited', async () => {
|
|
|
|
const dueDate = await nightmare
|
2018-11-22 14:44:33 +00:00
|
|
|
.waitToGetProperty(selectors.clientPayMethod.dueDayInput, 'value');
|
2018-10-31 10:58:10 +00:00
|
|
|
|
|
|
|
expect(dueDate).toEqual('60');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should confirm the IBAN was saved', async () => {
|
|
|
|
const IBAN = await nightmare
|
2018-11-22 11:34:20 +00:00
|
|
|
.waitToGetProperty(selectors.clientPayMethod.IBANInput, 'value');
|
2018-10-31 10:58:10 +00:00
|
|
|
|
|
|
|
expect(IBAN).toEqual('ES91 2100 0418 4502 0005 1332');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should confirm the swift / BIC code was saved', async () => {
|
|
|
|
const code = await nightmare
|
2018-11-22 11:34:20 +00:00
|
|
|
.waitToGetProperty(selectors.clientPayMethod.swiftBicInput, 'value');
|
2018-10-31 10:58:10 +00:00
|
|
|
|
|
|
|
expect(code).toEqual('GTHMCT Gotham City Banks');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should confirm Received LCR checkbox is checked', async () => {
|
|
|
|
const checkedBox = await nightmare
|
2018-11-07 12:32:09 +00:00
|
|
|
.evaluate(selector => {
|
2018-10-31 10:58:10 +00:00
|
|
|
return document.querySelector(selector).checked;
|
|
|
|
}, selectors.clientPayMethod.receivedCoreLCRCheckbox);
|
|
|
|
|
|
|
|
expect(checkedBox).toBeTruthy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should confirm Received core VNL checkbox is unchecked', async () => {
|
|
|
|
const checkedBox = await nightmare
|
2018-11-07 12:32:09 +00:00
|
|
|
.evaluate(selector => {
|
2018-10-31 10:58:10 +00:00
|
|
|
return document.querySelector(selector).checked;
|
|
|
|
}, selectors.clientPayMethod.receivedCoreVNLCheckbox);
|
|
|
|
|
|
|
|
expect(checkedBox).toBeFalsy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should confirm Received B2B VNL checkbox is unchecked', async () => {
|
|
|
|
const checkedBox = await nightmare
|
2018-11-07 12:32:09 +00:00
|
|
|
.evaluate(selector => {
|
2018-10-31 10:58:10 +00:00
|
|
|
return document.querySelector(selector).checked;
|
|
|
|
}, selectors.clientPayMethod.receivedB2BVNLCheckbox);
|
|
|
|
|
|
|
|
expect(checkedBox).toBeFalsy();
|
2018-01-09 12:51:41 +00:00
|
|
|
});
|
2017-12-11 11:33:27 +00:00
|
|
|
});
|