@webex/plugin-meetings 3.11.0-webex-services-ready.1 → 3.12.0-auth-prejoin-fetch.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 (294) 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 +16 -7
  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/events.js +29 -14
  11. package/dist/breakouts/events.js.map +1 -1
  12. package/dist/breakouts/index.js +99 -4
  13. package/dist/breakouts/index.js.map +1 -1
  14. package/dist/common/errors/webex-errors.js +49 -5
  15. package/dist/common/errors/webex-errors.js.map +1 -1
  16. package/dist/config.js +8 -3
  17. package/dist/config.js.map +1 -1
  18. package/dist/constants.js +60 -11
  19. package/dist/constants.js.map +1 -1
  20. package/dist/controls-options-manager/constants.js +11 -1
  21. package/dist/controls-options-manager/constants.js.map +1 -1
  22. package/dist/controls-options-manager/index.js +67 -29
  23. package/dist/controls-options-manager/index.js.map +1 -1
  24. package/dist/controls-options-manager/util.js +91 -0
  25. package/dist/controls-options-manager/util.js.map +1 -1
  26. package/dist/hashTree/constants.js +16 -2
  27. package/dist/hashTree/constants.js.map +1 -1
  28. package/dist/hashTree/hashTree.js +18 -0
  29. package/dist/hashTree/hashTree.js.map +1 -1
  30. package/dist/hashTree/hashTreeParser.js +1655 -538
  31. package/dist/hashTree/hashTreeParser.js.map +1 -1
  32. package/dist/hashTree/types.js +4 -2
  33. package/dist/hashTree/types.js.map +1 -1
  34. package/dist/hashTree/utils.js +52 -0
  35. package/dist/hashTree/utils.js.map +1 -1
  36. package/dist/index.js +18 -2
  37. package/dist/index.js.map +1 -1
  38. package/dist/interceptors/constant.js +12 -0
  39. package/dist/interceptors/constant.js.map +1 -0
  40. package/dist/interceptors/dataChannelAuthToken.js +350 -0
  41. package/dist/interceptors/dataChannelAuthToken.js.map +1 -0
  42. package/dist/interceptors/index.js +7 -0
  43. package/dist/interceptors/index.js.map +1 -1
  44. package/dist/interceptors/locusRetry.js +23 -8
  45. package/dist/interceptors/locusRetry.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 +9 -4
  54. package/dist/locus-info/controlsUtils.js.map +1 -1
  55. package/dist/locus-info/index.js +914 -212
  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 +8 -7
  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 +2347 -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 +100 -38
  83. package/dist/meeting-info/meeting-info-v2.js.map +1 -1
  84. package/dist/meetings/index.js +466 -174
  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 +116 -18
  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 +12 -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.map +1 -1
  114. package/dist/reachability/index.js +121 -83
  115. package/dist/reachability/index.js.map +1 -1
  116. package/dist/reachability/reachability.types.js +2 -0
  117. package/dist/reachability/reachability.types.js.map +1 -1
  118. package/dist/reachability/util.js +45 -0
  119. package/dist/reachability/util.js.map +1 -1
  120. package/dist/reactions/reactions.type.js.map +1 -1
  121. package/dist/reconnection-manager/index.js +0 -1
  122. package/dist/reconnection-manager/index.js.map +1 -1
  123. package/dist/recording-controller/index.js +1 -3
  124. package/dist/recording-controller/index.js.map +1 -1
  125. package/dist/roap/turnDiscovery.js +8 -1
  126. package/dist/roap/turnDiscovery.js.map +1 -1
  127. package/dist/types/aiEnableRequest/index.d.ts +5 -0
  128. package/dist/types/aiEnableRequest/utils.d.ts +2 -0
  129. package/dist/types/common/errors/webex-errors.d.ts +32 -2
  130. package/dist/types/config.d.ts +6 -2
  131. package/dist/types/constants.d.ts +35 -1
  132. package/dist/types/controls-options-manager/constants.d.ts +6 -1
  133. package/dist/types/controls-options-manager/index.d.ts +16 -0
  134. package/dist/types/hashTree/constants.d.ts +3 -0
  135. package/dist/types/hashTree/hashTree.d.ts +7 -0
  136. package/dist/types/hashTree/hashTreeParser.d.ts +315 -30
  137. package/dist/types/hashTree/types.d.ts +3 -0
  138. package/dist/types/hashTree/utils.d.ts +24 -0
  139. package/dist/types/index.d.ts +4 -0
  140. package/dist/types/interceptors/constant.d.ts +5 -0
  141. package/dist/types/interceptors/dataChannelAuthToken.d.ts +43 -0
  142. package/dist/types/interceptors/index.d.ts +2 -1
  143. package/dist/types/interceptors/locusRetry.d.ts +4 -4
  144. package/dist/types/interceptors/utils.d.ts +1 -0
  145. package/dist/types/interpretation/interpretation.types.d.ts +10 -0
  146. package/dist/types/locus-info/index.d.ts +126 -15
  147. package/dist/types/locus-info/infoUtils.d.ts +8 -0
  148. package/dist/types/locus-info/types.d.ts +28 -1
  149. package/dist/types/media/MediaConnectionAwaiter.d.ts +20 -2
  150. package/dist/types/media/properties.d.ts +8 -3
  151. package/dist/types/meeting/in-meeting-actions.d.ts +10 -0
  152. package/dist/types/meeting/index.d.ts +253 -16
  153. package/dist/types/meeting/locusMediaRequest.d.ts +12 -0
  154. package/dist/types/meeting/request.d.ts +17 -1
  155. package/dist/types/meeting/request.type.d.ts +5 -0
  156. package/dist/types/meeting/util.d.ts +40 -0
  157. package/dist/types/meeting-info/meeting-info-v2.d.ts +25 -1
  158. package/dist/types/meetings/index.d.ts +54 -21
  159. package/dist/types/meetings/meetings.types.d.ts +30 -1
  160. package/dist/types/meetings/request.d.ts +14 -0
  161. package/dist/types/member/index.d.ts +2 -0
  162. package/dist/types/member/types.d.ts +1 -0
  163. package/dist/types/member/util.d.ts +14 -0
  164. package/dist/types/members/index.d.ts +15 -2
  165. package/dist/types/members/util.d.ts +1 -5
  166. package/dist/types/metrics/constants.d.ts +11 -0
  167. package/dist/types/multistream/codec/constants.d.ts +7 -0
  168. package/dist/types/multistream/mediaRequestManager.d.ts +20 -26
  169. package/dist/types/multistream/sendSlotManager.d.ts +23 -1
  170. package/dist/types/reachability/clusterReachability.d.ts +3 -3
  171. package/dist/types/reachability/index.d.ts +10 -3
  172. package/dist/types/reachability/reachability.types.d.ts +7 -0
  173. package/dist/types/reachability/util.d.ts +17 -0
  174. package/dist/types/reactions/reactions.type.d.ts +4 -0
  175. package/dist/types/webinar/utils.d.ts +6 -0
  176. package/dist/webinar/index.js +585 -164
  177. package/dist/webinar/index.js.map +1 -1
  178. package/dist/webinar/utils.js +25 -0
  179. package/dist/webinar/utils.js.map +1 -0
  180. package/package.json +24 -23
  181. package/src/aiEnableRequest/README.md +84 -0
  182. package/src/aiEnableRequest/index.ts +186 -0
  183. package/src/aiEnableRequest/utils.ts +25 -0
  184. package/src/annotation/index.ts +32 -10
  185. package/src/breakouts/breakout.ts +3 -1
  186. package/src/breakouts/events.ts +33 -11
  187. package/src/breakouts/index.ts +122 -2
  188. package/src/common/errors/webex-errors.ts +50 -3
  189. package/src/config.ts +6 -2
  190. package/src/constants.ts +49 -3
  191. package/src/controls-options-manager/constants.ts +14 -1
  192. package/src/controls-options-manager/index.ts +87 -28
  193. package/src/controls-options-manager/util.ts +81 -1
  194. package/src/hashTree/constants.ts +17 -0
  195. package/src/hashTree/hashTree.ts +17 -0
  196. package/src/hashTree/hashTreeParser.ts +1482 -361
  197. package/src/hashTree/types.ts +4 -0
  198. package/src/hashTree/utils.ts +45 -0
  199. package/src/index.ts +14 -1
  200. package/src/interceptors/constant.ts +6 -0
  201. package/src/interceptors/dataChannelAuthToken.ts +246 -0
  202. package/src/interceptors/index.ts +2 -1
  203. package/src/interceptors/locusRetry.ts +25 -4
  204. package/src/interceptors/utils.ts +16 -0
  205. package/src/interpretation/index.ts +29 -11
  206. package/src/interpretation/interpretation.types.ts +11 -0
  207. package/src/locus-info/controlsUtils.ts +14 -1
  208. package/src/locus-info/index.ts +976 -203
  209. package/src/locus-info/infoUtils.ts +41 -6
  210. package/src/locus-info/selfUtils.ts +1 -0
  211. package/src/locus-info/types.ts +33 -1
  212. package/src/media/MediaConnectionAwaiter.ts +62 -5
  213. package/src/media/index.ts +10 -1
  214. package/src/media/properties.ts +11 -4
  215. package/src/meeting/in-meeting-actions.ts +20 -0
  216. package/src/meeting/index.ts +1300 -180
  217. package/src/meeting/locusMediaRequest.ts +106 -6
  218. package/src/meeting/muteState.ts +10 -1
  219. package/src/meeting/request.ts +53 -0
  220. package/src/meeting/request.type.ts +6 -0
  221. package/src/meeting/util.ts +207 -7
  222. package/src/meeting-info/meeting-info-v2.ts +83 -21
  223. package/src/meetings/index.ts +402 -121
  224. package/src/meetings/meetings.types.ts +36 -1
  225. package/src/meetings/request.ts +43 -0
  226. package/src/meetings/util.ts +117 -4
  227. package/src/member/index.ts +20 -0
  228. package/src/member/types.ts +1 -0
  229. package/src/member/util.ts +41 -0
  230. package/src/members/index.ts +70 -7
  231. package/src/members/util.ts +12 -4
  232. package/src/metrics/constants.ts +12 -0
  233. package/src/multistream/codec/constants.ts +58 -0
  234. package/src/multistream/mediaRequestManager.ts +117 -76
  235. package/src/multistream/receiveSlot.ts +18 -0
  236. package/src/multistream/remoteMediaManager.ts +13 -0
  237. package/src/multistream/sendSlotManager.ts +97 -3
  238. package/src/reachability/clusterReachability.ts +3 -2
  239. package/src/reachability/index.ts +47 -16
  240. package/src/reachability/reachability.types.ts +11 -0
  241. package/src/reachability/util.ts +36 -0
  242. package/src/reactions/reactions.type.ts +4 -0
  243. package/src/reconnection-manager/index.ts +0 -1
  244. package/src/recording-controller/index.ts +1 -2
  245. package/src/roap/turnDiscovery.ts +9 -1
  246. package/src/webinar/index.ts +448 -11
  247. package/src/webinar/utils.ts +16 -0
  248. package/test/unit/spec/aiEnableRequest/index.ts +1067 -0
  249. package/test/unit/spec/aiEnableRequest/utils.ts +130 -0
  250. package/test/unit/spec/annotation/index.ts +70 -8
  251. package/test/unit/spec/breakouts/breakout.ts +9 -3
  252. package/test/unit/spec/breakouts/events.ts +120 -2
  253. package/test/unit/spec/breakouts/index.ts +223 -3
  254. package/test/unit/spec/common/errors/webex-errors.ts +78 -0
  255. package/test/unit/spec/controls-options-manager/index.js +244 -29
  256. package/test/unit/spec/controls-options-manager/util.js +165 -0
  257. package/test/unit/spec/hashTree/hashTree.ts +66 -0
  258. package/test/unit/spec/hashTree/hashTreeParser.ts +4528 -171
  259. package/test/unit/spec/hashTree/utils.ts +125 -1
  260. package/test/unit/spec/interceptors/dataChannelAuthToken.ts +406 -0
  261. package/test/unit/spec/interceptors/locusRetry.ts +205 -4
  262. package/test/unit/spec/interceptors/utils.ts +75 -0
  263. package/test/unit/spec/interpretation/index.ts +26 -4
  264. package/test/unit/spec/locus-info/controlsUtils.js +200 -56
  265. package/test/unit/spec/locus-info/index.js +1861 -149
  266. package/test/unit/spec/locus-info/infoUtils.js +184 -1
  267. package/test/unit/spec/media/MediaConnectionAwaiter.ts +96 -1
  268. package/test/unit/spec/media/index.ts +92 -0
  269. package/test/unit/spec/media/properties.ts +35 -26
  270. package/test/unit/spec/meeting/in-meeting-actions.ts +12 -2
  271. package/test/unit/spec/meeting/index.js +3691 -366
  272. package/test/unit/spec/meeting/locusMediaRequest.ts +406 -4
  273. package/test/unit/spec/meeting/muteState.js +81 -0
  274. package/test/unit/spec/meeting/request.js +82 -0
  275. package/test/unit/spec/meeting/utils.js +595 -27
  276. package/test/unit/spec/meeting-info/meetinginfov2.js +286 -10
  277. package/test/unit/spec/meetings/index.js +1400 -78
  278. package/test/unit/spec/meetings/request.js +141 -0
  279. package/test/unit/spec/meetings/utils.js +402 -51
  280. package/test/unit/spec/member/index.js +35 -4
  281. package/test/unit/spec/member/util.js +154 -27
  282. package/test/unit/spec/members/index.js +216 -0
  283. package/test/unit/spec/members/request.js +37 -1
  284. package/test/unit/spec/members/utils.js +63 -0
  285. package/test/unit/spec/multistream/mediaRequestManager.ts +503 -122
  286. package/test/unit/spec/multistream/remoteMediaManager.ts +30 -0
  287. package/test/unit/spec/multistream/sendSlotManager.ts +135 -36
  288. package/test/unit/spec/reachability/index.ts +128 -46
  289. package/test/unit/spec/reachability/util.ts +31 -0
  290. package/test/unit/spec/reconnection-manager/index.js +4 -8
  291. package/test/unit/spec/recording-controller/index.js +9 -8
  292. package/test/unit/spec/roap/turnDiscovery.ts +20 -0
  293. package/test/unit/spec/webinar/index.ts +837 -39
  294. package/test/unit/spec/webinar/utils.ts +39 -0
@@ -14,15 +14,19 @@ 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';
19
+ import MeetingInfoV2 from '@webex/plugin-meetings/src/meeting-info/meeting-info-v2';
18
20
  import {Services} from '@webex/webex-core';
19
21
  import MeetingUtil from '@webex/plugin-meetings/src/meeting/util';
20
22
  import Meetings from '@webex/plugin-meetings/src/meetings';
21
23
  import MeetingCollection from '@webex/plugin-meetings/src/meetings/collection';
22
24
  import MeetingsUtil from '@webex/plugin-meetings/src/meetings/util';
25
+ import {SitePreferenceSelectOption} from '@webex/plugin-meetings/src/meetings/meetings.types';
23
26
  import PersonalMeetingRoom from '@webex/plugin-meetings/src/personal-meeting-room';
24
27
  import Reachability from '@webex/plugin-meetings/src/reachability';
25
28
  import Metrics from '@webex/plugin-meetings/src/metrics';
29
+ import {WasmRuntimeProbe} from '@webex/web-capabilities';
26
30
 
27
31
  import testUtils from '../../../utils/testUtils';
28
32
  import {
@@ -91,6 +95,7 @@ describe('plugin-meetings', () => {
91
95
  locusInfo = {
92
96
  parse: sinon.stub().returns(true),
93
97
  updateMainSessionLocusCache: sinon.stub(),
98
+ syncAllHashTreeDatasets: sinon.stub(),
94
99
  };
95
100
  webex = new MockWebex({
96
101
  children: {
@@ -355,32 +360,6 @@ describe('plugin-meetings', () => {
355
360
  });
356
361
  });
357
362
 
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
363
  describe('#_toggleIpv6BackendNativeSupport', () => {
385
364
  it('should have _toggleIpv6BackendNativeSupport', () => {
386
365
  assert.equal(typeof webex.meetings._toggleIpv6BackendNativeSupport, 'function');
@@ -423,9 +402,39 @@ describe('plugin-meetings', () => {
423
402
  });
424
403
  });
425
404
 
405
+ describe('#_toggleEnableAv1SlidesSupport', () => {
406
+ it('should have _toggleEnableAv1SlidesSupport', () => {
407
+ assert.equal(typeof webex.meetings._toggleEnableAv1SlidesSupport, 'function');
408
+ });
409
+
410
+ describe('success', () => {
411
+ it('should update meetings config to enable AV1 slides support', () => {
412
+ webex.meetings._toggleEnableAv1SlidesSupport(true);
413
+ assert.equal(webex.meetings.config.enableAv1SlidesSupport, true);
414
+
415
+ webex.meetings._toggleEnableAv1SlidesSupport(false);
416
+ assert.equal(webex.meetings.config.enableAv1SlidesSupport, false);
417
+ });
418
+
419
+ it('should not update config when called with a non-boolean value', () => {
420
+ webex.meetings._toggleEnableAv1SlidesSupport(true);
421
+ assert.equal(webex.meetings.config.enableAv1SlidesSupport, true);
422
+
423
+ webex.meetings._toggleEnableAv1SlidesSupport('invalid');
424
+ assert.equal(webex.meetings.config.enableAv1SlidesSupport, true);
425
+
426
+ webex.meetings._toggleEnableAv1SlidesSupport(undefined);
427
+ assert.equal(webex.meetings.config.enableAv1SlidesSupport, true);
428
+ });
429
+ });
430
+ });
431
+
426
432
  describe('#_toggleStopIceGatheringAfterFirstRelayCandidate', () => {
427
433
  it('should have _toggleStopIceGatheringAfterFirstRelayCandidate', () => {
428
- assert.equal(typeof webex.meetings._toggleStopIceGatheringAfterFirstRelayCandidate, 'function');
434
+ assert.equal(
435
+ typeof webex.meetings._toggleStopIceGatheringAfterFirstRelayCandidate,
436
+ 'function'
437
+ );
429
438
  });
430
439
 
431
440
  describe('success', () => {
@@ -602,6 +611,196 @@ describe('plugin-meetings', () => {
602
611
 
603
612
  clock.restore();
604
613
  });
614
+
615
+ it('returns the same promise when register is called multiple times concurrently', async () => {
616
+ webex.canAuthorize = true;
617
+ webex.meetings.registered = false;
618
+
619
+ // Make registration take some time
620
+ let resolveRegistration;
621
+ const registrationDelay = new Promise((resolve) => {
622
+ resolveRegistration = resolve;
623
+ });
624
+
625
+ webex.internal.device.register.returns(registrationDelay);
626
+ webex.internal.mercury.connect.returns(Promise.resolve());
627
+
628
+ // Start first registration
629
+ const firstRegisterPromise = webex.meetings.register();
630
+
631
+ // Immediately start second registration while first is in progress
632
+ const secondRegisterPromise = webex.meetings.register();
633
+
634
+ // Start third registration
635
+ const thirdRegisterPromise = webex.meetings.register();
636
+
637
+ // All should return the same promise
638
+ assert.strictEqual(firstRegisterPromise, secondRegisterPromise);
639
+ assert.strictEqual(secondRegisterPromise, thirdRegisterPromise);
640
+
641
+ // Complete the registration
642
+ resolveRegistration();
643
+
644
+ await firstRegisterPromise;
645
+ await secondRegisterPromise;
646
+ await thirdRegisterPromise;
647
+
648
+ // Device registration and mercury connect should only be called once
649
+ assert.calledOnce(webex.internal.device.register);
650
+ assert.calledOnce(webex.internal.mercury.connect);
651
+ assert.isTrue(webex.meetings.registered);
652
+ });
653
+
654
+ it('prevents duplicate registrations when register is called during in-flight registration', async () => {
655
+ webex.canAuthorize = true;
656
+ webex.meetings.registered = false;
657
+
658
+ let deviceRegisterCallCount = 0;
659
+ let mercuryConnectCallCount = 0;
660
+
661
+ // Track actual calls
662
+ webex.internal.device.register = sinon.stub().callsFake(() => {
663
+ deviceRegisterCallCount++;
664
+ return Promise.resolve();
665
+ });
666
+ webex.internal.mercury.connect = sinon.stub().callsFake(() => {
667
+ mercuryConnectCallCount++;
668
+ return Promise.resolve();
669
+ });
670
+
671
+ // Start registration without awaiting
672
+ const promise1 = webex.meetings.register();
673
+
674
+ // Call register again while first is in progress
675
+ const promise2 = webex.meetings.register();
676
+
677
+ // Wait for both
678
+ await Promise.all([promise1, promise2]);
679
+
680
+ // Should only register once
681
+ assert.equal(deviceRegisterCallCount, 1, 'device.register should only be called once');
682
+ assert.equal(mercuryConnectCallCount, 1, 'mercury.connect should only be called once');
683
+ assert.isTrue(webex.meetings.registered);
684
+ });
685
+
686
+ it('handles concurrent register calls when first registration fails', async () => {
687
+ webex.canAuthorize = true;
688
+ webex.meetings.registered = false;
689
+
690
+ const registrationError = new Error('registration failed');
691
+ webex.internal.device.register.rejects(registrationError);
692
+
693
+ // Start first registration
694
+ const firstRegisterPromise = webex.meetings.register();
695
+
696
+ // Start second registration while first is in progress
697
+ const secondRegisterPromise = webex.meetings.register();
698
+
699
+ // Both should reject with the same error
700
+ await assert.isRejected(firstRegisterPromise, 'registration failed');
701
+ await assert.isRejected(secondRegisterPromise, 'registration failed');
702
+
703
+ // Should still only attempt registration once
704
+ assert.calledOnce(webex.internal.device.register);
705
+ assert.isFalse(webex.meetings.registered);
706
+ });
707
+
708
+ it('allows new registration after previous registration completes', async () => {
709
+ webex.canAuthorize = true;
710
+ webex.meetings.registered = false;
711
+
712
+ // First registration
713
+ await webex.meetings.register();
714
+ assert.isTrue(webex.meetings.registered);
715
+
716
+ // Reset for second registration
717
+ webex.meetings.registered = false;
718
+ webex.internal.device.register.resetHistory();
719
+ webex.internal.mercury.connect.resetHistory();
720
+
721
+ // Second registration should work normally
722
+ await webex.meetings.register();
723
+ assert.calledOnce(webex.internal.device.register);
724
+ assert.calledOnce(webex.internal.mercury.connect);
725
+ assert.isTrue(webex.meetings.registered);
726
+ });
727
+
728
+ it('clears registrationPromise after successful registration', async () => {
729
+ webex.canAuthorize = true;
730
+ webex.meetings.registered = false;
731
+
732
+ await webex.meetings.register();
733
+
734
+ assert.isTrue(webex.meetings.registered);
735
+ assert.isNull(webex.meetings.registrationPromise);
736
+ });
737
+
738
+ it('clears registrationPromise after failed registration', async () => {
739
+ webex.canAuthorize = true;
740
+ webex.meetings.registered = false;
741
+
742
+ webex.internal.device.register.rejects(new Error('registration failed'));
743
+
744
+ await assert.isRejected(webex.meetings.register());
745
+
746
+ assert.isFalse(webex.meetings.registered);
747
+ assert.isNull(webex.meetings.registrationPromise);
748
+ });
749
+
750
+ it('waits for unregistration to complete before registering', async () => {
751
+ webex.canAuthorize = true;
752
+
753
+ assert.isFalse(webex.meetings.registered);
754
+
755
+ // First, register successfully
756
+ await webex.meetings.register();
757
+ assert.isTrue(webex.meetings.registered);
758
+
759
+ // Start unregistration (but don't await it)
760
+ const unregisterPromise = webex.meetings.unregister();
761
+ assert.isDefined(webex.meetings.unregistrationPromise);
762
+
763
+ // Immediately try to register while unregister is in progress
764
+ const registerPromise = webex.meetings.register();
765
+
766
+ // Wait for register to complete
767
+ await registerPromise;
768
+
769
+ // Should have completed registration
770
+ assert.isTrue(webex.meetings.registered);
771
+
772
+ // Now await the original unregister promise - this should have already completed
773
+ // and should NOT affect the registered state since register() took over
774
+ await unregisterPromise;
775
+
776
+ // Should STILL be registered because register() took over
777
+ assert.isTrue(webex.meetings.registered);
778
+ });
779
+
780
+ it('handles multiple register calls during unregistration', async () => {
781
+ webex.canAuthorize = true;
782
+
783
+ // First, register successfully
784
+ await webex.meetings.register();
785
+ assert.isTrue(webex.meetings.registered);
786
+
787
+ // Start unregistration
788
+ const unregistrationPromise = webex.meetings.unregister();
789
+
790
+ // Try to register once while unregister is in progress
791
+ await webex.meetings.register();
792
+
793
+ // Should be registered again
794
+ assert.isTrue(
795
+ webex.meetings.registered,
796
+ 'Expected meetings to be registered after unregister and register cycle'
797
+ );
798
+
799
+ await unregistrationPromise;
800
+
801
+ // Should STILL be registered because register() took over
802
+ assert.isTrue(webex.meetings.registered);
803
+ });
605
804
  });
606
805
 
607
806
  describe('#unregister', () => {
@@ -622,6 +821,18 @@ describe('plugin-meetings', () => {
622
821
  });
623
822
  });
624
823
 
824
+ it('calls mercury.disconnect with code 3050 and reason to prevent auto-reconnect', (done) => {
825
+ webex.meetings.registered = true;
826
+ webex.meetings.unregister().then(() => {
827
+ assert.calledOnce(webex.internal.mercury.disconnect);
828
+ assert.calledWith(webex.internal.mercury.disconnect, {
829
+ code: 3050,
830
+ reason: 'meetings unregister',
831
+ });
832
+ done();
833
+ });
834
+ });
835
+
625
836
  it('rejects when device.unregister fails', async () => {
626
837
  webex.meetings.registered = true;
627
838
  webex.internal.device.unregister = sinon.stub().returns(Promise.reject());
@@ -670,6 +881,335 @@ describe('plugin-meetings', () => {
670
881
  done();
671
882
  });
672
883
  });
884
+
885
+ it('waits for registration to complete before unregistering when called during registration', async () => {
886
+ webex.canAuthorize = true;
887
+ webex.meetings.registered = false;
888
+
889
+ let resolveRegistration;
890
+ const registrationDelay = new Promise((resolve) => {
891
+ resolveRegistration = resolve;
892
+ });
893
+
894
+ webex.internal.device.register.returns(registrationDelay);
895
+ webex.internal.mercury.connect.returns(Promise.resolve());
896
+
897
+ // Start registration (don't await)
898
+ const registerPromise = webex.meetings.register();
899
+
900
+ // Verify registration is in progress
901
+ assert.exists(webex.meetings.registrationPromise);
902
+ assert.isFalse(webex.meetings.registered);
903
+
904
+ // Call unregister while registration is in progress
905
+ const unregisterPromise = webex.meetings.unregister();
906
+
907
+ // Registration should still be in progress
908
+ assert.exists(webex.meetings.registrationPromise);
909
+
910
+ // Complete the registration
911
+ resolveRegistration();
912
+ await registerPromise;
913
+
914
+ // Now unregister should proceed
915
+ await unregisterPromise;
916
+
917
+ // Verify final state
918
+ assert.isFalse(webex.meetings.registered);
919
+ assert.isNull(webex.meetings.registrationPromise);
920
+ assert.calledOnce(webex.internal.device.unregister);
921
+ assert.calledOnce(webex.internal.mercury.disconnect);
922
+ });
923
+
924
+ it('handles unregister called during registration that fails', async () => {
925
+ webex.canAuthorize = true;
926
+ webex.meetings.registered = false;
927
+
928
+ const registrationError = new Error('registration failed');
929
+ let rejectRegistration;
930
+ const registrationDelay = new Promise((resolve, reject) => {
931
+ rejectRegistration = reject;
932
+ });
933
+
934
+ webex.internal.device.register.returns(registrationDelay);
935
+
936
+ // Start registration (don't await)
937
+ const registerPromise = webex.meetings.register();
938
+
939
+ // Call unregister while registration is in progress
940
+ const unregisterPromise = webex.meetings.unregister();
941
+
942
+ // Fail the registration
943
+ rejectRegistration(registrationError);
944
+
945
+ // Registration should fail
946
+ await assert.isRejected(registerPromise, 'registration failed');
947
+
948
+ // // Unregister should resolve immediately since registration failed
949
+ await unregisterPromise;
950
+
951
+ // Verify final state - not registered
952
+ assert.isFalse(webex.meetings.registered);
953
+ assert.isNull(webex.meetings.registrationPromise);
954
+ // Device unregister should not be called because registration never completed
955
+ assert.notCalled(webex.internal.device.unregister);
956
+ });
957
+
958
+ it('handles multiple unregister calls during registration', async () => {
959
+ webex.canAuthorize = true;
960
+ webex.meetings.registered = false;
961
+
962
+ let resolveRegistration;
963
+ const registrationDelay = new Promise((resolve) => {
964
+ resolveRegistration = resolve;
965
+ });
966
+
967
+ webex.internal.device.register.returns(registrationDelay);
968
+ webex.internal.mercury.connect.returns(Promise.resolve());
969
+
970
+ // Start registration
971
+ const registerPromise = webex.meetings.register();
972
+
973
+ // Call unregister multiple times while registration is in progress
974
+ const unregisterPromise1 = webex.meetings.unregister();
975
+ const unregisterPromise2 = webex.meetings.unregister();
976
+ const unregisterPromise3 = webex.meetings.unregister();
977
+
978
+ // Complete registration
979
+ resolveRegistration();
980
+ await registerPromise;
981
+
982
+ // All unregister calls should complete
983
+ await Promise.all([unregisterPromise1, unregisterPromise2, unregisterPromise3]);
984
+
985
+ // Verify final state
986
+ assert.isFalse(webex.meetings.registered);
987
+ // Disconnect and unregister should be called, but not multiple times
988
+ assert.calledOnce(webex.internal.mercury.disconnect);
989
+ assert.calledOnce(webex.internal.device.unregister);
990
+ });
991
+
992
+ it('completes unregister correctly after waiting for registration', async () => {
993
+ webex.canAuthorize = true;
994
+ webex.meetings.registered = false;
995
+
996
+ const stopListeningForEventsSpy = sinon.spy(webex.meetings, 'stopListeningForEvents');
997
+
998
+ let resolveRegistration;
999
+ const registrationDelay = new Promise((resolve) => {
1000
+ resolveRegistration = resolve;
1001
+ });
1002
+
1003
+ webex.internal.device.register.returns(registrationDelay);
1004
+ webex.internal.mercury.connect.returns(Promise.resolve());
1005
+
1006
+ // Start registration
1007
+ const registerPromise = webex.meetings.register();
1008
+
1009
+ // Call unregister during registration
1010
+ const unregisterPromise = webex.meetings.unregister();
1011
+
1012
+ // stopListeningForEvents should not be called yet
1013
+ assert.notCalled(stopListeningForEventsSpy);
1014
+
1015
+ // Complete registration
1016
+ resolveRegistration();
1017
+ await registerPromise;
1018
+
1019
+ // After registration completes, the meetings plugin should be registered
1020
+ assert.isTrue(webex.meetings.registered);
1021
+
1022
+ // Now unregister should proceed
1023
+ await unregisterPromise;
1024
+
1025
+ // Verify unregister completed properly
1026
+ assert.calledOnce(stopListeningForEventsSpy);
1027
+ assert.calledOnce(webex.internal.mercury.disconnect);
1028
+ assert.calledOnce(webex.internal.device.unregister);
1029
+ assert.isFalse(webex.meetings.registered);
1030
+ assert.deepEqual(webex.meetings.registrationStatus, INITIAL_REGISTRATION_STATUS);
1031
+ });
1032
+
1033
+ it('logs appropriate message when unregister is called during registration', async () => {
1034
+ webex.canAuthorize = true;
1035
+ webex.meetings.registered = false;
1036
+
1037
+ const loggerSpy = sinon.spy(LoggerProxy.logger, 'info');
1038
+
1039
+ let resolveRegistration;
1040
+ const registrationDelay = new Promise((resolve) => {
1041
+ resolveRegistration = resolve;
1042
+ });
1043
+
1044
+ webex.internal.device.register.returns(registrationDelay);
1045
+ webex.internal.mercury.connect.returns(Promise.resolve());
1046
+
1047
+ // Start registration
1048
+ const registerPromise = webex.meetings.register();
1049
+
1050
+ // Call unregister during registration
1051
+ const unregisterPromise = webex.meetings.unregister();
1052
+
1053
+ // Should log that it's waiting
1054
+ assert.calledWith(
1055
+ loggerSpy,
1056
+ 'Meetings:index#unregister --> INFO, Meetings plugin registration in progress, waiting to unregister'
1057
+ );
1058
+
1059
+ // Complete registration and unregistration
1060
+ resolveRegistration();
1061
+ await registerPromise;
1062
+ await unregisterPromise;
1063
+
1064
+ loggerSpy.restore();
1065
+ });
1066
+
1067
+ it('returns the same promise when unregister is called multiple times concurrently', async () => {
1068
+ webex.meetings.registered = true;
1069
+
1070
+ // Make unregistration take some time
1071
+ let resolveUnregistration;
1072
+ const unregistrationDelay = new Promise((resolve) => {
1073
+ resolveUnregistration = resolve;
1074
+ });
1075
+
1076
+ webex.internal.mercury.disconnect.returns(unregistrationDelay);
1077
+ webex.internal.device.unregister.returns(Promise.resolve());
1078
+
1079
+ // Start first unregistration
1080
+ const firstUnregisterPromise = webex.meetings.unregister();
1081
+
1082
+ // Immediately start second unregistration while first is in progress
1083
+ const secondUnregisterPromise = webex.meetings.unregister();
1084
+
1085
+ // Start third unregistration
1086
+ const thirdUnregisterPromise = webex.meetings.unregister();
1087
+
1088
+ // All should return the same promise
1089
+ assert.strictEqual(firstUnregisterPromise, secondUnregisterPromise);
1090
+ assert.strictEqual(secondUnregisterPromise, thirdUnregisterPromise);
1091
+
1092
+ // Complete the unregistration
1093
+ resolveUnregistration();
1094
+
1095
+ await firstUnregisterPromise;
1096
+ await secondUnregisterPromise;
1097
+ await thirdUnregisterPromise;
1098
+
1099
+ // Mercury disconnect and device unregister should only be called once
1100
+ assert.calledOnce(webex.internal.mercury.disconnect);
1101
+ assert.calledOnce(webex.internal.device.unregister);
1102
+ assert.isFalse(webex.meetings.registered);
1103
+ });
1104
+
1105
+ it('clears unregistrationPromise after successful unregistration', async () => {
1106
+ webex.meetings.registered = true;
1107
+
1108
+ await webex.meetings.unregister();
1109
+
1110
+ assert.isFalse(webex.meetings.registered);
1111
+ assert.isNull(webex.meetings.unregistrationPromise);
1112
+ });
1113
+
1114
+ it('clears unregistrationPromise after failed unregistration', async () => {
1115
+ webex.meetings.registered = true;
1116
+
1117
+ webex.internal.mercury.disconnect.rejects(new Error('disconnect failed'));
1118
+
1119
+ await assert.isRejected(webex.meetings.unregister());
1120
+
1121
+ assert.isTrue(webex.meetings.registered);
1122
+ assert.isNull(webex.meetings.unregistrationPromise);
1123
+ });
1124
+
1125
+ it('allows new unregistration after previous unregistration completes', async () => {
1126
+ webex.meetings.registered = true;
1127
+
1128
+ // First unregistration
1129
+ await webex.meetings.unregister();
1130
+ assert.isFalse(webex.meetings.registered);
1131
+
1132
+ // Register again
1133
+ webex.canAuthorize = true;
1134
+ await webex.meetings.register();
1135
+ assert.isTrue(webex.meetings.registered);
1136
+
1137
+ // Reset history
1138
+ webex.internal.mercury.disconnect.resetHistory();
1139
+ webex.internal.device.unregister.resetHistory();
1140
+
1141
+ // Second unregistration should work normally
1142
+ await webex.meetings.unregister();
1143
+ assert.calledOnce(webex.internal.mercury.disconnect);
1144
+ assert.calledOnce(webex.internal.device.unregister);
1145
+ assert.isFalse(webex.meetings.registered);
1146
+ });
1147
+
1148
+ it('handles register called during unregistration that fails', async () => {
1149
+ webex.canAuthorize = true;
1150
+ webex.meetings.registered = true;
1151
+
1152
+ const unregistrationError = new Error('unregistration failed');
1153
+ let rejectUnregistration;
1154
+ const unregistrationDelay = new Promise((resolve, reject) => {
1155
+ rejectUnregistration = reject;
1156
+ });
1157
+
1158
+ webex.internal.mercury.disconnect.returns(unregistrationDelay);
1159
+
1160
+ // Start unregistration (don't await)
1161
+ const unregisterPromise = webex.meetings.unregister();
1162
+
1163
+ // Call register while unregistration is in progress
1164
+ const registerPromise = webex.meetings.register();
1165
+
1166
+ // Fail the unregistration
1167
+ rejectUnregistration(unregistrationError);
1168
+
1169
+ // Unregistration should fail
1170
+ await assert.isRejected(unregisterPromise, 'unregistration failed');
1171
+
1172
+ // Register should still succeed (retry after unregister failure)
1173
+ await registerPromise;
1174
+
1175
+ // Verify final state - should be registered
1176
+ assert.isTrue(webex.meetings.registered);
1177
+ assert.isNull(webex.meetings.unregistrationPromise);
1178
+ });
1179
+
1180
+ it('logs appropriate message when register is called during unregistration', async () => {
1181
+ webex.canAuthorize = true;
1182
+ webex.meetings.registered = true;
1183
+
1184
+ const loggerSpy = sinon.spy(LoggerProxy.logger, 'info');
1185
+
1186
+ let resolveUnregistration;
1187
+ const unregistrationDelay = new Promise((resolve) => {
1188
+ resolveUnregistration = resolve;
1189
+ });
1190
+
1191
+ webex.internal.mercury.disconnect.returns(unregistrationDelay);
1192
+ webex.internal.device.unregister.returns(Promise.resolve());
1193
+
1194
+ // Start unregistration
1195
+ const unregisterPromise = webex.meetings.unregister();
1196
+
1197
+ // Call register during unregistration
1198
+ const registerPromise = webex.meetings.register();
1199
+
1200
+ // Should log that it's waiting
1201
+ assert.calledWith(
1202
+ loggerSpy,
1203
+ 'Meetings:index#register --> INFO, Meetings plugin unregistration in progress, waiting to register'
1204
+ );
1205
+
1206
+ // Complete unregistration and registration
1207
+ resolveUnregistration();
1208
+ await unregisterPromise;
1209
+ await registerPromise;
1210
+
1211
+ loggerSpy.restore();
1212
+ });
673
1213
  });
674
1214
 
675
1215
  describe('virtual background effect', () => {
@@ -732,42 +1272,65 @@ describe('plugin-meetings', () => {
732
1272
  };
733
1273
  });
734
1274
 
735
- it('creates noise reduction effect', async () => {
736
- const result = await webex.meetings.createNoiseReductionEffect({audioContext: {}});
1275
+ it('creates noise reduction effect with BNR model', async () => {
1276
+ const result = await webex.meetings.createNoiseReductionEffect({
1277
+ audioContext: {addEventListener: sinon.stub()},
1278
+ });
737
1279
 
738
1280
  assert.exists(result);
739
1281
  assert.instanceOf(result, NoiseReductionEffect);
740
1282
  assert.containsAllKeys(result, ['audioContext', 'isEnabled', 'isReady', 'options']);
741
1283
  assert.equal(result.options.authToken, 'fake_token');
742
1284
  assert.deepEqual(result.options, {
743
- audioContext: {},
1285
+ audioContext: {addEventListener: result.options.audioContext.addEventListener},
744
1286
  authToken: 'fake_token',
745
1287
  mode: 'WORKLET',
746
1288
  avoidSimd: false,
1289
+ model: 'bnr',
747
1290
  });
748
1291
  assert.exists(result.enable);
749
1292
  assert.exists(result.disable);
750
1293
  assert.exists(result.dispose);
751
1294
  });
752
1295
 
753
- it('creates noise reduction effect with custom options passed', async () => {
754
- const effectOptions = {
755
- audioContext: {},
756
- mode: 'LEGACY',
757
- env: 'int',
758
- avoidSimd: true,
759
- };
760
-
761
- const result = await webex.meetings.createNoiseReductionEffect(effectOptions);
1296
+ it('creates noise reduction effect with OFMV model', async () => {
1297
+ const result = await webex.meetings.createNoiseReductionEffect({
1298
+ audioContext: {addEventListener: sinon.stub()},
1299
+ model: 'ofmv',
1300
+ });
762
1301
 
763
1302
  assert.exists(result);
764
1303
  assert.instanceOf(result, NoiseReductionEffect);
765
1304
  assert.containsAllKeys(result, ['audioContext', 'isEnabled', 'isReady', 'options']);
766
- assert.deepEqual(result.options, {...effectOptions, authToken: 'fake_token'});
1305
+ assert.equal(result.options.authToken, 'fake_token');
1306
+ assert.deepEqual(result.options, {
1307
+ audioContext: {addEventListener: result.options.audioContext.addEventListener},
1308
+ authToken: 'fake_token',
1309
+ mode: 'WORKLET',
1310
+ avoidSimd: false,
1311
+ model: 'ofmv',
1312
+ });
767
1313
  assert.exists(result.enable);
768
1314
  assert.exists(result.disable);
769
1315
  assert.exists(result.dispose);
770
1316
  });
1317
+
1318
+ it('passes custom options to noise reduction effect', async () => {
1319
+ const result = await webex.meetings.createNoiseReductionEffect({
1320
+ audioContext: {addEventListener: sinon.stub()},
1321
+ mode: 'LEGACY',
1322
+ env: 'int',
1323
+ avoidSimd: true,
1324
+ });
1325
+
1326
+ assert.exists(result);
1327
+ assert.instanceOf(result, NoiseReductionEffect);
1328
+ assert.equal(result.options.mode, 'LEGACY');
1329
+ assert.equal(result.options.env, 'int');
1330
+ assert.equal(result.options.avoidSimd, true);
1331
+ assert.equal(result.options.authToken, 'fake_token');
1332
+ assert.equal(result.options.model, 'bnr');
1333
+ });
771
1334
  });
772
1335
 
773
1336
  describe('gets', () => {
@@ -800,6 +1363,87 @@ describe('plugin-meetings', () => {
800
1363
  );
801
1364
  });
802
1365
  });
1366
+ describe('#fetchSitePreferencesMeViaSite', () => {
1367
+ const sitePreferencesResponse = {
1368
+ scheduling: {
1369
+ supportScheduleWebinar: true,
1370
+ webinarWebLink: 'https://go.webex.com/webappng/sites/go/webinar/scheduler',
1371
+ },
1372
+ };
1373
+
1374
+ beforeEach(() => {
1375
+ webex.meetings.request.fetchSitePreferencesMeViaSite = sinon
1376
+ .stub()
1377
+ .resolves(sitePreferencesResponse);
1378
+ });
1379
+
1380
+ it('should have #fetchSitePreferencesMeViaSite', () => {
1381
+ assert.exists(webex.meetings.fetchSitePreferencesMeViaSite);
1382
+ });
1383
+
1384
+ it('fetches scheduling preferences for the preferred Webex site by default', async () => {
1385
+ webex.meetings.preferredWebexSite = 'go.webex.com';
1386
+
1387
+ const result = await webex.meetings.fetchSitePreferencesMeViaSite();
1388
+
1389
+ assert.deepEqual(result, sitePreferencesResponse);
1390
+ assert.calledOnceWithExactly(
1391
+ webex.meetings.request.fetchSitePreferencesMeViaSite,
1392
+ {
1393
+ siteUrl: 'go.webex.com',
1394
+ }
1395
+ );
1396
+ });
1397
+
1398
+ it('uses the provided Webex site instead of the preferred Webex site', async () => {
1399
+ webex.meetings.preferredWebexSite = 'preferred.webex.com';
1400
+
1401
+ await webex.meetings.fetchSitePreferencesMeViaSite({siteUrl: 'go.webex.com'});
1402
+
1403
+ assert.calledOnceWithExactly(
1404
+ webex.meetings.request.fetchSitePreferencesMeViaSite,
1405
+ {
1406
+ siteUrl: 'go.webex.com',
1407
+ }
1408
+ );
1409
+ });
1410
+
1411
+ it('forwards custom site name and preference sections to the request helper', async () => {
1412
+ webex.meetings.preferredWebexSite = 'go.webex.com';
1413
+
1414
+ await webex.meetings.fetchSitePreferencesMeViaSite({
1415
+ siteName: 'custom-site',
1416
+ selectOptions: [SitePreferenceSelectOption.SCHEDULING],
1417
+ });
1418
+
1419
+ assert.calledOnceWithExactly(
1420
+ webex.meetings.request.fetchSitePreferencesMeViaSite,
1421
+ {
1422
+ siteUrl: 'go.webex.com',
1423
+ siteName: 'custom-site',
1424
+ selectOptions: [SitePreferenceSelectOption.SCHEDULING],
1425
+ }
1426
+ );
1427
+ });
1428
+
1429
+ it('throws when no Webex site is available', () => {
1430
+ webex.meetings.preferredWebexSite = '';
1431
+ webex.meetings.request.fetchSitePreferencesMeViaSite.throws(
1432
+ new ParameterError(
1433
+ 'No siteUrl available. Call register() before fetching site preferences or provide options.siteUrl.'
1434
+ )
1435
+ );
1436
+
1437
+ assert.throws(
1438
+ () => webex.meetings.fetchSitePreferencesMeViaSite(),
1439
+ ParameterError,
1440
+ 'No siteUrl available. Call register() before fetching site preferences or provide options.siteUrl.'
1441
+ );
1442
+ assert.calledOnceWithExactly(webex.meetings.request.fetchSitePreferencesMeViaSite, {
1443
+ siteUrl: '',
1444
+ });
1445
+ });
1446
+ });
803
1447
  describe('Static shortcut proxy methods', () => {
804
1448
  describe('MeetingCollection getByKey proxies', () => {
805
1449
  beforeEach(() => {
@@ -836,7 +1480,7 @@ describe('plugin-meetings', () => {
836
1480
  it('should have #syncMeetings', () => {
837
1481
  assert.exists(webex.meetings.syncMeetings);
838
1482
  });
839
- it('should do nothing and return a resolved promise if unverified guest', async () => {
1483
+ it('should skip getActiveMeetings but still call syncAllHashTreeDatasets if unverified guest', async () => {
840
1484
  webex.meetings.request.getActiveMeetings = sinon.stub().returns(
841
1485
  Promise.resolve({
842
1486
  loci: [
@@ -849,13 +1493,23 @@ describe('plugin-meetings', () => {
849
1493
  webex.credentials.isUnverifiedGuest = true;
850
1494
  LoggerProxy.logger.info = sinon.stub();
851
1495
 
1496
+ const mockLocusInfo = {
1497
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
1498
+ };
1499
+ webex.meetings.meetingCollection.getAll = sinon.stub().returns({
1500
+ meeting1: {locusInfo: mockLocusInfo},
1501
+ meeting2: {locusInfo: undefined},
1502
+ meeting3: {},
1503
+ });
1504
+
852
1505
  await webex.meetings.syncMeetings();
853
1506
 
854
1507
  assert.notCalled(webex.meetings.request.getActiveMeetings);
855
1508
  assert.calledWith(
856
1509
  LoggerProxy.logger.info,
857
- 'Meetings:index#syncMeetings --> skipping meeting sync as unverified guest'
1510
+ 'Meetings:index#syncMeetings --> user is unverified guest, skipping calling Locus for meeting sync'
858
1511
  );
1512
+ assert.calledOnce(mockLocusInfo.syncAllHashTreeDatasets);
859
1513
  });
860
1514
  describe('succesful requests', () => {
861
1515
  beforeEach(() => {
@@ -874,6 +1528,9 @@ describe('plugin-meetings', () => {
874
1528
  webex.meetings.meetingCollection.getByKey = sinon.stub().returns({
875
1529
  locusInfo,
876
1530
  });
1531
+ webex.meetings.meetingCollection.getAll = sinon.stub().returns({
1532
+ meeting1: {locusInfo, locusUrl: url1},
1533
+ });
877
1534
  });
878
1535
  it('tests the sync meeting calls for existing meeting', async () => {
879
1536
  await webex.meetings.syncMeetings();
@@ -881,6 +1538,7 @@ describe('plugin-meetings', () => {
881
1538
  assert.calledOnce(webex.meetings.meetingCollection.getByKey);
882
1539
  assert.calledOnce(locusInfo.parse);
883
1540
  assert.calledWith(webex.meetings.meetingCollection.getByKey, 'locusUrl', url1);
1541
+ assert.calledOnce(locusInfo.syncAllHashTreeDatasets);
884
1542
  });
885
1543
  });
886
1544
  describe('when meeting is not returned', () => {
@@ -918,8 +1576,8 @@ describe('plugin-meetings', () => {
918
1576
  locus: {
919
1577
  url: url1,
920
1578
  },
921
- hashTreeMessage: undefined
922
- });
1579
+ hashTreeMessage: undefined,
1580
+ }, sinon.match.func);
923
1581
  });
924
1582
  });
925
1583
  describe('when destroying meeting is needed', () => {
@@ -965,7 +1623,7 @@ describe('plugin-meetings', () => {
965
1623
  it('destroy any meeting that has no active locus url if keepOnlyLocusMeetings is not defined', async () => {
966
1624
  await webex.meetings.syncMeetings();
967
1625
  assert.calledOnce(webex.meetings.request.getActiveMeetings);
968
- assert.calledOnce(webex.meetings.meetingCollection.getAll);
1626
+ assert.calledTwice(webex.meetings.meetingCollection.getAll);
969
1627
  assert.calledWith(destroySpy, meetingCollectionMeetings.noLongerValidLocusMeeting);
970
1628
  assert.calledWith(destroySpy, meetingCollectionMeetings.otherNonLocusMeeting1);
971
1629
  assert.calledWith(destroySpy, meetingCollectionMeetings.otherNonLocusMeeting2);
@@ -977,7 +1635,7 @@ describe('plugin-meetings', () => {
977
1635
  it('destroy any meeting that has no active locus url if keepOnlyLocusMeetings === true', async () => {
978
1636
  await webex.meetings.syncMeetings({keepOnlyLocusMeetings: true});
979
1637
  assert.calledOnce(webex.meetings.request.getActiveMeetings);
980
- assert.calledOnce(webex.meetings.meetingCollection.getAll);
1638
+ assert.calledTwice(webex.meetings.meetingCollection.getAll);
981
1639
  assert.calledWith(destroySpy, meetingCollectionMeetings.noLongerValidLocusMeeting);
982
1640
  assert.calledWith(destroySpy, meetingCollectionMeetings.otherNonLocusMeeting1);
983
1641
  assert.calledWith(destroySpy, meetingCollectionMeetings.otherNonLocusMeeting2);
@@ -989,7 +1647,7 @@ describe('plugin-meetings', () => {
989
1647
  it('destroy any LOCUS meetings that have no active locus url if keepOnlyLocusMeetings === false', async () => {
990
1648
  await webex.meetings.syncMeetings({keepOnlyLocusMeetings: false});
991
1649
  assert.calledOnce(webex.meetings.request.getActiveMeetings);
992
- assert.calledOnce(webex.meetings.meetingCollection.getAll);
1650
+ assert.calledTwice(webex.meetings.meetingCollection.getAll);
993
1651
  assert.calledWith(destroySpy, meetingCollectionMeetings.noLongerValidLocusMeeting);
994
1652
  assert.callCount(destroySpy, 1);
995
1653
 
@@ -997,6 +1655,147 @@ describe('plugin-meetings', () => {
997
1655
  });
998
1656
  });
999
1657
  });
1658
+
1659
+ describe('when globalMeetingId preserves breakout meetings', () => {
1660
+ let destroySpy;
1661
+ let cleanUpSpy;
1662
+
1663
+ beforeEach(() => {
1664
+ destroySpy = sinon.spy(webex.meetings, 'destroy');
1665
+ cleanUpSpy = sinon.stub(MeetingUtil, 'cleanUp').returns(Promise.resolve());
1666
+ });
1667
+
1668
+ afterEach(() => {
1669
+ cleanUpSpy.restore();
1670
+ });
1671
+
1672
+ it('should not destroy a meeting whose globalMeetingId matches an active locus', async () => {
1673
+ const meetingCollectionMeetings = {
1674
+ breakoutMeeting: {
1675
+ locusUrl: 'breakout-url',
1676
+ locusInfo: {
1677
+ info: {globalMeetingId: 'gmid-123'},
1678
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
1679
+ },
1680
+ sendCallAnalyzerMetrics: sinon.stub(),
1681
+ },
1682
+ };
1683
+
1684
+ webex.meetings.meetingCollection.getAll = sinon
1685
+ .stub()
1686
+ .returns(meetingCollectionMeetings);
1687
+ webex.meetings.request.getActiveMeetings = sinon.stub().resolves({
1688
+ loci: [{url: 'main-url', info: {globalMeetingId: 'gmid-123'}}],
1689
+ });
1690
+
1691
+ await webex.meetings.syncMeetings();
1692
+
1693
+ assert.notCalled(destroySpy);
1694
+ });
1695
+
1696
+ it('should destroy a meeting whose globalMeetingId does NOT match any active locus', async () => {
1697
+ const meetingCollectionMeetings = {
1698
+ breakoutMeeting: {
1699
+ locusUrl: 'breakout-url',
1700
+ locusInfo: {
1701
+ info: {globalMeetingId: 'gmid-other'},
1702
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
1703
+ },
1704
+ sendCallAnalyzerMetrics: sinon.stub(),
1705
+ },
1706
+ };
1707
+
1708
+ webex.meetings.meetingCollection.getAll = sinon
1709
+ .stub()
1710
+ .returns(meetingCollectionMeetings);
1711
+ webex.meetings.request.getActiveMeetings = sinon.stub().resolves({
1712
+ loci: [{url: 'main-url', info: {globalMeetingId: 'gmid-123'}}],
1713
+ });
1714
+
1715
+ await webex.meetings.syncMeetings();
1716
+
1717
+ assert.calledOnce(destroySpy);
1718
+ assert.calledWith(destroySpy, meetingCollectionMeetings.breakoutMeeting);
1719
+ });
1720
+ });
1721
+
1722
+ describe('skipHashTreeSync parameter', () => {
1723
+ it('should skip syncAllHashTreeDatasets when skipHashTreeSync is true', async () => {
1724
+ const mockLocusInfo = {
1725
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
1726
+ };
1727
+
1728
+ webex.meetings.request.getActiveMeetings = sinon.stub().resolves({loci: []});
1729
+ webex.meetings.meetingCollection.getAll = sinon.stub().returns({
1730
+ meeting1: {locusInfo: mockLocusInfo},
1731
+ });
1732
+
1733
+ await webex.meetings.syncMeetings({keepOnlyLocusMeetings: false, skipHashTreeSync: true});
1734
+
1735
+ assert.calledOnce(webex.meetings.request.getActiveMeetings);
1736
+ assert.notCalled(mockLocusInfo.syncAllHashTreeDatasets);
1737
+ });
1738
+
1739
+ it('should call syncAllHashTreeDatasets when skipHashTreeSync is false (default)', async () => {
1740
+ const mockLocusInfo = {
1741
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
1742
+ };
1743
+
1744
+ webex.meetings.request.getActiveMeetings = sinon.stub().resolves({loci: []});
1745
+ webex.meetings.meetingCollection.getAll = sinon.stub().returns({
1746
+ meeting1: {locusInfo: mockLocusInfo},
1747
+ });
1748
+
1749
+ await webex.meetings.syncMeetings({keepOnlyLocusMeetings: false, skipHashTreeSync: false});
1750
+
1751
+ assert.calledOnce(webex.meetings.request.getActiveMeetings);
1752
+ assert.calledOnce(mockLocusInfo.syncAllHashTreeDatasets);
1753
+ });
1754
+ });
1755
+
1756
+ describe('syncAllHashTreeDatasets in syncMeetings', () => {
1757
+ it('should call syncAllHashTreeDatasets for multiple meetings, skipping those without locusInfo', async () => {
1758
+ const mockLocusInfo1 = {
1759
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
1760
+ };
1761
+ const mockLocusInfo2 = {
1762
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
1763
+ };
1764
+
1765
+ webex.meetings.request.getActiveMeetings = sinon.stub().resolves({loci: []});
1766
+ webex.meetings.meetingCollection.getAll = sinon.stub().returns({
1767
+ meeting1: {locusInfo: mockLocusInfo1},
1768
+ meeting2: {locusInfo: undefined},
1769
+ meeting3: {locusInfo: mockLocusInfo2},
1770
+ meeting4: {},
1771
+ });
1772
+
1773
+ await webex.meetings.syncMeetings({keepOnlyLocusMeetings: false});
1774
+
1775
+ assert.calledOnce(mockLocusInfo1.syncAllHashTreeDatasets);
1776
+ assert.calledOnce(mockLocusInfo2.syncAllHashTreeDatasets);
1777
+ });
1778
+
1779
+ it('should not call syncAllHashTreeDatasets when getActiveMeetings throws an error', async () => {
1780
+ const mockLocusInfo = {
1781
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
1782
+ };
1783
+
1784
+ webex.meetings.request.getActiveMeetings = sinon.stub().rejects(new Error('network error'));
1785
+ webex.meetings.meetingCollection.getAll = sinon.stub().returns({
1786
+ meeting1: {locusInfo: mockLocusInfo},
1787
+ });
1788
+
1789
+ try {
1790
+ await webex.meetings.syncMeetings();
1791
+ assert.fail('should have thrown');
1792
+ } catch (err) {
1793
+ assert.equal(err.message, 'network error');
1794
+ }
1795
+
1796
+ assert.notCalled(mockLocusInfo.syncAllHashTreeDatasets);
1797
+ });
1798
+ });
1000
1799
  });
1001
1800
  describe('#fetchStaticMeetingLink', () => {
1002
1801
  const conversationUrl = 'conv.fakeconversationurl.com';
@@ -1061,6 +1860,73 @@ describe('plugin-meetings', () => {
1061
1860
  });
1062
1861
  });
1063
1862
  });
1863
+ describe('#prefetchMeetingInfo', () => {
1864
+ it('starts a reusable preJoin request without creating a Meeting', async () => {
1865
+ const response = {body: {meetingJoinUrl: 'meeting-join-url'}};
1866
+ const preJoinContext = {
1867
+ correlationId: 'correlation-id',
1868
+ sessionCorrelationId: 'session-correlation-id',
1869
+ };
1870
+
1871
+ const preJoinProvider = {fetchMeetingInfo: sinon.stub().resolves(response)};
1872
+ const createPreJoinProvider = sinon
1873
+ .stub(MeetingInfoV2, 'createPreJoinProvider')
1874
+ .returns(preJoinProvider);
1875
+ const createMeeting = sinon.stub(webex.meetings, 'createMeeting');
1876
+
1877
+ const prefetchedMeetingInfo = webex.meetings.prefetchMeetingInfo({
1878
+ destination: 'test destination',
1879
+ type: DESTINATION_TYPE.MEETING_ID,
1880
+ extraParams: {joinTXId: 'join-transaction-id'},
1881
+ preJoinContext,
1882
+ classificationId: 'classification-id',
1883
+ });
1884
+
1885
+ assert.calledOnceWithExactly(createPreJoinProvider, webex, preJoinContext);
1886
+ assert.calledOnceWithExactly(
1887
+ preJoinProvider.fetchMeetingInfo,
1888
+ 'test destination',
1889
+ DESTINATION_TYPE.MEETING_ID,
1890
+ null,
1891
+ null,
1892
+ undefined,
1893
+ null,
1894
+ {joinTXId: 'join-transaction-id'},
1895
+ {sendCAevents: true},
1896
+ null,
1897
+ null,
1898
+ 'classification-id'
1899
+ );
1900
+ assert.deepEqual(await prefetchedMeetingInfo.request, response);
1901
+ assert.deepEqual(prefetchedMeetingInfo, {
1902
+ request: prefetchedMeetingInfo.request,
1903
+ provider: preJoinProvider,
1904
+ extraParams: {joinTXId: 'join-transaction-id'},
1905
+ });
1906
+ assert.notCalled(createMeeting);
1907
+ });
1908
+
1909
+ it('uses AppAPI for preJoin when unified meetings is not enabled yet', async () => {
1910
+ const response = {body: {meetingJoinUrl: 'meeting-join-url'}};
1911
+ const legacyFetchMeetingInfo = sinon.stub().resolves(response);
1912
+ const appApiFetchMeetingInfo = sinon
1913
+ .stub(MeetingInfoV2.prototype, 'fetchMeetingInfo')
1914
+ .resolves(response);
1915
+
1916
+ webex.meetings.meetingInfo = {fetchMeetingInfo: legacyFetchMeetingInfo};
1917
+
1918
+ const prefetchedMeetingInfo = webex.meetings.prefetchMeetingInfo({
1919
+ destination: 'test destination',
1920
+ type: DESTINATION_TYPE.MEETING_ID,
1921
+ preJoinContext: {correlationId: 'correlation-id'},
1922
+ });
1923
+
1924
+ assert.deepEqual(await prefetchedMeetingInfo.request, response);
1925
+ assert.instanceOf(prefetchedMeetingInfo.provider, MeetingInfoV2);
1926
+ assert.notCalled(legacyFetchMeetingInfo);
1927
+ assert.calledOnce(appApiFetchMeetingInfo);
1928
+ });
1929
+ });
1064
1930
  describe('#create', () => {
1065
1931
  let infoOptions;
1066
1932
 
@@ -1080,6 +1946,141 @@ describe('plugin-meetings', () => {
1080
1946
  );
1081
1947
  });
1082
1948
 
1949
+ describe('wasm runtime performance telemetry', () => {
1950
+ const correlationId = 'wasm-corr-id';
1951
+ const benchmarkMeasurements = {
1952
+ divRatio: 1.888,
1953
+ sqrtRatio: 3.474,
1954
+ addNsPerOp: 2.006,
1955
+ addMedianMs: 32.1,
1956
+ divMedianMs: 60.6,
1957
+ sqrtMedianMs: 111.5,
1958
+ };
1959
+ const probeResult = {
1960
+ status: 'slow',
1961
+ capability: 'not capable',
1962
+ reason: null,
1963
+ measurements: benchmarkMeasurements,
1964
+ };
1965
+ const expectedMetricFields = {
1966
+ status: probeResult.status,
1967
+ capability: probeResult.capability,
1968
+ reason: probeResult.reason,
1969
+ ...benchmarkMeasurements,
1970
+ correlation_id: correlationId,
1971
+ };
1972
+ let metricsSpy;
1973
+ let probeCheckStub;
1974
+
1975
+ beforeEach(() => {
1976
+ webex.meetings.meetingInfo.fetchInfoOptions = sinon.stub().resolves({});
1977
+ webex.meetings.createMeeting = sinon
1978
+ .stub()
1979
+ .returns(Promise.resolve({on: () => true, correlationId}));
1980
+ probeCheckStub = sinon.stub(WasmRuntimeProbe, 'check').resolves(probeResult);
1981
+ metricsSpy = sinon.stub(Metrics, 'sendBehavioralMetric');
1982
+ });
1983
+
1984
+ afterEach(() => {
1985
+ probeCheckStub.restore();
1986
+ metricsSpy.restore();
1987
+ });
1988
+
1989
+ it('emits js_sdk_wasm_runtime_performance once after a meeting is created', async () => {
1990
+ await webex.meetings.create(test1, test2);
1991
+ await testUtils.flushPromises();
1992
+
1993
+ assert.calledOnceWithExactly(probeCheckStub);
1994
+ assert.calledOnceWithExactly(
1995
+ metricsSpy,
1996
+ 'js_sdk_wasm_runtime_performance',
1997
+ expectedMetricFields
1998
+ );
1999
+ });
2000
+
2001
+ it('logs the WASM runtime status after a meeting is created', async () => {
2002
+ const loggerLogStub = sinon.stub(LoggerProxy.logger, 'log');
2003
+
2004
+ await webex.meetings.create(test1, test2);
2005
+ await testUtils.flushPromises();
2006
+
2007
+ assert.calledOnceWithExactly(probeCheckStub);
2008
+ assert.calledOnceWithExactly(
2009
+ loggerLogStub,
2010
+ sinon.match(
2011
+ /Meetings:index#emitWasmRuntimePerformance --> WASM runtime performance status/
2012
+ )
2013
+ );
2014
+ loggerLogStub.restore();
2015
+ });
2016
+
2017
+ it('emits only once even when create() is called multiple times', async () => {
2018
+ await webex.meetings.create(test1, test2);
2019
+ await webex.meetings.create(test1, test2);
2020
+ await testUtils.flushPromises();
2021
+
2022
+ assert.calledOnceWithExactly(probeCheckStub);
2023
+ assert.calledOnceWithExactly(
2024
+ metricsSpy,
2025
+ 'js_sdk_wasm_runtime_performance',
2026
+ expectedMetricFields
2027
+ );
2028
+ });
2029
+
2030
+ it('emits the reason with null measurement fields when no measurements are available', async () => {
2031
+ probeCheckStub.resolves({
2032
+ status: 'unknown',
2033
+ capability: 'unknown',
2034
+ reason: 'worker_timeout',
2035
+ measurements: null,
2036
+ });
2037
+
2038
+ await webex.meetings.create(test1, test2);
2039
+ await testUtils.flushPromises();
2040
+
2041
+ assert.calledOnceWithExactly(metricsSpy, 'js_sdk_wasm_runtime_performance', {
2042
+ status: 'unknown',
2043
+ capability: 'unknown',
2044
+ reason: 'worker_timeout',
2045
+ divRatio: null,
2046
+ sqrtRatio: null,
2047
+ addNsPerOp: null,
2048
+ addMedianMs: null,
2049
+ divMedianMs: null,
2050
+ sqrtMedianMs: null,
2051
+ correlation_id: correlationId,
2052
+ });
2053
+ });
2054
+
2055
+ it('still resolves the meeting when the probe fails', async () => {
2056
+ const loggerErrorStub = sinon.stub(LoggerProxy.logger, 'error');
2057
+ probeCheckStub.rejects(new Error('probe failed'));
2058
+
2059
+ const created = await webex.meetings.create(test1, test2);
2060
+ await testUtils.flushPromises();
2061
+
2062
+ assert.equal(created.correlationId, correlationId);
2063
+ assert.notCalled(metricsSpy);
2064
+ assert.calledOnceWithExactly(
2065
+ loggerErrorStub,
2066
+ sinon.match(/Meetings:index#emitWasmRuntimePerformance --> ERROR/)
2067
+ );
2068
+ loggerErrorStub.restore();
2069
+ });
2070
+
2071
+ it('does not re-run the probe when create() returns an already-created meeting', async () => {
2072
+ webex.meetings.meetingCollection.getByKey = sinon
2073
+ .stub()
2074
+ .returns({updateCallStateForMetrics: sinon.stub()});
2075
+
2076
+ await webex.meetings.create(test1, test2);
2077
+ await testUtils.flushPromises();
2078
+
2079
+ assert.notCalled(probeCheckStub);
2080
+ assert.notCalled(metricsSpy);
2081
+ });
2082
+ });
2083
+
1083
2084
  it('should call MeetingInfo#fetchInfoOptions() with proper params', () => {
1084
2085
  webex.meetings.meetingInfo.fetchInfoOptions = sinon.stub().resolves(infoOptions);
1085
2086
 
@@ -1128,6 +2129,77 @@ describe('plugin-meetings', () => {
1128
2129
  });
1129
2130
  });
1130
2131
 
2132
+ it('consumes a prefetched request for an existing meeting without meeting info', async () => {
2133
+ const prefetchedMeetingInfo = {
2134
+ request: Promise.resolve({body: {meetingJoinUrl: 'meeting-join-url'}}),
2135
+ provider: webex.meetings.meetingInfo,
2136
+ extraParams: {},
2137
+ };
2138
+ const fakeMeeting = {
2139
+ meetingInfo: {},
2140
+ updateCallStateForMetrics: sinon.stub(),
2141
+ consumePrefetchedMeetingInfo: sinon.stub().resolves(),
2142
+ };
2143
+
2144
+ webex.meetings.meetingCollection.getByKey = sinon.stub().returns(fakeMeeting);
2145
+
2146
+ const meeting = await webex.meetings.create(
2147
+ test1,
2148
+ test2,
2149
+ FAKE_USE_RANDOM_DELAY,
2150
+ {},
2151
+ correlationId,
2152
+ true,
2153
+ callStateForMetrics,
2154
+ undefined,
2155
+ undefined,
2156
+ sessionCorrelationId,
2157
+ classificationId,
2158
+ prefetchedMeetingInfo
2159
+ );
2160
+
2161
+ assert.equal(meeting, fakeMeeting);
2162
+ assert.calledOnceWithExactly(
2163
+ fakeMeeting.consumePrefetchedMeetingInfo,
2164
+ prefetchedMeetingInfo
2165
+ );
2166
+ assert.notCalled(webex.meetings.createMeeting);
2167
+ });
2168
+
2169
+ it('keeps an existing populated meeting instead of applying a prefetched response', async () => {
2170
+ const prefetchedMeetingInfo = {
2171
+ request: Promise.resolve({body: {meetingJoinUrl: 'meeting-join-url'}}),
2172
+ provider: webex.meetings.meetingInfo,
2173
+ extraParams: {},
2174
+ };
2175
+ const fakeMeeting = {
2176
+ meetingInfo: {meetingJoinUrl: 'existing-meeting-join-url'},
2177
+ updateCallStateForMetrics: sinon.stub(),
2178
+ consumePrefetchedMeetingInfo: sinon.stub(),
2179
+ };
2180
+
2181
+ webex.meetings.meetingCollection.getByKey = sinon.stub().returns(fakeMeeting);
2182
+
2183
+ const meeting = await webex.meetings.create(
2184
+ test1,
2185
+ test2,
2186
+ FAKE_USE_RANDOM_DELAY,
2187
+ {},
2188
+ correlationId,
2189
+ true,
2190
+ callStateForMetrics,
2191
+ undefined,
2192
+ undefined,
2193
+ sessionCorrelationId,
2194
+ classificationId,
2195
+ prefetchedMeetingInfo
2196
+ );
2197
+
2198
+ assert.equal(meeting, fakeMeeting);
2199
+ assert.notCalled(fakeMeeting.consumePrefetchedMeetingInfo);
2200
+ assert.notCalled(webex.meetings.createMeeting);
2201
+ });
2202
+
1131
2203
  const checkCallCreateMeeting = async (createParameters, createMeetingParameters) => {
1132
2204
  const create = webex.meetings.create(...createParameters);
1133
2205
 
@@ -1203,8 +2275,30 @@ describe('plugin-meetings', () => {
1203
2275
 
1204
2276
  it('calls createMeeting with classificationId and returns its promise', async () => {
1205
2277
  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],
2278
+ [
2279
+ test1,
2280
+ test2,
2281
+ FAKE_USE_RANDOM_DELAY,
2282
+ {},
2283
+ undefined,
2284
+ true,
2285
+ callStateForMetrics,
2286
+ undefined,
2287
+ undefined,
2288
+ undefined,
2289
+ classificationId,
2290
+ ],
2291
+ [
2292
+ test1,
2293
+ test2,
2294
+ FAKE_USE_RANDOM_DELAY,
2295
+ {},
2296
+ callStateForMetrics,
2297
+ true,
2298
+ undefined,
2299
+ undefined,
2300
+ classificationId,
2301
+ ]
1208
2302
  );
1209
2303
  });
1210
2304
 
@@ -1437,36 +2531,80 @@ describe('plugin-meetings', () => {
1437
2531
  webExMeetingId,
1438
2532
  },
1439
2533
  },
1440
- hashTreeMessage: undefined
1441
- });
2534
+ hashTreeMessage: undefined,
2535
+ }, sinon.match.func);
1442
2536
  });
1443
2537
  it('should setup the meeting from a hash tree event', async () => {
1444
- const locus = {
1445
- id: uuid1,
1446
- self: {},
1447
- info: {
1448
- webExMeetingId,
1449
- },
2538
+ const selfData = {};
2539
+ const infoData = {webExMeetingId};
2540
+ const hashTreeMessage = {
2541
+ locusUrl: url1,
2542
+ locusStateElements: [
2543
+ {
2544
+ htMeta: {elementId: {type: 'Self', id: 1, version: 1}},
2545
+ data: selfData,
2546
+ },
2547
+ {
2548
+ htMeta: {elementId: {type: 'Info', id: 2, version: 1}},
2549
+ data: infoData,
2550
+ },
2551
+ ],
1450
2552
  };
1451
- const hashTreeMessage = {something: 'hashTreeData'};
1452
2553
  await webex.meetings.handleLocusEvent({
1453
- locus,
1454
2554
  eventType: 'locus.state_message',
1455
2555
  locusUrl: url1,
1456
2556
  stateElementsMessage: hashTreeMessage,
1457
2557
  });
1458
2558
  assert.calledWith(webex.meetings.meetingCollection.getByKey, 'locusUrl', url1);
1459
- assert.calledWith(
1460
- webex.meetings.meetingCollection.getByKey,
1461
- 'meetingNumber',
1462
- webExMeetingId
1463
- );
1464
2559
  assert.calledOnce(initialSetup);
1465
2560
  assert.calledWith(initialSetup, {
1466
2561
  trigger: 'locus-message',
1467
- locus,
2562
+ locus: {
2563
+ participants: [],
2564
+ url: url1,
2565
+ self: selfData,
2566
+ info: infoData,
2567
+ },
1468
2568
  hashTreeMessage,
2569
+ }, sinon.match.func);
2570
+ });
2571
+
2572
+ it('should ignore hash tree event when created locus has INACTIVE fullState', async () => {
2573
+ const hashTreeMessage = {
2574
+ locusUrl: url1,
2575
+ locusStateElements: [
2576
+ {
2577
+ htMeta: {elementId: {type: 'FullState', id: 1, version: 1}},
2578
+ data: {state: 'INACTIVE'},
2579
+ },
2580
+ ],
2581
+ };
2582
+ await webex.meetings.handleLocusEvent({
2583
+ eventType: 'locus.state_message',
2584
+ locusUrl: url1,
2585
+ stateElementsMessage: hashTreeMessage,
2586
+ });
2587
+ assert.notCalled(webex.meetings.create);
2588
+ assert.notCalled(initialSetup);
2589
+ });
2590
+
2591
+ it('should ignore hash tree event when created locus has self LEFT and removed', async () => {
2592
+ const hashTreeMessage = {
2593
+ locusUrl: url1,
2594
+ locusStateElements: [
2595
+ {
2596
+ htMeta: {elementId: {type: 'Self', id: 1, version: 1}},
2597
+ data: {state: 'LEFT', removed: true},
2598
+ },
2599
+ ],
2600
+ };
2601
+ await webex.meetings.handleLocusEvent({
2602
+ eventType: 'locus.state_message',
2603
+ locusUrl: url1,
2604
+ stateElementsMessage: hashTreeMessage,
1469
2605
  });
2606
+ assert.notCalled(webex.meetings.create);
2607
+ assert.notCalled(initialSetup);
1470
2608
  });
1471
2609
  it('should setup the meeting by difference event without replaces', async () => {
1472
2610
  await webex.meetings.handleLocusEvent({
@@ -1507,8 +2645,8 @@ describe('plugin-meetings', () => {
1507
2645
  webExMeetingId,
1508
2646
  },
1509
2647
  },
1510
- hashTreeMessage: undefined
1511
- });
2648
+ hashTreeMessage: undefined,
2649
+ }, sinon.match.func);
1512
2650
  });
1513
2651
 
1514
2652
  it('sends client event correctly on finally', async () => {
@@ -1583,8 +2721,8 @@ describe('plugin-meetings', () => {
1583
2721
  webExMeetingId,
1584
2722
  },
1585
2723
  },
1586
- hashTreeMessage: undefined
1587
- });
2724
+ hashTreeMessage: undefined,
2725
+ }, sinon.match.func);
1588
2726
  });
1589
2727
 
1590
2728
  const generateFakeLocusData = (isUnifiedSpaceMeeting) => ({
@@ -1716,7 +2854,11 @@ describe('plugin-meetings', () => {
1716
2854
  undefined,
1717
2855
  undefined,
1718
2856
  extraParams,
1719
- {meetingId: meeting.id, sendCAevents}
2857
+ {
2858
+ meetingId: meeting.id,
2859
+ sendCAevents,
2860
+ correlationId: meeting.correlationId,
2861
+ }
1720
2862
  );
1721
2863
  }
1722
2864
 
@@ -1819,6 +2961,98 @@ describe('plugin-meetings', () => {
1819
2961
  );
1820
2962
  });
1821
2963
 
2964
+ it('accepts a prefetched response and keeps using preJoin for later requests', async () => {
2965
+ const callState = {
2966
+ correlationId: 'correlation-id',
2967
+ sessionCorrelationId: 'session-correlation-id',
2968
+ loginType: 'reuse-ci-token',
2969
+ joinFlowVersion: 'NewFTE',
2970
+ };
2971
+ const permissionToken =
2972
+ 'eyJhbGciOiJIUzI1NiJ9.eyJleHAiOiIxMjM0NTYiLCJwZXJtaXNzaW9uIjp7InVzZXJQb2xpY2llcyI6eyJhIjp0cnVlfX19.wkTk0Hp8sUlq2wi2nP4-Ym4Xb7aEUHzyXA1kzk6f0V0';
2973
+ const preJoinProvider = {fetchMeetingInfo: sinon.stub()};
2974
+ const prefetchedMeetingInfo = {
2975
+ extraParams: {joinTXId: 'join-transaction-id'},
2976
+ provider: preJoinProvider,
2977
+ request: Promise.resolve({
2978
+ body: {
2979
+ permissionToken,
2980
+ meetingJoinUrl: 'meetingJoinUrl',
2981
+ },
2982
+ }),
2983
+ };
2984
+
2985
+ const meeting = await webex.meetings.createMeeting(
2986
+ 'test destination',
2987
+ 'test type',
2988
+ false,
2989
+ {},
2990
+ callState,
2991
+ false,
2992
+ undefined,
2993
+ undefined,
2994
+ undefined,
2995
+ prefetchedMeetingInfo
2996
+ );
2997
+
2998
+ assert.notCalled(webex.meetings.meetingInfo.fetchMeetingInfo);
2999
+ assert.equal(meeting.meetingJoinUrl, 'meetingJoinUrl');
3000
+ assert.equal(meeting.permissionToken, permissionToken);
3001
+ assert.deepEqual(meeting.selfUserPolicies, {a: true});
3002
+ assert.equal(meeting.attrs.meetingInfoProvider, preJoinProvider);
3003
+
3004
+ preJoinProvider.fetchMeetingInfo.resolves({
3005
+ body: {meetingJoinUrl: 'refreshed-meetingJoinUrl', permissionToken},
3006
+ });
3007
+
3008
+ await meeting.refreshPermissionToken('test');
3009
+
3010
+ assert.calledOnceWithExactly(
3011
+ preJoinProvider.fetchMeetingInfo,
3012
+ 'test destination',
3013
+ 'test type',
3014
+ null,
3015
+ null,
3016
+ undefined,
3017
+ meeting.locusId,
3018
+ {joinTXId: 'join-transaction-id', permissionToken},
3019
+ {
3020
+ meetingId: meeting.id,
3021
+ sendCAevents: true,
3022
+ correlationId: meeting.correlationId,
3023
+ },
3024
+ null,
3025
+ null,
3026
+ null
3027
+ );
3028
+
3029
+ preJoinProvider.fetchMeetingInfo.resetHistory();
3030
+ preJoinProvider.fetchMeetingInfo.resolves({
3031
+ body: {meetingJoinUrl: 'updated-meetingJoinUrl', permissionToken},
3032
+ });
3033
+
3034
+ await meeting.fetchMeetingInfo({sendCAevents: true});
3035
+
3036
+ assert.calledOnceWithExactly(
3037
+ preJoinProvider.fetchMeetingInfo,
3038
+ 'test destination',
3039
+ 'test type',
3040
+ null,
3041
+ null,
3042
+ undefined,
3043
+ meeting.locusId,
3044
+ {},
3045
+ {
3046
+ meetingId: meeting.id,
3047
+ sendCAevents: true,
3048
+ correlationId: meeting.correlationId,
3049
+ },
3050
+ null,
3051
+ null,
3052
+ null
3053
+ );
3054
+ });
3055
+
1822
3056
  it('accepts injected meeting info with meeting lookup url', async () => {
1823
3057
  const meetingInfo = {
1824
3058
  permissionToken:
@@ -2212,6 +3446,39 @@ describe('plugin-meetings', () => {
2212
3446
  checkCreateMeetingWithNoMeetingInfo(true, true);
2213
3447
  });
2214
3448
 
3449
+ it('does not emit meeting:added when meeting is destroyed due to missing meeting info', async () => {
3450
+ // Make destroy actually remove the meeting from the collection
3451
+ // so that getMeetingByType returns null in the finally block
3452
+ webex.meetings.destroy = sinon.stub().callsFake((meeting) => {
3453
+ webex.meetings.meetingCollection.delete(meeting.id);
3454
+ });
3455
+
3456
+ try {
3457
+ await webex.meetings.createMeeting(
3458
+ 'test destination',
3459
+ 'test type',
3460
+ undefined,
3461
+ undefined,
3462
+ undefined,
3463
+ true
3464
+ );
3465
+ assert.fail('should have thrown NoMeetingInfoError');
3466
+ } catch (err) {
3467
+ assert.instanceOf(err, NoMeetingInfoError);
3468
+ }
3469
+
3470
+ assert.calledOnce(webex.meetings.destroy);
3471
+
3472
+ // meeting:added should NOT have been triggered since the meeting was destroyed
3473
+ assert.neverCalledWith(
3474
+ TriggerProxy.trigger,
3475
+ sinon.match.any,
3476
+ sinon.match({function: 'createMeeting'}),
3477
+ 'meeting:added',
3478
+ sinon.match.any
3479
+ );
3480
+ });
3481
+
2215
3482
  it('creates the meeting avoiding meeting info fetch by passing type as DESTINATION_TYPE.ONE_ON_ONE_CALL', async () => {
2216
3483
  const meeting = await webex.meetings.createMeeting(
2217
3484
  'test destination',
@@ -2226,6 +3493,30 @@ describe('plugin-meetings', () => {
2226
3493
 
2227
3494
  assert.notCalled(webex.meetings.meetingInfo.fetchMeetingInfo);
2228
3495
  });
3496
+
3497
+ [
3498
+ {fullStateType: 'CALL'},
3499
+ {fullStateType: 'SIP_BRIDGE'},
3500
+ {fullStateType: 'SPACE_SHARE'},
3501
+ ].forEach(({fullStateType}) => {
3502
+ it(`skips meeting info fetch when LOCUS_ID destination is a 1:1 call (fullState.type ${fullStateType})`, async () => {
3503
+ const locusDestination = {
3504
+ fullState: {type: fullStateType},
3505
+ };
3506
+
3507
+ const meeting = await webex.meetings.createMeeting(
3508
+ locusDestination,
3509
+ DESTINATION_TYPE.LOCUS_ID
3510
+ );
3511
+
3512
+ assert.instanceOf(
3513
+ meeting,
3514
+ Meeting,
3515
+ 'createMeeting should eventually resolve to a Meeting Object'
3516
+ );
3517
+ assert.notCalled(webex.meetings.meetingInfo.fetchMeetingInfo);
3518
+ });
3519
+ });
2229
3520
  });
2230
3521
 
2231
3522
  describe('rejected MeetingInfo.#fetchMeetingInfo - does not log for known Error types', () => {
@@ -2465,7 +3756,7 @@ describe('plugin-meetings', () => {
2465
3756
  loggerProxySpy,
2466
3757
  'Failed to fetch preferred site from user - no site will be set'
2467
3758
  );
2468
- assert.deepEqual(webex.internal.services._getCatalog().getAllowedDomains(), ['']);
3759
+ assert.deepEqual(webex.internal.services._getCatalog().getAllowedDomains(), []);
2469
3760
  });
2470
3761
 
2471
3762
  it('should fall back to fetching the site from the user', async () => {
@@ -2483,7 +3774,6 @@ describe('plugin-meetings', () => {
2483
3774
 
2484
3775
  assert.equal(webex.meetings.preferredWebexSite, 'site.webex.com');
2485
3776
  assert.deepEqual(webex.internal.services._getCatalog().getAllowedDomains(), [
2486
- '',
2487
3777
  'site.webex.com',
2488
3778
  ]);
2489
3779
  assert.notCalled(loggerProxySpy);
@@ -2507,7 +3797,7 @@ describe('plugin-meetings', () => {
2507
3797
  loggerProxySpy,
2508
3798
  'Failed to fetch preferred site from user - no site will be set'
2509
3799
  );
2510
- assert.deepEqual(webex.internal.services._getCatalog().getAllowedDomains(), ['']);
3800
+ assert.deepEqual(webex.internal.services._getCatalog().getAllowedDomains(), []);
2511
3801
  });
2512
3802
  }
2513
3803
  );
@@ -2524,7 +3814,7 @@ describe('plugin-meetings', () => {
2524
3814
  loggerProxySpy,
2525
3815
  'Failed to fetch preferred site from user - no site will be set'
2526
3816
  );
2527
- assert.deepEqual(webex.internal.services._getCatalog().getAllowedDomains(), ['']);
3817
+ assert.deepEqual(webex.internal.services._getCatalog().getAllowedDomains(), []);
2528
3818
  });
2529
3819
 
2530
3820
  it('should fall back to fetching the site from the user', async () => {
@@ -2543,7 +3833,6 @@ describe('plugin-meetings', () => {
2543
3833
  assert.equal(webex.meetings.preferredWebexSite, 'site.webex.com');
2544
3834
  assert.notCalled(loggerProxySpy);
2545
3835
  assert.deepEqual(webex.internal.services._getCatalog().getAllowedDomains(), [
2546
- '',
2547
3836
  'site.webex.com',
2548
3837
  ]);
2549
3838
  });
@@ -2566,7 +3855,7 @@ describe('plugin-meetings', () => {
2566
3855
  loggerProxySpy,
2567
3856
  'Failed to fetch preferred site from user - no site will be set'
2568
3857
  );
2569
- assert.deepEqual(webex.internal.services._getCatalog().getAllowedDomains(), ['']);
3858
+ assert.deepEqual(webex.internal.services._getCatalog().getAllowedDomains(), []);
2570
3859
  });
2571
3860
  }
2572
3861
  );
@@ -2583,7 +3872,7 @@ describe('plugin-meetings', () => {
2583
3872
  loggerProxySpy,
2584
3873
  'Failed to fetch preferred site from user - no site will be set'
2585
3874
  );
2586
- assert.deepEqual(webex.internal.services._getCatalog().getAllowedDomains(), ['']);
3875
+ assert.deepEqual(webex.internal.services._getCatalog().getAllowedDomains(), []);
2587
3876
  });
2588
3877
  });
2589
3878
  });
@@ -2649,10 +3938,13 @@ describe('plugin-meetings', () => {
2649
3938
  };
2650
3939
 
2651
3940
  it('triggers correct event when SELF_CANNOT_VIEW_PARTICIPANT_LIST_CHANGE emitted', async () => {
3941
+ sinon.stub(meeting, 'updateMeetingActions');
2652
3942
  checkSelfTrigger(
2653
3943
  LOCUSINFO.EVENTS.SELF_CANNOT_VIEW_PARTICIPANT_LIST_CHANGE,
2654
3944
  EVENT_TRIGGERS.MEETING_SELF_CANNOT_VIEW_PARTICIPANT_LIST
2655
3945
  );
3946
+ assert.calledOnce(meeting.updateMeetingActions);
3947
+ meeting.updateMeetingActions.restore();
2656
3948
  });
2657
3949
 
2658
3950
  it('triggers correct event when SELF_IS_SHARING_BLOCKED_CHANGE emitted', async () => {
@@ -2805,6 +4097,21 @@ describe('plugin-meetings', () => {
2805
4097
  'Meetings:index#isNeedHandleMainLocus --> self device left&moved in main locus with self joined status, not need to handle'
2806
4098
  );
2807
4099
  });
4100
+
4101
+ it('check breakout ended with self removed, return false', () => {
4102
+ webex.meetings.meetingCollection.getActiveBreakoutLocus = sinon.stub().returns(null);
4103
+ newLocus.self.state = 'LEFT';
4104
+ newLocus.self.reason = 'OTHER';
4105
+ newLocus.self.removed = true;
4106
+ newLocus.fullState = {state: 'INACTIVE', endMeetingReason: 'BREAKOUT_ENDED'};
4107
+ LoggerProxy.logger.log = sinon.stub();
4108
+ const result = webex.meetings.isNeedHandleMainLocus(meeting, newLocus);
4109
+ assert.equal(result, false);
4110
+ assert.calledWith(
4111
+ LoggerProxy.logger.log,
4112
+ 'Meetings:index#isNeedHandleMainLocus --> self moved main locus with self removed status or with device resource moved, not need to handle'
4113
+ );
4114
+ });
2808
4115
  });
2809
4116
 
2810
4117
  describe('#isNeedHandleLocusDTO', () => {
@@ -2865,6 +4172,18 @@ describe('plugin-meetings', () => {
2865
4172
  const result = webex.meetings.isNeedHandleLocusDTO(meeting, newLocus);
2866
4173
  assert.equal(result, false);
2867
4174
  });
4175
+ it('breakout session with breakout ended, return false', () => {
4176
+ newLocus.controls.breakout = {
4177
+ sessionType: 'BREAKOUT',
4178
+ };
4179
+ newLocus.self.state = 'LEFT';
4180
+ newLocus.self.reason = 'OTHER';
4181
+ newLocus.self.devices = [];
4182
+ newLocus.fullState = {state: 'INACTIVE', endMeetingReason: 'BREAKOUT_ENDED'};
4183
+ LoggerProxy.logger.log = sinon.stub();
4184
+ const result = webex.meetings.isNeedHandleLocusDTO(meeting, newLocus);
4185
+ assert.equal(result, false);
4186
+ });
2868
4187
  it('moved to lobby, return true', () => {
2869
4188
  newLocus.controls.breakout = {
2870
4189
  sessionType: 'MAIN',
@@ -3322,7 +4641,7 @@ describe('plugin-meetings', () => {
3322
4641
  },
3323
4642
  });
3324
4643
  assert.calledWith(webex.meetings.handleLocusEvent, {
3325
- eventType: LOCUSEVENT.SDK_NO_EVENT,
4644
+ eventType: LOCUSEVENT.SDK_LOCUS_FROM_SYNC_MEETINGS,
3326
4645
  locus: breakoutLocus,
3327
4646
  locusUrl: breakoutLocus.url,
3328
4647
  });
@@ -3342,6 +4661,9 @@ describe('plugin-meetings', () => {
3342
4661
 
3343
4662
  triggerProxyStub.restore();
3344
4663
 
4664
+ // Never resolve, so the create()-triggered WASM emit can't reach the metrics spy below.
4665
+ sinon.stub(WasmRuntimeProbe, 'check').returns(new Promise(() => {}));
4666
+
3345
4667
  metricsSpy = sinon.stub(Metrics, 'sendBehavioralMetric');
3346
4668
 
3347
4669
  meeting = await webex.meetings.create('test');