From e023a0020a7380c71dbf510559fee51ea52d2bea Mon Sep 17 00:00:00 2001 From: Joan Gallego Girona Date: Thu, 21 Nov 2024 21:19:31 +0100 Subject: [PATCH 1/2] Entity getPropertyValue now returns default value (#7467) in case of text fields we are now returning an empty string when the field has no value at all --- app/api/entities.v2/model/Entity.ts | 2 +- .../utils/specs/ATSolveVersionConflict.spec.ts | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/api/entities.v2/model/Entity.ts b/app/api/entities.v2/model/Entity.ts index 30ac8bd1e1..98475c8236 100644 --- a/app/api/entities.v2/model/Entity.ts +++ b/app/api/entities.v2/model/Entity.ts @@ -82,7 +82,7 @@ export class Entity { if (property.type === 'text' || property.type === 'markdown') { const isTitleProperty = property instanceof CommonProperty && property.name === 'title'; if (isTitleProperty) return this.title; - return this.metadata[property.name]?.[0]?.value as string; + return (this.metadata[property.name]?.[0]?.value as string) || ''; } throw new Error('types other than string/markdown are not implemented yet'); diff --git a/app/api/externalIntegrations.v2/automaticTranslation/utils/specs/ATSolveVersionConflict.spec.ts b/app/api/externalIntegrations.v2/automaticTranslation/utils/specs/ATSolveVersionConflict.spec.ts index 3947124585..fedec8ce6c 100644 --- a/app/api/externalIntegrations.v2/automaticTranslation/utils/specs/ATSolveVersionConflict.spec.ts +++ b/app/api/externalIntegrations.v2/automaticTranslation/utils/specs/ATSolveVersionConflict.spec.ts @@ -100,5 +100,18 @@ describe('ATSolveVersionConflict', () => { }, }); }); + + it('should not fail if the props have no value', async () => { + const currentEntity = factory.entity('current entity', 'template', { prop1: [] }); + const newEntity = factory.entity('new entity', 'template', { + prop1: [], + prop2: [{ value: 'prop2' }], + }); + + await expect(ATSolveVersionConflict(currentEntity, newEntity)).resolves.toMatchObject({ + title: 'new entity', + metadata: { prop1: [], prop2: [{ value: 'prop2' }] }, + }); + }); }); }); From 6f44268271b6cdca432ad621cf6fa41f8af05bbe Mon Sep 17 00:00:00 2001 From: Daneryl Date: Thu, 21 Nov 2024 21:19:37 +0100 Subject: [PATCH 2/2] Bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7dc9640e62..ccde6f69aa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "uwazi", - "version": "1.191.5", + "version": "1.191.6", "description": "Uwazi is a free, open-source solution for organising, analysing and publishing your documents.", "keywords": [ "react"