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"]' }; describe('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'); const form = 'vn-supplier-fiscal-data form'; const values = { province: null, country: null, postcode: null, city: 'Valencia', socialName: 'Farmer King SL', taxNumber: 'Wrong tax number', account: '0123456789', sageWithholding: 'retencion estimacion objetiva', sageTaxType: 'operaciones no sujetas' }; const errorMessage = await page.sendForm(form, values); const message = await page.sendForm(form, { taxNumber: '12345678Z' }); await page.reloadSection('supplier.card.fiscalData'); const formValues = await page.fetchForm(form, Object.keys(values)); expect(errorMessage.text).toContain('Invalid Tax number'); expect(message.isSuccess).toBeTrue(); expect(formValues).toEqual({ province: 'Province one', country: 'EspaƱa', postcode: '46000', city: 'Valencia', socialName: 'Farmer King SL', taxNumber: '12345678Z', account: '0123456789', sageWithholding: 'RETENCION ESTIMACION OBJETIVA', sageTaxType: 'Operaciones no sujetas' }); }); });