import getBrowser from '../../helpers/puppeteer'; const $ = { saveButton: 'vn-supplier-fiscal-data button[type="submit"]', }; const $inputs = { province: 'vn-supplier-fiscal-data [name="province"]', country: 'vn-supplier-fiscal-data [name="country"]', postcode: 'vn-supplier-fiscal-data [name="postcode"]', city: 'vn-supplier-fiscal-data [name="city"]', socialName: 'vn-supplier-fiscal-data [name="socialName"]', taxNumber: 'vn-supplier-fiscal-data [name="taxNumber"]', account: 'vn-supplier-fiscal-data [name="account"]', sageWithholding: 'vn-supplier-fiscal-data [ng-model="$ctrl.supplier.sageWithholdingFk"]', sageTaxType: 'vn-supplier-fiscal-data [ng-model="$ctrl.supplier.sageTaxTypeFk"]' }; fdescribe('Supplier fiscal data path', () => { let browser; let page; beforeAll(async() => { browser = await getBrowser(); page = browser.page; await page.loginAndModule('administrative', 'supplier'); await page.accessToSearchResult('2'); }); afterAll(async() => { await browser.close(); }); it('should attempt to edit the fiscal data and check data is saved', async() => { await page.accessToSection('supplier.card.fiscalData'); await page.clearInput($inputs.province); await page.clearInput($inputs.country); await page.clearInput($inputs.postcode); await page.overwrite($inputs.city, 'Valencia'); await page.overwrite($inputs.socialName, 'Farmer King SL'); await page.overwrite($inputs.taxNumber, 'Wrong tax number'); await page.overwrite($inputs.account, '0123456789'); await page.autocompleteSearch($inputs.sageWithholding, 'retencion estimacion objetiva'); await page.autocompleteSearch($inputs.sageTaxType, 'operaciones no sujetas'); await page.click($.saveButton); const errorMessage = await page.waitForSnackbar(); await page.overwrite($inputs.taxNumber, '12345678Z'); await page.click($.saveButton); const successMessage = await page.waitForSnackbar(); await page.reloadSection('supplier.card.fiscalData'); const values = await page.getValues($inputs); expect(errorMessage.text).toContain('Invalid Tax number'); expect(successMessage.type).toBe('success'); expect(values).toEqual({ province: 'Province one (España)', country: 'España', postcode: '46000', city: 'Valencia', socialName: 'Farmer King SL', taxNumber: '12345678Z', account: '0123456789', sageWithholding: 'RETENCION ESTIMACION OBJETIVA', sageTaxType: 'Operaciones no sujetas' }); }); });