From 247d0f0157f3d92b555179085e4ba6dc4ee103e8 Mon Sep 17 00:00:00 2001 From: Eric Wamugu Date: Tue, 25 Aug 2020 16:19:47 +0200 Subject: [PATCH 1/3] change the relationship object passed to EntityViewer component from the one passed as prop to the one that is attached to the entity object --- app/react/Entities/components/EntityViewer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/react/Entities/components/EntityViewer.js b/app/react/Entities/components/EntityViewer.js index 5c28cb04ee..9d56516153 100644 --- a/app/react/Entities/components/EntityViewer.js +++ b/app/react/Entities/components/EntityViewer.js @@ -131,7 +131,7 @@ export class EntityViewer extends Component { return (
Date: Tue, 25 Aug 2020 16:30:58 +0200 Subject: [PATCH 2/3] the relationship object passed as a prop to the EntityViewer component was wrongly named --- app/react/Entities/components/EntityViewer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/react/Entities/components/EntityViewer.js b/app/react/Entities/components/EntityViewer.js index 9d56516153..dc64dea408 100644 --- a/app/react/Entities/components/EntityViewer.js +++ b/app/react/Entities/components/EntityViewer.js @@ -131,7 +131,7 @@ export class EntityViewer extends Component { return (
({ entity: state.entityView.entity, relationTypes: selectRelationTypes(state), templates: state.templates, - relationships: state.entityView.entity.get('relationships'), + relationships: state.entityView.entity.get('relations'), connectionsGroups: state.relationships.list.connectionsGroups, entityBeingEdited: !!state.entityView.entityForm._id, tab: state.entityView.uiState.get('tab'), From ccafcaa5329fe3caa17f30241cc81fbd7a2795b1 Mon Sep 17 00:00:00 2001 From: Eric Wamugu Date: Wed, 26 Aug 2020 23:34:05 +0200 Subject: [PATCH 3/3] add test for the inherited properties of an entity which are passed via props as relationships to the ShowMetadata component --- .../components/specs/EntityViewer.spec.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/app/react/Entities/components/specs/EntityViewer.spec.js b/app/react/Entities/components/specs/EntityViewer.spec.js index fbc8b89507..d141738e87 100644 --- a/app/react/Entities/components/specs/EntityViewer.spec.js +++ b/app/react/Entities/components/specs/EntityViewer.spec.js @@ -2,6 +2,7 @@ import Immutable from 'immutable'; import React from 'react'; import { ConnectionsGroups, ConnectionsList } from 'app/ConnectionsList'; +import { ShowMetadata } from 'app/Metadata'; import { shallow } from 'enzyme'; import { FileList } from 'app/Attachments/components/FileList'; import { EntityViewer } from '../EntityViewer'; @@ -15,7 +16,11 @@ describe('EntityViewer', () => { beforeEach(() => { context = { confirm: jasmine.createSpy('confirm') }; props = { - entity: Immutable.fromJS({ title: 'Title', documents: [{ _id: '123', title: 'Test doc' }] }), + entity: Immutable.fromJS({ + title: 'Title', + documents: [{ _id: '123', title: 'Test doc' }], + relations: [{ template: null, entity: '123', hub: 'abc' }], + }), templates: Immutable.fromJS([ { _id: 'template1', @@ -28,6 +33,7 @@ describe('EntityViewer', () => { name: 'template2Name', }, ]), + relationships: Immutable.fromJS([{ template: null, entity: '123', hub: 'abc' }]), relationTypes: [{ _id: 'abc', name: 'relationTypeName' }], connectionsGroups: Immutable.fromJS([ { key: 'g1', templates: [{ _id: 't1', count: 1 }] }, @@ -73,6 +79,17 @@ describe('EntityViewer', () => { expect(component.find(FileList).props().entity).toEqual(props.entity.toJS()); }); + it('should render the inherited properties of an entity', () => { + render(); + expect(component.find(ShowMetadata).props().relationships.size).toBe(1); + expect( + component + .find(ShowMetadata) + .props() + .relationships.toJS() + ).toEqual(props.entity.toJS().relations); + }); + describe('deleteConnection', () => { beforeEach(() => { render();