From 36d7e514ff23b6f28336b2bb269bc3f1ec5b5d8a Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Mon, 23 Sep 2019 09:27:58 +0200 Subject: [PATCH 1/2] Allow spanish characters on socialName #1712 --- .../client/specs/createWithUser.spec.js | 4 +--- modules/client/back/models/client.js | 24 +++++++++++-------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/modules/client/back/methods/client/specs/createWithUser.spec.js b/modules/client/back/methods/client/specs/createWithUser.spec.js index 2404628e5..1551fb961 100644 --- a/modules/client/back/methods/client/specs/createWithUser.spec.js +++ b/modules/client/back/methods/client/specs/createWithUser.spec.js @@ -1,6 +1,6 @@ const app = require('vn-loopback/server/server'); -describe('Client Create', () => { +fdescribe('Client Create', () => { const clientName = 'Wade'; const AccountName = 'Deadpool'; @@ -39,8 +39,6 @@ describe('Client Create', () => { expect(account.name).toEqual(newAccount.userName); - client = await app.models.Client.findOne({where: {name: newAccount.name}}); - expect(client.id).toEqual(account.id); expect(client.name).toEqual(newAccount.name); expect(client.email).toEqual(newAccount.email); diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index cdff58f34..740066efa 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -152,16 +152,6 @@ module.exports = Self => { done(); } - Self.validateBinded('socialName', isAlpha, { - message: 'The socialName has an invalid format' - }); - - function isAlpha(value) { - const regexp = new RegExp(/^[a-zA-Z\s]*$/); - - return regexp.test(value); - } - Self.validateAsync('postCode', hasValidPostcode, { message: `The postcode doesn't exists. Ensure you put the correct format` }); @@ -177,12 +167,26 @@ module.exports = Self => { done(); } + function isAlpha(value) { + const regexp = new RegExp(/^[ñça-zA-Z\s]*$/); + + return regexp.test(value); + } + Self.observe('before save', async function(ctx) { let changes = ctx.data || ctx.instance; let orgData = ctx.currentInstance; let finalState = getFinalState(ctx); let payMethodWithIban = 4; + // Validate socialName format + const socialNameChanged = orgData && changes + && orgData.socialName != changes.socialName; + + if (socialNameChanged && !isAlpha(changes.socialName)) + throw new UserError('The socialName has an invalid format'); + + if (changes.salesPerson === null) { changes.credit = 0; changes.discount = 0; From a60e31ea136091d2b741abc83106a1b56704ba69 Mon Sep 17 00:00:00 2001 From: Bernat Date: Mon, 23 Sep 2019 09:31:20 +0200 Subject: [PATCH 2/2] delete wait(1999) in e2e --- e2e/paths/07-order-module/01_edit_basic_data.spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/e2e/paths/07-order-module/01_edit_basic_data.spec.js b/e2e/paths/07-order-module/01_edit_basic_data.spec.js index 2b2170aac..4cc04bfa0 100644 --- a/e2e/paths/07-order-module/01_edit_basic_data.spec.js +++ b/e2e/paths/07-order-module/01_edit_basic_data.spec.js @@ -75,7 +75,6 @@ describe('Order edit basic data path', () => { it('should navigate to the basic data section of the new order', async() => { const url = await nightmare - .wait(1999) .accessToSection('order.card.basicData') .wait(selectors.orderBasicData.observationInput) .parsedUrl();