@webex/plugin-meetings 3.12.0-next.93 → 3.12.0-next.95

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.
@@ -1,9 +1,12 @@
1
+ import 'jsdom-global/register';
1
2
  import {assert} from '@webex/test-helper-chai';
2
3
  import sinon from 'sinon';
4
+ import {CapabilityState, WebCapabilities} from '@webex/web-capabilities';
3
5
 
4
6
  import MeetingsUtil from '@webex/plugin-meetings/src/meetings/util';
5
7
  import Metrics from '@webex/plugin-meetings/src/metrics';
6
8
  import BEHAVIORAL_METRICS from '@webex/plugin-meetings/src/metrics/constants';
9
+ import LoggerProxy from '@webex/plugin-meetings/src/common/logs/logger-proxy';
7
10
 
8
11
  const multipartSitePrefixList = ['.my.', '.mydmz.', '.mybts.', '.mydev.', '.myats2.', '.myats.'];
9
12
 
@@ -77,6 +80,107 @@ describe('plugin-meetings', () => {
77
80
  });
78
81
  });
79
82
 
83
+ describe('#hasH264Codec', () => {
84
+ let isCapableOfReceivingVideoCodecStub;
85
+
86
+ beforeEach(() => {
87
+ isCapableOfReceivingVideoCodecStub = sinon.stub(
88
+ WebCapabilities,
89
+ 'isCapableOfReceivingVideoCodec'
90
+ );
91
+ });
92
+
93
+ it('returns true when video/H264 reports CAPABLE', async () => {
94
+ isCapableOfReceivingVideoCodecStub.withArgs('video/H264').returns(CapabilityState.CAPABLE);
95
+
96
+ const result = await MeetingsUtil.hasH264Codec();
97
+ assert.equal(result, true);
98
+ assert.calledOnceWithExactly(isCapableOfReceivingVideoCodecStub, 'video/H264');
99
+ });
100
+
101
+ it('returns false when video/H264 reports NOT_CAPABLE', async () => {
102
+ isCapableOfReceivingVideoCodecStub
103
+ .withArgs('video/H264')
104
+ .returns(CapabilityState.NOT_CAPABLE);
105
+
106
+ const result = await MeetingsUtil.hasH264Codec();
107
+ assert.equal(result, false);
108
+ assert.calledOnceWithExactly(isCapableOfReceivingVideoCodecStub, 'video/H264');
109
+ });
110
+
111
+ it('falls back to RTCPeerConnection when isCapableOfReceivingVideoCodec throws', async () => {
112
+ isCapableOfReceivingVideoCodecStub.throws(new Error('WebCapabilities unavailable'));
113
+ const mockPc = {createOffer: sinon.stub(), close: sinon.stub()};
114
+ global.window.RTCPeerConnection = sinon.stub().returns(mockPc);
115
+ mockPc.createOffer.resolves({sdp: 'v=0\r\na=rtpmap:96 H264/90000\r\n'});
116
+
117
+ assert.equal(await MeetingsUtil.hasH264Codec(), true);
118
+ assert.calledOnce(mockPc.close);
119
+
120
+ delete global.window.RTCPeerConnection;
121
+ });
122
+
123
+ describe('when video/H264 reports UNKNOWN (falls back to RTCPeerConnection)', () => {
124
+ let mockPc;
125
+
126
+ beforeEach(() => {
127
+ isCapableOfReceivingVideoCodecStub
128
+ .withArgs('video/H264')
129
+ .returns(CapabilityState.UNKNOWN);
130
+ mockPc = {createOffer: sinon.stub(), close: sinon.stub()};
131
+ global.window.RTCPeerConnection = sinon.stub().returns(mockPc);
132
+ });
133
+
134
+ afterEach(() => {
135
+ delete global.window.RTCPeerConnection;
136
+ });
137
+
138
+ it('returns true when SDP contains H264', async () => {
139
+ mockPc.createOffer.resolves({sdp: 'v=0\r\na=rtpmap:96 H264/90000\r\n'});
140
+
141
+ assert.equal(await MeetingsUtil.hasH264Codec(), true);
142
+ assert.calledOnce(mockPc.close);
143
+ });
144
+
145
+ it('returns false when SDP does not contain H264', async () => {
146
+ mockPc.createOffer.resolves({sdp: 'v=0\r\na=rtpmap:96 VP8/90000\r\n'});
147
+
148
+ assert.equal(await MeetingsUtil.hasH264Codec(), false);
149
+ assert.calledOnce(mockPc.close);
150
+ });
151
+
152
+ it('returns false when SDP is undefined', async () => {
153
+ mockPc.createOffer.resolves({sdp: undefined});
154
+
155
+ assert.equal(await MeetingsUtil.hasH264Codec(), false);
156
+ assert.calledOnce(mockPc.close);
157
+ });
158
+
159
+ it('logs a warning and returns false when createOffer throws', async () => {
160
+ sinon.stub(LoggerProxy.logger, 'warn');
161
+ mockPc.createOffer.rejects(new Error('createOffer failed'));
162
+
163
+ assert.equal(await MeetingsUtil.hasH264Codec(), false);
164
+ assert.calledOnce(mockPc.close);
165
+ assert.calledWith(
166
+ LoggerProxy.logger.warn,
167
+ 'Meetings:util#hasH264Codec --> Error creating peerConnection for H.264 test.'
168
+ );
169
+ });
170
+
171
+ it('logs a warning and returns false when RTCPeerConnection constructor throws', async () => {
172
+ sinon.stub(LoggerProxy.logger, 'warn');
173
+ global.window.RTCPeerConnection = sinon.stub().throws(new Error('no RTCPeerConnection'));
174
+
175
+ assert.equal(await MeetingsUtil.hasH264Codec(), false);
176
+ assert.calledWith(
177
+ LoggerProxy.logger.warn,
178
+ 'Meetings:util#hasH264Codec --> Error creating peerConnection for H.264 test.'
179
+ );
180
+ });
181
+ });
182
+ });
183
+
80
184
  describe('#getSiteName', () => {
81
185
  it('gets the site name from a standard Webex site', () => {
82
186
  assert.equal(MeetingsUtil.getSiteName('go.webex.com', multipartSitePrefixList), 'go');
@@ -107,25 +211,28 @@ describe('plugin-meetings', () => {
107
211
  it('return null if no matched device in self', () => {
108
212
  const newLocus = {
109
213
  self: {
110
- devices: [{state: 'JOINED', url: '456'}]
111
- }
214
+ devices: [{state: 'JOINED', url: '456'}],
215
+ },
112
216
  };
113
217
  assert.equal(MeetingsUtil.getThisDevice(newLocus, '123'), null);
114
218
  });
115
219
  it('return the device match with current device', () => {
116
220
  const newLocus = {
117
221
  self: {
118
- devices: [{state: 'JOINED', url: '123'}]
119
- }
222
+ devices: [{state: 'JOINED', url: '123'}],
223
+ },
120
224
  };
121
- assert.deepEqual(MeetingsUtil.getThisDevice(newLocus, '123'), {state: 'JOINED', url: '123'});
122
- })
225
+ assert.deepEqual(MeetingsUtil.getThisDevice(newLocus, '123'), {
226
+ state: 'JOINED',
227
+ url: '123',
228
+ });
229
+ });
123
230
  });
124
231
 
125
232
  describe('#isBreakoutLocusDTO', () => {
126
233
  it('returns false is no breakout in locus.controls', () => {
127
234
  const newLocus = {
128
- controls: {}
235
+ controls: {},
129
236
  };
130
237
 
131
238
  assert.equal(MeetingsUtil.isBreakoutLocusDTO(newLocus), false);
@@ -264,10 +371,26 @@ describe('plugin-meetings', () => {
264
371
 
265
372
  describe('#isWholeMeetingEnded', () => {
266
373
  [
267
- {description: 'state is INACTIVE with no endMeetingReason', fullState: {state: 'INACTIVE'}, expected: true},
268
- {description: 'state is INACTIVE with endMeetingReason OTHER', fullState: {state: 'INACTIVE', endMeetingReason: 'SOME_OTHER_REASON'}, expected: true},
269
- {description: 'state is INACTIVE with endMeetingReason BREAKOUT_ENDED', fullState: {state: 'INACTIVE', endMeetingReason: 'BREAKOUT_ENDED'}, expected: false},
270
- {description: 'state is not INACTIVE', fullState: {state: 'ACTIVE', endMeetingReason: 'SOME_OTHER_REASON'}, expected: false},
374
+ {
375
+ description: 'state is INACTIVE with no endMeetingReason',
376
+ fullState: {state: 'INACTIVE'},
377
+ expected: true,
378
+ },
379
+ {
380
+ description: 'state is INACTIVE with endMeetingReason OTHER',
381
+ fullState: {state: 'INACTIVE', endMeetingReason: 'SOME_OTHER_REASON'},
382
+ expected: true,
383
+ },
384
+ {
385
+ description: 'state is INACTIVE with endMeetingReason BREAKOUT_ENDED',
386
+ fullState: {state: 'INACTIVE', endMeetingReason: 'BREAKOUT_ENDED'},
387
+ expected: false,
388
+ },
389
+ {
390
+ description: 'state is not INACTIVE',
391
+ fullState: {state: 'ACTIVE', endMeetingReason: 'SOME_OTHER_REASON'},
392
+ expected: false,
393
+ },
271
394
  ].forEach(({description, fullState, expected}) => {
272
395
  it(`returns ${expected} when ${description}`, () => {
273
396
  assert.equal(MeetingsUtil.isWholeMeetingEnded(fullState), expected);
@@ -278,12 +401,42 @@ describe('plugin-meetings', () => {
278
401
  describe('#isSelfMovedOrBreakoutEnded', () => {
279
402
  [
280
403
  {description: 'locus is undefined', locus: undefined, expected: false},
281
- {description: 'self state is JOINED', locus: {self: {state: 'JOINED', reason: 'OTHER'}}, expected: false},
282
- {description: 'self state is LEFT with reason MOVED', locus: {self: {state: 'LEFT', reason: 'MOVED'}}, expected: true},
283
- {description: 'fullState is INACTIVE with BREAKOUT_ENDED', locus: {self: {state: 'LEFT', reason: 'OTHER'}, fullState: {state: 'INACTIVE', endMeetingReason: 'BREAKOUT_ENDED'}}, expected: true},
284
- {description: 'fullState is INACTIVE with different endMeetingReason', locus: {self: {state: 'LEFT', reason: 'OTHER'}, fullState: {state: 'INACTIVE', endMeetingReason: 'SOME_OTHER_REASON'}}, expected: false},
285
- {description: 'fullState is missing', locus: {self: {state: 'LEFT', reason: 'OTHER'}}, expected: false},
286
- {description: 'endMeetingReason is missing', locus: {self: {state: 'LEFT', reason: 'OTHER'}, fullState: {state: 'INACTIVE'}}, expected: false},
404
+ {
405
+ description: 'self state is JOINED',
406
+ locus: {self: {state: 'JOINED', reason: 'OTHER'}},
407
+ expected: false,
408
+ },
409
+ {
410
+ description: 'self state is LEFT with reason MOVED',
411
+ locus: {self: {state: 'LEFT', reason: 'MOVED'}},
412
+ expected: true,
413
+ },
414
+ {
415
+ description: 'fullState is INACTIVE with BREAKOUT_ENDED',
416
+ locus: {
417
+ self: {state: 'LEFT', reason: 'OTHER'},
418
+ fullState: {state: 'INACTIVE', endMeetingReason: 'BREAKOUT_ENDED'},
419
+ },
420
+ expected: true,
421
+ },
422
+ {
423
+ description: 'fullState is INACTIVE with different endMeetingReason',
424
+ locus: {
425
+ self: {state: 'LEFT', reason: 'OTHER'},
426
+ fullState: {state: 'INACTIVE', endMeetingReason: 'SOME_OTHER_REASON'},
427
+ },
428
+ expected: false,
429
+ },
430
+ {
431
+ description: 'fullState is missing',
432
+ locus: {self: {state: 'LEFT', reason: 'OTHER'}},
433
+ expected: false,
434
+ },
435
+ {
436
+ description: 'endMeetingReason is missing',
437
+ locus: {self: {state: 'LEFT', reason: 'OTHER'}, fullState: {state: 'INACTIVE'}},
438
+ expected: false,
439
+ },
287
440
  ].forEach(({description, locus, expected}) => {
288
441
  it(`returns ${expected} when ${description}`, () => {
289
442
  assert.equal(MeetingsUtil.isSelfMovedOrBreakoutEnded(locus), expected);
@@ -327,11 +480,11 @@ describe('plugin-meetings', () => {
327
480
  it('return true if joined on this device', () => {
328
481
  const newLocus = {
329
482
  self: {
330
- devices: [{state: 'JOINED', correlationId: '111', url: '123'}]
331
- }
483
+ devices: [{state: 'JOINED', correlationId: '111', url: '123'}],
484
+ },
332
485
  };
333
486
  const meeting = {
334
- correlationId: '111'
487
+ correlationId: '111',
335
488
  };
336
489
 
337
490
  assert.equal(MeetingsUtil.joinedOnThisDevice(meeting, newLocus, '123'), true);
@@ -339,18 +492,18 @@ describe('plugin-meetings', () => {
339
492
  it('return true if selfMoved on this device', () => {
340
493
  const newLocus = {
341
494
  self: {
342
- devices: [{state: 'LEFT', reason: 'MOVED', correlationId: '111', url: '123'}]
343
- }
495
+ devices: [{state: 'LEFT', reason: 'MOVED', correlationId: '111', url: '123'}],
496
+ },
344
497
  };
345
498
  const meeting = {
346
- correlationId: '111'
499
+ correlationId: '111',
347
500
  };
348
501
 
349
502
  assert.equal(MeetingsUtil.joinedOnThisDevice(meeting, newLocus, '123'), true);
350
503
  });
351
504
  });
352
505
 
353
- describe("#handleRoapMercury", () => {
506
+ describe('#handleRoapMercury', () => {
354
507
  let envelope;
355
508
  let meetingCollection;
356
509
  let roapMessageReceived;
@@ -365,67 +518,74 @@ describe('plugin-meetings', () => {
365
518
  id: 'meeting-id',
366
519
  roapMessageReceived,
367
520
  roap: {
368
- turnDiscovery: {handleTurnDiscoveryResponse}
369
- }
521
+ turnDiscovery: {handleTurnDiscoveryResponse},
522
+ },
370
523
  };
371
524
  envelope = {
372
525
  data: {
373
- message:{
374
- seq: "seq",
526
+ message: {
527
+ seq: 'seq',
375
528
  messageType: 'messageType',
376
529
  tieBreaker: 'tieBreaker',
377
530
  errorType: 'errorType',
378
531
  errorCause: 'errorCause',
379
- sdps: [{id:'sdp-1'}]
532
+ sdps: [{id: 'sdp-1'}],
380
533
  },
381
534
  correlationId: 'correlationId',
382
535
  eventType: 'locus.message.roap',
383
- }
536
+ },
384
537
  };
385
538
  meetingCollection = {
386
- getByKey: () => meeting
539
+ getByKey: () => meeting,
387
540
  };
388
541
  });
389
542
 
390
543
  it('it sends the correct behaviour metric', () => {
391
544
  MeetingsUtil.handleRoapMercury(envelope, meetingCollection);
392
- assert.calledWith(Metrics.sendBehavioralMetric, BEHAVIORAL_METRICS.ROAP_MERCURY_EVENT_RECEIVED, {
393
- correlation_id: 'correlationId',
394
- seq: "seq",
395
- message_type: 'messageType',
396
- error_type: 'errorType',
397
- error_cause: 'errorCause',
398
- })
545
+ assert.calledWith(
546
+ Metrics.sendBehavioralMetric,
547
+ BEHAVIORAL_METRICS.ROAP_MERCURY_EVENT_RECEIVED,
548
+ {
549
+ correlation_id: 'correlationId',
550
+ seq: 'seq',
551
+ message_type: 'messageType',
552
+ error_type: 'errorType',
553
+ error_cause: 'errorCause',
554
+ }
555
+ );
399
556
  assert.calledWith(roapMessageReceived, {
400
- seq: "seq",
557
+ seq: 'seq',
401
558
  messageType: 'messageType',
402
559
  errorType: 'errorType',
403
560
  tieBreaker: 'tieBreaker',
404
561
  errorCause: 'errorCause',
405
- sdp: {id:'sdp-1'}
406
- })
407
-
562
+ sdp: {id: 'sdp-1'},
563
+ });
408
564
  });
409
565
 
410
566
  it('calls handleTurnDiscoveryResponse for TURN_DISCOVERY_RESPONSE', () => {
411
567
  envelope.data.message.messageType = 'TURN_DISCOVERY_RESPONSE';
412
568
  delete envelope.data.message.sdps;
413
569
  MeetingsUtil.handleRoapMercury(envelope, meetingCollection);
414
- assert.calledWith(meeting.roap.turnDiscovery.handleTurnDiscoveryResponse, {
415
- seq: "seq",
416
- messageType: 'TURN_DISCOVERY_RESPONSE',
417
- errorType: 'errorType',
418
- tieBreaker: 'tieBreaker',
419
- errorCause: 'errorCause',
420
- }, 'from mercury')
570
+ assert.calledWith(
571
+ meeting.roap.turnDiscovery.handleTurnDiscoveryResponse,
572
+ {
573
+ seq: 'seq',
574
+ messageType: 'TURN_DISCOVERY_RESPONSE',
575
+ errorType: 'errorType',
576
+ tieBreaker: 'tieBreaker',
577
+ errorCause: 'errorCause',
578
+ },
579
+ 'from mercury'
580
+ );
421
581
  });
422
- })
582
+ });
423
583
  });
424
584
 
425
585
  describe('#isValidBreakoutLocus', () => {
426
586
  it('returns false if is not breakout locus', () => {
427
587
  const newLocus = {
428
- controls: {}
588
+ controls: {},
429
589
  };
430
590
 
431
591
  assert.equal(MeetingsUtil.isValidBreakoutLocus(newLocus), false);
@@ -439,8 +599,8 @@ describe('plugin-meetings', () => {
439
599
  },
440
600
  },
441
601
  fullState: {
442
- state: 'INACTIVE'
443
- }
602
+ state: 'INACTIVE',
603
+ },
444
604
  };
445
605
  assert.equal(MeetingsUtil.isValidBreakoutLocus(newLocus), false);
446
606
  });
@@ -453,11 +613,11 @@ describe('plugin-meetings', () => {
453
613
  },
454
614
  },
455
615
  fullState: {
456
- state: 'ACTIVE'
616
+ state: 'ACTIVE',
457
617
  },
458
618
  self: {
459
- state: 'LEFT'
460
- }
619
+ state: 'LEFT',
620
+ },
461
621
  };
462
622
  assert.equal(MeetingsUtil.isValidBreakoutLocus(newLocus), false);
463
623
  });
@@ -470,11 +630,11 @@ describe('plugin-meetings', () => {
470
630
  },
471
631
  },
472
632
  fullState: {
473
- state: 'ACTIVE'
633
+ state: 'ACTIVE',
474
634
  },
475
635
  self: {
476
- state: 'JOINED'
477
- }
636
+ state: 'JOINED',
637
+ },
478
638
  };
479
639
  assert.equal(MeetingsUtil.isValidBreakoutLocus(newLocus), true);
480
640
  });
@@ -482,10 +642,12 @@ describe('plugin-meetings', () => {
482
642
 
483
643
  describe('#getMediaServer', () => {
484
644
  it('returns the contents of o-line lower cased', () => {
485
- const sdp1 = 'v=0\r\no=homer 0 1 IN IP4 23.89.67.81\r\ns=-\r\nc=IN IP4 23.89.67.81\r\nb=TIAS:128000\r\nt=0 0\r\na=ice-lite\r\n'
645
+ const sdp1 =
646
+ 'v=0\r\no=homer 0 1 IN IP4 23.89.67.81\r\ns=-\r\nc=IN IP4 23.89.67.81\r\nb=TIAS:128000\r\nt=0 0\r\na=ice-lite\r\n';
486
647
  assert.equal(MeetingsUtil.getMediaServer(sdp1), 'homer');
487
648
 
488
- const sdp2 = 'v=0\r\no=HOMER 0 1 IN IP4 23.89.67.81\r\ns=-\r\nc=IN IP4 23.89.67.81\r\nb=TIAS:128000\r\nt=0 0\r\na=ice-lite\r\n'
649
+ const sdp2 =
650
+ 'v=0\r\no=HOMER 0 1 IN IP4 23.89.67.81\r\ns=-\r\nc=IN IP4 23.89.67.81\r\nb=TIAS:128000\r\nt=0 0\r\na=ice-lite\r\n';
489
651
  assert.equal(MeetingsUtil.getMediaServer(sdp2), 'homer');
490
652
  });
491
653
  });