@webex/plugin-meetings 3.0.0-beta.50 → 3.0.0-beta.52

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.
@@ -5,7 +5,7 @@ import {BREAKOUTS} from '@webex/plugin-meetings/src/constants';
5
5
  import sinon from 'sinon';
6
6
  import MockWebex from '@webex/test-helper-mock-webex';
7
7
  import testUtils from '../../../utils/testUtils';
8
- import BreakoutEditLockedError from "@webex/plugin-meetings/src/breakouts/edit-lock-error";
8
+ import BreakoutEditLockedError from '@webex/plugin-meetings/src/breakouts/edit-lock-error';
9
9
 
10
10
  const getBOResponse = (status: string) => {
11
11
  return {
@@ -347,13 +347,13 @@ describe('plugin-meetings', () => {
347
347
  enableBreakoutSession: true,
348
348
  startTime: 'startTime',
349
349
  status: 'active',
350
- locusUrl: 'locusUrl'
350
+ locusUrl: 'locusUrl',
351
351
  });
352
352
  const payload = {
353
353
  breakoutSessions: {
354
354
  active: [{sessionId: 'sessionId1'}],
355
- }
356
- }
355
+ },
356
+ };
357
357
  breakouts.updateBreakoutSessions(payload);
358
358
 
359
359
  breakouts.set('sessionType', BREAKOUTS.SESSION_TYPES.MAIN);
@@ -363,8 +363,8 @@ describe('plugin-meetings', () => {
363
363
  const payload2 = {
364
364
  breakoutSessions: {
365
365
  active: [{sessionId: 'sessionId1', sessionType: BREAKOUTS.SESSION_TYPES.MAIN}],
366
- }
367
- }
366
+ },
367
+ };
368
368
  breakouts.updateBreakoutSessions(payload2);
369
369
  breakouts.set('sessionType', 'BREAKOUT');
370
370
  result = breakouts.getMainSession();
@@ -373,12 +373,12 @@ describe('plugin-meetings', () => {
373
373
  it('throw error if cannot find main session', () => {
374
374
  const fn = () => {
375
375
  breakouts.getMainSession();
376
- }
376
+ };
377
377
  expect(fn).to.throw(/no main session found/);
378
378
  });
379
379
  });
380
380
 
381
- describe('#askAllToReturn', () => {
381
+ describe('#askAllToReturn', () => {
382
382
  it('makes the request as expected', async () => {
383
383
  breakouts.set('sessionType', BREAKOUTS.SESSION_TYPES.MAIN);
384
384
  breakouts.currentBreakoutSession.sessionId = 'sessionId';
@@ -389,8 +389,8 @@ describe('plugin-meetings', () => {
389
389
  uri: 'url/requestMove',
390
390
  body: {
391
391
  groupId: 'groupId',
392
- sessionId: 'sessionId'
393
- }
392
+ sessionId: 'sessionId',
393
+ },
394
394
  });
395
395
  });
396
396
  });
@@ -403,16 +403,18 @@ describe('plugin-meetings', () => {
403
403
  });
404
404
 
405
405
  describe('#toggleBreakout', () => {
406
- it('enableBreakoutSession is undefined, run enableBreakouts then toggleBreakout', async() => {
406
+ it('enableBreakoutSession is undefined, run enableBreakouts then toggleBreakout', async () => {
407
407
  breakouts.enableBreakoutSession = undefined;
408
- breakouts.enableBreakouts = sinon.stub().resolves(({body: {
409
- sessionId: 'sessionId',
410
- groupId: 'groupId',
411
- name: 'name',
412
- current: true,
413
- sessionType: 'sessionType',
414
- url: 'url'
415
- }}))
408
+ breakouts.enableBreakouts = sinon.stub().resolves({
409
+ body: {
410
+ sessionId: 'sessionId',
411
+ groupId: 'groupId',
412
+ name: 'name',
413
+ current: true,
414
+ sessionType: 'sessionType',
415
+ url: 'url',
416
+ },
417
+ });
416
418
  breakouts.updateBreakout = sinon.stub().resolves();
417
419
  breakouts.doToggleBreakout = sinon.stub().resolves();
418
420
 
@@ -424,12 +426,12 @@ describe('plugin-meetings', () => {
424
426
  name: 'name',
425
427
  current: true,
426
428
  sessionType: 'sessionType',
427
- url: 'url'
429
+ url: 'url',
428
430
  });
429
431
  assert.calledOnceWithExactly(breakouts.doToggleBreakout, false);
430
432
  });
431
433
 
432
- it('enableBreakoutSession is exist, run toggleBreakout', async() => {
434
+ it('enableBreakoutSession is exist, run toggleBreakout', async () => {
433
435
  breakouts.enableBreakoutSession = true;
434
436
  breakouts.doToggleBreakout = sinon.stub().resolves();
435
437
  await breakouts.toggleBreakout(true);
@@ -445,17 +447,19 @@ describe('plugin-meetings', () => {
445
447
  method: 'POST',
446
448
  uri: 'breakoutServiceUrl',
447
449
  body: {
448
- locusUrl: 'locusUrl'
449
- }
450
+ locusUrl: 'locusUrl',
451
+ },
450
452
  });
451
453
 
452
454
  assert.equal(result, 'REQUEST_RETURN_VALUE');
453
455
  });
454
456
  });
455
457
 
456
- describe('#broadcast', () => {
458
+ describe('#broadcast', () => {
457
459
  it('makes the request as expected', async () => {
458
- breakouts.breakoutRequest.broadcast = sinon.stub().returns(Promise.resolve('REQUEST_RETURN_VALUE'));
460
+ breakouts.breakoutRequest.broadcast = sinon
461
+ .stub()
462
+ .returns(Promise.resolve('REQUEST_RETURN_VALUE'));
459
463
  webex.request.returns(
460
464
  Promise.resolve({
461
465
  body: getBOResponse('OPEN'),
@@ -467,7 +471,7 @@ describe('plugin-meetings', () => {
467
471
  url: 'url',
468
472
  message: 'hello',
469
473
  options: undefined,
470
- groupId: 'groupId'
474
+ groupId: 'groupId',
471
475
  });
472
476
 
473
477
  assert.equal(result, 'REQUEST_RETURN_VALUE');
@@ -477,16 +481,16 @@ describe('plugin-meetings', () => {
477
481
  url: 'url',
478
482
  groupId: 'groupId',
479
483
  message: 'hello',
480
- options: {presenters: true, cohosts: true}
484
+ options: {presenters: true, cohosts: true},
481
485
  });
482
- assert.equal(result, 'REQUEST_RETURN_VALUE')
486
+ assert.equal(result, 'REQUEST_RETURN_VALUE');
483
487
  });
484
488
 
485
489
  it('throw error if no breakout group id found', () => {
486
490
  breakouts.set('sessionType', BREAKOUTS.SESSION_TYPES.MAIN);
487
491
  const fn = () => {
488
492
  breakouts.broadcast('hello');
489
- }
493
+ };
490
494
  expect(fn).to.throw(/no breakout session found/);
491
495
  });
492
496
  });
@@ -511,25 +515,39 @@ describe('plugin-meetings', () => {
511
515
 
512
516
  assert.equal(arg.uri, 'url');
513
517
  assert.equal(arg.method, 'PUT');
514
- assert.deepEqual(argObj1, {id:'groupId', action: 'START', allowBackToMain: false, allowToJoinLater: false, duration: BREAKOUTS.DEFAULT_DURATION});
515
- assert.deepEqual(argObj2, {id:'id', action: 'START', allowBackToMain: false, allowToJoinLater: false, someOtherParam: 'someOtherParam', duration: BREAKOUTS.DEFAULT_DURATION});
518
+ assert.deepEqual(argObj1, {
519
+ id: 'groupId',
520
+ action: 'START',
521
+ allowBackToMain: false,
522
+ allowToJoinLater: false,
523
+ duration: BREAKOUTS.DEFAULT_DURATION,
524
+ });
525
+ assert.deepEqual(argObj2, {
526
+ id: 'id',
527
+ action: 'START',
528
+ allowBackToMain: false,
529
+ allowToJoinLater: false,
530
+ someOtherParam: 'someOtherParam',
531
+ duration: BREAKOUTS.DEFAULT_DURATION,
532
+ });
516
533
  assert.deepEqual(result, {body: getBOResponse('OPEN')});
517
534
  });
518
535
 
519
536
  it('rejects when edit lock token mismatch', async () => {
520
- webex.request.returns(Promise.reject({
521
- body: {
522
- "errorCode":BREAKOUTS.ERROR_CODE.EDIT_LOCK_TOKEN_MISMATCH,
523
- "message":"Edit lock token mismatch"
524
- }
525
- }));
537
+ webex.request.returns(
538
+ Promise.reject({
539
+ body: {
540
+ errorCode: BREAKOUTS.ERROR_CODE.EDIT_LOCK_TOKEN_MISMATCH,
541
+ message: 'Edit lock token mismatch',
542
+ },
543
+ })
544
+ );
526
545
 
527
546
  await assert.isRejected(
528
547
  breakouts.start(),
529
548
  BreakoutEditLockedError,
530
549
  'Edit lock token mismatch'
531
550
  );
532
-
533
551
  });
534
552
  });
535
553
 
@@ -553,25 +571,31 @@ describe('plugin-meetings', () => {
553
571
 
554
572
  assert.equal(arg.uri, 'url');
555
573
  assert.equal(arg.method, 'PUT');
556
- assert.deepEqual(argObj1, {id:'groupId', action: 'CLOSE', delayCloseTime: 60});
557
- assert.deepEqual(argObj2, {id:'id', action: 'CLOSE', delayCloseTime: 60, someOtherParam: 'someOtherParam'});
574
+ assert.deepEqual(argObj1, {id: 'groupId', action: 'CLOSE', delayCloseTime: 60});
575
+ assert.deepEqual(argObj2, {
576
+ id: 'id',
577
+ action: 'CLOSE',
578
+ delayCloseTime: 60,
579
+ someOtherParam: 'someOtherParam',
580
+ });
558
581
  assert.deepEqual(result, {body: getBOResponse('CLOSING')});
559
582
  });
560
583
 
561
584
  it('rejects when edit lock token mismatch', async () => {
562
- webex.request.returns(Promise.reject({
563
- body: {
564
- "errorCode":BREAKOUTS.ERROR_CODE.EDIT_LOCK_TOKEN_MISMATCH,
565
- "message":"Edit lock token mismatch"
566
- }
567
- }));
585
+ webex.request.returns(
586
+ Promise.reject({
587
+ body: {
588
+ errorCode: BREAKOUTS.ERROR_CODE.EDIT_LOCK_TOKEN_MISMATCH,
589
+ message: 'Edit lock token mismatch',
590
+ },
591
+ })
592
+ );
568
593
 
569
594
  await assert.isRejected(
570
595
  breakouts.end(),
571
596
  BreakoutEditLockedError,
572
597
  'Edit lock token mismatch'
573
598
  );
574
-
575
599
  });
576
600
  });
577
601
 
@@ -605,8 +629,8 @@ describe('plugin-meetings', () => {
605
629
  method: 'PUT',
606
630
  uri: 'url',
607
631
  body: {
608
- enableBreakoutSession: true
609
- }
632
+ enableBreakoutSession: true,
633
+ },
610
634
  });
611
635
 
612
636
  assert.equal(result, 'REQUEST_RETURN_VALUE');
@@ -615,15 +639,19 @@ describe('plugin-meetings', () => {
615
639
 
616
640
  describe('delete', () => {
617
641
  it('makes the request as expected', async () => {
618
- webex.request.returns(Promise.resolve({
619
- body: {
620
- groups: [{
621
- id : "455556a4-37cd-4baa-89bc-8730581a1cc0",
622
- status : "CLOSE",
623
- type : "BREAKOUT",
624
- }]
625
- }
626
- }));
642
+ webex.request.returns(
643
+ Promise.resolve({
644
+ body: {
645
+ groups: [
646
+ {
647
+ id: '455556a4-37cd-4baa-89bc-8730581a1cc0',
648
+ status: 'CLOSE',
649
+ type: 'BREAKOUT',
650
+ },
651
+ ],
652
+ },
653
+ })
654
+ );
627
655
 
628
656
  const result = await breakouts.clearSessions();
629
657
  assert.calledOnceWithExactly(webex.request, {
@@ -635,66 +663,71 @@ describe('plugin-meetings', () => {
635
663
  action: BREAKOUTS.ACTION.DELETE,
636
664
  },
637
665
  ],
638
- }
666
+ },
639
667
  });
640
668
 
641
- assert.equal(breakouts.groups[0].status, "CLOSE")
669
+ assert.equal(breakouts.groups[0].status, 'CLOSE');
642
670
  });
643
671
 
644
672
  it('rejects when edit lock token mismatch', async () => {
645
- webex.request.returns(Promise.reject({
646
- body: {
647
- "errorCode":BREAKOUTS.ERROR_CODE.EDIT_LOCK_TOKEN_MISMATCH,
648
- "message":"Edit lock token mismatch"
649
- }
650
- }));
673
+ webex.request.returns(
674
+ Promise.reject({
675
+ body: {
676
+ errorCode: BREAKOUTS.ERROR_CODE.EDIT_LOCK_TOKEN_MISMATCH,
677
+ message: 'Edit lock token mismatch',
678
+ },
679
+ })
680
+ );
651
681
 
652
682
  await assert.isRejected(
653
683
  breakouts.clearSessions(),
654
684
  BreakoutEditLockedError,
655
685
  'Edit lock token mismatch'
656
686
  );
657
-
658
687
  });
659
688
  });
660
689
 
661
690
  describe('create', () => {
662
691
  it('response not include groups info', async () => {
663
- const sessions = [{'name':'session1', "anyoneCanJoin" : true}];
692
+ const sessions = [{name: 'session1', anyoneCanJoin: true}];
664
693
  const result = await breakouts.create(sessions);
665
694
 
666
695
  assert.equal(result, 'REQUEST_RETURN_VALUE');
667
-
668
696
  });
669
697
 
670
698
  it('response include groups info', async () => {
671
- const sessions = [{'name':'session1', "anyoneCanJoin" : true}];
699
+ const sessions = [{name: 'session1', anyoneCanJoin: true}];
672
700
 
673
- webex.request.returns(Promise.resolve({
674
- body: {
675
- groups: [{
676
- id : "455556a4-37cd-4baa-89bc-8730581a1cc0",
677
- status : "PENDING",
678
- type : "BREAKOUT",
679
- }]
680
- }
681
- }));
701
+ webex.request.returns(
702
+ Promise.resolve({
703
+ body: {
704
+ groups: [
705
+ {
706
+ id: '455556a4-37cd-4baa-89bc-8730581a1cc0',
707
+ status: 'PENDING',
708
+ type: 'BREAKOUT',
709
+ },
710
+ ],
711
+ },
712
+ })
713
+ );
682
714
 
683
715
  const result = await breakouts.create(sessions);
684
716
 
685
- assert.equal(breakouts.groups[0].id, "455556a4-37cd-4baa-89bc-8730581a1cc0")
686
-
717
+ assert.equal(breakouts.groups[0].id, '455556a4-37cd-4baa-89bc-8730581a1cc0');
687
718
  });
688
719
 
689
720
  it('rejects when edit lock token mismatch', async () => {
690
- const sessions = [{'name':'session1', "anyoneCanJoin" : true}];
721
+ const sessions = [{name: 'session1', anyoneCanJoin: true}];
691
722
 
692
- webex.request.returns(Promise.reject({
693
- body: {
694
- "errorCode":BREAKOUTS.ERROR_CODE.EDIT_LOCK_TOKEN_MISMATCH,
695
- "message":"Edit lock token mismatch"
696
- }
697
- }));
723
+ webex.request.returns(
724
+ Promise.reject({
725
+ body: {
726
+ errorCode: BREAKOUTS.ERROR_CODE.EDIT_LOCK_TOKEN_MISMATCH,
727
+ message: 'Edit lock token mismatch',
728
+ },
729
+ })
730
+ );
698
731
 
699
732
  await assert.isRejected(
700
733
  breakouts.create(sessions),
@@ -703,5 +736,230 @@ describe('plugin-meetings', () => {
703
736
  );
704
737
  });
705
738
  });
739
+
740
+ describe('enableAndLockBreakout', () => {
741
+
742
+ it('enableBreakoutSession is true', async () => {
743
+
744
+ breakouts.enableBreakoutSession = true;
745
+
746
+ breakouts.lockBreakout = sinon.stub().resolves();
747
+
748
+ breakouts.enableAndLockBreakout();
749
+
750
+ assert.calledOnceWithExactly(breakouts.lockBreakout);
751
+
752
+ });
753
+
754
+ it('enableBreakoutSession is false', async () => {
755
+
756
+ breakouts.enableBreakoutSession = false;
757
+
758
+ breakouts.enableBreakouts = sinon.stub().resolves();
759
+
760
+ breakouts.enableAndLockBreakout();
761
+
762
+ assert.calledOnceWithExactly(breakouts.enableBreakouts);
763
+
764
+ });
765
+
766
+ });
767
+
768
+ describe('lockBreakout', () => {
769
+
770
+ it('lock breakout is true', async () => {
771
+
772
+ breakouts.editLock = {
773
+ ttl: 30,
774
+ token: 'token',
775
+ state: 'UNLOCKED',
776
+ };
777
+
778
+ breakouts.keepEditLockAlive = sinon.stub().resolves();
779
+
780
+ breakouts.lockBreakout();
781
+
782
+ assert.calledOnceWithExactly(breakouts.keepEditLockAlive);
783
+
784
+ });
785
+
786
+
787
+ it('lock breakout throw error', async () => {
788
+
789
+ breakouts.editLock = {
790
+ ttl: 30,
791
+ token: '2ad57140-01b5-4bd0-a5a7-4dccdc06904c',
792
+ state: 'LOCKED',
793
+
794
+ };
795
+
796
+ await expect(breakouts.lockBreakout()).to.be.rejectedWith('Breakout already locked');
797
+ });
798
+
799
+ it('lock breakout without editLock', async () => {
800
+
801
+ breakouts.getBreakout = sinon.stub().resolves();
802
+
803
+ breakouts.lockBreakout();
804
+
805
+ assert.calledOnceWithExactly(breakouts.getBreakout, true);
806
+ });
807
+
808
+ });
809
+
810
+ describe('unLockEditBreakout', () => {
811
+ it('unLock edit breakout request as expected', async () => {
812
+
813
+ breakouts.set('editLock', {
814
+ ttl: 30,
815
+ token: '2ad57140-01b5-4bd0-a5a7-4dccdc06904c',
816
+ state: 'LOCKED',
817
+ });
818
+
819
+ breakouts.unLockEditBreakout();
820
+ assert.calledOnceWithExactly(webex.request, {
821
+ method: 'DELETE',
822
+ uri: 'url/editlock/2ad57140-01b5-4bd0-a5a7-4dccdc06904c'
823
+ });
824
+
825
+ });
826
+ });
827
+
828
+ describe('keepEditLockAlive', () => {
829
+
830
+ it('keep edit lock', () => {
831
+
832
+ const clock = sinon.useFakeTimers()
833
+
834
+ breakouts.set('editLock', {
835
+ ttl: 30,
836
+ token: 'token',
837
+ state: 'UNLOCKED',
838
+ });
839
+
840
+ breakouts.keepEditLockAlive();
841
+ clock.tick(15001);
842
+
843
+ assert.calledOnceWithExactly(webex.request, {
844
+ method: 'PUT',
845
+ uri: 'url/editlock/token'
846
+ });
847
+
848
+ clock.restore();
849
+ });
850
+
851
+ it('keep edit lock, ttl < 30, also using 30', () => {
852
+
853
+ const clock = sinon.useFakeTimers()
854
+
855
+ breakouts.set('editLock', {
856
+ ttl: 20,
857
+ token: 'token',
858
+ state: 'UNLOCKED',
859
+ });
860
+
861
+ breakouts.keepEditLockAlive();
862
+ clock.tick(15001);
863
+
864
+ assert.calledOnceWithExactly(webex.request, {
865
+ method: 'PUT',
866
+ uri: 'url/editlock/token'
867
+ });
868
+
869
+ clock.restore();
870
+ });
871
+
872
+ it('keep edit lock, ttl > 30, using the ttl', () => {
873
+
874
+ const clock = sinon.useFakeTimers()
875
+
876
+ breakouts.set('editLock', {
877
+ ttl: 50,
878
+ token: 'token',
879
+ state: 'UNLOCKED',
880
+ });
881
+
882
+ breakouts.keepEditLockAlive();
883
+ clock.tick(24099);
884
+
885
+ assert.notCalled(webex.request);
886
+
887
+ clock.restore();
888
+ });
889
+
890
+ it('keep edit lock, throw error, clearInterval', async() => {
891
+
892
+ breakouts._clearEditLockInfo = sinon.stub();
893
+
894
+ const error = new Error('something went wrong');
895
+ webex.request.rejects(error);
896
+
897
+ const clock = sinon.useFakeTimers()
898
+
899
+ breakouts.set('editLock', {
900
+ ttl: 30,
901
+ token: 'token',
902
+ state: 'UNLOCKED',
903
+ });
904
+
905
+ breakouts.keepEditLockAlive();
906
+ clock.tick(15001);
907
+
908
+ await testUtils.flushPromises();
909
+
910
+ assert.calledOnceWithExactly(breakouts._clearEditLockInfo);
911
+
912
+ clock.restore();
913
+ });
914
+
915
+ it('keep edit lock, do not call until reached ttl', () => {
916
+
917
+ const clock = sinon.useFakeTimers()
918
+
919
+ breakouts.set('editLock', {
920
+ ttl: 30,
921
+ token: 'token',
922
+ state: 'UNLOCKED',
923
+ });
924
+
925
+ breakouts.keepEditLockAlive();
926
+ clock.tick(14999);
927
+
928
+ assert.notCalled(webex.request);
929
+
930
+ clock.tick(1);
931
+ assert.calledOnceWithExactly(webex.request, {
932
+ method: 'PUT',
933
+ uri: 'url/editlock/token'
934
+ });
935
+
936
+ clock.restore();
937
+ });
938
+
939
+ });
940
+
941
+ describe('#assign', () => {
942
+ it('assign members and emails to a breakout session', async () => {
943
+ breakouts.assign = sinon.stub().returns(Promise.resolve('ASSIGN_RETURN_VALUE'));
944
+ const params = [{id: 'sessionId', memberIds: ['111'], emails: ['111@cisco.com']}];
945
+ const result = await breakouts.assign(params);
946
+ assert.calledOnceWithExactly(breakouts.assign, params);
947
+ assert.equal(result, 'ASSIGN_RETURN_VALUE');
948
+ });
949
+ it('assign only members to a breakout session', async () => {
950
+ breakouts.assign = sinon.stub().returns(Promise.resolve('ASSIGN_RETURN_VALUE'));
951
+ const params = [{id: 'sessionId', memberIds: ['111']}];
952
+ const result = await breakouts.assign(params);
953
+ assert.calledOnceWithExactly(breakouts.assign, params);
954
+ assert.equal(result, 'ASSIGN_RETURN_VALUE');
955
+ });
956
+ it('assign only emails to a breakout session', async () => {
957
+ breakouts.assign = sinon.stub().returns(Promise.resolve('ASSIGN_RETURN_VALUE'));
958
+ const params = [{id: 'sessionId', emails: ['111@cisco.com']}];
959
+ const result = await breakouts.assign(params);
960
+ assert.calledOnceWithExactly(breakouts.assign, params);
961
+ assert.equal(result, 'ASSIGN_RETURN_VALUE');
962
+ });
963
+ });
706
964
  });
707
965
  });