@webex/plugin-meetings 3.12.0-task-refactor.1 → 3.12.0-webex-services-ready.1

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.
Files changed (302) hide show
  1. package/AGENTS.md +9 -0
  2. package/dist/aiEnableRequest/index.js +197 -0
  3. package/dist/aiEnableRequest/index.js.map +1 -0
  4. package/dist/aiEnableRequest/utils.js +36 -0
  5. package/dist/aiEnableRequest/utils.js.map +1 -0
  6. package/dist/annotation/index.js +14 -5
  7. package/dist/annotation/index.js.map +1 -1
  8. package/dist/breakouts/breakout.js +8 -3
  9. package/dist/breakouts/breakout.js.map +1 -1
  10. package/dist/breakouts/index.js +26 -2
  11. package/dist/breakouts/index.js.map +1 -1
  12. package/dist/common/errors/webex-errors.js +49 -5
  13. package/dist/common/errors/webex-errors.js.map +1 -1
  14. package/dist/config.js +9 -3
  15. package/dist/config.js.map +1 -1
  16. package/dist/constants.js +59 -10
  17. package/dist/constants.js.map +1 -1
  18. package/dist/controls-options-manager/constants.js +11 -1
  19. package/dist/controls-options-manager/constants.js.map +1 -1
  20. package/dist/controls-options-manager/index.js +67 -29
  21. package/dist/controls-options-manager/index.js.map +1 -1
  22. package/dist/controls-options-manager/util.js +91 -0
  23. package/dist/controls-options-manager/util.js.map +1 -1
  24. package/dist/hashTree/constants.js +34 -0
  25. package/dist/hashTree/constants.js.map +1 -0
  26. package/dist/hashTree/hashTree.js +533 -0
  27. package/dist/hashTree/hashTree.js.map +1 -0
  28. package/dist/hashTree/hashTreeParser.js +2068 -36
  29. package/dist/hashTree/hashTreeParser.js.map +1 -1
  30. package/dist/hashTree/types.js +13 -3
  31. package/dist/hashTree/types.js.map +1 -1
  32. package/dist/hashTree/utils.js +111 -0
  33. package/dist/hashTree/utils.js.map +1 -0
  34. package/dist/index.js +18 -2
  35. package/dist/index.js.map +1 -1
  36. package/dist/interceptors/constant.js +12 -0
  37. package/dist/interceptors/constant.js.map +1 -0
  38. package/dist/interceptors/dataChannelAuthToken.js +350 -0
  39. package/dist/interceptors/dataChannelAuthToken.js.map +1 -0
  40. package/dist/interceptors/index.js +7 -0
  41. package/dist/interceptors/index.js.map +1 -1
  42. package/dist/interceptors/locusRetry.js +23 -8
  43. package/dist/interceptors/locusRetry.js.map +1 -1
  44. package/dist/interceptors/locusRouteToken.js +27 -5
  45. package/dist/interceptors/locusRouteToken.js.map +1 -1
  46. package/dist/interceptors/utils.js +27 -0
  47. package/dist/interceptors/utils.js.map +1 -0
  48. package/dist/interpretation/index.js +11 -2
  49. package/dist/interpretation/index.js.map +1 -1
  50. package/dist/interpretation/interpretation.types.js +7 -0
  51. package/dist/interpretation/interpretation.types.js.map +1 -0
  52. package/dist/interpretation/siLanguage.js +1 -1
  53. package/dist/locus-info/controlsUtils.js +11 -4
  54. package/dist/locus-info/controlsUtils.js.map +1 -1
  55. package/dist/locus-info/index.js +896 -277
  56. package/dist/locus-info/index.js.map +1 -1
  57. package/dist/locus-info/infoUtils.js +36 -5
  58. package/dist/locus-info/infoUtils.js.map +1 -1
  59. package/dist/locus-info/selfUtils.js +1 -0
  60. package/dist/locus-info/selfUtils.js.map +1 -1
  61. package/dist/locus-info/types.js +19 -0
  62. package/dist/locus-info/types.js.map +1 -1
  63. package/dist/media/MediaConnectionAwaiter.js +72 -3
  64. package/dist/media/MediaConnectionAwaiter.js.map +1 -1
  65. package/dist/media/index.js +8 -2
  66. package/dist/media/index.js.map +1 -1
  67. package/dist/media/properties.js +5 -2
  68. package/dist/media/properties.js.map +1 -1
  69. package/dist/meeting/in-meeting-actions.js +11 -1
  70. package/dist/meeting/in-meeting-actions.js.map +1 -1
  71. package/dist/meeting/index.js +2075 -1096
  72. package/dist/meeting/index.js.map +1 -1
  73. package/dist/meeting/locusMediaRequest.js +229 -82
  74. package/dist/meeting/locusMediaRequest.js.map +1 -1
  75. package/dist/meeting/muteState.js +10 -1
  76. package/dist/meeting/muteState.js.map +1 -1
  77. package/dist/meeting/request.js +55 -2
  78. package/dist/meeting/request.js.map +1 -1
  79. package/dist/meeting/request.type.js.map +1 -1
  80. package/dist/meeting/util.js +168 -5
  81. package/dist/meeting/util.js.map +1 -1
  82. package/dist/meeting-info/meeting-info-v2.js +2 -2
  83. package/dist/meeting-info/meeting-info-v2.js.map +1 -1
  84. package/dist/meetings/index.js +369 -173
  85. package/dist/meetings/index.js.map +1 -1
  86. package/dist/meetings/meetings.types.js +6 -1
  87. package/dist/meetings/meetings.types.js.map +1 -1
  88. package/dist/meetings/request.js +39 -0
  89. package/dist/meetings/request.js.map +1 -1
  90. package/dist/meetings/util.js +127 -25
  91. package/dist/meetings/util.js.map +1 -1
  92. package/dist/member/index.js +20 -0
  93. package/dist/member/index.js.map +1 -1
  94. package/dist/member/types.js.map +1 -1
  95. package/dist/member/util.js +40 -0
  96. package/dist/member/util.js.map +1 -1
  97. package/dist/members/index.js +101 -43
  98. package/dist/members/index.js.map +1 -1
  99. package/dist/members/util.js +8 -1
  100. package/dist/members/util.js.map +1 -1
  101. package/dist/metrics/constants.js +11 -1
  102. package/dist/metrics/constants.js.map +1 -1
  103. package/dist/multistream/codec/constants.js +63 -0
  104. package/dist/multistream/codec/constants.js.map +1 -0
  105. package/dist/multistream/mediaRequestManager.js +64 -68
  106. package/dist/multistream/mediaRequestManager.js.map +1 -1
  107. package/dist/multistream/receiveSlot.js +9 -0
  108. package/dist/multistream/receiveSlot.js.map +1 -1
  109. package/dist/multistream/remoteMediaManager.js +11 -0
  110. package/dist/multistream/remoteMediaManager.js.map +1 -1
  111. package/dist/multistream/sendSlotManager.js +116 -2
  112. package/dist/multistream/sendSlotManager.js.map +1 -1
  113. package/dist/reachability/clusterReachability.js +171 -18
  114. package/dist/reachability/clusterReachability.js.map +1 -1
  115. package/dist/reachability/index.js +142 -94
  116. package/dist/reachability/index.js.map +1 -1
  117. package/dist/reachability/reachability.types.js +2 -0
  118. package/dist/reachability/reachability.types.js.map +1 -1
  119. package/dist/reachability/reachabilityPeerConnection.js +1 -1
  120. package/dist/reachability/reachabilityPeerConnection.js.map +1 -1
  121. package/dist/reachability/util.js +45 -0
  122. package/dist/reachability/util.js.map +1 -1
  123. package/dist/reactions/reactions.type.js.map +1 -1
  124. package/dist/reconnection-manager/index.js +0 -1
  125. package/dist/reconnection-manager/index.js.map +1 -1
  126. package/dist/recording-controller/index.js +1 -3
  127. package/dist/recording-controller/index.js.map +1 -1
  128. package/dist/types/aiEnableRequest/index.d.ts +5 -0
  129. package/dist/types/aiEnableRequest/utils.d.ts +2 -0
  130. package/dist/types/common/browser-detection.d.ts +1 -0
  131. package/dist/types/common/errors/webex-errors.d.ts +32 -2
  132. package/dist/types/common/events/events-scope.d.ts +1 -0
  133. package/dist/types/common/events/events.d.ts +1 -0
  134. package/dist/types/config.d.ts +7 -2
  135. package/dist/types/constants.d.ts +35 -1
  136. package/dist/types/controls-options-manager/constants.d.ts +6 -1
  137. package/dist/types/controls-options-manager/index.d.ts +16 -0
  138. package/dist/types/hashTree/constants.d.ts +11 -0
  139. package/dist/types/hashTree/hashTree.d.ts +136 -0
  140. package/dist/types/hashTree/hashTreeParser.d.ts +392 -14
  141. package/dist/types/hashTree/types.d.ts +20 -0
  142. package/dist/types/hashTree/utils.d.ts +40 -0
  143. package/dist/types/index.d.ts +4 -0
  144. package/dist/types/interceptors/constant.d.ts +5 -0
  145. package/dist/types/interceptors/dataChannelAuthToken.d.ts +43 -0
  146. package/dist/types/interceptors/index.d.ts +2 -1
  147. package/dist/types/interceptors/locusRetry.d.ts +4 -4
  148. package/dist/types/interceptors/locusRouteToken.d.ts +2 -0
  149. package/dist/types/interceptors/utils.d.ts +1 -0
  150. package/dist/types/interpretation/interpretation.types.d.ts +10 -0
  151. package/dist/types/locus-info/index.d.ts +116 -51
  152. package/dist/types/locus-info/infoUtils.d.ts +8 -0
  153. package/dist/types/locus-info/types.d.ts +48 -12
  154. package/dist/types/media/MediaConnectionAwaiter.d.ts +20 -2
  155. package/dist/types/media/properties.d.ts +3 -1
  156. package/dist/types/meeting/in-meeting-actions.d.ts +10 -0
  157. package/dist/types/meeting/index.d.ts +196 -15
  158. package/dist/types/meeting/locusMediaRequest.d.ts +12 -0
  159. package/dist/types/meeting/request.d.ts +17 -1
  160. package/dist/types/meeting/request.type.d.ts +5 -0
  161. package/dist/types/meeting/util.d.ts +40 -0
  162. package/dist/types/meeting-info/util.d.ts +1 -0
  163. package/dist/types/meeting-info/utilv2.d.ts +1 -0
  164. package/dist/types/meetings/index.d.ts +34 -20
  165. package/dist/types/meetings/meetings.types.d.ts +15 -0
  166. package/dist/types/meetings/request.d.ts +14 -0
  167. package/dist/types/member/index.d.ts +2 -0
  168. package/dist/types/member/types.d.ts +5 -4
  169. package/dist/types/member/util.d.ts +14 -0
  170. package/dist/types/members/index.d.ts +15 -2
  171. package/dist/types/members/util.d.ts +1 -5
  172. package/dist/types/metrics/constants.d.ts +10 -0
  173. package/dist/types/multistream/codec/constants.d.ts +7 -0
  174. package/dist/types/multistream/mediaRequestManager.d.ts +20 -26
  175. package/dist/types/multistream/sendSlotManager.d.ts +23 -1
  176. package/dist/types/reachability/clusterReachability.d.ts +33 -6
  177. package/dist/types/reachability/index.d.ts +10 -3
  178. package/dist/types/reachability/reachability.types.d.ts +7 -0
  179. package/dist/types/reachability/util.d.ts +17 -0
  180. package/dist/types/reactions/reactions.type.d.ts +4 -0
  181. package/dist/types/recording-controller/util.d.ts +5 -5
  182. package/dist/types/roap/index.d.ts +1 -1
  183. package/dist/types/webinar/utils.d.ts +6 -0
  184. package/dist/webinar/index.js +585 -164
  185. package/dist/webinar/index.js.map +1 -1
  186. package/dist/webinar/utils.js +25 -0
  187. package/dist/webinar/utils.js.map +1 -0
  188. package/package.json +26 -24
  189. package/src/aiEnableRequest/README.md +84 -0
  190. package/src/aiEnableRequest/index.ts +186 -0
  191. package/src/aiEnableRequest/utils.ts +25 -0
  192. package/src/annotation/index.ts +27 -7
  193. package/src/breakouts/breakout.ts +3 -1
  194. package/src/breakouts/index.ts +31 -0
  195. package/src/common/errors/webex-errors.ts +50 -3
  196. package/src/config.ts +7 -2
  197. package/src/constants.ts +49 -3
  198. package/src/controls-options-manager/constants.ts +14 -1
  199. package/src/controls-options-manager/index.ts +87 -28
  200. package/src/controls-options-manager/util.ts +81 -1
  201. package/src/hashTree/constants.ts +26 -0
  202. package/src/hashTree/hashTree.ts +480 -0
  203. package/src/hashTree/hashTreeParser.ts +1911 -29
  204. package/src/hashTree/types.ts +24 -1
  205. package/src/hashTree/utils.ts +98 -0
  206. package/src/index.ts +14 -1
  207. package/src/interceptors/constant.ts +6 -0
  208. package/src/interceptors/dataChannelAuthToken.ts +246 -0
  209. package/src/interceptors/index.ts +2 -1
  210. package/src/interceptors/locusRetry.ts +25 -4
  211. package/src/interceptors/locusRouteToken.ts +22 -5
  212. package/src/interceptors/utils.ts +16 -0
  213. package/src/interpretation/index.ts +29 -11
  214. package/src/interpretation/interpretation.types.ts +11 -0
  215. package/src/locus-info/controlsUtils.ts +20 -1
  216. package/src/locus-info/index.ts +958 -250
  217. package/src/locus-info/infoUtils.ts +41 -6
  218. package/src/locus-info/selfUtils.ts +1 -0
  219. package/src/locus-info/types.ts +51 -12
  220. package/src/media/MediaConnectionAwaiter.ts +62 -5
  221. package/src/media/index.ts +10 -1
  222. package/src/media/properties.ts +4 -1
  223. package/src/meeting/in-meeting-actions.ts +20 -0
  224. package/src/meeting/index.ts +1025 -146
  225. package/src/meeting/locusMediaRequest.ts +106 -6
  226. package/src/meeting/muteState.ts +10 -1
  227. package/src/meeting/request.ts +53 -0
  228. package/src/meeting/request.type.ts +6 -0
  229. package/src/meeting/util.ts +207 -7
  230. package/src/meeting-info/meeting-info-v2.ts +4 -2
  231. package/src/meetings/index.ts +307 -132
  232. package/src/meetings/meetings.types.ts +19 -0
  233. package/src/meetings/request.ts +43 -0
  234. package/src/meetings/util.ts +127 -13
  235. package/src/member/index.ts +20 -0
  236. package/src/member/types.ts +1 -0
  237. package/src/member/util.ts +41 -0
  238. package/src/members/index.ts +70 -7
  239. package/src/members/util.ts +12 -4
  240. package/src/metrics/constants.ts +11 -0
  241. package/src/multistream/codec/constants.ts +58 -0
  242. package/src/multistream/mediaRequestManager.ts +117 -76
  243. package/src/multistream/receiveSlot.ts +18 -0
  244. package/src/multistream/remoteMediaManager.ts +13 -0
  245. package/src/multistream/sendSlotManager.ts +97 -3
  246. package/src/reachability/clusterReachability.ts +156 -29
  247. package/src/reachability/index.ts +62 -17
  248. package/src/reachability/reachability.types.ts +11 -0
  249. package/src/reachability/reachabilityPeerConnection.ts +3 -1
  250. package/src/reachability/util.ts +36 -0
  251. package/src/reactions/reactions.type.ts +4 -0
  252. package/src/reconnection-manager/index.ts +0 -1
  253. package/src/recording-controller/index.ts +1 -2
  254. package/src/webinar/index.ts +448 -11
  255. package/src/webinar/utils.ts +16 -0
  256. package/test/unit/spec/aiEnableRequest/index.ts +1067 -0
  257. package/test/unit/spec/aiEnableRequest/utils.ts +130 -0
  258. package/test/unit/spec/annotation/index.ts +69 -7
  259. package/test/unit/spec/breakouts/breakout.ts +9 -3
  260. package/test/unit/spec/breakouts/index.ts +49 -0
  261. package/test/unit/spec/common/errors/webex-errors.ts +78 -0
  262. package/test/unit/spec/controls-options-manager/index.js +244 -29
  263. package/test/unit/spec/controls-options-manager/util.js +165 -0
  264. package/test/unit/spec/hashTree/hashTree.ts +721 -0
  265. package/test/unit/spec/hashTree/hashTreeParser.ts +5328 -0
  266. package/test/unit/spec/hashTree/utils.ts +264 -0
  267. package/test/unit/spec/interceptors/dataChannelAuthToken.ts +406 -0
  268. package/test/unit/spec/interceptors/locusRetry.ts +205 -4
  269. package/test/unit/spec/interceptors/locusRouteToken.ts +44 -0
  270. package/test/unit/spec/interceptors/utils.ts +75 -0
  271. package/test/unit/spec/interpretation/index.ts +26 -4
  272. package/test/unit/spec/locus-info/controlsUtils.js +222 -52
  273. package/test/unit/spec/locus-info/index.js +2000 -171
  274. package/test/unit/spec/locus-info/infoUtils.js +184 -1
  275. package/test/unit/spec/media/MediaConnectionAwaiter.ts +96 -1
  276. package/test/unit/spec/media/index.ts +92 -0
  277. package/test/unit/spec/media/properties.ts +12 -3
  278. package/test/unit/spec/meeting/in-meeting-actions.ts +12 -2
  279. package/test/unit/spec/meeting/index.js +2925 -209
  280. package/test/unit/spec/meeting/locusMediaRequest.ts +406 -4
  281. package/test/unit/spec/meeting/muteState.js +81 -0
  282. package/test/unit/spec/meeting/request.js +82 -0
  283. package/test/unit/spec/meeting/utils.js +595 -27
  284. package/test/unit/spec/meeting-info/meetinginfov2.js +19 -10
  285. package/test/unit/spec/meetings/index.js +1214 -75
  286. package/test/unit/spec/meetings/request.js +141 -0
  287. package/test/unit/spec/meetings/utils.js +453 -52
  288. package/test/unit/spec/member/index.js +35 -4
  289. package/test/unit/spec/member/util.js +154 -27
  290. package/test/unit/spec/members/index.js +216 -0
  291. package/test/unit/spec/members/request.js +37 -1
  292. package/test/unit/spec/members/utils.js +63 -0
  293. package/test/unit/spec/multistream/mediaRequestManager.ts +503 -122
  294. package/test/unit/spec/multistream/remoteMediaManager.ts +30 -0
  295. package/test/unit/spec/multistream/sendSlotManager.ts +135 -36
  296. package/test/unit/spec/reachability/clusterReachability.ts +125 -1
  297. package/test/unit/spec/reachability/index.ts +154 -49
  298. package/test/unit/spec/reachability/util.ts +31 -0
  299. package/test/unit/spec/reconnection-manager/index.js +4 -8
  300. package/test/unit/spec/recording-controller/index.js +9 -8
  301. package/test/unit/spec/webinar/index.ts +837 -39
  302. package/test/unit/spec/webinar/utils.ts +39 -0
@@ -14,12 +14,14 @@ import StaticConfig from '@webex/plugin-meetings/src/common/config';
14
14
  import TriggerProxy from '@webex/plugin-meetings/src/common/events/trigger-proxy';
15
15
  import LoggerProxy from '@webex/plugin-meetings/src/common/logs/logger-proxy';
16
16
  import LoggerConfig from '@webex/plugin-meetings/src/common/logs/logger-config';
17
+ import ParameterError from '@webex/plugin-meetings/src/common/errors/parameter';
17
18
  import Meeting, {CallStateForMetrics} from '@webex/plugin-meetings/src/meeting';
18
19
  import {Services} from '@webex/webex-core';
19
20
  import MeetingUtil from '@webex/plugin-meetings/src/meeting/util';
20
21
  import Meetings from '@webex/plugin-meetings/src/meetings';
21
22
  import MeetingCollection from '@webex/plugin-meetings/src/meetings/collection';
22
23
  import MeetingsUtil from '@webex/plugin-meetings/src/meetings/util';
24
+ import {SitePreferenceSelectOption} from '@webex/plugin-meetings/src/meetings/meetings.types';
23
25
  import PersonalMeetingRoom from '@webex/plugin-meetings/src/personal-meeting-room';
24
26
  import Reachability from '@webex/plugin-meetings/src/reachability';
25
27
  import Metrics from '@webex/plugin-meetings/src/metrics';
@@ -91,6 +93,7 @@ describe('plugin-meetings', () => {
91
93
  locusInfo = {
92
94
  parse: sinon.stub().returns(true),
93
95
  updateMainSessionLocusCache: sinon.stub(),
96
+ syncAllHashTreeDatasets: sinon.stub(),
94
97
  };
95
98
  webex = new MockWebex({
96
99
  children: {
@@ -355,32 +358,6 @@ describe('plugin-meetings', () => {
355
358
  });
356
359
  });
357
360
 
358
- describe('#_toggleTcpReachability', () => {
359
- it('should have _toggleTcpReachability', () => {
360
- assert.equal(typeof webex.meetings._toggleTcpReachability, 'function');
361
- });
362
-
363
- describe('success', () => {
364
- it('should update meetings to do TCP reachability', () => {
365
- webex.meetings._toggleTcpReachability(true);
366
- assert.equal(webex.meetings.config.experimental.enableTcpReachability, true);
367
- });
368
- });
369
- });
370
-
371
- describe('#_toggleTlsReachability', () => {
372
- it('should have _toggleTlsReachability', () => {
373
- assert.equal(typeof webex.meetings._toggleTlsReachability, 'function');
374
- });
375
-
376
- describe('success', () => {
377
- it('should update meetings to do TLS reachability', () => {
378
- webex.meetings._toggleTlsReachability(true);
379
- assert.equal(webex.meetings.config.experimental.enableTlsReachability, true);
380
- });
381
- });
382
- });
383
-
384
361
  describe('#_toggleIpv6BackendNativeSupport', () => {
385
362
  it('should have _toggleIpv6BackendNativeSupport', () => {
386
363
  assert.equal(typeof webex.meetings._toggleIpv6BackendNativeSupport, 'function');
@@ -423,9 +400,39 @@ describe('plugin-meetings', () => {
423
400
  });
424
401
  });
425
402
 
403
+ describe('#_toggleEnableAv1SlidesSupport', () => {
404
+ it('should have _toggleEnableAv1SlidesSupport', () => {
405
+ assert.equal(typeof webex.meetings._toggleEnableAv1SlidesSupport, 'function');
406
+ });
407
+
408
+ describe('success', () => {
409
+ it('should update meetings config to enable AV1 slides support', () => {
410
+ webex.meetings._toggleEnableAv1SlidesSupport(true);
411
+ assert.equal(webex.meetings.config.enableAv1SlidesSupport, true);
412
+
413
+ webex.meetings._toggleEnableAv1SlidesSupport(false);
414
+ assert.equal(webex.meetings.config.enableAv1SlidesSupport, false);
415
+ });
416
+
417
+ it('should not update config when called with a non-boolean value', () => {
418
+ webex.meetings._toggleEnableAv1SlidesSupport(true);
419
+ assert.equal(webex.meetings.config.enableAv1SlidesSupport, true);
420
+
421
+ webex.meetings._toggleEnableAv1SlidesSupport('invalid');
422
+ assert.equal(webex.meetings.config.enableAv1SlidesSupport, true);
423
+
424
+ webex.meetings._toggleEnableAv1SlidesSupport(undefined);
425
+ assert.equal(webex.meetings.config.enableAv1SlidesSupport, true);
426
+ });
427
+ });
428
+ });
429
+
426
430
  describe('#_toggleStopIceGatheringAfterFirstRelayCandidate', () => {
427
431
  it('should have _toggleStopIceGatheringAfterFirstRelayCandidate', () => {
428
- assert.equal(typeof webex.meetings._toggleStopIceGatheringAfterFirstRelayCandidate, 'function');
432
+ assert.equal(
433
+ typeof webex.meetings._toggleStopIceGatheringAfterFirstRelayCandidate,
434
+ 'function'
435
+ );
429
436
  });
430
437
 
431
438
  describe('success', () => {
@@ -602,6 +609,196 @@ describe('plugin-meetings', () => {
602
609
 
603
610
  clock.restore();
604
611
  });
612
+
613
+ it('returns the same promise when register is called multiple times concurrently', async () => {
614
+ webex.canAuthorize = true;
615
+ webex.meetings.registered = false;
616
+
617
+ // Make registration take some time
618
+ let resolveRegistration;
619
+ const registrationDelay = new Promise((resolve) => {
620
+ resolveRegistration = resolve;
621
+ });
622
+
623
+ webex.internal.device.register.returns(registrationDelay);
624
+ webex.internal.mercury.connect.returns(Promise.resolve());
625
+
626
+ // Start first registration
627
+ const firstRegisterPromise = webex.meetings.register();
628
+
629
+ // Immediately start second registration while first is in progress
630
+ const secondRegisterPromise = webex.meetings.register();
631
+
632
+ // Start third registration
633
+ const thirdRegisterPromise = webex.meetings.register();
634
+
635
+ // All should return the same promise
636
+ assert.strictEqual(firstRegisterPromise, secondRegisterPromise);
637
+ assert.strictEqual(secondRegisterPromise, thirdRegisterPromise);
638
+
639
+ // Complete the registration
640
+ resolveRegistration();
641
+
642
+ await firstRegisterPromise;
643
+ await secondRegisterPromise;
644
+ await thirdRegisterPromise;
645
+
646
+ // Device registration and mercury connect should only be called once
647
+ assert.calledOnce(webex.internal.device.register);
648
+ assert.calledOnce(webex.internal.mercury.connect);
649
+ assert.isTrue(webex.meetings.registered);
650
+ });
651
+
652
+ it('prevents duplicate registrations when register is called during in-flight registration', async () => {
653
+ webex.canAuthorize = true;
654
+ webex.meetings.registered = false;
655
+
656
+ let deviceRegisterCallCount = 0;
657
+ let mercuryConnectCallCount = 0;
658
+
659
+ // Track actual calls
660
+ webex.internal.device.register = sinon.stub().callsFake(() => {
661
+ deviceRegisterCallCount++;
662
+ return Promise.resolve();
663
+ });
664
+ webex.internal.mercury.connect = sinon.stub().callsFake(() => {
665
+ mercuryConnectCallCount++;
666
+ return Promise.resolve();
667
+ });
668
+
669
+ // Start registration without awaiting
670
+ const promise1 = webex.meetings.register();
671
+
672
+ // Call register again while first is in progress
673
+ const promise2 = webex.meetings.register();
674
+
675
+ // Wait for both
676
+ await Promise.all([promise1, promise2]);
677
+
678
+ // Should only register once
679
+ assert.equal(deviceRegisterCallCount, 1, 'device.register should only be called once');
680
+ assert.equal(mercuryConnectCallCount, 1, 'mercury.connect should only be called once');
681
+ assert.isTrue(webex.meetings.registered);
682
+ });
683
+
684
+ it('handles concurrent register calls when first registration fails', async () => {
685
+ webex.canAuthorize = true;
686
+ webex.meetings.registered = false;
687
+
688
+ const registrationError = new Error('registration failed');
689
+ webex.internal.device.register.rejects(registrationError);
690
+
691
+ // Start first registration
692
+ const firstRegisterPromise = webex.meetings.register();
693
+
694
+ // Start second registration while first is in progress
695
+ const secondRegisterPromise = webex.meetings.register();
696
+
697
+ // Both should reject with the same error
698
+ await assert.isRejected(firstRegisterPromise, 'registration failed');
699
+ await assert.isRejected(secondRegisterPromise, 'registration failed');
700
+
701
+ // Should still only attempt registration once
702
+ assert.calledOnce(webex.internal.device.register);
703
+ assert.isFalse(webex.meetings.registered);
704
+ });
705
+
706
+ it('allows new registration after previous registration completes', async () => {
707
+ webex.canAuthorize = true;
708
+ webex.meetings.registered = false;
709
+
710
+ // First registration
711
+ await webex.meetings.register();
712
+ assert.isTrue(webex.meetings.registered);
713
+
714
+ // Reset for second registration
715
+ webex.meetings.registered = false;
716
+ webex.internal.device.register.resetHistory();
717
+ webex.internal.mercury.connect.resetHistory();
718
+
719
+ // Second registration should work normally
720
+ await webex.meetings.register();
721
+ assert.calledOnce(webex.internal.device.register);
722
+ assert.calledOnce(webex.internal.mercury.connect);
723
+ assert.isTrue(webex.meetings.registered);
724
+ });
725
+
726
+ it('clears registrationPromise after successful registration', async () => {
727
+ webex.canAuthorize = true;
728
+ webex.meetings.registered = false;
729
+
730
+ await webex.meetings.register();
731
+
732
+ assert.isTrue(webex.meetings.registered);
733
+ assert.isNull(webex.meetings.registrationPromise);
734
+ });
735
+
736
+ it('clears registrationPromise after failed registration', async () => {
737
+ webex.canAuthorize = true;
738
+ webex.meetings.registered = false;
739
+
740
+ webex.internal.device.register.rejects(new Error('registration failed'));
741
+
742
+ await assert.isRejected(webex.meetings.register());
743
+
744
+ assert.isFalse(webex.meetings.registered);
745
+ assert.isNull(webex.meetings.registrationPromise);
746
+ });
747
+
748
+ it('waits for unregistration to complete before registering', async () => {
749
+ webex.canAuthorize = true;
750
+
751
+ assert.isFalse(webex.meetings.registered);
752
+
753
+ // First, register successfully
754
+ await webex.meetings.register();
755
+ assert.isTrue(webex.meetings.registered);
756
+
757
+ // Start unregistration (but don't await it)
758
+ const unregisterPromise = webex.meetings.unregister();
759
+ assert.isDefined(webex.meetings.unregistrationPromise);
760
+
761
+ // Immediately try to register while unregister is in progress
762
+ const registerPromise = webex.meetings.register();
763
+
764
+ // Wait for register to complete
765
+ await registerPromise;
766
+
767
+ // Should have completed registration
768
+ assert.isTrue(webex.meetings.registered);
769
+
770
+ // Now await the original unregister promise - this should have already completed
771
+ // and should NOT affect the registered state since register() took over
772
+ await unregisterPromise;
773
+
774
+ // Should STILL be registered because register() took over
775
+ assert.isTrue(webex.meetings.registered);
776
+ });
777
+
778
+ it('handles multiple register calls during unregistration', async () => {
779
+ webex.canAuthorize = true;
780
+
781
+ // First, register successfully
782
+ await webex.meetings.register();
783
+ assert.isTrue(webex.meetings.registered);
784
+
785
+ // Start unregistration
786
+ const unregistrationPromise = webex.meetings.unregister();
787
+
788
+ // Try to register once while unregister is in progress
789
+ await webex.meetings.register();
790
+
791
+ // Should be registered again
792
+ assert.isTrue(
793
+ webex.meetings.registered,
794
+ 'Expected meetings to be registered after unregister and register cycle'
795
+ );
796
+
797
+ await unregistrationPromise;
798
+
799
+ // Should STILL be registered because register() took over
800
+ assert.isTrue(webex.meetings.registered);
801
+ });
605
802
  });
606
803
 
607
804
  describe('#unregister', () => {
@@ -622,6 +819,18 @@ describe('plugin-meetings', () => {
622
819
  });
623
820
  });
624
821
 
822
+ it('calls mercury.disconnect with code 3050 and reason to prevent auto-reconnect', (done) => {
823
+ webex.meetings.registered = true;
824
+ webex.meetings.unregister().then(() => {
825
+ assert.calledOnce(webex.internal.mercury.disconnect);
826
+ assert.calledWith(webex.internal.mercury.disconnect, {
827
+ code: 3050,
828
+ reason: 'meetings unregister',
829
+ });
830
+ done();
831
+ });
832
+ });
833
+
625
834
  it('rejects when device.unregister fails', async () => {
626
835
  webex.meetings.registered = true;
627
836
  webex.internal.device.unregister = sinon.stub().returns(Promise.reject());
@@ -670,6 +879,335 @@ describe('plugin-meetings', () => {
670
879
  done();
671
880
  });
672
881
  });
882
+
883
+ it('waits for registration to complete before unregistering when called during registration', async () => {
884
+ webex.canAuthorize = true;
885
+ webex.meetings.registered = false;
886
+
887
+ let resolveRegistration;
888
+ const registrationDelay = new Promise((resolve) => {
889
+ resolveRegistration = resolve;
890
+ });
891
+
892
+ webex.internal.device.register.returns(registrationDelay);
893
+ webex.internal.mercury.connect.returns(Promise.resolve());
894
+
895
+ // Start registration (don't await)
896
+ const registerPromise = webex.meetings.register();
897
+
898
+ // Verify registration is in progress
899
+ assert.exists(webex.meetings.registrationPromise);
900
+ assert.isFalse(webex.meetings.registered);
901
+
902
+ // Call unregister while registration is in progress
903
+ const unregisterPromise = webex.meetings.unregister();
904
+
905
+ // Registration should still be in progress
906
+ assert.exists(webex.meetings.registrationPromise);
907
+
908
+ // Complete the registration
909
+ resolveRegistration();
910
+ await registerPromise;
911
+
912
+ // Now unregister should proceed
913
+ await unregisterPromise;
914
+
915
+ // Verify final state
916
+ assert.isFalse(webex.meetings.registered);
917
+ assert.isNull(webex.meetings.registrationPromise);
918
+ assert.calledOnce(webex.internal.device.unregister);
919
+ assert.calledOnce(webex.internal.mercury.disconnect);
920
+ });
921
+
922
+ it('handles unregister called during registration that fails', async () => {
923
+ webex.canAuthorize = true;
924
+ webex.meetings.registered = false;
925
+
926
+ const registrationError = new Error('registration failed');
927
+ let rejectRegistration;
928
+ const registrationDelay = new Promise((resolve, reject) => {
929
+ rejectRegistration = reject;
930
+ });
931
+
932
+ webex.internal.device.register.returns(registrationDelay);
933
+
934
+ // Start registration (don't await)
935
+ const registerPromise = webex.meetings.register();
936
+
937
+ // Call unregister while registration is in progress
938
+ const unregisterPromise = webex.meetings.unregister();
939
+
940
+ // Fail the registration
941
+ rejectRegistration(registrationError);
942
+
943
+ // Registration should fail
944
+ await assert.isRejected(registerPromise, 'registration failed');
945
+
946
+ // // Unregister should resolve immediately since registration failed
947
+ await unregisterPromise;
948
+
949
+ // Verify final state - not registered
950
+ assert.isFalse(webex.meetings.registered);
951
+ assert.isNull(webex.meetings.registrationPromise);
952
+ // Device unregister should not be called because registration never completed
953
+ assert.notCalled(webex.internal.device.unregister);
954
+ });
955
+
956
+ it('handles multiple unregister calls during registration', async () => {
957
+ webex.canAuthorize = true;
958
+ webex.meetings.registered = false;
959
+
960
+ let resolveRegistration;
961
+ const registrationDelay = new Promise((resolve) => {
962
+ resolveRegistration = resolve;
963
+ });
964
+
965
+ webex.internal.device.register.returns(registrationDelay);
966
+ webex.internal.mercury.connect.returns(Promise.resolve());
967
+
968
+ // Start registration
969
+ const registerPromise = webex.meetings.register();
970
+
971
+ // Call unregister multiple times while registration is in progress
972
+ const unregisterPromise1 = webex.meetings.unregister();
973
+ const unregisterPromise2 = webex.meetings.unregister();
974
+ const unregisterPromise3 = webex.meetings.unregister();
975
+
976
+ // Complete registration
977
+ resolveRegistration();
978
+ await registerPromise;
979
+
980
+ // All unregister calls should complete
981
+ await Promise.all([unregisterPromise1, unregisterPromise2, unregisterPromise3]);
982
+
983
+ // Verify final state
984
+ assert.isFalse(webex.meetings.registered);
985
+ // Disconnect and unregister should be called, but not multiple times
986
+ assert.calledOnce(webex.internal.mercury.disconnect);
987
+ assert.calledOnce(webex.internal.device.unregister);
988
+ });
989
+
990
+ it('completes unregister correctly after waiting for registration', async () => {
991
+ webex.canAuthorize = true;
992
+ webex.meetings.registered = false;
993
+
994
+ const stopListeningForEventsSpy = sinon.spy(webex.meetings, 'stopListeningForEvents');
995
+
996
+ let resolveRegistration;
997
+ const registrationDelay = new Promise((resolve) => {
998
+ resolveRegistration = resolve;
999
+ });
1000
+
1001
+ webex.internal.device.register.returns(registrationDelay);
1002
+ webex.internal.mercury.connect.returns(Promise.resolve());
1003
+
1004
+ // Start registration
1005
+ const registerPromise = webex.meetings.register();
1006
+
1007
+ // Call unregister during registration
1008
+ const unregisterPromise = webex.meetings.unregister();
1009
+
1010
+ // stopListeningForEvents should not be called yet
1011
+ assert.notCalled(stopListeningForEventsSpy);
1012
+
1013
+ // Complete registration
1014
+ resolveRegistration();
1015
+ await registerPromise;
1016
+
1017
+ // After registration completes, the meetings plugin should be registered
1018
+ assert.isTrue(webex.meetings.registered);
1019
+
1020
+ // Now unregister should proceed
1021
+ await unregisterPromise;
1022
+
1023
+ // Verify unregister completed properly
1024
+ assert.calledOnce(stopListeningForEventsSpy);
1025
+ assert.calledOnce(webex.internal.mercury.disconnect);
1026
+ assert.calledOnce(webex.internal.device.unregister);
1027
+ assert.isFalse(webex.meetings.registered);
1028
+ assert.deepEqual(webex.meetings.registrationStatus, INITIAL_REGISTRATION_STATUS);
1029
+ });
1030
+
1031
+ it('logs appropriate message when unregister is called during registration', async () => {
1032
+ webex.canAuthorize = true;
1033
+ webex.meetings.registered = false;
1034
+
1035
+ const loggerSpy = sinon.spy(LoggerProxy.logger, 'info');
1036
+
1037
+ let resolveRegistration;
1038
+ const registrationDelay = new Promise((resolve) => {
1039
+ resolveRegistration = resolve;
1040
+ });
1041
+
1042
+ webex.internal.device.register.returns(registrationDelay);
1043
+ webex.internal.mercury.connect.returns(Promise.resolve());
1044
+
1045
+ // Start registration
1046
+ const registerPromise = webex.meetings.register();
1047
+
1048
+ // Call unregister during registration
1049
+ const unregisterPromise = webex.meetings.unregister();
1050
+
1051
+ // Should log that it's waiting
1052
+ assert.calledWith(
1053
+ loggerSpy,
1054
+ 'Meetings:index#unregister --> INFO, Meetings plugin registration in progress, waiting to unregister'
1055
+ );
1056
+
1057
+ // Complete registration and unregistration
1058
+ resolveRegistration();
1059
+ await registerPromise;
1060
+ await unregisterPromise;
1061
+
1062
+ loggerSpy.restore();
1063
+ });
1064
+
1065
+ it('returns the same promise when unregister is called multiple times concurrently', async () => {
1066
+ webex.meetings.registered = true;
1067
+
1068
+ // Make unregistration take some time
1069
+ let resolveUnregistration;
1070
+ const unregistrationDelay = new Promise((resolve) => {
1071
+ resolveUnregistration = resolve;
1072
+ });
1073
+
1074
+ webex.internal.mercury.disconnect.returns(unregistrationDelay);
1075
+ webex.internal.device.unregister.returns(Promise.resolve());
1076
+
1077
+ // Start first unregistration
1078
+ const firstUnregisterPromise = webex.meetings.unregister();
1079
+
1080
+ // Immediately start second unregistration while first is in progress
1081
+ const secondUnregisterPromise = webex.meetings.unregister();
1082
+
1083
+ // Start third unregistration
1084
+ const thirdUnregisterPromise = webex.meetings.unregister();
1085
+
1086
+ // All should return the same promise
1087
+ assert.strictEqual(firstUnregisterPromise, secondUnregisterPromise);
1088
+ assert.strictEqual(secondUnregisterPromise, thirdUnregisterPromise);
1089
+
1090
+ // Complete the unregistration
1091
+ resolveUnregistration();
1092
+
1093
+ await firstUnregisterPromise;
1094
+ await secondUnregisterPromise;
1095
+ await thirdUnregisterPromise;
1096
+
1097
+ // Mercury disconnect and device unregister should only be called once
1098
+ assert.calledOnce(webex.internal.mercury.disconnect);
1099
+ assert.calledOnce(webex.internal.device.unregister);
1100
+ assert.isFalse(webex.meetings.registered);
1101
+ });
1102
+
1103
+ it('clears unregistrationPromise after successful unregistration', async () => {
1104
+ webex.meetings.registered = true;
1105
+
1106
+ await webex.meetings.unregister();
1107
+
1108
+ assert.isFalse(webex.meetings.registered);
1109
+ assert.isNull(webex.meetings.unregistrationPromise);
1110
+ });
1111
+
1112
+ it('clears unregistrationPromise after failed unregistration', async () => {
1113
+ webex.meetings.registered = true;
1114
+
1115
+ webex.internal.mercury.disconnect.rejects(new Error('disconnect failed'));
1116
+
1117
+ await assert.isRejected(webex.meetings.unregister());
1118
+
1119
+ assert.isTrue(webex.meetings.registered);
1120
+ assert.isNull(webex.meetings.unregistrationPromise);
1121
+ });
1122
+
1123
+ it('allows new unregistration after previous unregistration completes', async () => {
1124
+ webex.meetings.registered = true;
1125
+
1126
+ // First unregistration
1127
+ await webex.meetings.unregister();
1128
+ assert.isFalse(webex.meetings.registered);
1129
+
1130
+ // Register again
1131
+ webex.canAuthorize = true;
1132
+ await webex.meetings.register();
1133
+ assert.isTrue(webex.meetings.registered);
1134
+
1135
+ // Reset history
1136
+ webex.internal.mercury.disconnect.resetHistory();
1137
+ webex.internal.device.unregister.resetHistory();
1138
+
1139
+ // Second unregistration should work normally
1140
+ await webex.meetings.unregister();
1141
+ assert.calledOnce(webex.internal.mercury.disconnect);
1142
+ assert.calledOnce(webex.internal.device.unregister);
1143
+ assert.isFalse(webex.meetings.registered);
1144
+ });
1145
+
1146
+ it('handles register called during unregistration that fails', async () => {
1147
+ webex.canAuthorize = true;
1148
+ webex.meetings.registered = true;
1149
+
1150
+ const unregistrationError = new Error('unregistration failed');
1151
+ let rejectUnregistration;
1152
+ const unregistrationDelay = new Promise((resolve, reject) => {
1153
+ rejectUnregistration = reject;
1154
+ });
1155
+
1156
+ webex.internal.mercury.disconnect.returns(unregistrationDelay);
1157
+
1158
+ // Start unregistration (don't await)
1159
+ const unregisterPromise = webex.meetings.unregister();
1160
+
1161
+ // Call register while unregistration is in progress
1162
+ const registerPromise = webex.meetings.register();
1163
+
1164
+ // Fail the unregistration
1165
+ rejectUnregistration(unregistrationError);
1166
+
1167
+ // Unregistration should fail
1168
+ await assert.isRejected(unregisterPromise, 'unregistration failed');
1169
+
1170
+ // Register should still succeed (retry after unregister failure)
1171
+ await registerPromise;
1172
+
1173
+ // Verify final state - should be registered
1174
+ assert.isTrue(webex.meetings.registered);
1175
+ assert.isNull(webex.meetings.unregistrationPromise);
1176
+ });
1177
+
1178
+ it('logs appropriate message when register is called during unregistration', async () => {
1179
+ webex.canAuthorize = true;
1180
+ webex.meetings.registered = true;
1181
+
1182
+ const loggerSpy = sinon.spy(LoggerProxy.logger, 'info');
1183
+
1184
+ let resolveUnregistration;
1185
+ const unregistrationDelay = new Promise((resolve) => {
1186
+ resolveUnregistration = resolve;
1187
+ });
1188
+
1189
+ webex.internal.mercury.disconnect.returns(unregistrationDelay);
1190
+ webex.internal.device.unregister.returns(Promise.resolve());
1191
+
1192
+ // Start unregistration
1193
+ const unregisterPromise = webex.meetings.unregister();
1194
+
1195
+ // Call register during unregistration
1196
+ const registerPromise = webex.meetings.register();
1197
+
1198
+ // Should log that it's waiting
1199
+ assert.calledWith(
1200
+ loggerSpy,
1201
+ 'Meetings:index#register --> INFO, Meetings plugin unregistration in progress, waiting to register'
1202
+ );
1203
+
1204
+ // Complete unregistration and registration
1205
+ resolveUnregistration();
1206
+ await unregisterPromise;
1207
+ await registerPromise;
1208
+
1209
+ loggerSpy.restore();
1210
+ });
673
1211
  });
674
1212
 
675
1213
  describe('virtual background effect', () => {
@@ -732,7 +1270,7 @@ describe('plugin-meetings', () => {
732
1270
  };
733
1271
  });
734
1272
 
735
- it('creates noise reduction effect', async () => {
1273
+ it('creates noise reduction effect with BNR model', async () => {
736
1274
  const result = await webex.meetings.createNoiseReductionEffect({audioContext: {}});
737
1275
 
738
1276
  assert.exists(result);
@@ -744,30 +1282,51 @@ describe('plugin-meetings', () => {
744
1282
  authToken: 'fake_token',
745
1283
  mode: 'WORKLET',
746
1284
  avoidSimd: false,
1285
+ model: 'bnr',
747
1286
  });
748
1287
  assert.exists(result.enable);
749
1288
  assert.exists(result.disable);
750
1289
  assert.exists(result.dispose);
751
1290
  });
752
1291
 
753
- it('creates noise reduction effect with custom options passed', async () => {
754
- const effectOptions = {
1292
+ it('creates noise reduction effect with OFMV model', async () => {
1293
+ const result = await webex.meetings.createNoiseReductionEffect({
755
1294
  audioContext: {},
756
- mode: 'LEGACY',
757
- env: 'int',
758
- avoidSimd: true,
759
- };
760
-
761
- const result = await webex.meetings.createNoiseReductionEffect(effectOptions);
1295
+ model: 'ofmv',
1296
+ });
762
1297
 
763
1298
  assert.exists(result);
764
1299
  assert.instanceOf(result, NoiseReductionEffect);
765
1300
  assert.containsAllKeys(result, ['audioContext', 'isEnabled', 'isReady', 'options']);
766
- assert.deepEqual(result.options, {...effectOptions, authToken: 'fake_token'});
1301
+ assert.equal(result.options.authToken, 'fake_token');
1302
+ assert.deepEqual(result.options, {
1303
+ audioContext: {},
1304
+ authToken: 'fake_token',
1305
+ mode: 'WORKLET',
1306
+ avoidSimd: false,
1307
+ model: 'ofmv',
1308
+ });
767
1309
  assert.exists(result.enable);
768
1310
  assert.exists(result.disable);
769
1311
  assert.exists(result.dispose);
770
1312
  });
1313
+
1314
+ it('passes custom options to noise reduction effect', async () => {
1315
+ const result = await webex.meetings.createNoiseReductionEffect({
1316
+ audioContext: {},
1317
+ mode: 'LEGACY',
1318
+ env: 'int',
1319
+ avoidSimd: true,
1320
+ });
1321
+
1322
+ assert.exists(result);
1323
+ assert.instanceOf(result, NoiseReductionEffect);
1324
+ assert.equal(result.options.mode, 'LEGACY');
1325
+ assert.equal(result.options.env, 'int');
1326
+ assert.equal(result.options.avoidSimd, true);
1327
+ assert.equal(result.options.authToken, 'fake_token');
1328
+ assert.equal(result.options.model, 'bnr');
1329
+ });
771
1330
  });
772
1331
 
773
1332
  describe('gets', () => {
@@ -789,15 +1348,96 @@ describe('plugin-meetings', () => {
789
1348
  it('gets the personal meeting room instance from webex.meetings', () => {
790
1349
  const personalMeetingRoom = webex.meetings.getPersonalMeetingRoom();
791
1350
 
792
- assert.exists(
793
- personalMeetingRoom,
794
- 'personal meeting room instance is set up at object creation'
1351
+ assert.exists(
1352
+ personalMeetingRoom,
1353
+ 'personal meeting room instance is set up at object creation'
1354
+ );
1355
+ assert.instanceOf(
1356
+ personalMeetingRoom,
1357
+ PersonalMeetingRoom,
1358
+ 'should be a personal meeting room instance'
1359
+ );
1360
+ });
1361
+ });
1362
+ describe('#fetchSitePreferencesMeViaSite', () => {
1363
+ const sitePreferencesResponse = {
1364
+ scheduling: {
1365
+ supportScheduleWebinar: true,
1366
+ webinarWebLink: 'https://go.webex.com/webappng/sites/go/webinar/scheduler',
1367
+ },
1368
+ };
1369
+
1370
+ beforeEach(() => {
1371
+ webex.meetings.request.fetchSitePreferencesMeViaSite = sinon
1372
+ .stub()
1373
+ .resolves(sitePreferencesResponse);
1374
+ });
1375
+
1376
+ it('should have #fetchSitePreferencesMeViaSite', () => {
1377
+ assert.exists(webex.meetings.fetchSitePreferencesMeViaSite);
1378
+ });
1379
+
1380
+ it('fetches scheduling preferences for the preferred Webex site by default', async () => {
1381
+ webex.meetings.preferredWebexSite = 'go.webex.com';
1382
+
1383
+ const result = await webex.meetings.fetchSitePreferencesMeViaSite();
1384
+
1385
+ assert.deepEqual(result, sitePreferencesResponse);
1386
+ assert.calledOnceWithExactly(
1387
+ webex.meetings.request.fetchSitePreferencesMeViaSite,
1388
+ {
1389
+ siteUrl: 'go.webex.com',
1390
+ }
1391
+ );
1392
+ });
1393
+
1394
+ it('uses the provided Webex site instead of the preferred Webex site', async () => {
1395
+ webex.meetings.preferredWebexSite = 'preferred.webex.com';
1396
+
1397
+ await webex.meetings.fetchSitePreferencesMeViaSite({siteUrl: 'go.webex.com'});
1398
+
1399
+ assert.calledOnceWithExactly(
1400
+ webex.meetings.request.fetchSitePreferencesMeViaSite,
1401
+ {
1402
+ siteUrl: 'go.webex.com',
1403
+ }
1404
+ );
1405
+ });
1406
+
1407
+ it('forwards custom site name and preference sections to the request helper', async () => {
1408
+ webex.meetings.preferredWebexSite = 'go.webex.com';
1409
+
1410
+ await webex.meetings.fetchSitePreferencesMeViaSite({
1411
+ siteName: 'custom-site',
1412
+ selectOptions: [SitePreferenceSelectOption.SCHEDULING],
1413
+ });
1414
+
1415
+ assert.calledOnceWithExactly(
1416
+ webex.meetings.request.fetchSitePreferencesMeViaSite,
1417
+ {
1418
+ siteUrl: 'go.webex.com',
1419
+ siteName: 'custom-site',
1420
+ selectOptions: [SitePreferenceSelectOption.SCHEDULING],
1421
+ }
1422
+ );
1423
+ });
1424
+
1425
+ it('throws when no Webex site is available', () => {
1426
+ webex.meetings.preferredWebexSite = '';
1427
+ webex.meetings.request.fetchSitePreferencesMeViaSite.throws(
1428
+ new ParameterError(
1429
+ 'No siteUrl available. Call register() before fetching site preferences or provide options.siteUrl.'
1430
+ )
795
1431
  );
796
- assert.instanceOf(
797
- personalMeetingRoom,
798
- PersonalMeetingRoom,
799
- 'should be a personal meeting room instance'
1432
+
1433
+ assert.throws(
1434
+ () => webex.meetings.fetchSitePreferencesMeViaSite(),
1435
+ ParameterError,
1436
+ 'No siteUrl available. Call register() before fetching site preferences or provide options.siteUrl.'
800
1437
  );
1438
+ assert.calledOnceWithExactly(webex.meetings.request.fetchSitePreferencesMeViaSite, {
1439
+ siteUrl: '',
1440
+ });
801
1441
  });
802
1442
  });
803
1443
  describe('Static shortcut proxy methods', () => {
@@ -836,7 +1476,7 @@ describe('plugin-meetings', () => {
836
1476
  it('should have #syncMeetings', () => {
837
1477
  assert.exists(webex.meetings.syncMeetings);
838
1478
  });
839
- it('should do nothing and return a resolved promise if unverified guest', async () => {
1479
+ it('should skip getActiveMeetings but still call syncAllHashTreeDatasets if unverified guest', async () => {
840
1480
  webex.meetings.request.getActiveMeetings = sinon.stub().returns(
841
1481
  Promise.resolve({
842
1482
  loci: [
@@ -849,13 +1489,23 @@ describe('plugin-meetings', () => {
849
1489
  webex.credentials.isUnverifiedGuest = true;
850
1490
  LoggerProxy.logger.info = sinon.stub();
851
1491
 
1492
+ const mockLocusInfo = {
1493
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
1494
+ };
1495
+ webex.meetings.meetingCollection.getAll = sinon.stub().returns({
1496
+ meeting1: {locusInfo: mockLocusInfo},
1497
+ meeting2: {locusInfo: undefined},
1498
+ meeting3: {},
1499
+ });
1500
+
852
1501
  await webex.meetings.syncMeetings();
853
1502
 
854
1503
  assert.notCalled(webex.meetings.request.getActiveMeetings);
855
1504
  assert.calledWith(
856
1505
  LoggerProxy.logger.info,
857
- 'Meetings:index#syncMeetings --> skipping meeting sync as unverified guest'
1506
+ 'Meetings:index#syncMeetings --> user is unverified guest, skipping calling Locus for meeting sync'
858
1507
  );
1508
+ assert.calledOnce(mockLocusInfo.syncAllHashTreeDatasets);
859
1509
  });
860
1510
  describe('succesful requests', () => {
861
1511
  beforeEach(() => {
@@ -874,6 +1524,9 @@ describe('plugin-meetings', () => {
874
1524
  webex.meetings.meetingCollection.getByKey = sinon.stub().returns({
875
1525
  locusInfo,
876
1526
  });
1527
+ webex.meetings.meetingCollection.getAll = sinon.stub().returns({
1528
+ meeting1: {locusInfo, locusUrl: url1},
1529
+ });
877
1530
  });
878
1531
  it('tests the sync meeting calls for existing meeting', async () => {
879
1532
  await webex.meetings.syncMeetings();
@@ -881,6 +1534,7 @@ describe('plugin-meetings', () => {
881
1534
  assert.calledOnce(webex.meetings.meetingCollection.getByKey);
882
1535
  assert.calledOnce(locusInfo.parse);
883
1536
  assert.calledWith(webex.meetings.meetingCollection.getByKey, 'locusUrl', url1);
1537
+ assert.calledOnce(locusInfo.syncAllHashTreeDatasets);
884
1538
  });
885
1539
  });
886
1540
  describe('when meeting is not returned', () => {
@@ -918,8 +1572,8 @@ describe('plugin-meetings', () => {
918
1572
  locus: {
919
1573
  url: url1,
920
1574
  },
921
- hashTreeMessage: undefined
922
- });
1575
+ hashTreeMessage: undefined,
1576
+ }, sinon.match.func);
923
1577
  });
924
1578
  });
925
1579
  describe('when destroying meeting is needed', () => {
@@ -965,7 +1619,7 @@ describe('plugin-meetings', () => {
965
1619
  it('destroy any meeting that has no active locus url if keepOnlyLocusMeetings is not defined', async () => {
966
1620
  await webex.meetings.syncMeetings();
967
1621
  assert.calledOnce(webex.meetings.request.getActiveMeetings);
968
- assert.calledOnce(webex.meetings.meetingCollection.getAll);
1622
+ assert.calledTwice(webex.meetings.meetingCollection.getAll);
969
1623
  assert.calledWith(destroySpy, meetingCollectionMeetings.noLongerValidLocusMeeting);
970
1624
  assert.calledWith(destroySpy, meetingCollectionMeetings.otherNonLocusMeeting1);
971
1625
  assert.calledWith(destroySpy, meetingCollectionMeetings.otherNonLocusMeeting2);
@@ -977,7 +1631,7 @@ describe('plugin-meetings', () => {
977
1631
  it('destroy any meeting that has no active locus url if keepOnlyLocusMeetings === true', async () => {
978
1632
  await webex.meetings.syncMeetings({keepOnlyLocusMeetings: true});
979
1633
  assert.calledOnce(webex.meetings.request.getActiveMeetings);
980
- assert.calledOnce(webex.meetings.meetingCollection.getAll);
1634
+ assert.calledTwice(webex.meetings.meetingCollection.getAll);
981
1635
  assert.calledWith(destroySpy, meetingCollectionMeetings.noLongerValidLocusMeeting);
982
1636
  assert.calledWith(destroySpy, meetingCollectionMeetings.otherNonLocusMeeting1);
983
1637
  assert.calledWith(destroySpy, meetingCollectionMeetings.otherNonLocusMeeting2);
@@ -989,7 +1643,7 @@ describe('plugin-meetings', () => {
989
1643
  it('destroy any LOCUS meetings that have no active locus url if keepOnlyLocusMeetings === false', async () => {
990
1644
  await webex.meetings.syncMeetings({keepOnlyLocusMeetings: false});
991
1645
  assert.calledOnce(webex.meetings.request.getActiveMeetings);
992
- assert.calledOnce(webex.meetings.meetingCollection.getAll);
1646
+ assert.calledTwice(webex.meetings.meetingCollection.getAll);
993
1647
  assert.calledWith(destroySpy, meetingCollectionMeetings.noLongerValidLocusMeeting);
994
1648
  assert.callCount(destroySpy, 1);
995
1649
 
@@ -997,6 +1651,147 @@ describe('plugin-meetings', () => {
997
1651
  });
998
1652
  });
999
1653
  });
1654
+
1655
+ describe('when globalMeetingId preserves breakout meetings', () => {
1656
+ let destroySpy;
1657
+ let cleanUpSpy;
1658
+
1659
+ beforeEach(() => {
1660
+ destroySpy = sinon.spy(webex.meetings, 'destroy');
1661
+ cleanUpSpy = sinon.stub(MeetingUtil, 'cleanUp').returns(Promise.resolve());
1662
+ });
1663
+
1664
+ afterEach(() => {
1665
+ cleanUpSpy.restore();
1666
+ });
1667
+
1668
+ it('should not destroy a meeting whose globalMeetingId matches an active locus', async () => {
1669
+ const meetingCollectionMeetings = {
1670
+ breakoutMeeting: {
1671
+ locusUrl: 'breakout-url',
1672
+ locusInfo: {
1673
+ info: {globalMeetingId: 'gmid-123'},
1674
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
1675
+ },
1676
+ sendCallAnalyzerMetrics: sinon.stub(),
1677
+ },
1678
+ };
1679
+
1680
+ webex.meetings.meetingCollection.getAll = sinon
1681
+ .stub()
1682
+ .returns(meetingCollectionMeetings);
1683
+ webex.meetings.request.getActiveMeetings = sinon.stub().resolves({
1684
+ loci: [{url: 'main-url', info: {globalMeetingId: 'gmid-123'}}],
1685
+ });
1686
+
1687
+ await webex.meetings.syncMeetings();
1688
+
1689
+ assert.notCalled(destroySpy);
1690
+ });
1691
+
1692
+ it('should destroy a meeting whose globalMeetingId does NOT match any active locus', async () => {
1693
+ const meetingCollectionMeetings = {
1694
+ breakoutMeeting: {
1695
+ locusUrl: 'breakout-url',
1696
+ locusInfo: {
1697
+ info: {globalMeetingId: 'gmid-other'},
1698
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
1699
+ },
1700
+ sendCallAnalyzerMetrics: sinon.stub(),
1701
+ },
1702
+ };
1703
+
1704
+ webex.meetings.meetingCollection.getAll = sinon
1705
+ .stub()
1706
+ .returns(meetingCollectionMeetings);
1707
+ webex.meetings.request.getActiveMeetings = sinon.stub().resolves({
1708
+ loci: [{url: 'main-url', info: {globalMeetingId: 'gmid-123'}}],
1709
+ });
1710
+
1711
+ await webex.meetings.syncMeetings();
1712
+
1713
+ assert.calledOnce(destroySpy);
1714
+ assert.calledWith(destroySpy, meetingCollectionMeetings.breakoutMeeting);
1715
+ });
1716
+ });
1717
+
1718
+ describe('skipHashTreeSync parameter', () => {
1719
+ it('should skip syncAllHashTreeDatasets when skipHashTreeSync is true', async () => {
1720
+ const mockLocusInfo = {
1721
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
1722
+ };
1723
+
1724
+ webex.meetings.request.getActiveMeetings = sinon.stub().resolves({loci: []});
1725
+ webex.meetings.meetingCollection.getAll = sinon.stub().returns({
1726
+ meeting1: {locusInfo: mockLocusInfo},
1727
+ });
1728
+
1729
+ await webex.meetings.syncMeetings({keepOnlyLocusMeetings: false, skipHashTreeSync: true});
1730
+
1731
+ assert.calledOnce(webex.meetings.request.getActiveMeetings);
1732
+ assert.notCalled(mockLocusInfo.syncAllHashTreeDatasets);
1733
+ });
1734
+
1735
+ it('should call syncAllHashTreeDatasets when skipHashTreeSync is false (default)', async () => {
1736
+ const mockLocusInfo = {
1737
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
1738
+ };
1739
+
1740
+ webex.meetings.request.getActiveMeetings = sinon.stub().resolves({loci: []});
1741
+ webex.meetings.meetingCollection.getAll = sinon.stub().returns({
1742
+ meeting1: {locusInfo: mockLocusInfo},
1743
+ });
1744
+
1745
+ await webex.meetings.syncMeetings({keepOnlyLocusMeetings: false, skipHashTreeSync: false});
1746
+
1747
+ assert.calledOnce(webex.meetings.request.getActiveMeetings);
1748
+ assert.calledOnce(mockLocusInfo.syncAllHashTreeDatasets);
1749
+ });
1750
+ });
1751
+
1752
+ describe('syncAllHashTreeDatasets in syncMeetings', () => {
1753
+ it('should call syncAllHashTreeDatasets for multiple meetings, skipping those without locusInfo', async () => {
1754
+ const mockLocusInfo1 = {
1755
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
1756
+ };
1757
+ const mockLocusInfo2 = {
1758
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
1759
+ };
1760
+
1761
+ webex.meetings.request.getActiveMeetings = sinon.stub().resolves({loci: []});
1762
+ webex.meetings.meetingCollection.getAll = sinon.stub().returns({
1763
+ meeting1: {locusInfo: mockLocusInfo1},
1764
+ meeting2: {locusInfo: undefined},
1765
+ meeting3: {locusInfo: mockLocusInfo2},
1766
+ meeting4: {},
1767
+ });
1768
+
1769
+ await webex.meetings.syncMeetings({keepOnlyLocusMeetings: false});
1770
+
1771
+ assert.calledOnce(mockLocusInfo1.syncAllHashTreeDatasets);
1772
+ assert.calledOnce(mockLocusInfo2.syncAllHashTreeDatasets);
1773
+ });
1774
+
1775
+ it('should not call syncAllHashTreeDatasets when getActiveMeetings throws an error', async () => {
1776
+ const mockLocusInfo = {
1777
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
1778
+ };
1779
+
1780
+ webex.meetings.request.getActiveMeetings = sinon.stub().rejects(new Error('network error'));
1781
+ webex.meetings.meetingCollection.getAll = sinon.stub().returns({
1782
+ meeting1: {locusInfo: mockLocusInfo},
1783
+ });
1784
+
1785
+ try {
1786
+ await webex.meetings.syncMeetings();
1787
+ assert.fail('should have thrown');
1788
+ } catch (err) {
1789
+ assert.equal(err.message, 'network error');
1790
+ }
1791
+
1792
+ assert.notCalled(mockLocusInfo.syncAllHashTreeDatasets);
1793
+ });
1794
+ });
1000
1795
  });
1001
1796
  describe('#fetchStaticMeetingLink', () => {
1002
1797
  const conversationUrl = 'conv.fakeconversationurl.com';
@@ -1203,8 +1998,30 @@ describe('plugin-meetings', () => {
1203
1998
 
1204
1999
  it('calls createMeeting with classificationId and returns its promise', async () => {
1205
2000
  await checkCallCreateMeeting(
1206
- [test1, test2, FAKE_USE_RANDOM_DELAY, {}, undefined, true, callStateForMetrics, undefined, undefined, undefined, classificationId],
1207
- [test1, test2, FAKE_USE_RANDOM_DELAY, {}, callStateForMetrics, true, undefined, undefined, classificationId],
2001
+ [
2002
+ test1,
2003
+ test2,
2004
+ FAKE_USE_RANDOM_DELAY,
2005
+ {},
2006
+ undefined,
2007
+ true,
2008
+ callStateForMetrics,
2009
+ undefined,
2010
+ undefined,
2011
+ undefined,
2012
+ classificationId,
2013
+ ],
2014
+ [
2015
+ test1,
2016
+ test2,
2017
+ FAKE_USE_RANDOM_DELAY,
2018
+ {},
2019
+ callStateForMetrics,
2020
+ true,
2021
+ undefined,
2022
+ undefined,
2023
+ classificationId,
2024
+ ]
1208
2025
  );
1209
2026
  });
1210
2027
 
@@ -1437,36 +2254,80 @@ describe('plugin-meetings', () => {
1437
2254
  webExMeetingId,
1438
2255
  },
1439
2256
  },
1440
- hashTreeMessage: undefined
1441
- });
2257
+ hashTreeMessage: undefined,
2258
+ }, sinon.match.func);
1442
2259
  });
1443
2260
  it('should setup the meeting from a hash tree event', async () => {
1444
- const locus = {
1445
- id: uuid1,
1446
- self: {},
1447
- info: {
1448
- webExMeetingId,
1449
- },
2261
+ const selfData = {};
2262
+ const infoData = {webExMeetingId};
2263
+ const hashTreeMessage = {
2264
+ locusUrl: url1,
2265
+ locusStateElements: [
2266
+ {
2267
+ htMeta: {elementId: {type: 'Self', id: 1, version: 1}},
2268
+ data: selfData,
2269
+ },
2270
+ {
2271
+ htMeta: {elementId: {type: 'Info', id: 2, version: 1}},
2272
+ data: infoData,
2273
+ },
2274
+ ],
1450
2275
  };
1451
- const hashTreeMessage = {something: 'hashTreeData'};
1452
2276
  await webex.meetings.handleLocusEvent({
1453
- locus,
1454
2277
  eventType: 'locus.state_message',
1455
2278
  locusUrl: url1,
1456
2279
  stateElementsMessage: hashTreeMessage,
1457
2280
  });
1458
2281
  assert.calledWith(webex.meetings.meetingCollection.getByKey, 'locusUrl', url1);
1459
- assert.calledWith(
1460
- webex.meetings.meetingCollection.getByKey,
1461
- 'meetingNumber',
1462
- webExMeetingId
1463
- );
1464
2282
  assert.calledOnce(initialSetup);
1465
2283
  assert.calledWith(initialSetup, {
1466
2284
  trigger: 'locus-message',
1467
- locus,
2285
+ locus: {
2286
+ participants: [],
2287
+ url: url1,
2288
+ self: selfData,
2289
+ info: infoData,
2290
+ },
1468
2291
  hashTreeMessage,
2292
+ }, sinon.match.func);
2293
+ });
2294
+
2295
+ it('should ignore hash tree event when created locus has INACTIVE fullState', async () => {
2296
+ const hashTreeMessage = {
2297
+ locusUrl: url1,
2298
+ locusStateElements: [
2299
+ {
2300
+ htMeta: {elementId: {type: 'FullState', id: 1, version: 1}},
2301
+ data: {state: 'INACTIVE'},
2302
+ },
2303
+ ],
2304
+ };
2305
+ await webex.meetings.handleLocusEvent({
2306
+ eventType: 'locus.state_message',
2307
+ locusUrl: url1,
2308
+ stateElementsMessage: hashTreeMessage,
2309
+ });
2310
+ assert.notCalled(webex.meetings.create);
2311
+ assert.notCalled(initialSetup);
2312
+ });
2313
+
2314
+ it('should ignore hash tree event when created locus has self LEFT and removed', async () => {
2315
+ const hashTreeMessage = {
2316
+ locusUrl: url1,
2317
+ locusStateElements: [
2318
+ {
2319
+ htMeta: {elementId: {type: 'Self', id: 1, version: 1}},
2320
+ data: {state: 'LEFT', removed: true},
2321
+ },
2322
+ ],
2323
+ };
2324
+ await webex.meetings.handleLocusEvent({
2325
+ eventType: 'locus.state_message',
2326
+ locusUrl: url1,
2327
+ stateElementsMessage: hashTreeMessage,
1469
2328
  });
2329
+ assert.notCalled(webex.meetings.create);
2330
+ assert.notCalled(initialSetup);
1470
2331
  });
1471
2332
  it('should setup the meeting by difference event without replaces', async () => {
1472
2333
  await webex.meetings.handleLocusEvent({
@@ -1507,8 +2368,8 @@ describe('plugin-meetings', () => {
1507
2368
  webExMeetingId,
1508
2369
  },
1509
2370
  },
1510
- hashTreeMessage: undefined
1511
- });
2371
+ hashTreeMessage: undefined,
2372
+ }, sinon.match.func);
1512
2373
  });
1513
2374
 
1514
2375
  it('sends client event correctly on finally', async () => {
@@ -1583,8 +2444,8 @@ describe('plugin-meetings', () => {
1583
2444
  webExMeetingId,
1584
2445
  },
1585
2446
  },
1586
- hashTreeMessage: undefined
1587
- });
2447
+ hashTreeMessage: undefined,
2448
+ }, sinon.match.func);
1588
2449
  });
1589
2450
 
1590
2451
  const generateFakeLocusData = (isUnifiedSpaceMeeting) => ({
@@ -2212,6 +3073,39 @@ describe('plugin-meetings', () => {
2212
3073
  checkCreateMeetingWithNoMeetingInfo(true, true);
2213
3074
  });
2214
3075
 
3076
+ it('does not emit meeting:added when meeting is destroyed due to missing meeting info', async () => {
3077
+ // Make destroy actually remove the meeting from the collection
3078
+ // so that getMeetingByType returns null in the finally block
3079
+ webex.meetings.destroy = sinon.stub().callsFake((meeting) => {
3080
+ webex.meetings.meetingCollection.delete(meeting.id);
3081
+ });
3082
+
3083
+ try {
3084
+ await webex.meetings.createMeeting(
3085
+ 'test destination',
3086
+ 'test type',
3087
+ undefined,
3088
+ undefined,
3089
+ undefined,
3090
+ true
3091
+ );
3092
+ assert.fail('should have thrown NoMeetingInfoError');
3093
+ } catch (err) {
3094
+ assert.instanceOf(err, NoMeetingInfoError);
3095
+ }
3096
+
3097
+ assert.calledOnce(webex.meetings.destroy);
3098
+
3099
+ // meeting:added should NOT have been triggered since the meeting was destroyed
3100
+ assert.neverCalledWith(
3101
+ TriggerProxy.trigger,
3102
+ sinon.match.any,
3103
+ sinon.match({function: 'createMeeting'}),
3104
+ 'meeting:added',
3105
+ sinon.match.any
3106
+ );
3107
+ });
3108
+
2215
3109
  it('creates the meeting avoiding meeting info fetch by passing type as DESTINATION_TYPE.ONE_ON_ONE_CALL', async () => {
2216
3110
  const meeting = await webex.meetings.createMeeting(
2217
3111
  'test destination',
@@ -2226,6 +3120,30 @@ describe('plugin-meetings', () => {
2226
3120
 
2227
3121
  assert.notCalled(webex.meetings.meetingInfo.fetchMeetingInfo);
2228
3122
  });
3123
+
3124
+ [
3125
+ {fullStateType: 'CALL'},
3126
+ {fullStateType: 'SIP_BRIDGE'},
3127
+ {fullStateType: 'SPACE_SHARE'},
3128
+ ].forEach(({fullStateType}) => {
3129
+ it(`skips meeting info fetch when LOCUS_ID destination is a 1:1 call (fullState.type ${fullStateType})`, async () => {
3130
+ const locusDestination = {
3131
+ fullState: {type: fullStateType},
3132
+ };
3133
+
3134
+ const meeting = await webex.meetings.createMeeting(
3135
+ locusDestination,
3136
+ DESTINATION_TYPE.LOCUS_ID
3137
+ );
3138
+
3139
+ assert.instanceOf(
3140
+ meeting,
3141
+ Meeting,
3142
+ 'createMeeting should eventually resolve to a Meeting Object'
3143
+ );
3144
+ assert.notCalled(webex.meetings.meetingInfo.fetchMeetingInfo);
3145
+ });
3146
+ });
2229
3147
  });
2230
3148
 
2231
3149
  describe('rejected MeetingInfo.#fetchMeetingInfo - does not log for known Error types', () => {
@@ -2649,10 +3567,13 @@ describe('plugin-meetings', () => {
2649
3567
  };
2650
3568
 
2651
3569
  it('triggers correct event when SELF_CANNOT_VIEW_PARTICIPANT_LIST_CHANGE emitted', async () => {
3570
+ sinon.stub(meeting, 'updateMeetingActions');
2652
3571
  checkSelfTrigger(
2653
3572
  LOCUSINFO.EVENTS.SELF_CANNOT_VIEW_PARTICIPANT_LIST_CHANGE,
2654
3573
  EVENT_TRIGGERS.MEETING_SELF_CANNOT_VIEW_PARTICIPANT_LIST
2655
3574
  );
3575
+ assert.calledOnce(meeting.updateMeetingActions);
3576
+ meeting.updateMeetingActions.restore();
2656
3577
  });
2657
3578
 
2658
3579
  it('triggers correct event when SELF_IS_SHARING_BLOCKED_CHANGE emitted', async () => {
@@ -2805,6 +3726,21 @@ describe('plugin-meetings', () => {
2805
3726
  'Meetings:index#isNeedHandleMainLocus --> self device left&moved in main locus with self joined status, not need to handle'
2806
3727
  );
2807
3728
  });
3729
+
3730
+ it('check breakout ended with self removed, return false', () => {
3731
+ webex.meetings.meetingCollection.getActiveBreakoutLocus = sinon.stub().returns(null);
3732
+ newLocus.self.state = 'LEFT';
3733
+ newLocus.self.reason = 'OTHER';
3734
+ newLocus.self.removed = true;
3735
+ newLocus.fullState = {state: 'INACTIVE', endMeetingReason: 'BREAKOUT_ENDED'};
3736
+ LoggerProxy.logger.log = sinon.stub();
3737
+ const result = webex.meetings.isNeedHandleMainLocus(meeting, newLocus);
3738
+ assert.equal(result, false);
3739
+ assert.calledWith(
3740
+ LoggerProxy.logger.log,
3741
+ 'Meetings:index#isNeedHandleMainLocus --> self moved main locus with self removed status or with device resource moved, not need to handle'
3742
+ );
3743
+ });
2808
3744
  });
2809
3745
 
2810
3746
  describe('#isNeedHandleLocusDTO', () => {
@@ -2865,6 +3801,18 @@ describe('plugin-meetings', () => {
2865
3801
  const result = webex.meetings.isNeedHandleLocusDTO(meeting, newLocus);
2866
3802
  assert.equal(result, false);
2867
3803
  });
3804
+ it('breakout session with breakout ended, return false', () => {
3805
+ newLocus.controls.breakout = {
3806
+ sessionType: 'BREAKOUT',
3807
+ };
3808
+ newLocus.self.state = 'LEFT';
3809
+ newLocus.self.reason = 'OTHER';
3810
+ newLocus.self.devices = [];
3811
+ newLocus.fullState = {state: 'INACTIVE', endMeetingReason: 'BREAKOUT_ENDED'};
3812
+ LoggerProxy.logger.log = sinon.stub();
3813
+ const result = webex.meetings.isNeedHandleLocusDTO(meeting, newLocus);
3814
+ assert.equal(result, false);
3815
+ });
2868
3816
  it('moved to lobby, return true', () => {
2869
3817
  newLocus.controls.breakout = {
2870
3818
  sessionType: 'MAIN',
@@ -2911,7 +3859,7 @@ describe('plugin-meetings', () => {
2911
3859
  conversationUrl: 'conversationUrl1',
2912
3860
  };
2913
3861
 
2914
- sinon.stub(MeetingsUtil, 'checkForCorrelationId').returns('correlationId1');
3862
+ sinon.stub(MeetingsUtil, 'getCorrelationIdForDevice').returns('correlationId1');
2915
3863
  });
2916
3864
  afterEach(() => {
2917
3865
  sinon.restore();
@@ -3017,6 +3965,197 @@ describe('plugin-meetings', () => {
3017
3965
  );
3018
3966
  assert.calledWith(webex.meetings.meetingCollection.getByKey, 'meetingNumber', '123456');
3019
3967
  });
3968
+
3969
+ describe('when receiving hash tree events', () => {
3970
+ let hashTreeEvent;
3971
+
3972
+ beforeEach(() => {
3973
+ MeetingsUtil.getCorrelationIdForDevice.restore();
3974
+ sinon.spy(MeetingsUtil, 'getCorrelationIdForDevice');
3975
+
3976
+ hashTreeEvent = {
3977
+ eventType: 'locus.state_message',
3978
+ stateElementsMessage: {
3979
+ locusUrl: url1,
3980
+ locusStateElements: [
3981
+ {
3982
+ htMeta: {
3983
+ elementId: {
3984
+ type: 'participant',
3985
+ id: 2,
3986
+ version: 1,
3987
+ },
3988
+ dataSetNames: ['main'],
3989
+ },
3990
+ data: {
3991
+ id: 'participant1',
3992
+ },
3993
+ },
3994
+ {
3995
+ htMeta: {
3996
+ elementId: {
3997
+ type: 'Self',
3998
+ id: 1,
3999
+ version: 1,
4000
+ },
4001
+ dataSetNames: ['self'],
4002
+ },
4003
+ data: {
4004
+ callbackInfo: {
4005
+ callbackAddress: 'address1',
4006
+ },
4007
+ devices: [
4008
+ {
4009
+ url: 'deviceUrl',
4010
+ correlationId: 'correlationId1',
4011
+ },
4012
+ ],
4013
+ },
4014
+ },
4015
+ ],
4016
+ },
4017
+ };
4018
+
4019
+ webex.internal.device.url = 'deviceUrl';
4020
+ });
4021
+
4022
+ it('should find meeting by locusUrl from stateElementsMessage', () => {
4023
+ mockGetByKey('locusUrl');
4024
+ const result = webex.meetings.getCorrespondingMeetingByLocus(hashTreeEvent);
4025
+ assert.deepEqual(result, mockReturnMeeting);
4026
+ assert.calledOnceWithExactly(webex.meetings.meetingCollection.getByKey, 'locusUrl', url1);
4027
+ });
4028
+
4029
+ it('should extract self data from locusStateElements and try correlationId when locusUrl not found', () => {
4030
+ mockGetByKey('correlationId');
4031
+ const result = webex.meetings.getCorrespondingMeetingByLocus(hashTreeEvent);
4032
+ assert.deepEqual(result, mockReturnMeeting);
4033
+ assert.callCount(webex.meetings.meetingCollection.getByKey, 2);
4034
+ assert.calledWith(webex.meetings.meetingCollection.getByKey, 'locusUrl', url1);
4035
+ assert.calledWith(
4036
+ webex.meetings.meetingCollection.getByKey,
4037
+ 'correlationId',
4038
+ 'correlationId1'
4039
+ );
4040
+ assert.calledOnceWithExactly(
4041
+ MeetingsUtil.getCorrelationIdForDevice,
4042
+ 'deviceUrl',
4043
+ hashTreeEvent.stateElementsMessage.locusStateElements[1].data
4044
+ );
4045
+ });
4046
+
4047
+ it('should extract self data from locusStateElements and try sipUri when locusUrl and correlationId not found', () => {
4048
+ mockGetByKey('sipUri');
4049
+ const result = webex.meetings.getCorrespondingMeetingByLocus(hashTreeEvent);
4050
+ assert.deepEqual(result, mockReturnMeeting);
4051
+ assert.callCount(webex.meetings.meetingCollection.getByKey, 3);
4052
+ assert.calledWith(webex.meetings.meetingCollection.getByKey, 'locusUrl', url1);
4053
+ assert.calledWith(
4054
+ webex.meetings.meetingCollection.getByKey,
4055
+ 'correlationId',
4056
+ 'correlationId1'
4057
+ );
4058
+ assert.calledWith(webex.meetings.meetingCollection.getByKey, 'sipUri', 'address1');
4059
+ });
4060
+
4061
+ it('should try all keys when no meeting found', () => {
4062
+ mockGetByKey();
4063
+ const result = webex.meetings.getCorrespondingMeetingByLocus(hashTreeEvent);
4064
+ assert.isNull(result);
4065
+ assert.callCount(webex.meetings.meetingCollection.getByKey, 5);
4066
+ assert.calledWith(webex.meetings.meetingCollection.getByKey, 'locusUrl', url1);
4067
+ assert.calledWith(
4068
+ webex.meetings.meetingCollection.getByKey,
4069
+ 'correlationId',
4070
+ 'correlationId1'
4071
+ );
4072
+ assert.calledWith(webex.meetings.meetingCollection.getByKey, 'sipUri', 'address1');
4073
+ // these remaining 2 will never work for hash trees, but just checking that
4074
+ // the calls are made and we don't crash
4075
+ assert.calledWith(
4076
+ webex.meetings.meetingCollection.getByKey,
4077
+ 'conversationUrl',
4078
+ undefined
4079
+ );
4080
+ assert.calledWith(webex.meetings.meetingCollection.getByKey, 'meetingNumber', undefined);
4081
+ });
4082
+
4083
+ it('should handle hash tree event with no self object', () => {
4084
+ mockGetByKey();
4085
+ hashTreeEvent.stateElementsMessage.locusStateElements = [
4086
+ {
4087
+ htMeta: {
4088
+ elementId: {
4089
+ type: 'participant',
4090
+ id: 2,
4091
+ version: 1,
4092
+ },
4093
+ dataSetNames: ['dataset1'],
4094
+ },
4095
+ data: {
4096
+ id: 'participant1',
4097
+ },
4098
+ },
4099
+ ];
4100
+
4101
+ const result = webex.meetings.getCorrespondingMeetingByLocus(hashTreeEvent);
4102
+ assert.isNull(result);
4103
+ assert.callCount(webex.meetings.meetingCollection.getByKey, 5);
4104
+ assert.calledWith(webex.meetings.meetingCollection.getByKey, 'locusUrl', url1);
4105
+ assert.calledWith(webex.meetings.meetingCollection.getByKey, 'correlationId', false);
4106
+ assert.calledWith(webex.meetings.meetingCollection.getByKey, 'sipUri', undefined);
4107
+ // these remaining 2 will never work for hash trees, but just checking that
4108
+ // the calls are made and we don't crash
4109
+ assert.calledWith(
4110
+ webex.meetings.meetingCollection.getByKey,
4111
+ 'conversationUrl',
4112
+ undefined
4113
+ );
4114
+ assert.calledWith(webex.meetings.meetingCollection.getByKey, 'meetingNumber', undefined);
4115
+ });
4116
+
4117
+ it('should handle hash tree event with empty locusStateElements', () => {
4118
+ mockGetByKey();
4119
+ hashTreeEvent.stateElementsMessage.locusStateElements = [];
4120
+ const result = webex.meetings.getCorrespondingMeetingByLocus(hashTreeEvent);
4121
+ assert.isNull(result);
4122
+ assert.callCount(webex.meetings.meetingCollection.getByKey, 5);
4123
+ assert.calledWith(webex.meetings.meetingCollection.getByKey, 'locusUrl', url1);
4124
+ assert.calledWith(webex.meetings.meetingCollection.getByKey, 'correlationId', false);
4125
+ assert.calledWith(webex.meetings.meetingCollection.getByKey, 'sipUri', undefined);
4126
+ // these remaining 2 will never work for hash trees, but just checking that
4127
+ // the calls are made and we don't crash
4128
+ assert.calledWith(
4129
+ webex.meetings.meetingCollection.getByKey,
4130
+ 'conversationUrl',
4131
+ undefined
4132
+ );
4133
+ assert.calledWith(webex.meetings.meetingCollection.getByKey, 'meetingNumber', undefined);
4134
+ });
4135
+
4136
+ it('should handle hash tree event with self object but no callbackAddress', () => {
4137
+ mockGetByKey('meetingNumber');
4138
+ delete hashTreeEvent.stateElementsMessage.locusStateElements[1].data.callbackInfo;
4139
+ const result = webex.meetings.getCorrespondingMeetingByLocus(hashTreeEvent);
4140
+ assert.deepEqual(result, mockReturnMeeting);
4141
+ assert.callCount(webex.meetings.meetingCollection.getByKey, 5);
4142
+ assert.calledWith(webex.meetings.meetingCollection.getByKey, 'locusUrl', url1);
4143
+ assert.calledWith(
4144
+ webex.meetings.meetingCollection.getByKey,
4145
+ 'correlationId',
4146
+ 'correlationId1'
4147
+ );
4148
+ assert.calledWith(webex.meetings.meetingCollection.getByKey, 'sipUri', undefined);
4149
+ // these remaining 2 will never work for hash trees, but just checking that
4150
+ // the calls are made and we don't crash
4151
+ assert.calledWith(
4152
+ webex.meetings.meetingCollection.getByKey,
4153
+ 'conversationUrl',
4154
+ undefined
4155
+ );
4156
+ assert.calledWith(webex.meetings.meetingCollection.getByKey, 'meetingNumber', undefined);
4157
+ });
4158
+ });
3020
4159
  });
3021
4160
 
3022
4161
  describe('#sortLocusArrayToUpdate', () => {
@@ -3131,7 +4270,7 @@ describe('plugin-meetings', () => {
3131
4270
  },
3132
4271
  });
3133
4272
  assert.calledWith(webex.meetings.handleLocusEvent, {
3134
- eventType: LOCUSEVENT.SDK_NO_EVENT,
4273
+ eventType: LOCUSEVENT.SDK_LOCUS_FROM_SYNC_MEETINGS,
3135
4274
  locus: breakoutLocus,
3136
4275
  locusUrl: breakoutLocus.url,
3137
4276
  });