Skip to content

Conversation

@reneshen0328
Copy link
Contributor

@reneshen0328 reneshen0328 commented Oct 22, 2025

What

  • When the suggested collab dropdown is rendered, the avatar associated to the user should render as well (This functionality is currently not working in ContentSharingV1, but added here in V2 since it should be implemented)
  • Update all variable names to change from API to Api, ID to Id, etc.

Testing

Screenshot 2025-10-22 at 10 10 42 AM

Summary by CodeRabbit

  • New Features

    • Added a contact-avatar retrieval method to the contact service to fetch avatar URLs for contact lists.
  • Chores

    • Wide renaming and naming-consistency updates across the Content Sharing module and its stories/tests to align identifiers and mocks; no user-facing behavior changes.

@reneshen0328 reneshen0328 requested review from a team as code owners October 22, 2025 06:45
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 22, 2025

Walkthrough

A consistent naming refactor across the content-sharing module: itemIDitemId, avatarURLMapavatarUrlMap, API/mock factory names from PascalCase → camelCase, plus a new getContactsAvatarUrls method added to the contact service hook.

Changes

Cohort / File(s) Summary
Main Components
src/elements/content-sharing/ContentSharing.js, src/elements/content-sharing/ContentSharingV2.tsx
Rename prop itemIDitemId; rename state avatarURLMapavatarUrlMap and setter accordingly; update all internal API calls, effects, and prop propagation.
API Modules
src/elements/content-sharing/apis/*
src/elements/content-sharing/apis/fetchAvatars.ts, .../fetchCollaborators.ts, .../fetchCurrentUser.ts, .../fetchItem.ts
Rename function parameters itemIDitemId; rename local API variables (e.g., usersAPIusersApi, collabAPIInstancecollabApiInstance); adjust return type on fetchCollaborators to include null path and add final return null in fetchItem.
Hook Modules
src/elements/content-sharing/hooks/useContactService.ts, src/elements/content-sharing/hooks/useSharingService.ts
Rename parameter avatarURLMapavatarUrlMap in useSharingService; add getContactsAvatarUrls to useContactService (memoized async function that builds collaborators from contacts and calls fetchAvatars).
Utilities / Converters
src/elements/content-sharing/utils/convertCollaborators.ts, src/elements/content-sharing/utils/convertItemResponse.ts
Rename parameters/properties: avatarURLMapavatarUrlMap, collabsAPIDatacollabsApiData, itemAPIDataitemApiData; update function signatures and internal uses.
Mocks & Mock Utilities
src/elements/content-sharing/utils/__mocks__/ContentSharingV2Mocks.js, src/elements/content-sharing/apis/__tests__/testUtils.ts
Rename mock constants and factories to camelCase (mockAvatarURLMapmockAvatarUrlMap, createMockAPIcreateMockApi, createItemAPIMockcreateItemApiMock, etc.) and update returned getter names to match.
Tests (component & API)
src/elements/content-sharing/__tests__/ContentSharingV2.test.tsx, src/elements/content-sharing/apis/__tests__/*
Update test imports, mock factory names and variables (createAPIMockcreateApiMock, defaultAPIMockdefaultApiMock), and replace itemID usages with itemId; add tests for getContactsAvatarUrls and mocks for fetchAvatars.
Hook Tests
src/elements/content-sharing/hooks/__tests__/useContactService.test.ts, .../useSharingService.test.ts
Add fetchAvatars mock and tests for getContactsAvatarUrls; rename avatarURLMapavatarUrlMap in test fixtures and expectations.
Stories / Visual tests
src/elements/content-sharing/stories/*, src/elements/content-sharing/stories/tests/*
Rename story args and mock imports from mockAPI...mockApi...; change story default args.itemIDargs.itemId.
Convert tests
src/elements/content-sharing/utils/__tests__/convertCollaborators.test.ts
Rename test data and mocks: avatarURLMapavatarUrlMap, ownerFromAPIownerFromApi, mockCollaborationsFromAPImockCollaborationsFromApi; update all invocations and expectations.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant UI as ContentSharingV2
    participant ContactHook as useContactService
    participant AvatarsAPI as fetchAvatars
    participant SharingHook as useSharingService

    rect rgb(235,245,255)
    Note right of UI: On mount / contacts update
    UI->>ContactHook: getContactsAvatarUrls(contacts, itemId)
    end

    rect rgb(245,255,235)
    ContactHook->>AvatarsAPI: fetchAvatars({ api, itemId, collaborators })
    AvatarsAPI-->>ContactHook: avatarUrlMap
    ContactHook-->>UI: avatarUrlMap
    end

    rect rgb(255,250,230)
    Note right of UI: UI passes avatarUrlMap to sharing logic
    UI->>SharingHook: useSharingService({ avatarUrlMap, ... })
    SharingHook-->>UI: sharingService (uses avatarUrlMap in convertCollab)
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

ready-to-merge

Suggested reviewers

  • jfox-box
  • tjuanitas
  • jpan-box

Poem

🐰 From itemID to itemId I hop with glee,
Camel-case rivers flow through each tree.
Avatars tucked in urlMap so bright,
Mocks made small and names set right.
A new helper fetches faces—hooray for clarity! 🎉

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title Check ⚠️ Warning The title "Create contact service getContactsAvatarUrls" accurately refers to one specific new method added to the useContactService hook, which is a real component of the changeset. However, the predominant changes throughout this pull request are extensive refactoring efforts to rename parameters and variables for naming consistency (itemID → itemId, avatarURLMap → avatarUrlMap, and similar changes across API mocks and utility functions in 15+ files). The title focuses narrowly on a single new method rather than capturing the scope and primary nature of the refactoring effort, making it partially related to the changeset but not representative of the main point of the changes.
✅ Passed checks (2 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
Description Check ✅ Passed The PR description provides a "What" section that clearly explains the two main objectives: enabling avatar rendering in the suggested collaborator dropdown and updating variable naming conventions throughout the codebase (API to Api, ID to Id, etc.). A "Testing" section is included with a screenshot demonstrating the implemented functionality. However, the provided description_template appears to be solely merge process guidance (regarding the ready-to-merge label and reviewer handling) rather than a template defining required PR description sections or structure. The PR description exceeds the minimal template provided by including substantive change information and testing evidence, though it could benefit from more detailed context about why these changes were made or how the new avatar functionality works.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch create-contact-service-getContactsAvatarUrls

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/elements/content-sharing/utils/convertCollaborators.ts (1)

9-15: Type-safety: ownerEmailDomain can be null; widen its type.

convertCollabsResponse computes ownerEmailDomain as string | null, but ConvertCollabProps requires string. Widen to avoid latent type errors.

 export interface ConvertCollabProps {
   collab: Collaboration;
   currentUserId: string;
   isCurrentUserOwner: boolean;
-  ownerEmailDomain: string;
+  ownerEmailDomain: string | null;
   avatarUrlMap?: AvatarURLMap;
 }
…
-export const convertCollabsResponse = (
-    collabsApiData: Collaborations,
+export const convertCollabsResponse = (
+    collabsApiData: Collaborations,
     currentUserId: string,
     owner: { id: string; email: string; name: string },
     avatarUrlMap?: AvatarURLMap,
 ): Collaborator[] => {
-    const { entries = [] } = collabsApiData;
+    const { entries = [] } = collabsApiData;

Also applies to: 17-23, 54-61, 78-82

♻️ Duplicate comments (1)
src/elements/content-sharing/hooks/__tests__/useContactService.test.ts (1)

114-152: Optional: if you adopt user-only filtering, update this test accordingly.

Should you filter out non-user contacts, adjust the expected collaborators array to include only the user entry.

🧹 Nitpick comments (12)
src/elements/content-sharing/utils/convertItemResponse.ts (1)

8-21: Defensive destructuring to avoid runtime error if shared_link_features is absent.

If shared_link_features is undefined, destructuring throws. Use nullish coalescing.

-    const { password: isPasswordAvailable } = shared_link_features;
+    const { password: isPasswordAvailable } = shared_link_features ?? {};

Minor readability (optional):

-    const isEditAllowed = allowed_invitee_roles.indexOf(INVITEE_ROLE_EDITOR) !== -1;
+    const isEditAllowed = allowed_invitee_roles.includes(INVITEE_ROLE_EDITOR);
src/elements/content-sharing/apis/fetchItem.ts (1)

8-21: LGTM; small optional refactor to reduce duplication.

Logic and types look good. Optionally, collapse the two branches with a switch for readability; behavior unchanged.

src/elements/content-sharing/apis/fetchCurrentUser.ts (1)

7-13: Use join(',') for better readability; apply to both source and test files.

The suggestion is valid. Both .toString() and .join(',') produce identical results for arrays, but .join(',') is more explicit and idiomatic for creating comma-separated strings. The same pattern exists in the test file at src/elements/content-sharing/apis/__tests__/fetchCurrentUser.test.ts:20, which should also be updated for consistency.

Apply the refactor to both files:

  • src/elements/content-sharing/apis/fetchCurrentUser.ts:11
  • src/elements/content-sharing/apis/__tests__/fetchCurrentUser.test.ts:20
src/elements/content-sharing/apis/__tests__/fetchItem.test.ts (2)

41-49: Consider adding a folder-error path test.

You cover file error; mirroring one for folders would catch regressions in getFolderFields rejection handling.


5-5: Speed up tests by removing artificial delay in createSuccessMock.

The helper currently waits 500ms; this slows the suite. Recommend resolving immediately (or using fake timers) to keep tests fast.

Apply in src/elements/content-sharing/apis/tests/testUtils.ts:

-export const createSuccessMock = responseFromApi => (itemId, successFn) => {
-    return new Promise(resolve => {
-        setTimeout(() => {
-            resolve(responseFromApi);
-        }, 500);
-    }).then(response => {
-        successFn(response);
-    });
-};
+export const createSuccessMock = responseFromApi => (_itemId, successFn) => {
+    return Promise.resolve(responseFromApi).then(successFn);
+};
src/elements/content-sharing/hooks/useContactService.ts (2)

26-47: Filter to user contacts and dedupe before fetching avatars.

Fetching avatars for groups is wasteful and may 404; also avoid duplicate user lookups.

-    const getContactsAvatarUrls = React.useCallback(
-        async contacts => {
-            if (!contacts || contacts.length === 0) return Promise.resolve({});
-
-            const collaborators = contacts.map(contact => ({
+    const getContactsAvatarUrls = React.useCallback(
+        async (contacts) => {
+            if (!contacts || contacts.length === 0) return {};
+            const userIds = Array.from(
+                new Set(contacts.filter(c => c?.type === 'user').map(c => c.id)),
+            );
+            const collaborators = contacts
+                .filter(contact => contact?.type === 'user')
+                .map(contact => ({
                     accessible_by: {
                         id: contact.id,
                         is_active: true,
                         login: contact.email,
                         name: contact.name,
                         type: contact.type,
                     },
-            }));
+                }));
 
             return fetchAvatars({
                 api,
                 itemId,
                 collaborators,
             });
         },
         [api, itemId],
     );

11-25: Add explicit TS types to the hook API and return value.

Typing improves DX and guards regressions.

-import * as React from 'react';
+import * as React from 'react';
+import type API from '../../../api';
+import type { AvatarURLMap } from '../types';
+
+type Contact = { id: string | number; email?: string; name?: string; type: 'user' | 'group' };
 
-export const useContactService = (api, itemId, currentUserId) => {
+export const useContactService = (api: API, itemId: string, currentUserId?: string) => {-    const getContactsAvatarUrls = React.useCallback(
-        async contacts => {
+    const getContactsAvatarUrls = React.useCallback(
+        async (contacts: Contact[] | null | undefined): Promise<AvatarURLMap> => {
           …
         },
         [api, itemId],
     );
 
-    return { contactService: { getContactByEmail, getContacts, getContactsAvatarUrls } };
+    return { contactService: { getContactByEmail, getContacts, getContactsAvatarUrls } } as const;

Also applies to: 26-47, 49-49

src/elements/content-sharing/hooks/__tests__/useContactService.test.ts (2)

41-59: Wrap the hook in an IntlProvider to avoid useIntl crashes.

useContactService calls useIntl; without a provider tests can break depending on env. Add a wrapper.

-import { renderHook } from '@testing-library/react';
+import { renderHook } from '@testing-library/react';
+import { IntlProvider } from 'react-intl';-        const { result } = renderHook(() => useContactService(mockApi, mockItemId, mockCurrentUserId));
+        const wrapper = ({ children }) => <IntlProvider locale="en">{children}</IntlProvider>;
+        const { result } = renderHook(() => useContactService(mockApi, mockItemId, mockCurrentUserId), { wrapper });

Repeat for other renderHook calls in this file.


81-91: Make the assertion less brittle than hard-coding 'Group'.

Relying on a specific English string can fail with i18n. Prefer any string.

-expect(convertGroupContactsResponse as jest.Mock).toHaveBeenCalledWith(mockGroupData, 'Group');
+expect(convertGroupContactsResponse as jest.Mock).toHaveBeenCalledWith(mockGroupData, expect.any(String));
src/elements/content-sharing/utils/convertCollaborators.ts (1)

33-37: Nit: optional chaining for avatarUrlMap access.

A tiny readability tweak:

-const avatarUrl = avatarUrlMap ? avatarUrlMap[collabId] : undefined;
+const avatarUrl = avatarUrlMap?.[collabId];
src/elements/content-sharing/ContentSharingV2.tsx (2)

98-107: Handle fetchItem errors to avoid unhandled rejections.

Wrap the await in try/catch and set safe defaults.

-        (async () => {
-            const itemData = await fetchItem({ api, itemId, itemType });
-            handleGetItemSuccess(itemData);
-        })();
+        (async () => {
+            try {
+                const itemData = await fetchItem({ api, itemId, itemType });
+                if (itemData) handleGetItemSuccess(itemData);
+            } catch {
+                // no-op: keep item null; optionally log
+            }
+        })();

124-129: Same for fetchCurrentUser: guard with try/catch.

-        (async () => {
-            const userData = await fetchCurrentUser({ api, itemId });
-            getUserSuccess(userData);
-        })();
+        (async () => {
+            try {
+                const userData = await fetchCurrentUser({ api, itemId });
+                if (userData) getUserSuccess(userData);
+            } catch {
+                // keep currentUser null; optionally log
+            }
+        })();
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d497350 and 4ec69da.

📒 Files selected for processing (22)
  • src/elements/content-sharing/ContentSharing.js (1 hunks)
  • src/elements/content-sharing/ContentSharingV2.tsx (7 hunks)
  • src/elements/content-sharing/__tests__/ContentSharingV2.test.tsx (5 hunks)
  • src/elements/content-sharing/apis/__tests__/fetchAvatars.test.ts (5 hunks)
  • src/elements/content-sharing/apis/__tests__/fetchCollaborators.test.ts (3 hunks)
  • src/elements/content-sharing/apis/__tests__/fetchCurrentUser.test.ts (2 hunks)
  • src/elements/content-sharing/apis/__tests__/fetchItem.test.ts (1 hunks)
  • src/elements/content-sharing/apis/__tests__/testUtils.ts (1 hunks)
  • src/elements/content-sharing/apis/fetchAvatars.ts (1 hunks)
  • src/elements/content-sharing/apis/fetchCollaborators.ts (1 hunks)
  • src/elements/content-sharing/apis/fetchCurrentUser.ts (1 hunks)
  • src/elements/content-sharing/apis/fetchItem.ts (1 hunks)
  • src/elements/content-sharing/hooks/__tests__/useContactService.test.ts (5 hunks)
  • src/elements/content-sharing/hooks/__tests__/useSharingService.test.ts (4 hunks)
  • src/elements/content-sharing/hooks/useContactService.ts (2 hunks)
  • src/elements/content-sharing/hooks/useSharingService.ts (2 hunks)
  • src/elements/content-sharing/stories/ContentSharingV2.stories.tsx (1 hunks)
  • src/elements/content-sharing/stories/tests/ContentSharingV2-visual.stories.tsx (4 hunks)
  • src/elements/content-sharing/utils/__mocks__/ContentSharingV2Mocks.js (2 hunks)
  • src/elements/content-sharing/utils/__tests__/convertCollaborators.test.ts (11 hunks)
  • src/elements/content-sharing/utils/convertCollaborators.ts (4 hunks)
  • src/elements/content-sharing/utils/convertItemResponse.ts (2 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-10-02T16:47:50.715Z
Learnt from: reneshen0328
PR: box/box-ui-elements#4322
File: src/elements/content-sharing/utils/__mocks__/ContentSharingV2Mocks.js:30-36
Timestamp: 2025-10-02T16:47:50.715Z
Learning: In src/elements/content-sharing/utils/__mocks__/ContentSharingV2Mocks.js, mockCurrentUserID is intentionally a number (789) while DEFAULT_USER_API_RESPONSE.id is a string ('789'). This represents different stages of data transformation: mockCurrentUserID is the raw API response before conversion, and DEFAULT_USER_API_RESPONSE.id is the post-conversion state after fetchCurrentUser processes it.

Applied to files:

  • src/elements/content-sharing/hooks/__tests__/useSharingService.test.ts
  • src/elements/content-sharing/apis/__tests__/fetchAvatars.test.ts
  • src/elements/content-sharing/apis/fetchCurrentUser.ts
  • src/elements/content-sharing/__tests__/ContentSharingV2.test.tsx
  • src/elements/content-sharing/stories/ContentSharingV2.stories.tsx
  • src/elements/content-sharing/apis/__tests__/fetchCurrentUser.test.ts
  • src/elements/content-sharing/utils/__mocks__/ContentSharingV2Mocks.js
📚 Learning: 2025-09-25T22:28:08.867Z
Learnt from: jfox-box
PR: box/box-ui-elements#4285
File: src/elements/content-sharing/ContentSharingV2.tsx:108-118
Timestamp: 2025-09-25T22:28:08.867Z
Learning: In ContentSharingV2, the getUsersAPI().getUser() call should use itemID as the first parameter, not 'me', when fetching user data for content sharing functionality.

Applied to files:

  • src/elements/content-sharing/apis/fetchCurrentUser.ts
🧬 Code graph analysis (20)
src/elements/content-sharing/hooks/useContactService.ts (2)
src/elements/content-sharing/apis/fetchAvatars.ts (1)
  • fetchAvatars (3-22)
src/elements/content-sharing/ContentSharing.js (1)
  • api (89-89)
src/elements/content-sharing/apis/fetchCollaborators.ts (2)
src/elements/content-sharing/ContentSharing.js (1)
  • api (89-89)
src/utils/Xhr.js (1)
  • itemId (242-242)
src/elements/content-sharing/hooks/__tests__/useSharingService.test.ts (1)
src/elements/content-sharing/utils/__mocks__/ContentSharingV2Mocks.js (2)
  • mockAvatarUrlMap (30-32)
  • mockAvatarUrlMap (30-32)
src/elements/content-sharing/utils/convertItemResponse.ts (1)
src/elements/content-sharing/sharingService.ts (1)
  • ItemData (8-14)
src/elements/content-sharing/apis/__tests__/fetchAvatars.test.ts (1)
src/elements/content-sharing/apis/__tests__/testUtils.ts (2)
  • createSuccessMock (1-9)
  • createUsersApiMock (21-23)
src/elements/content-sharing/apis/fetchCurrentUser.ts (3)
src/elements/content-sharing/apis/index.ts (1)
  • fetchCurrentUser (3-3)
src/elements/content-sharing/ContentSharing.js (1)
  • api (89-89)
src/utils/Xhr.js (1)
  • itemId (242-242)
src/elements/content-sharing/utils/convertCollaborators.ts (1)
src/features/presence/PresenceAvatarList.tsx (1)
  • Collaborator (10-18)
src/elements/content-sharing/__tests__/ContentSharingV2.test.tsx (2)
src/elements/content-sharing/apis/__tests__/testUtils.ts (1)
  • createSuccessMock (1-9)
src/elements/content-sharing/utils/__mocks__/ContentSharingV2Mocks.js (2)
  • MOCK_ITEM (14-18)
  • MOCK_ITEM (14-18)
src/elements/content-sharing/stories/ContentSharingV2.stories.tsx (2)
src/elements/content-sharing/stories/tests/ContentSharingV2-visual.stories.tsx (1)
  • withSharedLink (31-49)
src/elements/content-sharing/utils/__mocks__/ContentSharingV2Mocks.js (4)
  • mockApiWithSharedLink (181-185)
  • mockApiWithSharedLink (181-185)
  • mockApiWithoutSharedLink (186-190)
  • mockApiWithoutSharedLink (186-190)
src/elements/content-sharing/hooks/__tests__/useContactService.test.ts (2)
src/elements/content-sharing/apis/fetchAvatars.ts (1)
  • fetchAvatars (3-22)
src/elements/content-sharing/hooks/useContactService.ts (1)
  • useContactService (11-50)
src/elements/content-sharing/ContentSharingV2.tsx (6)
src/elements/content-sharing/hooks/useContactService.ts (1)
  • useContactService (11-50)
src/utils/Xhr.js (1)
  • itemId (242-242)
src/elements/content-sharing/apis/fetchItem.ts (1)
  • fetchItem (8-22)
src/elements/content-sharing/apis/fetchCurrentUser.ts (1)
  • fetchCurrentUser (7-15)
src/elements/content-sharing/apis/fetchCollaborators.ts (1)
  • fetchCollaborators (6-21)
src/elements/content-sharing/utils/convertCollaborators.ts (1)
  • convertCollabsResponse (54-82)
src/elements/content-sharing/apis/__tests__/fetchItem.test.ts (3)
src/elements/content-sharing/apis/__tests__/testUtils.ts (2)
  • createSuccessMock (1-9)
  • createItemApiMock (11-14)
src/elements/content-sharing/utils/__mocks__/ContentSharingV2Mocks.js (4)
  • DEFAULT_ITEM_API_RESPONSE (93-107)
  • DEFAULT_ITEM_API_RESPONSE (93-107)
  • MOCK_ITEM (14-18)
  • MOCK_ITEM (14-18)
src/elements/content-sharing/apis/fetchItem.ts (1)
  • fetchItem (8-22)
src/elements/content-sharing/apis/__tests__/fetchCurrentUser.test.ts (3)
src/elements/content-sharing/apis/__tests__/testUtils.ts (2)
  • createSuccessMock (1-9)
  • createUsersApiMock (21-23)
src/elements/content-sharing/utils/__mocks__/ContentSharingV2Mocks.js (4)
  • DEFAULT_USER_API_RESPONSE (86-91)
  • DEFAULT_USER_API_RESPONSE (86-91)
  • MOCK_ITEM (14-18)
  • MOCK_ITEM (14-18)
src/elements/content-sharing/apis/fetchCurrentUser.ts (1)
  • fetchCurrentUser (7-15)
src/elements/content-sharing/apis/fetchItem.ts (2)
src/elements/content-sharing/ContentSharing.js (1)
  • api (89-89)
src/utils/Xhr.js (1)
  • itemId (242-242)
src/elements/content-sharing/stories/tests/ContentSharingV2-visual.stories.tsx (1)
src/elements/content-sharing/utils/__mocks__/ContentSharingV2Mocks.js (6)
  • mockApiWithoutSharedLink (186-190)
  • mockApiWithoutSharedLink (186-190)
  • mockApiWithSharedLink (181-185)
  • mockApiWithSharedLink (181-185)
  • mockApiWithCollaborators (191-195)
  • mockApiWithCollaborators (191-195)
src/elements/content-sharing/utils/__tests__/convertCollaborators.test.ts (2)
src/elements/content-sharing/utils/__mocks__/ContentSharingV2Mocks.js (10)
  • collabUser1 (38-43)
  • collabUser1 (38-43)
  • collabUser2 (45-49)
  • collabUser2 (45-49)
  • collabUser3 (51-55)
  • collabUser3 (51-55)
  • mockAvatarUrlMap (30-32)
  • mockAvatarUrlMap (30-32)
  • mockOwnerId (36-36)
  • mockOwnerId (36-36)
src/elements/content-sharing/utils/convertCollaborators.ts (2)
  • convertCollab (17-52)
  • convertCollabsResponse (54-82)
src/elements/content-sharing/apis/__tests__/testUtils.ts (1)
src/utils/Xhr.js (1)
  • itemId (242-242)
src/elements/content-sharing/apis/fetchAvatars.ts (2)
src/elements/content-sharing/ContentSharing.js (1)
  • api (89-89)
src/utils/Xhr.js (1)
  • itemId (242-242)
src/elements/content-sharing/utils/__mocks__/ContentSharingV2Mocks.js (1)
src/utils/Xhr.js (1)
  • itemId (242-242)
src/elements/content-sharing/apis/__tests__/fetchCollaborators.test.ts (3)
src/elements/content-sharing/apis/__tests__/testUtils.ts (2)
  • createSuccessMock (1-9)
  • createCollabApiMock (16-19)
src/elements/content-sharing/utils/__mocks__/ContentSharingV2Mocks.js (4)
  • MOCK_COLLABORATIONS_RESPONSE (65-80)
  • MOCK_COLLABORATIONS_RESPONSE (65-80)
  • MOCK_ITEM (14-18)
  • MOCK_ITEM (14-18)
src/elements/content-sharing/apis/fetchCollaborators.ts (1)
  • fetchCollaborators (6-21)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: lint_test_build
  • GitHub Check: Summary
🔇 Additional comments (20)
src/elements/content-sharing/ContentSharing.js (1)

120-127: Bridge prop rename is correct.

Passing itemId={itemID} cleanly adapts the old public prop to the new V2 API without breaking callers.

Confirm ContentSharingV2’s props expect itemId (camelCase) everywhere post‑rename to avoid mixed casing in downstream hooks.

src/elements/content-sharing/stories/ContentSharingV2.stories.tsx (1)

4-22: LGTM! Clean naming refactor.

The import and usage of renamed mocks (mockApiWithSharedLink, mockApiWithoutSharedLink) and the prop rename (itemId) improve consistency with JavaScript/TypeScript camelCase conventions.

src/elements/content-sharing/hooks/useSharingService.ts (1)

10-10: LGTM! Parameter rename is consistent.

The avatarUrlMap parameter rename and its usage in the convertCollab call are consistent with the codebase-wide naming improvements.

Also applies to: 85-85

src/elements/content-sharing/hooks/__tests__/useSharingService.test.ts (1)

61-61: LGTM! Test updated correctly.

All test references updated from avatarURLMap to avatarUrlMap, maintaining consistency with the implementation changes.

Also applies to: 234-234, 240-240, 262-262, 277-277

src/elements/content-sharing/apis/__tests__/fetchCurrentUser.test.ts (1)

4-31: LGTM! Mock naming refactor is consistent.

The test utility import and variable renames (createUsersApiMock, defaultApiMock) along with the itemId parameter usage maintain consistency across the test suite.

src/elements/content-sharing/apis/fetchAvatars.ts (1)

3-21: LGTM! Systematic naming improvements.

The parameter and variable renames (itemId, usersApi, avatarUrlMap) improve code consistency while preserving the function's logic.

src/elements/content-sharing/apis/__tests__/fetchCollaborators.test.ts (1)

4-42: LGTM! Test suite updated correctly.

The mock factory and variable renames (createCollabApiMock, defaultApiMock) along with the itemId parameter usage are consistent throughout the test suite.

src/elements/content-sharing/__tests__/ContentSharingV2.test.tsx (1)

18-63: LGTM! Comprehensive test refactor.

The mock factory rename (createApiMock), parameter updates, and prop changes (itemId) are systematically applied throughout the test suite, maintaining consistency with the implementation.

src/elements/content-sharing/apis/__tests__/fetchAvatars.test.ts (1)

3-92: LGTM! Test suite fully aligned.

All mock references (createUsersApiMock, defaultApiMock) and the itemId parameter usage are consistently updated throughout the test suite.

src/elements/content-sharing/apis/__tests__/fetchItem.test.ts (1)

5-10: Renames look consistent; mock wiring is correct.

createItemApiMock and defaultApiMock usage aligns with fetchItem’s contract; happy path assertions read well.

src/elements/content-sharing/utils/__mocks__/ContentSharingV2Mocks.js (1)

30-33: LGTM: rename to mockAvatarUrlMap is consistent with avatarUrlMap usage.

No issues; keys map to numeric IDs as expected. Based on learnings.

src/elements/content-sharing/utils/__tests__/convertCollaborators.test.ts (1)

16-21: Tests match the renamed API (avatarUrlMap) and cover edge cases well.

Inputs/expectations align with convertCollab/convertCollabsResponse behavior; null/undefined avatar maps handled.

Also applies to: 32-62, 186-191

src/elements/content-sharing/stories/tests/ContentSharingV2-visual.stories.tsx (2)

8-11: LGTM: story imports/args match the renames (mockApi…, itemId).

Visual flows should remain unchanged.

Also applies to: 16-17, 33-34, 53-54, 76-77


8-11: Ensure mock API method names match fetchCollaborators.

If fetchCollaborators expects getFileCollaborationsAPI/getFolderCollaborationsAPI, confirm mocks export those aliases (see suggested change in ContentSharingV2Mocks.js).

src/elements/content-sharing/ContentSharingV2.tsx (1)

145-163: Avatar fetch effect looks good; minor dependency cleanup.

You don’t use sharedLink/itemType here; current deps are correct. No change required.

src/elements/content-sharing/apis/__tests__/testUtils.ts (5)

1-9: LGTM! Naming standardization improves consistency.

The parameter renames from responseFromAPI to responseFromApi and itemID to itemId align with JavaScript/TypeScript camelCase conventions. The function logic is preserved.


11-14: LGTM! Function and parameter naming standardized.

The rename from createItemAPIMock to createItemApiMock and corresponding parameter updates maintain consistency with camelCase conventions. All internal references are correctly updated.


16-19: LGTM! Consistent with the overall refactoring.

The function and parameter renames follow the same camelCase standardization pattern, and all references are properly updated.


21-23: LGTM! Completes the naming standardization.

The rename from createUsersAPIMock to createUsersApiMock and parameter update complete the systematic refactoring.


1-23: All call sites have been properly updated.

The verification confirms no references to the old function names remain in the codebase. The new function names (createItemApiMock, createCollabApiMock, createUsersApiMock) are correctly imported and used across all test files: fetchItem.test.ts, fetchCurrentUser.test.ts, fetchCollaborators.test.ts, and fetchAvatars.test.ts. The renaming was properly coordinated.

@mergify mergify bot added the queued label Oct 22, 2025
@mergify mergify bot merged commit 6f9260b into master Oct 22, 2025
11 of 12 checks passed
@mergify mergify bot deleted the create-contact-service-getContactsAvatarUrls branch October 22, 2025 17:47
@mergify mergify bot removed the queued label Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants