Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(MembershipsSdkAdapter): added name property to member mapping in getmembers function #344

Merged
merged 3 commits into from
Nov 11, 2024

Conversation

Parimala032
Copy link
Contributor

@Parimala032 Parimala032 commented Nov 7, 2024

This pull request addresses

This PR enhances the getMembers function by including the name property in the returned member objects. By adding the name: member.name, each member object now contains the participant's display name in a local sample app of widgets, improving the comprehensiveness of the member data. If the user wanted to pass the name according to there wish that will be appear on widgets sample app (or) the system default name will be displayed

please do refer to the screenrecording

sdk-component.recording.mp4

Summary by CodeRabbit

  • New Features

    • Enhanced member information by including the member's name in the list returned by the membership function.
  • Bug Fixes

    • Improved error handling for invalid meeting IDs and SDK failures in adding members.
  • Tests

    • Expanded test coverage for member attributes and refined error handling in the membership-related tests.

@Parimala032 Parimala032 changed the title fix(MembershipsSdkAdapter):added name property to member mapping in g… fix(MembershipsSdkAdapter):added name property to member mapping in getmembers function Nov 7, 2024
Copy link

coderabbitai bot commented Nov 7, 2024

Walkthrough

The changes in this pull request involve modifications to the MembershipsSDKAdapter class and its associated test file. A new property, name, has been added to the object returned by the getMembers function, allowing for the inclusion of member names in the output. Additionally, the test cases for the getMembersFromDestination() and addRoomMember() methods have been enhanced to validate the new structure and error handling related to member attributes and invalid meeting IDs.

Changes

File Change Summary
src/MembershipsSDKAdapter.js Added name property to the return object of getMembers(sdkMembers, meeting).
src/MembershipsSDKAdapter.test.js Enhanced tests for getMembersFromDestination() to include new member properties and validate error handling. Updated tests for addRoomMember() to confirm observable return types and error messages.

Poem

In the meadow where members play,
A name now joins the bright array.
With tests that dance and errors that flee,
Our adapter sings in harmony! 🐇✨
So hop along, let’s celebrate,
For every member now feels great!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 4d4153f and 169874b.

📒 Files selected for processing (1)
  • src/MembershipsSDKAdapter.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/MembershipsSDKAdapter.js

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@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: 1

🧹 Outside diff range and nitpick comments (3)
src/MembershipsSDKAdapter.test.js (1)

Line range hint 42-82: Consider adding test cases for edge cases in name values.

While the current test coverage is good, consider adding test cases for:

  • Empty string names
  • Null names
  • Very long names
  • Names with special characters

This would ensure robust handling of the name property across all scenarios.

src/MembershipsSDKAdapter.js (2)

118-118: Fix formatting: Add space after colon in property declaration.

The property declaration is missing a space after the colon.

-    name:member.name,
+    name: member.name,
🧰 Tools
🪛 eslint

[error] 118-118: Missing space before value for key 'name'.

(key-spacing)


Property inconsistency confirmed between room and meeting members

The verification reveals that:

  • Meeting members use name property from member.name
  • Room members don't include any name property in membershipToMember mapping
  • Both member types are consumed through getMembersFromDestination() interface
  • Test expectations don't verify name-related properties

This inconsistency should be addressed as it could cause issues for consumers expecting consistent member objects.

  • In src/MembershipsSDKAdapter.js:
    • Add personDisplayName to meeting members (keeping name for backward compatibility if needed)
    • Add personDisplayName to room members using membership.personDisplayName
    • Document the naming properties in JSDoc if both are intentionally maintained
🔗 Analysis chain

Line range hint 91-119: Consider standardizing member properties between room and meeting members.

The getMembers() function now includes a name property for meeting members, while getRoomMembers() uses personDisplayName. This inconsistency might cause issues for consumers of the adapter. Consider:

  1. Using the same property name across both member types
  2. Documenting the difference if it's intentional
  3. Adding the name property to room members if they should be consistent

Let's verify the usage of these properties in the codebase:


Let me gather more context about the getRoomMembers function to fully understand the inconsistency:


Let me check one more thing to see how these member objects are being consumed:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for usages of personDisplayName and name properties
echo "Searching for personDisplayName usage:"
rg "personDisplayName" --type js

echo -e "\nSearching for member.name usage:"
rg "member\.name" --type js

Length of output: 948


Script:

#!/bin/bash
# Search for getRoomMembers implementation
ast-grep --pattern 'function getRoomMembers($_) {
  $$$
}'

# Also search for any consumer code that might be using these member objects
rg -A 3 "getRoomMembers|getMembers" --type js

Length of output: 5252


Script:

#!/bin/bash
# Search for the membershipToMember implementation in getRoomMembers
ast-grep --pattern 'const membershipToMember = $_'

# Look for any test expectations that might show the expected shape
rg -B 2 -A 5 "expect\(members\)" --type js

Length of output: 1847

🧰 Tools
🪛 eslint

[error] 118-118: Missing space before value for key 'name'.

(key-spacing)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 7381ded and 4d4153f.

📒 Files selected for processing (2)
  • src/MembershipsSDKAdapter.js (1 hunks)
  • src/MembershipsSDKAdapter.test.js (4 hunks)
🧰 Additional context used
🪛 eslint
src/MembershipsSDKAdapter.js

[error] 118-118: Missing space before value for key 'name'.

(key-spacing)

🔇 Additional comments (4)
src/MembershipsSDKAdapter.test.js (4)

47-47: LGTM! Name property correctly added to basic member object.

The test case properly validates the name property for a standard member with basic privileges.


57-57: LGTM! Name property correctly added to privileged member object.

The test case appropriately validates the name property for a member with full privileges (muted, sharing, host, guest).


67-67: LGTM! Name property correctly added to non-joined member object.

The test case properly validates that the name property is included even for members who haven't joined the meeting.


77-77: Verify if undefined name is the expected behavior for device members.

While the test case properly includes the name property for device members, please confirm if undefined is the intended value. Consider:

  1. Should devices have a default name?
  2. Should the name be derived from the device type or ID?

Let's verify the implementation:

✅ Verification successful

These scripts will help us understand:

  1. How device members are handled in the adapter
  2. Where and how member objects are created/mapped
  3. The type definitions for member objects to verify if name is optional

Having undefined name for device members is correct behavior

Based on the code analysis:

  1. The membershipToMember transformation doesn't include a name field in its mapping
  2. The fromSDKMembership function only maps person-related fields like personDisplayName
  3. Device members are handled differently from person members, and the test correctly reflects that devices don't have a name property
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for device member handling in the adapter implementation
rg -l "device.*member" src/

Length of output: 29


Script:

#!/bin/bash
# Let's try a broader search for device-related code and member handling
rg -A 5 "device" src/MembershipsSDKAdapter

Length of output: 108


Script:

#!/bin/bash
# Search for member object construction or mapping
rg -A 5 "mapMember|createMember" src/

Length of output: 39


Script:

#!/bin/bash
# Look for member type definitions or interfaces
ast-grep --pattern 'interface $_Member {
  $$$
  name?: $_
  $$$
}'

Length of output: 69


Script:

#!/bin/bash
# Let's try to find the correct file name first
fd "Membership.*" src/

# Then search for device-related code in test file
rg -A 5 "device" src/MembershipsSDKAdapter.test.js

# Look for member object construction in the test file
rg -A 5 "member" src/MembershipsSDKAdapter.test.js

Length of output: 3069


Script:

#!/bin/bash
# Let's check the implementation file for device member handling
rg -A 5 "device" src/MembershipsSDKAdapter.js

# Look for member mapping or transformation logic
rg -A 10 "transform|map.*Member" src/MembershipsSDKAdapter.js

Length of output: 860


Script:

#!/bin/bash
# Let's look for the membershipToMember and fromSDKMembership transformations
rg -B 5 -A 10 "membershipToMember|fromSDKMembership" src/MembershipsSDKAdapter.js

# Also check for any device-specific member handling in the entire codebase
rg -l "deviceType|isDevice" src/

Length of output: 2177

@@ -115,6 +115,7 @@ function getMembers(sdkMembers, meeting) {
sharing: member.isContentSharing,
host: !!meeting.meetingInfo.isWebexScheduled && member.isModerator,
guest: member.isGuest,
name:member.name,
Copy link

@coderabbitai coderabbitai bot Nov 7, 2024

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add null check for member.name property.

The name property is accessed directly from the member object without any validation. Consider adding a null check to maintain consistency with how other properties are handled in the function.

-    name:member.name,
+    name: member.name || null,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
name:member.name,
name: member.name || null,
🧰 Tools
🪛 eslint

[error] 118-118: Missing space before value for key 'name'.

(key-spacing)

Copy link

Choose a reason for hiding this comment

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

What happens if this value comes as undefined? Do we have an edge check?

Copy link

Choose a reason for hiding this comment

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

@adhmenon, if member.name comes as undefined, the name property in the returned object would also be undefined. Currently, there is no edge check for this scenario in the function. Adding a null check like name: member.name || null ensures that when member.name is undefined, the name property is explicitly set to null. This maintains consistency with how other properties are handled and prevents potential issues if other parts of the code expect name to have a defined value.

Copy link

@adhmenon adhmenon left a comment

Choose a reason for hiding this comment

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

LGTM. Noticed you have added check in the other repo.

@@ -115,6 +115,7 @@ function getMembers(sdkMembers, meeting) {
sharing: member.isContentSharing,
host: !!meeting.meetingInfo.isWebexScheduled && member.isModerator,
guest: member.isGuest,
name:member.name,
Copy link

Choose a reason for hiding this comment

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

What happens if this value comes as undefined? Do we have an edge check?

@Parimala032
Copy link
Contributor Author

LGTM. Noticed you have added check in the other repo.

Yes @adhmenon the check for this is there in the components repo because this function will return the members object that the members object call actually has been there in the components repo so here we just include the name as a property in the members function previously it was not there if we include this property then only the user accepting wished name will be visible on widgets sample app

@Parimala032
Copy link
Contributor Author

Parimala032 commented Nov 8, 2024

@adhmenon for you question What happens if this value comes as undefined? Do we have an edge check? below is the answer

to this question the logic is there in the components repo here we just passing this property in the return object of members
so if the user enter the name it will take this name in the return object of members or if user is not providing name that means when it is undefined it will take that undefined as well in the return object of members to the implicit edge check which is there in the components rpeo
The current statement has an implicit edge check due to the use of optional chaining and the || operator. It will handle cases where member.name is undefined by falling back to displayName.

@sreenara sreenara merged commit f4480a5 into webex:master Nov 11, 2024
1 of 2 checks passed
@Parimala032 Parimala032 changed the title fix(MembershipsSdkAdapter):added name property to member mapping in getmembers function fix(MembershipsSdkAdapter): added name property to member mapping in getmembers function Nov 11, 2024
@sreenara
Copy link
Contributor

🎉 This PR is included in version 1.112.13 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants