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 @@ -1078,7 +1078,7 @@ describe('elements/content-sharing/SharingModal', () => {
expect(getUsersInEnterprise).toHaveBeenCalledWith(MOCK_ITEM_ID, expect.anything(), expect.anything(), {
filter_term: MOCK_EMAIL,
});
expect(response).resolves.toBeFalsy();
expect(response).resolves.toEqual({});
expect(wrapper.exists(Notification)).toBeFalsy();
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ describe('elements/content-sharing/hooks/useContacts', () => {
{ fields: 'name,permissions', filter_term: MOCK_FILTER },
);
expect(handleError).toHaveBeenCalled();
expect(contacts).resolves.toBeFalsy();
expect(contacts).resolves.toEqual([]);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,9 @@ describe('elements/content-sharing/hooks/useContactsByEmail', () => {
}),
);

result.current({ emails: [MOCK_EMAIL] });

// Wait a short time to ensure handleError is called
let contacts;
await act(async () => {
await new Promise(resolve => setTimeout(resolve, 100));
contacts = await result.current({ emails: [MOCK_EMAIL] });
});

expect(getUsersInEnterprise).toHaveBeenCalledWith(
Expand All @@ -238,6 +236,7 @@ describe('elements/content-sharing/hooks/useContactsByEmail', () => {
{ filter_term: MOCK_EMAIL },
);
expect(handleError).toHaveBeenCalled();
expect(contacts).toEqual({});
});
});
});
10 changes: 8 additions & 2 deletions src/elements/content-sharing/hooks/useContacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,21 @@ function useContacts(api: API, itemID: string, options: ContentSharingHooksOptio
api.getMarkerBasedUsersAPI(false).getUsersInEnterprise(
itemID,
(response: UserCollection) => resolveAPICall(resolve, response, transformUsers),
handleError,
error => {
handleError(error);
resolve([]);
},
{ filter_term: filterTerm },
);
});
const getGroups = new Promise((resolve: (result: Array<GroupMini>) => void) => {
api.getMarkerBasedGroupsAPI(false).getGroupsInEnterprise(
itemID,
(response: GroupCollection) => resolveAPICall(resolve, response, transformGroups),
handleError,
error => {
handleError(error);
resolve([]);
},
{
fields: [FIELD_NAME, FIELD_PERMISSIONS].toString(),
filter_term: filterTerm,
Expand Down
10 changes: 8 additions & 2 deletions src/elements/content-sharing/hooks/useContactsByEmail.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ function useContactsByEmail(
api.getMarkerBasedUsersAPI(false).getUsersInEnterprise(
itemID,
response => resolveAPICall(resolve, response, transformUsers),
handleError,
error => {
handleError(error);
resolve({});
},
{ filter_term: email },
);
});
Expand All @@ -74,7 +77,10 @@ function useContactsByEmail(
api.getMarkerBasedUsersAPI(false).getUsersInEnterprise(
itemID,
(response: UserCollection) => resolveAPICall(resolve, response, transformUsers),
handleError,
error => {
handleError(error);
resolve({});
},
{ filter_term: parsedFilterTerm },
);
});
Expand Down