@webex/plugin-meetings 3.12.0-next.181 → 3.12.0-next.183

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.
@@ -348,14 +348,18 @@ describe('SendSlotsManager', () => {
348
348
 
349
349
  describe('reset', () => {
350
350
  let mediaConnection;
351
+ let mockSlot: {unpublishStream: sinon.SinonStub};
351
352
 
352
353
  beforeEach(() => {
354
+ mockSlot = {
355
+ unpublishStream: sinon.stub().resolves(),
356
+ };
353
357
  mediaConnection = {
354
- createSendSlot: sinon.stub().returns({}),
358
+ createSendSlot: sinon.stub().returns(mockSlot),
355
359
  } as MultistreamRoapMediaConnection;
356
360
  });
357
361
 
358
- it('should reset the send slot manager', () => {
362
+ it('should unpublish and reset the send slot manager', () => {
359
363
  const AudioSlot = sendSlotsManager.createSlot(mediaConnection, MediaType.AudioMain);
360
364
  const VideoSlot = sendSlotsManager.createSlot(mediaConnection, MediaType.VideoMain);
361
365
  const AudioSlidesSlot = sendSlotsManager.createSlot(mediaConnection, MediaType.AudioSlides);
@@ -364,11 +368,35 @@ describe('SendSlotsManager', () => {
364
368
  expect(sendSlotsManager.getSlot(MediaType.VideoMain)).to.equal(VideoSlot);
365
369
  expect(sendSlotsManager.getSlot(MediaType.AudioSlides)).to.equal(AudioSlidesSlot);
366
370
  expect(sendSlotsManager.getSlot(MediaType.VideoSlides)).to.equal(VideoSlidesSlot);
371
+
367
372
  sendSlotsManager.reset();
373
+
368
374
  expect(() => sendSlotsManager.getSlot(MediaType.AudioMain)).to.throw();
369
375
  expect(() => sendSlotsManager.getSlot(MediaType.VideoMain)).to.throw();
370
376
  expect(() => sendSlotsManager.getSlot(MediaType.AudioSlides)).to.throw();
371
377
  expect(() => sendSlotsManager.getSlot(MediaType.VideoSlides)).to.throw();
378
+
379
+ // every slot must be unpublished (detaching its stream listeners) before being
380
+ // discarded, otherwise it stays subscribed to a stream that may be reused later
381
+ assert.callCount(mockSlot.unpublishStream, 4);
382
+ });
383
+
384
+ it('logs a warning and still clears the slots when unpublishStream rejects', async () => {
385
+ const error = new Error('cannot unpublish: peer connection is closed');
386
+ mockSlot.unpublishStream.rejects(error);
387
+
388
+ sendSlotsManager.createSlot(mediaConnection, MediaType.AudioMain);
389
+
390
+ sendSlotsManager.reset();
391
+
392
+ // allow the rejected unpublishStream promise's .catch() handler to run
393
+ await new Promise((resolve) => setImmediate(resolve));
394
+
395
+ expect(() => sendSlotsManager.getSlot(MediaType.AudioMain)).to.throw();
396
+ assert.calledWith(
397
+ LoggerProxy.logger.warn,
398
+ `SendSlotsManager->reset#Failed to unpublish stream for ${MediaType.AudioMain} while resetting: ${error.message}`
399
+ );
372
400
  });
373
401
  });
374
402