From b4721fe6fb6350b4193eda22f1536a0dd0d06189 Mon Sep 17 00:00:00 2001 From: Oleksandr Hladchenko1 Date: Fri, 4 Oct 2024 15:04:54 +0200 Subject: [PATCH] STSMACOM-858: Display 'Unknown user' when the creator was deleted --- lib/ControlledVocab/ControlledVocab.js | 2 ++ lib/ControlledVocab/tests/ControlledVocab-test.js | 10 +++++++--- lib/ControlledVocab/tests/mountComponent.js | 10 ++++++++++ translations/stripes-smart-components/en.json | 1 + 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/lib/ControlledVocab/ControlledVocab.js b/lib/ControlledVocab/ControlledVocab.js index 9aa65a413..98bde5ef0 100644 --- a/lib/ControlledVocab/ControlledVocab.js +++ b/lib/ControlledVocab/ControlledVocab.js @@ -478,6 +478,8 @@ class ControlledVocab extends React.Component { user = {name}; } else if (metadata.updatedByUserId === SYSTEM_USER_ID || !metadata.updatedByUserId) { user = ; + } else { + user = ; } return ( diff --git a/lib/ControlledVocab/tests/ControlledVocab-test.js b/lib/ControlledVocab/tests/ControlledVocab-test.js index ddb7cae11..4d69f328c 100644 --- a/lib/ControlledVocab/tests/ControlledVocab-test.js +++ b/lib/ControlledVocab/tests/ControlledVocab-test.js @@ -46,7 +46,7 @@ describe('ControlledVocab', () => { // eslint-disable-next-line no-undef beforeEach(() => mountComponent(true, server, { translations })); - it('should have row count 7', () => cv.has({ rowCount: 7 })); + it('should have row count 8', () => cv.has({ rowCount: 8 })); describe('clicking Delete icon on first row', () => { beforeEach(async () => { @@ -79,7 +79,7 @@ describe('ControlledVocab', () => { // eslint-disable-next-line no-undef beforeEach(() => mountComponent(true, server, { labelSingular })); - it('should have row count 7', () => cv.has({ rowCount: 7 })); + it('should have row count 8', () => cv.has({ rowCount: 8 })); describe('clicking Delete icon on first row', () => { beforeEach(async function () { @@ -268,7 +268,7 @@ describe('ControlledVocab', () => { await mountComponent(false, server, { listSuppressor }); }); - it('should have row count 7', () => cv.has({ rowCount: 7 })); + it('should have row count 8', () => cv.has({ rowCount: 8 })); it('should render the row with last updated by user-1 without user firstname or lastname', async () => { await mcl.find(MultiColumnListCell({ row: 4, columnIndex: 3, content: '4/18/2019 by ' })).exists(); @@ -281,5 +281,9 @@ describe('ControlledVocab', () => { it('should render the row with last updated by system without data about user', async () => { await mcl.find(MultiColumnListCell({ row: 7, columnIndex: 3, content: '1/9/2024 by System' })).exists(); }); + + it('should render the row with last updated by unknown user when user was deleted', async () => { + await mcl.find(MultiColumnListCell({ row: 8, columnIndex: 3, content: '1/9/2024 by Unknown user' })).exists(); + }); }); }); diff --git a/lib/ControlledVocab/tests/mountComponent.js b/lib/ControlledVocab/tests/mountComponent.js index f3a894939..b3581d700 100644 --- a/lib/ControlledVocab/tests/mountComponent.js +++ b/lib/ControlledVocab/tests/mountComponent.js @@ -77,6 +77,16 @@ export default async function (editable, server, props) { 'createdDate' : '2024-01-09T01:49:57.008+00:00', 'updatedDate' : '2024-01-09T01:49:57.008+00:00', } + }, { + 'id' : '40ee00ca-a518-4b49-be01-0638d0a4ac02', + 'name' : 'Københavns Universitet', + 'code' : 'KU', + 'metadata' : { + 'createdDate' : '2024-01-09T01:49:57.008+00:00', + 'createdByUserId' : 'unknown-id', + 'updatedDate' : '2024-01-09T01:49:57.008+00:00', + 'updatedByUserId' : 'unknown-id', + } }]; server.get('location-units/institutions', (schema, request) => { diff --git a/translations/stripes-smart-components/en.json b/translations/stripes-smart-components/en.json index e662ccadf..1b8db55c5 100644 --- a/translations/stripes-smart-components/en.json +++ b/translations/stripes-smart-components/en.json @@ -130,6 +130,7 @@ "address.alternate": "Alternate", "searchFieldLabel": "Search {moduleName}", "system": "System", + "unknownUser": "Unknown user", "assignUnassign": "Assign / Unassign", "notes": "Notes", "notes.notFound": "No notes found",