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(); 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;