Skip to content
Merged
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 @@ -176,6 +176,8 @@ const ActivityFeedV2 = ({
onClose: noop,
onSubmit: noop,
},
// Mentions are restricted to file collaborators; the invite popover is intentionally never shown.
fetchCollaboratorState: async () => true,
}),
[],
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ const mockScrollTo = jest.fn<boolean, [string]>(() => true);

type FilterMenuProps = { children?: React.ReactNode; hasActiveFilters?: boolean };
type FilterOptionProps = { checked?: boolean; onCheckedChange?: (checked: boolean) => void };
type RootProps = React.ComponentProps<typeof ActivityFeed.Root>;
let lastFilterMenuProps: FilterMenuProps = {};
let lastShowResolvedOptionProps: FilterOptionProps = {};
let lastMentionMeOptionProps: FilterOptionProps = {};
let lastEditorProps: Partial<EditorProps> = {};
let lastRootProps: Partial<RootProps> = {};
let lastTaskModalProps: Partial<TaskModalV2Props> = {};

jest.mock('../task-modal-v2', () => ({
Expand All @@ -43,9 +45,10 @@ jest.mock('../task-modal-v2', () => ({

jest.mock('@box/activity-feed', () => {
const actual = jest.requireActual('@box/activity-feed');
const ActivityFeedRoot = ({ children }: { children: React.ReactNode }) => (
<div data-testid="activity-feed-root">{children}</div>
);
const ActivityFeedRoot = (props: Partial<RootProps>) => {
lastRootProps = props;
return <div data-testid="activity-feed-root">{props.children}</div>;
};
const ActivityFeedList = ({ children }: { children: React.ReactNode }) => (
<div data-testid="activity-feed-list">{children}</div>
);
Expand Down Expand Up @@ -181,6 +184,7 @@ describe('elements/content-sidebar/activity-feed-v2/ActivityFeedV2', () => {
lastShowResolvedOptionProps = {};
lastMentionMeOptionProps = {};
lastEditorProps = {};
lastRootProps = {};
lastTaskModalProps = {};
mockSerializeMentionMarkup.mockImplementation((doc: unknown) => ({
hasMention: false,
Expand Down Expand Up @@ -401,6 +405,15 @@ describe('elements/content-sidebar/activity-feed-v2/ActivityFeedV2', () => {
expect(lastEditorProps.userSelectorProps?.allowEmptyQuery).toBe(true);
});

test('should report every mentioned user as a collaborator so the invite popover never opens', async () => {
render(<ActivityFeedV2 currentUser={mockCurrentUser} feedItems={[] as ActivityFeedV2Props['feedItems']} />);

const { fetchCollaboratorState } = lastRootProps.mentionContext ?? {};
await expect(fetchCollaboratorState?.({ email: 'a@box.com', id: 1, name: 'A', value: '1' })).resolves.toBe(
true,
);
});

test('should skip the API call when fetchUsers is invoked with an empty query', async () => {
const getMentionAsync = jest.fn().mockResolvedValue([{ id: '1', name: 'foo' }]);
render(
Expand Down
Loading