Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/npm_and_yarn/store2-2.14.4
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Jan 25, 2025
2 parents 1d7e5d3 + 2f0a9ee commit 7f31995
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/api/Feed.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ export const getParsedFileActivitiesResponse = (
}
if (versionsItem.action_type === ACTION_TYPE_PROMOTED && versionsItem.start?.promoted_from) {
versionsItem.version_promoted = versionsItem.start?.promoted_from;
versionsItem.promoted_by = { ...versionsItem.start?.promoted_by };
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/api/__tests__/Feed.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2356,6 +2356,7 @@ describe('api/Feed', () => {

test('should return a parsed entries array when response is valid', () => {
const mockUser = fileActivitiesVersion.start.created_by;
const promotedByUser = promotedFileActivitiesVersion.start.promoted_by;
const promotedFileActivities = {
entries: [
{
Expand All @@ -2376,6 +2377,7 @@ describe('api/Feed', () => {
id: '123',
collaborators: { 42: mockUser },
version_promoted: 2,
promoted_by: promotedByUser,
},
]);
});
Expand Down
12 changes: 12 additions & 0 deletions src/api/fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ export const promotedFileActivitiesVersion = {
uploader_display_name: 'John Doe',
type: 'file_version',
promoted_from: 2,
promoted_by: {
id: '42',
name: 'John Doe',
login: '[email protected]',
type: 'user',
},
},
start: {
created_at: '2022-01-05T10:12:28.000-08:00',
Expand All @@ -160,6 +166,12 @@ export const promotedFileActivitiesVersion = {
uploader_display_name: 'John Doe',
type: 'file_version',
promoted_from: 2,
promoted_by: {
id: '42',
name: 'John Doe',
login: '[email protected]',
type: 'user',
},
},
action_by: [
{
Expand Down
16 changes: 10 additions & 6 deletions src/elements/content-sidebar/activity-feed/task-new/Task.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class Task extends React.Component<Props, State> {

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

const isCreator = created_by.target.id === currentUser.id;
const isCreator = created_by.target?.id === currentUser.id;

const isMultiFile = task_links.entries.length > 1;

Expand Down Expand Up @@ -334,11 +334,15 @@ class Task extends React.Component<Props, State> {
</TetherComponent>
)}
<div className="bcs-Task-headline">
<UserLink
{...createdByUser}
data-resin-target={ACTIVITY_TARGETS.PROFILE}
getUserProfileUrl={getUserProfileUrl}
/>
{createdByUser.name ? (
<UserLink
{...createdByUser}
data-resin-target={ACTIVITY_TARGETS.PROFILE}
getUserProfileUrl={getUserProfileUrl}
/>
) : (
<FormattedMessage {...commonMessages.priorCollaborator} />
)}
</div>
<div>
<ActivityTimestamp date={createdAtTimestamp} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import { mount, shallow } from 'enzyme';
import cloneDeep from 'lodash/cloneDeep';
import { FormattedMessage } from 'react-intl';

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

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

test('should show prior collaborator text if created_by user is a placeholder user', () => {
const completeWrapper = mount(
<Task
{...task}
created_by={placeholderUser}
currentUser={currentUser}
onEdit={jest.fn()}
onDelete={jest.fn()}
due_at={new Date() - 1000}
status="COMPLETED"
/>,
);
const headline = completeWrapper.find('.bcs-Task-headline');
expect(headline.find(FormattedMessage).prop('id')).toBe('be.priorCollaborator');
});

test('due date should have overdue class if task is incomplete and due date is in past', () => {
const incompleteWrapper = mount(
<Task
Expand Down Expand Up @@ -270,10 +288,7 @@ describe('elements/content-sidebar/ActivityFeed/task-new/Task', () => {
test('should call onView when view-task-details button is clicked for multifile task', () => {
const onViewSpy = jest.fn();
const wrapper = mount(<Task {...taskMultifile} currentUser={currentUser} onView={onViewSpy} />);
wrapper
.find('[data-testid="view-task"]')
.hostNodes()
.simulate('click');
wrapper.find('[data-testid="view-task"]').hostNodes().simulate('click');
expect(onViewSpy).toHaveBeenCalledWith(taskId, false);
});

Expand Down

0 comments on commit 7f31995

Please sign in to comment.