@webex/plugin-meetings 3.12.0-next.19 → 3.12.0-next.190

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 (312) hide show
  1. package/.sdd/manifest.json +1312 -0
  2. package/.sdd/templates/.source.json +30 -0
  3. package/.sdd/templates/component-repo/module-docs/module-spec-quality.md +111 -0
  4. package/.sdd/templates/component-repo/module-docs/module-spec.template.md +321 -0
  5. package/.sdd/templates/component-repo/reference-docs/adr/_adr-example.md +59 -0
  6. package/.sdd/templates/component-repo/reference-docs/patterns/_pattern-example.md +49 -0
  7. package/.sdd/templates/component-repo/reference-docs/rules/_rule-example.md +42 -0
  8. package/.sdd/templates/component-repo/standing-docs/AGENTS.template.md +120 -0
  9. package/.sdd/templates/component-repo/standing-docs/ARCHITECTURE.template.md +206 -0
  10. package/.sdd/templates/component-repo/standing-docs/CONTRACTS.template.md +90 -0
  11. package/.sdd/templates/component-repo/standing-docs/DATA_MODEL.template.md +68 -0
  12. package/.sdd/templates/component-repo/standing-docs/GETTING_STARTED.template.md +111 -0
  13. package/.sdd/templates/component-repo/standing-docs/GLOSSARY.template.md +57 -0
  14. package/.sdd/templates/component-repo/standing-docs/REVIEW_CHECKLIST.template.md +69 -0
  15. package/.sdd/templates/component-repo/standing-docs/RULES.template.md +96 -0
  16. package/.sdd/templates/component-repo/standing-docs/SECURITY.template.md +84 -0
  17. package/.sdd/templates/component-repo/standing-docs/SERVICE_STATE.template.md +82 -0
  18. package/.sdd/templates/component-repo/standing-docs/SPEC_INDEX.template.md +94 -0
  19. package/.sdd/templates/component-repo/standing-docs/TEST_INDEX.template.md +64 -0
  20. package/.sdd/templates/component-repo/template-map.json +112 -0
  21. package/AGENTS.md +135 -0
  22. package/ai-docs/ARCHITECTURE.md +208 -0
  23. package/ai-docs/CONTRACTS.md +267 -0
  24. package/ai-docs/DATA_MODEL.md +64 -0
  25. package/ai-docs/GETTING_STARTED.md +73 -0
  26. package/ai-docs/GLOSSARY.md +56 -0
  27. package/ai-docs/REVIEW_CHECKLIST.md +45 -0
  28. package/ai-docs/RULES.md +79 -0
  29. package/ai-docs/SECURITY.md +74 -0
  30. package/ai-docs/SERVICE_STATE.md +59 -0
  31. package/ai-docs/SPEC_INDEX.md +85 -0
  32. package/ai-docs/TEST_INDEX.md +45 -0
  33. package/ai-docs/adr/0001-migrate-existing-docs-into-sdd.md +61 -0
  34. package/ai-docs/patterns/defensive-error-propagation.md +55 -0
  35. package/ai-docs/patterns/event-scope-emission.md +46 -0
  36. package/ai-docs/patterns/source-to-test-path-mirroring.md +45 -0
  37. package/ai-docs/patterns/stateless-plugin-request-classes.md +53 -0
  38. package/ai-docs/patterns/typed-constants-and-enum-values.md +47 -0
  39. package/assets/README.md +28 -0
  40. package/assets/e2ee-0.0.1.js +2 -0
  41. package/assets/e2ee-0.0.1.wasm +0 -0
  42. package/dist/aiEnableRequest/index.js +15 -2
  43. package/dist/aiEnableRequest/index.js.map +1 -1
  44. package/dist/annotation/index.js +55 -19
  45. package/dist/annotation/index.js.map +1 -1
  46. package/dist/assets/e2ee-0.0.1.js +2 -0
  47. package/dist/assets/e2ee-0.0.1.wasm +0 -0
  48. package/dist/breakouts/breakout.js +8 -3
  49. package/dist/breakouts/breakout.js.map +1 -1
  50. package/dist/breakouts/events.js +29 -14
  51. package/dist/breakouts/events.js.map +1 -1
  52. package/dist/breakouts/index.js +128 -7
  53. package/dist/breakouts/index.js.map +1 -1
  54. package/dist/common/errors/webex-errors.js +54 -5
  55. package/dist/common/errors/webex-errors.js.map +1 -1
  56. package/dist/config.js +3 -2
  57. package/dist/config.js.map +1 -1
  58. package/dist/constants.js +39 -11
  59. package/dist/constants.js.map +1 -1
  60. package/dist/controls-options-manager/index.js +46 -10
  61. package/dist/controls-options-manager/index.js.map +1 -1
  62. package/dist/hashTree/constants.js +4 -1
  63. package/dist/hashTree/constants.js.map +1 -1
  64. package/dist/hashTree/hashTreeParser.js +1096 -391
  65. package/dist/hashTree/hashTreeParser.js.map +1 -1
  66. package/dist/hashTree/utils.js +20 -0
  67. package/dist/hashTree/utils.js.map +1 -1
  68. package/dist/index.js +8 -0
  69. package/dist/index.js.map +1 -1
  70. package/dist/interceptors/dataChannelAuthToken.js +58 -16
  71. package/dist/interceptors/dataChannelAuthToken.js.map +1 -1
  72. package/dist/interceptors/locusRetry.js +24 -9
  73. package/dist/interceptors/locusRetry.js.map +1 -1
  74. package/dist/interpretation/index.js +55 -12
  75. package/dist/interpretation/index.js.map +1 -1
  76. package/dist/interpretation/interpretation.types.js +7 -0
  77. package/dist/interpretation/interpretation.types.js.map +1 -0
  78. package/dist/interpretation/siLanguage.js +1 -1
  79. package/dist/locus-info/controlsUtils.js +4 -1
  80. package/dist/locus-info/controlsUtils.js.map +1 -1
  81. package/dist/locus-info/index.js +615 -176
  82. package/dist/locus-info/index.js.map +1 -1
  83. package/dist/locus-info/infoUtils.js +36 -5
  84. package/dist/locus-info/infoUtils.js.map +1 -1
  85. package/dist/locus-info/types.js +20 -0
  86. package/dist/locus-info/types.js.map +1 -1
  87. package/dist/media/MediaConnectionAwaiter.js +229 -166
  88. package/dist/media/MediaConnectionAwaiter.js.map +1 -1
  89. package/dist/media/index.js +8 -2
  90. package/dist/media/index.js.map +1 -1
  91. package/dist/media/properties.js +4 -5
  92. package/dist/media/properties.js.map +1 -1
  93. package/dist/meeting/in-meeting-actions.js +5 -1
  94. package/dist/meeting/in-meeting-actions.js.map +1 -1
  95. package/dist/meeting/index.js +1850 -961
  96. package/dist/meeting/index.js.map +1 -1
  97. package/dist/meeting/locusMediaRequest.js +229 -82
  98. package/dist/meeting/locusMediaRequest.js.map +1 -1
  99. package/dist/meeting/muteState.js +10 -1
  100. package/dist/meeting/muteState.js.map +1 -1
  101. package/dist/meeting/request.js +5 -2
  102. package/dist/meeting/request.js.map +1 -1
  103. package/dist/meeting/util.js +42 -4
  104. package/dist/meeting/util.js.map +1 -1
  105. package/dist/meeting/voicea-meeting.js +2 -1
  106. package/dist/meeting/voicea-meeting.js.map +1 -1
  107. package/dist/meeting-info/meeting-info-v2.js +12 -5
  108. package/dist/meeting-info/meeting-info-v2.js.map +1 -1
  109. package/dist/meetings/index.js +304 -129
  110. package/dist/meetings/index.js.map +1 -1
  111. package/dist/meetings/meetings.types.js +6 -1
  112. package/dist/meetings/meetings.types.js.map +1 -1
  113. package/dist/meetings/request.js +39 -0
  114. package/dist/meetings/request.js.map +1 -1
  115. package/dist/meetings/util.js +116 -18
  116. package/dist/meetings/util.js.map +1 -1
  117. package/dist/member/index.js +10 -0
  118. package/dist/member/index.js.map +1 -1
  119. package/dist/member/types.js.map +1 -1
  120. package/dist/member/util.js +30 -0
  121. package/dist/member/util.js.map +1 -1
  122. package/dist/members/index.js +101 -43
  123. package/dist/members/index.js.map +1 -1
  124. package/dist/members/util.js +8 -1
  125. package/dist/members/util.js.map +1 -1
  126. package/dist/metrics/constants.js +7 -1
  127. package/dist/metrics/constants.js.map +1 -1
  128. package/dist/multistream/codec/constants.js +63 -0
  129. package/dist/multistream/codec/constants.js.map +1 -0
  130. package/dist/multistream/mediaRequestManager.js +62 -15
  131. package/dist/multistream/mediaRequestManager.js.map +1 -1
  132. package/dist/multistream/receiveSlot.js +9 -0
  133. package/dist/multistream/receiveSlot.js.map +1 -1
  134. package/dist/multistream/remoteMediaManager.js +32 -4
  135. package/dist/multistream/remoteMediaManager.js.map +1 -1
  136. package/dist/multistream/sendSlotManager.js +11 -1
  137. package/dist/multistream/sendSlotManager.js.map +1 -1
  138. package/dist/reachability/clusterReachability.js.map +1 -1
  139. package/dist/reachability/index.js +121 -83
  140. package/dist/reachability/index.js.map +1 -1
  141. package/dist/reachability/reachability.types.js +2 -0
  142. package/dist/reachability/reachability.types.js.map +1 -1
  143. package/dist/reachability/util.js +45 -0
  144. package/dist/reachability/util.js.map +1 -1
  145. package/dist/reactions/reactions.type.js.map +1 -1
  146. package/dist/recording-controller/index.js +1 -3
  147. package/dist/recording-controller/index.js.map +1 -1
  148. package/dist/roap/turnDiscovery.js +8 -1
  149. package/dist/roap/turnDiscovery.js.map +1 -1
  150. package/dist/types/annotation/index.d.ts +19 -0
  151. package/dist/types/common/errors/webex-errors.d.ts +36 -2
  152. package/dist/types/config.d.ts +3 -2
  153. package/dist/types/constants.d.ts +15 -2
  154. package/dist/types/controls-options-manager/index.d.ts +16 -0
  155. package/dist/types/hashTree/constants.d.ts +1 -0
  156. package/dist/types/hashTree/hashTreeParser.d.ts +201 -22
  157. package/dist/types/hashTree/utils.d.ts +7 -0
  158. package/dist/types/index.d.ts +4 -0
  159. package/dist/types/interceptors/locusRetry.d.ts +4 -4
  160. package/dist/types/interpretation/interpretation.types.d.ts +10 -0
  161. package/dist/types/locus-info/index.d.ts +106 -8
  162. package/dist/types/locus-info/infoUtils.d.ts +8 -0
  163. package/dist/types/locus-info/types.d.ts +22 -1
  164. package/dist/types/media/MediaConnectionAwaiter.d.ts +66 -49
  165. package/dist/types/media/properties.d.ts +6 -2
  166. package/dist/types/meeting/in-meeting-actions.d.ts +4 -0
  167. package/dist/types/meeting/index.d.ts +217 -16
  168. package/dist/types/meeting/locusMediaRequest.d.ts +12 -0
  169. package/dist/types/meeting/request.d.ts +1 -0
  170. package/dist/types/meeting/util.d.ts +12 -1
  171. package/dist/types/meeting-info/meeting-info-v2.d.ts +1 -0
  172. package/dist/types/meetings/index.d.ts +40 -19
  173. package/dist/types/meetings/meetings.types.d.ts +15 -0
  174. package/dist/types/meetings/request.d.ts +14 -0
  175. package/dist/types/member/index.d.ts +1 -0
  176. package/dist/types/member/types.d.ts +1 -0
  177. package/dist/types/member/util.d.ts +9 -0
  178. package/dist/types/members/index.d.ts +15 -2
  179. package/dist/types/members/util.d.ts +1 -5
  180. package/dist/types/metrics/constants.d.ts +6 -0
  181. package/dist/types/multistream/codec/constants.d.ts +7 -0
  182. package/dist/types/multistream/mediaRequestManager.d.ts +22 -5
  183. package/dist/types/multistream/remoteMediaManager.d.ts +18 -0
  184. package/dist/types/multistream/sendSlotManager.d.ts +5 -1
  185. package/dist/types/reachability/clusterReachability.d.ts +3 -3
  186. package/dist/types/reachability/index.d.ts +10 -3
  187. package/dist/types/reachability/reachability.types.d.ts +7 -0
  188. package/dist/types/reachability/util.d.ts +17 -0
  189. package/dist/types/reactions/reactions.type.d.ts +3 -0
  190. package/dist/webinar/index.js +441 -252
  191. package/dist/webinar/index.js.map +1 -1
  192. package/package.json +26 -24
  193. package/src/aiEnableRequest/ai-docs/ai-enable-request-spec.md +223 -0
  194. package/src/aiEnableRequest/index.ts +16 -0
  195. package/src/annotation/ai-docs/annotation-spec.md +236 -0
  196. package/src/annotation/index.ts +61 -29
  197. package/src/breakouts/ai-docs/breakouts-spec.md +324 -0
  198. package/src/breakouts/breakout.ts +3 -1
  199. package/src/breakouts/events.ts +33 -11
  200. package/src/breakouts/index.ts +145 -3
  201. package/src/common/errors/webex-errors.ts +56 -3
  202. package/src/config.ts +7 -3
  203. package/src/constants.ts +23 -4
  204. package/src/controls-options-manager/ai-docs/controls-options-manager-spec.md +243 -0
  205. package/src/controls-options-manager/index.ts +62 -10
  206. package/src/hashTree/ai-docs/hash-tree-spec.md +267 -0
  207. package/src/hashTree/constants.ts +7 -0
  208. package/src/hashTree/hashTreeParser.ts +861 -193
  209. package/src/hashTree/utils.ts +19 -0
  210. package/src/index.ts +7 -0
  211. package/src/interceptors/ai-docs/interceptors-spec.md +247 -0
  212. package/src/interceptors/dataChannelAuthToken.ts +59 -12
  213. package/src/interceptors/locusRetry.ts +26 -5
  214. package/src/interpretation/ai-docs/interpretation-spec.md +256 -0
  215. package/src/interpretation/index.ts +65 -10
  216. package/src/interpretation/interpretation.types.ts +11 -0
  217. package/src/locus-info/ai-docs/locus-info-spec.md +293 -0
  218. package/src/locus-info/controlsUtils.ts +3 -1
  219. package/src/locus-info/index.ts +566 -164
  220. package/src/locus-info/infoUtils.ts +41 -6
  221. package/src/locus-info/types.ts +26 -1
  222. package/src/media/MediaConnectionAwaiter.ts +229 -196
  223. package/src/media/ai-docs/media-spec.md +267 -0
  224. package/src/media/index.ts +10 -1
  225. package/src/media/properties.ts +8 -3
  226. package/src/meeting/ai-docs/meeting-spec.md +404 -0
  227. package/src/meeting/in-meeting-actions.ts +8 -0
  228. package/src/meeting/index.ts +1093 -251
  229. package/src/meeting/locusMediaRequest.ts +106 -6
  230. package/src/meeting/muteState.ts +10 -1
  231. package/src/meeting/request.ts +11 -0
  232. package/src/meeting/util.ts +53 -9
  233. package/src/meeting/voicea-meeting.ts +1 -1
  234. package/src/meeting-info/ai-docs/meeting-info-spec.md +261 -0
  235. package/src/meeting-info/meeting-info-v2.ts +11 -4
  236. package/src/meetings/ai-docs/meetings-spec.md +296 -0
  237. package/src/meetings/index.ts +202 -81
  238. package/src/meetings/meetings.types.ts +19 -0
  239. package/src/meetings/request.ts +43 -0
  240. package/src/meetings/util.ts +117 -4
  241. package/src/member/ai-docs/member-spec.md +196 -0
  242. package/src/member/index.ts +10 -0
  243. package/src/member/types.ts +1 -0
  244. package/src/member/util.ts +29 -0
  245. package/src/members/ai-docs/members-spec.md +256 -0
  246. package/src/members/index.ts +70 -7
  247. package/src/members/util.ts +12 -4
  248. package/src/metrics/ai-docs/metrics-spec.md +185 -0
  249. package/src/metrics/constants.ts +6 -0
  250. package/src/multistream/ai-docs/multistream-spec.md +295 -0
  251. package/src/multistream/codec/constants.ts +58 -0
  252. package/src/multistream/mediaRequestManager.ts +119 -28
  253. package/src/multistream/receiveSlot.ts +18 -0
  254. package/src/multistream/remoteMediaManager.ts +23 -1
  255. package/src/multistream/sendSlotManager.ts +15 -1
  256. package/src/personal-meeting-room/ai-docs/personal-meeting-room-spec.md +234 -0
  257. package/src/reachability/ai-docs/reachability-spec.md +261 -0
  258. package/src/reachability/clusterReachability.ts +3 -2
  259. package/src/reachability/index.ts +47 -16
  260. package/src/reachability/reachability.types.ts +11 -0
  261. package/src/reachability/util.ts +36 -0
  262. package/src/reactions/ai-docs/reactions-spec.md +198 -0
  263. package/src/reactions/reactions.type.ts +3 -0
  264. package/src/reconnection-manager/ai-docs/reconnection-manager-spec.md +272 -0
  265. package/src/recording-controller/ai-docs/recording-controller-spec.md +223 -0
  266. package/src/recording-controller/index.ts +1 -2
  267. package/src/roap/ai-docs/roap-spec.md +241 -0
  268. package/src/roap/turnDiscovery.ts +9 -1
  269. package/src/webinar/ai-docs/webinar-spec.md +243 -0
  270. package/src/webinar/index.ts +247 -89
  271. package/test/unit/spec/aiEnableRequest/index.ts +86 -0
  272. package/test/unit/spec/annotation/index.ts +214 -182
  273. package/test/unit/spec/breakouts/breakout.ts +9 -3
  274. package/test/unit/spec/breakouts/events.ts +120 -2
  275. package/test/unit/spec/breakouts/index.ts +336 -15
  276. package/test/unit/spec/common/errors/webex-errors.ts +78 -0
  277. package/test/unit/spec/controls-options-manager/index.js +139 -32
  278. package/test/unit/spec/hashTree/hashTreeParser.ts +2360 -239
  279. package/test/unit/spec/hashTree/utils.ts +37 -0
  280. package/test/unit/spec/interceptors/dataChannelAuthToken.ts +179 -1
  281. package/test/unit/spec/interceptors/locusRetry.ts +234 -5
  282. package/test/unit/spec/interpretation/index.ts +119 -4
  283. package/test/unit/spec/locus-info/controlsUtils.js +172 -57
  284. package/test/unit/spec/locus-info/index.js +1014 -58
  285. package/test/unit/spec/locus-info/infoUtils.js +184 -1
  286. package/test/unit/spec/media/MediaConnectionAwaiter.ts +479 -17
  287. package/test/unit/spec/media/index.ts +92 -0
  288. package/test/unit/spec/media/properties.ts +26 -26
  289. package/test/unit/spec/meeting/in-meeting-actions.ts +4 -0
  290. package/test/unit/spec/meeting/index.js +3601 -536
  291. package/test/unit/spec/meeting/locusMediaRequest.ts +406 -4
  292. package/test/unit/spec/meeting/muteState.js +81 -0
  293. package/test/unit/spec/meeting/request.js +12 -0
  294. package/test/unit/spec/meeting/utils.js +205 -19
  295. package/test/unit/spec/meeting/voicea-meeting.ts +85 -1
  296. package/test/unit/spec/meeting-info/meetinginfov2.js +88 -11
  297. package/test/unit/spec/meetings/index.js +549 -49
  298. package/test/unit/spec/meetings/request.js +141 -0
  299. package/test/unit/spec/meetings/utils.js +402 -51
  300. package/test/unit/spec/member/index.js +7 -0
  301. package/test/unit/spec/member/util.js +89 -0
  302. package/test/unit/spec/members/index.js +216 -0
  303. package/test/unit/spec/members/request.js +37 -1
  304. package/test/unit/spec/members/utils.js +63 -0
  305. package/test/unit/spec/multistream/mediaRequestManager.ts +501 -37
  306. package/test/unit/spec/multistream/remoteMediaManager.ts +46 -0
  307. package/test/unit/spec/multistream/sendSlotManager.ts +30 -2
  308. package/test/unit/spec/reachability/index.ts +128 -46
  309. package/test/unit/spec/reachability/util.ts +31 -0
  310. package/test/unit/spec/recording-controller/index.js +9 -8
  311. package/test/unit/spec/roap/turnDiscovery.ts +20 -0
  312. package/test/unit/spec/webinar/index.ts +935 -466
@@ -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,71 @@ 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
+
198
+ it('passes an isLlmExpected callback that is true when current device is joined', async () => {
199
+ locusInfo.parsedLocus.self = {
200
+ state: 'LEFT',
201
+ joinedWith: {state: 'JOINED'},
202
+ };
203
+
204
+ await locusInfo.initialSetup({
205
+ trigger: 'locus-message',
206
+ hashTreeMessage: createHashTreeMessage(['dataset1']),
207
+ });
208
+
209
+ const {isLlmExpected} = HashTreeParserStub.firstCall.args[0].callbacks;
210
+
211
+ assert.equal(isLlmExpected(), true);
212
+ });
213
+
214
+ it('passes an isLlmExpected callback that is false when self is joined but current device is not joined', async () => {
215
+ locusInfo.parsedLocus.self = {
216
+ state: 'JOINED',
217
+ joinedWith: {state: 'LEFT'},
218
+ };
219
+
220
+ await locusInfo.initialSetup({
221
+ trigger: 'locus-message',
222
+ hashTreeMessage: createHashTreeMessage(['dataset1']),
223
+ });
224
+
225
+ const {isLlmExpected} = HashTreeParserStub.firstCall.args[0].callbacks;
226
+
227
+ assert.equal(isLlmExpected(), false);
228
+ });
229
+
160
230
  it('should not initialize the hash tree when triggered from a non-hash tree locus message', async () => {
161
231
  const locus = {url: 'http://locus-url.com', participants: []};
162
232
 
@@ -197,7 +267,9 @@ describe('plugin-meetings', () => {
197
267
  },
198
268
  metadata,
199
269
  webexRequest: sinon.match.func,
200
- locusInfoUpdateCallback: sinon.match.func,
270
+ callbacks: sinon.match({
271
+ locusInfoUpdateCallback: sinon.match.func,
272
+ }),
201
273
  debugId: sinon.match.string,
202
274
  })
203
275
  );
@@ -220,6 +292,47 @@ describe('plugin-meetings', () => {
220
292
  assert.isTrue(locusInfo.emitChange);
221
293
  });
222
294
 
295
+ it('calls onLocusSynced callback passed as second argument with full locus from join response', async () => {
296
+ const syncedLocus = {url: 'http://locus-url.com', participants: []};
297
+ const onLocusSynced = sinon.stub();
298
+
299
+ await locusInfo.initialSetup(
300
+ {
301
+ trigger: 'join-response',
302
+ locus: syncedLocus,
303
+ },
304
+ onLocusSynced
305
+ );
306
+
307
+ assert.calledOnceWithExactly(onLocusSynced, syncedLocus);
308
+ });
309
+
310
+ it('swallows onLocusSynced callback errors and logs warn', async () => {
311
+ const syncedLocus = {url: 'http://locus-url.com', participants: []};
312
+ const callbackError = new Error('onLocusSynced failed');
313
+ const onLocusSynced = sinon.stub().throws(callbackError);
314
+ const loggerWarnStub = LoggerProxy.logger.warn?.isSinonProxy
315
+ ? LoggerProxy.logger.warn
316
+ : sinon.stub(LoggerProxy.logger, 'warn');
317
+
318
+ loggerWarnStub.resetHistory();
319
+
320
+ await locusInfo.initialSetup(
321
+ {
322
+ trigger: 'join-response',
323
+ locus: syncedLocus,
324
+ },
325
+ onLocusSynced
326
+ );
327
+
328
+ assert.calledOnceWithExactly(onLocusSynced, syncedLocus);
329
+ assert.calledOnce(loggerWarnStub);
330
+ assert.match(
331
+ loggerWarnStub.firstCall.args[0],
332
+ /Locus-info:index#initialSetup --> onLocusSynced callback failed/
333
+ );
334
+ });
335
+
223
336
  it('should initialize the hash tree parser correctly when triggered from a get loci response containing visible datasets', async () => {
224
337
  const visibleDataSets = ['dataset1', 'dataset2'];
225
338
  const locus = createLocusWithVisibleDataSets(visibleDataSets);
@@ -237,7 +350,9 @@ describe('plugin-meetings', () => {
237
350
  dataSets: [],
238
351
  },
239
352
  webexRequest: sinon.match.func,
240
- locusInfoUpdateCallback: sinon.match.func,
353
+ callbacks: sinon.match({
354
+ locusInfoUpdateCallback: sinon.match.func,
355
+ }),
241
356
  debugId: sinon.match.string,
242
357
  metadata: null,
243
358
  })
@@ -290,6 +405,7 @@ describe('plugin-meetings', () => {
290
405
  describe('should setup correct locusInfoUpdateCallback when creating HashTreeParser', () => {
291
406
  const OBJECTS_UPDATED = HashTreeParserModule.LocusInfoUpdateType.OBJECTS_UPDATED;
292
407
  const MEETING_ENDED = HashTreeParserModule.LocusInfoUpdateType.MEETING_ENDED;
408
+ const LOCUS_NOT_FOUND = HashTreeParserModule.LocusInfoUpdateType.LOCUS_NOT_FOUND;
293
409
 
294
410
  let locusInfoUpdateCallback;
295
411
  let onDeltaLocusStub;
@@ -312,7 +428,7 @@ describe('plugin-meetings', () => {
312
428
  },
313
429
  });
314
430
 
315
- locusInfoUpdateCallback = HashTreeParserStub.firstCall.args[0].locusInfoUpdateCallback;
431
+ locusInfoUpdateCallback = HashTreeParserStub.firstCall.args[0].callbacks.locusInfoUpdateCallback;
316
432
 
317
433
  assert.isDefined(locusInfoUpdateCallback);
318
434
 
@@ -959,6 +1075,37 @@ describe('plugin-meetings', () => {
959
1075
  assert.notCalled(destroyStub);
960
1076
  });
961
1077
 
1078
+ it('should handle LOCUS_NOT_FOUND by calling syncMeetings with skipHashTreeSync', () => {
1079
+ const syncMeetingsStub = sinon.stub(locusInfo.webex.meetings, 'syncMeetings').resolves();
1080
+
1081
+ locusInfoUpdateCallback({updateType: LOCUS_NOT_FOUND});
1082
+
1083
+ assert.calledOnceWithExactly(syncMeetingsStub, {keepOnlyLocusMeetings: false, skipHashTreeSync: true});
1084
+ });
1085
+
1086
+ it('should handle LOCUS_NOT_FOUND and log error if syncMeetings fails', async () => {
1087
+ const syncError = new Error('sync failed');
1088
+ const syncMeetingsStub = sinon.stub(locusInfo.webex.meetings, 'syncMeetings').rejects(syncError);
1089
+ const logErrorStub = LoggerProxy.logger.error?.isSinonProxy
1090
+ ? LoggerProxy.logger.error
1091
+ : sinon.stub(LoggerProxy.logger, 'error');
1092
+
1093
+ logErrorStub.resetHistory();
1094
+
1095
+ locusInfoUpdateCallback({updateType: LOCUS_NOT_FOUND});
1096
+
1097
+ assert.calledOnceWithExactly(syncMeetingsStub, {keepOnlyLocusMeetings: false, skipHashTreeSync: true});
1098
+
1099
+ // wait for the promise rejection to be handled
1100
+ await testUtils.flushPromises();
1101
+
1102
+ assert.calledOnce(logErrorStub);
1103
+ assert.match(
1104
+ logErrorStub.firstCall.args[0],
1105
+ /syncMeetings failed after LOCUS_NOT_FOUND/
1106
+ );
1107
+ });
1108
+
962
1109
  it('should set forceReplaceMembers to true on the first update for a locusUrl (initializedFromHashTree is false)', () => {
963
1110
  const createdHashTreeParser = locusInfo.hashTreeParsers.get('fake-locus-url');
964
1111
  createdHashTreeParser.initializedFromHashTree = false;
@@ -1289,6 +1436,8 @@ describe('plugin-meetings', () => {
1289
1436
  state: RECORDING_STATE.IDLE,
1290
1437
  modifiedBy: 'George Kittle',
1291
1438
  lastModified: 'TODAY',
1439
+ modifiedByServiceAppName: undefined,
1440
+ modifiedByServiceAppId: undefined,
1292
1441
  }
1293
1442
  );
1294
1443
  });
@@ -1323,6 +1472,8 @@ describe('plugin-meetings', () => {
1323
1472
  state: RECORDING_STATE.RECORDING,
1324
1473
  modifiedBy: 'George Kittle',
1325
1474
  lastModified: 'TODAY',
1475
+ modifiedByServiceAppName: undefined,
1476
+ modifiedByServiceAppId: undefined,
1326
1477
  }
1327
1478
  );
1328
1479
  });
@@ -1358,6 +1509,8 @@ describe('plugin-meetings', () => {
1358
1509
  state: RECORDING_STATE.PAUSED,
1359
1510
  modifiedBy: 'George Kittle',
1360
1511
  lastModified: 'TODAY',
1512
+ modifiedByServiceAppName: undefined,
1513
+ modifiedByServiceAppId: undefined,
1361
1514
  }
1362
1515
  );
1363
1516
  });
@@ -1394,6 +1547,8 @@ describe('plugin-meetings', () => {
1394
1547
  state: RECORDING_STATE.RESUMED,
1395
1548
  modifiedBy: 'George Kittle',
1396
1549
  lastModified: 'TODAY',
1550
+ modifiedByServiceAppName: undefined,
1551
+ modifiedByServiceAppId: undefined,
1397
1552
  }
1398
1553
  );
1399
1554
  });
@@ -1429,6 +1584,44 @@ describe('plugin-meetings', () => {
1429
1584
  state: RECORDING_STATE.IDLE,
1430
1585
  modifiedBy: 'George Kittle',
1431
1586
  lastModified: 'TODAY',
1587
+ modifiedByServiceAppName: undefined,
1588
+ modifiedByServiceAppId: undefined,
1589
+ }
1590
+ );
1591
+ });
1592
+
1593
+ it('should include service app fields in the recording event when present', () => {
1594
+ locusInfo.controls = {
1595
+ record: {
1596
+ recording: false,
1597
+ paused: false,
1598
+ meta: {
1599
+ lastModified: 'TODAY',
1600
+ modifiedBy: 'George Kittle',
1601
+ },
1602
+ },
1603
+ shareControl: {},
1604
+ transcribe: {},
1605
+ };
1606
+ newControls.record.recording = true;
1607
+ newControls.record.meta.modifiedByServiceAppName = 'My Bot';
1608
+ newControls.record.meta.modifiedByServiceAppId = 'app-id-123';
1609
+ locusInfo.emitScoped = sinon.stub();
1610
+ locusInfo.updateControls(newControls);
1611
+
1612
+ assert.calledWith(
1613
+ locusInfo.emitScoped,
1614
+ {
1615
+ file: 'locus-info',
1616
+ function: 'updateControls',
1617
+ },
1618
+ LOCUSINFO.EVENTS.CONTROLS_RECORDING_UPDATED,
1619
+ {
1620
+ state: RECORDING_STATE.RECORDING,
1621
+ modifiedBy: 'George Kittle',
1622
+ lastModified: 'TODAY',
1623
+ modifiedByServiceAppName: 'My Bot',
1624
+ modifiedByServiceAppId: 'app-id-123',
1432
1625
  }
1433
1626
  );
1434
1627
  });
@@ -1862,6 +2055,53 @@ describe('plugin-meetings', () => {
1862
2055
  });
1863
2056
 
1864
2057
  describe('#updateSelf', () => {
2058
+ describe('LLM watchdog re-evaluation', () => {
2059
+ it('re-evaluates LLM watchdogs on all hash tree parsers when self transitions to joined', () => {
2060
+ const parserA = {reevaluateLlmWatchdogs: sinon.stub()};
2061
+ const parserB = {reevaluateLlmWatchdogs: sinon.stub()};
2062
+ locusInfo.hashTreeParsers.set('urlA', {parser: parserA});
2063
+ locusInfo.hashTreeParsers.set('urlB', {parser: parserB});
2064
+
2065
+ // start with LLM not expected (no self yet)
2066
+ locusInfo.parsedLocus.self = undefined;
2067
+ locusInfo.webex.internal.device.url = self.deviceUrl;
2068
+
2069
+ // the self fixture's joined device has state JOINED -> isLlmExpected becomes true
2070
+ locusInfo.updateSelf(cloneDeep(self));
2071
+
2072
+ assert.calledOnceWithExactly(parserA.reevaluateLlmWatchdogs);
2073
+ assert.calledOnceWithExactly(parserB.reevaluateLlmWatchdogs);
2074
+ });
2075
+
2076
+ it('does not re-evaluate LLM watchdogs when LLM was already expected before the update', () => {
2077
+ const parser = {reevaluateLlmWatchdogs: sinon.stub()};
2078
+ locusInfo.hashTreeParsers.set('urlA', {parser});
2079
+ locusInfo.webex.internal.device.url = self.deviceUrl;
2080
+
2081
+ // first update establishes the JOINED state (LLM already expected)
2082
+ locusInfo.updateSelf(cloneDeep(self));
2083
+ parser.reevaluateLlmWatchdogs.resetHistory();
2084
+
2085
+ // second update while already joined must not re-trigger re-evaluation
2086
+ locusInfo.updateSelf(cloneDeep(self));
2087
+
2088
+ assert.notCalled(parser.reevaluateLlmWatchdogs);
2089
+ });
2090
+
2091
+ it('does not re-evaluate LLM watchdogs when the self update does not make LLM expected', () => {
2092
+ const parser = {reevaluateLlmWatchdogs: sinon.stub()};
2093
+ locusInfo.hashTreeParsers.set('urlA', {parser});
2094
+
2095
+ locusInfo.parsedLocus.self = undefined;
2096
+ // device url does not match any of self's devices -> joinedWith is undefined -> not expected
2097
+ locusInfo.webex.internal.device.url = 'https://some-other-device-url.com';
2098
+
2099
+ locusInfo.updateSelf(cloneDeep(self));
2100
+
2101
+ assert.notCalled(parser.reevaluateLlmWatchdogs);
2102
+ });
2103
+ });
2104
+
1865
2105
  it('should trigger SELF_MEETING_BRB_CHANGED when brb state changed', () => {
1866
2106
  locusInfo.self = undefined;
1867
2107
 
@@ -2285,6 +2525,33 @@ describe('plugin-meetings', () => {
2285
2525
  locusInfo.updateSelf(self);
2286
2526
  const selfWithLocalUnmuteRequired = cloneDeep(self);
2287
2527
 
2528
+ selfWithLocalUnmuteRequired.controls.audio.muted = false;
2529
+ selfWithLocalUnmuteRequired.controls.audio.localAudioUnmuteRequired = true;
2530
+ selfWithLocalUnmuteRequired.controls.audio.meta = {modifiedBy: 'host-uuid-123'};
2531
+
2532
+ locusInfo.emitScoped = sinon.stub();
2533
+ locusInfo.updateSelf(selfWithLocalUnmuteRequired);
2534
+
2535
+ assert.calledWith(
2536
+ locusInfo.emitScoped,
2537
+ {
2538
+ file: 'locus-info',
2539
+ function: 'updateSelf',
2540
+ },
2541
+ LOCUSINFO.EVENTS.LOCAL_UNMUTE_REQUIRED,
2542
+ {
2543
+ muted: false,
2544
+ unmuteAllowed: true,
2545
+ modifiedBy: 'host-uuid-123',
2546
+ }
2547
+ );
2548
+ });
2549
+
2550
+ it('should set modifiedBy to null on LOCAL_UNMUTE_REQUIRED when it is unavailable', () => {
2551
+ locusInfo.webex.internal.device.url = self.deviceUrl;
2552
+ locusInfo.updateSelf(self);
2553
+ const selfWithLocalUnmuteRequired = cloneDeep(self);
2554
+
2288
2555
  selfWithLocalUnmuteRequired.controls.audio.muted = false;
2289
2556
  selfWithLocalUnmuteRequired.controls.audio.localAudioUnmuteRequired = true;
2290
2557
 
@@ -2301,6 +2568,7 @@ describe('plugin-meetings', () => {
2301
2568
  {
2302
2569
  muted: false,
2303
2570
  unmuteAllowed: true,
2571
+ modifiedBy: null,
2304
2572
  }
2305
2573
  );
2306
2574
  });
@@ -2726,6 +2994,10 @@ describe('plugin-meetings', () => {
2726
2994
 
2727
2995
  let expectedMeeting;
2728
2996
 
2997
+ // simulate that updateSelf has been called previously (as happens in production)
2998
+ // so that parsedLocus.self reflects the joined state
2999
+ locusInfo.parsedLocus.self = {state: 'JOINED'};
3000
+
2729
3001
  /*
2730
3002
  When the event is triggered, it is required that the meeting has already
2731
3003
  been updated. This is why the meeting is being checked within the stubbed event emitter
@@ -2736,6 +3008,7 @@ describe('plugin-meetings', () => {
2736
3008
 
2737
3009
  // set the info initially as locusInfo.info starts as undefined
2738
3010
  expectedMeeting = {
3011
+ attendee: {},
2739
3012
  coHost: {
2740
3013
  LOWER_SOMEONE_ELSES_HAND: true,
2741
3014
  },
@@ -2744,10 +3017,12 @@ describe('plugin-meetings', () => {
2744
3017
  moderator: {
2745
3018
  LOWER_SOMEONE_ELSES_HAND: true,
2746
3019
  },
3020
+ panelist: {},
2747
3021
  policy: {
2748
3022
  LOCK_STATUS_UNLOCKED: true,
2749
3023
  ROSTER_IN_MEETING: true,
2750
3024
  },
3025
+ presenter: {},
2751
3026
  userDisplayHints: ['ROSTER_IN_MEETING', 'LOCK_STATUS_UNLOCKED'],
2752
3027
  };
2753
3028
  locusInfo.updateMeetingInfo(initialInfo, self);
@@ -2762,6 +3037,7 @@ describe('plugin-meetings', () => {
2762
3037
 
2763
3038
  // Updating with different info should trigger the event
2764
3039
  expectedMeeting = {
3040
+ attendee: {},
2765
3041
  coHost: {
2766
3042
  LOWER_SOMEONE_ELSES_HAND: true,
2767
3043
  LOCK_CONTROL_LOCK: true,
@@ -2771,10 +3047,12 @@ describe('plugin-meetings', () => {
2771
3047
  moderator: {
2772
3048
  LOWER_SOMEONE_ELSES_HAND: true,
2773
3049
  },
3050
+ panelist: {},
2774
3051
  policy: {
2775
3052
  LOCK_STATUS_UNLOCKED: true,
2776
3053
  ROSTER_IN_MEETING: true,
2777
3054
  },
3055
+ presenter: {},
2778
3056
  userDisplayHints: ['ROSTER_IN_MEETING', 'LOCK_STATUS_UNLOCKED'],
2779
3057
  };
2780
3058
  locusInfo.updateMeetingInfo(newInfo, self);
@@ -2783,6 +3061,7 @@ describe('plugin-meetings', () => {
2783
3061
 
2784
3062
  // update it with the same info
2785
3063
  expectedMeeting = {
3064
+ attendee: {},
2786
3065
  coHost: {
2787
3066
  LOWER_SOMEONE_ELSES_HAND: true,
2788
3067
  LOCK_CONTROL_LOCK: true,
@@ -2792,10 +3071,12 @@ describe('plugin-meetings', () => {
2792
3071
  moderator: {
2793
3072
  LOWER_SOMEONE_ELSES_HAND: true,
2794
3073
  },
3074
+ panelist: {},
2795
3075
  policy: {
2796
3076
  LOCK_STATUS_UNLOCKED: true,
2797
3077
  ROSTER_IN_MEETING: true,
2798
3078
  },
3079
+ presenter: {},
2799
3080
  userDisplayHints: ['ROSTER_IN_MEETING', 'LOCK_STATUS_UNLOCKED'],
2800
3081
  };
2801
3082
  locusInfo.updateMeetingInfo(newInfo, self);
@@ -2810,6 +3091,7 @@ describe('plugin-meetings', () => {
2810
3091
  hasRole: true,
2811
3092
  });
2812
3093
  expectedMeeting = {
3094
+ attendee: {},
2813
3095
  coHost: {
2814
3096
  LOWER_SOMEONE_ELSES_HAND: true,
2815
3097
  LOCK_CONTROL_LOCK: true,
@@ -2819,10 +3101,12 @@ describe('plugin-meetings', () => {
2819
3101
  moderator: {
2820
3102
  LOWER_SOMEONE_ELSES_HAND: true,
2821
3103
  },
3104
+ panelist: {},
2822
3105
  policy: {
2823
3106
  LOCK_STATUS_UNLOCKED: true,
2824
3107
  ROSTER_IN_MEETING: true,
2825
3108
  },
3109
+ presenter: {},
2826
3110
  userDisplayHints: [
2827
3111
  'ROSTER_IN_MEETING',
2828
3112
  'LOCK_STATUS_UNLOCKED',
@@ -2865,6 +3149,46 @@ describe('plugin-meetings', () => {
2865
3149
  // since self is not passed to updateMeetingInfo, MEETING_INFO_UPDATED should be triggered with isIntializing: true
2866
3150
  checkMeetingInfoUpdatedCalledForRoles(true, {isInitializing: true});
2867
3151
  });
3152
+
3153
+ // joined-section hints (like ROSTER_IN_MEETING) are filtered out while not joined, so they
3154
+ // are a good proxy for verifying that userDisplayHints get recomputed on a join transition
3155
+ [
3156
+ {
3157
+ name: 'the JOINED delta carries the info section',
3158
+ getSecondInfo: (info) => info,
3159
+ },
3160
+ {
3161
+ name: 'the JOINED delta omits the info section (falls back to stored info)',
3162
+ getSecondInfo: () => undefined,
3163
+ },
3164
+ ].forEach(({name, getSecondInfo}) => {
3165
+ it(`recomputes userDisplayHints when self transitions to JOINED with unchanged roles and ${name}`, () => {
3166
+ const info = cloneDeep(meetingInfo); // joined: ['ROSTER_IN_MEETING', 'LOCK_STATUS_UNLOCKED']
3167
+
3168
+ const notJoinedSelf = cloneDeep(self);
3169
+ notJoinedSelf.state = 'IDLE';
3170
+ notJoinedSelf.controls.role.roles = [];
3171
+
3172
+ const joinedSelf = cloneDeep(self);
3173
+ joinedSelf.state = 'JOINED';
3174
+ joinedSelf.controls.role.roles = [];
3175
+
3176
+ sinon.stub(locusInfo, 'emitScoped');
3177
+
3178
+ // first update while not joined: joined-section hints are filtered out
3179
+ locusInfo.updateMeetingInfo(info, notJoinedSelf);
3180
+ assert.notInclude(locusInfo.parsedLocus.info.userDisplayHints, 'ROSTER_IN_MEETING');
3181
+ assert.notInclude(locusInfo.parsedLocus.info.userDisplayHints, 'LOCK_STATUS_UNLOCKED');
3182
+
3183
+ // self transitions to JOINED - info and roles are unchanged
3184
+ locusInfo.updateMeetingInfo(getSecondInfo(info), joinedSelf);
3185
+
3186
+ // the hints must be recomputed with the new joined state
3187
+ assert.include(locusInfo.parsedLocus.info.userDisplayHints, 'ROSTER_IN_MEETING');
3188
+ assert.include(locusInfo.parsedLocus.info.userDisplayHints, 'LOCK_STATUS_UNLOCKED');
3189
+ checkMeetingInfoUpdatedCalled(true, {isInitializing: false});
3190
+ });
3191
+ });
2868
3192
  });
2869
3193
 
2870
3194
  describe('#updateMediaShares', () => {
@@ -3175,13 +3499,14 @@ describe('plugin-meetings', () => {
3175
3499
  const createMockParser = (state = 'active') => ({
3176
3500
  state,
3177
3501
  stop: sinon.stub(),
3178
- resume: sinon.stub(),
3502
+ resumeFromMessage: sinon.stub(),
3179
3503
  handleMessage: sinon.stub(),
3180
3504
  });
3181
3505
 
3182
3506
  const createSelfElementWithReplaces = (replacedLocusUrl, replacedAt) => ({
3183
3507
  htMeta: {elementId: {type: 'Self'}},
3184
3508
  data: {
3509
+ deviceUrl,
3185
3510
  devices: [{url: deviceUrl, replaces: [{locusUrl: replacedLocusUrl, replacedAt}]}],
3186
3511
  },
3187
3512
  });
@@ -3257,7 +3582,7 @@ describe('plugin-meetings', () => {
3257
3582
  stateElementsMessage: message,
3258
3583
  });
3259
3584
 
3260
- assert.calledOnce(parserA.resume);
3585
+ assert.calledOnce(parserA.resumeFromMessage);
3261
3586
  assert.calledOnce(parserB.stop);
3262
3587
  });
3263
3588
 
@@ -3280,7 +3605,7 @@ describe('plugin-meetings', () => {
3280
3605
  stateElementsMessage: message,
3281
3606
  });
3282
3607
 
3283
- assert.notCalled(parserA.resume);
3608
+ assert.notCalled(parserA.resumeFromMessage);
3284
3609
  assert.notCalled(parserB.stop);
3285
3610
  });
3286
3611
 
@@ -3299,7 +3624,7 @@ describe('plugin-meetings', () => {
3299
3624
  stateElementsMessage: message,
3300
3625
  });
3301
3626
 
3302
- assert.notCalled(parserA.resume);
3627
+ assert.notCalled(parserA.resumeFromMessage);
3303
3628
  assert.notCalled(parserA.handleMessage);
3304
3629
  });
3305
3630
 
@@ -3383,6 +3708,51 @@ describe('plugin-meetings', () => {
3383
3708
 
3384
3709
  assert.calledOnceWithExactly(parserA.handleMessage, message);
3385
3710
  });
3711
+
3712
+ it('should send mismatch metric when eventType is not HASH_TREE_DATA_UPDATED', () => {
3713
+ const locusUrlA = 'http://locus-url-A.com';
3714
+ const parserA = {state: 'active', handleMessage: sinon.stub()};
3715
+ locusInfo.hashTreeParsers.set(locusUrlA, {parser: parserA, initializedFromHashTree: true});
3716
+
3717
+ locusInfo.parse(mockMeeting, {
3718
+ eventType: LOCUSEVENT.SELF_CHANGED,
3719
+ stateElementsMessage: {locusUrl: locusUrlA, locusStateElements: [], dataSets: []},
3720
+ });
3721
+
3722
+ assert.calledOnceWithExactly(
3723
+ sendBehavioralMetricStub,
3724
+ 'js_sdk_locus_classic_vs_hash_tree_mismatch',
3725
+ {
3726
+ correlationId: mockMeeting.correlationId,
3727
+ message: `got ${LOCUSEVENT.SELF_CHANGED}, expected ${LOCUSEVENT.HASH_TREE_DATA_UPDATED}`,
3728
+ }
3729
+ );
3730
+ assert.notCalled(parserA.handleMessage);
3731
+ });
3732
+ });
3733
+
3734
+ describe('#sendClassicVsHashTreeMismatchMetric', () => {
3735
+ it('should send the metric when called for the first time', () => {
3736
+ locusInfo.sendClassicVsHashTreeMismatchMetric(mockMeeting, 'some mismatch');
3737
+
3738
+ assert.calledOnceWithExactly(
3739
+ sendBehavioralMetricStub,
3740
+ 'js_sdk_locus_classic_vs_hash_tree_mismatch',
3741
+ {
3742
+ correlationId: mockMeeting.correlationId,
3743
+ message: 'some mismatch',
3744
+ }
3745
+ );
3746
+ });
3747
+
3748
+ it('should send the metric up to 5 times and stop after that', () => {
3749
+ for (let i = 0; i < 7; i += 1) {
3750
+ locusInfo.sendClassicVsHashTreeMismatchMetric(mockMeeting, `mismatch ${i}`);
3751
+ }
3752
+
3753
+ assert.callCount(sendBehavioralMetricStub, 5);
3754
+ assert.equal(locusInfo.classicVsHashTreeMismatchMetricCounter, 5);
3755
+ });
3386
3756
  });
3387
3757
 
3388
3758
  describe('#handleLocusAPIResponse', () => {
@@ -3438,19 +3808,186 @@ describe('plugin-meetings', () => {
3438
3808
  assert.calledOnceWithExactly(locusInfo.handleLocusDelta, fakeLocus, mockMeeting);
3439
3809
  });
3440
3810
 
3441
- it('should send mismatch metric when hash tree parser exists but dataSets are missing in wrapped response', () => {
3811
+ it('should send mismatch metric in classic mode when wrapped response has dataSets', () => {
3442
3812
  const fakeLocus = {url: 'http://locus-url.com'};
3443
- const mockHashTreeParser = {handleLocusUpdate: sinon.stub()};
3444
- locusInfo.hashTreeParsers.set(fakeLocus.url, {
3445
- parser: mockHashTreeParser,
3446
- initializedFromHashTree: true,
3813
+ sinon.stub(locusInfo, 'handleLocusDelta');
3814
+
3815
+ locusInfo.handleLocusAPIResponse(mockMeeting, {
3816
+ locus: fakeLocus,
3817
+ dataSets: [{name: 'dataset1', url: 'test-url'}],
3447
3818
  });
3448
- sinon.stub(locusInfo, 'sendClassicVsHashTreeMismatchMetric');
3449
3819
 
3450
- locusInfo.handleLocusAPIResponse(mockMeeting, {locus: fakeLocus});
3820
+ assert.calledOnceWithExactly(
3821
+ sendBehavioralMetricStub,
3822
+ 'js_sdk_locus_classic_vs_hash_tree_mismatch',
3823
+ {
3824
+ correlationId: mockMeeting.correlationId,
3825
+ message: 'unexpected hash tree dataSets in API response',
3826
+ }
3827
+ );
3828
+ assert.calledOnce(locusInfo.handleLocusDelta);
3829
+ });
3451
3830
 
3452
- assert.calledOnce(locusInfo.sendClassicVsHashTreeMismatchMetric);
3453
- assert.calledOnce(mockHashTreeParser.handleLocusUpdate);
3831
+ describe('parser switch via API response', () => {
3832
+ const deviceUrl = 'http://device-url.com';
3833
+ const locusUrlA = 'http://locus-url-A.com';
3834
+ const locusUrlB = 'http://locus-url-B.com';
3835
+
3836
+ let HashTreeParserStub;
3837
+
3838
+ const createMockApiParser = (state = 'active') => ({
3839
+ state,
3840
+ stop: sinon.stub(),
3841
+ resumeFromApiResponse: sinon.stub(),
3842
+ handleLocusUpdate: sinon.stub(),
3843
+ initializeFromGetLociResponse: sinon.stub(),
3844
+ });
3845
+
3846
+ const createLocusWithReplaces = (url, replacedLocusUrl, replacedAt) => ({
3847
+ url,
3848
+ self: {
3849
+ devices: [{url: deviceUrl, replaces: [{locusUrl: replacedLocusUrl, replacedAt}]}],
3850
+ },
3851
+ });
3852
+
3853
+ const createLocusWithoutReplaces = (url) => ({
3854
+ url,
3855
+ self: {devices: [{url: deviceUrl}]},
3856
+ });
3857
+
3858
+ beforeEach(() => {
3859
+ locusInfo.webex.internal.device.url = deviceUrl;
3860
+ HashTreeParserStub = sinon
3861
+ .stub(HashTreeParserModule, 'default')
3862
+ .returns(createMockApiParser());
3863
+ });
3864
+
3865
+ it('should create a new parser and initialize it when no entry exists for the locusUrl', () => {
3866
+ // existing parser for a different url so hashTreeParsers.size > 0
3867
+ locusInfo.hashTreeParsers.set(locusUrlA, {parser: createMockApiParser(), initializedFromHashTree: true});
3868
+
3869
+ const locus = createLocusWithReplaces(locusUrlB, locusUrlA, '2026-01-01T00:00:00Z');
3870
+ sinon.stub(locusInfo, 'handleLocusDelta');
3871
+
3872
+ locusInfo.handleLocusAPIResponse(mockMeeting, {locus});
3873
+
3874
+ assert.isTrue(locusInfo.hashTreeParsers.has(locusUrlB));
3875
+ const newEntry = locusInfo.hashTreeParsers.get(locusUrlB);
3876
+ assert.isFalse(newEntry.initializedFromHashTree);
3877
+
3878
+ // the stub returns the mock, so initializeFromGetLociResponse should be called on it
3879
+ const createdParser = HashTreeParserStub.returnValues[0];
3880
+ assert.calledOnceWithExactly(createdParser.initializeFromGetLociResponse, locus);
3881
+ assert.notCalled(locusInfo.handleLocusDelta);
3882
+ });
3883
+
3884
+ it('should reactivate a stopped parser when replaces info is newer', () => {
3885
+ const parserA = createMockApiParser('stopped');
3886
+ const parserB = createMockApiParser('active');
3887
+ locusInfo.hashTreeParsers.set(locusUrlA, {parser: parserA, replacedAt: '2026-01-01T00:00:00Z', initializedFromHashTree: true});
3888
+ locusInfo.hashTreeParsers.set(locusUrlB, {parser: parserB, initializedFromHashTree: true});
3889
+
3890
+ const locus = createLocusWithReplaces(locusUrlA, locusUrlB, '2026-02-01T00:00:00Z');
3891
+
3892
+ locusInfo.handleLocusAPIResponse(mockMeeting, {locus});
3893
+
3894
+ assert.calledOnce(parserA.resumeFromApiResponse);
3895
+ assert.calledWithExactly(parserA.resumeFromApiResponse, locus);
3896
+ assert.calledOnce(parserB.stop);
3897
+ assert.equal(locusInfo.hashTreeParsers.get(locusUrlB).replacedAt, '2026-02-01T00:00:00Z');
3898
+ assert.isFalse(locusInfo.hashTreeParsers.get(locusUrlA).initializedFromHashTree);
3899
+ });
3900
+
3901
+ it('should not reactivate a stopped parser when replaces info is not newer', () => {
3902
+ const parserA = createMockApiParser('stopped');
3903
+ const parserB = createMockApiParser('active');
3904
+ locusInfo.hashTreeParsers.set(locusUrlA, {parser: parserA, replacedAt: '2026-03-01T00:00:00Z', initializedFromHashTree: true});
3905
+ locusInfo.hashTreeParsers.set(locusUrlB, {parser: parserB, initializedFromHashTree: true});
3906
+
3907
+ const locus = createLocusWithReplaces(locusUrlA, locusUrlB, '2026-01-01T00:00:00Z');
3908
+
3909
+ locusInfo.handleLocusAPIResponse(mockMeeting, {locus});
3910
+
3911
+ assert.notCalled(parserA.resumeFromApiResponse);
3912
+ assert.notCalled(parserB.stop);
3913
+ });
3914
+
3915
+ it('should not reactivate a stopped parser when no replaces info is available', () => {
3916
+ const parserA = createMockApiParser('stopped');
3917
+ locusInfo.hashTreeParsers.set(locusUrlA, {parser: parserA, initializedFromHashTree: true});
3918
+
3919
+ const locus = createLocusWithoutReplaces(locusUrlA);
3920
+
3921
+ locusInfo.handleLocusAPIResponse(mockMeeting, {locus});
3922
+
3923
+ assert.notCalled(parserA.resumeFromApiResponse);
3924
+ });
3925
+ });
3926
+ });
3927
+
3928
+ describe('#syncAllHashTreeDatasets', () => {
3929
+ it('should call syncAllDatasets on each parser that has an entry', async () => {
3930
+ const parser1 = {syncAllDatasets: sinon.stub().resolves()};
3931
+ const parser2 = {syncAllDatasets: sinon.stub().resolves()};
3932
+ locusInfo.hashTreeParsers.set('url1', {parser: parser1});
3933
+ locusInfo.hashTreeParsers.set('url2', {parser: parser2});
3934
+
3935
+ await locusInfo.syncAllHashTreeDatasets();
3936
+
3937
+ assert.calledOnce(parser1.syncAllDatasets);
3938
+ assert.calledOnce(parser2.syncAllDatasets);
3939
+ });
3940
+
3941
+ it('should skip parser entries without a parser object', async () => {
3942
+ const parser1 = {syncAllDatasets: sinon.stub().resolves()};
3943
+ locusInfo.hashTreeParsers.set('url1', {parser: parser1});
3944
+ locusInfo.hashTreeParsers.set('url2', {parser: undefined});
3945
+
3946
+ await locusInfo.syncAllHashTreeDatasets();
3947
+
3948
+ assert.calledOnce(parser1.syncAllDatasets);
3949
+ });
3950
+
3951
+ it('should forward options to each parser syncAllDatasets', async () => {
3952
+ const parser1 = {syncAllDatasets: sinon.stub().resolves()};
3953
+ const parser2 = {syncAllDatasets: sinon.stub().resolves()};
3954
+ locusInfo.hashTreeParsers.set('url1', {parser: parser1});
3955
+ locusInfo.hashTreeParsers.set('url2', {parser: parser2});
3956
+
3957
+ await locusInfo.syncAllHashTreeDatasets({onlyLLM: true});
3958
+
3959
+ assert.calledOnceWithExactly(parser1.syncAllDatasets, {onlyLLM: true});
3960
+ assert.calledOnceWithExactly(parser2.syncAllDatasets, {onlyLLM: true});
3961
+ });
3962
+
3963
+ it('should await each parsers syncAllDatasets sequentially', async () => {
3964
+ const callOrder = [];
3965
+ const parser1 = {syncAllDatasets: sinon.stub().callsFake(() => {
3966
+ callOrder.push('start1');
3967
+ return new Promise((resolve) => {
3968
+ setTimeout(() => {
3969
+ callOrder.push('end1');
3970
+ resolve();
3971
+ }, 100);
3972
+ });
3973
+ })};
3974
+ const parser2 = {syncAllDatasets: sinon.stub().callsFake(() => {
3975
+ callOrder.push('start2');
3976
+ return Promise.resolve();
3977
+ })};
3978
+ locusInfo.hashTreeParsers.set('url1', {parser: parser1});
3979
+ locusInfo.hashTreeParsers.set('url2', {parser: parser2});
3980
+
3981
+ const clock = sinon.useFakeTimers();
3982
+ const promise = locusInfo.syncAllHashTreeDatasets();
3983
+ // parser1 started but parser2 not yet
3984
+ assert.deepEqual(callOrder, ['start1']);
3985
+
3986
+ await clock.tickAsync(100);
3987
+ await promise;
3988
+ // parser1 finished, then parser2 started and finished
3989
+ assert.deepEqual(callOrder, ['start1', 'end1', 'start2']);
3990
+ clock.restore();
3454
3991
  });
3455
3992
  });
3456
3993
 
@@ -3542,49 +4079,23 @@ describe('plugin-meetings', () => {
3542
4079
  assert.deepEqual(callOrder, ['updateLocusUrl', 'updateMeetingInfo']);
3543
4080
  });
3544
4081
 
3545
- it('#updateLocusInfo ignores breakout LEFT message', () => {
3546
- const newLocus = {
3547
- self: {
3548
- reason: 'MOVED',
3549
- state: 'LEFT',
3550
- },
3551
- };
4082
+ it('#updateLocusInfo ignores locus when isSelfMovedOrBreakoutEnded returns true', () => {
4083
+ const newLocus = {self: {state: 'JOINED'}};
4084
+
4085
+ sinon.stub(MeetingsUtil, 'isSelfMovedOrBreakoutEnded').returns(true);
3552
4086
 
3553
4087
  locusInfo.updateControls = sinon.stub();
3554
- locusInfo.updateConversationUrl = sinon.stub();
3555
- locusInfo.updateCreated = sinon.stub();
3556
4088
  locusInfo.updateFullState = sinon.stub();
3557
- locusInfo.updateHostInfo = sinon.stub();
3558
- locusInfo.updateMeetingInfo = sinon.stub();
3559
- locusInfo.updateMediaShares = sinon.stub();
3560
- locusInfo.updateReplaces = sinon.stub();
3561
4089
  locusInfo.updateSelf = sinon.stub();
3562
- locusInfo.updateLocusUrl = sinon.stub();
3563
- locusInfo.updateAclUrl = sinon.stub();
3564
- locusInfo.updateBasequence = sinon.stub();
3565
- locusInfo.updateSequence = sinon.stub();
3566
- locusInfo.updateEmbeddedApps = sinon.stub();
3567
- locusInfo.updateLinks = sinon.stub();
3568
- locusInfo.compareAndUpdate = sinon.stub();
3569
4090
 
3570
4091
  locusInfo.updateLocusInfo(newLocus);
3571
4092
 
4093
+ assert.calledOnceWithExactly(MeetingsUtil.isSelfMovedOrBreakoutEnded, newLocus);
3572
4094
  assert.notCalled(locusInfo.updateControls);
3573
- assert.notCalled(locusInfo.updateConversationUrl);
3574
- assert.notCalled(locusInfo.updateCreated);
3575
4095
  assert.notCalled(locusInfo.updateFullState);
3576
- assert.notCalled(locusInfo.updateHostInfo);
3577
- assert.notCalled(locusInfo.updateMeetingInfo);
3578
- assert.notCalled(locusInfo.updateMediaShares);
3579
- assert.notCalled(locusInfo.updateReplaces);
3580
4096
  assert.notCalled(locusInfo.updateSelf);
3581
- assert.notCalled(locusInfo.updateLocusUrl);
3582
- assert.notCalled(locusInfo.updateAclUrl);
3583
- assert.notCalled(locusInfo.updateBasequence);
3584
- assert.notCalled(locusInfo.updateSequence);
3585
- assert.notCalled(locusInfo.updateEmbeddedApps);
3586
- assert.notCalled(locusInfo.updateLinks);
3587
- assert.notCalled(locusInfo.compareAndUpdate);
4097
+
4098
+ MeetingsUtil.isSelfMovedOrBreakoutEnded.restore();
3588
4099
  });
3589
4100
 
3590
4101
  it('#updateLocusInfo puts the Locus DTO top level properties at the right place in LocusInfo class', () => {
@@ -3830,6 +4341,296 @@ describe('plugin-meetings', () => {
3830
4341
  assert.calledOnceWithExactly(meeting.meetingRequest.getLocusDTO, {url: fakeLocus.url});
3831
4342
  });
3832
4343
 
4344
+ describe('#sync', () => {
4345
+ it('pauses the parser and awaits the Locus sync for classic meetings when canSyncClassicLocus is true', async () => {
4346
+ const fakeFullLocusDto = {id: 'fake full locus dto'};
4347
+ const meeting = {
4348
+ meetingRequest: {
4349
+ getLocusDTO: sandbox.stub().resolves({body: fakeFullLocusDto}),
4350
+ },
4351
+ locusInfo: {
4352
+ onFullLocus: sandbox.stub(),
4353
+ },
4354
+ locusUrl: 'someLocusUrl',
4355
+ };
4356
+
4357
+ locusInfo.locusParser.workingCopy = {}; // no syncUrl -> full sync
4358
+ sandbox.stub(locusInfo.locusParser, 'pause');
4359
+ sandbox.stub(locusInfo.locusParser, 'resume');
4360
+
4361
+ await locusInfo.sync(meeting, {canSyncClassicLocus: true, canSyncHashTree: true});
4362
+
4363
+ assert.calledOnce(locusInfo.locusParser.pause);
4364
+ assert.calledOnceWithExactly(meeting.meetingRequest.getLocusDTO, {url: 'someLocusUrl'});
4365
+ // sync() must not resolve until the fetched DTO has been applied
4366
+ assert.calledOnceWithExactly(
4367
+ meeting.locusInfo.onFullLocus,
4368
+ 'classic Locus sync',
4369
+ fakeFullLocusDto
4370
+ );
4371
+ assert.calledOnce(locusInfo.locusParser.resume);
4372
+ });
4373
+
4374
+ it('does nothing for classic meetings when the meeting has no Locus URL', async () => {
4375
+ const meeting = {
4376
+ meetingRequest: {
4377
+ getLocusDTO: sandbox.stub().resolves({body: {}}),
4378
+ },
4379
+ locusUrl: undefined,
4380
+ };
4381
+
4382
+ locusInfo.locusParser.workingCopy = {};
4383
+ sandbox.stub(locusInfo.locusParser, 'pause');
4384
+
4385
+ await locusInfo.sync(meeting, {canSyncClassicLocus: true, canSyncHashTree: true});
4386
+
4387
+ assert.notCalled(locusInfo.locusParser.pause);
4388
+ assert.notCalled(meeting.meetingRequest.getLocusDTO);
4389
+ });
4390
+
4391
+ it('does nothing for classic meetings when canSyncClassicLocus is false', async () => {
4392
+ const meeting = {
4393
+ meetingRequest: {
4394
+ getLocusDTO: sandbox.stub().resolves({body: {}}),
4395
+ },
4396
+ locusUrl: 'someLocusUrl',
4397
+ };
4398
+
4399
+ locusInfo.locusParser.workingCopy = {};
4400
+ sandbox.stub(locusInfo.locusParser, 'pause');
4401
+
4402
+ await locusInfo.sync(meeting, {canSyncClassicLocus: false, canSyncHashTree: true});
4403
+
4404
+ assert.notCalled(locusInfo.locusParser.pause);
4405
+ assert.notCalled(meeting.meetingRequest.getLocusDTO);
4406
+ });
4407
+
4408
+ it('syncs hash tree datasets and never does a classic Locus sync for hash tree based meetings', async () => {
4409
+ const parser = {syncAllDatasets: sandbox.stub().resolves()};
4410
+ const meeting = {
4411
+ meetingRequest: {
4412
+ getLocusDTO: sandbox.stub().resolves({body: {}}),
4413
+ },
4414
+ };
4415
+
4416
+ locusInfo.hashTreeParsers.set('someLocusUrl', {parser});
4417
+ sandbox.stub(locusInfo.locusParser, 'pause');
4418
+
4419
+ await locusInfo.sync(meeting, {canSyncClassicLocus: true, canSyncHashTree: true});
4420
+
4421
+ assert.calledOnce(parser.syncAllDatasets);
4422
+ assert.notCalled(locusInfo.locusParser.pause);
4423
+ assert.notCalled(meeting.meetingRequest.getLocusDTO);
4424
+ });
4425
+
4426
+ it('does not sync hash tree datasets when canSyncHashTree is false', async () => {
4427
+ const parser = {syncAllDatasets: sandbox.stub().resolves()};
4428
+ const meeting = {
4429
+ meetingRequest: {
4430
+ getLocusDTO: sandbox.stub().resolves({body: {}}),
4431
+ },
4432
+ };
4433
+
4434
+ locusInfo.hashTreeParsers.set('someLocusUrl', {parser});
4435
+ sandbox.stub(locusInfo.locusParser, 'pause');
4436
+
4437
+ await locusInfo.sync(meeting, {canSyncClassicLocus: true, canSyncHashTree: false});
4438
+
4439
+ assert.notCalled(parser.syncAllDatasets);
4440
+ assert.notCalled(locusInfo.locusParser.pause);
4441
+ assert.notCalled(meeting.meetingRequest.getLocusDTO);
4442
+ });
4443
+
4444
+ it('preserves the meeting and rejects when the classic sync fails, so the caller can retry', async () => {
4445
+ const fetchError = new Error('transient failure');
4446
+ const meeting = {
4447
+ meetingRequest: {
4448
+ getLocusDTO: sandbox.stub().rejects(fetchError),
4449
+ },
4450
+ locusInfo: {
4451
+ onFullLocus: sandbox.stub(),
4452
+ },
4453
+ locusUrl: 'someLocusUrl',
4454
+ };
4455
+
4456
+ locusInfo.locusParser.workingCopy = {}; // no syncUrl -> full sync
4457
+ sandbox.stub(locusInfo.locusParser, 'pause');
4458
+ sandbox.stub(locusInfo.locusParser, 'resume');
4459
+ sandbox.stub(webex.meetings, 'destroy');
4460
+
4461
+ await assert.isRejected(
4462
+ locusInfo.sync(meeting, {canSyncClassicLocus: true, canSyncHashTree: true}),
4463
+ fetchError
4464
+ );
4465
+
4466
+ // the meeting must not be torn down on a transient reconnection sync failure
4467
+ assert.notCalled(webex.meetings.destroy);
4468
+ // the parser must still be resumed so it isn't left paused
4469
+ assert.calledOnce(locusInfo.locusParser.resume);
4470
+ });
4471
+
4472
+ it('destroys the meeting and resolves when the classic sync gets a terminal 403, so the caller does not retry', async () => {
4473
+ const fake403Error = new Error('meeting ended');
4474
+ fake403Error.statusCode = 403;
4475
+ const meeting = {
4476
+ correlationId: 'correlationId',
4477
+ meetingRequest: {
4478
+ getLocusDTO: sandbox.stub().rejects(fake403Error),
4479
+ },
4480
+ locusInfo: {
4481
+ onFullLocus: sandbox.stub(),
4482
+ },
4483
+ locusUrl: 'someLocusUrl',
4484
+ };
4485
+
4486
+ locusInfo.locusParser.workingCopy = {syncUrl: 'deltaSyncUrl'}; // delta sync -> 403 is terminal
4487
+ sandbox.stub(locusInfo.locusParser, 'pause');
4488
+ sandbox.stub(locusInfo.locusParser, 'resume');
4489
+ sandbox.stub(webex.meetings, 'destroy');
4490
+
4491
+ // a terminal 403 means the meeting has ended, so the sync must resolve (not reject),
4492
+ // otherwise the reconnection flow would retry indefinitely
4493
+ await locusInfo.sync(meeting, {canSyncClassicLocus: true, canSyncHashTree: true});
4494
+
4495
+ assert.calledOnceWithExactly(webex.meetings.destroy, meeting, 'LOCUS_DTO_SYNC_FAILED');
4496
+ // meeting was destroyed, so the parser is not resumed
4497
+ assert.notCalled(locusInfo.locusParser.resume);
4498
+ });
4499
+
4500
+ it('destroys the meeting and resolves when the fallback full sync gets a terminal 403, so the caller does not retry', async () => {
4501
+ const fakeDeltaError = new Error('delta failed');
4502
+ fakeDeltaError.statusCode = 500;
4503
+ const fake403Error = new Error('meeting ended');
4504
+ fake403Error.statusCode = 403;
4505
+ const getLocusDTO = sandbox.stub();
4506
+ getLocusDTO.onCall(0).rejects(fakeDeltaError); // delta sync fails with non-403
4507
+ getLocusDTO.onCall(1).rejects(fake403Error); // fallback full sync fails with 403
4508
+ const meeting = {
4509
+ correlationId: 'correlationId',
4510
+ meetingRequest: {
4511
+ getLocusDTO,
4512
+ },
4513
+ locusInfo: {
4514
+ onFullLocus: sandbox.stub(),
4515
+ },
4516
+ locusUrl: 'someLocusUrl',
4517
+ };
4518
+
4519
+ locusInfo.locusParser.workingCopy = {syncUrl: 'deltaSyncUrl'}; // delta sync -> fallback to full sync
4520
+ sandbox.stub(locusInfo.locusParser, 'pause');
4521
+ sandbox.stub(locusInfo.locusParser, 'resume');
4522
+ sandbox.stub(webex.meetings, 'destroy');
4523
+
4524
+ // a terminal 403 from the fallback full sync means the meeting has ended, so the sync must
4525
+ // resolve (not reject), otherwise the reconnection flow would retry indefinitely
4526
+ await locusInfo.sync(meeting, {canSyncClassicLocus: true, canSyncHashTree: true});
4527
+
4528
+ assert.calledTwice(getLocusDTO);
4529
+ assert.deepEqual(getLocusDTO.getCalls()[0].args, [{url: 'deltaSyncUrl'}]);
4530
+ assert.deepEqual(getLocusDTO.getCalls()[1].args, [{url: 'someLocusUrl'}]);
4531
+ assert.calledOnceWithExactly(webex.meetings.destroy, meeting, 'LOCUS_DTO_SYNC_FAILED');
4532
+ // meeting was destroyed, so the parser is not resumed
4533
+ assert.notCalled(locusInfo.locusParser.resume);
4534
+ });
4535
+
4536
+ it('destroys the meeting and resolves when the direct full sync (no delta syncUrl) gets a terminal 403, so the caller does not retry', async () => {
4537
+ const fake403Error = new Error('meeting ended');
4538
+ fake403Error.statusCode = 403;
4539
+ const meeting = {
4540
+ correlationId: 'correlationId',
4541
+ meetingRequest: {
4542
+ getLocusDTO: sandbox.stub().rejects(fake403Error),
4543
+ },
4544
+ locusInfo: {
4545
+ onFullLocus: sandbox.stub(),
4546
+ },
4547
+ locusUrl: 'someLocusUrl',
4548
+ };
4549
+
4550
+ locusInfo.locusParser.workingCopy = {}; // no syncUrl -> direct full sync, 403 is terminal
4551
+ sandbox.stub(locusInfo.locusParser, 'pause');
4552
+ sandbox.stub(locusInfo.locusParser, 'resume');
4553
+ sandbox.stub(webex.meetings, 'destroy');
4554
+
4555
+ // a terminal 403 from the direct full sync means the meeting has ended, so the sync must
4556
+ // resolve (not reject), otherwise the reconnection flow would retry indefinitely
4557
+ await locusInfo.sync(meeting, {canSyncClassicLocus: true, canSyncHashTree: true});
4558
+
4559
+ assert.calledOnceWithExactly(meeting.meetingRequest.getLocusDTO, {url: 'someLocusUrl'});
4560
+ assert.calledOnceWithExactly(webex.meetings.destroy, meeting, 'LOCUS_DTO_SYNC_FAILED');
4561
+ // meeting was destroyed, so the parser is not resumed
4562
+ assert.notCalled(locusInfo.locusParser.resume);
4563
+ });
4564
+ });
4565
+
4566
+ describe('#doLocusSync', () => {
4567
+ it('resolves without destroying the meeting when the DTO is fetched but applying it fails and destroyOnTransientFailure is true', async () => {
4568
+ const fakeFullLocusDto = {id: 'fake full locus dto'};
4569
+ const applyError = new Error('failed to apply DTO');
4570
+ const meeting = {
4571
+ correlationId: 'correlationId',
4572
+ meetingRequest: {
4573
+ getLocusDTO: sandbox.stub().resolves({body: fakeFullLocusDto}),
4574
+ },
4575
+ locusInfo: {
4576
+ onFullLocus: sandbox.stub().throws(applyError),
4577
+ },
4578
+ locusUrl: 'someLocusUrl',
4579
+ };
4580
+
4581
+ locusInfo.locusParser.workingCopy = {}; // no syncUrl -> full sync
4582
+ sandbox.stub(locusInfo.locusParser, 'resume');
4583
+ sandbox.stub(webex.meetings, 'destroy');
4584
+
4585
+ // destroyOnTransientFailure defaults to true: a successfully fetched DTO that then fails to
4586
+ // apply must not reject or destroy the meeting - doLocusSync just resumes the parser and
4587
+ // resolves (the returned promise must not reject)
4588
+ await locusInfo.doLocusSync(meeting, false, undefined);
4589
+
4590
+ assert.calledOnceWithExactly(
4591
+ meeting.locusInfo.onFullLocus,
4592
+ 'classic Locus sync',
4593
+ fakeFullLocusDto
4594
+ );
4595
+ assert.notCalled(webex.meetings.destroy);
4596
+ assert.calledOnce(locusInfo.locusParser.resume);
4597
+ });
4598
+
4599
+ it('resolves (does not reject) when the DTO is fetched but applying it fails even when destroyOnTransientFailure is false, so the sync is not retried indefinitely', async () => {
4600
+ const fakeFullLocusDto = {id: 'fake full locus dto'};
4601
+ const applyError = new Error('failed to apply DTO');
4602
+ const meeting = {
4603
+ correlationId: 'correlationId',
4604
+ meetingRequest: {
4605
+ getLocusDTO: sandbox.stub().resolves({body: fakeFullLocusDto}),
4606
+ },
4607
+ locusInfo: {
4608
+ onFullLocus: sandbox.stub().throws(applyError),
4609
+ },
4610
+ locusUrl: 'someLocusUrl',
4611
+ };
4612
+
4613
+ locusInfo.locusParser.workingCopy = {}; // no syncUrl -> full sync
4614
+ sandbox.stub(locusInfo.locusParser, 'resume');
4615
+ sandbox.stub(webex.meetings, 'destroy');
4616
+
4617
+ // Even on the caller-driven (reconnection) path (destroyOnTransientFailure: false), an
4618
+ // application failure must not reject: retrying would re-fetch and re-apply the same
4619
+ // unprocessable DTO, so doLocusSync just resumes the parser and resolves.
4620
+ await locusInfo.doLocusSync(meeting, false, undefined, {
4621
+ destroyOnTransientFailure: false,
4622
+ });
4623
+
4624
+ assert.calledOnceWithExactly(
4625
+ meeting.locusInfo.onFullLocus,
4626
+ 'classic Locus sync',
4627
+ fakeFullLocusDto
4628
+ );
4629
+ assert.notCalled(webex.meetings.destroy);
4630
+ assert.calledOnce(locusInfo.locusParser.resume);
4631
+ });
4632
+ });
4633
+
3833
4634
  describe('edge cases for sync failing', () => {
3834
4635
  const {DESYNC} = LocusDeltaParser.loci;
3835
4636
  const fakeFullLocusDto = {id: 'fake full locus dto'};
@@ -4501,6 +5302,9 @@ describe('plugin-meetings', () => {
4501
5302
  });
4502
5303
 
4503
5304
  describe('#isMeetingActive', () => {
5305
+ beforeEach(() => {
5306
+ webex.internal.newMetrics.submitClientEvent.resetHistory();
5307
+ });
4504
5308
  forEach([_CALL_, _SIP_BRIDGE_, _SPACE_SHARE_], (type) => {
4505
5309
  describe(`type = ${type}`, () => {
4506
5310
  it('sends client event correctly for state = inactive', () => {
@@ -4521,6 +5325,11 @@ describe('plugin-meetings', () => {
4521
5325
  options: {
4522
5326
  meetingId: locusInfo.meetingId,
4523
5327
  },
5328
+ payload: {
5329
+ eventData: {
5330
+ joinInProgress: false,
5331
+ },
5332
+ },
4524
5333
  });
4525
5334
  });
4526
5335
 
@@ -4541,6 +5350,11 @@ describe('plugin-meetings', () => {
4541
5350
  options: {
4542
5351
  meetingId: locusInfo.meetingId,
4543
5352
  },
5353
+ payload: {
5354
+ eventData: {
5355
+ joinInProgress: false,
5356
+ },
5357
+ },
4544
5358
  });
4545
5359
  });
4546
5360
 
@@ -4562,12 +5376,17 @@ describe('plugin-meetings', () => {
4562
5376
  options: {
4563
5377
  meetingId: locusInfo.meetingId,
4564
5378
  },
5379
+ payload: {
5380
+ eventData: {
5381
+ joinInProgress: false,
5382
+ },
5383
+ },
4565
5384
  });
4566
5385
  });
4567
5386
  });
4568
5387
  });
4569
5388
 
4570
- it('sends client event correctly for state = MEETING_INACTIVE_TERMINATING', () => {
5389
+ it('sends client event correctly for state = MEETING_INACTIVE', () => {
4571
5390
  locusInfo.getLocusPartner = sinon.stub().returns({state: MEETING_STATE.STATES.LEFT});
4572
5391
  locusInfo.parsedLocus = {
4573
5392
  fullState: {
@@ -4589,7 +5408,7 @@ describe('plugin-meetings', () => {
4589
5408
  });
4590
5409
  });
4591
5410
 
4592
- it('sends client event correctly for state = FULLSTATE_REMOVED', () => {
5411
+ it('does not send client event when state = INACTIVE and endMeetingReason = BREAKOUT_ENDED', () => {
4593
5412
  locusInfo.getLocusPartner = sinon.stub().returns({state: MEETING_STATE.STATES.LEFT});
4594
5413
  locusInfo.parsedLocus = {
4595
5414
  fullState: {
@@ -4598,16 +5417,127 @@ describe('plugin-meetings', () => {
4598
5417
  };
4599
5418
 
4600
5419
  locusInfo.fullState = {
4601
- removed: true,
5420
+ state: LOCUS.STATE.INACTIVE,
5421
+ endMeetingReason: 'BREAKOUT_ENDED',
4602
5422
  };
4603
5423
 
4604
5424
  locusInfo.isMeetingActive();
4605
5425
 
4606
- assert.calledWith(webex.internal.newMetrics.submitClientEvent, {
4607
- name: 'client.call.remote-ended',
4608
- options: {
4609
- meetingId: locusInfo.meetingId,
5426
+ assert.notCalled(webex.internal.newMetrics.submitClientEvent);
5427
+ });
5428
+
5429
+ it('sends client event correctly for state self removed', () => {
5430
+ locusInfo.emitScoped = sinon.stub();
5431
+ locusInfo.parsedLocus = {
5432
+ fullState: {
5433
+ type: _MEETING_,
4610
5434
  },
5435
+ self: {
5436
+ removed: true,
5437
+ }
5438
+ };
5439
+
5440
+ locusInfo.isMeetingActive();
5441
+
5442
+ assert.notCalled(webex.internal.newMetrics.submitClientEvent);
5443
+ assert.calledOnceWithExactly(
5444
+ locusInfo.emitScoped,
5445
+ {
5446
+ file: 'locus-info',
5447
+ function: 'isMeetingActive',
5448
+ },
5449
+ EVENTS.DESTROY_MEETING,
5450
+ {
5451
+ reason: MEETING_REMOVED_REASON.SELF_REMOVED,
5452
+ shouldLeave: false,
5453
+ }
5454
+ );
5455
+ });
5456
+
5457
+ describe('destroyMeetingSuspended', () => {
5458
+ it('suppresses DESTROY_MEETING for SELF_REMOVED when suspended', () => {
5459
+ locusInfo.emitScoped = sinon.stub();
5460
+ locusInfo.suspendDestroyMeeting(true);
5461
+ locusInfo.parsedLocus = {
5462
+ fullState: {
5463
+ type: _MEETING_,
5464
+ },
5465
+ self: {
5466
+ removed: true,
5467
+ }
5468
+ };
5469
+
5470
+ locusInfo.isMeetingActive();
5471
+
5472
+ assert.notCalled(locusInfo.emitScoped);
5473
+ assert.calledOnceWithExactly(
5474
+ sendBehavioralMetricStub,
5475
+ BEHAVIORAL_METRICS.DESTROY_MEETING_WHILE_SUSPENDED,
5476
+ {
5477
+ meetingId: locusInfo.meetingId,
5478
+ reason: 'SELF_REMOVED',
5479
+ }
5480
+ );
5481
+ });
5482
+
5483
+ it('suppresses DESTROY_MEETING for MEETING_INACTIVE_TERMINATING when suspended', () => {
5484
+ locusInfo.emitScoped = sinon.stub();
5485
+ locusInfo.suspendDestroyMeeting(true);
5486
+ locusInfo.parsedLocus = {
5487
+ fullState: {
5488
+ type: _MEETING_,
5489
+ },
5490
+ };
5491
+ locusInfo.fullState = {
5492
+ state: LOCUS.STATE.INACTIVE,
5493
+ };
5494
+
5495
+ locusInfo.isMeetingActive();
5496
+
5497
+ assert.notCalled(locusInfo.emitScoped);
5498
+ assert.notCalled(webex.internal.newMetrics.submitClientEvent);
5499
+ assert.calledOnceWithExactly(
5500
+ sendBehavioralMetricStub,
5501
+ BEHAVIORAL_METRICS.DESTROY_MEETING_WHILE_SUSPENDED,
5502
+ {
5503
+ meetingId: locusInfo.meetingId,
5504
+ reason: 'MEETING_INACTIVE_TERMINATING',
5505
+ }
5506
+ );
5507
+ });
5508
+
5509
+ [
5510
+ {reason: 'CALL_INACTIVE', setup: () => {
5511
+ locusInfo.parsedLocus = {fullState: {type: _CALL_}};
5512
+ locusInfo.fullState = {state: LOCUS.STATE.INACTIVE};
5513
+ }},
5514
+ {reason: 'PARTNER_LEFT', setup: () => {
5515
+ locusInfo.getLocusPartner = sinon.stub().returns({state: MEETING_STATE.STATES.LEFT});
5516
+ locusInfo.parsedLocus = {fullState: {type: _CALL_}, self: {state: MEETING_STATE.STATES.JOINED}};
5517
+ }},
5518
+ {reason: 'SELF_LEFT', setup: () => {
5519
+ locusInfo.getLocusPartner = sinon.stub().returns({state: MEETING_STATE.STATES.LEFT});
5520
+ locusInfo.parsedLocus = {fullState: {type: _CALL_}, self: {state: MEETING_STATE.STATES.LEFT}};
5521
+ }},
5522
+ ].forEach(({reason, setup}) => {
5523
+ it(`sends joinInProgress=true in client event for ${reason} when suspended`, () => {
5524
+ locusInfo.suspendDestroyMeeting(true);
5525
+ setup();
5526
+
5527
+ locusInfo.isMeetingActive();
5528
+
5529
+ assert.calledWith(webex.internal.newMetrics.submitClientEvent, {
5530
+ name: 'client.call.remote-ended',
5531
+ options: {
5532
+ meetingId: locusInfo.meetingId,
5533
+ },
5534
+ payload: {
5535
+ eventData: {
5536
+ joinInProgress: true,
5537
+ },
5538
+ },
5539
+ });
5540
+ });
4611
5541
  });
4612
5542
  });
4613
5543
  });
@@ -5000,6 +5930,31 @@ describe('plugin-meetings', () => {
5000
5930
  );
5001
5931
  assert.notCalled(getTheLocusToUpdateStub);
5002
5932
  });
5933
+
5934
+ it('should call handleLocusAPIResponse for SDK_LOCUS_FROM_SYNC_MEETINGS when hash tree parsers exist', () => {
5935
+ const fakeLocusUrl = 'http://locus-url.com';
5936
+ const fakeLocus = {url: fakeLocusUrl, fullState: {state: 'ACTIVE'}};
5937
+ const mockHashTreeParser = {
5938
+ handleMessage: sinon.stub(),
5939
+ handleLocusUpdate: sinon.stub(),
5940
+ };
5941
+ locusInfo.hashTreeParsers.set(fakeLocusUrl, {
5942
+ parser: mockHashTreeParser,
5943
+ initializedFromHashTree: true,
5944
+ });
5945
+
5946
+ sinon.stub(locusInfo, 'handleLocusDelta');
5947
+
5948
+ locusInfo.parse(mockMeeting, {
5949
+ eventType: LOCUSEVENT.SDK_LOCUS_FROM_SYNC_MEETINGS,
5950
+ locus: fakeLocus,
5951
+ });
5952
+
5953
+ // should route through handleLocusAPIResponse which passes unwrapped LocusDTO to parser
5954
+ assert.calledOnce(mockHashTreeParser.handleLocusUpdate);
5955
+ assert.notCalled(mockHashTreeParser.handleMessage);
5956
+ assert.notCalled(locusInfo.handleLocusDelta);
5957
+ });
5003
5958
  });
5004
5959
  });
5005
5960
 
@@ -5192,6 +6147,7 @@ describe('plugin-meetings', () => {
5192
6147
  return {
5193
6148
  htMeta: {elementId: {type: 'Self'}},
5194
6149
  data: {
6150
+ deviceUrl,
5195
6151
  devices,
5196
6152
  },
5197
6153
  };