Skip to content

Commit

Permalink
feat(webinar): update lower hand API and unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
mickelr committed Nov 14, 2024
1 parent 2a24f75 commit a3b447d
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 9 deletions.
6 changes: 4 additions & 2 deletions packages/@webex/plugin-meetings/src/members/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -915,11 +915,12 @@ export default class Members extends StatelessWebexPlugin {
/**
* Lower all hands of members in a meeting
* @param {String} requestingMemberId - id of the participant which requested the lower all hands
* @param {array} roles which should be lowered
* @returns {Promise}
* @public
* @memberof Members
*/
public lowerAllHands(requestingMemberId: string) {
public lowerAllHands(requestingMemberId: string, roles: Array<string>) {
if (!this.locusUrl) {
return Promise.reject(
new ParameterError(
Expand All @@ -936,7 +937,8 @@ export default class Members extends StatelessWebexPlugin {
}
const options = MembersUtil.generateLowerAllHandsMemberOptions(
requestingMemberId,
this.locusUrl
this.locusUrl,
roles
);

return this.membersRequest.lowerAllHandsMember(options);
Expand Down
5 changes: 4 additions & 1 deletion packages/@webex/plugin-meetings/src/members/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {

import {RoleAssignmentOptions, RoleAssignmentRequest, ServerRoleShape} from './types';

// @ts-ignore
const MembersUtil = {
/**
* @param {Object} invitee with emailAddress, email or phoneNumber
Expand Down Expand Up @@ -166,9 +167,10 @@ const MembersUtil = {
locusUrl,
}),

generateLowerAllHandsMemberOptions: (requestingParticipantId, locusUrl) => ({
generateLowerAllHandsMemberOptions: (requestingParticipantId, locusUrl, roles) => ({
requestingParticipantId,
locusUrl,
...(roles !== undefined && {roles}),
}),

/**
Expand Down Expand Up @@ -253,6 +255,7 @@ const MembersUtil = {
const body = {
hand: {
raised: false,
...(options.roles !== undefined && {roles: options.roles}),
},
requestingParticipantId: options.requestingParticipantId,
};
Expand Down
27 changes: 25 additions & 2 deletions packages/@webex/plugin-meetings/test/unit/spec/members/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -660,17 +660,20 @@ describe('plugin-meetings', () => {
resultPromise,
spies,
expectedRequestingMemberId,
expectedLocusUrl
expectedLocusUrl,
expectedRoles,
) => {
await assert.isFulfilled(resultPromise);
assert.calledOnceWithExactly(
spies.generateLowerAllHandsMemberOptions,
expectedRequestingMemberId,
expectedLocusUrl
expectedLocusUrl,
expectedRoles,
);
assert.calledOnceWithExactly(spies.lowerAllHandsMember, {
requestingParticipantId: expectedRequestingMemberId,
locusUrl: expectedLocusUrl,
...(expectedRoles !== undefined && { roles: expectedRoles })
});
assert.strictEqual(resultPromise, spies.lowerAllHandsMember.getCall(0).returnValue);
};
Expand Down Expand Up @@ -707,6 +710,26 @@ describe('plugin-meetings', () => {

await checkValid(resultPromise, spies, requestingMemberId, url1);
});

it('should make the correct request when called with valid requestingMemberId and roles', async () => {
const requestingMemberId = 'test-member-id';
const roles = ['panelist', 'attendee'];
const { members, spies } = setup('test-locus-url');

const resultPromise = members.lowerAllHands(requestingMemberId, roles);

await checkValid(resultPromise, spies, requestingMemberId, 'test-locus-url', roles);
});

it('should handle an empty roles array correctly', async () => {
const requestingMemberId = 'test-member-id';
const roles = [];
const { members, spies } = setup('test-locus-url');

const resultPromise = members.lowerAllHands(requestingMemberId, roles);

await checkValid(resultPromise, spies, requestingMemberId, 'test-locus-url', roles);
});
});

describe('#editDisplayName', () => {
Expand Down
40 changes: 37 additions & 3 deletions packages/@webex/plugin-meetings/test/unit/spec/members/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ describe('plugin-meetings', () => {
});

describe('#assignRolesMember', () => {
it('sends a PATCH to the locus endpoint', async () => {
it('sends a assignRolesMember PATCH to the locus endpoint', async () => {
const locusUrl = url1;
const memberId = 'test1';
const roles = [
Expand Down Expand Up @@ -255,7 +255,7 @@ describe('plugin-meetings', () => {
});

describe('#raiseHand', () => {
it('sends a PATCH to the locus endpoint', async () => {
it('sends a raiseOrLowerHandMember PATCH to the locus endpoint', async () => {
const locusUrl = url1;
const memberId = 'test1';

Expand Down Expand Up @@ -319,7 +319,7 @@ describe('plugin-meetings', () => {
assert.strictEqual(result, requestResponse);
});

it('sends a PATCH to the locus endpoint', async () => {
it('sends a lowerAllHandsMember PATCH to the locus endpoint', async () => {
const locusUrl = url1;
const memberId = 'test1';

Expand Down Expand Up @@ -348,6 +348,40 @@ describe('plugin-meetings', () => {
},
});
});

it('sends a lowerAllHandsMember PATCH to the locus endpoint with roles', async () => {
const locusUrl = url1;
const memberId = 'test1';
const roles = ['attendee'];

const options = {
requestingParticipantId: memberId,
locusUrl,
roles,
};

const getRequestParamsSpy = sandbox.spy(membersUtil, 'getLowerAllHandsMemberRequestParams');

await membersRequest.lowerAllHandsMember(options);

assert.calledOnceWithExactly(getRequestParamsSpy, {
requestingParticipantId: memberId,
locusUrl: url1,
roles: ['attendee'],
});

checkRequest({
method: 'PATCH',
uri: `${locusUrl}/controls`,
body: {
hand: {
raised: false,
roles: ['attendee'],
},
requestingParticipantId: memberId,
},
});
});
});

describe('#editDisplayName', () => {
Expand Down
16 changes: 15 additions & 1 deletion packages/@webex/plugin-meetings/test/unit/spec/members/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ describe('plugin-meetings', () => {
});
});
describe('#generateLowerAllHandsMemberOptions', () => {
it('returns the correct options', () => {
it('returns the correct options without roles', () => {
const requestingParticipantId = 'test';
const locusUrl = 'urlTest1';

Expand All @@ -113,6 +113,20 @@ describe('plugin-meetings', () => {
}
);
});
it('returns the correct options with roles', () => {
const requestingParticipantId = 'test';
const locusUrl = 'urlTest1';
const roles = ['panelist'];

assert.deepEqual(
MembersUtil.generateLowerAllHandsMemberOptions(requestingParticipantId, locusUrl, roles),
{
requestingParticipantId,
locusUrl,
roles,
}
);
});
});
describe('#generateEditDisplayNameMemberOptions', () => {
it('returns the correct options', () => {
Expand Down

0 comments on commit a3b447d

Please sign in to comment.