Skip to content

Commit

Permalink
test(plugin-meetings): fix failing tests after merge (#4)
Browse files Browse the repository at this point in the history
* test(plugin-meetings): fix failing tests after merge

* fix(samples): jsonwebtoken es6 incompatibilities
  • Loading branch information
mkesavan13 authored Dec 15, 2023
1 parent 8973106 commit 6cad14d
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 107 deletions.
2 changes: 1 addition & 1 deletion packages/@webex/plugin-meetings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"global": "^4.4.0",
"ip-anonymize": "^0.1.0",
"javascript-state-machine": "^3.1.0",
"jsonwebtoken": "^8.5.1",
"jwt-decode": "^4.0.0",
"lodash": "^4.17.21",
"sdp-transform": "^2.12.0",
"uuid": "^3.3.2",
Expand Down
10 changes: 5 additions & 5 deletions packages/@webex/plugin-meetings/src/meeting/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import uuid from 'uuid';
import {cloneDeep, isEqual, isEmpty} from 'lodash';
import jwt from 'jsonwebtoken';
import {jwtDecode as decode} from 'jwt-decode';
// @ts-ignore - Fix this
import {StatelessWebexPlugin} from '@webex/webex-core';
import {
Expand Down Expand Up @@ -2047,7 +2047,6 @@ export default class Meeting extends StatelessWebexPlugin {
modifiedBy,
lastModified,
};

Trigger.trigger(
this,
{
Expand Down Expand Up @@ -3414,7 +3413,7 @@ export default class Meeting extends StatelessWebexPlugin {
* @returns {void}
*/
public setPermissionTokenPayload(permissionToken: string) {
this.permissionTokenPayload = jwt.decode(permissionToken);
this.permissionTokenPayload = decode(permissionToken);
}

/**
Expand Down Expand Up @@ -4609,6 +4608,7 @@ export default class Meeting extends StatelessWebexPlugin {
joinSuccess(join);

this.deferJoin = undefined;
this.receiveTranscription = !!options.receiveTranscription;

return join;
})
Expand Down Expand Up @@ -4668,12 +4668,12 @@ export default class Meeting extends StatelessWebexPlugin {
.then((join) => {
if (isBrowser) {
// @ts-ignore - config coming from registerPlugin
if (this.config.receiveTranscription || options.receiveTranscription) {
if (this.config.receiveTranscription || this.receiveTranscription) {
if (this.isTranscriptionSupported()) {
LoggerProxy.logger.info(
'Meeting:index#join --> Attempting to enabled to recieve transcription!'
);
this.receiveTranscription().catch((error) => {
this.startTranscription().catch((error) => {
LoggerProxy.logger.error(
'Meeting:index#join --> Receive Transcription Failed',
error
Expand Down
2 changes: 2 additions & 0 deletions packages/@webex/plugin-meetings/src/roap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ export default class Roap extends StatelessWebexPlugin {
locusSelfUrl: meeting.selfUrl,
mediaId: options.mediaId,
meetingId: meeting.id,
audioMuted: meeting.audio?.isLocallyMuted(),
videoMuted: meeting.video?.isLocallyMuted(),
locusMediaRequest: meeting.locusMediaRequest,
});
}
Expand Down
2 changes: 2 additions & 0 deletions packages/@webex/plugin-meetings/src/roap/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ export default class RoapRequest extends StatelessWebexPlugin {
meetingId: string;
ipVersion?: IP_VERSION;
locusMediaRequest?: LocusMediaRequest;
audioMuted?: boolean;
videoMuted?: boolean;
}) {
const {roapMessage, locusSelfUrl, mediaId, meetingId, locusMediaRequest, ipVersion} = options;

Expand Down
4 changes: 4 additions & 0 deletions packages/@webex/plugin-meetings/src/roap/turnDiscovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ export default class TurnDiscovery {
locusSelfUrl: meeting.selfUrl,
// @ts-ignore - Fix missing type
mediaId: isReconnecting ? '' : meeting.mediaId,
audioMuted: meeting.audio?.isLocallyMuted(),
videoMuted: meeting.video?.isLocallyMuted(),
meetingId: meeting.id,
locusMediaRequest: meeting.locusMediaRequest,
// @ts-ignore - because of meeting.webex
Expand Down Expand Up @@ -214,6 +216,8 @@ export default class TurnDiscovery {
// @ts-ignore - fix type
mediaId: meeting.mediaId,
meetingId: meeting.id,
audioMuted: meeting.audio?.isLocallyMuted(),
videoMuted: meeting.video?.isLocallyMuted(),
locusMediaRequest: meeting.locusMediaRequest,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -786,13 +786,12 @@ describe('plugin-meetings', () => {
it('Make a request to /spaceInstant when conversationUrl', async () => {
const {invitee} = setup();

const result = await meetingInfo.createAdhocSpaceMeeting(conversationUrl);
webex.request.resolves({
statusCode: 200,
body: conversation
});

await meetingInfo.createAdhocSpaceMeeting(conversationUrl);
const result = await meetingInfo.createAdhocSpaceMeeting(conversationUrl,installedOrgID);

assert.calledWith(
webex.request,
Expand All @@ -808,44 +807,17 @@ describe('plugin-meetings', () => {
keyUrl: conversation.encryptionKeyUrl,
kroUrl: conversation.kmsResourceObjectUrl,
invitees: invitee,
installedOrgID: installedOrgID
},
});
assert(Metrics.sendBehavioralMetric.calledOnce);
assert.calledOnce(Metrics.sendBehavioralMetric);
assert.calledWith(Metrics.sendBehavioralMetric, BEHAVIORAL_METRICS.ADHOC_MEETING_SUCCESS);
assert.deepEqual(result, {
body: {},
body: conversation,
statusCode: 200
});
});

it('Make a request to /spaceInstant when conversationUrl with installed org ID', async () => {
const {invitee} = setup();

await meetingInfo.createAdhocSpaceMeeting(conversationUrl, installedOrgID);

assert.calledWith(
webex.internal.conversation.get,
{url: conversationUrl},
{includeParticipants: true, disableTransform: true}
);

assert.calledWith(webex.request, {
method: 'POST',
uri: 'https://go.webex.com/wbxappapi/v2/meetings/spaceInstant',
body: {
title: conversation.displayName,
spaceUrl: conversation.url,
keyUrl: conversation.encryptionKeyUrl,
kroUrl: conversation.kmsResourceObjectUrl,
invitees: invitee,
installedOrgID,
},
});
assert(Metrics.sendBehavioralMetric.calledOnce);
assert.calledWith(Metrics.sendBehavioralMetric, BEHAVIORAL_METRICS.ADHOC_MEETING_SUCCESS);
});


forEach(
[
{errorCode: 403049},
Expand Down
77 changes: 40 additions & 37 deletions packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -994,12 +994,12 @@ describe('plugin-meetings', () => {
});

describe('receive transcription', () => {
it('should invoke `receiveTranscription()` if receiveTranscription is set to true', async () => {
it('should invoke `startTranscription()` if receiveTranscription is set to true', async () => {
meeting.isTranscriptionSupported = sinon.stub().returns(true);
meeting.receiveTranscription = sinon.stub().returns(Promise.resolve());
meeting.startTranscription = sinon.stub().returns(Promise.resolve());

await meeting.join({receiveTranscription: true});
assert.calledOnce(meeting.receiveTranscription);
assert.calledOnce(meeting.startTranscription);
});

it('make sure that join does not wait for setting up receive transcriptions', async () => {
Expand All @@ -1019,7 +1019,7 @@ describe('plugin-meetings', () => {
const defer = new Defer();

meeting.isTranscriptionSupported = sinon.stub().returns(true);
meeting.receiveTranscription = sinon.stub().returns(defer.promise);
meeting.startTranscription = sinon.stub().returns(defer.promise);

const result = await meeting.join({receiveTranscription: true});

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

describe('#setupLocusControlsListener', () => {
it('transcription should start when meeting transcribe state is updated with active transcribing', (done) => {
const payload = {caption: true, transcribing: true};
meeting.startTranscription = sinon.stub();
meeting.config.receiveTranscription = true;
meeting.transcription = null;

meeting.locusInfo.emit({function: 'meeting/index', file: 'setupLocusControlsListener'}, 'CONTROLS_MEETING_TRANSCRIBE_UPDATED', payload);
assert.calledOnce(meeting.startTranscription);
done();
});

it('transcription should stop when meeting transcribe state is updated with inactive transcribing', (done) => {
const payload = {caption: false, transcribing: false};
meeting.startTranscription = sinon.stub();
meeting.config.receiveTranscription = true;
meeting.transcription = {};

meeting.locusInfo.emit({function: 'meeting/index', file: 'setupLocusControlsListener'}, 'CONTROLS_MEETING_TRANSCRIBE_UPDATED', payload);
assert.notCalled(meeting.startTranscription);
assert.calledThrice(TriggerProxy.trigger);
assert.calledWith(
TriggerProxy.trigger,
sinon.match.instanceOf(Meeting),
{file: 'meeting/index', function: 'setupLocusControlsListener'},
'meeting:receiveTranscription:stopped',
payload
);
done();
});

it('listens to the locus breakouts update event', () => {
const locus = {
breakout: 'breakout',
Expand Down Expand Up @@ -5645,38 +5675,6 @@ describe('plugin-meetings', () => {
});
});

describe('#setupLocusControlsListener', () => {
it('transcription should start when meeting transcribe state is updated with active transcribing', (done) => {
const payload = {caption: true, transcribing: true};
meeting.startTranscription = sinon.stub();
meeting.config.receiveTranscription = true;
meeting.transcription = null;

meeting.locusInfo.emit({function: 'meeting/index', file: 'setupLocusControlsListener'}, 'CONTROLS_MEETING_TRANSCRIBE_UPDATED', payload);
assert.calledOnce(meeting.startTranscription);
done();
})

it('transcription should stop when meeting transcribe state is updated with inactive transcribing', (done) => {
const payload = {caption: false, transcribing: false};
meeting.startTranscription = sinon.stub();
meeting.config.receiveTranscription = true;
meeting.transcription = {};

meeting.locusInfo.emit({function: 'meeting/index', file: 'setupLocusControlsListener'}, 'CONTROLS_MEETING_TRANSCRIBE_UPDATED', payload);
assert.notCalled(meeting.startTranscription);
assert.calledTwice(TriggerProxy.trigger);
assert.calledWith(
TriggerProxy.trigger,
sinon.match.instanceOf(Meeting),
{file: 'meeting/index', function: 'setupLocusControlsListener'},
'meeting:receiveTranscription:stopped',
payload
);
done();
})
})

describe('#setUpLocusUrlListener', () => {
it('listens to the locus url update event', (done) => {
const newLocusUrl = 'newLocusUrl/12345';
Expand Down Expand Up @@ -6309,7 +6307,6 @@ describe('plugin-meetings', () => {
);
canUserLowerSomeoneElsesHandSpy = sinon.spy(MeetingUtil, 'canUserLowerSomeoneElsesHand');
waitingForOthersToJoinSpy = sinon.spy(MeetingUtil, 'waitingForOthersToJoin');
locusInfoOnSpy = sinon.spy(meeting.locusInfo, 'on');
handleDataChannelUrlChangeSpy = sinon.spy(meeting, 'handleDataChannelUrlChange');
updateMeetingActionsSpy = sinon.spy(meeting, 'updateMeetingActions');
});
Expand Down Expand Up @@ -6347,6 +6344,12 @@ describe('plugin-meetings', () => {
assert.equal(locusInfoOnSpy.thirdCall.args[0], 'MEETING_INFO_UPDATED');
const callback = locusInfoOnSpy.thirdCall.args[1];

const payload = {
info: {
userDisplayHints: ['LOCK_CONTROL_UNLOCK'],
},
};

callback();

assert.calledWith(canUserLockSpy, payload.info.userDisplayHints);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,19 +170,6 @@ describe('plugin-meetings', () => {
meeting.remoteMuted = true;
meeting.mediaProperties.audioStream.muted = false;
// create a new MuteState intance
audio = createMuteState(AUDIO, meeting, {sendAudio: true});

assert.isFalse(audio.isLocallyMuted());
});
});

describe('#handleClientRequest', () => {
it('disables/enables the local audio track when audio is muted/unmuted', async () => {
// mute
audio.handleClientRequest(meeting, true);
assert.calledWith(Media.setLocalTrack, false, meeting.mediaProperties.audioTrack);

// create a new MuteState instance
audio = createMuteState(AUDIO, meeting, true);
audio.handleLocalStreamChange(meeting);

Expand Down
27 changes: 8 additions & 19 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7769,7 +7769,7 @@ __metadata:
javascript-state-machine: ^3.1.0
jsdom: 19.0.0
jsdom-global: 3.0.2
jsonwebtoken: ^8.5.1
jwt-decode: ^4.0.0
lodash: ^4.17.21
prettier: ^2.7.1
sdp-transform: ^2.12.0
Expand Down Expand Up @@ -20467,24 +20467,6 @@ __metadata:
languageName: node
linkType: hard

"jsonwebtoken@npm:^8.5.1":
version: 8.5.1
resolution: "jsonwebtoken@npm:8.5.1"
dependencies:
jws: ^3.2.2
lodash.includes: ^4.3.0
lodash.isboolean: ^3.0.3
lodash.isinteger: ^4.0.4
lodash.isnumber: ^3.0.3
lodash.isplainobject: ^4.0.6
lodash.isstring: ^4.0.1
lodash.once: ^4.0.0
ms: ^2.1.1
semver: ^5.6.0
checksum: 93c9e3f23c59b758ac88ba15f4e4753b3749dfce7a6f7c40fb86663128a1e282db085eec852d4e0cbca4cefdcd3a8275ee255dbd08fcad0df26ad9f6e4cc853a
languageName: node
linkType: hard

"jsonwebtoken@npm:^9.0.0":
version: 9.0.2
resolution: "jsonwebtoken@npm:9.0.2"
Expand Down Expand Up @@ -20567,6 +20549,13 @@ __metadata:
languageName: node
linkType: hard

"jwt-decode@npm:^4.0.0":
version: 4.0.0
resolution: "jwt-decode@npm:4.0.0"
checksum: 390e2edcb31a92e86c8cbdd1edeea4c0d62acd371f8a8f0a8878e499390c0ecf4c658b365c4e941e4ef37d0170e4ca650aaa49f99a45c0b9695a235b210154b0
languageName: node
linkType: hard

"karma-browserify@npm:^8.1.0":
version: 8.1.0
resolution: "karma-browserify@npm:8.1.0"
Expand Down

0 comments on commit 6cad14d

Please sign in to comment.