@webex/plugin-meetings 3.12.0-next.170 → 3.12.0-next.172

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 (36) hide show
  1. package/dist/aiEnableRequest/index.js +1 -1
  2. package/dist/annotation/index.js +53 -17
  3. package/dist/annotation/index.js.map +1 -1
  4. package/dist/breakouts/breakout.js +1 -1
  5. package/dist/breakouts/index.js +35 -9
  6. package/dist/breakouts/index.js.map +1 -1
  7. package/dist/interceptors/dataChannelAuthToken.js +41 -59
  8. package/dist/interceptors/dataChannelAuthToken.js.map +1 -1
  9. package/dist/interpretation/index.js +1 -1
  10. package/dist/interpretation/siLanguage.js +1 -1
  11. package/dist/meeting/index.js +327 -292
  12. package/dist/meeting/index.js.map +1 -1
  13. package/dist/meeting/util.js +5 -1
  14. package/dist/meeting/util.js.map +1 -1
  15. package/dist/meetings/index.js +4 -1
  16. package/dist/meetings/index.js.map +1 -1
  17. package/dist/types/annotation/index.d.ts +19 -0
  18. package/dist/types/meeting/index.d.ts +46 -12
  19. package/dist/types/meeting/util.d.ts +3 -1
  20. package/dist/webinar/index.js +298 -255
  21. package/dist/webinar/index.js.map +1 -1
  22. package/package.json +13 -13
  23. package/src/annotation/index.ts +55 -25
  24. package/src/breakouts/index.ts +33 -11
  25. package/src/interceptors/dataChannelAuthToken.ts +48 -77
  26. package/src/meeting/index.ts +296 -289
  27. package/src/meeting/util.ts +2 -2
  28. package/src/meetings/index.ts +2 -1
  29. package/src/webinar/index.ts +168 -188
  30. package/test/unit/spec/annotation/index.ts +214 -182
  31. package/test/unit/spec/breakouts/index.ts +126 -25
  32. package/test/unit/spec/interceptors/dataChannelAuthToken.ts +81 -99
  33. package/test/unit/spec/meeting/index.js +939 -705
  34. package/test/unit/spec/meeting/utils.js +16 -2
  35. package/test/unit/spec/meetings/index.js +5 -0
  36. package/test/unit/spec/webinar/index.ts +886 -718
@@ -7,14 +7,34 @@ import LLMChannel from '@webex/internal-plugin-llm';
7
7
 
8
8
  import AnnotationService from '../../../../src/annotation/index';
9
9
  import {ANNOTATION_RELAY_TYPES, ANNOTATION_REQUEST_TYPE, EVENT_TRIGGERS} from '../../../../src/annotation/constants';
10
- import {LLM_PRACTICE_SESSION} from '../../../../src/constants';
11
10
 
11
+ /**
12
+ * Creates a mock LLM channel for testing
13
+ * @param {Object} [options] - Options for the mock channel
14
+ * @param {boolean} [options.isConnected=true] - Whether the channel is connected
15
+ * @param {string} [options.binding] - The binding string
16
+ * @returns {Object} Mock channel
17
+ */
18
+ function createMockLLMChannel(options: {isConnected?: boolean; binding?: string} = {}) {
19
+ const mockWebSocket = new MockWebSocket();
20
+ const {isConnected = true, binding = 'binding'} = options;
21
+
22
+ return {
23
+ isConnected: sinon.stub().returns(isConnected),
24
+ getSocket: sinon.stub().returns(mockWebSocket),
25
+ getBinding: sinon.stub().returns(binding),
26
+ getLocusUrl: sinon.stub().returns('locusUrl'),
27
+ on: sinon.stub(),
28
+ off: sinon.stub(),
29
+ socket: mockWebSocket,
30
+ };
31
+ }
12
32
 
13
33
  describe('live-annotation', () => {
14
34
  const locusUrl = 'https://locus.wbx2.com/locus/api/v1/loci/163c1787-c1f5-47cc-95eb-ab2d660999e6';
15
35
 
16
36
  describe('annotation', () => {
17
- let webex, annotationService;
37
+ let webex, annotationService, mockChannel;
18
38
 
19
39
  beforeEach(() => {
20
40
  webex = new MockWebex({
@@ -25,26 +45,56 @@ describe('live-annotation', () => {
25
45
  },
26
46
  });
27
47
 
28
-
29
48
  annotationService = webex.internal.annotation;
30
- annotationService.connect = sinon.stub().resolves(true);
31
- annotationService.webex.internal.llm.isConnected = sinon.stub().returns(true);
32
- annotationService.webex.internal.llm.getSocket = sinon.stub().returns(undefined);
33
- annotationService.webex.internal.llm.getBinding = sinon.stub().returns(undefined);
34
- annotationService.webex.internal.llm.getLocusUrl = sinon.stub().returns(locusUrl);
35
49
  annotationService.approvalUrl = 'url/approval';
36
50
  annotationService.locusUrl = locusUrl;
37
51
 
52
+ mockChannel = createMockLLMChannel();
38
53
 
39
54
  webex.request = sinon.stub().returns(Promise.resolve('REQUEST_RETURN_VALUE'));
40
- annotationService.register = sinon.stub().resolves({
41
- body: {
42
- binding: 'binding',
43
- webSocketUrl: 'url',
44
- },
55
+ });
56
+
57
+ afterEach(() => {
58
+ annotationService.unregisterChannel();
59
+ sinon.restore();
60
+ });
61
+
62
+ describe('#registerChannel', () => {
63
+ it('registers an LLM channel and subscribes to relay events', () => {
64
+ annotationService.registerChannel(mockChannel);
65
+
66
+ assert.calledOnceWithExactly(mockChannel.on, 'event:relay.event', sinon.match.func);
67
+ assert.equal(annotationService.channel, mockChannel);
68
+ });
69
+
70
+ it('unregisters existing channel before registering new one', () => {
71
+ const oldChannel = createMockLLMChannel();
72
+ annotationService.registerChannel(oldChannel);
73
+
74
+ const newChannel = createMockLLMChannel();
75
+ annotationService.registerChannel(newChannel);
76
+
77
+ assert.calledOnceWithExactly(oldChannel.off, 'event:relay.event', sinon.match.func);
78
+ assert.calledOnceWithExactly(newChannel.on, 'event:relay.event', sinon.match.func);
79
+ assert.equal(annotationService.channel, newChannel);
45
80
  });
46
81
  });
47
82
 
83
+ describe('#unregisterChannel', () => {
84
+ it('unregisters the current channel', () => {
85
+ annotationService.registerChannel(mockChannel);
86
+ annotationService.unregisterChannel();
87
+
88
+ assert.calledOnceWithExactly(mockChannel.off, 'event:relay.event', sinon.match.func);
89
+ assert.equal(annotationService.channel, undefined);
90
+ });
91
+
92
+ it('does nothing if no channel is registered', () => {
93
+ annotationService.unregisterChannel();
94
+ // Should not throw
95
+ assert.equal(annotationService.channel, undefined);
96
+ });
97
+ });
48
98
 
49
99
  describe('event message processing', () => {
50
100
  beforeEach(async () => {
@@ -57,10 +107,8 @@ describe('live-annotation', () => {
57
107
  annotationService.eventCommandProcessor({});
58
108
  assert.notCalled(spy);
59
109
 
60
-
61
110
  annotationService.eventCommandProcessor({
62
- data: {
63
- }
111
+ data: {}
64
112
  });
65
113
  assert.notCalled(spy);
66
114
 
@@ -94,11 +142,9 @@ describe('live-annotation', () => {
94
142
  }
95
143
  }
96
144
  });
97
- assert.notCalled(spy)
145
+ assert.notCalled(spy);
98
146
  });
99
147
 
100
-
101
-
102
148
  it('eventCommandProcessor call success', () => {
103
149
  const spy = sinon.spy();
104
150
  annotationService.on(EVENT_TRIGGERS.ANNOTATION_COMMAND, spy);
@@ -123,80 +169,82 @@ describe('live-annotation', () => {
123
169
  });
124
170
 
125
171
  it('eventDataProcessor call failed', () => {
126
-
127
- const spy = sinon.spy(annotationService, "processStrokeMessage");
172
+ const spy = sinon.spy(annotationService, 'processStrokeMessage');
128
173
 
129
174
  annotationService.eventDataProcessor();
130
-
131
175
  assert.notCalled(spy);
132
176
 
133
177
  annotationService.eventDataProcessor({data: {}});
134
-
135
178
  assert.notCalled(spy);
136
179
 
137
180
  annotationService.eventDataProcessor({data: {relayType: 'NOT:annotation.client'}});
138
-
139
181
  assert.notCalled(spy);
140
182
  });
141
183
 
142
-
143
184
  it('eventDataProcessor call success', () => {
185
+ const spy = sinon.spy(annotationService, 'processStrokeMessage');
144
186
 
145
- const spy = sinon.spy(annotationService, "processStrokeMessage");
146
-
147
- annotationService.eventDataProcessor({data: {relayType: 'annotation.client', request:{value:{encryptionKeyUrl:"encryptionKeyUrl"}}}});
187
+ annotationService.eventDataProcessor({
188
+ data: {
189
+ relayType: 'annotation.client',
190
+ request: {value: {encryptionKeyUrl: 'encryptionKeyUrl'}}
191
+ }
192
+ });
148
193
 
149
194
  assert.calledOnceWithExactly(spy, {
150
195
  relayType: 'annotation.client',
151
- request: { value: { encryptionKeyUrl: 'encryptionKeyUrl' } }
152
- } );
153
-
196
+ request: {value: {encryptionKeyUrl: 'encryptionKeyUrl'}}
197
+ });
154
198
  });
155
199
 
156
-
157
200
  it('processStrokeMessage', async () => {
158
201
  const spy = sinon.spy();
159
202
  annotationService.on(EVENT_TRIGGERS.ANNOTATION_STROKE_DATA, spy);
160
203
 
161
- await annotationService.processStrokeMessage({request:{value:{encryptionKeyUrl: 'encryptionKeyUrl', content: 'content'}}});
204
+ await annotationService.processStrokeMessage({
205
+ request: {value: {encryptionKeyUrl: 'encryptionKeyUrl', content: 'content'}}
206
+ });
162
207
 
163
208
  assert.calledOnceWithExactly(spy, {
164
- payload:{request:{value:{encryptionKeyUrl: 'encryptionKeyUrl', content: 'decryptedContent'}}} ,
209
+ payload: {request: {value: {encryptionKeyUrl: 'encryptionKeyUrl', content: 'decryptedContent'}}},
165
210
  });
166
-
167
211
  });
168
-
169
212
  });
170
213
 
171
- describe('event message processing',() =>{
214
+ describe('event registration via registerChannel', () => {
215
+ it('registers relay event handler when channel is registered', () => {
216
+ annotationService.registerChannel(mockChannel);
172
217
 
173
- it('listens to mercury events once', () => {
218
+ assert.calledOnceWithExactly(mockChannel.on, 'event:relay.event', sinon.match.func);
219
+ });
174
220
 
175
- const spy = sinon.spy(annotationService.webex.internal.mercury, 'on');
221
+ it('processes events through the registered handler', () => {
222
+ annotationService.decryptContent = sinon.stub().returns(Promise.resolve('decryptedContent'));
223
+ annotationService.registerChannel(mockChannel);
176
224
 
177
- annotationService.listenToEvents();
225
+ // Get the handler that was registered
226
+ const handler = mockChannel.on.getCall(0).args[1];
178
227
 
179
- assert.calledOnceWithExactly(spy, 'event:locus.approval_request', sinon.match.func,sinon.match.object);
180
- });
228
+ const spy = sinon.spy(annotationService, 'processStrokeMessage');
229
+ handler({
230
+ data: {
231
+ relayType: 'annotation.client',
232
+ request: {value: {encryptionKeyUrl: 'key'}}
233
+ }
234
+ });
181
235
 
182
- it('listens to llm events once', () => {
236
+ assert.calledOnce(spy);
237
+ });
183
238
 
184
- const spy = sinon.spy(webex.internal.llm, 'on');
239
+ it('listens to mercury events via listenToEvents', () => {
240
+ const spy = sinon.spy(annotationService.webex.internal.mercury, 'on');
185
241
 
186
242
  annotationService.listenToEvents();
187
243
 
188
- assert.calledWithExactly(spy.firstCall, 'event:relay.event', sinon.match.func, sinon.match.object);
189
- assert.calledWithExactly(
190
- spy.secondCall,
191
- `event:relay.event:${LLM_PRACTICE_SESSION}`,
192
- sinon.match.func,
193
- sinon.match.object
194
- );
244
+ assert.calledOnceWithExactly(spy, 'event:locus.approval_request', sinon.match.func, sinon.match.object);
195
245
  });
196
-
197
246
  });
198
247
 
199
-
200
248
  describe('encrypt/decrypt Content', () => {
201
249
  beforeEach(async () => {
202
250
  annotationService.webex.internal.encryption.encryptText = sinon.stub().returns(Promise.resolve('RETURN_VALUE'));
@@ -204,67 +252,72 @@ describe('live-annotation', () => {
204
252
  });
205
253
 
206
254
  it('encryptContent', async () => {
207
- const result = await annotationService.encryptContent("encryptionKeyUrl", "content");
208
- assert.calledOnceWithExactly(webex.internal.encryption.encryptText, "encryptionKeyUrl", "content");
209
- assert.equal(result, 'RETURN_VALUE')
255
+ const result = await annotationService.encryptContent('encryptionKeyUrl', 'content');
256
+ assert.calledOnceWithExactly(webex.internal.encryption.encryptText, 'encryptionKeyUrl', 'content');
257
+ assert.equal(result, 'RETURN_VALUE');
210
258
  });
211
259
 
212
- it('decryptContent', async() => {
213
- const result = await annotationService.decryptContent("decryptionKeyUrl", "content");
214
- assert.calledOnceWithExactly(webex.internal.encryption.decryptText, "decryptionKeyUrl", "content");
215
- assert.equal(result, 'RETURN_VALUE')
260
+ it('decryptContent', async () => {
261
+ const result = await annotationService.decryptContent('decryptionKeyUrl', 'content');
262
+ assert.calledOnceWithExactly(webex.internal.encryption.decryptText, 'decryptionKeyUrl', 'content');
263
+ assert.equal(result, 'RETURN_VALUE');
216
264
  });
217
-
218
265
  });
219
266
 
220
-
221
-
222
- describe('publish Stroke Data with LLM is not connected', () => {
223
-
224
- beforeEach(async () => {
225
- annotationService.webex.internal.llm.socket = new MockWebSocket();
226
- annotationService.webex.internal.llm.isConnected = sinon.stub().returns(false);
267
+ describe('publish Stroke Data with no channel registered', () => {
268
+ it('does not send when no channel is registered', async () => {
269
+ annotationService.sendStrokeData({});
270
+ // Should not throw, just return early
227
271
  });
272
+ });
228
273
 
229
- it('publish Stroke Data with LLM is not connected', async () => {
230
- annotationService.sendStrokeData("", {});
231
- assert.notCalled(annotationService.webex.internal.llm.socket.send);
232
- });
274
+ describe('publish Stroke Data with channel not connected', () => {
275
+ it('does not send when channel is not connected', async () => {
276
+ const disconnectedChannel = createMockLLMChannel({isConnected: false});
277
+ annotationService.registerChannel(disconnectedChannel);
233
278
 
279
+ annotationService.sendStrokeData({});
280
+ assert.notCalled(disconnectedChannel.socket.send);
281
+ });
234
282
  });
235
283
 
236
284
  describe('sendStrokeData', () => {
237
285
  let strokeData;
238
286
 
239
287
  beforeEach(async () => {
240
- annotationService.webex.internal.llm.socket = new MockWebSocket();
288
+ annotationService.registerChannel(mockChannel);
289
+ annotationService.webex.internal.encryption.encryptText = sinon.stub().returns(Promise.resolve('encryptedContent'));
290
+
241
291
  strokeData = {
242
292
  content: {
243
- "contentsBuffer": [{
244
- "contentArray": [{
245
- "curveId": "58dcf45c-1fc5-46bf-a902-053621dd8977",
246
- "curvePoints": [592.593, 352.963, 3.400, 596.710, 352.963, 3.400, 600.000, 352.963, 3.398, 600.000, 352.963, 3.398],
247
- "stride": 3
248
- }], "type": "curve", "name": "contentUpdate"
249
- }], "action": "contentUpdate", "sender": {"name": "perfect", "id": "4dd5eaf9-4cf8-4f0f-a1d6-014bf5d00741"}
293
+ contentsBuffer: [{
294
+ contentArray: [{
295
+ curveId: '58dcf45c-1fc5-46bf-a902-053621dd8977',
296
+ curvePoints: [592.593, 352.963, 3.400, 596.710, 352.963, 3.400],
297
+ stride: 3
298
+ }],
299
+ type: 'curve',
300
+ name: 'contentUpdate'
301
+ }],
302
+ action: 'contentUpdate',
303
+ sender: {name: 'perfect', id: '4dd5eaf9-4cf8-4f0f-a1d6-014bf5d00741'}
250
304
  },
251
- deviceId: "525ead98-6c93-4fcb-899d-517305c47513",
305
+ deviceId: '525ead98-6c93-4fcb-899d-517305c47513',
252
306
  requesterId: '525ead98-6c93-4fcb-899d-517305c47513',
253
- toUserId: "987ead98-6c93-4fcb-899d-517305c47503",
307
+ toUserId: '987ead98-6c93-4fcb-899d-517305c47503',
254
308
  shareInstanceId: '7fa6fe07-dcb1-41ad-973d-7bcf65fab55d',
255
- encryptionKeyUrl: "encryptionKeyUrl",
309
+ encryptionKeyUrl: 'encryptionKeyUrl',
256
310
  version: '1',
257
311
  };
258
312
  });
259
313
 
260
-
261
314
  it('works on publish Stroke Data', async () => {
262
315
  annotationService.publishEncrypted(strokeData.content, strokeData);
263
316
 
264
317
  const sendObject = {
265
318
  id: sinon.match.string,
266
319
  type: 'publishRequest',
267
- recipients: [{route: undefined}],
320
+ recipients: [{route: 'binding'}],
268
321
  headers: {to: '987ead98-6c93-4fcb-899d-517305c47503'},
269
322
  data: {
270
323
  eventType: 'relay.event',
@@ -274,7 +327,7 @@ describe('live-annotation', () => {
274
327
  type: ANNOTATION_REQUEST_TYPE.ANNOTATION_MESSAGE,
275
328
  content: strokeData.content,
276
329
  version: '1',
277
- seq:sinon.match.number,
330
+ seq: sinon.match.number,
278
331
  deviceId: sinon.match.string,
279
332
  requesterId: sinon.match.string,
280
333
  shareInstanceId: strokeData.shareInstanceId,
@@ -288,66 +341,48 @@ describe('live-annotation', () => {
288
341
  filterMessage: false,
289
342
  };
290
343
 
291
- assert.calledOnceWithExactly(annotationService.webex.internal.llm.socket.send, sendObject);
344
+ assert.calledOnceWithExactly(mockChannel.socket.send, sendObject);
292
345
  });
293
346
 
294
- it('uses the practice-session socket and binding only when the practice-session session is connected', () => {
295
- const practiceSocket = new MockWebSocket();
296
-
297
- annotationService.webex.internal.llm.isConnected.callsFake((sessionId) =>
298
- sessionId === LLM_PRACTICE_SESSION
299
- );
300
- annotationService.webex.internal.llm.getSocket
301
- .withArgs(LLM_PRACTICE_SESSION)
302
- .returns(practiceSocket);
303
- annotationService.webex.internal.llm.getBinding
304
- .withArgs(LLM_PRACTICE_SESSION)
305
- .returns('practice-binding');
347
+ it('does not send if socket is not available', () => {
348
+ const channelWithoutSocket = createMockLLMChannel();
349
+ channelWithoutSocket.getSocket.returns(undefined);
350
+ annotationService.registerChannel(channelWithoutSocket);
306
351
 
307
352
  annotationService.publishEncrypted(strokeData.content, strokeData);
308
353
 
309
- assert.calledOnce(practiceSocket.send);
310
- assert.notCalled(annotationService.webex.internal.llm.socket.send);
311
-
312
- const sent = practiceSocket.send.getCall(0).args[0];
313
- assert.equal(sent.recipients[0].route, 'practice-binding');
354
+ assert.notCalled(channelWithoutSocket.socket.send);
314
355
  });
315
356
 
316
- it('falls back to the default socket and binding when the practice-session socket exists but is not connected', () => {
317
- const practiceSocket = new MockWebSocket();
318
-
319
- annotationService.webex.internal.llm.isConnected.callsFake((sessionId) => !sessionId);
320
- annotationService.webex.internal.llm.getSocket
321
- .withArgs(LLM_PRACTICE_SESSION)
322
- .returns(practiceSocket);
323
- annotationService.webex.internal.llm.getBinding
324
- .withArgs(LLM_PRACTICE_SESSION)
325
- .returns('practice-binding');
326
- annotationService.webex.internal.llm.getBinding.returns('default-binding');
357
+ it('does not send if binding is not available', () => {
358
+ const channelWithoutBinding = createMockLLMChannel({binding: undefined});
359
+ channelWithoutBinding.getBinding.returns(undefined);
360
+ annotationService.registerChannel(channelWithoutBinding);
327
361
 
328
362
  annotationService.publishEncrypted(strokeData.content, strokeData);
329
363
 
330
- assert.notCalled(practiceSocket.send);
331
- assert.calledOnce(annotationService.webex.internal.llm.socket.send);
332
-
333
- const sent = annotationService.webex.internal.llm.socket.send.getCall(0).args[0];
334
- assert.equal(sent.recipients[0].route, 'default-binding');
364
+ assert.notCalled(channelWithoutBinding.socket.send);
335
365
  });
336
366
 
337
- });
367
+ it('encrypts content before publishing', async () => {
368
+ await annotationService.sendStrokeData(strokeData);
338
369
 
370
+ assert.calledOnceWithExactly(
371
+ webex.internal.encryption.encryptText,
372
+ strokeData.encryptionKeyUrl,
373
+ strokeData.content
374
+ );
375
+ });
376
+ });
339
377
 
340
378
  describe('Locus API collection', () => {
341
-
342
379
  describe('send approve request', () => {
343
- it('makes send request approved annotation as expected', async () => {
344
- const
345
- requestData = {
346
- toUserId: '4dd5eaf9-4cf8-4f0f-a1d6-014bf5d00741',
347
- toDeviceUrl: 'https://wdm-a.wbx2.com/wdm/api/v1/devices/a3018aa9-70cb-4142-ae9a-f03db4fe1057',
348
- shareInstanceId: '9428c492-da14-476f-a36c-b377ee8c4009',
349
- };
350
-
380
+ it('makes send request approved annotation as expected', async () => {
381
+ const requestData = {
382
+ toUserId: '4dd5eaf9-4cf8-4f0f-a1d6-014bf5d00741',
383
+ toDeviceUrl: 'https://wdm-a.wbx2.com/wdm/api/v1/devices/a3018aa9-70cb-4142-ae9a-f03db4fe1057',
384
+ shareInstanceId: '9428c492-da14-476f-a36c-b377ee8c4009',
385
+ };
351
386
 
352
387
  const result = await annotationService.approveAnnotation(requestData);
353
388
  assert.calledOnceWithExactly(webex.request, {
@@ -364,22 +399,20 @@ describe('live-annotation', () => {
364
399
  }
365
400
  });
366
401
 
367
- assert.equal(result, 'REQUEST_RETURN_VALUE')
402
+ assert.equal(result, 'REQUEST_RETURN_VALUE');
368
403
  });
369
404
  });
370
405
 
371
406
  describe('cancel Approve request', () => {
372
407
  it('makes the cancel Approve request annotation as expected', async () => {
373
- const
374
- requestData = {
375
- toUserId: '4dd5eaf9-4cf8-4f0f-a1d6-014bf5d00741',
376
- toDeviceUrl: 'https://wdm-a.wbx2.com/wdm/api/v1/devices/a3018aa9-70cb-4142-ae9a-f03db4fe1057',
377
- shareInstanceId: '9428c492-da14-476f-a36c-b377ee8c4009',
378
- };
379
- const approval = {url:"url/cancel"};
380
-
381
-
382
- const result = await annotationService.cancelApproveAnnotation(requestData,approval);
408
+ const requestData = {
409
+ toUserId: '4dd5eaf9-4cf8-4f0f-a1d6-014bf5d00741',
410
+ toDeviceUrl: 'https://wdm-a.wbx2.com/wdm/api/v1/devices/a3018aa9-70cb-4142-ae9a-f03db4fe1057',
411
+ shareInstanceId: '9428c492-da14-476f-a36c-b377ee8c4009',
412
+ };
413
+ const approval = {url: 'url/cancel'};
414
+
415
+ const result = await annotationService.cancelApproveAnnotation(requestData, approval);
383
416
  assert.calledOnceWithExactly(webex.request, {
384
417
  method: 'PUT',
385
418
  url: 'url/cancel',
@@ -390,21 +423,17 @@ describe('live-annotation', () => {
390
423
  }
391
424
  });
392
425
 
393
- assert.equal(result, 'REQUEST_RETURN_VALUE')
426
+ assert.equal(result, 'REQUEST_RETURN_VALUE');
394
427
  });
395
428
  });
396
429
 
397
-
398
-
399
430
  describe('close annotation', () => {
400
431
  it('makes the close annotation as expected', async () => {
401
- const
402
- requestData = {
403
- toUserId: '4dd5eaf9-4cf8-4f0f-a1d6-014bf5d00741',
404
- toDeviceUrl: 'https://wdm-a.wbx2.com/wdm/api/v1/devices/a3018aa9-70cb-4142-ae9a-f03db4fe1057',
405
- shareInstanceId: '9428c492-da14-476f-a36c-b377ee8c4009',
406
- };
407
-
432
+ const requestData = {
433
+ toUserId: '4dd5eaf9-4cf8-4f0f-a1d6-014bf5d00741',
434
+ toDeviceUrl: 'https://wdm-a.wbx2.com/wdm/api/v1/devices/a3018aa9-70cb-4142-ae9a-f03db4fe1057',
435
+ shareInstanceId: '9428c492-da14-476f-a36c-b377ee8c4009',
436
+ };
408
437
 
409
438
  const result = await annotationService.closeAnnotation(requestData);
410
439
  assert.calledOnceWithExactly(webex.request, {
@@ -421,16 +450,15 @@ describe('live-annotation', () => {
421
450
  }
422
451
  });
423
452
 
424
- assert.equal(result, 'REQUEST_RETURN_VALUE')
453
+ assert.equal(result, 'REQUEST_RETURN_VALUE');
425
454
  });
426
455
  });
427
456
 
428
-
429
457
  describe('declined annotation', () => {
430
458
  it('makes the declined annotation as expected', async () => {
431
459
  const approval = {
432
460
  url: 'approvalUrl'
433
- }
461
+ };
434
462
  const result = await annotationService.declineRequest(approval);
435
463
  assert.calledOnceWithExactly(webex.request, {
436
464
  method: 'PUT',
@@ -441,7 +469,7 @@ describe('live-annotation', () => {
441
469
  }
442
470
  });
443
471
 
444
- assert.equal(result, 'REQUEST_RETURN_VALUE')
472
+ assert.equal(result, 'REQUEST_RETURN_VALUE');
445
473
  });
446
474
  });
447
475
 
@@ -449,7 +477,7 @@ describe('live-annotation', () => {
449
477
  it('makes the accepted annotation as expected', async () => {
450
478
  const approval = {
451
479
  url: 'approvalUrl'
452
- }
480
+ };
453
481
  const result = await annotationService.acceptRequest(approval);
454
482
  assert.calledOnceWithExactly(webex.request, {
455
483
  method: 'PUT',
@@ -460,66 +488,70 @@ describe('live-annotation', () => {
460
488
  }
461
489
  });
462
490
 
463
- assert.equal(result, 'REQUEST_RETURN_VALUE')
491
+ assert.equal(result, 'REQUEST_RETURN_VALUE');
464
492
  });
465
493
  });
466
494
  });
467
495
 
468
496
  describe('#deregisterEvents', () => {
469
- let llmOn;
470
- let llmOff;
471
497
  let mercuryOn;
472
498
  let mercuryOff;
473
499
 
474
500
  beforeEach(() => {
475
- llmOn = sinon.spy(webex.internal.llm, 'on');
476
- llmOff = sinon.spy(webex.internal.llm, 'off');
477
501
  mercuryOn = sinon.spy(webex.internal.mercury, 'on');
478
502
  mercuryOff = sinon.spy(webex.internal.mercury, 'off');
479
503
  });
480
504
 
481
- it('cleans up events', () => {
505
+ it('cleans up mercury events and unregisters channel', () => {
506
+ annotationService.registerChannel(mockChannel);
482
507
  annotationService.locusUrlUpdate(locusUrl);
508
+
483
509
  assert.calledWith(
484
510
  mercuryOn,
485
511
  'event:locus.approval_request',
486
512
  annotationService.eventCommandProcessor,
487
513
  annotationService
488
514
  );
489
- assert.calledWith(
490
- llmOn,
491
- 'event:relay.event',
492
- annotationService.eventDataProcessor,
493
- annotationService
494
- );
495
- assert.calledWith(
496
- llmOn,
497
- `event:relay.event:${LLM_PRACTICE_SESSION}`,
498
- annotationService.eventDataProcessor,
499
- annotationService
500
- );
501
515
  assert.match(annotationService.hasSubscribedToEvents, true);
502
516
 
503
517
  annotationService.deregisterEvents();
504
- assert.calledWith(llmOff, 'event:relay.event', annotationService.eventDataProcessor);
505
- assert.calledWith(
506
- llmOff,
507
- `event:relay.event:${LLM_PRACTICE_SESSION}`,
508
- annotationService.eventDataProcessor
509
- );
518
+
510
519
  assert.calledWith(
511
520
  mercuryOff,
512
521
  'event:locus.approval_request',
513
522
  annotationService.eventCommandProcessor
514
523
  );
524
+ assert.calledOnceWithExactly(mockChannel.off, 'event:relay.event', sinon.match.func);
525
+ assert.equal(annotationService.channel, undefined);
515
526
  assert.match(annotationService.hasSubscribedToEvents, false);
516
527
  });
517
528
 
518
- it('does not call llm off if events have not been registered', () => {
529
+ it('does not call off if events have not been registered', () => {
519
530
  annotationService.deregisterEvents();
520
- assert.notCalled(llmOff);
521
531
  assert.notCalled(mercuryOff);
522
532
  });
523
533
  });
534
+
535
+ describe('#locusUrlUpdate', () => {
536
+ it('updates locusUrl and calls listenToEvents', () => {
537
+ const newLocusUrl = 'https://new-locus-url.com';
538
+ const listenSpy = sinon.spy(annotationService, 'listenToEvents');
539
+
540
+ annotationService.locusUrlUpdate(newLocusUrl);
541
+
542
+ assert.equal(annotationService.locusUrl, newLocusUrl);
543
+ assert.calledOnce(listenSpy);
544
+ });
545
+ });
546
+
547
+ describe('#approvalUrlUpdate', () => {
548
+ it('updates approvalUrl', () => {
549
+ const newApprovalUrl = 'https://new-approval-url.com';
550
+
551
+ annotationService.approvalUrlUpdate(newApprovalUrl);
552
+
553
+ assert.equal(annotationService.approvalUrl, newApprovalUrl);
554
+ });
555
+ });
524
556
  });
525
557
  });