salix/e2e/paths/13-supplier/03_fiscal_data.spec.js

112 lines
4.6 KiB
JavaScript
Raw Normal View History

2020-11-04 17:14:08 +00:00
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
describe('Supplier fiscal data path', () => {
2020-11-04 17:14:08 +00:00
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');
2020-12-31 11:25:20 +00:00
await page.waitForTimeout(1000); // must repeat this action twice or fails. also #2699 may be a cool solution to this.
await page.clearInput(selectors.supplierFiscalData.city);
await page.write(selectors.supplierFiscalData.city, 'Valencia');
2020-11-04 17:14:08 +00:00
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);
2022-10-20 06:00:46 +00:00
await page.write(selectors.supplierFiscalData.account, '0123456789');
2020-11-04 17:14:08 +00:00
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');
2022-10-20 06:00:46 +00:00
expect(result).toEqual('0123456789');
2020-11-04 17:14:08 +00:00
});
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');
});
});