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

Feat/practice session - start/stop control API and displayhint #4008

Merged
merged 15 commits into from
Dec 16, 2024

Conversation

mickelr
Copy link
Contributor

@mickelr mickelr commented Nov 27, 2024

COMPLETES #< INSERT LINK TO ISSUE >

https://jira-eng-gpk2.cisco.com/jira/browse/SPARK-575353

This pull request addresses

  • Practice session start/stop control API and related display hint
  • Add new parameter "roles" for invite API

by making the following changes

< DESCRIBE YOUR CHANGES >

Change Type

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Tooling change
  • Internal code refactor

The following scenarios were tested

  • Host/cohost can start and stop practice session according to related display hints.
  • Panelist/Attendee receive practice session on/off status.

I certified that

  • I have read and followed contributing guidelines

  • I discussed changes with code owners prior to submitting this pull request

  • I have not skipped any automated checks

  • All existing and new tests passed

  • I have updated the documentation accordingly


Make sure to have followed the contributing guidelines before submitting.

Summary by CodeRabbit

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced practice session management capabilities, allowing users to start and stop practice sessions during meetings and webinars.
    • Added new display hints for practice sessions to enhance user interface interactions.
    • Enhanced role management logic for better control over practice session permissions.
    • Updated invite functionality to include role specifications for invited members.
    • Improved data structure for adding members by including role information.
  • Bug Fixes

    • Improved error handling for media connections and practice session transitions.
  • Tests

    • Expanded test coverage for the new practice session features, ensuring robust validation of functionality and error handling.
    • Added tests for the getAddMemberBody method to validate various input scenarios.

@mickelr mickelr requested review from a team as code owners November 27, 2024 02:43
Copy link

coderabbitai bot commented Nov 27, 2024

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

warning [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options.
warning eslint > @humanwhocodes/[email protected]: Use @eslint/config-array instead
warning eslint > @humanwhocodes/config-array > @humanwhocodes/[email protected]: Use @eslint/object-schema instead
warning eslint > file-entry-cache > flat-cache > [email protected]: Rimraf versions prior to v4 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > [email protected]: Glob versions prior to v9 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > glob > [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning eslint-import-resolver-typescript > [email protected]: Glob versions prior to v9 are no longer supported
warning [email protected]: Glob versions prior to v9 are no longer supported
warning intern > [email protected]: Glob versions prior to v9 are no longer supported
warning intern > glob > [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning jasmine > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > jest-config > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > jest-runtime > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > @jest/reporters > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > @jest/transform > babel-plugin-istanbul > test-exclude > [email protected]: Glob versions prior to v9 are no longer supported
warning mocha > [email protected]: Glob versions prior to v9 are no longer supported
warning mocha > glob > [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning [email protected]: 16.1.1
warning wd > [email protected]: You or someone you depend on is using Q, the JavaScript Promise library that gave JavaScript developers strong feelings about promises. They can almost certainly migrate to the native JavaScript promise now. Thank you literally everyone for joining me in this bet against the odds. Be excellent to each other.

(For a CapTP with native promises, see @endo/eventual-send and @endo/captp)
warning wd > archiver > [email protected]: Glob versions prior to v9 are no longer supported
warning wd > [email protected]: request has been deprecated, see request/request#3142
warning wd > archiver > archiver-utils > [email protected]: Glob versions prior to v9 are no longer supported
warning wd > request > [email protected]: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
warning wd > request > [email protected]: this library is no longer supported
warning @babel/cli > [email protected]: Glob versions prior to v9 are no longer supported
warning @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-async-generator-functions instead.
warning @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
warning @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-export-namespace-from instead.
warning @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
warning @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead.
warning @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
warning @babel/[email protected]: 🚨 This package has been deprecated in favor of separate inclusion of a polyfill and regenerator-runtime (when needed). See the @babel/polyfill docs (https://babeljs.io/docs/en/babel-polyfill) for more information.
warning @babel/polyfill > [email protected]: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
warning @babel/runtime-corejs2 > [email protected]: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
warning babel-plugin-lodash > [email protected]: Glob versions prior to v9 are no longer supported
warning workspace-aggregator-125147bb-dd5f-447e-9e2b-9c3d54b8dfda > [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options.
warning workspace-aggregator-125147bb-dd5f-447e-9e2b-9c3d54b8dfda > [email protected]: Glob versions prior to v9 are no longer supported
warning workspace-aggregator-125147bb-dd5f-447e-9e2b-9c3d54b8dfda > [email protected]: 16.1.1
warning workspace-aggregator-125147bb-dd5f-447e-9e2b-9c3d54b8dfda > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-async-generator-functions instead.
warning workspace-aggregator-125147bb-dd5f-447e-9e2b-9c3d54b8dfda > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
warning workspace-aggregator-125147bb-dd5f-447e-9e2b-9c3d54b8dfda > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-export-namespace-from instead.
warning workspace-aggregator-125147bb-dd5f-447e-9e2b-9c3d54b8dfda > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
warning workspace-aggregator-125147bb-dd5f-447e-9e2b-9c3d54b8dfda > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead.
warning workspace-aggregator-125147bb-dd5f-447e-9e2b-9c3d54b8dfda > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
warning workspace-aggregator-125147bb-dd5f-447e-9e2b-9c3d54b8dfda > @babel/[email protected]: 🚨 This package has been deprecated in favor of separate inclusion of a polyfill and regenerator-runtime (when needed). See the @babel/polyfill docs (https://babeljs.io/docs/en/babel-polyfill) for more information.
error [email protected]: The engine "node" is incompatible with this module. Expected version "^14 || ^16 || ^17 || ^18 || ^19". Got "22.9.0"
error Found incompatible module.

Walkthrough

The changes in this pull request introduce new constants and methods related to practice sessions within the Webex plugin meetings. Specifically, new constants are added to manage display hints, and several properties are introduced to the IInMeetingActions interface and InMeetingActions class. The Meeting class is enhanced with methods to manage practice session status, and the Webinar class receives new methods for starting practice sessions. Additionally, corresponding tests are added to ensure proper functionality and error handling.

Changes

File Path Change Summary
packages/@webex/plugin-meetings/src/constants.ts Added constants: PRACTICE_SESSION_ON, PRACTICE_SESSION_OFF, SHOW_PRACTICE_SESSION_START, SHOW_PRACTICE_SESSION_STOP to DISPLAY_HINTS.
packages/@webex/plugin-meetings/src/meeting/in-meeting-actions.ts Updated IInMeetingActions interface and InMeetingActions class to include properties: isPracticeSessionOn, isPracticeSessionOff, canStartPracticeSession, canStopPracticeSession.
packages/@webex/plugin-meetings/src/meeting/index.ts Added properties related to practice sessions in inMeetingActions. Updated updateMeetingActions to check for practice session capabilities. Added event listener for practice session status updates.
packages/@webex/plugin-meetings/src/webinar/index.ts Added methods: setPracticeSessionState(enabled) and updatePracticeSessionStatus(payload) for managing practice sessions. Added property practiceSessionEnabled. Refactored updateRoleChanged method for clarity.
packages/@webex/plugin-meetings/test/unit/spec/meeting/in-meeting-actions.ts Updated tests to include new properties in checkValues function for InMeetingActions.
packages/@webex/plugin-meetings/test/unit/spec/webinar/index.ts Introduced a new test suite for setPracticeSessionState method in Webinar, including tests for successful execution and error handling.
packages/@webex/plugin-meetings/src/members/util.ts Updated getAddMemberBody method to conditionally include roles in the returned object.
packages/@webex/plugin-meetings/test/unit/spec/members/utils.js Added tests for getAddMemberBody method to validate the request body structure across various scenarios.

Possibly related PRs

  • fix: locus DTOs not handled if an earlier one causes an error #3982: This PR introduces error handling improvements in the locus-info/parser.ts, which may relate to the management of practice sessions as it enhances the robustness of event processing, indirectly supporting the new constants added in the main PR.
  • fix: lobby entry/exit metrics #4018: This PR adds metrics for guest entry and exit in the lobby, which could be related to the practice session management as both involve user interactions within the meeting context, enhancing the overall functionality of the meeting management system.

Suggested reviewers

  • marcin-bazyl
  • k-wasniowski
  • jor-row
  • szotrabh

🐰 In the meadow, we hop with glee,
New constants added, oh what a spree!
Practice sessions now take the stage,
In meetings and webinars, we engage.
With methods and tests, our code shines bright,
Hopping along, everything feels right! 🌼


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

🧹 Outside diff range and nitpick comments (8)
packages/@webex/plugin-meetings/src/webinar/index.ts (3)

63-72: Consider adding TypeScript type safety improvements.

The refactoring improves readability by introducing intermediate variables. However, the payload parameter could benefit from stronger typing.

Consider adding an interface for the payload:

interface RoleChangePayload {
  oldRoles: string[];
  newRoles: string[];
}

updateRoleChanged(payload: RoleChangePayload) {
  const {oldRoles, newRoles} = payload;
  // ... rest of the implementation
}

82-90: Add input validation for the enabled parameter.

The method should validate the enabled parameter before making the API call.

Consider adding validation:

 startPracticeSession(enabled) {
+  if (typeof enabled !== 'boolean') {
+    throw new TypeError('enabled parameter must be a boolean');
+  }
   return this.request({

91-94: Enhance error handling with specific error types.

The current error handling is basic and could be more informative for debugging purposes.

Consider enhancing the error handling:

 }).catch((error) => {
-  LoggerProxy.logger.error('Meeting:webinar#startPracticeSession failed', error);
+  LoggerProxy.logger.error(
+    `Meeting:webinar#startPracticeSession failed to ${enabled ? 'start' : 'stop'} practice session`,
+    {error, locusUrl: this.locusUrl}
+  );
   throw error;
 });
packages/@webex/plugin-meetings/test/unit/spec/webinar/index.ts (2)

126-140: Enhance test coverage and clarity.

While the test is well-structured, consider these improvements:

  1. Make the test name more descriptive (e.g., "successfully enables practice session and returns API response")
  2. Add assertion for Content-Type header to ensure proper API communication
 it('sends a PATCH request to enable the practice session', async () => {
   const enabled = true;

   const result = await webinar.startPracticeSession(enabled);

   assert.calledOnce(webex.request);
   assert.calledWith(webex.request, {
     method: 'PATCH',
     uri: `${webinar.locusUrl}/controls`,
+    headers: {
+      'Content-Type': 'application/json',
+    },
     body: {
       practiceSession: { enabled },
     },
   });
   assert.equal(result, 'REQUEST_RETURN_VALUE', 'should return the resolved value from the request');
 });

158-172: Improve error handling test robustness.

The error handling test is well-structured but could be enhanced:

 it('handles API call failures gracefully', async () => {
-  webex.request.rejects(new Error('API_ERROR'));
+  const apiError = new Error('API_ERROR');
+  apiError.name = 'WebexApiError';  // Use a more specific error type
+  webex.request.rejects(apiError);
   const errorLogger = sinon.stub(LoggerProxy.logger, 'error');

   try {
     await webinar.startPracticeSession(true);
     assert.fail('startPracticeSession should throw an error');
   } catch (error) {
-    assert.equal(error.message, 'API_ERROR', 'should throw the correct error');
+    assert.instanceOf(error, Error);
+    assert.equal(error.name, 'WebexApiError', 'should be a WebexApiError');
+    assert.equal(error.message, 'API_ERROR', 'should have correct message');
     assert.calledOnce(errorLogger);
     assert.calledWith(errorLogger, 'Meeting:webinar#startPracticeSession failed', sinon.match.instanceOf(Error));
+  } finally {
+    errorLogger.restore();  // Ensure cleanup even if assertions fail
   }
-
-  errorLogger.restore();
 });
packages/@webex/plugin-meetings/src/meeting/in-meeting-actions.ts (2)

273-281: Remove excessive blank lines between properties

The new properties have unnecessary blank lines between them, which differs from the style used for other properties in this class.

Apply this diff to maintain consistent spacing:

-
-  IsPracticeSessionOn = null;
-
-  IsPracticeSessionOff = null;
-
-  canStartPracticeSession = null;
-
-  canStopPracticeSession = null;
-
+  IsPracticeSessionOn = null;
+  IsPracticeSessionOff = null;
+  canStartPracticeSession = null;
+  canStopPracticeSession = null;

96-99: Consider using an enum for practice session state

The current implementation uses separate boolean flags for practice session states, which could lead to invalid states (both On and Off being true or false). Consider using an enum to represent the practice session state more effectively.

Example implementation:

enum PracticeSessionState {
  ON = 'on',
  OFF = 'off'
}

interface IInMeetingActions {
  // ... other properties
  practiceSessionState?: PracticeSessionState;
  canStartPracticeSession?: boolean;
  canStopPracticeSession?: boolean;
}

This approach would:

  1. Prevent invalid states
  2. Make the code more maintainable
  3. Provide better type safety
packages/@webex/plugin-meetings/src/constants.ts (1)

991-996: LGTM! Consider adding JSDoc comments.

The new practice session display hint constants are well organized and follow the existing naming convention. However, consider adding JSDoc comments to document the purpose of each constant.

  // Practice Session
+ /**
+  * Indicates that a practice session is currently active
+  */
  PRACTICE_SESSION_ON: 'PRACTICE_SESSION_ON',
+ /**
+  * Indicates that a practice session is currently inactive
+  */
  PRACTICE_SESSION_OFF: 'PRACTICE_SESSION_OFF',
+ /**
+  * Control hint to show the start practice session action
+  */
  SHOW_PRACTICE_SESSION_START: 'SHOW_PRACTICE_SESSION_START',
+ /**
+  * Control hint to show the stop practice session action
+  */
  SHOW_PRACTICE_SESSION_STOP: 'SHOW_PRACTICE_SESSION_STOP',
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between c4ba3e5 and 2cf86e6.

📒 Files selected for processing (6)
  • packages/@webex/plugin-meetings/src/constants.ts (1 hunks)
  • packages/@webex/plugin-meetings/src/meeting/in-meeting-actions.ts (3 hunks)
  • packages/@webex/plugin-meetings/src/meeting/index.ts (1 hunks)
  • packages/@webex/plugin-meetings/src/webinar/index.ts (2 hunks)
  • packages/@webex/plugin-meetings/test/unit/spec/meeting/in-meeting-actions.ts (2 hunks)
  • packages/@webex/plugin-meetings/test/unit/spec/webinar/index.ts (1 hunks)
🔇 Additional comments (6)
packages/@webex/plugin-meetings/src/webinar/index.ts (2)

6-6: LGTM! Import statements are properly organized.

The new imports for HTTP_VERBS and LoggerProxy are correctly added and utilized in the new functionality.

Also applies to: 9-9


82-95: Verify the impact on the UI when practice session state changes.

The practice session state change might need corresponding UI updates or notifications.

Let's check for any display hint or notification handlers:

✅ Verification successful

Let me check the content of these files to understand how practice session state changes are handled.


Let me check how these events are handled in the UI components.


Based on the search results, I can now provide a final response:

Practice session state changes are properly handled through event system

The codebase shows a complete event handling chain for practice session state changes:

  • The startPracticeSession method triggers state changes
  • LocusInfo emits CONTROLS_PRACTICE_SESSION_STATUS_UPDATED events
  • Meeting class listens and propagates these events via MEETING_CONTROLS_PRACTICE_SESSION_STATUS_UPDATED
  • Display hints (PRACTICE_SESSION_ON, PRACTICE_SESSION_OFF, etc.) are properly defined and checked in the meeting controls
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for practice session related UI handlers
rg -l "practiceSession|PRACTICE_SESSION" --type ts

# Look for any event emitters or handlers related to practice sessions
ast-grep --pattern 'emit($_, "practiceSession")'

Length of output: 442


Script:

#!/bin/bash
# Check practice session related code in the files
rg "practiceSession" -A 5 -B 5 packages/@webex/plugin-meetings/src/locus-info/index.ts
rg "practiceSession" -A 5 -B 5 packages/@webex/plugin-meetings/src/meeting/index.ts
rg "PRACTICE_SESSION" packages/@webex/plugin-meetings/src/constants.ts

# Look for any event listeners or handlers
ast-grep --pattern 'on($_, "practiceSession")'
ast-grep --pattern 'handlePracticeSession'

Length of output: 1013


Script:

#!/bin/bash
# Search for components or handlers that listen to practice session events
rg "CONTROLS_PRACTICE_SESSION_STATUS_UPDATED|PRACTICE_SESSION_ON|PRACTICE_SESSION_OFF|SHOW_PRACTICE_SESSION_START|SHOW_PRACTICE_SESSION_STOP" -A 5 -B 5

# Look for any UI components that might be affected
rg "practiceSession" --type tsx --type jsx -A 5 -B 5

Length of output: 12699

packages/@webex/plugin-meetings/test/unit/spec/meeting/in-meeting-actions.ts (1)

Line range hint 194-208: LGTM! Test implementation is thorough

The test implementation for the new practice session properties follows the established pattern and provides good coverage:

  • Tests both successful and unsuccessful property updates
  • Verifies the return value of the set operation
  • Checks individual and bulk property retrieval
packages/@webex/plugin-meetings/test/unit/spec/webinar/index.ts (1)

125-125: LGTM! Test suite structure follows established patterns.

packages/@webex/plugin-meetings/src/meeting/in-meeting-actions.ts (1)

370-373: LGTM!

The additions to the getter method are implemented correctly and maintain consistency with the existing pattern.

packages/@webex/plugin-meetings/src/meeting/index.ts (1)

3915-3922: LGTM!

The addition of canStartPracticeSession and canStopPracticeSession properties aligns with existing patterns and correctly utilizes ControlsOptionsUtil.hasHints.

Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-4008.d3m3l2kee0btzx.amplifyapp.com

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 (1)
packages/@webex/plugin-meetings/src/webinar/index.ts (1)

64-73: LGTM: Improved readability with local variables

The refactored code is more readable with local variables for roles. Consider adding type annotations for better maintainability:

-    const oldRoles = get(payload, 'oldRoles', []);
-    const newRoles = get(payload, 'newRoles', []);
+    const oldRoles: string[] = get(payload, 'oldRoles', []);
+    const newRoles: string[] = get(payload, 'newRoles', []);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 2cf86e6 and 609ae79.

📒 Files selected for processing (2)
  • packages/@webex/plugin-meetings/src/meeting/index.ts (2 hunks)
  • packages/@webex/plugin-meetings/src/webinar/index.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/@webex/plugin-meetings/src/meeting/index.ts
🔇 Additional comments (3)
packages/@webex/plugin-meetings/src/webinar/index.ts (3)

6-6: LGTM: Import additions are appropriate

The new imports for HTTP_VERBS and LoggerProxy are necessary for the added functionality and follow the existing import style.

Also applies to: 9-9


26-26: LGTM: Property addition is well-documented

The practiceSessionEnabled boolean property is appropriately typed and documented.


78-96: 🛠️ Refactor suggestion

Consider renaming method and improving error handling

The method name and implementation could be improved for clarity and robustness.

  1. Rename as previously suggested to better reflect the purpose:
-  startPracticeSession(enabled) {
+  setPracticeSessionState(enabled: boolean) {
  1. Add more specific error handling:
   }).catch((error) => {
-    LoggerProxy.logger.error('Meeting:webinar#startPracticeSession failed', error);
+    LoggerProxy.logger.error(
+      `Meeting:webinar#setPracticeSessionState failed to ${enabled ? 'start' : 'stop'} practice session`,
+      {error, locusUrl: this.locusUrl}
+    );
     throw error;
   });

@webex webex deleted a comment from coderabbitai bot Dec 3, 2024
@webex webex deleted a comment from coderabbitai bot Dec 3, 2024
@webex webex deleted a comment from coderabbitai bot Dec 3, 2024
@webex webex deleted a comment from coderabbitai bot Dec 3, 2024
@webex webex deleted a comment from coderabbitai bot Dec 3, 2024
@webex webex deleted a comment from coderabbitai bot Dec 3, 2024
@webex webex deleted a comment from coderabbitai bot Dec 3, 2024
@mickelr mickelr added the validated If the pull request is validated for automation. label Dec 3, 2024
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: 0

🧹 Outside diff range and nitpick comments (2)
packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js (2)

Line range hint 93-196: Consider extracting common test setup into shared helper functions.

The describe block setup contains a lot of repeated mock setup code. Consider extracting common setup patterns into helper functions to reduce duplication and improve maintainability.

// Example helper function
function setupBasicMeetingMocks(webex) {
  webex.internal.support.submitLogs = sinon.stub().returns(Promise.resolve());
  webex.internal.services = {get: sinon.stub().returns('locus-url')};
  webex.credentials.getOrgId = sinon.stub().returns('fake-org-id');
  // ... other common setup
}

Line range hint 3001-9043: Consider adding more edge case tests for error scenarios.

While the test coverage is good, consider adding more tests for:

  • Network failure scenarios
  • Race conditions in media negotiation
  • Invalid state transitions
  • Timeout handling
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 8af552d and 1380147.

📒 Files selected for processing (3)
  • packages/@webex/plugin-meetings/src/meeting/index.ts (3 hunks)
  • packages/@webex/plugin-meetings/src/members/util.ts (1 hunks)
  • packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js (2 hunks)
👮 Files not reviewed due to content moderation or server errors (2)
  • packages/@webex/plugin-meetings/src/members/util.ts
  • packages/@webex/plugin-meetings/src/meeting/index.ts
🔇 Additional comments (9)
packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js (9)

Line range hint 1-3: LGTM! Standard file header with copyright notice.


Line range hint 4-47: LGTM! Well organized test dependencies and imports.

The imports are logically grouped and include all necessary testing utilities and mocks. Good use of sinon for stubbing/spying and chai for assertions.


Line range hint 48-92: LGTM! Comprehensive constants imported for testing.

The test file imports all the necessary constants from the meetings plugin that are used throughout the tests. This helps maintain consistency with the actual implementation.


Line range hint 197-392: LGTM! Thorough test coverage for Meeting constructor and basic properties.

The tests verify all important aspects of Meeting object initialization:

  • Public properties and their initial values
  • Correct instantiation of dependent objects (Members, Roap, etc.)
  • Proper handling of correlation IDs

Line range hint 393-1200: LGTM! Comprehensive test coverage for media handling.

The tests thoroughly cover:

  • Media negotiation and SDP handling
  • Stream publishing/unpublishing
  • Screen sharing
  • Media reconnection scenarios
  • Error cases and edge conditions

Line range hint 1201-2000: LGTM! Good test coverage for meeting control operations.

Tests verify important meeting control functionality:

  • Joining/leaving meetings
  • Meeting locks and security
  • Recording controls
  • Participant management
  • Meeting state transitions

Line range hint 2001-3000: LGTM! Thorough testing of events and callbacks.

The tests verify proper event handling for:

  • Mercury events
  • Locus updates
  • Media state changes
  • Participant updates

Line range hint 9043-9048: LGTM! Good test for practice session status updates.

The test verifies that practice session status updates are properly handled and propagated through the system.


Line range hint 9048-9500: LGTM! Thorough test coverage for remaining functionality.

The tests comprehensively cover the remaining Meeting class functionality including:

  • Permission token handling
  • Keep-alive mechanism
  • Reaction handling
  • Whiteboard sharing

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: 0

🧹 Outside diff range and nitpick comments (2)
packages/@webex/plugin-meetings/test/unit/spec/members/utils.js (2)

266-359: Consider adding tests for input validation edge cases.

While the current test coverage is good, consider adding tests for the following scenarios:

  • Invalid email format
  • Empty or null address
  • Invalid phone number format
  • Empty roles array

Here's a suggested test case:

it('handles invalid input gracefully', () => {
  const invalidCases = [
    {
      invitee: {
        emailAddress: 'invalid-email',  // Invalid email
        roles: ['role1']
      }
    },
    {
      invitee: {
        emailAddress: '',  // Empty address
        roles: ['role1']
      }
    },
    {
      invitee: {
        phoneNumber: 'abc',  // Invalid phone
      }
    },
    {
      invitee: {
        emailAddress: '[email protected]',
        roles: []  // Empty roles
      }
    }
  ];

  invalidCases.forEach(options => {
    // Assert that the function either throws or handles these cases appropriately
    // depending on the expected behavior
  });
});

266-359: Consider extracting test data and common patterns.

To improve maintainability and reduce duplication, consider:

  1. Extracting test data to constants
  2. Creating helper functions for common assertion patterns

Here's a suggested refactor:

// At the top of the describe block
const TEST_DATA = {
  validEmail: {
    invitee: {
      emailAddress: '[email protected]',
      roles: ['role1', 'role2']
    },
    alertIfActive: true,
    expected: {
      invitees: [{
        address: '[email protected]',
        roles: ['role1', 'role2']
      }],
      alertIfActive: true
    }
  },
  // Add other test cases...
};

const assertAddMemberBody = (options, expected) => {
  assert.deepEqual(MembersUtil.getAddMemberBody(options), expected);
};

// In the tests
it('returns the correct body with email address and roles', () => {
  const {invitee, alertIfActive, expected} = TEST_DATA.validEmail;
  assertAddMemberBody({invitee, alertIfActive}, expected);
});
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 1380147 and 025b823.

📒 Files selected for processing (1)
  • packages/@webex/plugin-meetings/test/unit/spec/members/utils.js (1 hunks)
🔇 Additional comments (1)
packages/@webex/plugin-meetings/test/unit/spec/members/utils.js (1)

266-359: Well-structured test suite with comprehensive coverage!

The test suite follows best practices with:

  • Clear and descriptive test case names
  • Good separation of concerns
  • Consistent implementation pattern
  • Comprehensive coverage of edge cases

@Shreyas281299
Copy link
Contributor

@CodeRabbit review

Copy link

coderabbitai bot commented Dec 6, 2024

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@Shreyas281299 Shreyas281299 left a comment

Choose a reason for hiding this comment

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

Please add the manual tests performed in the PR description.

@mickelr
Copy link
Contributor Author

mickelr commented Dec 9, 2024

Please add the manual tests performed in the PR description.

Done

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: 0

🧹 Outside diff range and nitpick comments (5)
packages/@webex/plugin-meetings/src/meeting/index.ts (2)

3920-3935: Consider adding JSDoc documentation for the new practice session properties

The new practice session properties would benefit from JSDoc documentation explaining their purpose and usage. This would help other developers understand when and how to use these flags.

+  /**
+   * Whether practice session is currently active
+   * @type {boolean} 
+   */
   isPracticeSessionOn: ControlsOptionsUtil.hasHints({
     requiredHints: [DISPLAY_HINTS.PRACTICE_SESSION_ON],
     displayHints: this.userDisplayHints,
   }),

+  /**
+   * Whether practice session is currently inactive
+   * @type {boolean}
+   */
   isPracticeSessionOff: ControlsOptionsUtil.hasHints({
     requiredHints: [DISPLAY_HINTS.PRACTICE_SESSION_OFF], 
     displayHints: this.userDisplayHints,
   }),

+  /**
+   * Whether user has permission to start a practice session
+   * @type {boolean}
+   */
   canStartPracticeSession: ControlsOptionsUtil.hasHints({
     requiredHints: [DISPLAY_HINTS.SHOW_PRACTICE_SESSION_START],
     displayHints: this.userDisplayHints, 
   }),

+  /**
+   * Whether user has permission to stop a practice session
+   * @type {boolean}
+   */
   canStopPracticeSession: ControlsOptionsUtil.hasHints({
     requiredHints: [DISPLAY_HINTS.SHOW_PRACTICE_SESSION_STOP],
     displayHints: this.userDisplayHints,
   }),

3920-3935: Consider adding TypeScript type definitions

The practice session properties would benefit from explicit TypeScript type definitions to improve type safety and IDE support.

+interface PracticeSessionState {
+  isPracticeSessionOn: boolean;
+  isPracticeSessionOff: boolean;
+  canStartPracticeSession: boolean; 
+  canStopPracticeSession: boolean;
+}
packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js (3)

Line range hint 4-4: Reminder: Address the TODO comment.

The TODO comment indicates that tests are missing for this function. Please ensure that the additional parameter change is thoroughly tested to confirm that it behaves as expected.

Do you want me to generate the unit testing code or open a GitHub issue to track this task?


Line range hint 12-24: Consider adjusting the fee structure or discount policy.

The implementation of a flat $20 fee on discounted bills could negate the benefit of the discount, especially for smaller purchases or marginal loyalty tiers. This might lead to customer dissatisfaction, as the intent to reward loyalty paradoxically increases the bill.

Consider revising either the discount percentages or the flat fee application to better align with customer incentives.

Would you like assistance in generating a revised implementation?


Line range hint 15-18: Fix indentation in elif/else blocks.

The indentation of the elif and else blocks is incorrect. They should be at the same level as the if statement.

Apply this diff to fix the indentation:

  if loyalty_years >= 5:
    discount = 0.15
-    elif loyalty_years >= 3:
-      discount = 0.1
-    else:
-      discount = 0
+  elif loyalty_years >= 3:
+    discount = 0.1
+  else:
+    discount = 0
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 025b823 and ae90865.

📒 Files selected for processing (2)
  • packages/@webex/plugin-meetings/src/meeting/index.ts (3 hunks)
  • packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js (2 hunks)
🔇 Additional comments (2)
packages/@webex/plugin-meetings/src/meeting/index.ts (2)

2663-2663: LGTM!

The practice session status update handler is well implemented with proper separation of concerns between state management and event notification.


3920-3935: Verify test coverage for practice session functionality

Please ensure there are adequate unit tests covering:

  1. Practice session state transitions
  2. Display hint handling
  3. Event emission
  4. Permission checks
✅ Verification successful

Test coverage exists for practice session functionality

The practice session functionality has adequate test coverage across multiple test files:

  • test/unit/spec/webinar/index.ts:

    • Tests for setPracticeSessionState method
    • Tests for updatePracticeSessionStatus method
    • Covers state transitions and error handling
  • test/unit/spec/meeting/index.js:

    • Tests for practice session event handling
    • Tests for status updates propagation
  • test/unit/spec/locus-info/controlsUtils.js:

    • Tests for practice session control parsing
    • Tests for state change detection
  • test/unit/spec/meeting/in-meeting-actions.ts:

    • Tests for practice session state properties
    • Tests for permission flags
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check test coverage for practice session related code
fd -e test.ts -e spec.ts | xargs rg "practice.*session"

Length of output: 57


Script:

#!/bin/bash
# Let's try a broader search for test files related to practice sessions
rg -i "practice.*session" -t ts --glob "*test*" --glob "*spec*" -A 5

Length of output: 70


Script:

#!/bin/bash
# Search for the display hints enum to find related test files
rg "DISPLAY_HINTS.PRACTICE_SESSION" -t ts --glob "*test*" --glob "*spec*"

Length of output: 73


Script:

#!/bin/bash
# Look for test files in the meetings plugin directory
fd -p "packages/@webex/plugin-meetings/.*\.(test|spec)\.ts$" | xargs cat

Length of output: 74


Script:

#!/bin/bash
# Let's try a more focused search in the meetings plugin directory
rg -l "DISPLAY_HINTS" packages/@webex/plugin-meetings/src/

Length of output: 406


Script:

#!/bin/bash
# Search for test files specifically in the meetings plugin directory
fd . packages/@webex/plugin-meetings/src/ -e test.ts -e spec.ts

Length of output: 65


Script:

#!/bin/bash
# Look for any practice session related code to find potential test locations
rg -i "practicesession|practice.*session" packages/@webex/plugin-meetings/

Length of output: 10055

Copy link
Contributor

@Shreyas281299 Shreyas281299 left a comment

Choose a reason for hiding this comment

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

Looks good to me, please see a query that I had.

* @param {boolean} enabled
* @returns {Promise}
*/
setPracticeSessionState(enabled) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: can you point me to where we are using this method, I was unable to find it

Copy link
Contributor

@JudyZhuHz JudyZhuHz left a comment

Choose a reason for hiding this comment

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

LGTM

@JudyZhuHz JudyZhuHz merged commit 71f56bf into webex:next Dec 16, 2024
13 checks passed
@mickelr mickelr deleted the feat/practice_session branch December 16, 2024 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
validated If the pull request is validated for automation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants