From 840da5e6bc506a72400ca473f7d9b6dd6aee5413 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Wed, 4 Nov 2020 18:14:08 +0100 Subject: [PATCH] e2e path for supplier.fiscalData --- e2e/helpers/selectors.js | 15 +++ .../01_summary_and_descriptor.spec.js | 2 +- e2e/paths/13-supplier/03_fiscal_data.spec.js | 108 ++++++++++++++++++ loopback/locale/en.json | 4 +- 4 files changed, 127 insertions(+), 2 deletions(-) create mode 100644 e2e/paths/13-supplier/03_fiscal_data.spec.js diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 52e359687..02c749b3c 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -923,5 +923,20 @@ export default { thirdContactNotes: 'vn-supplier-contact div:nth-child(3) vn-textfield[ng-model="contact.observation"]', saveButton: 'vn-supplier-contact button[type="submit"]', thirdContactDeleteButton: 'vn-supplier-contact div:nth-child(3) vn-icon-button[icon="delete"]' + }, + supplierBasicData: { + + }, + supplierFiscalData: { + socialName: 'vn-supplier-fiscal-data vn-textfield[ng-model="$ctrl.supplier.name"]', + taxNumber: 'vn-supplier-fiscal-data vn-textfield[ng-model="$ctrl.supplier.nif"]', + account: 'vn-supplier-fiscal-data vn-textfield[ng-model="$ctrl.supplier.account"]', + sageTaxType: 'vn-supplier-fiscal-data vn-autocomplete[ng-model="$ctrl.supplier.sageTaxTypeFk"]', + sageWihholding: 'vn-supplier-fiscal-data vn-autocomplete[ng-model="$ctrl.supplier.sageWithholdingFk"]', + postCode: 'vn-supplier-fiscal-data vn-datalist[ng-model="$ctrl.supplier.postCode"]', + city: 'vn-supplier-fiscal-data vn-datalist[ng-model="$ctrl.supplier.city"]', + province: 'vn-supplier-fiscal-data vn-autocomplete[ng-model="$ctrl.supplier.provinceFk"]', + country: 'vn-supplier-fiscal-data vn-autocomplete[ng-model="$ctrl.supplier.countryFk"]', + saveButton: 'vn-supplier-fiscal-data button[type="submit"]', } }; diff --git a/e2e/paths/13-supplier/01_summary_and_descriptor.spec.js b/e2e/paths/13-supplier/01_summary_and_descriptor.spec.js index 21609fced..591a6116a 100644 --- a/e2e/paths/13-supplier/01_summary_and_descriptor.spec.js +++ b/e2e/paths/13-supplier/01_summary_and_descriptor.spec.js @@ -79,6 +79,6 @@ describe('Supplier summary & descriptor path', () => { }); it(`should check the client button isn't present since this supplier should not be a client`, async() => { - await page.waitForSelector(selectors.supplierDescriptor.clientButton, {hidden: true}); + await page.waitForSelector(selectors.supplierDescriptor.clientButton, {visible: false}); }); }); diff --git a/e2e/paths/13-supplier/03_fiscal_data.spec.js b/e2e/paths/13-supplier/03_fiscal_data.spec.js new file mode 100644 index 000000000..2d1e4fbed --- /dev/null +++ b/e2e/paths/13-supplier/03_fiscal_data.spec.js @@ -0,0 +1,108 @@ +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'); + }); +}); diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 172da6faf..0081af429 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -82,5 +82,7 @@ "landed": "Landed", "addressFk": "Address", "companyFk": "Company", - "You need to fill sage information before you check verified data": "You need to fill sage information before you check verified data" + "You need to fill sage information before you check verified data": "You need to fill sage information before you check verified data", + "The social name cannot be empty": "The social name cannot be empty", + "The nif cannot be empty": "The nif cannot be empty" } \ No newline at end of file