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.payMethod, 'PayMethod with IBAN'); await page.autocompleteSearch(selectors.clientBillingData.swiftBic, 'BBKKESMMMMM'); await page.clearInput(selectors.clientBillingData.dueDay); await page.write(selectors.clientBillingData.dueDay, '60'); await page.waitForTextInField(selectors.clientBillingData.dueDay, '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.waitForTextInField(selectors.clientBillingData.swiftBic, 'Gotham City Bank'); let newcode = await page.waitToGetProperty(selectors.clientBillingData.swiftBic, '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.payMethod, '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.IBAN, 'ES9121000418450200051332'); await page.keyboard.press('Tab'); await page.keyboard.press('Tab'); await page.waitForTextInField(selectors.clientBillingData.swiftBic, 'caixesbb'); let automaticCode = await page.waitToGetProperty(selectors.clientBillingData.swiftBic, 'value'); expect(automaticCode).toEqual('CAIXESBB Caixa Bank'); }); it(`should save the form with all its new data`, async() => { await page.waitFor(3000); 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.dueDay, 'value'); expect(dueDate).toEqual('60'); }); it('should confirm the IBAN was saved', async() => { let IBAN = await page.waitToGetProperty(selectors.clientBillingData.IBAN, 'value'); expect(IBAN).toEqual('ES9121000418450200051332'); }); it('should confirm the swift / BIC code was saved', async() => { let code = await page.waitToGetProperty(selectors.clientBillingData.swiftBic, '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'); }); });