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
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/@webex/plugin-meetings/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,12 @@ export const DISPLAY_HINTS = {
STAGE_VIEW_INACTIVE: 'STAGE_VIEW_INACTIVE',
ENABLE_STAGE_VIEW: 'ENABLE_STAGE_VIEW',
DISABLE_STAGE_VIEW: 'DISABLE_STAGE_VIEW',

// Practice Session
PRACTICE_SESSION_ON: 'PRACTICE_SESSION_ON',
PRACTICE_SESSION_OFF: 'PRACTICE_SESSION_OFF',
SHOW_PRACTICE_SESSION_START: 'SHOW_PRACTICE_SESSION_START',
SHOW_PRACTICE_SESSION_STOP: 'SHOW_PRACTICE_SESSION_STOP',
};

export const INTERSTITIAL_DISPLAY_HINTS = [DISPLAY_HINTS.VOIP_IS_ENABLED];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ interface IInMeetingActions {
canShowStageView?: boolean;
canEnableStageView?: boolean;
canDisableStageView?: boolean;
IsPracticeSessionOn?: boolean;
IsPracticeSessionOff?: boolean;
canStartPracticeSession?: boolean;
canStopPracticeSession?: boolean;
}

/**
Expand Down Expand Up @@ -266,6 +270,15 @@ export default class InMeetingActions implements IInMeetingActions {
canEnableStageView = null;

canDisableStageView = null;

IsPracticeSessionOn = null;

IsPracticeSessionOff = null;

canStartPracticeSession = null;

canStopPracticeSession = null;

/**
* Returns all meeting action options
* @returns {Object}
Expand Down Expand Up @@ -354,6 +367,10 @@ export default class InMeetingActions implements IInMeetingActions {
canShowStageView: this.canShowStageView,
canEnableStageView: this.canEnableStageView,
canDisableStageView: this.canDisableStageView,
IsPracticeSessionOn: this.IsPracticeSessionOn,
IsPracticeSessionOff: this.IsPracticeSessionOff,
canStartPracticeSession: this.canStartPracticeSession,
canStopPracticeSession: this.canStopPracticeSession,
});

/**
Expand Down
16 changes: 16 additions & 0 deletions packages/@webex/plugin-meetings/src/meeting/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3904,6 +3904,22 @@ export default class Meeting extends StatelessWebexPlugin {
requiredHints: [DISPLAY_HINTS.DISABLE_STAGE_VIEW],
displayHints: this.userDisplayHints,
}),
IsPracticeSessionOn: ControlsOptionsUtil.hasHints({
requiredHints: [DISPLAY_HINTS.PRACTICE_SESSION_ON],
displayHints: this.userDisplayHints,
}),
IsPracticeSessionOff: ControlsOptionsUtil.hasHints({
requiredHints: [DISPLAY_HINTS.PRACTICE_SESSION_OFF],
displayHints: this.userDisplayHints,
}),
canStartPracticeSession: ControlsOptionsUtil.hasHints({
requiredHints: [DISPLAY_HINTS.SHOW_PRACTICE_SESSION_START],
displayHints: this.userDisplayHints,
}),
canStopPracticeSession: ControlsOptionsUtil.hasHints({
requiredHints: [DISPLAY_HINTS.SHOW_PRACTICE_SESSION_STOP],
displayHints: this.userDisplayHints,
}),
canShareFile:
(ControlsOptionsUtil.hasHints({
requiredHints: [DISPLAY_HINTS.SHARE_FILE],
Expand Down
38 changes: 30 additions & 8 deletions packages/@webex/plugin-meetings/src/webinar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
*/
import {WebexPlugin} from '@webex/webex-core';
import {get} from 'lodash';
import {MEETINGS, SELF_ROLES} from '../constants';
import {HTTP_VERBS, MEETINGS, SELF_ROLES} from '../constants';

import WebinarCollection from './collection';
import LoggerProxy from '../common/logs/logger-proxy';

/**
* @class Webinar
Expand Down Expand Up @@ -59,18 +60,39 @@ const Webinar = WebexPlugin.extend({
* @returns {{isPromoted: boolean, isDemoted: boolean}} Role transition states
*/
updateRoleChanged(payload) {
const oldRoles = get(payload, 'oldRoles', []);
const newRoles = get(payload, 'newRoles', []);

const isPromoted =
get(payload, 'oldRoles', []).includes(SELF_ROLES.ATTENDEE) &&
get(payload, 'newRoles', []).includes(SELF_ROLES.PANELIST);
oldRoles.includes(SELF_ROLES.ATTENDEE) && newRoles.includes(SELF_ROLES.PANELIST);
const isDemoted =
get(payload, 'oldRoles', []).includes(SELF_ROLES.PANELIST) &&
get(payload, 'newRoles', []).includes(SELF_ROLES.ATTENDEE);
this.set('selfIsPanelist', get(payload, 'newRoles', []).includes(SELF_ROLES.PANELIST));
this.set('selfIsAttendee', get(payload, 'newRoles', []).includes(SELF_ROLES.ATTENDEE));
this.updateCanManageWebcast(get(payload, 'newRoles', []).includes(SELF_ROLES.MODERATOR));
oldRoles.includes(SELF_ROLES.PANELIST) && newRoles.includes(SELF_ROLES.ATTENDEE);
this.set('selfIsPanelist', newRoles.includes(SELF_ROLES.PANELIST));
this.set('selfIsAttendee', newRoles.includes(SELF_ROLES.ATTENDEE));
this.updateCanManageWebcast(newRoles.includes(SELF_ROLES.MODERATOR));

return {isPromoted, isDemoted};
},

/**
* start practice session for webinar
* @param {boolean} enabled
* @returns {Promise}
*/
startPracticeSession(enabled) {
return this.request({
method: HTTP_VERBS.PATCH,
uri: `${this.locusUrl}/controls`,
body: {
practiceSession: {
enabled,
},
},
}).catch((error) => {
LoggerProxy.logger.error('Meeting:webinar#startPracticeSession failed', error);
throw error;
});
},
});

export default Webinar;
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ describe('plugin-meetings', () => {
canShowStageView: null,
canEnableStageView: null,
canDisableStageView: null,
IsPracticeSessionOn : null,
IsPracticeSessionOff : null,
canStartPracticeSession: null,
canStopPracticeSession: null,

...expected,
};

Expand Down Expand Up @@ -181,7 +186,12 @@ describe('plugin-meetings', () => {
'canShowStageView',
'canEnableStageView',
'canDisableStageView',
].forEach((key) => {
'IsPracticeSessionOn',
'IsPracticeSessionOff',
'canStartPracticeSession',
'canStopPracticeSession',

].forEach((key) => {
it(`get and set for ${key} work as expected`, () => {
const inMeetingActions = new InMeetingActions();

Expand Down
51 changes: 51 additions & 0 deletions packages/@webex/plugin-meetings/test/unit/spec/webinar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,56 @@ describe('plugin-meetings', () => {
});
});

describe('#startPracticeSession', () => {
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`,
body: {
practiceSession: { enabled },
},
});
assert.equal(result, 'REQUEST_RETURN_VALUE', 'should return the resolved value from the request');
});

it('sends a PATCH request to disable the practice session', async () => {
const enabled = false;

const result = await webinar.startPracticeSession(enabled);

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

it('handles API call failures gracefully', async () => {
webex.request.rejects(new Error('API_ERROR'));
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.calledOnce(errorLogger);
assert.calledWith(errorLogger, 'Meeting:webinar#startPracticeSession failed', sinon.match.instanceOf(Error));
}

errorLogger.restore();
});
});


Shreyas281299 marked this conversation as resolved.
Show resolved Hide resolved
})
})
Loading