@webex/plugin-meetings 3.10.0-next.9 → 3.10.0-set-bitrate.2

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 (73) hide show
  1. package/dist/breakouts/breakout.js +1 -1
  2. package/dist/breakouts/index.js +1 -1
  3. package/dist/constants.js +11 -3
  4. package/dist/constants.js.map +1 -1
  5. package/dist/hashTree/constants.js +20 -0
  6. package/dist/hashTree/constants.js.map +1 -0
  7. package/dist/hashTree/hashTree.js +515 -0
  8. package/dist/hashTree/hashTree.js.map +1 -0
  9. package/dist/hashTree/hashTreeParser.js +1266 -0
  10. package/dist/hashTree/hashTreeParser.js.map +1 -0
  11. package/dist/hashTree/types.js +22 -0
  12. package/dist/hashTree/types.js.map +1 -0
  13. package/dist/hashTree/utils.js +48 -0
  14. package/dist/hashTree/utils.js.map +1 -0
  15. package/dist/interpretation/index.js +1 -1
  16. package/dist/interpretation/siLanguage.js +1 -1
  17. package/dist/locus-info/index.js +550 -130
  18. package/dist/locus-info/index.js.map +1 -1
  19. package/dist/locus-info/types.js +7 -0
  20. package/dist/locus-info/types.js.map +1 -0
  21. package/dist/meeting/index.js +100 -50
  22. package/dist/meeting/index.js.map +1 -1
  23. package/dist/meeting/util.js +1 -0
  24. package/dist/meeting/util.js.map +1 -1
  25. package/dist/meetings/index.js +112 -70
  26. package/dist/meetings/index.js.map +1 -1
  27. package/dist/metrics/constants.js +3 -1
  28. package/dist/metrics/constants.js.map +1 -1
  29. package/dist/reachability/clusterReachability.js +44 -358
  30. package/dist/reachability/clusterReachability.js.map +1 -1
  31. package/dist/reachability/reachability.types.js +14 -1
  32. package/dist/reachability/reachability.types.js.map +1 -1
  33. package/dist/reachability/reachabilityPeerConnection.js +445 -0
  34. package/dist/reachability/reachabilityPeerConnection.js.map +1 -0
  35. package/dist/types/constants.d.ts +26 -21
  36. package/dist/types/hashTree/constants.d.ts +8 -0
  37. package/dist/types/hashTree/hashTree.d.ts +129 -0
  38. package/dist/types/hashTree/hashTreeParser.d.ts +260 -0
  39. package/dist/types/hashTree/types.d.ts +27 -0
  40. package/dist/types/hashTree/utils.d.ts +9 -0
  41. package/dist/types/locus-info/index.d.ts +97 -80
  42. package/dist/types/locus-info/types.d.ts +54 -0
  43. package/dist/types/meeting/index.d.ts +23 -9
  44. package/dist/types/meetings/index.d.ts +9 -2
  45. package/dist/types/metrics/constants.d.ts +2 -0
  46. package/dist/types/reachability/clusterReachability.d.ts +10 -88
  47. package/dist/types/reachability/reachability.types.d.ts +12 -1
  48. package/dist/types/reachability/reachabilityPeerConnection.d.ts +111 -0
  49. package/dist/webinar/index.js +1 -1
  50. package/package.json +23 -22
  51. package/src/constants.ts +13 -1
  52. package/src/hashTree/constants.ts +9 -0
  53. package/src/hashTree/hashTree.ts +463 -0
  54. package/src/hashTree/hashTreeParser.ts +1161 -0
  55. package/src/hashTree/types.ts +32 -0
  56. package/src/hashTree/utils.ts +42 -0
  57. package/src/locus-info/index.ts +597 -154
  58. package/src/locus-info/types.ts +53 -0
  59. package/src/meeting/index.ts +88 -28
  60. package/src/meeting/util.ts +1 -0
  61. package/src/meetings/index.ts +104 -51
  62. package/src/metrics/constants.ts +2 -0
  63. package/src/reachability/clusterReachability.ts +50 -347
  64. package/src/reachability/reachability.types.ts +15 -1
  65. package/src/reachability/reachabilityPeerConnection.ts +416 -0
  66. package/test/unit/spec/hashTree/hashTree.ts +655 -0
  67. package/test/unit/spec/hashTree/hashTreeParser.ts +1532 -0
  68. package/test/unit/spec/hashTree/utils.ts +103 -0
  69. package/test/unit/spec/locus-info/index.js +795 -16
  70. package/test/unit/spec/meeting/index.js +120 -20
  71. package/test/unit/spec/meeting/utils.js +77 -0
  72. package/test/unit/spec/meetings/index.js +71 -26
  73. package/test/unit/spec/reachability/clusterReachability.ts +281 -138
@@ -12,6 +12,7 @@ import EmbeddedAppsUtils from '@webex/plugin-meetings/src/locus-info/embeddedApp
12
12
  import MediaSharesUtils from '@webex/plugin-meetings/src/locus-info//mediaSharesUtils';
13
13
  import LocusDeltaParser from '@webex/plugin-meetings/src/locus-info/parser';
14
14
  import Metrics from '@webex/plugin-meetings/src/metrics';
15
+ import * as HashTreeParserModule from '@webex/plugin-meetings/src/hashTree/hashTreeParser';
15
16
 
16
17
  import {
17
18
  LOCUSINFO,
@@ -28,6 +29,7 @@ import {
28
29
  } from '../../../../src/constants';
29
30
 
30
31
  import {self, selfWithInactivity} from './selfConstant';
32
+ import { MEETING_REMOVED_REASON } from '@webex/plugin-meetings/src/constants';
31
33
 
32
34
  describe('plugin-meetings', () => {
33
35
  describe('LocusInfo index', () => {
@@ -77,6 +79,715 @@ describe('plugin-meetings', () => {
77
79
  sinon.restore();
78
80
  });
79
81
 
82
+ describe('#initialSetup', () => {
83
+ let HashTreeParserStub;
84
+ let mockHashTreeParser;
85
+ let updateLocusCacheStub;
86
+ let updateLocusInfoStub;
87
+ let isNewFullLocusStub;
88
+
89
+ beforeEach(() => {
90
+ mockHashTreeParser = {
91
+ initializeFromMessage: sinon.stub().resolves(),
92
+ initializeFromGetLociResponse: sinon.stub().resolves(),
93
+ };
94
+ HashTreeParserStub = sinon
95
+ .stub(HashTreeParserModule, 'default')
96
+ .returns(mockHashTreeParser);
97
+ updateLocusCacheStub = sinon.stub(locusInfo, 'updateLocusCache');
98
+ updateLocusInfoStub = sinon.stub(locusInfo, 'updateLocusInfo');
99
+ isNewFullLocusStub = sinon.stub(locusInfo.locusParser, 'isNewFullLocus').returns(true);
100
+ });
101
+
102
+ afterEach(() => {
103
+ sinon.restore();
104
+ });
105
+
106
+ const createHashTreeMessage = (visibleDataSets) => ({
107
+ locusStateElements: [
108
+ {
109
+ htMeta: {elementId: {type: 'self'}},
110
+ data: {visibleDataSets},
111
+ },
112
+ ],
113
+ dataSets: [{name: 'dataset1', url: 'test-url'}],
114
+ });
115
+
116
+ const createLocusWithVisibleDataSets = (visibleDataSets) => ({
117
+ self: {visibleDataSets},
118
+ participants: [],
119
+ links: {
120
+ resources: {
121
+ visibleDataSets: {url: 'http://visible-datasets-url.com'},
122
+ },
123
+ },
124
+ });
125
+
126
+ it('should initialize the hash tree parser when triggered from a hash tree locus message', async () => {
127
+ const visibleDataSets = ['dataset1', 'dataset2'];
128
+ const hashTreeMessage = createHashTreeMessage(visibleDataSets);
129
+
130
+ await locusInfo.initialSetup({
131
+ trigger: 'locus-message',
132
+ hashTreeMessage,
133
+ });
134
+
135
+ assert.calledOnceWithExactly(
136
+ HashTreeParserStub,
137
+ sinon.match({
138
+ initialLocus: {
139
+ locus: {self: {visibleDataSets}},
140
+ dataSets: [],
141
+ },
142
+ webexRequest: sinon.match.func,
143
+ locusInfoUpdateCallback: sinon.match.func,
144
+ debugId: sinon.match.string,
145
+ })
146
+ );
147
+ assert.calledOnceWithExactly(mockHashTreeParser.initializeFromMessage, hashTreeMessage);
148
+ assert.notCalled(updateLocusCacheStub);
149
+ assert.notCalled(updateLocusInfoStub);
150
+ assert.isTrue(locusInfo.emitChange);
151
+ });
152
+
153
+ it('should not initialize the hash tree when triggered from a non-hash tree locus message', async () => {
154
+ const locus = {url: 'http://locus-url.com', participants: []};
155
+
156
+ await locusInfo.initialSetup({
157
+ trigger: 'locus-message',
158
+ locus,
159
+ });
160
+
161
+ assert.notCalled(HashTreeParserStub);
162
+ assert.notCalled(mockHashTreeParser.initializeFromMessage);
163
+ assert.calledOnceWithExactly(updateLocusCacheStub, locus);
164
+ assert.calledOnce(updateLocusInfoStub);
165
+ assert.isTrue(locusInfo.emitChange);
166
+ });
167
+
168
+ it('should initialize the hash tree parser correctly when triggered from a join response containing datasets', async () => {
169
+ const visibleDataSets = ['dataset1', 'dataset2'];
170
+ const locus = createLocusWithVisibleDataSets(visibleDataSets);
171
+ const dataSets = [{name: 'dataset1', url: 'http://dataset-url.com'}];
172
+
173
+ await locusInfo.initialSetup({
174
+ trigger: 'join-response',
175
+ locus,
176
+ dataSets,
177
+ });
178
+
179
+ assert.calledOnceWithExactly(
180
+ HashTreeParserStub,
181
+ sinon.match({
182
+ initialLocus: {
183
+ locus,
184
+ dataSets,
185
+ },
186
+ webexRequest: sinon.match.func,
187
+ locusInfoUpdateCallback: sinon.match.func,
188
+ debugId: sinon.match.string,
189
+ })
190
+ );
191
+ assert.calledOnceWithExactly(updateLocusCacheStub, locus);
192
+ assert.calledOnce(updateLocusInfoStub);
193
+ assert.isTrue(locusInfo.emitChange);
194
+ });
195
+
196
+ it('should do normal (classic) initialization when triggered from a join response without datasets', async () => {
197
+ const locus = {url: 'http://locus-url.com', participants: []};
198
+
199
+ await locusInfo.initialSetup({
200
+ trigger: 'join-response',
201
+ locus,
202
+ });
203
+
204
+ assert.notCalled(HashTreeParserStub);
205
+ assert.calledOnceWithExactly(updateLocusCacheStub, locus);
206
+ assert.calledOnce(updateLocusInfoStub);
207
+ assert.isTrue(locusInfo.emitChange);
208
+ });
209
+
210
+ it('should initialize the hash tree parser correctly when triggered from a get loci response containing visible datasets', async () => {
211
+ const visibleDataSets = ['dataset1', 'dataset2'];
212
+ const locus = createLocusWithVisibleDataSets(visibleDataSets);
213
+
214
+ await locusInfo.initialSetup({
215
+ trigger: 'get-loci-response',
216
+ locus,
217
+ });
218
+
219
+ assert.calledOnceWithExactly(
220
+ HashTreeParserStub,
221
+ sinon.match({
222
+ initialLocus: {
223
+ locus: {self: {visibleDataSets}},
224
+ dataSets: [],
225
+ },
226
+ webexRequest: sinon.match.func,
227
+ locusInfoUpdateCallback: sinon.match.func,
228
+ debugId: sinon.match.string,
229
+ })
230
+ );
231
+ assert.calledOnceWithExactly(mockHashTreeParser.initializeFromGetLociResponse, locus);
232
+ assert.notCalled(updateLocusCacheStub);
233
+ assert.notCalled(updateLocusInfoStub);
234
+ assert.isTrue(locusInfo.emitChange);
235
+ });
236
+
237
+ it('should do normal (classic) initialization when triggered from a get loci response without visible datasets', async () => {
238
+ const locus = {url: 'http://locus-url.com', participants: []};
239
+
240
+ await locusInfo.initialSetup({
241
+ trigger: 'get-loci-response',
242
+ locus,
243
+ });
244
+
245
+ assert.notCalled(HashTreeParserStub);
246
+ assert.notCalled(mockHashTreeParser.initializeFromGetLociResponse);
247
+ assert.calledOnceWithExactly(updateLocusCacheStub, locus);
248
+ assert.calledOnce(updateLocusInfoStub);
249
+ assert.isTrue(locusInfo.emitChange);
250
+ });
251
+
252
+ describe('should setup correct locusInfoUpdateCallback when creating HashTreeParser', () => {
253
+ const OBJECTS_UPDATED = HashTreeParserModule.LocusInfoUpdateType.OBJECTS_UPDATED;
254
+ const MEETING_ENDED = HashTreeParserModule.LocusInfoUpdateType.MEETING_ENDED;
255
+
256
+ let locusInfoUpdateCallback;
257
+ let onDeltaLocusStub;
258
+ let expectedLocusInfo;
259
+
260
+ beforeEach(async () => {
261
+ onDeltaLocusStub = sinon.stub(locusInfo, 'onDeltaLocus');
262
+
263
+ await locusInfo.initialSetup({
264
+ trigger: 'locus-message',
265
+ hashTreeMessage: {
266
+ locusStateElements: [
267
+ {
268
+ htMeta: {elementId: {type: 'self'}},
269
+ data: {visibleDataSets: ['dataset1']},
270
+ },
271
+ ],
272
+ dataSets: [{name: 'dataset1', url: 'test-url'}],
273
+ },
274
+ });
275
+
276
+ locusInfoUpdateCallback = HashTreeParserStub.firstCall.args[0].locusInfoUpdateCallback;
277
+
278
+ assert.isDefined(locusInfoUpdateCallback);
279
+
280
+ // setup fake initial locusInfo state
281
+ locusInfo.controls = {id: 'fake-controls'};
282
+ locusInfo.fullState = {id: 'fake-full-state'};
283
+ locusInfo.host = {id: 'fake-host'};
284
+ locusInfo.info = {id: 'fake-info'};
285
+ locusInfo.links = {id: 'fake-links'};
286
+ locusInfo.mediaShares = [
287
+ {
288
+ id: 'fake-media-share-1',
289
+ htMeta: {elementId: {type: 'mediashare', id: 'fake-ht-mediaShare-1', version: 1}},
290
+ },
291
+ {
292
+ id: 'fake-media-share-2',
293
+ htMeta: {elementId: {type: 'mediashare', id: 'fake-ht-mediaShare-2', version: 1}},
294
+ },
295
+ ];
296
+ locusInfo.meetings = {id: 'fake-meetings'};
297
+ locusInfo.participants = [
298
+ {id: 'fake-participant-1', name: 'Participant One'},
299
+ {id: 'fake-participant-2', name: 'Participant Two'},
300
+ ];
301
+ locusInfo.hashTreeObjectId2ParticipantId.set(
302
+ 'fake-ht-participant-1',
303
+ 'fake-participant-1'
304
+ );
305
+ locusInfo.hashTreeObjectId2ParticipantId.set(
306
+ 'fake-ht-participant-2',
307
+ 'fake-participant-2'
308
+ );
309
+ locusInfo.replaces = {id: 'fake-replaces'};
310
+ locusInfo.self = {id: 'fake-self'};
311
+ locusInfo.url = 'fake-locus-url';
312
+ locusInfo.htMeta = {elementId: {type: 'locus', id: 'fake-ht-locus-id', version: 1}};
313
+
314
+ // setup the default expected locus info state that each test builds upon
315
+ expectedLocusInfo = {
316
+ controls: {id: 'fake-controls'},
317
+ fullState: {id: 'fake-full-state'},
318
+ host: {id: 'fake-host'},
319
+ info: {id: 'fake-info'},
320
+ links: {id: 'fake-links'},
321
+ mediaShares: [
322
+ {
323
+ id: 'fake-media-share-1',
324
+ htMeta: {elementId: {type: 'mediashare', id: 'fake-ht-mediaShare-1', version: 1}},
325
+ },
326
+ {
327
+ id: 'fake-media-share-2',
328
+ htMeta: {elementId: {type: 'mediashare', id: 'fake-ht-mediaShare-2', version: 1}},
329
+ },
330
+ ],
331
+ meetings: {id: 'fake-meetings'},
332
+ jsSdkMeta: {removedParticipantIds: []},
333
+ participants: [], // empty means there were no participant updates
334
+ replaces: {id: 'fake-replaces'},
335
+ self: {id: 'fake-self'},
336
+ url: 'fake-locus-url',
337
+ htMeta: {elementId: {type: 'locus', id: 'fake-ht-locus-id', version: 1}},
338
+ sequence: null, // not relevant for hash trees, so should remain null
339
+ syncUrl: undefined, // not relevant for hash trees, so should remain undefined
340
+ };
341
+ });
342
+
343
+ it('should process locus update correctly when called with updated SELF', () => {
344
+ const newSelf = {
345
+ id: 'new-self',
346
+ visibleDataSets: ['dataset1', 'dataset2'],
347
+ };
348
+
349
+ // simulate an update from the HashTreeParser (normally this would be triggered by incoming locus messages)
350
+ locusInfoUpdateCallback(OBJECTS_UPDATED, {
351
+ updatedObjects: [{htMeta: {elementId: {type: 'self'}}, data: newSelf}],
352
+ });
353
+
354
+ // check onDeltaLocus() was called with correctly updated locus info
355
+ assert.calledOnceWithExactly(onDeltaLocusStub, {
356
+ ...expectedLocusInfo,
357
+ self: newSelf,
358
+ });
359
+ });
360
+
361
+ it('should process locus update correctly when called with updated SELF (webinar non-attendee)', () => {
362
+ const newSelf = {
363
+ id: 'new-self',
364
+ visibleDataSets: ['dataset1', 'dataset2'],
365
+ controls: {
366
+ role: {
367
+ roles: [
368
+ {type: 'PANELIST', hasRole: true},
369
+ {type: 'ATTENDEE', hasRole: false},
370
+ ],
371
+ },
372
+ },
373
+ };
374
+ locusInfo.info.isWebinar = true;
375
+
376
+ // simulate an update from the HashTreeParser (normally this would be triggered by incoming locus messages)
377
+ locusInfoUpdateCallback(OBJECTS_UPDATED, {
378
+ updatedObjects: [{htMeta: {elementId: {type: 'self'}}, data: newSelf}],
379
+ });
380
+
381
+ // check onDeltaLocus() was called with correctly updated locus info
382
+ // without any participant generated
383
+ assert.calledOnceWithExactly(onDeltaLocusStub, {
384
+ ...expectedLocusInfo,
385
+ info: {
386
+ ...expectedLocusInfo.info,
387
+ isWebinar: true,
388
+ },
389
+ self: newSelf,
390
+ });
391
+ });
392
+
393
+ it('should generate a participant when called with updated SELF for webinar attendee', () => {
394
+ const newSelf = {
395
+ id: 'new-self',
396
+ visibleDataSets: ['dataset1', 'dataset2'],
397
+ controls: {
398
+ role: {
399
+ roles: [
400
+ {type: 'something else - should be ignored', hasRole: true},
401
+ {type: 'ATTENDEE', hasRole: true},
402
+ ],
403
+ },
404
+ },
405
+ };
406
+
407
+ locusInfo.info.isWebinar = true;
408
+
409
+ // simulate an update from the HashTreeParser (normally this would be triggered by incoming locus messages)
410
+ locusInfoUpdateCallback(OBJECTS_UPDATED, {
411
+ updatedObjects: [{htMeta: {elementId: {type: 'self'}}, data: newSelf}],
412
+ });
413
+
414
+ // check onDeltaLocus() was called with correctly updated locus info
415
+ // that contains a participant created from self
416
+ assert.calledOnceWithExactly(onDeltaLocusStub, {
417
+ ...expectedLocusInfo,
418
+ info: {
419
+ ...expectedLocusInfo.info,
420
+ isWebinar: true,
421
+ },
422
+ self: newSelf,
423
+ participants: [
424
+ {
425
+ ...newSelf,
426
+ },
427
+ ],
428
+ });
429
+ });
430
+
431
+ it('should process locus update correctly when called with updated fullState', () => {
432
+ const newFullState = {
433
+ id: 'new-fullState',
434
+ visibleDataSets: ['dataset1', 'dataset2'],
435
+ };
436
+
437
+ // simulate an update from the HashTreeParser (normally this would be triggered by incoming locus messages)
438
+ locusInfoUpdateCallback(OBJECTS_UPDATED, {
439
+ updatedObjects: [{htMeta: {elementId: {type: 'fullState'}}, data: newFullState}],
440
+ });
441
+
442
+ // check onDeltaLocus() was called with correctly updated locus info
443
+ assert.calledOnceWithExactly(onDeltaLocusStub, {
444
+ ...expectedLocusInfo,
445
+ fullState: newFullState,
446
+ });
447
+ });
448
+
449
+ it('should process locus update correctly when called with updated info', () => {
450
+ const newInfo = {
451
+ id: 'new-info',
452
+ visibleDataSets: ['dataset1', 'dataset2'],
453
+ };
454
+
455
+ // simulate an update from the HashTreeParser (normally this would be triggered by incoming locus messages)
456
+ locusInfoUpdateCallback(OBJECTS_UPDATED, {
457
+ updatedObjects: [{htMeta: {elementId: {type: 'info'}}, data: newInfo}],
458
+ });
459
+
460
+ // check onDeltaLocus() was called with correctly updated locus info
461
+ assert.calledOnceWithExactly(onDeltaLocusStub, {
462
+ ...expectedLocusInfo,
463
+ info: newInfo,
464
+ });
465
+ });
466
+
467
+ it('should process locus update correctly when called with updated links', () => {
468
+ const newLinks = {
469
+ id: 'new-links',
470
+ visibleDataSets: ['dataset1', 'dataset2'],
471
+ };
472
+
473
+ // simulate an update from the HashTreeParser (normally this would be triggered by incoming locus messages)
474
+ locusInfoUpdateCallback(OBJECTS_UPDATED, {
475
+ updatedObjects: [{htMeta: {elementId: {type: 'links'}}, data: newLinks}],
476
+ });
477
+
478
+ // check onDeltaLocus() was called with correctly updated locus info
479
+ assert.calledOnceWithExactly(onDeltaLocusStub, {
480
+ ...expectedLocusInfo,
481
+ links: newLinks,
482
+ });
483
+ });
484
+
485
+ it('should process locus update correctly when called with updated LOCUS object', () => {
486
+ // setup new updated locus that has many things missing
487
+ const newLocusHtMeta = {elementId: {type: 'locus', version: 42}};
488
+ const newLocus = {
489
+ controls: 'new-controls',
490
+ host: 'new-host',
491
+ htMeta: newLocusHtMeta,
492
+ };
493
+
494
+ // simulate an update from the HashTreeParser (normally this would be triggered by incoming locus messages)
495
+ locusInfoUpdateCallback(OBJECTS_UPDATED, {
496
+ updatedObjects: [{htMeta: newLocusHtMeta, data: newLocus}],
497
+ });
498
+
499
+ // check onDeltaLocus() was called with correctly updated locus info
500
+ assert.calledOnceWithExactly(onDeltaLocusStub, {
501
+ // these fields are not part of Locus object, so should keep their old values:
502
+ info: {id: 'fake-info'},
503
+ fullState: {id: 'fake-full-state'},
504
+ self: {id: 'fake-self'},
505
+ links: { id: 'fake-links' },
506
+ mediaShares: expectedLocusInfo.mediaShares,
507
+ // and now the new fields
508
+ ...newLocus,
509
+ htMeta: newLocusHtMeta,
510
+ participants: [], // empty means there were no participant updates
511
+ jsSdkMeta: {removedParticipantIds: []}, // no participants were removed
512
+ });
513
+ });
514
+
515
+ // this test is checking that we cope with an edge case if Locus
516
+ // sends us something that they shouldn't
517
+ it('should process locus update correctly when called with updated LOCUS object that contains info/fullState/self/participants etc', () => {
518
+ // setup new updated locus that has many things missing
519
+ const newLocusHtMeta = {elementId: {type: 'locus', version: 42}};
520
+ const newLocus = {
521
+ controls: 'new-controls',
522
+ host: 'new-host',
523
+ htMeta: newLocusHtMeta,
524
+ };
525
+
526
+ // simulate an update from the HashTreeParser (normally this would be triggered by incoming locus messages)
527
+ locusInfoUpdateCallback(OBJECTS_UPDATED, {
528
+ updatedObjects: [
529
+ {
530
+ htMeta: newLocusHtMeta,
531
+ data: {
532
+ ...newLocus,
533
+ // all these fields below should be ignored and not override the existing ones in our "old" Locus
534
+ info: 'new-info',
535
+ fullState: 'new-fullState',
536
+ self: 'new-self',
537
+ participants: 'new-participants',
538
+ mediaShares: 'new-mediaShares',
539
+ },
540
+ },
541
+ ],
542
+ });
543
+
544
+ // check onDeltaLocus() was called with correctly updated locus info
545
+ // with old values for the fields that should be ignored (like "info" or "fullState")
546
+ assert.calledOnceWithExactly(onDeltaLocusStub, {
547
+ // these fields have the "old" values:
548
+ info: {id: 'fake-info'},
549
+ fullState: {id: 'fake-full-state'},
550
+ self: {id: 'fake-self'},
551
+ links: { id: 'fake-links' },
552
+ mediaShares: expectedLocusInfo.mediaShares,
553
+ participants: [], // empty means there were no participant updates
554
+ jsSdkMeta: {removedParticipantIds: []}, // no participants were removed
555
+ ...newLocus,
556
+ htMeta: newLocusHtMeta,
557
+ });
558
+ });
559
+
560
+ it('should process locus update correctly when called with removed LOCUS object followed by updated LOCUS object', () => {
561
+ // setup new updated locus that has many things missing
562
+ const newLocusHtMeta = {elementId: {type: 'locus', version: 99}};
563
+ const newLocus = {
564
+ info: 'new-info',
565
+ links: 'new-links',
566
+ htMeta: newLocusHtMeta,
567
+ };
568
+
569
+ // simulate an update from the HashTreeParser (normally this would be triggered by incoming locus messages)
570
+ locusInfoUpdateCallback(OBJECTS_UPDATED, {
571
+ updatedObjects: [
572
+ // first, a removal of LOCUS object
573
+ {htMeta: {elementId: {type: 'locus'}}, data: null},
574
+ // followed by an update of LOCUS object
575
+ {htMeta: newLocusHtMeta, data: newLocus},
576
+ ],
577
+ });
578
+
579
+ // check onDeltaLocus() was called with correctly updated locus info
580
+ assert.calledOnceWithExactly(onDeltaLocusStub, {
581
+ // these fields are not part of Locus object, so should keep their old values:
582
+ info: {id: 'fake-info'},
583
+ fullState: {id: 'fake-full-state'},
584
+ self: {id: 'fake-self'},
585
+ links: {id: 'fake-links'},
586
+ mediaShares: expectedLocusInfo.mediaShares,
587
+ // and now the new fields
588
+ ...newLocus,
589
+ htMeta: newLocusHtMeta,
590
+ participants: [], // empty means there were no participant updates
591
+ jsSdkMeta: {removedParticipantIds: []}, // no participants were removed
592
+ });
593
+ });
594
+
595
+ it('should send a metric if unsupported sequence of LOCUS object updates occurs (update followed by removal)', () => {
596
+ const newLocus = {
597
+ info: 'new-info',
598
+ };
599
+ const newLocusHtMeta = {elementId: {type: 'locus', version: 99}};
600
+
601
+ // simulate an update from the HashTreeParser (normally this would be triggered by incoming locus messages)
602
+ locusInfoUpdateCallback(OBJECTS_UPDATED, {
603
+ updatedObjects: [
604
+ // first, an update
605
+ {htMeta: newLocusHtMeta, data: newLocus},
606
+ // followed by removal
607
+ {htMeta: {elementId: {type: 'locus'}}, data: null},
608
+ ],
609
+ });
610
+
611
+ assert.calledWith(
612
+ sendBehavioralMetricStub,
613
+ 'js_sdk_locus_hash_tree_unsupported_operation',
614
+ {
615
+ locusUrl: 'fake-locus-url',
616
+ message: 'LOCUS object update followed by removal',
617
+ }
618
+ );
619
+ });
620
+
621
+ it('should send a metric if unsupported sequence of LOCUS object updates occurs (multiple updates)', () => {
622
+ const newLocus1 = {
623
+ info: 'new-info-1',
624
+ };
625
+ const newLocus2 = {
626
+ info: 'new-info-2',
627
+ url: 'new-url-2',
628
+ };
629
+
630
+ // simulate an update from the HashTreeParser (normally this would be triggered by incoming locus messages)
631
+ locusInfoUpdateCallback(OBJECTS_UPDATED, {
632
+ updatedObjects: [
633
+ // first, an update
634
+ {htMeta: {elementId: {type: 'locus'}}, data: newLocus1},
635
+ // followed by another update
636
+ {htMeta: {elementId: {type: 'locus'}}, data: newLocus2},
637
+ ],
638
+ });
639
+
640
+ assert.calledWith(
641
+ sendBehavioralMetricStub,
642
+ 'js_sdk_locus_hash_tree_unsupported_operation',
643
+ {
644
+ locusUrl: 'new-url-2',
645
+ message: 'multiple LOCUS object updates',
646
+ }
647
+ );
648
+ });
649
+
650
+ it('should process locus update correctly when called with added/updated/removed PARTICIPANT objects', () => {
651
+ const newParticipant = {
652
+ id: 'fake-participant-3',
653
+ name: 'New Participant',
654
+ };
655
+ const updatedParticipant2 = {
656
+ id: 'fake-participant-2',
657
+ name: 'Updated Participant Two',
658
+ };
659
+ // simulate an update from the HashTreeParser (normally this would be triggered by incoming locus messages)
660
+ // with 1 participant added, 1 updated, and 1 removed
661
+ locusInfoUpdateCallback(OBJECTS_UPDATED, {
662
+ updatedObjects: [
663
+ {htMeta: {elementId: {type: 'participant', id: 'fake-ht-participant-1'}}, data: null},
664
+ {
665
+ htMeta: {elementId: {type: 'participant', id: 'fake-ht-participant-3'}},
666
+ data: newParticipant,
667
+ },
668
+ {
669
+ htMeta: {elementId: {type: 'participant', id: 'fake-ht-participant-2'}},
670
+ data: updatedParticipant2,
671
+ },
672
+ ],
673
+ });
674
+
675
+ // check onDeltaLocus() was called with correctly updated locus info
676
+ assert.calledOnceWithExactly(onDeltaLocusStub, {
677
+ ...expectedLocusInfo,
678
+ participants: [newParticipant, updatedParticipant2],
679
+ jsSdkMeta: {removedParticipantIds: ['fake-participant-1']},
680
+ });
681
+ // and that the hashTreeObjectId2ParticipantId map was updated correctly
682
+ assert.isUndefined(locusInfo.hashTreeObjectId2ParticipantId.get('fake-ht-participant-1'));
683
+ assert.equal(
684
+ locusInfo.hashTreeObjectId2ParticipantId.get('fake-ht-participant-2'),
685
+ 'fake-participant-2'
686
+ );
687
+ assert.equal(
688
+ locusInfo.hashTreeObjectId2ParticipantId.get('fake-ht-participant-3'),
689
+ 'fake-participant-3'
690
+ );
691
+ });
692
+
693
+ it('should process locus update correctly when called with updated MEDIASHARE objects', () => {
694
+ const newMediaShare = {
695
+ id: 'new-mediaShare-3',
696
+ htMeta: {elementId: {type: 'mediashare', id: 'fake-ht-mediaShare-3', version: 100}},
697
+ };
698
+ const updatedMediaShare2 = {
699
+ id: 'fake-media-share-2',
700
+ someNewProp: 'newValue',
701
+ htMeta: {elementId: {type: 'mediashare', id: 'fake-ht-mediaShare-2', version: 100}},
702
+ };
703
+ // simulate an update from the HashTreeParser (normally this would be triggered by incoming locus messages)
704
+ // with 1 participant added, 1 updated, and 1 removed
705
+ locusInfoUpdateCallback(OBJECTS_UPDATED, {
706
+ updatedObjects: [
707
+ {htMeta: {elementId: {type: 'mediashare', id: 'fake-ht-mediaShare-1'}}, data: null},
708
+ {
709
+ htMeta: {elementId: {type: 'mediashare', id: 'fake-ht-mediaShare-2'}},
710
+ data: updatedMediaShare2,
711
+ },
712
+ {
713
+ htMeta: {elementId: {type: 'mediashare', id: 'fake-ht-mediaShare-3'}},
714
+ data: newMediaShare,
715
+ },
716
+ ],
717
+ });
718
+
719
+ // check onDeltaLocus() was called with correctly updated locus info
720
+ assert.calledOnceWithExactly(onDeltaLocusStub, {
721
+ ...expectedLocusInfo,
722
+ mediaShares: [updatedMediaShare2, newMediaShare],
723
+ });
724
+ });
725
+
726
+ it('should process locus update correctly when called with a combination of various updated objects', () => {
727
+ const newSelf = {
728
+ id: 'new-self',
729
+ visibleDataSets: ['dataset1', 'dataset2'],
730
+ };
731
+ const updatedMediaShare2 = {
732
+ id: 'fake-media-share-2',
733
+ someNewProp: 'newValue',
734
+ htMeta: {elementId: {type: 'mediashare', id: 'fake-ht-mediaShare-2', version: 100}},
735
+ };
736
+ const updatedParticipant2 = {
737
+ id: 'fake-participant-2',
738
+ name: 'Updated Participant Two',
739
+ };
740
+
741
+ // simulate an update from the HashTreeParser (normally this would be triggered by incoming locus messages)
742
+ locusInfoUpdateCallback(OBJECTS_UPDATED, {
743
+ updatedObjects: [
744
+ {
745
+ htMeta: {elementId: {type: 'mediashare', id: 'fake-ht-mediaShare-2'}},
746
+ data: updatedMediaShare2,
747
+ },
748
+ {htMeta: {elementId: {type: 'self'}}, data: newSelf},
749
+ {
750
+ htMeta: {elementId: {type: 'participant', id: 'fake-ht-participant-2'}},
751
+ data: updatedParticipant2,
752
+ },
753
+ ],
754
+ });
755
+
756
+ // check onDeltaLocus() was called with correctly updated locus info
757
+ assert.calledOnceWithExactly(onDeltaLocusStub, {
758
+ ...expectedLocusInfo,
759
+ mediaShares: [
760
+ {
761
+ id: 'fake-media-share-1',
762
+ htMeta: {elementId: {type: 'mediashare', id: 'fake-ht-mediaShare-1', version: 1}},
763
+ },
764
+ updatedMediaShare2,
765
+ ],
766
+ participants: [updatedParticipant2],
767
+ self: newSelf,
768
+ });
769
+ });
770
+
771
+ it('should handle MEETING_ENDED correctly', () => {
772
+ const fakeMeeting = {id: 'fake-meeting-from-collection'};
773
+ const collectionGetStub = sinon
774
+ .stub(locusInfo.webex.meetings.meetingCollection, 'get')
775
+ .returns(fakeMeeting);
776
+ const destroyStub = sinon.stub(locusInfo.webex.meetings, 'destroy');
777
+
778
+ // simulate an update from the HashTreeParser (normally this would be triggered by incoming locus messages)
779
+ locusInfoUpdateCallback(MEETING_ENDED);
780
+
781
+ assert.calledOnceWithExactly(collectionGetStub, locusInfo.meetingId);
782
+ assert.calledOnceWithExactly(
783
+ destroyStub,
784
+ fakeMeeting,
785
+ MEETING_REMOVED_REASON.SELF_REMOVED
786
+ );
787
+ });
788
+ });
789
+ });
790
+
80
791
  describe('#updateControls', () => {
81
792
  let newControls;
82
793
 
@@ -2041,7 +2752,7 @@ describe('plugin-meetings', () => {
2041
2752
  });
2042
2753
 
2043
2754
  describe('#handleLocusAPIResponse', () => {
2044
- it('calls handleLocusDelta', () => {
2755
+ it('calls handleLocusDelta when we are not using hash trees', () => {
2045
2756
  const fakeLocus = {eventType: LOCUSEVENT.DIFFERENCE};
2046
2757
 
2047
2758
  sinon.stub(locusInfo, 'handleLocusDelta');
@@ -2050,6 +2761,23 @@ describe('plugin-meetings', () => {
2050
2761
 
2051
2762
  assert.calledWith(locusInfo.handleLocusDelta, fakeLocus, mockMeeting);
2052
2763
  });
2764
+ it('calls hash tree parser when we are using hash trees', () => {
2765
+ const fakeLocus = {eventType: LOCUSEVENT.DIFFERENCE};
2766
+ const fakeDataSets = [{name: 'dataset1', url: 'http://test.com'}];
2767
+ const responseBody = {locus: fakeLocus, dataSets: fakeDataSets};
2768
+
2769
+ // Create a mock hash tree parser
2770
+ const mockHashTreeParser = {
2771
+ handleLocusUpdate: sinon.stub(),
2772
+ };
2773
+ locusInfo.hashTreeParser = mockHashTreeParser;
2774
+
2775
+ sinon.stub(locusInfo, 'onDeltaLocus');
2776
+
2777
+ locusInfo.handleLocusAPIResponse(mockMeeting, responseBody);
2778
+
2779
+ assert.calledOnceWithExactly(mockHashTreeParser.handleLocusUpdate, responseBody);
2780
+ });
2053
2781
  });
2054
2782
 
2055
2783
  describe('#LocusDeltaEvents', () => {
@@ -2122,8 +2850,7 @@ describe('plugin-meetings', () => {
2122
2850
  callOrder.push("updateMeetingInfo");
2123
2851
  });
2124
2852
  sinon.stub(locusInfo, "updateMediaShares");
2125
- sinon.stub(locusInfo, "updateParticipantsUrl");
2126
- sinon.stub(locusInfo, "updateReplace");
2853
+ sinon.stub(locusInfo, "updateReplaces");
2127
2854
  sinon.stub(locusInfo, "updateSelf");
2128
2855
  sinon.stub(locusInfo, "updateLocusUrl").callsFake(() => {
2129
2856
  callOrder.push("updateLocusUrl");
@@ -2131,10 +2858,8 @@ describe('plugin-meetings', () => {
2131
2858
  sinon.stub(locusInfo, "updateAclUrl");
2132
2859
  sinon.stub(locusInfo, "updateBasequence");
2133
2860
  sinon.stub(locusInfo, "updateSequence");
2134
- sinon.stub(locusInfo, "updateMemberShip");
2135
- sinon.stub(locusInfo, "updateIdentifiers");
2136
2861
  sinon.stub(locusInfo, "updateEmbeddedApps");
2137
- sinon.stub(locusInfo, "updateResources");
2862
+ sinon.stub(locusInfo, "updateLinks");
2138
2863
  sinon.stub(locusInfo, "compareAndUpdate");
2139
2864
 
2140
2865
  locusInfo.updateLocusInfo(locus);
@@ -2158,17 +2883,14 @@ describe('plugin-meetings', () => {
2158
2883
  locusInfo.updateHostInfo = sinon.stub();
2159
2884
  locusInfo.updateMeetingInfo = sinon.stub();
2160
2885
  locusInfo.updateMediaShares = sinon.stub();
2161
- locusInfo.updateParticipantsUrl = sinon.stub();
2162
- locusInfo.updateReplace = sinon.stub();
2886
+ locusInfo.updateReplaces = sinon.stub();
2163
2887
  locusInfo.updateSelf = sinon.stub();
2164
2888
  locusInfo.updateLocusUrl = sinon.stub();
2165
2889
  locusInfo.updateAclUrl = sinon.stub();
2166
2890
  locusInfo.updateBasequence = sinon.stub();
2167
2891
  locusInfo.updateSequence = sinon.stub();
2168
- locusInfo.updateMemberShip = sinon.stub();
2169
- locusInfo.updateIdentifiers = sinon.stub();
2170
2892
  locusInfo.updateEmbeddedApps = sinon.stub();
2171
- locusInfo.updateResources = sinon.stub();
2893
+ locusInfo.updateLinks = sinon.stub();
2172
2894
  locusInfo.compareAndUpdate = sinon.stub();
2173
2895
 
2174
2896
  locusInfo.updateLocusInfo(newLocus);
@@ -2180,21 +2902,49 @@ describe('plugin-meetings', () => {
2180
2902
  assert.notCalled(locusInfo.updateHostInfo);
2181
2903
  assert.notCalled(locusInfo.updateMeetingInfo);
2182
2904
  assert.notCalled(locusInfo.updateMediaShares);
2183
- assert.notCalled(locusInfo.updateParticipantsUrl);
2184
- assert.notCalled(locusInfo.updateReplace);
2905
+ assert.notCalled(locusInfo.updateReplaces);
2185
2906
  assert.notCalled(locusInfo.updateSelf);
2186
2907
  assert.notCalled(locusInfo.updateLocusUrl);
2187
2908
  assert.notCalled(locusInfo.updateAclUrl);
2188
2909
  assert.notCalled(locusInfo.updateBasequence);
2189
2910
  assert.notCalled(locusInfo.updateSequence);
2190
- assert.notCalled(locusInfo.updateMemberShip);
2191
- assert.notCalled(locusInfo.updateIdentifiers);
2192
2911
  assert.notCalled(locusInfo.updateEmbeddedApps);
2193
- assert.notCalled(locusInfo.updateResources);
2912
+ assert.notCalled(locusInfo.updateLinks);
2194
2913
  assert.notCalled(locusInfo.compareAndUpdate);
2195
2914
  });
2196
2915
 
2916
+ it('#updateLocusInfo puts the Locus DTO top level properties at the right place in LocusInfo class', () => {
2917
+ // this test verifies that the top-level properties of Locus DTO are copied
2918
+ // into LocusInfo class and set as top level properties too
2919
+ // this is important, because the code handling Locus hass trees relies on it, see updateFromHashTree()
2920
+ const info = {id: 'info id'};
2921
+ const fullState = {id: 'fullState id'};
2922
+ const links = {services: {id: 'service links'}, resources: {id: 'resource links'}};
2923
+ const self = {id: 'self id'};
2924
+ const mediaShares = [{id: 'fake media share'}];
2925
+
2926
+ sinon.stub(SelfUtils, 'getSelves').returns({
2927
+ current: {},
2928
+ previous: {},
2929
+ updates: {},
2930
+ });
2931
+
2932
+ const newLocus = {
2933
+ info,
2934
+ fullState,
2935
+ links,
2936
+ self,
2937
+ mediaShares,
2938
+ };
2939
+
2940
+ locusInfo.updateLocusInfo(newLocus);
2197
2941
 
2942
+ assert.deepEqual(locusInfo.info, newLocus.info);
2943
+ assert.deepEqual(locusInfo.fullState, newLocus.fullState);
2944
+ assert.deepEqual(locusInfo.links, newLocus.links);
2945
+ assert.deepEqual(locusInfo.self, newLocus.self);
2946
+ assert.deepEqual(locusInfo.mediaShares, newLocus.mediaShares);
2947
+ });
2198
2948
 
2199
2949
  it('onFullLocus() updates the working-copy of locus parser', () => {
2200
2950
  const eventType = 'fakeEvent';
@@ -3351,5 +4101,34 @@ describe('plugin-meetings', () => {
3351
4101
  assert.calledWith(updateLocusInfoStub.getCall(2), deltaEvents[7]);
3352
4102
  });
3353
4103
  });
4104
+
4105
+ describe('#parse', () => {
4106
+ it('handles hash tree messages correctly', () => {
4107
+ const fakeHashTreeMessage = {
4108
+ locusStateElements: [
4109
+ {
4110
+ htMeta: {elementId: {type: 'self'}},
4111
+ data: {visibleDataSets: ['dataset1']},
4112
+ },
4113
+ ],
4114
+ dataSets: [{name: 'dataset1', url: 'http://test.com'}],
4115
+ };
4116
+
4117
+ const data = {
4118
+ eventType: LOCUSEVENT.HASH_TREE_DATA_UPDATED,
4119
+ stateElementsMessage: fakeHashTreeMessage,
4120
+ };
4121
+
4122
+ // Create a mock hash tree parser
4123
+ const mockHashTreeParser = {
4124
+ handleMessage: sinon.stub(),
4125
+ };
4126
+ locusInfo.hashTreeParser = mockHashTreeParser;
4127
+
4128
+ locusInfo.parse(mockMeeting, data);
4129
+
4130
+ assert.calledOnceWithExactly(mockHashTreeParser.handleMessage, fakeHashTreeMessage);
4131
+ });
4132
+ });
3354
4133
  });
3355
4134
  });