Skip to content

Commit

Permalink
STSMACOM-858: Display 'Unknown user' when the creator was deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
OleksandrHladchenko1 committed Oct 4, 2024
1 parent 2eb01c2 commit b4721fe
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
2 changes: 2 additions & 0 deletions lib/ControlledVocab/ControlledVocab.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,8 @@ class ControlledVocab extends React.Component {
user = <Link to={`/users/view/${metadata.updatedByUserId}`}>{name}</Link>;
} else if (metadata.updatedByUserId === SYSTEM_USER_ID || !metadata.updatedByUserId) {
user = <FormattedMessage id="stripes-smart-components.system" />;
} else {
user = <FormattedMessage id="stripes-smart-components.unknownUser" />;
}

return (
Expand Down
10 changes: 7 additions & 3 deletions lib/ControlledVocab/tests/ControlledVocab-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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 () {
Expand Down Expand Up @@ -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();
Expand All @@ -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();
});
});
});
10 changes: 10 additions & 0 deletions lib/ControlledVocab/tests/mountComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
1 change: 1 addition & 0 deletions translations/stripes-smart-components/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit b4721fe

Please sign in to comment.