import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; 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'); await page.accessToSection('supplier.card.fiscalData'); }); afterAll(async() => { await browser.close(); }); it('should attempt to edit the fiscal data but fail as the tax number is invalid', async() => { await page.clearInput(selectors.supplierFiscalData.city); await page.clearInput(selectors.supplierFiscalData.province); await page.clearInput(selectors.supplierFiscalData.country); await page.clearInput(selectors.supplierFiscalData.postCode); await page.write(selectors.supplierFiscalData.city, 'Valencia'); await page.clearInput(selectors.supplierFiscalData.socialName); await page.write(selectors.supplierFiscalData.socialName, 'Farmer King SL'); await page.clearInput(selectors.supplierFiscalData.taxNumber); await page.write(selectors.supplierFiscalData.taxNumber, 'invalid tax number'); await page.clearInput(selectors.supplierFiscalData.account); await page.write(selectors.supplierFiscalData.account, 'edited account number'); await page.autocompleteSearch(selectors.supplierFiscalData.sageWihholding, 'retencion estimacion objetiva'); await page.autocompleteSearch(selectors.supplierFiscalData.sageTaxType, 'operaciones no sujetas'); await page.waitToClick(selectors.supplierFiscalData.saveButton); const message = await page.waitForSnackbar(); expect(message.text).toBe('Invalid Tax number'); }); it('should save the changes as the tax number is valid this time', async() => { await page.clearInput(selectors.supplierFiscalData.taxNumber); await page.write(selectors.supplierFiscalData.taxNumber, '12345678Z'); await page.waitToClick(selectors.supplierFiscalData.saveButton); const message = await page.waitForSnackbar(); expect(message.text).toBe('Data saved!'); }); it('should reload the section', async() => { await page.reloadSection('supplier.card.fiscalData'); }); it('should check the socialName was edited', async() => { const result = await page.waitToGetProperty(selectors.supplierFiscalData.socialName, 'value'); expect(result).toEqual('Farmer King SL'); }); it('should check the taxNumber was edited', async() => { const result = await page.waitToGetProperty(selectors.supplierFiscalData.taxNumber, 'value'); expect(result).toEqual('12345678Z'); }); it('should check the account was edited', async() => { const result = await page.waitToGetProperty(selectors.supplierFiscalData.account, 'value'); expect(result).toEqual('edited account number'); }); it('should check the sageWihholding was edited', async() => { const result = await page.waitToGetProperty(selectors.supplierFiscalData.sageWihholding, 'value'); expect(result).toEqual('RETENCION ESTIMACION OBJETIVA'); }); it('should check the sageTaxType was edited', async() => { const result = await page.waitToGetProperty(selectors.supplierFiscalData.sageTaxType, 'value'); expect(result).toEqual('Operaciones no sujetas'); }); it('should check the postCode was edited', async() => { const result = await page.waitToGetProperty(selectors.supplierFiscalData.postCode, 'value'); expect(result).toEqual('46000'); }); it('should check the city was edited', async() => { const result = await page.waitToGetProperty(selectors.supplierFiscalData.city, 'value'); expect(result).toEqual('Valencia'); }); it('should check the province was edited', async() => { const result = await page.waitToGetProperty(selectors.supplierFiscalData.province, 'value'); expect(result).toEqual('Province one (España)'); }); it('should check the country was edited', async() => { const result = await page.waitToGetProperty(selectors.supplierFiscalData.country, 'value'); expect(result).toEqual('España'); }); });