@webex/plugin-meetings 3.0.0-beta.213 → 3.0.0-beta.215

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.
@@ -188,6 +188,24 @@ const MeetingUtil = {
188
188
  });
189
189
  },
190
190
 
191
+ /**
192
+ * Returns options for leaving a meeting.
193
+ * @param {any} meeting
194
+ * @param {any} options
195
+ * @returns {any} leave options
196
+ */
197
+ prepareLeaveMeetingOptions: (meeting, options: any = {}) => {
198
+ const defaultOptions = {
199
+ locusUrl: meeting.locusUrl,
200
+ selfId: meeting.selfId,
201
+ correlationId: meeting.correlationId,
202
+ resourceId: meeting.resourceId,
203
+ deviceUrl: meeting.deviceUrl,
204
+ };
205
+
206
+ return {...defaultOptions, ...options};
207
+ },
208
+
191
209
  // by default will leave on meeting's resourceId
192
210
  // if you explicity want it not to leave on resource id, pass
193
211
  // {resourceId: null}
@@ -202,15 +220,7 @@ const MeetingUtil = {
202
220
  return Promise.reject(new UserNotJoinedError());
203
221
  }
204
222
 
205
- const defaultOptions = {
206
- locusUrl: meeting.locusUrl,
207
- selfId: meeting.selfId,
208
- correlationId: meeting.correlationId,
209
- resourceId: meeting.resourceId,
210
- deviceUrl: meeting.deviceUrl,
211
- };
212
-
213
- const leaveOptions = {...defaultOptions, ...options};
223
+ const leaveOptions = MeetingUtil.prepareLeaveMeetingOptions(meeting, options);
214
224
 
215
225
  return meeting.meetingRequest
216
226
  .leaveMeeting(leaveOptions)
@@ -302,6 +312,18 @@ const MeetingUtil = {
302
312
  });
303
313
  },
304
314
 
315
+ /**
316
+ * Returns request options for leaving a meeting.
317
+ * @param {any} meeting
318
+ * @param {any} options
319
+ * @returns {any} request options
320
+ */
321
+ buildLeaveFetchRequestOptions: (meeting, options: any = {}) => {
322
+ const leaveOptions = MeetingUtil.prepareLeaveMeetingOptions(meeting, options);
323
+
324
+ return meeting.meetingRequest.buildLeaveMeetingRequestOptions(leaveOptions);
325
+ },
326
+
305
327
  getTrack: (stream) => {
306
328
  let audioTrack = null;
307
329
  let videoTrack = null;
@@ -538,14 +560,14 @@ const MeetingUtil = {
538
560
  return response;
539
561
  },
540
562
 
541
- generateLocusDeltaRequest: (originalMeeting) => {
563
+ generateBuildLocusDeltaRequestOptions: (originalMeeting) => {
542
564
  const meetingRef = new WeakRef(originalMeeting);
543
565
 
544
- const locusDeltaRequest = (originalOptions) => {
566
+ const buildLocusDeltaRequestOptions = (originalOptions) => {
545
567
  const meeting = meetingRef.deref();
546
568
 
547
569
  if (!meeting) {
548
- return Promise.resolve();
570
+ return originalOptions;
549
571
  }
550
572
 
551
573
  const options = cloneDeep(originalOptions);
@@ -556,6 +578,27 @@ const MeetingUtil = {
556
578
 
557
579
  MeetingUtil.addSequence(meeting, options.body);
558
580
 
581
+ return options;
582
+ };
583
+
584
+ return buildLocusDeltaRequestOptions;
585
+ },
586
+
587
+ generateLocusDeltaRequest: (originalMeeting) => {
588
+ const meetingRef = new WeakRef(originalMeeting);
589
+
590
+ const buildLocusDeltaRequestOptions =
591
+ MeetingUtil.generateBuildLocusDeltaRequestOptions(originalMeeting);
592
+
593
+ const locusDeltaRequest = (originalOptions) => {
594
+ const meeting = meetingRef.deref();
595
+
596
+ if (!meeting) {
597
+ return Promise.resolve();
598
+ }
599
+
600
+ const options = buildLocusDeltaRequestOptions(originalOptions);
601
+
559
602
  return meeting
560
603
  .request(options)
561
604
  .then((response) => MeetingUtil.updateLocusWithDelta(meeting, response));
@@ -255,6 +255,7 @@ describe('plugin-meetings', () => {
255
255
  destination: testDestination,
256
256
  destinationType: _MEETING_ID_,
257
257
  correlationId,
258
+ selfId: uuid1,
258
259
  },
259
260
  {
260
261
  parent: webex,
@@ -262,6 +263,7 @@ describe('plugin-meetings', () => {
262
263
  );
263
264
 
264
265
  meeting.members.selfId = uuid1;
266
+ meeting.selfId = uuid1;
265
267
  });
266
268
 
267
269
  describe('meeting index', () => {
@@ -2487,7 +2489,7 @@ describe('plugin-meetings', () => {
2487
2489
  });
2488
2490
 
2489
2491
  it('should send client.call.leave after meetingRequest.leaveMeeting', async () => {
2490
- const leave = meeting.leave();
2492
+ const leave = meeting.leave({clientEventLeaveReason: 'ended-by-locus'});
2491
2493
 
2492
2494
  await leave;
2493
2495
 
@@ -2496,7 +2498,7 @@ describe('plugin-meetings', () => {
2496
2498
  payload: {
2497
2499
  trigger: 'user-interaction',
2498
2500
  canProceed: false,
2499
- leaveReason: 'CLIENT_LEAVE_REQUEST',
2501
+ leaveReason: 'ended-by-locus',
2500
2502
  },
2501
2503
  options: {meetingId: meeting.id},
2502
2504
  });
@@ -2520,7 +2522,7 @@ describe('plugin-meetings', () => {
2520
2522
  payload: {
2521
2523
  trigger: 'user-interaction',
2522
2524
  canProceed: false,
2523
- leaveReason: 'CLIENT_LEAVE_REQUEST',
2525
+ leaveReason: undefined,
2524
2526
  errors: [
2525
2527
  {
2526
2528
  fatal: false,
@@ -7961,4 +7963,39 @@ describe('plugin-meetings', () => {
7961
7963
  });
7962
7964
  });
7963
7965
  });
7966
+
7967
+ describe('#buildLeaveFetchRequestOptions', () => {
7968
+ it('should have #buildLeaveFetchRequestOptions', () => {
7969
+ assert.exists(meeting.buildLeaveFetchRequestOptions);
7970
+ });
7971
+
7972
+ it('calls expected functions', () => {
7973
+ const buildLeaveFetchRequestOptionsSpy = sinon.spy(
7974
+ MeetingUtil,
7975
+ 'buildLeaveFetchRequestOptions'
7976
+ );
7977
+ const prepareFetchOptionsSpy = sinon.stub();
7978
+ webex.prepareFetchOptions = prepareFetchOptionsSpy;
7979
+
7980
+ meeting.buildLeaveFetchRequestOptions({resourceId: 'foo'});
7981
+
7982
+ assert.calledOnce(buildLeaveFetchRequestOptionsSpy);
7983
+ assert.instanceOf(buildLeaveFetchRequestOptionsSpy.getCall(0).args[0], Meeting);
7984
+ assert.deepEqual(buildLeaveFetchRequestOptionsSpy.getCall(0).args[1], {resourceId: 'foo'});
7985
+
7986
+ assert.calledOnce(prepareFetchOptionsSpy);
7987
+ assert.deepEqual(prepareFetchOptionsSpy.getCall(0).args[0], {
7988
+ body: {
7989
+ correlationId: meeting.correlationId,
7990
+ device: {
7991
+ deviceType: undefined,
7992
+ url: uuid3,
7993
+ },
7994
+ usingResource: 'foo',
7995
+ },
7996
+ method: 'PUT',
7997
+ uri: `${url1}/participant/${uuid1}/leave`,
7998
+ });
7999
+ });
8000
+ });
7964
8001
  });
@@ -4,8 +4,7 @@ import MockWebex from '@webex/test-helper-mock-webex';
4
4
  import Meetings from '@webex/plugin-meetings';
5
5
  import MeetingRequest from '@webex/plugin-meetings/src/meeting/request';
6
6
  import uuid from 'uuid';
7
- import { merge } from 'lodash';
8
-
7
+ import {merge} from 'lodash';
9
8
 
10
9
  describe('plugin-meetings', () => {
11
10
  let meetingsRequest;
@@ -30,7 +29,9 @@ describe('plugin-meetings', () => {
30
29
  },
31
30
  };
32
31
 
33
- webex.boundedStorage.get = sinon.mock().returns(Promise.resolve(JSON.stringify({anycastEntryPoint: "aws-eu-west-1"})))
32
+ webex.boundedStorage.get = sinon
33
+ .mock()
34
+ .returns(Promise.resolve(JSON.stringify({anycastEntryPoint: 'aws-eu-west-1'})));
34
35
 
35
36
  const request = sinon.mock().returns(Promise.resolve({}));
36
37
 
@@ -39,9 +40,9 @@ describe('plugin-meetings', () => {
39
40
  meeting: {
40
41
  request,
41
42
  locusInfo: {
42
- sequence: {}
43
- }
44
- }
43
+ sequence: {},
44
+ },
45
+ },
45
46
  },
46
47
  {
47
48
  parent: webex,
@@ -54,11 +55,13 @@ describe('plugin-meetings', () => {
54
55
 
55
56
  const checkRequest = (expectedParams) => {
56
57
  assert.calledOnceWithExactly(locusDeltaRequestSpy, expectedParams);
57
- assert.calledOnceWithExactly(meetingsRequest.request, merge(expectedParams, {body: {sequence: {}}}));
58
- }
58
+ assert.calledOnceWithExactly(
59
+ meetingsRequest.request,
60
+ merge(expectedParams, {body: {sequence: {}}})
61
+ );
62
+ };
59
63
 
60
64
  describe('meeting request library', () => {
61
-
62
65
  beforeEach(() => {
63
66
  sinon.stub(uuid, 'v4').returns('12345');
64
67
  });
@@ -73,8 +76,6 @@ describe('plugin-meetings', () => {
73
76
  const deviceUrl = 'deviceUrl';
74
77
  const tones = '1234';
75
78
 
76
-
77
-
78
79
  await meetingsRequest.sendDTMF({
79
80
  locusUrl,
80
81
  deviceUrl,
@@ -236,7 +237,7 @@ describe('plugin-meetings', () => {
236
237
 
237
238
  it('adds deviceCapabilities to request when breakouts are supported', async () => {
238
239
  await meetingsRequest.joinMeeting({
239
- breakoutsSupported: true
240
+ breakoutsSupported: true,
240
241
  });
241
242
  const requestParams = meetingsRequest.request.getCall(0).args[0];
242
243
 
@@ -245,7 +246,7 @@ describe('plugin-meetings', () => {
245
246
 
246
247
  it('adds deviceCapabilities to request when live annotation are supported', async () => {
247
248
  await meetingsRequest.joinMeeting({
248
- liveAnnotationSupported: true
249
+ liveAnnotationSupported: true,
249
250
  });
250
251
  const requestParams = meetingsRequest.request.getCall(0).args[0];
251
252
  assert.deepEqual(requestParams.body.deviceCapabilities, ['ANNOTATION_ON_SHARE_SUPPORTED']);
@@ -256,7 +257,10 @@ describe('plugin-meetings', () => {
256
257
  breakoutsSupported: true,
257
258
  });
258
259
  const requestParams = meetingsRequest.request.getCall(0).args[0];
259
- assert.deepEqual(requestParams.body.deviceCapabilities, ['BREAKOUTS_SUPPORTED','ANNOTATION_ON_SHARE_SUPPORTED']);
260
+ assert.deepEqual(requestParams.body.deviceCapabilities, [
261
+ 'BREAKOUTS_SUPPORTED',
262
+ 'ANNOTATION_ON_SHARE_SUPPORTED',
263
+ ]);
260
264
  });
261
265
  it('does not add deviceCapabilities to request when breakouts and live annotation are not supported', async () => {
262
266
  await meetingsRequest.joinMeeting({});
@@ -264,17 +268,18 @@ describe('plugin-meetings', () => {
264
268
  const requestParams = meetingsRequest.request.getCall(0).args[0];
265
269
 
266
270
  assert.deepEqual(requestParams.body.deviceCapabilities, undefined);
267
-
268
271
  });
269
272
 
270
273
  it('adds deviceCapabilities and locale to request when they are provided', async () => {
271
274
  await meetingsRequest.joinMeeting({
272
275
  locale: 'en_UK',
273
- deviceCapabilities: ['SERVER_AUDIO_ANNOUNCEMENT_SUPPORTED']
276
+ deviceCapabilities: ['SERVER_AUDIO_ANNOUNCEMENT_SUPPORTED'],
274
277
  });
275
278
  const requestParams = meetingsRequest.request.getCall(0).args[0];
276
279
 
277
- assert.deepEqual(requestParams.body.deviceCapabilities, ['SERVER_AUDIO_ANNOUNCEMENT_SUPPORTED']);
280
+ assert.deepEqual(requestParams.body.deviceCapabilities, [
281
+ 'SERVER_AUDIO_ANNOUNCEMENT_SUPPORTED',
282
+ ]);
278
283
  assert.deepEqual(requestParams.body.locale, 'en_UK');
279
284
  });
280
285
 
@@ -305,8 +310,8 @@ describe('plugin-meetings', () => {
305
310
  assert.equal(requestParams.method, 'POST');
306
311
  assert.equal(requestParams.uri, `${locusUrl}/participant?alternateRedirect=true`);
307
312
  assert.deepEqual(requestParams.body.clientMediaPreferences, {
308
- "joinCookie": {anycastEntryPoint: "aws-eu-west-1"},
309
- "preferTranscoding": true
313
+ joinCookie: {anycastEntryPoint: 'aws-eu-west-1'},
314
+ preferTranscoding: true,
310
315
  });
311
316
  });
312
317
  });
@@ -335,8 +340,8 @@ describe('plugin-meetings', () => {
335
340
  provisionalType: 'DIAL_IN',
336
341
  clientUrl,
337
342
  },
338
- correlationId
339
- }
343
+ correlationId,
344
+ },
340
345
  });
341
346
  });
342
347
 
@@ -369,7 +374,6 @@ describe('plugin-meetings', () => {
369
374
  correlationId,
370
375
  },
371
376
  });
372
-
373
377
  });
374
378
 
375
379
  it('sends disconnect phone audio request', async () => {
@@ -391,10 +395,10 @@ describe('plugin-meetings', () => {
391
395
  body: {
392
396
  device: {
393
397
  url: phoneUrl,
394
- deviceType: 'PROVISIONAL'
398
+ deviceType: 'PROVISIONAL',
395
399
  },
396
- correlationId
397
- }
400
+ correlationId,
401
+ },
398
402
  });
399
403
  });
400
404
  });
@@ -467,13 +471,12 @@ describe('plugin-meetings', () => {
467
471
  method: 'PATCH',
468
472
  uri: `${locusUrl}/controls`,
469
473
  body: {
470
- lock: {locked: true}
471
- }
474
+ lock: {locked: true},
475
+ },
472
476
  });
473
477
  });
474
478
  });
475
479
 
476
-
477
480
  describe('#endMeetingForAll', () => {
478
481
  it('sends request to endMeetingForAll', async () => {
479
482
  const locusUrl = 'locusURL';
@@ -551,10 +554,83 @@ describe('plugin-meetings', () => {
551
554
  });
552
555
  });
553
556
  });
557
+
558
+ describe('#prepareLeaveMeetingRequestOptions', () => {
559
+ it('returns expected result', async () => {
560
+ const result = meetingsRequest.prepareLeaveMeetingRequestOptions({
561
+ locusUrl: 'locusUrl',
562
+ selfId: 'selfId',
563
+ correlationId: 'correlationId',
564
+ resourceId: 'resourceId',
565
+ deviceUrl: 'deviceUrl',
566
+ });
567
+
568
+ assert.deepEqual(result, {
569
+ body: {
570
+ correlationId: 'correlationId',
571
+ device: {
572
+ deviceType: undefined,
573
+ url: 'deviceUrl',
574
+ },
575
+ usingResource: 'resourceId',
576
+ },
577
+ method: 'PUT',
578
+ uri: 'locusUrl/participant/selfId/leave',
579
+ });
580
+ });
581
+ });
582
+
583
+ describe('#buildLeaveMeetingRequestOptions', () => {
584
+ it('calls expected functions and returns expected result', async () => {
585
+ // return this.buildLocusDeltaRequestOptions(this.prepareLeaveMeetingRequestOptions(options));
586
+ const prepareLeaveMeetingRequestOptionsSpy = sinon.spy(
587
+ meetingsRequest,
588
+ 'prepareLeaveMeetingRequestOptions'
589
+ );
590
+ const buildLocusDeltaRequestOptionsSpy = sinon.spy(
591
+ meetingsRequest,
592
+ 'buildLocusDeltaRequestOptions'
593
+ );
594
+
595
+ const inputOpts = {
596
+ locusUrl: 'locusUrl',
597
+ selfId: 'selfId',
598
+ correlationId: 'correlationId',
599
+ resourceId: 'resourceId',
600
+ deviceUrl: 'deviceUrl',
601
+ };
602
+
603
+ const result = meetingsRequest.buildLeaveMeetingRequestOptions(inputOpts);
604
+
605
+ assert.calledOnceWithExactly(prepareLeaveMeetingRequestOptionsSpy, inputOpts);
606
+ assert.calledOnceWithExactly(buildLocusDeltaRequestOptionsSpy, {
607
+ method: 'PUT',
608
+ uri: 'locusUrl/participant/selfId/leave',
609
+ body: {
610
+ device: {deviceType: undefined, url: 'deviceUrl'},
611
+ usingResource: 'resourceId',
612
+ correlationId: 'correlationId',
613
+ },
614
+ });
615
+
616
+ assert.deepEqual(result, {
617
+ body: {
618
+ correlationId: 'correlationId',
619
+ device: {
620
+ deviceType: undefined,
621
+ url: 'deviceUrl',
622
+ },
623
+ sequence: {},
624
+ usingResource: 'resourceId',
625
+ },
626
+ method: 'PUT',
627
+ uri: 'locusUrl/participant/selfId/leave',
628
+ });
629
+ });
630
+ });
554
631
  });
555
632
 
556
633
  describe('#declineMeeting', () => {
557
-
558
634
  it('sends a request to decline the meeting', async () => {
559
635
  const reason = 'reason';
560
636
  const deviceUrl = 'deviceUrl';
@@ -564,7 +640,7 @@ describe('plugin-meetings', () => {
564
640
  await meetingsRequest.declineMeeting({
565
641
  locusUrl,
566
642
  deviceUrl,
567
- reason
643
+ reason,
568
644
  });
569
645
 
570
646
  const expectedBody = {
@@ -581,7 +657,6 @@ describe('plugin-meetings', () => {
581
657
  body: expectedBody,
582
658
  });
583
659
  });
584
-
585
660
  });
586
661
 
587
662
  describe('#getLocusStatusByUrl', () => {
@@ -592,12 +667,11 @@ describe('plugin-meetings', () => {
592
667
  assert.deepEqual(meetingsRequest.request.getCall(0).args[0], {
593
668
  method: 'GET',
594
669
  uri: locusUrl,
595
- })
670
+ });
596
671
  });
597
672
  });
598
673
 
599
674
  describe('#changeMeetingFloor', () => {
600
-
601
675
  it('change meeting floor', async () => {
602
676
  const options = {
603
677
  disposition: 'GRANTED',
@@ -606,11 +680,11 @@ describe('plugin-meetings', () => {
606
680
  resourceId: 'resourceId',
607
681
  resourceUrl: 'resourceUrl',
608
682
  uri: 'optionsUrl',
609
- annotationInfo:{
683
+ annotationInfo: {
610
684
  version: '1',
611
685
  policy: 'Approval',
612
686
  },
613
- }
687
+ };
614
688
 
615
689
  const expectBody = {
616
690
  annotation: {
@@ -622,27 +696,26 @@ describe('plugin-meetings', () => {
622
696
  devices: [
623
697
  {
624
698
  deviceType: undefined,
625
- url: "deviceUrl"
626
- }
699
+ url: 'deviceUrl',
700
+ },
627
701
  ],
628
702
  url: 'personUrl',
629
703
  },
630
704
  disposition: 'GRANTED',
631
705
  requester: {
632
- "url": "personUrl"
633
- }
706
+ url: 'personUrl',
707
+ },
634
708
  },
635
709
  resourceUrl: 'resourceUrl',
636
710
  };
637
711
 
638
-
639
712
  await meetingsRequest.changeMeetingFloor(options);
640
713
 
641
714
  assert.deepEqual(meetingsRequest.request.getCall(0).args[0], {
642
715
  method: 'PUT',
643
716
  uri: 'optionsUrl',
644
717
  body: expectBody,
645
- })
718
+ });
646
719
  });
647
720
  });
648
721
  });