Skip to content

Commit

Permalink
Fix-Uts in-plugin-meetings (#3429)
Browse files Browse the repository at this point in the history
Co-authored-by: Shreyas Sharma <shreysh2@cisco.com>
Co-authored-by: Kesava Krishnan Madavan <kmadavan@cisco.com>
  • Loading branch information
3 people authored Mar 20, 2024
1 parent 0924685 commit 13d3bf7
Show file tree
Hide file tree
Showing 13 changed files with 259 additions and 800 deletions.
6 changes: 6 additions & 0 deletions packages/@webex/media-helpers/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const config = require('@webex/jest-config-legacy');

module.exports = {
...config,
testEnvironment: 'jsdom',
};
2 changes: 1 addition & 1 deletion packages/@webex/media-helpers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"test:browser:broken": "webex-legacy-tools test --integration --unit --runner karma",
"test:integration:broken": "webex-legacy-tools test --integration --runner mocha",
"test:style": "eslint 'src/**/*.ts' --fix",
"test:unit:broken": "webex-legacy-tools test --unit --runner mocha",
"test:unit": "webex-legacy-tools test --unit --runner jest",
"deploy:npm": "yarn npm publish"
},
"dependencies": {
Expand Down
25 changes: 12 additions & 13 deletions packages/@webex/media-helpers/test/unit/spec/webrtc-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ describe('media-helpers', () => {
spyFn: 'createMicrophoneStream',
},
];

classesToTest.forEach(({className, title, event, createFn, spyFn}) =>
describe(title, () => {
const fakeStream = {
Expand All @@ -58,15 +57,15 @@ describe('media-helpers', () => {
});

it('rejects setMute(false) if unmute is not allowed', async () => {
stream.setUnmuteAllowed(false);
await stream.setUnmuteAllowed(false);

assert.equal(stream.isUnmuteAllowed(), false);
const fn = () => stream.setMuted(false);
expect(fn).to.throw(/Unmute is not allowed/);
});

it('resolves setMute(false) if unmute is allowed', async () => {
stream.setUnmuteAllowed(true);
await stream.setUnmuteAllowed(true);

assert.equal(stream.isUnmuteAllowed(), true);
await stream.setMuted(false);
Expand All @@ -81,15 +80,15 @@ describe('media-helpers', () => {
sinon.restore();
});

const checkSetServerMuted = (startMute, setMute, expectedCalled) => {
stream.setMuted(startMute);
const checkSetServerMuted = async (startMute, setMute, expectedCalled) => {
await stream.setMuted(startMute);

assert.equal(stream.muted, startMute);

const handler = sinon.fake();
stream.on(event.ServerMuted, handler);

stream.setServerMuted(setMute, 'remotelyMuted');
await stream.setServerMuted(setMute, 'remotelyMuted');

assert.equal(stream.muted, setMute);
if (expectedCalled) {
Expand All @@ -100,19 +99,19 @@ describe('media-helpers', () => {
};

it('tests true to false', async () => {
checkSetServerMuted(true, false, true);
await checkSetServerMuted(true, false, true);
});

it('tests false to true', async () => {
checkSetServerMuted(false, true, true);
await checkSetServerMuted(false, true, true);
});

it('tests true to true', async () => {
checkSetServerMuted(true, true, false);
await checkSetServerMuted(true, true, false);
});

it('tests false to false', async () => {
checkSetServerMuted(false, false, false);
await checkSetServerMuted(false, false, false);
});
});

Expand All @@ -121,7 +120,7 @@ describe('media-helpers', () => {
const constraints = {deviceId: 'abc'};

const spy = sinon.stub(wcmestreams, spyFn).returns('something');
const result = createFn(constraints);
const result = await createFn(constraints);

assert.equal(result, 'something');
assert.calledOnceWithExactly(spy, className, constraints);
Expand All @@ -133,7 +132,7 @@ describe('media-helpers', () => {
describe('createDisplayStream', () => {
it('checks createDisplayStream', async () => {
const spy = sinon.stub(wcmestreams, 'createDisplayStream').returns('something');
const result = createDisplayStream();
const result = await createDisplayStream();
assert.equal(result, 'something');
assert.calledOnceWithExactly(spy, LocalDisplayStream);
});
Expand All @@ -142,7 +141,7 @@ describe('media-helpers', () => {
describe('createDisplayStreamWithAudio', () => {
it('checks createDisplayStreamWithAudio', async () => {
const spy = sinon.stub(wcmestreams, 'createDisplayStreamWithAudio').returns('something');
const result = createDisplayStreamWithAudio();
const result = await createDisplayStreamWithAudio();
assert.equal(result, 'something');
assert.calledOnceWithExactly(spy, LocalDisplayStream, LocalSystemAudioStream);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/@webex/plugin-meetings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"test:browser": "webex-legacy-tools test --integration --runner karma",
"test:integration:broken": "webex-legacy-tools test --integration --runner mocha",
"test:style": "eslint ./src/**/*.*",
"test:unit:broken": "webex-legacy-tools test --unit --runner mocha"
"test:unit": "webex-legacy-tools test --unit --runner mocha"
},
"devDependencies": {
"@babel/core": "^7.17.10",
Expand Down
3 changes: 2 additions & 1 deletion packages/@webex/plugin-meetings/src/meeting/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4758,6 +4758,7 @@ export default class Meeting extends StatelessWebexPlugin {
LoggerProxy.logger.error(
`Meeting:index#startTranscription --> meeting joined : ${this.isJoined()}`
);
throw new Error('Meeting is not joined');
}
}

Expand Down Expand Up @@ -4854,7 +4855,7 @@ export default class Meeting extends StatelessWebexPlugin {
Trigger.trigger(
this,
{
file: 'meeting',
file: 'meeting/index',
function: 'triggerStopReceivingTranscriptionEvent',
},
EVENT_TRIGGERS.MEETING_STOPPED_RECEIVING_TRANSCRIPTION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ describe('plugin-meetings', () => {
})
};

sinon.stub(webex.internal.newMetrics.submitClientEvent, 'bind').returns(webex.internal.newMetrics.submitClientEvent);
const submitClientEventStub = sinon.stub(webex.internal.newMetrics.submitClientEvent, 'bind').returns(webex.internal.newMetrics.submitClientEvent);

let onBreakoutMoveRequestStub = sinon.stub(breakoutEvent, 'onBreakoutMoveRequest');
let onBreakoutMoveResponseStub = sinon.stub(breakoutEvent, 'onBreakoutMoveResponse');
Expand All @@ -105,6 +105,7 @@ describe('plugin-meetings', () => {

onBreakoutMoveRequestStub.restore();
onBreakoutMoveResponseStub.restore();
submitClientEventStub.restore()
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ describe('plugin-meetings', () => {
id: 'meeting-id'
})
};
breakoutEvent.onBreakoutJoinResponse = sinon.stub();
const onBreakoutJoinResponseSpy = sinon.stub(breakoutEvent,'onBreakoutJoinResponse')
breakouts.currentBreakoutSession.sessionId = "sessionId-old";
breakouts.updateBreakout({
sessionId: 'sessionId-new',
Expand All @@ -398,7 +398,9 @@ describe('plugin-meetings', () => {
breakoutMoveId: 'breakoutMoveId',
});

assert.calledOnce(breakoutEvent.onBreakoutJoinResponse);
assert.calledOnce(onBreakoutJoinResponseSpy);

onBreakoutJoinResponseSpy.restore()

});

Expand All @@ -408,7 +410,7 @@ describe('plugin-meetings', () => {
id: 'meeting-id'
})
};
breakoutEvent.onBreakoutJoinResponse = sinon.stub();
const onBreakoutJoinResponseSpy = sinon.stub(breakoutEvent, 'onBreakoutJoinResponse');
breakouts.currentBreakoutSession.sessionId = "sessionId";
breakouts.currentBreakoutSession.groupId = "groupId";
breakouts.updateBreakout({
Expand All @@ -426,7 +428,8 @@ describe('plugin-meetings', () => {
breakoutMoveId: 'breakoutMoveId',
});

assert.notCalled(breakoutEvent.onBreakoutJoinResponse);
assert.notCalled(onBreakoutJoinResponseSpy);
onBreakoutJoinResponseSpy.restore()

});
});
Expand Down
5 changes: 5 additions & 0 deletions packages/@webex/plugin-meetings/test/unit/spec/media/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import {forEach} from 'lodash';
import MockWebex from '@webex/test-helper-mock-webex';

describe('createMediaConnection', () => {
let clock;
beforeEach(() => {
clock = sinon.useFakeTimers();
});
const webex = MockWebex();

const fakeRoapMediaConnection = {
Expand Down Expand Up @@ -45,6 +49,7 @@ describe('createMediaConnection', () => {
};
afterEach(() => {
sinon.restore();
clock.uninstall()
});

it('creates a RoapMediaConnection when multistream is disabled', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -826,18 +826,18 @@ describe('plugin-meetings', () => {
statusCode: 200
});
});

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

webex.request = sinon.stub().resolves({
body: conversation,
});
await meetingInfo.createAdhocSpaceMeeting(conversationUrl, installedOrgID);

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

assert.calledWith(webex.request, {
uri: conversationUrl,
qs: {includeParticipants: true},
disableTransform: true,
});
assert.calledWith(webex.request, {
method: 'POST',
uri: 'https://go.webex.com/wbxappapi/v2/meetings/spaceInstant',
Expand Down
Loading

0 comments on commit 13d3bf7

Please sign in to comment.