Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ const ActivityFeedV2 = ({
);

return (
<div className="bcs-NewActivityFeed" data-resin-feature="activityfeedv2">
<div className="bcs-NewActivityFeed" data-resin-feature="activityfeedv2" data-resin-fileid={file?.id}>
<ActivityFeed.Root mentionContext={mentionContext} scrollTo={scrollHandle}>
<ActivityFeed.Header title={headerTitle}>
<ActivityFeed.Header.Actions>
Expand Down Expand Up @@ -532,6 +532,7 @@ const ActivityFeedV2 = ({
error={taskError}
fetchAvatarUrls={fetchAvatarUrls}
fetchUsers={fetchApprovers}
fileId={file?.id}
isOpen={isTaskFormOpen}
mode="edit"
onClose={handleTaskModalClose}
Expand All @@ -545,6 +546,7 @@ const ActivityFeedV2 = ({
error={taskError}
fetchAvatarUrls={fetchAvatarUrls}
fetchUsers={fetchApprovers}
fileId={file?.id}
isOpen={isTaskFormOpen}
onClose={handleTaskModalClose}
onSubmitError={setTaskError}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,19 @@ describe('elements/content-sidebar/activity-feed-v2/ActivityFeedV2', () => {
expect(screen.getByTestId('activity-feed-editor')).toBeVisible();
});

test('should tag the feed wrapper with resin feature and fileid', () => {
const { container } = render(
<ActivityFeedV2
currentUser={mockCurrentUser}
feedItems={[] as ActivityFeedV2Props['feedItems']}
file={{ id: '12345' }}
/>,
);

expect(container.firstChild).toHaveAttribute('data-resin-feature', 'activityfeedv2');
expect(container.firstChild).toHaveAttribute('data-resin-fileid', '12345');
});

test('should not render the list when feedItems is undefined', () => {
render(<ActivityFeedV2 currentUser={mockCurrentUser} />);
expect(screen.queryByTestId('activity-feed-list')).not.toBeInTheDocument();
Expand Down Expand Up @@ -1213,9 +1226,10 @@ describe('elements/content-sidebar/activity-feed-v2/ActivityFeedV2', () => {
};

test('should forward create-mode props to TaskModalV2', () => {
renderFeed({ createTask: jest.fn(), onTaskUpdate: jest.fn() });
renderFeed({ createTask: jest.fn(), file: { id: '12345' }, onTaskUpdate: jest.fn() });
expect(lastTaskModalProps.mode).toBeUndefined();
expect(lastTaskModalProps.editingTask).toBeUndefined();
expect(lastTaskModalProps.fileId).toBe('12345');
expect(lastTaskModalProps.taskType).toBe('APPROVAL');
expect(lastTaskModalProps.isOpen).toBe(false);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { TASK_COMPLETION_RULE_ALL, TASK_COMPLETION_RULE_ANY, TASK_EDIT_MODE_EDIT

import type { TaskCompletionRule, TaskEditMode, TaskType } from '../../../../common/types/tasks';

import { ACTIVITY_TARGETS } from '../../../common/interactionTargets';

import { mapAssigneeToUserContact, mapUserContactToAssignee } from './utils/contactMapping';
import type { TaskAssignee, TaskFormV2SubmitPayload } from './types';

Expand Down Expand Up @@ -199,6 +201,7 @@ const TaskFormV2 = ({
<DatePicker
calendarAriaLabel={formatMessage(messages.datePickerCalendarAriaLabel)}
clearDatePickerAriaLabel={formatMessage(messages.datePickerClearAriaLabel)}
data-resin-target={ACTIVITY_TARGETS.TASK_DATE_PICKER}
dataTargetId="TaskFormV2-dueDateInput"
isDisabled={isDisabled}
label={formatMessage(messages.dueDateLabel)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type SharedProps = {
error?: ElementsXhrError;
fetchAvatarUrls: (contacts: UserContactType[]) => Promise<FetchedAvatarUrls>;
fetchUsers: (query: string) => Promise<UserContactType[]>;
fileId?: string;
isOpen: boolean;
onClose: () => void;
onSubmitError: (error: ElementsXhrError) => void;
Expand Down Expand Up @@ -89,6 +90,7 @@ const TaskModalV2 = ({
error,
fetchAvatarUrls,
fetchUsers,
fileId,
isOpen,
onClose,
onSubmitError,
Expand Down Expand Up @@ -174,6 +176,8 @@ const TaskModalV2 = ({
<Modal.Content
className="bcs-NewTaskModal"
data-resin-component="taskmodalv2"
data-resin-feature="activityfeedv2"
data-resin-fileid={fileId}
data-testid="task-modal-v2"
size="medium"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ jest.mock('@box/user-selector', () => ({
},
}));

type DatePickerMockProps = { label: React.ReactNode; value?: unknown; minValue?: unknown };
type DatePickerMockProps = {
'data-resin-target'?: string;
label: React.ReactNode;
minValue?: unknown;
value?: unknown;
};

let lastDatePickerProps: DatePickerMockProps = { label: null };

Expand Down Expand Up @@ -242,6 +247,11 @@ describe('elements/content-sidebar/activity-feed-v2/task-modal-v2/TaskFormV2', (
expect(lastDatePickerProps.minValue).toBeDefined();
});

test('tags the DatePicker with the task datepicker resin target', () => {
renderForm();
expect(lastDatePickerProps['data-resin-target']).toBe('activityfeed-taskdatepicker');
});

test('omits the DatePicker minValue when editing a task whose due date is already in the past', () => {
const pastDate = new Date();
pastDate.setDate(pastDate.getDate() - 7);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ type RenderModalOptions = {
editingAssignees?: TaskAssignee[];
editingTask?: TaskNew | null;
error?: ElementsXhrError;
fileId?: string;
isOpen?: boolean;
taskType?: TaskNew['task_type'];
};
Expand Down Expand Up @@ -309,9 +310,12 @@ describe('elements/content-sidebar/activity-feed-v2/task-modal-v2/TaskModalV2',
expect(screen.getByRole('button', { name: /cancel/i })).toBeDisabled();
});

test('tags the modal content with data-resin-component=taskmodalv2', () => {
renderModal();
expect(screen.getByTestId('task-modal-v2')).toHaveAttribute('data-resin-component', 'taskmodalv2');
test('tags the modal content with resin component, feature, and fileid', () => {
renderModal({ fileId: '12345' });
const modalContent = screen.getByTestId('task-modal-v2');
expect(modalContent).toHaveAttribute('data-resin-component', 'taskmodalv2');
expect(modalContent).toHaveAttribute('data-resin-feature', 'activityfeedv2');
expect(modalContent).toHaveAttribute('data-resin-fileid', '12345');
});

test('tags the Cancel and Create buttons with data-resin-target and data-target-id', () => {
Expand Down
1 change: 1 addition & 0 deletions src/elements/content-sidebar/activity-feed-v2/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export type TransformedFeedItem =
export type ActivityFeedV2File = {
extension?: string;
file_version?: { id: string };
id?: string;
};

export type ViewerHandle = {
Expand Down
Loading