@webex/plugin-meetings 3.12.0-next.13 → 3.12.0-next.130

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 (232) hide show
  1. package/AGENTS.md +9 -0
  2. package/dist/aiEnableRequest/index.js +15 -2
  3. package/dist/aiEnableRequest/index.js.map +1 -1
  4. package/dist/annotation/index.js +2 -2
  5. package/dist/annotation/index.js.map +1 -1
  6. package/dist/breakouts/breakout.js +8 -3
  7. package/dist/breakouts/breakout.js.map +1 -1
  8. package/dist/breakouts/events.js +29 -14
  9. package/dist/breakouts/events.js.map +1 -1
  10. package/dist/breakouts/index.js +99 -4
  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 +2 -2
  15. package/dist/config.js.map +1 -1
  16. package/dist/constants.js +37 -10
  17. package/dist/constants.js.map +1 -1
  18. package/dist/controls-options-manager/index.js +46 -10
  19. package/dist/controls-options-manager/index.js.map +1 -1
  20. package/dist/hashTree/constants.js +4 -1
  21. package/dist/hashTree/constants.js.map +1 -1
  22. package/dist/hashTree/hashTreeParser.js +1045 -393
  23. package/dist/hashTree/hashTreeParser.js.map +1 -1
  24. package/dist/hashTree/utils.js +20 -0
  25. package/dist/hashTree/utils.js.map +1 -1
  26. package/dist/index.js +7 -0
  27. package/dist/index.js.map +1 -1
  28. package/dist/interceptors/dataChannelAuthToken.js +75 -15
  29. package/dist/interceptors/dataChannelAuthToken.js.map +1 -1
  30. package/dist/interceptors/locusRetry.js +23 -8
  31. package/dist/interceptors/locusRetry.js.map +1 -1
  32. package/dist/interpretation/index.js +10 -1
  33. package/dist/interpretation/index.js.map +1 -1
  34. package/dist/interpretation/interpretation.types.js +7 -0
  35. package/dist/interpretation/interpretation.types.js.map +1 -0
  36. package/dist/interpretation/siLanguage.js +1 -1
  37. package/dist/locus-info/controlsUtils.js +4 -1
  38. package/dist/locus-info/controlsUtils.js.map +1 -1
  39. package/dist/locus-info/index.js +409 -122
  40. package/dist/locus-info/index.js.map +1 -1
  41. package/dist/locus-info/infoUtils.js +36 -5
  42. package/dist/locus-info/infoUtils.js.map +1 -1
  43. package/dist/locus-info/types.js +19 -0
  44. package/dist/locus-info/types.js.map +1 -1
  45. package/dist/media/MediaConnectionAwaiter.js +15 -2
  46. package/dist/media/MediaConnectionAwaiter.js.map +1 -1
  47. package/dist/media/index.js +8 -2
  48. package/dist/media/index.js.map +1 -1
  49. package/dist/media/properties.js +4 -5
  50. package/dist/media/properties.js.map +1 -1
  51. package/dist/meeting/in-meeting-actions.js +5 -1
  52. package/dist/meeting/in-meeting-actions.js.map +1 -1
  53. package/dist/meeting/index.js +1669 -835
  54. package/dist/meeting/index.js.map +1 -1
  55. package/dist/meeting/locusMediaRequest.js +229 -82
  56. package/dist/meeting/locusMediaRequest.js.map +1 -1
  57. package/dist/meeting/muteState.js +10 -1
  58. package/dist/meeting/muteState.js.map +1 -1
  59. package/dist/meeting/request.js +5 -2
  60. package/dist/meeting/request.js.map +1 -1
  61. package/dist/meeting/util.js +34 -2
  62. package/dist/meeting/util.js.map +1 -1
  63. package/dist/meeting-info/meeting-info-v2.js +9 -3
  64. package/dist/meeting-info/meeting-info-v2.js.map +1 -1
  65. package/dist/meetings/index.js +281 -124
  66. package/dist/meetings/index.js.map +1 -1
  67. package/dist/meetings/meetings.types.js +6 -1
  68. package/dist/meetings/meetings.types.js.map +1 -1
  69. package/dist/meetings/request.js +39 -0
  70. package/dist/meetings/request.js.map +1 -1
  71. package/dist/meetings/util.js +116 -18
  72. package/dist/meetings/util.js.map +1 -1
  73. package/dist/member/index.js +10 -0
  74. package/dist/member/index.js.map +1 -1
  75. package/dist/member/types.js.map +1 -1
  76. package/dist/member/util.js +30 -0
  77. package/dist/member/util.js.map +1 -1
  78. package/dist/members/index.js +101 -43
  79. package/dist/members/index.js.map +1 -1
  80. package/dist/members/util.js +8 -1
  81. package/dist/members/util.js.map +1 -1
  82. package/dist/metrics/constants.js +7 -1
  83. package/dist/metrics/constants.js.map +1 -1
  84. package/dist/multistream/codec/constants.js +63 -0
  85. package/dist/multistream/codec/constants.js.map +1 -0
  86. package/dist/multistream/mediaRequestManager.js +62 -15
  87. package/dist/multistream/mediaRequestManager.js.map +1 -1
  88. package/dist/multistream/receiveSlot.js +9 -0
  89. package/dist/multistream/receiveSlot.js.map +1 -1
  90. package/dist/reachability/clusterReachability.js.map +1 -1
  91. package/dist/reachability/index.js +121 -83
  92. package/dist/reachability/index.js.map +1 -1
  93. package/dist/reachability/reachability.types.js +2 -0
  94. package/dist/reachability/reachability.types.js.map +1 -1
  95. package/dist/reachability/util.js +45 -0
  96. package/dist/reachability/util.js.map +1 -1
  97. package/dist/reactions/reactions.type.js.map +1 -1
  98. package/dist/recording-controller/index.js +1 -3
  99. package/dist/recording-controller/index.js.map +1 -1
  100. package/dist/roap/turnDiscovery.js +8 -1
  101. package/dist/roap/turnDiscovery.js.map +1 -1
  102. package/dist/types/common/errors/webex-errors.d.ts +32 -2
  103. package/dist/types/config.d.ts +2 -2
  104. package/dist/types/constants.d.ts +13 -1
  105. package/dist/types/controls-options-manager/index.d.ts +16 -0
  106. package/dist/types/hashTree/constants.d.ts +1 -0
  107. package/dist/types/hashTree/hashTreeParser.d.ts +189 -22
  108. package/dist/types/hashTree/utils.d.ts +7 -0
  109. package/dist/types/index.d.ts +3 -0
  110. package/dist/types/interceptors/locusRetry.d.ts +4 -4
  111. package/dist/types/interpretation/interpretation.types.d.ts +10 -0
  112. package/dist/types/locus-info/index.d.ts +61 -7
  113. package/dist/types/locus-info/infoUtils.d.ts +8 -0
  114. package/dist/types/locus-info/types.d.ts +21 -1
  115. package/dist/types/media/MediaConnectionAwaiter.d.ts +10 -1
  116. package/dist/types/media/properties.d.ts +6 -2
  117. package/dist/types/meeting/in-meeting-actions.d.ts +4 -0
  118. package/dist/types/meeting/index.d.ts +175 -11
  119. package/dist/types/meeting/locusMediaRequest.d.ts +12 -0
  120. package/dist/types/meeting/request.d.ts +1 -0
  121. package/dist/types/meeting/util.d.ts +9 -0
  122. package/dist/types/meeting-info/meeting-info-v2.d.ts +1 -0
  123. package/dist/types/meetings/index.d.ts +38 -18
  124. package/dist/types/meetings/meetings.types.d.ts +15 -0
  125. package/dist/types/meetings/request.d.ts +14 -0
  126. package/dist/types/member/index.d.ts +1 -0
  127. package/dist/types/member/types.d.ts +1 -0
  128. package/dist/types/member/util.d.ts +9 -0
  129. package/dist/types/members/index.d.ts +15 -2
  130. package/dist/types/members/util.d.ts +1 -5
  131. package/dist/types/metrics/constants.d.ts +6 -0
  132. package/dist/types/multistream/codec/constants.d.ts +7 -0
  133. package/dist/types/multistream/mediaRequestManager.d.ts +22 -5
  134. package/dist/types/reachability/clusterReachability.d.ts +3 -3
  135. package/dist/types/reachability/index.d.ts +10 -3
  136. package/dist/types/reachability/reachability.types.d.ts +7 -0
  137. package/dist/types/reachability/util.d.ts +17 -0
  138. package/dist/types/reactions/reactions.type.d.ts +3 -0
  139. package/dist/webinar/index.js +307 -161
  140. package/dist/webinar/index.js.map +1 -1
  141. package/package.json +23 -23
  142. package/src/aiEnableRequest/index.ts +16 -0
  143. package/src/annotation/index.ts +6 -4
  144. package/src/breakouts/breakout.ts +3 -1
  145. package/src/breakouts/events.ts +33 -11
  146. package/src/breakouts/index.ts +122 -2
  147. package/src/common/errors/webex-errors.ts +50 -3
  148. package/src/config.ts +2 -2
  149. package/src/constants.ts +21 -3
  150. package/src/controls-options-manager/index.ts +62 -10
  151. package/src/hashTree/constants.ts +7 -0
  152. package/src/hashTree/hashTreeParser.ts +796 -192
  153. package/src/hashTree/utils.ts +19 -0
  154. package/src/index.ts +6 -0
  155. package/src/interceptors/dataChannelAuthToken.ts +88 -12
  156. package/src/interceptors/locusRetry.ts +25 -4
  157. package/src/interpretation/index.ts +27 -9
  158. package/src/interpretation/interpretation.types.ts +11 -0
  159. package/src/locus-info/controlsUtils.ts +3 -1
  160. package/src/locus-info/index.ts +413 -130
  161. package/src/locus-info/infoUtils.ts +41 -6
  162. package/src/locus-info/types.ts +25 -1
  163. package/src/media/MediaConnectionAwaiter.ts +21 -4
  164. package/src/media/index.ts +10 -1
  165. package/src/media/properties.ts +8 -3
  166. package/src/meeting/in-meeting-actions.ts +8 -0
  167. package/src/meeting/index.ts +923 -117
  168. package/src/meeting/locusMediaRequest.ts +106 -6
  169. package/src/meeting/muteState.ts +10 -1
  170. package/src/meeting/request.ts +11 -0
  171. package/src/meeting/util.ts +46 -5
  172. package/src/meeting-info/meeting-info-v2.ts +10 -4
  173. package/src/meetings/index.ts +178 -78
  174. package/src/meetings/meetings.types.ts +19 -0
  175. package/src/meetings/request.ts +43 -0
  176. package/src/meetings/util.ts +117 -4
  177. package/src/member/index.ts +10 -0
  178. package/src/member/types.ts +1 -0
  179. package/src/member/util.ts +29 -0
  180. package/src/members/index.ts +70 -7
  181. package/src/members/util.ts +12 -4
  182. package/src/metrics/constants.ts +6 -0
  183. package/src/multistream/codec/constants.ts +58 -0
  184. package/src/multistream/mediaRequestManager.ts +119 -28
  185. package/src/multistream/receiveSlot.ts +18 -0
  186. package/src/reachability/clusterReachability.ts +3 -2
  187. package/src/reachability/index.ts +47 -16
  188. package/src/reachability/reachability.types.ts +11 -0
  189. package/src/reachability/util.ts +36 -0
  190. package/src/reactions/reactions.type.ts +3 -0
  191. package/src/recording-controller/index.ts +1 -2
  192. package/src/roap/turnDiscovery.ts +9 -1
  193. package/src/webinar/index.ts +216 -38
  194. package/test/unit/spec/aiEnableRequest/index.ts +86 -0
  195. package/test/unit/spec/annotation/index.ts +3 -3
  196. package/test/unit/spec/breakouts/breakout.ts +9 -3
  197. package/test/unit/spec/breakouts/events.ts +120 -2
  198. package/test/unit/spec/breakouts/index.ts +223 -3
  199. package/test/unit/spec/common/errors/webex-errors.ts +78 -0
  200. package/test/unit/spec/controls-options-manager/index.js +139 -32
  201. package/test/unit/spec/hashTree/hashTreeParser.ts +2299 -243
  202. package/test/unit/spec/hashTree/utils.ts +37 -0
  203. package/test/unit/spec/interceptors/dataChannelAuthToken.ts +196 -0
  204. package/test/unit/spec/interceptors/locusRetry.ts +205 -4
  205. package/test/unit/spec/interpretation/index.ts +26 -4
  206. package/test/unit/spec/locus-info/controlsUtils.js +172 -57
  207. package/test/unit/spec/locus-info/index.js +671 -63
  208. package/test/unit/spec/locus-info/infoUtils.js +184 -1
  209. package/test/unit/spec/media/MediaConnectionAwaiter.ts +55 -0
  210. package/test/unit/spec/media/index.ts +92 -0
  211. package/test/unit/spec/media/properties.ts +23 -23
  212. package/test/unit/spec/meeting/in-meeting-actions.ts +4 -0
  213. package/test/unit/spec/meeting/index.js +2733 -116
  214. package/test/unit/spec/meeting/locusMediaRequest.ts +406 -4
  215. package/test/unit/spec/meeting/muteState.js +81 -0
  216. package/test/unit/spec/meeting/request.js +12 -0
  217. package/test/unit/spec/meeting/utils.js +153 -1
  218. package/test/unit/spec/meeting-info/meetinginfov2.js +76 -10
  219. package/test/unit/spec/meetings/index.js +486 -49
  220. package/test/unit/spec/meetings/request.js +141 -0
  221. package/test/unit/spec/meetings/utils.js +402 -51
  222. package/test/unit/spec/member/index.js +7 -0
  223. package/test/unit/spec/member/util.js +89 -0
  224. package/test/unit/spec/members/index.js +216 -0
  225. package/test/unit/spec/members/request.js +37 -1
  226. package/test/unit/spec/members/utils.js +63 -0
  227. package/test/unit/spec/multistream/mediaRequestManager.ts +501 -37
  228. package/test/unit/spec/reachability/index.ts +128 -46
  229. package/test/unit/spec/reachability/util.ts +31 -0
  230. package/test/unit/spec/recording-controller/index.js +9 -8
  231. package/test/unit/spec/roap/turnDiscovery.ts +20 -0
  232. package/test/unit/spec/webinar/index.ts +332 -31
@@ -3,6 +3,7 @@ import sinon from 'sinon';
3
3
  import {cloneDeep, forEach} from 'lodash';
4
4
  import {assert} from '@webex/test-helper-chai';
5
5
  import MockWebex from '@webex/test-helper-mock-webex';
6
+ import {webexTrackingIdSequenceNumbers} from '@webex/webex-core';
6
7
  import testUtils from '../../../utils/testUtils';
7
8
  import Meetings from '@webex/plugin-meetings';
8
9
  import LocusInfo, {createLocusFromHashTreeMessage, findMeetingForHashTreeMessage} from '@webex/plugin-meetings/src/locus-info';
@@ -13,6 +14,7 @@ import MediaSharesUtils from '@webex/plugin-meetings/src/locus-info//mediaShares
13
14
  import LocusDeltaParser from '@webex/plugin-meetings/src/locus-info/parser';
14
15
  import Metrics from '@webex/plugin-meetings/src/metrics';
15
16
  import * as HashTreeParserModule from '@webex/plugin-meetings/src/hashTree/hashTreeParser';
17
+ import MeetingsUtil from '@webex/plugin-meetings/src/meetings/util';
16
18
 
17
19
  import {
18
20
  LOCUSINFO,
@@ -30,6 +32,7 @@ import {
30
32
 
31
33
  import {self, selfWithInactivity} from './selfConstant';
32
34
  import {MEETING_REMOVED_REASON} from '@webex/plugin-meetings/src/constants';
35
+ import BEHAVIORAL_METRICS from '@webex/plugin-meetings/src/metrics/constants';
33
36
  import LoggerProxy from '@webex/plugin-meetings/src/common/logs/logger-proxy';
34
37
 
35
38
  describe('plugin-meetings', () => {
@@ -55,7 +58,7 @@ describe('plugin-meetings', () => {
55
58
 
56
59
  beforeEach(() => {
57
60
  mockMeeting = {};
58
- locusInfo = new LocusInfo(updateMeeting, webex, meetingId);
61
+ locusInfo = new LocusInfo({updateMeeting}, webex, meetingId);
59
62
 
60
63
  locusInfo.init(locus);
61
64
 
@@ -147,7 +150,9 @@ describe('plugin-meetings', () => {
147
150
  visibleDataSets,
148
151
  },
149
152
  webexRequest: sinon.match.func,
150
- locusInfoUpdateCallback: sinon.match.func,
153
+ callbacks: sinon.match({
154
+ locusInfoUpdateCallback: sinon.match.func,
155
+ }),
151
156
  debugId: sinon.match.string,
152
157
  })
153
158
  );
@@ -157,6 +162,39 @@ describe('plugin-meetings', () => {
157
162
  assert.isTrue(locusInfo.emitChange);
158
163
  });
159
164
 
165
+ it('passes a generateTrackingId callback that reuses the tracking-id interceptor sequence', async () => {
166
+ webex.sessionId = 'test-session';
167
+ const hashTreeMessage = createHashTreeMessage(['dataset1']);
168
+
169
+ await locusInfo.initialSetup({trigger: 'locus-message', hashTreeMessage});
170
+
171
+ const {generateTrackingId} = HashTreeParserStub.firstCall.args[0].callbacks;
172
+
173
+ // The interceptor for this webex is present in the exposed map -> reuse its sequence.
174
+ const fakeInterceptor = {webex, sequence: 7};
175
+ webexTrackingIdSequenceNumbers.set(fakeInterceptor, 0);
176
+
177
+ try {
178
+ assert.equal(generateTrackingId(), 'test-session_7');
179
+ } finally {
180
+ webexTrackingIdSequenceNumbers.delete(fakeInterceptor);
181
+ }
182
+ });
183
+
184
+ it('passes a generateTrackingId callback that falls back to a uuid when no interceptor is registered', async () => {
185
+ webex.sessionId = 'test-session';
186
+ const hashTreeMessage = createHashTreeMessage(['dataset1']);
187
+
188
+ await locusInfo.initialSetup({trigger: 'locus-message', hashTreeMessage});
189
+
190
+ const {generateTrackingId} = HashTreeParserStub.firstCall.args[0].callbacks;
191
+
192
+ assert.match(
193
+ generateTrackingId(),
194
+ /^test-session_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/
195
+ );
196
+ });
197
+
160
198
  it('should not initialize the hash tree when triggered from a non-hash tree locus message', async () => {
161
199
  const locus = {url: 'http://locus-url.com', participants: []};
162
200
 
@@ -197,7 +235,9 @@ describe('plugin-meetings', () => {
197
235
  },
198
236
  metadata,
199
237
  webexRequest: sinon.match.func,
200
- locusInfoUpdateCallback: sinon.match.func,
238
+ callbacks: sinon.match({
239
+ locusInfoUpdateCallback: sinon.match.func,
240
+ }),
201
241
  debugId: sinon.match.string,
202
242
  })
203
243
  );
@@ -220,6 +260,47 @@ describe('plugin-meetings', () => {
220
260
  assert.isTrue(locusInfo.emitChange);
221
261
  });
222
262
 
263
+ it('calls onLocusSynced callback passed as second argument with full locus from join response', async () => {
264
+ const syncedLocus = {url: 'http://locus-url.com', participants: []};
265
+ const onLocusSynced = sinon.stub();
266
+
267
+ await locusInfo.initialSetup(
268
+ {
269
+ trigger: 'join-response',
270
+ locus: syncedLocus,
271
+ },
272
+ onLocusSynced
273
+ );
274
+
275
+ assert.calledOnceWithExactly(onLocusSynced, syncedLocus);
276
+ });
277
+
278
+ it('swallows onLocusSynced callback errors and logs warn', async () => {
279
+ const syncedLocus = {url: 'http://locus-url.com', participants: []};
280
+ const callbackError = new Error('onLocusSynced failed');
281
+ const onLocusSynced = sinon.stub().throws(callbackError);
282
+ const loggerWarnStub = LoggerProxy.logger.warn?.isSinonProxy
283
+ ? LoggerProxy.logger.warn
284
+ : sinon.stub(LoggerProxy.logger, 'warn');
285
+
286
+ loggerWarnStub.resetHistory();
287
+
288
+ await locusInfo.initialSetup(
289
+ {
290
+ trigger: 'join-response',
291
+ locus: syncedLocus,
292
+ },
293
+ onLocusSynced
294
+ );
295
+
296
+ assert.calledOnceWithExactly(onLocusSynced, syncedLocus);
297
+ assert.calledOnce(loggerWarnStub);
298
+ assert.match(
299
+ loggerWarnStub.firstCall.args[0],
300
+ /Locus-info:index#initialSetup --> onLocusSynced callback failed/
301
+ );
302
+ });
303
+
223
304
  it('should initialize the hash tree parser correctly when triggered from a get loci response containing visible datasets', async () => {
224
305
  const visibleDataSets = ['dataset1', 'dataset2'];
225
306
  const locus = createLocusWithVisibleDataSets(visibleDataSets);
@@ -237,7 +318,9 @@ describe('plugin-meetings', () => {
237
318
  dataSets: [],
238
319
  },
239
320
  webexRequest: sinon.match.func,
240
- locusInfoUpdateCallback: sinon.match.func,
321
+ callbacks: sinon.match({
322
+ locusInfoUpdateCallback: sinon.match.func,
323
+ }),
241
324
  debugId: sinon.match.string,
242
325
  metadata: null,
243
326
  })
@@ -290,6 +373,7 @@ describe('plugin-meetings', () => {
290
373
  describe('should setup correct locusInfoUpdateCallback when creating HashTreeParser', () => {
291
374
  const OBJECTS_UPDATED = HashTreeParserModule.LocusInfoUpdateType.OBJECTS_UPDATED;
292
375
  const MEETING_ENDED = HashTreeParserModule.LocusInfoUpdateType.MEETING_ENDED;
376
+ const LOCUS_NOT_FOUND = HashTreeParserModule.LocusInfoUpdateType.LOCUS_NOT_FOUND;
293
377
 
294
378
  let locusInfoUpdateCallback;
295
379
  let onDeltaLocusStub;
@@ -312,7 +396,7 @@ describe('plugin-meetings', () => {
312
396
  },
313
397
  });
314
398
 
315
- locusInfoUpdateCallback = HashTreeParserStub.firstCall.args[0].locusInfoUpdateCallback;
399
+ locusInfoUpdateCallback = HashTreeParserStub.firstCall.args[0].callbacks.locusInfoUpdateCallback;
316
400
 
317
401
  assert.isDefined(locusInfoUpdateCallback);
318
402
 
@@ -959,6 +1043,37 @@ describe('plugin-meetings', () => {
959
1043
  assert.notCalled(destroyStub);
960
1044
  });
961
1045
 
1046
+ it('should handle LOCUS_NOT_FOUND by calling syncMeetings with skipHashTreeSync', () => {
1047
+ const syncMeetingsStub = sinon.stub(locusInfo.webex.meetings, 'syncMeetings').resolves();
1048
+
1049
+ locusInfoUpdateCallback({updateType: LOCUS_NOT_FOUND});
1050
+
1051
+ assert.calledOnceWithExactly(syncMeetingsStub, {keepOnlyLocusMeetings: false, skipHashTreeSync: true});
1052
+ });
1053
+
1054
+ it('should handle LOCUS_NOT_FOUND and log error if syncMeetings fails', async () => {
1055
+ const syncError = new Error('sync failed');
1056
+ const syncMeetingsStub = sinon.stub(locusInfo.webex.meetings, 'syncMeetings').rejects(syncError);
1057
+ const logErrorStub = LoggerProxy.logger.error?.isSinonProxy
1058
+ ? LoggerProxy.logger.error
1059
+ : sinon.stub(LoggerProxy.logger, 'error');
1060
+
1061
+ logErrorStub.resetHistory();
1062
+
1063
+ locusInfoUpdateCallback({updateType: LOCUS_NOT_FOUND});
1064
+
1065
+ assert.calledOnceWithExactly(syncMeetingsStub, {keepOnlyLocusMeetings: false, skipHashTreeSync: true});
1066
+
1067
+ // wait for the promise rejection to be handled
1068
+ await testUtils.flushPromises();
1069
+
1070
+ assert.calledOnce(logErrorStub);
1071
+ assert.match(
1072
+ logErrorStub.firstCall.args[0],
1073
+ /syncMeetings failed after LOCUS_NOT_FOUND/
1074
+ );
1075
+ });
1076
+
962
1077
  it('should set forceReplaceMembers to true on the first update for a locusUrl (initializedFromHashTree is false)', () => {
963
1078
  const createdHashTreeParser = locusInfo.hashTreeParsers.get('fake-locus-url');
964
1079
  createdHashTreeParser.initializedFromHashTree = false;
@@ -1289,6 +1404,8 @@ describe('plugin-meetings', () => {
1289
1404
  state: RECORDING_STATE.IDLE,
1290
1405
  modifiedBy: 'George Kittle',
1291
1406
  lastModified: 'TODAY',
1407
+ modifiedByServiceAppName: undefined,
1408
+ modifiedByServiceAppId: undefined,
1292
1409
  }
1293
1410
  );
1294
1411
  });
@@ -1323,6 +1440,8 @@ describe('plugin-meetings', () => {
1323
1440
  state: RECORDING_STATE.RECORDING,
1324
1441
  modifiedBy: 'George Kittle',
1325
1442
  lastModified: 'TODAY',
1443
+ modifiedByServiceAppName: undefined,
1444
+ modifiedByServiceAppId: undefined,
1326
1445
  }
1327
1446
  );
1328
1447
  });
@@ -1358,6 +1477,8 @@ describe('plugin-meetings', () => {
1358
1477
  state: RECORDING_STATE.PAUSED,
1359
1478
  modifiedBy: 'George Kittle',
1360
1479
  lastModified: 'TODAY',
1480
+ modifiedByServiceAppName: undefined,
1481
+ modifiedByServiceAppId: undefined,
1361
1482
  }
1362
1483
  );
1363
1484
  });
@@ -1394,6 +1515,8 @@ describe('plugin-meetings', () => {
1394
1515
  state: RECORDING_STATE.RESUMED,
1395
1516
  modifiedBy: 'George Kittle',
1396
1517
  lastModified: 'TODAY',
1518
+ modifiedByServiceAppName: undefined,
1519
+ modifiedByServiceAppId: undefined,
1397
1520
  }
1398
1521
  );
1399
1522
  });
@@ -1429,6 +1552,44 @@ describe('plugin-meetings', () => {
1429
1552
  state: RECORDING_STATE.IDLE,
1430
1553
  modifiedBy: 'George Kittle',
1431
1554
  lastModified: 'TODAY',
1555
+ modifiedByServiceAppName: undefined,
1556
+ modifiedByServiceAppId: undefined,
1557
+ }
1558
+ );
1559
+ });
1560
+
1561
+ it('should include service app fields in the recording event when present', () => {
1562
+ locusInfo.controls = {
1563
+ record: {
1564
+ recording: false,
1565
+ paused: false,
1566
+ meta: {
1567
+ lastModified: 'TODAY',
1568
+ modifiedBy: 'George Kittle',
1569
+ },
1570
+ },
1571
+ shareControl: {},
1572
+ transcribe: {},
1573
+ };
1574
+ newControls.record.recording = true;
1575
+ newControls.record.meta.modifiedByServiceAppName = 'My Bot';
1576
+ newControls.record.meta.modifiedByServiceAppId = 'app-id-123';
1577
+ locusInfo.emitScoped = sinon.stub();
1578
+ locusInfo.updateControls(newControls);
1579
+
1580
+ assert.calledWith(
1581
+ locusInfo.emitScoped,
1582
+ {
1583
+ file: 'locus-info',
1584
+ function: 'updateControls',
1585
+ },
1586
+ LOCUSINFO.EVENTS.CONTROLS_RECORDING_UPDATED,
1587
+ {
1588
+ state: RECORDING_STATE.RECORDING,
1589
+ modifiedBy: 'George Kittle',
1590
+ lastModified: 'TODAY',
1591
+ modifiedByServiceAppName: 'My Bot',
1592
+ modifiedByServiceAppId: 'app-id-123',
1432
1593
  }
1433
1594
  );
1434
1595
  });
@@ -2024,7 +2185,7 @@ describe('plugin-meetings', () => {
2024
2185
  function: 'updateSelf',
2025
2186
  },
2026
2187
  LOCUSINFO.EVENTS.SELF_REMOTE_MUTE_STATUS_UPDATED,
2027
- {muted: true, unmuteAllowed: true}
2188
+ {muted: true, unmuteAllowed: true, modifiedBy: null}
2028
2189
  );
2029
2190
 
2030
2191
  // but sometimes "previous self" is defined, but without controls.audio.muted, so we test this here:
@@ -2039,7 +2200,7 @@ describe('plugin-meetings', () => {
2039
2200
  function: 'updateSelf',
2040
2201
  },
2041
2202
  LOCUSINFO.EVENTS.SELF_REMOTE_MUTE_STATUS_UPDATED,
2042
- {muted: true, unmuteAllowed: true}
2203
+ {muted: true, unmuteAllowed: true, modifiedBy: null}
2043
2204
  );
2044
2205
  });
2045
2206
 
@@ -2098,7 +2259,7 @@ describe('plugin-meetings', () => {
2098
2259
  function: 'updateSelf',
2099
2260
  },
2100
2261
  LOCUSINFO.EVENTS.SELF_REMOTE_MUTE_STATUS_UPDATED,
2101
- {muted: true, unmuteAllowed: true}
2262
+ {muted: true, unmuteAllowed: true, modifiedBy: null}
2102
2263
  );
2103
2264
  });
2104
2265
 
@@ -2237,7 +2398,7 @@ describe('plugin-meetings', () => {
2237
2398
  function: 'updateSelf',
2238
2399
  },
2239
2400
  LOCUSINFO.EVENTS.SELF_REMOTE_MUTE_STATUS_UPDATED,
2240
- {muted: true, unmuteAllowed: false}
2401
+ {muted: true, unmuteAllowed: false, modifiedBy: null}
2241
2402
  );
2242
2403
 
2243
2404
  // now change only disallowUnmute
@@ -2255,7 +2416,28 @@ describe('plugin-meetings', () => {
2255
2416
  function: 'updateSelf',
2256
2417
  },
2257
2418
  LOCUSINFO.EVENTS.SELF_REMOTE_MUTE_STATUS_UPDATED,
2258
- {muted: true, unmuteAllowed: true}
2419
+ {muted: true, unmuteAllowed: true, modifiedBy: null}
2420
+ );
2421
+ });
2422
+
2423
+ it('should include modifiedBy in payload when muted by host', () => {
2424
+ locusInfo.webex.internal.device.url = self.deviceUrl;
2425
+ locusInfo.updateSelf(self);
2426
+ const newSelf = cloneDeep(self);
2427
+ newSelf.controls.audio.muted = true;
2428
+ newSelf.controls.audio.meta = {modifiedBy: 'host-uuid-123'};
2429
+
2430
+ locusInfo.emitScoped = sinon.stub();
2431
+ locusInfo.updateSelf(newSelf);
2432
+
2433
+ assert.calledWith(
2434
+ locusInfo.emitScoped,
2435
+ {
2436
+ file: 'locus-info',
2437
+ function: 'updateSelf',
2438
+ },
2439
+ LOCUSINFO.EVENTS.SELF_REMOTE_MUTE_STATUS_UPDATED,
2440
+ {muted: true, unmuteAllowed: true, modifiedBy: 'host-uuid-123'}
2259
2441
  );
2260
2442
  });
2261
2443
 
@@ -2266,6 +2448,7 @@ describe('plugin-meetings', () => {
2266
2448
 
2267
2449
  selfWithLocalUnmuteRequired.controls.audio.muted = false;
2268
2450
  selfWithLocalUnmuteRequired.controls.audio.localAudioUnmuteRequired = true;
2451
+ selfWithLocalUnmuteRequired.controls.audio.meta = {modifiedBy: 'host-uuid-123'};
2269
2452
 
2270
2453
  locusInfo.emitScoped = sinon.stub();
2271
2454
  locusInfo.updateSelf(selfWithLocalUnmuteRequired);
@@ -2280,6 +2463,33 @@ describe('plugin-meetings', () => {
2280
2463
  {
2281
2464
  muted: false,
2282
2465
  unmuteAllowed: true,
2466
+ modifiedBy: 'host-uuid-123',
2467
+ }
2468
+ );
2469
+ });
2470
+
2471
+ it('should set modifiedBy to null on LOCAL_UNMUTE_REQUIRED when it is unavailable', () => {
2472
+ locusInfo.webex.internal.device.url = self.deviceUrl;
2473
+ locusInfo.updateSelf(self);
2474
+ const selfWithLocalUnmuteRequired = cloneDeep(self);
2475
+
2476
+ selfWithLocalUnmuteRequired.controls.audio.muted = false;
2477
+ selfWithLocalUnmuteRequired.controls.audio.localAudioUnmuteRequired = true;
2478
+
2479
+ locusInfo.emitScoped = sinon.stub();
2480
+ locusInfo.updateSelf(selfWithLocalUnmuteRequired);
2481
+
2482
+ assert.calledWith(
2483
+ locusInfo.emitScoped,
2484
+ {
2485
+ file: 'locus-info',
2486
+ function: 'updateSelf',
2487
+ },
2488
+ LOCUSINFO.EVENTS.LOCAL_UNMUTE_REQUIRED,
2489
+ {
2490
+ muted: false,
2491
+ unmuteAllowed: true,
2492
+ modifiedBy: null,
2283
2493
  }
2284
2494
  );
2285
2495
  });
@@ -2705,6 +2915,10 @@ describe('plugin-meetings', () => {
2705
2915
 
2706
2916
  let expectedMeeting;
2707
2917
 
2918
+ // simulate that updateSelf has been called previously (as happens in production)
2919
+ // so that parsedLocus.self reflects the joined state
2920
+ locusInfo.parsedLocus.self = {state: 'JOINED'};
2921
+
2708
2922
  /*
2709
2923
  When the event is triggered, it is required that the meeting has already
2710
2924
  been updated. This is why the meeting is being checked within the stubbed event emitter
@@ -2715,6 +2929,7 @@ describe('plugin-meetings', () => {
2715
2929
 
2716
2930
  // set the info initially as locusInfo.info starts as undefined
2717
2931
  expectedMeeting = {
2932
+ attendee: {},
2718
2933
  coHost: {
2719
2934
  LOWER_SOMEONE_ELSES_HAND: true,
2720
2935
  },
@@ -2723,10 +2938,12 @@ describe('plugin-meetings', () => {
2723
2938
  moderator: {
2724
2939
  LOWER_SOMEONE_ELSES_HAND: true,
2725
2940
  },
2941
+ panelist: {},
2726
2942
  policy: {
2727
2943
  LOCK_STATUS_UNLOCKED: true,
2728
2944
  ROSTER_IN_MEETING: true,
2729
2945
  },
2946
+ presenter: {},
2730
2947
  userDisplayHints: ['ROSTER_IN_MEETING', 'LOCK_STATUS_UNLOCKED'],
2731
2948
  };
2732
2949
  locusInfo.updateMeetingInfo(initialInfo, self);
@@ -2741,6 +2958,7 @@ describe('plugin-meetings', () => {
2741
2958
 
2742
2959
  // Updating with different info should trigger the event
2743
2960
  expectedMeeting = {
2961
+ attendee: {},
2744
2962
  coHost: {
2745
2963
  LOWER_SOMEONE_ELSES_HAND: true,
2746
2964
  LOCK_CONTROL_LOCK: true,
@@ -2750,10 +2968,12 @@ describe('plugin-meetings', () => {
2750
2968
  moderator: {
2751
2969
  LOWER_SOMEONE_ELSES_HAND: true,
2752
2970
  },
2971
+ panelist: {},
2753
2972
  policy: {
2754
2973
  LOCK_STATUS_UNLOCKED: true,
2755
2974
  ROSTER_IN_MEETING: true,
2756
2975
  },
2976
+ presenter: {},
2757
2977
  userDisplayHints: ['ROSTER_IN_MEETING', 'LOCK_STATUS_UNLOCKED'],
2758
2978
  };
2759
2979
  locusInfo.updateMeetingInfo(newInfo, self);
@@ -2762,6 +2982,7 @@ describe('plugin-meetings', () => {
2762
2982
 
2763
2983
  // update it with the same info
2764
2984
  expectedMeeting = {
2985
+ attendee: {},
2765
2986
  coHost: {
2766
2987
  LOWER_SOMEONE_ELSES_HAND: true,
2767
2988
  LOCK_CONTROL_LOCK: true,
@@ -2771,10 +2992,12 @@ describe('plugin-meetings', () => {
2771
2992
  moderator: {
2772
2993
  LOWER_SOMEONE_ELSES_HAND: true,
2773
2994
  },
2995
+ panelist: {},
2774
2996
  policy: {
2775
2997
  LOCK_STATUS_UNLOCKED: true,
2776
2998
  ROSTER_IN_MEETING: true,
2777
2999
  },
3000
+ presenter: {},
2778
3001
  userDisplayHints: ['ROSTER_IN_MEETING', 'LOCK_STATUS_UNLOCKED'],
2779
3002
  };
2780
3003
  locusInfo.updateMeetingInfo(newInfo, self);
@@ -2789,6 +3012,7 @@ describe('plugin-meetings', () => {
2789
3012
  hasRole: true,
2790
3013
  });
2791
3014
  expectedMeeting = {
3015
+ attendee: {},
2792
3016
  coHost: {
2793
3017
  LOWER_SOMEONE_ELSES_HAND: true,
2794
3018
  LOCK_CONTROL_LOCK: true,
@@ -2798,10 +3022,12 @@ describe('plugin-meetings', () => {
2798
3022
  moderator: {
2799
3023
  LOWER_SOMEONE_ELSES_HAND: true,
2800
3024
  },
3025
+ panelist: {},
2801
3026
  policy: {
2802
3027
  LOCK_STATUS_UNLOCKED: true,
2803
3028
  ROSTER_IN_MEETING: true,
2804
3029
  },
3030
+ presenter: {},
2805
3031
  userDisplayHints: [
2806
3032
  'ROSTER_IN_MEETING',
2807
3033
  'LOCK_STATUS_UNLOCKED',
@@ -2844,6 +3070,46 @@ describe('plugin-meetings', () => {
2844
3070
  // since self is not passed to updateMeetingInfo, MEETING_INFO_UPDATED should be triggered with isIntializing: true
2845
3071
  checkMeetingInfoUpdatedCalledForRoles(true, {isInitializing: true});
2846
3072
  });
3073
+
3074
+ // joined-section hints (like ROSTER_IN_MEETING) are filtered out while not joined, so they
3075
+ // are a good proxy for verifying that userDisplayHints get recomputed on a join transition
3076
+ [
3077
+ {
3078
+ name: 'the JOINED delta carries the info section',
3079
+ getSecondInfo: (info) => info,
3080
+ },
3081
+ {
3082
+ name: 'the JOINED delta omits the info section (falls back to stored info)',
3083
+ getSecondInfo: () => undefined,
3084
+ },
3085
+ ].forEach(({name, getSecondInfo}) => {
3086
+ it(`recomputes userDisplayHints when self transitions to JOINED with unchanged roles and ${name}`, () => {
3087
+ const info = cloneDeep(meetingInfo); // joined: ['ROSTER_IN_MEETING', 'LOCK_STATUS_UNLOCKED']
3088
+
3089
+ const notJoinedSelf = cloneDeep(self);
3090
+ notJoinedSelf.state = 'IDLE';
3091
+ notJoinedSelf.controls.role.roles = [];
3092
+
3093
+ const joinedSelf = cloneDeep(self);
3094
+ joinedSelf.state = 'JOINED';
3095
+ joinedSelf.controls.role.roles = [];
3096
+
3097
+ sinon.stub(locusInfo, 'emitScoped');
3098
+
3099
+ // first update while not joined: joined-section hints are filtered out
3100
+ locusInfo.updateMeetingInfo(info, notJoinedSelf);
3101
+ assert.notInclude(locusInfo.parsedLocus.info.userDisplayHints, 'ROSTER_IN_MEETING');
3102
+ assert.notInclude(locusInfo.parsedLocus.info.userDisplayHints, 'LOCK_STATUS_UNLOCKED');
3103
+
3104
+ // self transitions to JOINED - info and roles are unchanged
3105
+ locusInfo.updateMeetingInfo(getSecondInfo(info), joinedSelf);
3106
+
3107
+ // the hints must be recomputed with the new joined state
3108
+ assert.include(locusInfo.parsedLocus.info.userDisplayHints, 'ROSTER_IN_MEETING');
3109
+ assert.include(locusInfo.parsedLocus.info.userDisplayHints, 'LOCK_STATUS_UNLOCKED');
3110
+ checkMeetingInfoUpdatedCalled(true, {isInitializing: false});
3111
+ });
3112
+ });
2847
3113
  });
2848
3114
 
2849
3115
  describe('#updateMediaShares', () => {
@@ -3154,13 +3420,14 @@ describe('plugin-meetings', () => {
3154
3420
  const createMockParser = (state = 'active') => ({
3155
3421
  state,
3156
3422
  stop: sinon.stub(),
3157
- resume: sinon.stub(),
3423
+ resumeFromMessage: sinon.stub(),
3158
3424
  handleMessage: sinon.stub(),
3159
3425
  });
3160
3426
 
3161
3427
  const createSelfElementWithReplaces = (replacedLocusUrl, replacedAt) => ({
3162
3428
  htMeta: {elementId: {type: 'Self'}},
3163
3429
  data: {
3430
+ deviceUrl,
3164
3431
  devices: [{url: deviceUrl, replaces: [{locusUrl: replacedLocusUrl, replacedAt}]}],
3165
3432
  },
3166
3433
  });
@@ -3236,7 +3503,7 @@ describe('plugin-meetings', () => {
3236
3503
  stateElementsMessage: message,
3237
3504
  });
3238
3505
 
3239
- assert.calledOnce(parserA.resume);
3506
+ assert.calledOnce(parserA.resumeFromMessage);
3240
3507
  assert.calledOnce(parserB.stop);
3241
3508
  });
3242
3509
 
@@ -3259,7 +3526,7 @@ describe('plugin-meetings', () => {
3259
3526
  stateElementsMessage: message,
3260
3527
  });
3261
3528
 
3262
- assert.notCalled(parserA.resume);
3529
+ assert.notCalled(parserA.resumeFromMessage);
3263
3530
  assert.notCalled(parserB.stop);
3264
3531
  });
3265
3532
 
@@ -3278,7 +3545,7 @@ describe('plugin-meetings', () => {
3278
3545
  stateElementsMessage: message,
3279
3546
  });
3280
3547
 
3281
- assert.notCalled(parserA.resume);
3548
+ assert.notCalled(parserA.resumeFromMessage);
3282
3549
  assert.notCalled(parserA.handleMessage);
3283
3550
  });
3284
3551
 
@@ -3362,6 +3629,51 @@ describe('plugin-meetings', () => {
3362
3629
 
3363
3630
  assert.calledOnceWithExactly(parserA.handleMessage, message);
3364
3631
  });
3632
+
3633
+ it('should send mismatch metric when eventType is not HASH_TREE_DATA_UPDATED', () => {
3634
+ const locusUrlA = 'http://locus-url-A.com';
3635
+ const parserA = {state: 'active', handleMessage: sinon.stub()};
3636
+ locusInfo.hashTreeParsers.set(locusUrlA, {parser: parserA, initializedFromHashTree: true});
3637
+
3638
+ locusInfo.parse(mockMeeting, {
3639
+ eventType: LOCUSEVENT.SELF_CHANGED,
3640
+ stateElementsMessage: {locusUrl: locusUrlA, locusStateElements: [], dataSets: []},
3641
+ });
3642
+
3643
+ assert.calledOnceWithExactly(
3644
+ sendBehavioralMetricStub,
3645
+ 'js_sdk_locus_classic_vs_hash_tree_mismatch',
3646
+ {
3647
+ correlationId: mockMeeting.correlationId,
3648
+ message: `got ${LOCUSEVENT.SELF_CHANGED}, expected ${LOCUSEVENT.HASH_TREE_DATA_UPDATED}`,
3649
+ }
3650
+ );
3651
+ assert.notCalled(parserA.handleMessage);
3652
+ });
3653
+ });
3654
+
3655
+ describe('#sendClassicVsHashTreeMismatchMetric', () => {
3656
+ it('should send the metric when called for the first time', () => {
3657
+ locusInfo.sendClassicVsHashTreeMismatchMetric(mockMeeting, 'some mismatch');
3658
+
3659
+ assert.calledOnceWithExactly(
3660
+ sendBehavioralMetricStub,
3661
+ 'js_sdk_locus_classic_vs_hash_tree_mismatch',
3662
+ {
3663
+ correlationId: mockMeeting.correlationId,
3664
+ message: 'some mismatch',
3665
+ }
3666
+ );
3667
+ });
3668
+
3669
+ it('should send the metric up to 5 times and stop after that', () => {
3670
+ for (let i = 0; i < 7; i += 1) {
3671
+ locusInfo.sendClassicVsHashTreeMismatchMetric(mockMeeting, `mismatch ${i}`);
3672
+ }
3673
+
3674
+ assert.callCount(sendBehavioralMetricStub, 5);
3675
+ assert.equal(locusInfo.classicVsHashTreeMismatchMetricCounter, 5);
3676
+ });
3365
3677
  });
3366
3678
 
3367
3679
  describe('#handleLocusAPIResponse', () => {
@@ -3417,19 +3729,186 @@ describe('plugin-meetings', () => {
3417
3729
  assert.calledOnceWithExactly(locusInfo.handleLocusDelta, fakeLocus, mockMeeting);
3418
3730
  });
3419
3731
 
3420
- it('should send mismatch metric when hash tree parser exists but dataSets are missing in wrapped response', () => {
3732
+ it('should send mismatch metric in classic mode when wrapped response has dataSets', () => {
3421
3733
  const fakeLocus = {url: 'http://locus-url.com'};
3422
- const mockHashTreeParser = {handleLocusUpdate: sinon.stub()};
3423
- locusInfo.hashTreeParsers.set(fakeLocus.url, {
3424
- parser: mockHashTreeParser,
3425
- initializedFromHashTree: true,
3734
+ sinon.stub(locusInfo, 'handleLocusDelta');
3735
+
3736
+ locusInfo.handleLocusAPIResponse(mockMeeting, {
3737
+ locus: fakeLocus,
3738
+ dataSets: [{name: 'dataset1', url: 'test-url'}],
3426
3739
  });
3427
- sinon.stub(locusInfo, 'sendClassicVsHashTreeMismatchMetric');
3428
3740
 
3429
- locusInfo.handleLocusAPIResponse(mockMeeting, {locus: fakeLocus});
3741
+ assert.calledOnceWithExactly(
3742
+ sendBehavioralMetricStub,
3743
+ 'js_sdk_locus_classic_vs_hash_tree_mismatch',
3744
+ {
3745
+ correlationId: mockMeeting.correlationId,
3746
+ message: 'unexpected hash tree dataSets in API response',
3747
+ }
3748
+ );
3749
+ assert.calledOnce(locusInfo.handleLocusDelta);
3750
+ });
3430
3751
 
3431
- assert.calledOnce(locusInfo.sendClassicVsHashTreeMismatchMetric);
3432
- assert.calledOnce(mockHashTreeParser.handleLocusUpdate);
3752
+ describe('parser switch via API response', () => {
3753
+ const deviceUrl = 'http://device-url.com';
3754
+ const locusUrlA = 'http://locus-url-A.com';
3755
+ const locusUrlB = 'http://locus-url-B.com';
3756
+
3757
+ let HashTreeParserStub;
3758
+
3759
+ const createMockApiParser = (state = 'active') => ({
3760
+ state,
3761
+ stop: sinon.stub(),
3762
+ resumeFromApiResponse: sinon.stub(),
3763
+ handleLocusUpdate: sinon.stub(),
3764
+ initializeFromGetLociResponse: sinon.stub(),
3765
+ });
3766
+
3767
+ const createLocusWithReplaces = (url, replacedLocusUrl, replacedAt) => ({
3768
+ url,
3769
+ self: {
3770
+ devices: [{url: deviceUrl, replaces: [{locusUrl: replacedLocusUrl, replacedAt}]}],
3771
+ },
3772
+ });
3773
+
3774
+ const createLocusWithoutReplaces = (url) => ({
3775
+ url,
3776
+ self: {devices: [{url: deviceUrl}]},
3777
+ });
3778
+
3779
+ beforeEach(() => {
3780
+ locusInfo.webex.internal.device.url = deviceUrl;
3781
+ HashTreeParserStub = sinon
3782
+ .stub(HashTreeParserModule, 'default')
3783
+ .returns(createMockApiParser());
3784
+ });
3785
+
3786
+ it('should create a new parser and initialize it when no entry exists for the locusUrl', () => {
3787
+ // existing parser for a different url so hashTreeParsers.size > 0
3788
+ locusInfo.hashTreeParsers.set(locusUrlA, {parser: createMockApiParser(), initializedFromHashTree: true});
3789
+
3790
+ const locus = createLocusWithReplaces(locusUrlB, locusUrlA, '2026-01-01T00:00:00Z');
3791
+ sinon.stub(locusInfo, 'handleLocusDelta');
3792
+
3793
+ locusInfo.handleLocusAPIResponse(mockMeeting, {locus});
3794
+
3795
+ assert.isTrue(locusInfo.hashTreeParsers.has(locusUrlB));
3796
+ const newEntry = locusInfo.hashTreeParsers.get(locusUrlB);
3797
+ assert.isFalse(newEntry.initializedFromHashTree);
3798
+
3799
+ // the stub returns the mock, so initializeFromGetLociResponse should be called on it
3800
+ const createdParser = HashTreeParserStub.returnValues[0];
3801
+ assert.calledOnceWithExactly(createdParser.initializeFromGetLociResponse, locus);
3802
+ assert.notCalled(locusInfo.handleLocusDelta);
3803
+ });
3804
+
3805
+ it('should reactivate a stopped parser when replaces info is newer', () => {
3806
+ const parserA = createMockApiParser('stopped');
3807
+ const parserB = createMockApiParser('active');
3808
+ locusInfo.hashTreeParsers.set(locusUrlA, {parser: parserA, replacedAt: '2026-01-01T00:00:00Z', initializedFromHashTree: true});
3809
+ locusInfo.hashTreeParsers.set(locusUrlB, {parser: parserB, initializedFromHashTree: true});
3810
+
3811
+ const locus = createLocusWithReplaces(locusUrlA, locusUrlB, '2026-02-01T00:00:00Z');
3812
+
3813
+ locusInfo.handleLocusAPIResponse(mockMeeting, {locus});
3814
+
3815
+ assert.calledOnce(parserA.resumeFromApiResponse);
3816
+ assert.calledWithExactly(parserA.resumeFromApiResponse, locus);
3817
+ assert.calledOnce(parserB.stop);
3818
+ assert.equal(locusInfo.hashTreeParsers.get(locusUrlB).replacedAt, '2026-02-01T00:00:00Z');
3819
+ assert.isFalse(locusInfo.hashTreeParsers.get(locusUrlA).initializedFromHashTree);
3820
+ });
3821
+
3822
+ it('should not reactivate a stopped parser when replaces info is not newer', () => {
3823
+ const parserA = createMockApiParser('stopped');
3824
+ const parserB = createMockApiParser('active');
3825
+ locusInfo.hashTreeParsers.set(locusUrlA, {parser: parserA, replacedAt: '2026-03-01T00:00:00Z', initializedFromHashTree: true});
3826
+ locusInfo.hashTreeParsers.set(locusUrlB, {parser: parserB, initializedFromHashTree: true});
3827
+
3828
+ const locus = createLocusWithReplaces(locusUrlA, locusUrlB, '2026-01-01T00:00:00Z');
3829
+
3830
+ locusInfo.handleLocusAPIResponse(mockMeeting, {locus});
3831
+
3832
+ assert.notCalled(parserA.resumeFromApiResponse);
3833
+ assert.notCalled(parserB.stop);
3834
+ });
3835
+
3836
+ it('should not reactivate a stopped parser when no replaces info is available', () => {
3837
+ const parserA = createMockApiParser('stopped');
3838
+ locusInfo.hashTreeParsers.set(locusUrlA, {parser: parserA, initializedFromHashTree: true});
3839
+
3840
+ const locus = createLocusWithoutReplaces(locusUrlA);
3841
+
3842
+ locusInfo.handleLocusAPIResponse(mockMeeting, {locus});
3843
+
3844
+ assert.notCalled(parserA.resumeFromApiResponse);
3845
+ });
3846
+ });
3847
+ });
3848
+
3849
+ describe('#syncAllHashTreeDatasets', () => {
3850
+ it('should call syncAllDatasets on each parser that has an entry', async () => {
3851
+ const parser1 = {syncAllDatasets: sinon.stub().resolves()};
3852
+ const parser2 = {syncAllDatasets: sinon.stub().resolves()};
3853
+ locusInfo.hashTreeParsers.set('url1', {parser: parser1});
3854
+ locusInfo.hashTreeParsers.set('url2', {parser: parser2});
3855
+
3856
+ await locusInfo.syncAllHashTreeDatasets();
3857
+
3858
+ assert.calledOnce(parser1.syncAllDatasets);
3859
+ assert.calledOnce(parser2.syncAllDatasets);
3860
+ });
3861
+
3862
+ it('should skip parser entries without a parser object', async () => {
3863
+ const parser1 = {syncAllDatasets: sinon.stub().resolves()};
3864
+ locusInfo.hashTreeParsers.set('url1', {parser: parser1});
3865
+ locusInfo.hashTreeParsers.set('url2', {parser: undefined});
3866
+
3867
+ await locusInfo.syncAllHashTreeDatasets();
3868
+
3869
+ assert.calledOnce(parser1.syncAllDatasets);
3870
+ });
3871
+
3872
+ it('should forward options to each parser syncAllDatasets', async () => {
3873
+ const parser1 = {syncAllDatasets: sinon.stub().resolves()};
3874
+ const parser2 = {syncAllDatasets: sinon.stub().resolves()};
3875
+ locusInfo.hashTreeParsers.set('url1', {parser: parser1});
3876
+ locusInfo.hashTreeParsers.set('url2', {parser: parser2});
3877
+
3878
+ await locusInfo.syncAllHashTreeDatasets({onlyLLM: true});
3879
+
3880
+ assert.calledOnceWithExactly(parser1.syncAllDatasets, {onlyLLM: true});
3881
+ assert.calledOnceWithExactly(parser2.syncAllDatasets, {onlyLLM: true});
3882
+ });
3883
+
3884
+ it('should await each parsers syncAllDatasets sequentially', async () => {
3885
+ const callOrder = [];
3886
+ const parser1 = {syncAllDatasets: sinon.stub().callsFake(() => {
3887
+ callOrder.push('start1');
3888
+ return new Promise((resolve) => {
3889
+ setTimeout(() => {
3890
+ callOrder.push('end1');
3891
+ resolve();
3892
+ }, 100);
3893
+ });
3894
+ })};
3895
+ const parser2 = {syncAllDatasets: sinon.stub().callsFake(() => {
3896
+ callOrder.push('start2');
3897
+ return Promise.resolve();
3898
+ })};
3899
+ locusInfo.hashTreeParsers.set('url1', {parser: parser1});
3900
+ locusInfo.hashTreeParsers.set('url2', {parser: parser2});
3901
+
3902
+ const clock = sinon.useFakeTimers();
3903
+ const promise = locusInfo.syncAllHashTreeDatasets();
3904
+ // parser1 started but parser2 not yet
3905
+ assert.deepEqual(callOrder, ['start1']);
3906
+
3907
+ await clock.tickAsync(100);
3908
+ await promise;
3909
+ // parser1 finished, then parser2 started and finished
3910
+ assert.deepEqual(callOrder, ['start1', 'end1', 'start2']);
3911
+ clock.restore();
3433
3912
  });
3434
3913
  });
3435
3914
 
@@ -3521,49 +4000,23 @@ describe('plugin-meetings', () => {
3521
4000
  assert.deepEqual(callOrder, ['updateLocusUrl', 'updateMeetingInfo']);
3522
4001
  });
3523
4002
 
3524
- it('#updateLocusInfo ignores breakout LEFT message', () => {
3525
- const newLocus = {
3526
- self: {
3527
- reason: 'MOVED',
3528
- state: 'LEFT',
3529
- },
3530
- };
4003
+ it('#updateLocusInfo ignores locus when isSelfMovedOrBreakoutEnded returns true', () => {
4004
+ const newLocus = {self: {state: 'JOINED'}};
4005
+
4006
+ sinon.stub(MeetingsUtil, 'isSelfMovedOrBreakoutEnded').returns(true);
3531
4007
 
3532
4008
  locusInfo.updateControls = sinon.stub();
3533
- locusInfo.updateConversationUrl = sinon.stub();
3534
- locusInfo.updateCreated = sinon.stub();
3535
4009
  locusInfo.updateFullState = sinon.stub();
3536
- locusInfo.updateHostInfo = sinon.stub();
3537
- locusInfo.updateMeetingInfo = sinon.stub();
3538
- locusInfo.updateMediaShares = sinon.stub();
3539
- locusInfo.updateReplaces = sinon.stub();
3540
4010
  locusInfo.updateSelf = sinon.stub();
3541
- locusInfo.updateLocusUrl = sinon.stub();
3542
- locusInfo.updateAclUrl = sinon.stub();
3543
- locusInfo.updateBasequence = sinon.stub();
3544
- locusInfo.updateSequence = sinon.stub();
3545
- locusInfo.updateEmbeddedApps = sinon.stub();
3546
- locusInfo.updateLinks = sinon.stub();
3547
- locusInfo.compareAndUpdate = sinon.stub();
3548
4011
 
3549
4012
  locusInfo.updateLocusInfo(newLocus);
3550
4013
 
4014
+ assert.calledOnceWithExactly(MeetingsUtil.isSelfMovedOrBreakoutEnded, newLocus);
3551
4015
  assert.notCalled(locusInfo.updateControls);
3552
- assert.notCalled(locusInfo.updateConversationUrl);
3553
- assert.notCalled(locusInfo.updateCreated);
3554
4016
  assert.notCalled(locusInfo.updateFullState);
3555
- assert.notCalled(locusInfo.updateHostInfo);
3556
- assert.notCalled(locusInfo.updateMeetingInfo);
3557
- assert.notCalled(locusInfo.updateMediaShares);
3558
- assert.notCalled(locusInfo.updateReplaces);
3559
4017
  assert.notCalled(locusInfo.updateSelf);
3560
- assert.notCalled(locusInfo.updateLocusUrl);
3561
- assert.notCalled(locusInfo.updateAclUrl);
3562
- assert.notCalled(locusInfo.updateBasequence);
3563
- assert.notCalled(locusInfo.updateSequence);
3564
- assert.notCalled(locusInfo.updateEmbeddedApps);
3565
- assert.notCalled(locusInfo.updateLinks);
3566
- assert.notCalled(locusInfo.compareAndUpdate);
4018
+
4019
+ MeetingsUtil.isSelfMovedOrBreakoutEnded.restore();
3567
4020
  });
3568
4021
 
3569
4022
  it('#updateLocusInfo puts the Locus DTO top level properties at the right place in LocusInfo class', () => {
@@ -4480,6 +4933,9 @@ describe('plugin-meetings', () => {
4480
4933
  });
4481
4934
 
4482
4935
  describe('#isMeetingActive', () => {
4936
+ beforeEach(() => {
4937
+ webex.internal.newMetrics.submitClientEvent.resetHistory();
4938
+ });
4483
4939
  forEach([_CALL_, _SIP_BRIDGE_, _SPACE_SHARE_], (type) => {
4484
4940
  describe(`type = ${type}`, () => {
4485
4941
  it('sends client event correctly for state = inactive', () => {
@@ -4500,6 +4956,11 @@ describe('plugin-meetings', () => {
4500
4956
  options: {
4501
4957
  meetingId: locusInfo.meetingId,
4502
4958
  },
4959
+ payload: {
4960
+ eventData: {
4961
+ joinInProgress: false,
4962
+ },
4963
+ },
4503
4964
  });
4504
4965
  });
4505
4966
 
@@ -4520,6 +4981,11 @@ describe('plugin-meetings', () => {
4520
4981
  options: {
4521
4982
  meetingId: locusInfo.meetingId,
4522
4983
  },
4984
+ payload: {
4985
+ eventData: {
4986
+ joinInProgress: false,
4987
+ },
4988
+ },
4523
4989
  });
4524
4990
  });
4525
4991
 
@@ -4541,12 +5007,17 @@ describe('plugin-meetings', () => {
4541
5007
  options: {
4542
5008
  meetingId: locusInfo.meetingId,
4543
5009
  },
5010
+ payload: {
5011
+ eventData: {
5012
+ joinInProgress: false,
5013
+ },
5014
+ },
4544
5015
  });
4545
5016
  });
4546
5017
  });
4547
5018
  });
4548
5019
 
4549
- it('sends client event correctly for state = MEETING_INACTIVE_TERMINATING', () => {
5020
+ it('sends client event correctly for state = MEETING_INACTIVE', () => {
4550
5021
  locusInfo.getLocusPartner = sinon.stub().returns({state: MEETING_STATE.STATES.LEFT});
4551
5022
  locusInfo.parsedLocus = {
4552
5023
  fullState: {
@@ -4568,7 +5039,7 @@ describe('plugin-meetings', () => {
4568
5039
  });
4569
5040
  });
4570
5041
 
4571
- it('sends client event correctly for state = FULLSTATE_REMOVED', () => {
5042
+ it('does not send client event when state = INACTIVE and endMeetingReason = BREAKOUT_ENDED', () => {
4572
5043
  locusInfo.getLocusPartner = sinon.stub().returns({state: MEETING_STATE.STATES.LEFT});
4573
5044
  locusInfo.parsedLocus = {
4574
5045
  fullState: {
@@ -4577,16 +5048,127 @@ describe('plugin-meetings', () => {
4577
5048
  };
4578
5049
 
4579
5050
  locusInfo.fullState = {
4580
- removed: true,
5051
+ state: LOCUS.STATE.INACTIVE,
5052
+ endMeetingReason: 'BREAKOUT_ENDED',
4581
5053
  };
4582
5054
 
4583
5055
  locusInfo.isMeetingActive();
4584
5056
 
4585
- assert.calledWith(webex.internal.newMetrics.submitClientEvent, {
4586
- name: 'client.call.remote-ended',
4587
- options: {
4588
- meetingId: locusInfo.meetingId,
5057
+ assert.notCalled(webex.internal.newMetrics.submitClientEvent);
5058
+ });
5059
+
5060
+ it('sends client event correctly for state self removed', () => {
5061
+ locusInfo.emitScoped = sinon.stub();
5062
+ locusInfo.parsedLocus = {
5063
+ fullState: {
5064
+ type: _MEETING_,
4589
5065
  },
5066
+ self: {
5067
+ removed: true,
5068
+ }
5069
+ };
5070
+
5071
+ locusInfo.isMeetingActive();
5072
+
5073
+ assert.notCalled(webex.internal.newMetrics.submitClientEvent);
5074
+ assert.calledOnceWithExactly(
5075
+ locusInfo.emitScoped,
5076
+ {
5077
+ file: 'locus-info',
5078
+ function: 'isMeetingActive',
5079
+ },
5080
+ EVENTS.DESTROY_MEETING,
5081
+ {
5082
+ reason: MEETING_REMOVED_REASON.SELF_REMOVED,
5083
+ shouldLeave: false,
5084
+ }
5085
+ );
5086
+ });
5087
+
5088
+ describe('destroyMeetingSuspended', () => {
5089
+ it('suppresses DESTROY_MEETING for SELF_REMOVED when suspended', () => {
5090
+ locusInfo.emitScoped = sinon.stub();
5091
+ locusInfo.suspendDestroyMeeting(true);
5092
+ locusInfo.parsedLocus = {
5093
+ fullState: {
5094
+ type: _MEETING_,
5095
+ },
5096
+ self: {
5097
+ removed: true,
5098
+ }
5099
+ };
5100
+
5101
+ locusInfo.isMeetingActive();
5102
+
5103
+ assert.notCalled(locusInfo.emitScoped);
5104
+ assert.calledOnceWithExactly(
5105
+ sendBehavioralMetricStub,
5106
+ BEHAVIORAL_METRICS.DESTROY_MEETING_WHILE_SUSPENDED,
5107
+ {
5108
+ meetingId: locusInfo.meetingId,
5109
+ reason: 'SELF_REMOVED',
5110
+ }
5111
+ );
5112
+ });
5113
+
5114
+ it('suppresses DESTROY_MEETING for MEETING_INACTIVE_TERMINATING when suspended', () => {
5115
+ locusInfo.emitScoped = sinon.stub();
5116
+ locusInfo.suspendDestroyMeeting(true);
5117
+ locusInfo.parsedLocus = {
5118
+ fullState: {
5119
+ type: _MEETING_,
5120
+ },
5121
+ };
5122
+ locusInfo.fullState = {
5123
+ state: LOCUS.STATE.INACTIVE,
5124
+ };
5125
+
5126
+ locusInfo.isMeetingActive();
5127
+
5128
+ assert.notCalled(locusInfo.emitScoped);
5129
+ assert.notCalled(webex.internal.newMetrics.submitClientEvent);
5130
+ assert.calledOnceWithExactly(
5131
+ sendBehavioralMetricStub,
5132
+ BEHAVIORAL_METRICS.DESTROY_MEETING_WHILE_SUSPENDED,
5133
+ {
5134
+ meetingId: locusInfo.meetingId,
5135
+ reason: 'MEETING_INACTIVE_TERMINATING',
5136
+ }
5137
+ );
5138
+ });
5139
+
5140
+ [
5141
+ {reason: 'CALL_INACTIVE', setup: () => {
5142
+ locusInfo.parsedLocus = {fullState: {type: _CALL_}};
5143
+ locusInfo.fullState = {state: LOCUS.STATE.INACTIVE};
5144
+ }},
5145
+ {reason: 'PARTNER_LEFT', setup: () => {
5146
+ locusInfo.getLocusPartner = sinon.stub().returns({state: MEETING_STATE.STATES.LEFT});
5147
+ locusInfo.parsedLocus = {fullState: {type: _CALL_}, self: {state: MEETING_STATE.STATES.JOINED}};
5148
+ }},
5149
+ {reason: 'SELF_LEFT', setup: () => {
5150
+ locusInfo.getLocusPartner = sinon.stub().returns({state: MEETING_STATE.STATES.LEFT});
5151
+ locusInfo.parsedLocus = {fullState: {type: _CALL_}, self: {state: MEETING_STATE.STATES.LEFT}};
5152
+ }},
5153
+ ].forEach(({reason, setup}) => {
5154
+ it(`sends joinInProgress=true in client event for ${reason} when suspended`, () => {
5155
+ locusInfo.suspendDestroyMeeting(true);
5156
+ setup();
5157
+
5158
+ locusInfo.isMeetingActive();
5159
+
5160
+ assert.calledWith(webex.internal.newMetrics.submitClientEvent, {
5161
+ name: 'client.call.remote-ended',
5162
+ options: {
5163
+ meetingId: locusInfo.meetingId,
5164
+ },
5165
+ payload: {
5166
+ eventData: {
5167
+ joinInProgress: true,
5168
+ },
5169
+ },
5170
+ });
5171
+ });
4590
5172
  });
4591
5173
  });
4592
5174
  });
@@ -4979,6 +5561,31 @@ describe('plugin-meetings', () => {
4979
5561
  );
4980
5562
  assert.notCalled(getTheLocusToUpdateStub);
4981
5563
  });
5564
+
5565
+ it('should call handleLocusAPIResponse for SDK_LOCUS_FROM_SYNC_MEETINGS when hash tree parsers exist', () => {
5566
+ const fakeLocusUrl = 'http://locus-url.com';
5567
+ const fakeLocus = {url: fakeLocusUrl, fullState: {state: 'ACTIVE'}};
5568
+ const mockHashTreeParser = {
5569
+ handleMessage: sinon.stub(),
5570
+ handleLocusUpdate: sinon.stub(),
5571
+ };
5572
+ locusInfo.hashTreeParsers.set(fakeLocusUrl, {
5573
+ parser: mockHashTreeParser,
5574
+ initializedFromHashTree: true,
5575
+ });
5576
+
5577
+ sinon.stub(locusInfo, 'handleLocusDelta');
5578
+
5579
+ locusInfo.parse(mockMeeting, {
5580
+ eventType: LOCUSEVENT.SDK_LOCUS_FROM_SYNC_MEETINGS,
5581
+ locus: fakeLocus,
5582
+ });
5583
+
5584
+ // should route through handleLocusAPIResponse which passes unwrapped LocusDTO to parser
5585
+ assert.calledOnce(mockHashTreeParser.handleLocusUpdate);
5586
+ assert.notCalled(mockHashTreeParser.handleMessage);
5587
+ assert.notCalled(locusInfo.handleLocusDelta);
5588
+ });
4982
5589
  });
4983
5590
  });
4984
5591
 
@@ -5171,6 +5778,7 @@ describe('plugin-meetings', () => {
5171
5778
  return {
5172
5779
  htMeta: {elementId: {type: 'Self'}},
5173
5780
  data: {
5781
+ deviceUrl,
5174
5782
  devices,
5175
5783
  },
5176
5784
  };