Skip to content

Commit 2f0a9ee

Browse files
authored
fix(uaa-parity): Fix version promotion and deleted user task issues (#3868)
* fix(uaa-parity): Fix version promotion and deleted user task issues * fix(uaa-parity): Fix test
1 parent bb6cdc0 commit 2f0a9ee

File tree

5 files changed

+44
-10
lines changed

5 files changed

+44
-10
lines changed

src/api/Feed.js

+1
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ export const getParsedFileActivitiesResponse = (
253253
}
254254
if (versionsItem.action_type === ACTION_TYPE_PROMOTED && versionsItem.start?.promoted_from) {
255255
versionsItem.version_promoted = versionsItem.start?.promoted_from;
256+
versionsItem.promoted_by = { ...versionsItem.start?.promoted_by };
256257
}
257258
}
258259

src/api/__tests__/Feed.test.js

+2
Original file line numberDiff line numberDiff line change
@@ -2356,6 +2356,7 @@ describe('api/Feed', () => {
23562356

23572357
test('should return a parsed entries array when response is valid', () => {
23582358
const mockUser = fileActivitiesVersion.start.created_by;
2359+
const promotedByUser = promotedFileActivitiesVersion.start.promoted_by;
23592360
const promotedFileActivities = {
23602361
entries: [
23612362
{
@@ -2376,6 +2377,7 @@ describe('api/Feed', () => {
23762377
id: '123',
23772378
collaborators: { 42: mockUser },
23782379
version_promoted: 2,
2380+
promoted_by: promotedByUser,
23792381
},
23802382
]);
23812383
});

src/api/fixtures.js

+12
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@ export const promotedFileActivitiesVersion = {
146146
uploader_display_name: 'John Doe',
147147
type: 'file_version',
148148
promoted_from: 2,
149+
promoted_by: {
150+
id: '42',
151+
name: 'John Doe',
152+
153+
type: 'user',
154+
},
149155
},
150156
start: {
151157
created_at: '2022-01-05T10:12:28.000-08:00',
@@ -160,6 +166,12 @@ export const promotedFileActivitiesVersion = {
160166
uploader_display_name: 'John Doe',
161167
type: 'file_version',
162168
promoted_from: 2,
169+
promoted_by: {
170+
id: '42',
171+
name: 'John Doe',
172+
173+
type: 'user',
174+
},
163175
},
164176
action_by: [
165177
{

src/elements/content-sidebar/activity-feed/task-new/Task.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ class Task extends React.Component<Props, State> {
241241

242242
const isTaskCompleted = !(status === TASK_NEW_NOT_STARTED || status === TASK_NEW_IN_PROGRESS);
243243

244-
const isCreator = created_by.target.id === currentUser.id;
244+
const isCreator = created_by.target?.id === currentUser.id;
245245

246246
const isMultiFile = task_links.entries.length > 1;
247247

@@ -334,11 +334,15 @@ class Task extends React.Component<Props, State> {
334334
</TetherComponent>
335335
)}
336336
<div className="bcs-Task-headline">
337-
<UserLink
338-
{...createdByUser}
339-
data-resin-target={ACTIVITY_TARGETS.PROFILE}
340-
getUserProfileUrl={getUserProfileUrl}
341-
/>
337+
{createdByUser.name ? (
338+
<UserLink
339+
{...createdByUser}
340+
data-resin-target={ACTIVITY_TARGETS.PROFILE}
341+
getUserProfileUrl={getUserProfileUrl}
342+
/>
343+
) : (
344+
<FormattedMessage {...commonMessages.priorCollaborator} />
345+
)}
342346
</div>
343347
<div>
344348
<ActivityTimestamp date={createdAtTimestamp} />

src/elements/content-sidebar/activity-feed/task-new/__tests__/Task.test.js

+19-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as React from 'react';
22
import { mount, shallow } from 'enzyme';
33
import cloneDeep from 'lodash/cloneDeep';
4+
import { FormattedMessage } from 'react-intl';
45

56
import { FEED_ITEM_TYPE_TASK } from '../../../../../constants';
67
import { TaskComponent as Task } from '..';
@@ -18,6 +19,7 @@ const allHandlers = {
1819
const approverSelectorContacts = [];
1920

2021
describe('elements/content-sidebar/ActivityFeed/task-new/Task', () => {
22+
const placeholderUser = { nam: '', id: '0', type: 'user' };
2123
const currentUser = { name: 'Jake Thomas', id: '1', type: 'user' };
2224
const otherUser = { name: 'Patrick Paul', id: '3', type: 'user' };
2325
const creatorUser = { name: 'Steven Yang', id: '5', type: 'user' };
@@ -144,6 +146,22 @@ describe('elements/content-sidebar/ActivityFeed/task-new/Task', () => {
144146
expect(wrapper.find('[data-testid="task-due-date"]')).toHaveLength(1);
145147
});
146148

149+
test('should show prior collaborator text if created_by user is a placeholder user', () => {
150+
const completeWrapper = mount(
151+
<Task
152+
{...task}
153+
created_by={placeholderUser}
154+
currentUser={currentUser}
155+
onEdit={jest.fn()}
156+
onDelete={jest.fn()}
157+
due_at={new Date() - 1000}
158+
status="COMPLETED"
159+
/>,
160+
);
161+
const headline = completeWrapper.find('.bcs-Task-headline');
162+
expect(headline.find(FormattedMessage).prop('id')).toBe('be.priorCollaborator');
163+
});
164+
147165
test('due date should have overdue class if task is incomplete and due date is in past', () => {
148166
const incompleteWrapper = mount(
149167
<Task
@@ -270,10 +288,7 @@ describe('elements/content-sidebar/ActivityFeed/task-new/Task', () => {
270288
test('should call onView when view-task-details button is clicked for multifile task', () => {
271289
const onViewSpy = jest.fn();
272290
const wrapper = mount(<Task {...taskMultifile} currentUser={currentUser} onView={onViewSpy} />);
273-
wrapper
274-
.find('[data-testid="view-task"]')
275-
.hostNodes()
276-
.simulate('click');
291+
wrapper.find('[data-testid="view-task"]').hostNodes().simulate('click');
277292
expect(onViewSpy).toHaveBeenCalledWith(taskId, false);
278293
});
279294

0 commit comments

Comments
 (0)