@webex/plugin-meetings 2.29.1 → 2.29.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3227,7 +3227,9 @@ describe('plugin-meetings', () => {
3227
3227
  });
3228
3228
  describe('#setUpLocusInfoSelfListener', () => {
3229
3229
  it('listens to the self unadmitted guest event', (done) => {
3230
+ meeting.startKeepAlive = sinon.stub();
3230
3231
  meeting.locusInfo.emit({function: 'test', file: 'test'}, 'SELF_UNADMITTED_GUEST', test1);
3232
+ assert.calledOnceWithExactly(meeting.startKeepAlive);
3231
3233
  assert.calledTwice(TriggerProxy.trigger);
3232
3234
  assert.calledWith(
3233
3235
  TriggerProxy.trigger,
@@ -3239,7 +3241,9 @@ describe('plugin-meetings', () => {
3239
3241
  done();
3240
3242
  });
3241
3243
  it('listens to the self admitted guest event', (done) => {
3244
+ meeting.stopKeepAlive = sinon.stub();
3242
3245
  meeting.locusInfo.emit({function: 'test', file: 'test'}, 'SELF_ADMITTED_GUEST', test1);
3246
+ assert.calledOnceWithExactly(meeting.stopKeepAlive);
3243
3247
  assert.calledTwice(TriggerProxy.trigger);
3244
3248
  assert.calledWith(
3245
3249
  TriggerProxy.trigger,
@@ -4328,6 +4332,157 @@ describe('plugin-meetings', () => {
4328
4332
  });
4329
4333
  });
4330
4334
  });
4335
+
4336
+ describe('#startKeepAlive', () => {
4337
+ let clock;
4338
+ const defaultKeepAliveUrl = 'keep.alive.url';
4339
+ const defaultKeepAliveSecs = 23;
4340
+ const defaultExpectedInterval = (defaultKeepAliveSecs - 1) * 750;
4341
+
4342
+ beforeEach(() => {
4343
+ clock = sinon.useFakeTimers();
4344
+ });
4345
+ afterEach(() => {
4346
+ clock.restore();
4347
+ });
4348
+
4349
+ const progressTime = async (interval) => {
4350
+ await clock.tickAsync(interval);
4351
+ await testUtils.flushPromises();
4352
+ };
4353
+
4354
+ it('startKeepAlive starts the keep alive', async () => {
4355
+ meeting.meetingRequest.keepAlive = sinon.stub().returns(Promise.resolve());
4356
+
4357
+ assert.isNull(meeting.keepAliveTimerId);
4358
+ meeting.joinedWith = {
4359
+ keepAliveUrl: defaultKeepAliveUrl,
4360
+ keepAliveSecs: defaultKeepAliveSecs
4361
+ };
4362
+ meeting.startKeepAlive();
4363
+ assert.isNumber(meeting.keepAliveTimerId.id);
4364
+ await testUtils.flushPromises();
4365
+ assert.notCalled(meeting.meetingRequest.keepAlive);
4366
+ await progressTime(defaultExpectedInterval);
4367
+ assert.calledOnceWithExactly(meeting.meetingRequest.keepAlive, {keepAliveUrl: defaultKeepAliveUrl});
4368
+ await progressTime(defaultExpectedInterval);
4369
+ assert.calledTwice(meeting.meetingRequest.keepAlive);
4370
+ assert.alwaysCalledWithExactly(meeting.meetingRequest.keepAlive, {keepAliveUrl: defaultKeepAliveUrl});
4371
+ });
4372
+ it('startKeepAlive handles existing keepAliveTimerId', async () => {
4373
+ meeting.meetingRequest.keepAlive = sinon.stub().returns(Promise.resolve());
4374
+ logger.warn = sinon.spy();
4375
+
4376
+ meeting.keepAliveTimerId = 7;
4377
+ meeting.joinedWith = {
4378
+ keepAliveUrl: defaultKeepAliveUrl,
4379
+ keepAliveSecs: defaultKeepAliveSecs
4380
+ };
4381
+ meeting.startKeepAlive();
4382
+ assert.equal(meeting.keepAliveTimerId, 7);
4383
+ await progressTime(defaultExpectedInterval);
4384
+ assert.notCalled(meeting.meetingRequest.keepAlive);
4385
+ });
4386
+ it('startKeepAlive handles missing keepAliveUrl', async () => {
4387
+ meeting.meetingRequest.keepAlive = sinon.stub().returns(Promise.resolve());
4388
+ logger.warn = sinon.spy();
4389
+
4390
+ assert.isNull(meeting.keepAliveTimerId);
4391
+ meeting.joinedWith = {
4392
+ keepAliveSecs: defaultKeepAliveSecs
4393
+ };
4394
+ meeting.startKeepAlive();
4395
+ assert.isNull(meeting.keepAliveTimerId);
4396
+ await progressTime(defaultExpectedInterval);
4397
+ assert.notCalled(meeting.meetingRequest.keepAlive);
4398
+ });
4399
+ it('startKeepAlive handles missing keepAliveSecs', async () => {
4400
+ meeting.meetingRequest.keepAlive = sinon.stub().returns(Promise.resolve());
4401
+ logger.warn = sinon.spy();
4402
+
4403
+ assert.isNull(meeting.keepAliveTimerId);
4404
+ meeting.joinedWith = {
4405
+ keepAliveUrl: defaultKeepAliveUrl
4406
+ };
4407
+ meeting.startKeepAlive();
4408
+ assert.isNull(meeting.keepAliveTimerId);
4409
+ await progressTime(1);
4410
+ assert.notCalled(meeting.meetingRequest.keepAlive);
4411
+ });
4412
+ it('startKeepAlive handles too low keepAliveSecs', async () => {
4413
+ meeting.meetingRequest.keepAlive = sinon.stub().returns(Promise.resolve());
4414
+ logger.warn = sinon.spy();
4415
+
4416
+ assert.isNull(meeting.keepAliveTimerId);
4417
+ meeting.joinedWith = {
4418
+ keepAliveUrl: defaultKeepAliveUrl,
4419
+ keepAliveSecs: 1
4420
+ };
4421
+ meeting.startKeepAlive();
4422
+ assert.isNull(meeting.keepAliveTimerId);
4423
+ await progressTime(1);
4424
+ assert.notCalled(meeting.meetingRequest.keepAlive);
4425
+ });
4426
+ it('failed keepAlive stops the keep alives', async () => {
4427
+ meeting.meetingRequest.keepAlive = sinon.stub().returns(Promise.reject());
4428
+
4429
+ assert.isNull(meeting.keepAliveTimerId);
4430
+ meeting.joinedWith = {
4431
+ keepAliveUrl: defaultKeepAliveUrl,
4432
+ keepAliveSecs: defaultKeepAliveSecs
4433
+ };
4434
+ meeting.startKeepAlive();
4435
+ assert.isNumber(meeting.keepAliveTimerId.id);
4436
+ await testUtils.flushPromises();
4437
+ assert.notCalled(meeting.meetingRequest.keepAlive);
4438
+ await progressTime(defaultExpectedInterval);
4439
+ assert.calledOnceWithExactly(meeting.meetingRequest.keepAlive, {keepAliveUrl: defaultKeepAliveUrl});
4440
+ assert.isNull(meeting.keepAliveTimerId);
4441
+ await progressTime(defaultExpectedInterval);
4442
+ assert.calledOnce(meeting.meetingRequest.keepAlive);
4443
+ });
4444
+ });
4445
+ describe('#stopKeepAlive', () => {
4446
+ let clock;
4447
+ const defaultKeepAliveUrl = 'keep.alive.url';
4448
+ const defaultKeepAliveSecs = 23;
4449
+ const defaultExpectedInterval = (defaultKeepAliveSecs - 1) * 750;
4450
+
4451
+ beforeEach(() => {
4452
+ clock = sinon.useFakeTimers();
4453
+ });
4454
+ afterEach(() => {
4455
+ clock.restore();
4456
+ });
4457
+
4458
+ const progressTime = async (interval) => {
4459
+ await clock.tickAsync(interval);
4460
+ await testUtils.flushPromises();
4461
+ };
4462
+
4463
+ it('stopKeepAlive stops the keep alive', async () => {
4464
+ meeting.meetingRequest.keepAlive = sinon.stub().returns(Promise.resolve());
4465
+
4466
+ assert.isNull(meeting.keepAliveTimerId);
4467
+ meeting.joinedWith = {
4468
+ keepAliveUrl: defaultKeepAliveUrl,
4469
+ keepAliveSecs: defaultKeepAliveSecs
4470
+ };
4471
+ meeting.startKeepAlive();
4472
+ assert.isNumber(meeting.keepAliveTimerId.id);
4473
+ await progressTime(defaultExpectedInterval);
4474
+ assert.calledOnceWithExactly(meeting.meetingRequest.keepAlive, {keepAliveUrl: defaultKeepAliveUrl});
4475
+
4476
+ meeting.stopKeepAlive();
4477
+ assert.isNull(meeting.keepAliveTimerId);
4478
+ await progressTime(defaultExpectedInterval);
4479
+ assert.calledOnce(meeting.meetingRequest.keepAlive);
4480
+ });
4481
+ it('stopKeepAlive handles missing keepAliveTimerId', async () => {
4482
+ assert.isNull(meeting.keepAliveTimerId);
4483
+ meeting.stopKeepAlive();
4484
+ });
4485
+ });
4331
4486
  });
4332
4487
  });
4333
4488
  });
@@ -264,5 +264,19 @@ describe('plugin-meetings', () => {
264
264
  assert.equal(requestParams.uri, `${locusUrl}/end`);
265
265
  });
266
266
  });
267
+
268
+ describe('#keepAlive', () => {
269
+ it('sends request to keepAlive', async () => {
270
+ const keepAliveUrl = 'keepAliveURL';
271
+
272
+ await meetingsRequest.keepAlive({
273
+ keepAliveUrl,
274
+ });
275
+ const requestParams = meetingsRequest.request.getCall(0).args[0];
276
+
277
+ assert.equal(requestParams.method, 'GET');
278
+ assert.equal(requestParams.uri, keepAliveUrl);
279
+ });
280
+ });
267
281
  });
268
282
  });
@@ -43,6 +43,7 @@ describe('plugin-meetings', () => {
43
43
  meeting.unsetPeerConnections = sinon.stub();
44
44
  meeting.reconnectionManager = {cleanUp: sinon.stub()};
45
45
  meeting.roap = {stop: sinon.stub()};
46
+ meeting.stopKeepAlive = sinon.stub();
46
47
  });
47
48
 
48
49
  afterEach(() => {
@@ -64,6 +65,7 @@ describe('plugin-meetings', () => {
64
65
  assert.calledOnce(meeting.unsetPeerConnections);
65
66
  assert.calledOnce(meeting.reconnectionManager.cleanUp);
66
67
  assert.calledOnce(meeting.roap.stop);
68
+ assert.calledOnce(meeting.stopKeepAlive);
67
69
  });
68
70
  });
69
71