2020-11-04 17:14:08 +00:00
|
|
|
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);
|
2020-12-31 09:30:51 +00:00
|
|
|
await page.write(selectors.supplierFiscalData.taxNumber, 'Wrong tax number');
|
2020-11-04 17:14:08 +00:00
|
|
|
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();
|
|
|
|
|
2020-11-10 11:06:21 +00:00
|
|
|
expect(message.text).toContain('Invalid Tax number');
|
2020-11-04 17:14:08 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
2020-11-10 11:06:21 +00:00
|
|
|
expect(message.text).toContain('Data saved!');
|
2020-11-04 17:14:08 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
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');
|
|
|
|
});
|
|
|
|
});
|