salix/e2e/paths/02-client-module/04_edit_billing_data.spec.js

106 lines
4.8 KiB
JavaScript

import selectors from '../../helpers/selectors';
import getBrowser from '../../helpers/puppeteer';
describe('Client Edit billing data path', () => {
let browser;
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('administrative', 'client');
await page.accessToSearchResult('Bruce Banner');
await page.accessToSection('client.card.billingData');
});
afterAll(async() => {
await browser.close();
});
it(`should attempt to edit the billing data without an IBAN but fail`, async() => {
await page.autocompleteSearch(selectors.clientBillingData.payMethodAutocomplete, 'PayMethod with IBAN');
await page.autocompleteSearch(selectors.clientBillingData.swiftBicAutocomplete, 'BBKKESMMMMM');
await page.clearInput(selectors.clientBillingData.dueDayInput);
await page.write(selectors.clientBillingData.dueDayInput, '60');
await page.waitForTextInInput(selectors.clientBillingData.dueDayInput, '60');
await page.waitToClick(selectors.clientBillingData.receivedCoreLCRCheckbox);
await page.waitToClick(selectors.clientBillingData.receivedCoreVNLCheckbox);
await page.waitToClick(selectors.clientBillingData.receivedB2BVNLCheckbox);
await page.waitToClick(selectors.clientBillingData.saveButton);
let snackbarMessage = await page.waitForLastSnackbar();
expect(snackbarMessage).toEqual('That payment method requires an IBAN');
});
it(`should create a new BIC code`, async() => {
await page.waitToClick(selectors.clientBillingData.newBankEntityButton);
await page.write(selectors.clientBillingData.newBankEntityName, 'Gotham City Bank');
await page.write(selectors.clientBillingData.newBankEntityCode, '9999');
await page.write(selectors.clientBillingData.newBankEntityBIC, 'GTHMCT');
await page.waitToClick(selectors.clientBillingData.acceptBankEntityButton);
await page.waitForTextInInput(selectors.clientBillingData.swiftBicAutocomplete, 'Gotham City Bank');
let newcode = await page.waitToGetProperty(`${selectors.clientBillingData.swiftBicAutocomplete} input`, 'value');
expect(newcode).toEqual('GTHMCT Gotham City Bank');
});
it(`should confirm the IBAN pay method was sucessfully saved`, async() => {
let payMethod = await page.waitToGetProperty(`${selectors.clientBillingData.payMethodAutocomplete} input`, 'value');
expect(payMethod).toEqual('PayMethod with IBAN');
});
it(`should clear the BIC code field, update the IBAN to see how he BIC code autocompletes`, async() => {
await page.write(selectors.clientBillingData.IBANInput, 'ES9121000418450200051332');
await page.keyboard.press('Tab');
await page.keyboard.press('Tab');
await page.waitForTextInInput(selectors.clientBillingData.swiftBicAutocomplete, 'caixesbb');
let automaticCode = await page.waitToGetProperty(`${selectors.clientBillingData.swiftBicAutocomplete} input`, 'value');
expect(automaticCode).toEqual('CAIXESBB Caixa Bank');
});
it(`should save the form with all its new data`, async() => {
await page.waitForWatcherData(selectors.clientBillingData.watcher);
await page.waitToClick(selectors.clientBillingData.saveButton);
let snackbarMessage = await page.waitForLastSnackbar();
expect(snackbarMessage).toEqual('Notification sent!');
});
it('should confirm the due day have been edited', async() => {
let dueDate = await page.waitToGetProperty(`${selectors.clientBillingData.dueDayInput} input`, 'value');
expect(dueDate).toEqual('60');
});
it('should confirm the IBAN was saved', async() => {
let IBAN = await page.waitToGetProperty(`${selectors.clientBillingData.IBANInput} input`, 'value');
expect(IBAN).toEqual('ES9121000418450200051332');
});
it('should confirm the swift / BIC code was saved', async() => {
let code = await page.waitToGetProperty(`${selectors.clientBillingData.swiftBicAutocomplete} input`, 'value');
expect(code).toEqual('CAIXESBB Caixa Bank');
});
it('should confirm Received LCR checkbox is checked', async() => {
let result = await page.checkboxState(selectors.clientBillingData.receivedCoreLCRCheckbox);
expect(result).toBe('checked');
});
it('should confirm Received core VNL checkbox is unchecked', async() => {
let result = await page.checkboxState(selectors.clientBillingData.receivedCoreVNLCheckbox);
expect(result).toBe('unchecked');
});
it('should confirm Received B2B VNL checkbox is unchecked', async() => {
let result = await page.checkboxState(selectors.clientBillingData.receivedB2BVNLCheckbox);
expect(result).toBe('unchecked');
});
});