@webex/plugin-meetings 3.12.0-auth-prejoin-fetch.1 → 3.12.0-llmrefactor.10
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.
- package/dist/aiEnableRequest/index.js +1 -1
- package/dist/annotation/index.js +53 -17
- package/dist/annotation/index.js.map +1 -1
- package/dist/breakouts/breakout.js +1 -1
- package/dist/breakouts/index.js +35 -9
- package/dist/breakouts/index.js.map +1 -1
- package/dist/hashTree/hashTreeParser.js +101 -48
- package/dist/hashTree/hashTreeParser.js.map +1 -1
- package/dist/interceptors/dataChannelAuthToken.js +41 -59
- package/dist/interceptors/dataChannelAuthToken.js.map +1 -1
- package/dist/interpretation/index.js +1 -1
- package/dist/interpretation/siLanguage.js +1 -1
- package/dist/locus-info/index.js +27 -2
- package/dist/locus-info/index.js.map +1 -1
- package/dist/locus-info/types.js +2 -1
- package/dist/locus-info/types.js.map +1 -1
- package/dist/meeting/index.js +913 -921
- package/dist/meeting/index.js.map +1 -1
- package/dist/meeting/util.js +5 -1
- package/dist/meeting/util.js.map +1 -1
- package/dist/meeting/voicea-meeting.js +2 -1
- package/dist/meeting/voicea-meeting.js.map +1 -1
- package/dist/meeting-info/meeting-info-v2.js +36 -92
- package/dist/meeting-info/meeting-info-v2.js.map +1 -1
- package/dist/meetings/index.js +33 -93
- package/dist/meetings/index.js.map +1 -1
- package/dist/meetings/meetings.types.js.map +1 -1
- package/dist/types/annotation/index.d.ts +19 -0
- package/dist/types/hashTree/hashTreeParser.d.ts +12 -0
- package/dist/types/locus-info/index.d.ts +6 -0
- package/dist/types/locus-info/types.d.ts +1 -0
- package/dist/types/meeting/index.d.ts +47 -20
- package/dist/types/meeting/util.d.ts +3 -1
- package/dist/types/meeting-info/meeting-info-v2.d.ts +1 -24
- package/dist/types/meetings/index.d.ts +2 -13
- package/dist/types/meetings/meetings.types.d.ts +1 -15
- package/dist/webinar/index.js +298 -255
- package/dist/webinar/index.js.map +1 -1
- package/package.json +21 -21
- package/src/annotation/index.ts +55 -25
- package/src/breakouts/index.ts +33 -11
- package/src/hashTree/hashTreeParser.ts +67 -3
- package/src/interceptors/dataChannelAuthToken.ts +48 -77
- package/src/locus-info/index.ts +20 -0
- package/src/locus-info/types.ts +1 -0
- package/src/meeting/index.ts +318 -332
- package/src/meeting/util.ts +2 -2
- package/src/meeting/voicea-meeting.ts +1 -1
- package/src/meeting-info/meeting-info-v2.ts +18 -74
- package/src/meetings/index.ts +6 -70
- package/src/meetings/meetings.types.ts +1 -17
- package/src/webinar/index.ts +168 -188
- package/test/unit/spec/annotation/index.ts +214 -182
- package/test/unit/spec/breakouts/index.ts +126 -25
- package/test/unit/spec/hashTree/hashTreeParser.ts +212 -1
- package/test/unit/spec/interceptors/dataChannelAuthToken.ts +81 -99
- package/test/unit/spec/locus-info/index.js +79 -0
- package/test/unit/spec/meeting/index.js +979 -701
- package/test/unit/spec/meeting/utils.js +16 -2
- package/test/unit/spec/meeting/voicea-meeting.ts +85 -1
- package/test/unit/spec/meeting-info/meetinginfov2.js +0 -210
- package/test/unit/spec/meetings/index.js +5 -231
- package/test/unit/spec/webinar/index.ts +886 -718
|
@@ -35,7 +35,6 @@ import {
|
|
|
35
35
|
OFFLINE,
|
|
36
36
|
ROAP_OFFER_ANSWER_EXCHANGE_TIMEOUT,
|
|
37
37
|
LOCUS_LLM_EVENT,
|
|
38
|
-
LLM_PRACTICE_SESSION,
|
|
39
38
|
RECORDING_STATE,
|
|
40
39
|
} from '@webex/plugin-meetings/src/constants';
|
|
41
40
|
import {
|
|
@@ -287,7 +286,37 @@ describe('plugin-meetings', () => {
|
|
|
287
286
|
});
|
|
288
287
|
webex.internal.llm.isDataChannelTokenEnabled = sinon.stub().resolves(false);
|
|
289
288
|
webex.internal.llm.on = sinon.stub();
|
|
289
|
+
// Factory pattern: createChannel returns a mock channel
|
|
290
|
+
webex.internal.llm.createChannel = sinon.stub().callsFake(() => ({
|
|
291
|
+
registerAndConnect: sinon.stub().resolves({}),
|
|
292
|
+
disconnect: sinon.stub().resolves(),
|
|
293
|
+
isConnected: sinon.stub().returns(false),
|
|
294
|
+
isConnecting: sinon.stub().returns(false),
|
|
295
|
+
getLocusUrl: sinon.stub().returns(undefined),
|
|
296
|
+
getDatachannelUrl: sinon.stub().returns(undefined),
|
|
297
|
+
getDatachannelToken: sinon.stub().returns(undefined),
|
|
298
|
+
setDatachannelToken: sinon.stub(),
|
|
299
|
+
getBinding: sinon.stub().returns(undefined),
|
|
300
|
+
setRefreshHandler: sinon.stub(),
|
|
301
|
+
on: sinon.stub(),
|
|
302
|
+
off: sinon.stub(),
|
|
303
|
+
}));
|
|
290
304
|
webex.internal.voicea.announce = sinon.stub();
|
|
305
|
+
// Factory pattern: createChannel returns a mock voicea channel
|
|
306
|
+
webex.internal.voicea.createChannel = sinon.stub().callsFake(() => ({
|
|
307
|
+
on: sinon.stub(),
|
|
308
|
+
off: sinon.stub(),
|
|
309
|
+
onSpokenLanguageUpdate: sinon.stub(),
|
|
310
|
+
onCaptionServiceIdUpdate: sinon.stub(),
|
|
311
|
+
requestLanguage: sinon.stub(),
|
|
312
|
+
setSpokenLanguage: sinon.stub(),
|
|
313
|
+
turnOnCaptions: sinon.stub().resolves(),
|
|
314
|
+
listenToEvents: sinon.stub(),
|
|
315
|
+
deregisterEvents: sinon.stub(),
|
|
316
|
+
getIsCaptionBoxOn: sinon.stub().returns(false),
|
|
317
|
+
updateSubchannelSubscriptions: sinon.stub(),
|
|
318
|
+
switchLLMChannel: sinon.stub().resolves(),
|
|
319
|
+
}));
|
|
291
320
|
webex.internal.newMetrics.callDiagnosticLatencies = new CallDiagnosticLatencies(
|
|
292
321
|
{},
|
|
293
322
|
{parent: webex}
|
|
@@ -339,6 +368,27 @@ describe('plugin-meetings', () => {
|
|
|
339
368
|
});
|
|
340
369
|
|
|
341
370
|
describe('meeting index', () => {
|
|
371
|
+
/**
|
|
372
|
+
* Creates a mock LLM channel with sensible defaults that can be overridden.
|
|
373
|
+
* @param {Object} overrides - Properties to override on the mock channel
|
|
374
|
+
* @returns {Object} Mock channel object with sinon stubs
|
|
375
|
+
*/
|
|
376
|
+
const createMockLLMChannel = (overrides = {}) => ({
|
|
377
|
+
registerAndConnect: sinon.stub().resolves({}),
|
|
378
|
+
disconnect: sinon.stub().resolves(),
|
|
379
|
+
isConnected: sinon.stub().returns(false),
|
|
380
|
+
isConnecting: sinon.stub().returns(false),
|
|
381
|
+
getLocusUrl: sinon.stub().returns(undefined),
|
|
382
|
+
getDatachannelUrl: sinon.stub().returns(undefined),
|
|
383
|
+
getDatachannelToken: sinon.stub().returns(undefined),
|
|
384
|
+
setDatachannelToken: sinon.stub(),
|
|
385
|
+
getBinding: sinon.stub().returns(undefined),
|
|
386
|
+
setRefreshHandler: sinon.stub(),
|
|
387
|
+
on: sinon.stub(),
|
|
388
|
+
off: sinon.stub(),
|
|
389
|
+
...overrides,
|
|
390
|
+
});
|
|
391
|
+
|
|
342
392
|
describe('Public Api Contract', () => {
|
|
343
393
|
describe('#constructor', () => {
|
|
344
394
|
it('should have created a meeting object with public properties', () => {
|
|
@@ -524,6 +574,11 @@ describe('plugin-meetings', () => {
|
|
|
524
574
|
localWebex.internal.llm.isDataChannelTokenEnabled = sinon.stub().resolves(false);
|
|
525
575
|
localWebex.internal.llm.on = sinon.stub();
|
|
526
576
|
localWebex.internal.voicea.announce = sinon.stub();
|
|
577
|
+
localWebex.internal.voicea.createChannel = sinon.stub().returns({
|
|
578
|
+
on: sinon.stub(),
|
|
579
|
+
off: sinon.stub(),
|
|
580
|
+
switchLLMChannel: sinon.stub().resolves(),
|
|
581
|
+
});
|
|
527
582
|
localWebex.internal.newMetrics.callDiagnosticLatencies = new CallDiagnosticLatencies(
|
|
528
583
|
{},
|
|
529
584
|
{parent: localWebex}
|
|
@@ -1181,6 +1236,78 @@ describe('plugin-meetings', () => {
|
|
|
1181
1236
|
assert.calledWith(suspendDestroyMeetingStub.thirdCall, false);
|
|
1182
1237
|
});
|
|
1183
1238
|
|
|
1239
|
+
it('should not retry if join() fails because the Locus user capacity is full', async () => {
|
|
1240
|
+
const error = new Error('Error Joining Meeting');
|
|
1241
|
+
error.error = {
|
|
1242
|
+
statusCode: 423,
|
|
1243
|
+
body: {errorCode: 2423001},
|
|
1244
|
+
};
|
|
1245
|
+
meeting.join = sinon.stub().rejects(error);
|
|
1246
|
+
|
|
1247
|
+
const thrownError = await assert.isRejected(
|
|
1248
|
+
meeting.joinWithMedia({joinOptions, mediaOptions})
|
|
1249
|
+
);
|
|
1250
|
+
|
|
1251
|
+
assert.equal(thrownError, error);
|
|
1252
|
+
assert.calledOnce(meeting.join);
|
|
1253
|
+
assert.calledOnce(generateTurnDiscoveryRequestMessageStub);
|
|
1254
|
+
assert.calledOnce(Metrics.sendBehavioralMetric);
|
|
1255
|
+
assert.calledTwice(suspendDestroyMeetingStub);
|
|
1256
|
+
assert.calledWith(suspendDestroyMeetingStub.firstCall, true);
|
|
1257
|
+
assert.calledWith(suspendDestroyMeetingStub.secondCall, false);
|
|
1258
|
+
});
|
|
1259
|
+
|
|
1260
|
+
it('should still retry if join() fails with another HTTP 423 Locus error', async () => {
|
|
1261
|
+
const error = new Error('Error Joining Meeting');
|
|
1262
|
+
error.error = {
|
|
1263
|
+
statusCode: 423,
|
|
1264
|
+
body: {errorCode: 2423028},
|
|
1265
|
+
};
|
|
1266
|
+
meeting.join = sinon.stub().rejects(error);
|
|
1267
|
+
|
|
1268
|
+
const thrownError = await assert.isRejected(
|
|
1269
|
+
meeting.joinWithMedia({joinOptions, mediaOptions})
|
|
1270
|
+
);
|
|
1271
|
+
|
|
1272
|
+
assert.equal(thrownError, error);
|
|
1273
|
+
assert.calledTwice(meeting.join);
|
|
1274
|
+
assert.calledTwice(generateTurnDiscoveryRequestMessageStub);
|
|
1275
|
+
assert.calledTwice(Metrics.sendBehavioralMetric);
|
|
1276
|
+
});
|
|
1277
|
+
|
|
1278
|
+
it('should throw the Locus user full error over firstError when the retry hits full capacity', async () => {
|
|
1279
|
+
const firstJoinError = new Error('first join error');
|
|
1280
|
+
const capacityError = new Error('Error Joining Meeting');
|
|
1281
|
+
capacityError.error = {
|
|
1282
|
+
statusCode: 423,
|
|
1283
|
+
body: {errorCode: 2423001},
|
|
1284
|
+
};
|
|
1285
|
+
|
|
1286
|
+
meeting.join = sinon
|
|
1287
|
+
.stub()
|
|
1288
|
+
.onFirstCall()
|
|
1289
|
+
.rejects(firstJoinError)
|
|
1290
|
+
.onSecondCall()
|
|
1291
|
+
.rejects(capacityError);
|
|
1292
|
+
meeting.locusUrl = null; // join never succeeds
|
|
1293
|
+
|
|
1294
|
+
const thrownError = await assert.isRejected(
|
|
1295
|
+
meeting.joinWithMedia({joinOptions, mediaOptions})
|
|
1296
|
+
);
|
|
1297
|
+
|
|
1298
|
+
// join() runs once for the first attempt and once for the re-join
|
|
1299
|
+
assert.calledTwice(meeting.join);
|
|
1300
|
+
// the capacity error must take precedence over the stored firstError
|
|
1301
|
+
assert.equal(thrownError, capacityError);
|
|
1302
|
+
|
|
1303
|
+
assert.deepEqual(meeting.joinWithMediaRetryInfo, {
|
|
1304
|
+
retryCount: 0,
|
|
1305
|
+
prevJoinResponse: undefined,
|
|
1306
|
+
firstError: undefined,
|
|
1307
|
+
prevError: undefined,
|
|
1308
|
+
});
|
|
1309
|
+
});
|
|
1310
|
+
|
|
1184
1311
|
it('should re-join on retry when join() fails on first attempt, and throw the first error if join fails again', async () => {
|
|
1185
1312
|
const firstJoinError = new Error('first join error');
|
|
1186
1313
|
const secondJoinError = new Error('second join error');
|
|
@@ -2180,41 +2307,53 @@ describe('plugin-meetings', () => {
|
|
|
2180
2307
|
});
|
|
2181
2308
|
|
|
2182
2309
|
describe('#update hesiod llm id', () => {
|
|
2310
|
+
let mockVoiceaChannel;
|
|
2183
2311
|
beforeEach(() => {
|
|
2184
|
-
|
|
2312
|
+
mockVoiceaChannel = {
|
|
2313
|
+
onCaptionServiceIdUpdate: sinon.stub(),
|
|
2314
|
+
on: sinon.stub(),
|
|
2315
|
+
off: sinon.stub(),
|
|
2316
|
+
};
|
|
2317
|
+
meeting.voiceaChannel = mockVoiceaChannel;
|
|
2185
2318
|
});
|
|
2186
2319
|
afterEach(() => {
|
|
2187
2320
|
// Restore the original methods after each test
|
|
2188
2321
|
sinon.restore();
|
|
2189
2322
|
});
|
|
2190
|
-
it('should call
|
|
2323
|
+
it('should call voiceaChannel.onCaptionServiceIdUpdate when joined', async () => {
|
|
2191
2324
|
meeting.joinedWith = {state: 'JOINED'};
|
|
2192
2325
|
await meeting.locusInfo.emitScoped(
|
|
2193
2326
|
{function: 'test', file: 'test'},
|
|
2194
2327
|
LOCUSINFO.EVENTS.CONTROLS_MEETING_HESIOD_LLM_ID_UPDATED,
|
|
2195
2328
|
{hesiodLlmId: '123a-456b-789c'}
|
|
2196
2329
|
);
|
|
2197
|
-
assert.calledWith(
|
|
2330
|
+
assert.calledWith(mockVoiceaChannel.onCaptionServiceIdUpdate, '123a-456b-789c');
|
|
2198
2331
|
});
|
|
2199
2332
|
});
|
|
2200
2333
|
|
|
2201
2334
|
describe('#update spoken language', () => {
|
|
2335
|
+
let mockVoiceaChannel;
|
|
2202
2336
|
beforeEach(() => {
|
|
2203
|
-
|
|
2337
|
+
mockVoiceaChannel = {
|
|
2338
|
+
onSpokenLanguageUpdate: sinon.stub(),
|
|
2339
|
+
on: sinon.stub(),
|
|
2340
|
+
off: sinon.stub(),
|
|
2341
|
+
};
|
|
2342
|
+
meeting.voiceaChannel = mockVoiceaChannel;
|
|
2204
2343
|
meeting.transcription = {languageOptions: {currentSpokenLanguage: 'en'}};
|
|
2205
2344
|
});
|
|
2206
2345
|
afterEach(() => {
|
|
2207
2346
|
// Restore the original methods after each test
|
|
2208
2347
|
sinon.restore();
|
|
2209
2348
|
});
|
|
2210
|
-
it('should call
|
|
2349
|
+
it('should call voiceaChannel.onSpokenLanguageUpdate when joined', async () => {
|
|
2211
2350
|
meeting.joinedWith = {state: 'JOINED'};
|
|
2212
2351
|
await meeting.locusInfo.emitScoped(
|
|
2213
2352
|
{function: 'test', file: 'test'},
|
|
2214
2353
|
LOCUSINFO.EVENTS.CONTROLS_MEETING_TRANSCRIPTION_SPOKEN_LANGUAGE_UPDATED,
|
|
2215
2354
|
{spokenLanguage: 'fr'}
|
|
2216
2355
|
);
|
|
2217
|
-
assert.calledWith(
|
|
2356
|
+
assert.calledWith(mockVoiceaChannel.onSpokenLanguageUpdate, 'fr', meeting.id);
|
|
2218
2357
|
assert.equal(meeting.transcription.languageOptions.currentSpokenLanguage, 'fr');
|
|
2219
2358
|
assert.calledWith(
|
|
2220
2359
|
TriggerProxy.trigger,
|
|
@@ -2224,24 +2363,29 @@ describe('plugin-meetings', () => {
|
|
|
2224
2363
|
);
|
|
2225
2364
|
});
|
|
2226
2365
|
|
|
2227
|
-
it('should also call
|
|
2366
|
+
it('should also call voiceaChannel.onSpokenLanguageUpdate when not joined', async () => {
|
|
2228
2367
|
meeting.joinedWith = {state: 'NOT_JOINED'};
|
|
2229
2368
|
await meeting.locusInfo.emitScoped(
|
|
2230
2369
|
{function: 'test', file: 'test'},
|
|
2231
2370
|
LOCUSINFO.EVENTS.CONTROLS_MEETING_TRANSCRIPTION_SPOKEN_LANGUAGE_UPDATED,
|
|
2232
2371
|
{spokenLanguage: 'de'}
|
|
2233
2372
|
);
|
|
2234
|
-
assert.calledWith(
|
|
2373
|
+
assert.calledWith(mockVoiceaChannel.onSpokenLanguageUpdate, 'de');
|
|
2235
2374
|
assert.equal(meeting.transcription.languageOptions.currentSpokenLanguage, 'de');
|
|
2236
2375
|
});
|
|
2237
2376
|
});
|
|
2238
2377
|
|
|
2239
2378
|
describe('#startTranscription', () => {
|
|
2379
|
+
let mockVoiceaChannel;
|
|
2380
|
+
|
|
2240
2381
|
beforeEach(() => {
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2382
|
+
mockVoiceaChannel = {
|
|
2383
|
+
on: sinon.stub(),
|
|
2384
|
+
off: sinon.stub(),
|
|
2385
|
+
listenToEvents: sinon.stub(),
|
|
2386
|
+
turnOnCaptions: sinon.stub().resolves(),
|
|
2387
|
+
};
|
|
2388
|
+
meeting.voiceaChannel = mockVoiceaChannel;
|
|
2245
2389
|
});
|
|
2246
2390
|
|
|
2247
2391
|
it('should subscribe to events for the first time and avoid subscribing for future transcription starts', async () => {
|
|
@@ -2253,16 +2397,14 @@ describe('plugin-meetings', () => {
|
|
|
2253
2397
|
|
|
2254
2398
|
await meeting.startTranscription();
|
|
2255
2399
|
|
|
2256
|
-
assert.equal(
|
|
2400
|
+
assert.equal(mockVoiceaChannel.on.callCount, 4);
|
|
2257
2401
|
assert.equal(meeting.areVoiceaEventsSetup, true);
|
|
2258
|
-
assert.
|
|
2259
|
-
assert.called(webex.internal.voicea.turnOnCaptions);
|
|
2402
|
+
assert.calledOnce(mockVoiceaChannel.turnOnCaptions);
|
|
2260
2403
|
|
|
2261
2404
|
await meeting.startTranscription();
|
|
2262
|
-
assert.equal(
|
|
2405
|
+
assert.equal(mockVoiceaChannel.on.callCount, 4);
|
|
2263
2406
|
assert.equal(meeting.areVoiceaEventsSetup, true);
|
|
2264
|
-
assert.
|
|
2265
|
-
assert.calledTwice(webex.internal.voicea.turnOnCaptions);
|
|
2407
|
+
assert.calledTwice(mockVoiceaChannel.turnOnCaptions);
|
|
2266
2408
|
});
|
|
2267
2409
|
|
|
2268
2410
|
it('should listen to events and turnOnCaptions for all users', async () => {
|
|
@@ -2273,10 +2415,9 @@ describe('plugin-meetings', () => {
|
|
|
2273
2415
|
|
|
2274
2416
|
await meeting.startTranscription();
|
|
2275
2417
|
|
|
2276
|
-
assert.equal(
|
|
2418
|
+
assert.equal(mockVoiceaChannel.on.callCount, 4);
|
|
2277
2419
|
assert.equal(meeting.areVoiceaEventsSetup, true);
|
|
2278
|
-
assert.
|
|
2279
|
-
assert.calledOnce(webex.internal.voicea.turnOnCaptions);
|
|
2420
|
+
assert.calledOnce(mockVoiceaChannel.turnOnCaptions);
|
|
2280
2421
|
});
|
|
2281
2422
|
|
|
2282
2423
|
it("should throw error if request doesn't work", async () => {
|
|
@@ -2291,17 +2432,22 @@ describe('plugin-meetings', () => {
|
|
|
2291
2432
|
});
|
|
2292
2433
|
|
|
2293
2434
|
describe('#stopTranscription', () => {
|
|
2435
|
+
let mockVoiceaChannel;
|
|
2436
|
+
|
|
2294
2437
|
beforeEach(() => {
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2438
|
+
mockVoiceaChannel = {
|
|
2439
|
+
on: sinon.stub(),
|
|
2440
|
+
off: sinon.stub(),
|
|
2441
|
+
listenToEvents: sinon.stub(),
|
|
2442
|
+
turnOnCaptions: sinon.stub(),
|
|
2443
|
+
deregisterEvents: sinon.stub(),
|
|
2444
|
+
};
|
|
2445
|
+
meeting.voiceaChannel = mockVoiceaChannel;
|
|
2300
2446
|
});
|
|
2301
2447
|
|
|
2302
2448
|
it('should stop listening to voicea events and also trigger a stop event', () => {
|
|
2303
2449
|
meeting.stopTranscription();
|
|
2304
|
-
assert.equal(
|
|
2450
|
+
assert.equal(mockVoiceaChannel.off.callCount, 4);
|
|
2305
2451
|
assert.equal(meeting.areVoiceaEventsSetup, false);
|
|
2306
2452
|
assert.calledWith(
|
|
2307
2453
|
TriggerProxy.trigger,
|
|
@@ -2317,7 +2463,7 @@ describe('plugin-meetings', () => {
|
|
|
2317
2463
|
it('should stop listening to voicea events even when transcription is undefined', () => {
|
|
2318
2464
|
meeting.transcription = undefined;
|
|
2319
2465
|
meeting.stopTranscription();
|
|
2320
|
-
assert.equal(
|
|
2466
|
+
assert.equal(mockVoiceaChannel.off.callCount, 4);
|
|
2321
2467
|
assert.equal(meeting.areVoiceaEventsSetup, false);
|
|
2322
2468
|
assert.calledWith(
|
|
2323
2469
|
TriggerProxy.trigger,
|
|
@@ -2332,13 +2478,18 @@ describe('plugin-meetings', () => {
|
|
|
2332
2478
|
});
|
|
2333
2479
|
|
|
2334
2480
|
describe('#setCaptionLanguage', () => {
|
|
2481
|
+
let mockVoiceaChannel;
|
|
2482
|
+
|
|
2335
2483
|
beforeEach(() => {
|
|
2336
2484
|
meeting.isTranscriptionSupported = sinon.stub();
|
|
2337
2485
|
meeting.transcription = {languageOptions: {}};
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2486
|
+
mockVoiceaChannel = {
|
|
2487
|
+
on: sinon.stub(),
|
|
2488
|
+
off: sinon.stub(),
|
|
2489
|
+
setCaptionLanguage: sinon.stub(),
|
|
2490
|
+
requestLanguage: sinon.stub(),
|
|
2491
|
+
};
|
|
2492
|
+
meeting.voiceaChannel = mockVoiceaChannel;
|
|
2342
2493
|
});
|
|
2343
2494
|
|
|
2344
2495
|
afterEach(() => {
|
|
@@ -2360,7 +2511,7 @@ describe('plugin-meetings', () => {
|
|
|
2360
2511
|
const languageCode = 'fr';
|
|
2361
2512
|
|
|
2362
2513
|
meeting.setCaptionLanguage(languageCode).then((resolvedLanguageCode) => {
|
|
2363
|
-
assert.calledWith(
|
|
2514
|
+
assert.calledWith(mockVoiceaChannel.requestLanguage, languageCode);
|
|
2364
2515
|
assert.equal(resolvedLanguageCode, languageCode);
|
|
2365
2516
|
assert.equal(
|
|
2366
2517
|
meeting.transcription.languageOptions.currentCaptionLanguage,
|
|
@@ -2369,13 +2520,10 @@ describe('plugin-meetings', () => {
|
|
|
2369
2520
|
done();
|
|
2370
2521
|
});
|
|
2371
2522
|
|
|
2372
|
-
assert.calledOnceWithMatch(
|
|
2373
|
-
webex.internal.voicea.on,
|
|
2374
|
-
VOICEAEVENTS.CAPTION_LANGUAGE_UPDATE
|
|
2375
|
-
);
|
|
2523
|
+
assert.calledOnceWithMatch(mockVoiceaChannel.on, VOICEAEVENTS.CAPTION_LANGUAGE_UPDATE);
|
|
2376
2524
|
|
|
2377
2525
|
// Trigger the event
|
|
2378
|
-
const voiceaListenerLangugeUpdate =
|
|
2526
|
+
const voiceaListenerLangugeUpdate = mockVoiceaChannel.on.getCall(0).args[1];
|
|
2379
2527
|
voiceaListenerLangugeUpdate({statusCode: 200, languageCode});
|
|
2380
2528
|
});
|
|
2381
2529
|
|
|
@@ -2392,24 +2540,26 @@ describe('plugin-meetings', () => {
|
|
|
2392
2540
|
done();
|
|
2393
2541
|
});
|
|
2394
2542
|
|
|
2395
|
-
assert.calledOnceWithMatch(
|
|
2396
|
-
webex.internal.voicea.on,
|
|
2397
|
-
VOICEAEVENTS.CAPTION_LANGUAGE_UPDATE
|
|
2398
|
-
);
|
|
2543
|
+
assert.calledOnceWithMatch(mockVoiceaChannel.on, VOICEAEVENTS.CAPTION_LANGUAGE_UPDATE);
|
|
2399
2544
|
|
|
2400
2545
|
// Trigger the event
|
|
2401
|
-
const voiceaListenerLangugeUpdate =
|
|
2546
|
+
const voiceaListenerLangugeUpdate = mockVoiceaChannel.on.getCall(0).args[1];
|
|
2402
2547
|
voiceaListenerLangugeUpdate(rejectPayload);
|
|
2403
2548
|
});
|
|
2404
2549
|
});
|
|
2405
2550
|
|
|
2406
2551
|
describe('#setSpokenLanguage', () => {
|
|
2552
|
+
let mockVoiceaChannel;
|
|
2553
|
+
|
|
2407
2554
|
beforeEach(() => {
|
|
2408
2555
|
meeting.isTranscriptionSupported = sinon.stub();
|
|
2409
2556
|
meeting.transcription = {languageOptions: {}};
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2557
|
+
mockVoiceaChannel = {
|
|
2558
|
+
on: sinon.stub(),
|
|
2559
|
+
off: sinon.stub(),
|
|
2560
|
+
setSpokenLanguage: sinon.stub(),
|
|
2561
|
+
};
|
|
2562
|
+
meeting.voiceaChannel = mockVoiceaChannel;
|
|
2413
2563
|
meeting.roles = ['MODERATOR'];
|
|
2414
2564
|
});
|
|
2415
2565
|
|
|
@@ -2442,16 +2592,16 @@ describe('plugin-meetings', () => {
|
|
|
2442
2592
|
const languageCode = 'fr';
|
|
2443
2593
|
|
|
2444
2594
|
meeting.setSpokenLanguage(languageCode).then((resolvedLanguageCode) => {
|
|
2445
|
-
assert.calledWith(
|
|
2595
|
+
assert.calledWith(mockVoiceaChannel.setSpokenLanguage, languageCode);
|
|
2446
2596
|
assert.equal(resolvedLanguageCode, languageCode);
|
|
2447
2597
|
assert.equal(meeting.transcription.languageOptions.currentSpokenLanguage, languageCode);
|
|
2448
2598
|
done();
|
|
2449
2599
|
});
|
|
2450
2600
|
|
|
2451
|
-
assert.calledOnceWithMatch(
|
|
2601
|
+
assert.calledOnceWithMatch(mockVoiceaChannel.on, VOICEAEVENTS.SPOKEN_LANGUAGE_UPDATE);
|
|
2452
2602
|
|
|
2453
2603
|
// Trigger the event
|
|
2454
|
-
const voiceaListenerLangugeUpdate =
|
|
2604
|
+
const voiceaListenerLangugeUpdate = mockVoiceaChannel.on.getCall(0).args[1];
|
|
2455
2605
|
voiceaListenerLangugeUpdate({languageCode});
|
|
2456
2606
|
});
|
|
2457
2607
|
|
|
@@ -2467,10 +2617,10 @@ describe('plugin-meetings', () => {
|
|
|
2467
2617
|
done();
|
|
2468
2618
|
});
|
|
2469
2619
|
|
|
2470
|
-
assert.calledOnceWithMatch(
|
|
2620
|
+
assert.calledOnceWithMatch(mockVoiceaChannel.on, VOICEAEVENTS.SPOKEN_LANGUAGE_UPDATE);
|
|
2471
2621
|
|
|
2472
2622
|
// Trigger the event
|
|
2473
|
-
const voiceaListenerLangugeUpdate =
|
|
2623
|
+
const voiceaListenerLangugeUpdate = mockVoiceaChannel.on.getCall(0).args[1];
|
|
2474
2624
|
voiceaListenerLangugeUpdate(rejectPayload);
|
|
2475
2625
|
});
|
|
2476
2626
|
});
|
|
@@ -2739,68 +2889,111 @@ describe('plugin-meetings', () => {
|
|
|
2739
2889
|
});
|
|
2740
2890
|
|
|
2741
2891
|
[
|
|
2892
|
+
// Main session scenarios (no practice session active)
|
|
2742
2893
|
{
|
|
2743
2894
|
title:
|
|
2744
|
-
'should skip a reaction when the
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2895
|
+
'should skip a reaction when the relay route does not match the LLM binding (main session)',
|
|
2896
|
+
route: 'wrong-route',
|
|
2897
|
+
channelBinding: 'main-binding',
|
|
2898
|
+
practiceSessionConnected: false,
|
|
2899
|
+
practiceSessionBinding: undefined,
|
|
2749
2900
|
shouldProcess: false,
|
|
2750
|
-
expectedSessionLabel: 'default session',
|
|
2751
2901
|
},
|
|
2752
2902
|
{
|
|
2753
|
-
title:
|
|
2754
|
-
|
|
2755
|
-
route: '
|
|
2756
|
-
|
|
2757
|
-
|
|
2903
|
+
title:
|
|
2904
|
+
'should process a reaction when the relay route matches the LLM binding (main session)',
|
|
2905
|
+
route: 'main-binding',
|
|
2906
|
+
channelBinding: 'main-binding',
|
|
2907
|
+
practiceSessionConnected: false,
|
|
2908
|
+
practiceSessionBinding: undefined,
|
|
2758
2909
|
shouldProcess: true,
|
|
2759
2910
|
},
|
|
2760
2911
|
{
|
|
2761
|
-
title:
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2912
|
+
title: 'should process a reaction when no LLM channel exists',
|
|
2913
|
+
route: 'some-route',
|
|
2914
|
+
channelBinding: null, // No channel
|
|
2915
|
+
practiceSessionConnected: false,
|
|
2916
|
+
practiceSessionBinding: undefined,
|
|
2917
|
+
shouldProcess: true,
|
|
2918
|
+
},
|
|
2919
|
+
{
|
|
2920
|
+
title: 'should process a reaction when LLM channel has no binding',
|
|
2921
|
+
route: 'some-route',
|
|
2922
|
+
channelBinding: undefined, // Channel exists but no binding
|
|
2923
|
+
practiceSessionConnected: false,
|
|
2924
|
+
practiceSessionBinding: undefined,
|
|
2925
|
+
shouldProcess: true,
|
|
2926
|
+
},
|
|
2927
|
+
// Practice session active scenarios
|
|
2928
|
+
{
|
|
2929
|
+
title: 'should skip a reaction routed to main binding when practice session is active',
|
|
2930
|
+
route: 'main-binding',
|
|
2931
|
+
channelBinding: 'main-binding',
|
|
2932
|
+
practiceSessionConnected: true,
|
|
2933
|
+
practiceSessionBinding: 'ps-binding',
|
|
2934
|
+
shouldProcess: false,
|
|
2935
|
+
},
|
|
2936
|
+
{
|
|
2937
|
+
title: 'should process a reaction routed to PS binding when practice session is active',
|
|
2938
|
+
route: 'ps-binding',
|
|
2939
|
+
channelBinding: 'main-binding',
|
|
2940
|
+
practiceSessionConnected: true,
|
|
2941
|
+
practiceSessionBinding: 'ps-binding',
|
|
2767
2942
|
shouldProcess: true,
|
|
2768
2943
|
},
|
|
2769
2944
|
{
|
|
2770
2945
|
title:
|
|
2771
|
-
'should skip a reaction
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2946
|
+
'should skip a reaction routed to PS binding when practice session is NOT active',
|
|
2947
|
+
route: 'ps-binding',
|
|
2948
|
+
channelBinding: 'main-binding',
|
|
2949
|
+
practiceSessionConnected: false,
|
|
2950
|
+
practiceSessionBinding: 'ps-binding',
|
|
2776
2951
|
shouldProcess: false,
|
|
2777
|
-
|
|
2952
|
+
},
|
|
2953
|
+
{
|
|
2954
|
+
title:
|
|
2955
|
+
'should process a reaction routed to main binding when practice session is NOT active',
|
|
2956
|
+
route: 'main-binding',
|
|
2957
|
+
channelBinding: 'main-binding',
|
|
2958
|
+
practiceSessionConnected: false,
|
|
2959
|
+
practiceSessionBinding: 'ps-binding',
|
|
2960
|
+
shouldProcess: true,
|
|
2778
2961
|
},
|
|
2779
2962
|
].forEach(
|
|
2780
2963
|
({
|
|
2781
2964
|
title,
|
|
2782
|
-
isPracticeSessionConnected,
|
|
2783
2965
|
route,
|
|
2784
|
-
|
|
2785
|
-
|
|
2966
|
+
channelBinding,
|
|
2967
|
+
practiceSessionConnected,
|
|
2968
|
+
practiceSessionBinding,
|
|
2786
2969
|
shouldProcess,
|
|
2787
|
-
expectedSessionLabel,
|
|
2788
2970
|
}) => {
|
|
2789
2971
|
it(title, () => {
|
|
2790
2972
|
meeting.isReactionsSupported = sinon.stub().returns(true);
|
|
2791
2973
|
meeting.config.receiveReactions = true;
|
|
2792
2974
|
const fakeSendersName = 'Fake reactors name';
|
|
2793
2975
|
meeting.members.membersCollection.get = sinon.stub().returns({name: fakeSendersName});
|
|
2794
|
-
webex.internal.llm.isConnected = sinon.stub().callsFake((llmSessionId) => {
|
|
2795
|
-
return llmSessionId === LLM_PRACTICE_SESSION && isPracticeSessionConnected;
|
|
2796
|
-
});
|
|
2797
|
-
webex.internal.llm.getBinding = sinon.stub().callsFake((llmSessionId) => {
|
|
2798
|
-
if (llmSessionId === LLM_PRACTICE_SESSION) {
|
|
2799
|
-
return practiceBinding;
|
|
2800
|
-
}
|
|
2801
2976
|
|
|
2802
|
-
|
|
2803
|
-
|
|
2977
|
+
// Mock the llmChannel on the meeting
|
|
2978
|
+
if (channelBinding === null) {
|
|
2979
|
+
meeting.llmChannel = undefined;
|
|
2980
|
+
} else {
|
|
2981
|
+
meeting.llmChannel = {
|
|
2982
|
+
getBinding: sinon.stub().returns(channelBinding),
|
|
2983
|
+
};
|
|
2984
|
+
}
|
|
2985
|
+
|
|
2986
|
+
// Mock the webinar with practice session state
|
|
2987
|
+
meeting.webinar = {
|
|
2988
|
+
_practiceSessionLLMChannel: practiceSessionConnected
|
|
2989
|
+
? {isConnected: sinon.stub().returns(true)}
|
|
2990
|
+
: undefined,
|
|
2991
|
+
isPracticeSessionLLMChannelConnected: sinon
|
|
2992
|
+
.stub()
|
|
2993
|
+
.returns(practiceSessionConnected),
|
|
2994
|
+
getPracticeSessionBinding: sinon.stub().returns(practiceSessionBinding),
|
|
2995
|
+
};
|
|
2996
|
+
|
|
2804
2997
|
const fakeReactionPayload = {
|
|
2805
2998
|
type: 'fake_type',
|
|
2806
2999
|
codepoints: 'fake_codepoints',
|
|
@@ -2848,10 +3041,15 @@ describe('plugin-meetings', () => {
|
|
|
2848
3041
|
});
|
|
2849
3042
|
|
|
2850
3043
|
describe('#handleLLMOnline', () => {
|
|
3044
|
+
let mockVoiceaChannel;
|
|
3045
|
+
|
|
2851
3046
|
beforeEach(() => {
|
|
2852
3047
|
webex.internal.llm.off = sinon.stub();
|
|
2853
|
-
|
|
2854
|
-
|
|
3048
|
+
mockVoiceaChannel = {
|
|
3049
|
+
getKeepTranscriptionSubscribed: sinon.stub().returns(false),
|
|
3050
|
+
updateSubchannelSubscriptions: sinon.stub(),
|
|
3051
|
+
};
|
|
3052
|
+
meeting.voiceaChannel = mockVoiceaChannel;
|
|
2855
3053
|
});
|
|
2856
3054
|
|
|
2857
3055
|
it('emits transcription connected events', () => {
|
|
@@ -2868,21 +3066,21 @@ describe('plugin-meetings', () => {
|
|
|
2868
3066
|
});
|
|
2869
3067
|
|
|
2870
3068
|
it('restores transcription subscription when caption intent is enabled', () => {
|
|
2871
|
-
|
|
3069
|
+
mockVoiceaChannel.getKeepTranscriptionSubscribed.returns(true);
|
|
2872
3070
|
|
|
2873
3071
|
meeting.handleLLMOnline();
|
|
2874
3072
|
|
|
2875
|
-
assert.calledOnceWithExactly(
|
|
3073
|
+
assert.calledOnceWithExactly(mockVoiceaChannel.updateSubchannelSubscriptions, {
|
|
2876
3074
|
subscribe: ['transcription'],
|
|
2877
3075
|
});
|
|
2878
3076
|
});
|
|
2879
3077
|
|
|
2880
3078
|
it('does not restore transcription subscription when caption intent is disabled', () => {
|
|
2881
|
-
|
|
3079
|
+
mockVoiceaChannel.getKeepTranscriptionSubscribed.returns(false);
|
|
2882
3080
|
|
|
2883
3081
|
meeting.handleLLMOnline();
|
|
2884
3082
|
|
|
2885
|
-
assert.notCalled(
|
|
3083
|
+
assert.notCalled(mockVoiceaChannel.updateSubchannelSubscriptions);
|
|
2886
3084
|
});
|
|
2887
3085
|
|
|
2888
3086
|
it('calls syncAllHashTreeDatasets on locusInfo', () => {
|
|
@@ -2944,7 +3142,10 @@ describe('plugin-meetings', () => {
|
|
|
2944
3142
|
assert.calledOnce(MeetingUtil.joinMeeting);
|
|
2945
3143
|
assert.calledOnce(webex.internal.device.meetingStarted);
|
|
2946
3144
|
assert.equal(result, joinMeetingResult);
|
|
2947
|
-
|
|
3145
|
+
// With factory pattern, event is registered on the channel, not the plugin
|
|
3146
|
+
if (meeting.llmChannel) {
|
|
3147
|
+
assert.calledWith(meeting.llmChannel.on, 'online', meeting.handleLLMOnline);
|
|
3148
|
+
}
|
|
2948
3149
|
});
|
|
2949
3150
|
|
|
2950
3151
|
[true, false].forEach((enableMultistream) => {
|
|
@@ -3170,12 +3371,14 @@ describe('plugin-meetings', () => {
|
|
|
3170
3371
|
sinon.stub(meeting, 'isJoined').returns(true);
|
|
3171
3372
|
|
|
3172
3373
|
let locusLLMEventListener;
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3374
|
+
const mockChannel = createMockLLMChannel({
|
|
3375
|
+
on: sinon.stub().callsFake((eventName, callback) => {
|
|
3376
|
+
if (eventName === 'event:locus.state_message') {
|
|
3377
|
+
locusLLMEventListener = callback;
|
|
3378
|
+
}
|
|
3379
|
+
}),
|
|
3177
3380
|
});
|
|
3178
|
-
|
|
3381
|
+
webex.internal.llm.createChannel = sinon.stub().returns(mockChannel);
|
|
3179
3382
|
|
|
3180
3383
|
meeting.updateLLMConnection.restore();
|
|
3181
3384
|
|
|
@@ -3198,9 +3401,9 @@ describe('plugin-meetings', () => {
|
|
|
3198
3401
|
|
|
3199
3402
|
it('UpdateLLMConnection sends a metric if not connected after timeout', async () => {
|
|
3200
3403
|
sinon.stub(meeting, 'isJoined').returns(true);
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3404
|
+
|
|
3405
|
+
const mockChannel = createMockLLMChannel({hasEverConnected: true});
|
|
3406
|
+
webex.internal.llm.createChannel = sinon.stub().returns(mockChannel);
|
|
3204
3407
|
|
|
3205
3408
|
meeting.updateLLMConnection.restore();
|
|
3206
3409
|
|
|
@@ -3274,10 +3477,10 @@ describe('plugin-meetings', () => {
|
|
|
3274
3477
|
|
|
3275
3478
|
it('does not emit failed breakout join response metric when breakout session is missing', async () => {
|
|
3276
3479
|
sinon.stub(meeting, 'isJoined').returns(true);
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3480
|
+
const mockChannel = createMockLLMChannel({
|
|
3481
|
+
registerAndConnect: sinon.stub().rejects(new Error('failed to connect LLM')),
|
|
3482
|
+
});
|
|
3483
|
+
webex.internal.llm.createChannel = sinon.stub().returns(mockChannel);
|
|
3281
3484
|
|
|
3282
3485
|
meeting.meetingInfo.enableConvergedArchitecture = true;
|
|
3283
3486
|
meeting.breakouts.set('breakoutMoveId', 'move-id-1');
|
|
@@ -3301,11 +3504,13 @@ describe('plugin-meetings', () => {
|
|
|
3301
3504
|
|
|
3302
3505
|
it('emits llm breakout join response metric after suppressing join response without llmLatency', async () => {
|
|
3303
3506
|
sinon.stub(meeting, 'isJoined').returns(true);
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3507
|
+
const mockChannel = createMockLLMChannel({
|
|
3508
|
+
registerAndConnect: sinon.stub().resolves({
|
|
3509
|
+
clientLLMDatachannelResponseTime: 10,
|
|
3510
|
+
clientLLMWebSocketConnectTime: 20,
|
|
3511
|
+
}),
|
|
3308
3512
|
});
|
|
3513
|
+
webex.internal.llm.createChannel = sinon.stub().returns(mockChannel);
|
|
3309
3514
|
|
|
3310
3515
|
meeting.config.enableAutomaticLLM = true;
|
|
3311
3516
|
meeting.meetingInfo.enableConvergedArchitecture = true;
|
|
@@ -3337,11 +3542,13 @@ describe('plugin-meetings', () => {
|
|
|
3337
3542
|
|
|
3338
3543
|
it('emits breakout join response metric with llmLatency when returning to main session', async () => {
|
|
3339
3544
|
sinon.stub(meeting, 'isJoined').returns(true);
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3545
|
+
const mockChannel = createMockLLMChannel({
|
|
3546
|
+
registerAndConnect: sinon.stub().resolves({
|
|
3547
|
+
clientLLMDatachannelResponseTime: 10,
|
|
3548
|
+
clientLLMWebSocketConnectTime: 20,
|
|
3549
|
+
}),
|
|
3344
3550
|
});
|
|
3551
|
+
webex.internal.llm.createChannel = sinon.stub().returns(mockChannel);
|
|
3345
3552
|
|
|
3346
3553
|
meeting.meetingInfo.enableConvergedArchitecture = true;
|
|
3347
3554
|
meeting.breakouts.set('breakoutMoveId', 'move-id-1');
|
|
@@ -3370,10 +3577,12 @@ describe('plugin-meetings', () => {
|
|
|
3370
3577
|
|
|
3371
3578
|
it('uses the partial datachannel timing from the error when the websocket connect fails', async () => {
|
|
3372
3579
|
sinon.stub(meeting, 'isJoined').returns(true);
|
|
3373
|
-
sinon.stub(meeting.webex.internal.llm, 'isConnected').returns(false);
|
|
3374
3580
|
const connectError = new Error('failed to connect LLM');
|
|
3375
3581
|
connectError.timing = {clientLLMDatachannelResponseTime: 42};
|
|
3376
|
-
|
|
3582
|
+
const mockChannel = createMockLLMChannel({
|
|
3583
|
+
registerAndConnect: sinon.stub().rejects(connectError),
|
|
3584
|
+
});
|
|
3585
|
+
webex.internal.llm.createChannel = sinon.stub().returns(mockChannel);
|
|
3377
3586
|
|
|
3378
3587
|
meeting.meetingInfo.enableConvergedArchitecture = true;
|
|
3379
3588
|
meeting.breakouts.set('breakoutMoveId', 'move-id-1');
|
|
@@ -3407,10 +3616,12 @@ describe('plugin-meetings', () => {
|
|
|
3407
3616
|
|
|
3408
3617
|
it('reports the partial datachannel timing on client.llm.connect.response when the websocket connect fails during initial join', async () => {
|
|
3409
3618
|
sinon.stub(meeting, 'isJoined').returns(true);
|
|
3410
|
-
sinon.stub(meeting.webex.internal.llm, 'isConnected').returns(false);
|
|
3411
3619
|
const connectError = new Error('failed to connect LLM');
|
|
3412
3620
|
connectError.timing = {clientLLMDatachannelResponseTime: 42};
|
|
3413
|
-
|
|
3621
|
+
const mockChannel = createMockLLMChannel({
|
|
3622
|
+
registerAndConnect: sinon.stub().rejects(connectError),
|
|
3623
|
+
});
|
|
3624
|
+
webex.internal.llm.createChannel = sinon.stub().returns(mockChannel);
|
|
3414
3625
|
|
|
3415
3626
|
webex.internal.newMetrics.submitClientEvent.resetHistory();
|
|
3416
3627
|
meeting.updateLLMConnection.restore();
|
|
@@ -3435,32 +3646,32 @@ describe('plugin-meetings', () => {
|
|
|
3435
3646
|
|
|
3436
3647
|
it('clears the LLM health check timer when disconnecting LLM', async () => {
|
|
3437
3648
|
const isJoinedStub = sinon.stub(meeting, 'isJoined');
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
sinon
|
|
3442
|
-
.stub(meeting.webex.internal.llm, 'getLocusUrl')
|
|
3443
|
-
.returns('https://locus1.example.com');
|
|
3444
|
-
sinon
|
|
3445
|
-
.stub(meeting.webex.internal.llm, 'getDatachannelUrl')
|
|
3446
|
-
.returns('https://datachannel1.example.com');
|
|
3649
|
+
|
|
3650
|
+
const mockChannel = createMockLLMChannel();
|
|
3651
|
+
webex.internal.llm.createChannel = sinon.stub().returns(mockChannel);
|
|
3447
3652
|
|
|
3448
3653
|
meeting.updateLLMConnection.restore();
|
|
3449
3654
|
|
|
3655
|
+
// First: join and connect
|
|
3450
3656
|
isJoinedStub.returns(true);
|
|
3451
|
-
meeting.webex.internal.llm.isConnected.returns(false);
|
|
3452
3657
|
await meeting.updateLLMConnection();
|
|
3453
3658
|
|
|
3454
3659
|
assert.exists(meeting.llmHealthCheckTimer);
|
|
3455
3660
|
|
|
3661
|
+
// Simulate existing connected channel that will be cleaned up
|
|
3662
|
+
mockChannel.isConnected.returns(true);
|
|
3663
|
+
meeting.llmChannel = mockChannel;
|
|
3664
|
+
|
|
3665
|
+
// Now leave the meeting - this should trigger cleanup
|
|
3456
3666
|
isJoinedStub.returns(false);
|
|
3457
|
-
meeting.
|
|
3667
|
+
meeting.locusInfo.url = 'some-url';
|
|
3668
|
+
meeting.locusInfo.info = {datachannelUrl: 'some-datachannel-url'};
|
|
3458
3669
|
|
|
3459
3670
|
await meeting.updateLLMConnection();
|
|
3460
3671
|
|
|
3461
|
-
|
|
3462
|
-
|
|
3672
|
+
// After cleanup (not joined), timer should be cleared
|
|
3463
3673
|
assert.isUndefined(meeting.llmHealthCheckTimer);
|
|
3674
|
+
assert.calledOnce(mockChannel.disconnect);
|
|
3464
3675
|
|
|
3465
3676
|
Metrics.sendBehavioralMetric.resetHistory();
|
|
3466
3677
|
fakeClock.tick(3 * 60 * 1000);
|
|
@@ -8078,6 +8289,13 @@ describe('plugin-meetings', () => {
|
|
|
8078
8289
|
it('stops listening for LLM/Mercury and tears down transcription and annotation before calling Locus /leave', async () => {
|
|
8079
8290
|
const onlineHandler = meeting.mercuryOnlineHandler;
|
|
8080
8291
|
const offlineHandler = meeting.mercuryOfflineHandler;
|
|
8292
|
+
meeting.areVoiceaEventsSetup = true;
|
|
8293
|
+
|
|
8294
|
+
// Set up llmChannel with mock off function
|
|
8295
|
+
meeting.llmChannel = {
|
|
8296
|
+
off: sinon.stub(),
|
|
8297
|
+
disconnect: sinon.stub().resolves(),
|
|
8298
|
+
};
|
|
8081
8299
|
|
|
8082
8300
|
await meeting.leave();
|
|
8083
8301
|
|
|
@@ -8086,19 +8304,19 @@ describe('plugin-meetings', () => {
|
|
|
8086
8304
|
// in-flight events do not trigger unnecessary Locus syncs
|
|
8087
8305
|
// (per Locus team recommendation).
|
|
8088
8306
|
assert.callOrder(
|
|
8089
|
-
|
|
8307
|
+
meeting.llmChannel.off,
|
|
8090
8308
|
webex.internal.mercury.off,
|
|
8091
8309
|
meeting.stopTranscription,
|
|
8092
8310
|
meeting.annotation.deregisterEvents,
|
|
8093
8311
|
meeting.meetingRequest.leaveMeeting
|
|
8094
8312
|
);
|
|
8095
8313
|
assert.calledWithExactly(
|
|
8096
|
-
|
|
8314
|
+
meeting.llmChannel.off,
|
|
8097
8315
|
'event:relay.event',
|
|
8098
8316
|
meeting.processRelayEvent
|
|
8099
8317
|
);
|
|
8100
8318
|
assert.calledWithExactly(
|
|
8101
|
-
|
|
8319
|
+
meeting.llmChannel.off,
|
|
8102
8320
|
LOCUS_LLM_EVENT,
|
|
8103
8321
|
meeting.processLocusLLMEvent
|
|
8104
8322
|
);
|
|
@@ -8108,25 +8326,35 @@ describe('plugin-meetings', () => {
|
|
|
8108
8326
|
assert.isUndefined(meeting.mercuryOfflineHandler);
|
|
8109
8327
|
assert.calledOnceWithExactly(meeting.stopTranscription);
|
|
8110
8328
|
assert.calledOnceWithExactly(meeting.annotation.deregisterEvents);
|
|
8111
|
-
|
|
8329
|
+
// Transcription is reset to initial state (not undefined)
|
|
8330
|
+
assert.isDefined(meeting.transcription);
|
|
8331
|
+
assert.deepEqual(meeting.transcription.captions, []);
|
|
8332
|
+
assert.equal(meeting.transcription.isCaptioning, false);
|
|
8112
8333
|
});
|
|
8113
8334
|
|
|
8114
8335
|
it('tears down llm/mercury/transcription/annotation even when /leave rejects', async () => {
|
|
8115
8336
|
const onlineHandler = meeting.mercuryOnlineHandler;
|
|
8116
8337
|
const offlineHandler = meeting.mercuryOfflineHandler;
|
|
8338
|
+
meeting.areVoiceaEventsSetup = true;
|
|
8117
8339
|
meeting.meetingRequest.leaveMeeting = sinon
|
|
8118
8340
|
.stub()
|
|
8119
8341
|
.returns(Promise.reject(new Error('leave failed')));
|
|
8120
8342
|
|
|
8343
|
+
// Set up llmChannel with mock off function
|
|
8344
|
+
meeting.llmChannel = {
|
|
8345
|
+
off: sinon.stub(),
|
|
8346
|
+
disconnect: sinon.stub().resolves(),
|
|
8347
|
+
};
|
|
8348
|
+
|
|
8121
8349
|
await meeting.leave().catch(() => {});
|
|
8122
8350
|
|
|
8123
8351
|
assert.calledWithExactly(
|
|
8124
|
-
|
|
8352
|
+
meeting.llmChannel.off,
|
|
8125
8353
|
'event:relay.event',
|
|
8126
8354
|
meeting.processRelayEvent
|
|
8127
8355
|
);
|
|
8128
8356
|
assert.calledWithExactly(
|
|
8129
|
-
|
|
8357
|
+
meeting.llmChannel.off,
|
|
8130
8358
|
LOCUS_LLM_EVENT,
|
|
8131
8359
|
meeting.processLocusLLMEvent
|
|
8132
8360
|
);
|
|
@@ -10220,6 +10448,13 @@ describe('plugin-meetings', () => {
|
|
|
10220
10448
|
it('stops listening for LLM/Mercury and tears down transcription and annotation before calling Locus /end', async () => {
|
|
10221
10449
|
const onlineHandler = meeting.mercuryOnlineHandler;
|
|
10222
10450
|
const offlineHandler = meeting.mercuryOfflineHandler;
|
|
10451
|
+
meeting.areVoiceaEventsSetup = true;
|
|
10452
|
+
|
|
10453
|
+
// Set up llmChannel with mock off function
|
|
10454
|
+
meeting.llmChannel = {
|
|
10455
|
+
off: sinon.stub(),
|
|
10456
|
+
disconnect: sinon.stub().resolves(),
|
|
10457
|
+
};
|
|
10223
10458
|
|
|
10224
10459
|
await meeting.endMeetingForAll();
|
|
10225
10460
|
|
|
@@ -10228,19 +10463,19 @@ describe('plugin-meetings', () => {
|
|
|
10228
10463
|
// in-flight events do not trigger unnecessary Locus syncs
|
|
10229
10464
|
// (per Locus team recommendation).
|
|
10230
10465
|
assert.callOrder(
|
|
10231
|
-
|
|
10466
|
+
meeting.llmChannel.off,
|
|
10232
10467
|
webex.internal.mercury.off,
|
|
10233
10468
|
meeting.stopTranscription,
|
|
10234
10469
|
meeting.annotation.deregisterEvents,
|
|
10235
10470
|
meeting.meetingRequest.endMeetingForAll
|
|
10236
10471
|
);
|
|
10237
10472
|
assert.calledWithExactly(
|
|
10238
|
-
|
|
10473
|
+
meeting.llmChannel.off,
|
|
10239
10474
|
'event:relay.event',
|
|
10240
10475
|
meeting.processRelayEvent
|
|
10241
10476
|
);
|
|
10242
10477
|
assert.calledWithExactly(
|
|
10243
|
-
|
|
10478
|
+
meeting.llmChannel.off,
|
|
10244
10479
|
LOCUS_LLM_EVENT,
|
|
10245
10480
|
meeting.processLocusLLMEvent
|
|
10246
10481
|
);
|
|
@@ -10255,19 +10490,26 @@ describe('plugin-meetings', () => {
|
|
|
10255
10490
|
it('tears down llm/mercury/transcription/annotation even when /end rejects', async () => {
|
|
10256
10491
|
const onlineHandler = meeting.mercuryOnlineHandler;
|
|
10257
10492
|
const offlineHandler = meeting.mercuryOfflineHandler;
|
|
10493
|
+
meeting.areVoiceaEventsSetup = true;
|
|
10258
10494
|
meeting.meetingRequest.endMeetingForAll = sinon
|
|
10259
10495
|
.stub()
|
|
10260
10496
|
.returns(Promise.reject(new Error('end failed')));
|
|
10261
10497
|
|
|
10498
|
+
// Set up llmChannel with mock off function
|
|
10499
|
+
meeting.llmChannel = {
|
|
10500
|
+
off: sinon.stub(),
|
|
10501
|
+
disconnect: sinon.stub().resolves(),
|
|
10502
|
+
};
|
|
10503
|
+
|
|
10262
10504
|
await meeting.endMeetingForAll().catch(() => {});
|
|
10263
10505
|
|
|
10264
10506
|
assert.calledWithExactly(
|
|
10265
|
-
|
|
10507
|
+
meeting.llmChannel.off,
|
|
10266
10508
|
'event:relay.event',
|
|
10267
10509
|
meeting.processRelayEvent
|
|
10268
10510
|
);
|
|
10269
10511
|
assert.calledWithExactly(
|
|
10270
|
-
|
|
10512
|
+
meeting.llmChannel.off,
|
|
10271
10513
|
LOCUS_LLM_EVENT,
|
|
10272
10514
|
meeting.processLocusLLMEvent
|
|
10273
10515
|
);
|
|
@@ -14820,41 +15062,28 @@ describe('plugin-meetings', () => {
|
|
|
14820
15062
|
|
|
14821
15063
|
describe('#saveDataChannelToken', () => {
|
|
14822
15064
|
beforeEach(() => {
|
|
14823
|
-
|
|
14824
|
-
|
|
14825
|
-
.stub()
|
|
14826
|
-
.returns({currentOwner: undefined, isOwner: true});
|
|
14827
|
-
webex.internal.llm.isConnected = sinon.stub().returns(false);
|
|
15065
|
+
meeting._pendingDatachannelToken = undefined;
|
|
15066
|
+
meeting.webinar._pendingPracticeSessionDatachannelToken = undefined;
|
|
14828
15067
|
});
|
|
14829
15068
|
|
|
14830
|
-
it('saves datachannelToken
|
|
15069
|
+
it('saves datachannelToken to _pendingDatachannelToken', () => {
|
|
14831
15070
|
meeting.saveDataChannelToken({
|
|
14832
15071
|
locus: {
|
|
14833
15072
|
self: {datachannelToken: 'default-token'},
|
|
14834
15073
|
},
|
|
14835
15074
|
});
|
|
14836
15075
|
|
|
14837
|
-
assert.
|
|
14838
|
-
webex.internal.llm.setDatachannelToken,
|
|
14839
|
-
'default-token',
|
|
14840
|
-
'llm-default-session',
|
|
14841
|
-
meeting.id
|
|
14842
|
-
);
|
|
15076
|
+
assert.equal(meeting._pendingDatachannelToken, 'default-token');
|
|
14843
15077
|
});
|
|
14844
15078
|
|
|
14845
|
-
it('saves practiceSessionDatachannelToken
|
|
15079
|
+
it('saves practiceSessionDatachannelToken to webinar._pendingPracticeSessionDatachannelToken', () => {
|
|
14846
15080
|
meeting.saveDataChannelToken({
|
|
14847
15081
|
locus: {
|
|
14848
15082
|
self: {practiceSessionDatachannelToken: 'ps-token'},
|
|
14849
15083
|
},
|
|
14850
15084
|
});
|
|
14851
15085
|
|
|
14852
|
-
assert.
|
|
14853
|
-
webex.internal.llm.setDatachannelToken,
|
|
14854
|
-
'ps-token',
|
|
14855
|
-
'llm-practice-session',
|
|
14856
|
-
meeting.id
|
|
14857
|
-
);
|
|
15086
|
+
assert.equal(meeting.webinar._pendingPracticeSessionDatachannelToken, 'ps-token');
|
|
14858
15087
|
});
|
|
14859
15088
|
|
|
14860
15089
|
it('saves both tokens when both are present', () => {
|
|
@@ -14867,100 +15096,93 @@ describe('plugin-meetings', () => {
|
|
|
14867
15096
|
},
|
|
14868
15097
|
});
|
|
14869
15098
|
|
|
14870
|
-
assert.
|
|
14871
|
-
assert.
|
|
14872
|
-
webex.internal.llm.setDatachannelToken,
|
|
14873
|
-
'default-token',
|
|
14874
|
-
'llm-default-session',
|
|
14875
|
-
meeting.id
|
|
14876
|
-
);
|
|
14877
|
-
assert.calledWithExactly(
|
|
14878
|
-
webex.internal.llm.setDatachannelToken,
|
|
14879
|
-
'ps-token',
|
|
14880
|
-
'llm-practice-session',
|
|
14881
|
-
meeting.id
|
|
14882
|
-
);
|
|
15099
|
+
assert.equal(meeting._pendingDatachannelToken, 'default-token');
|
|
15100
|
+
assert.equal(meeting.webinar._pendingPracticeSessionDatachannelToken, 'ps-token');
|
|
14883
15101
|
});
|
|
14884
15102
|
|
|
14885
|
-
it('does not
|
|
15103
|
+
it('does not set pending tokens when no tokens are present', () => {
|
|
14886
15104
|
meeting.saveDataChannelToken({locus: {self: {}}});
|
|
14887
15105
|
|
|
14888
|
-
assert.
|
|
15106
|
+
assert.isUndefined(meeting._pendingDatachannelToken);
|
|
15107
|
+
assert.isUndefined(meeting.webinar._pendingPracticeSessionDatachannelToken);
|
|
14889
15108
|
});
|
|
14890
15109
|
|
|
14891
15110
|
it('handles undefined join gracefully', () => {
|
|
14892
15111
|
meeting.saveDataChannelToken(undefined);
|
|
14893
15112
|
|
|
14894
|
-
assert.
|
|
15113
|
+
assert.isUndefined(meeting._pendingDatachannelToken);
|
|
15114
|
+
assert.isUndefined(meeting.webinar._pendingPracticeSessionDatachannelToken);
|
|
14895
15115
|
});
|
|
14896
15116
|
|
|
14897
15117
|
it('handles missing locus.self gracefully', () => {
|
|
14898
15118
|
meeting.saveDataChannelToken({locus: {}});
|
|
14899
15119
|
|
|
14900
|
-
assert.
|
|
15120
|
+
assert.isUndefined(meeting._pendingDatachannelToken);
|
|
15121
|
+
assert.isUndefined(meeting.webinar._pendingPracticeSessionDatachannelToken);
|
|
14901
15122
|
});
|
|
14902
15123
|
|
|
14903
|
-
it('
|
|
15124
|
+
it('sets token on llmChannel if it exists', () => {
|
|
15125
|
+
const mockChannel = {
|
|
15126
|
+
setDatachannelToken: sinon.stub(),
|
|
15127
|
+
};
|
|
15128
|
+
meeting.llmChannel = mockChannel;
|
|
15129
|
+
|
|
14904
15130
|
meeting.saveDataChannelToken({
|
|
14905
15131
|
locus: {
|
|
14906
15132
|
self: {datachannelToken: 'default-token'},
|
|
14907
15133
|
},
|
|
14908
15134
|
});
|
|
14909
15135
|
|
|
14910
|
-
assert.calledOnceWithExactly(
|
|
14911
|
-
webex.internal.llm.setDatachannelToken,
|
|
14912
|
-
'default-token',
|
|
14913
|
-
'llm-default-session',
|
|
14914
|
-
meeting.id
|
|
14915
|
-
);
|
|
15136
|
+
assert.calledOnceWithExactly(mockChannel.setDatachannelToken, 'default-token');
|
|
14916
15137
|
});
|
|
14917
15138
|
});
|
|
14918
15139
|
|
|
14919
|
-
describe('#
|
|
15140
|
+
describe('#updateLLMConnection', () => {
|
|
15141
|
+
let mockChannel;
|
|
15142
|
+
let mockVoiceaChannel;
|
|
15143
|
+
|
|
14920
15144
|
beforeEach(() => {
|
|
14921
|
-
|
|
14922
|
-
|
|
15145
|
+
// Create a mock channel that createChannel will return
|
|
15146
|
+
mockChannel = createMockLLMChannel({
|
|
15147
|
+
registerAndConnect: sinon.stub().resolves('something'),
|
|
15148
|
+
});
|
|
14923
15149
|
|
|
14924
|
-
|
|
14925
|
-
|
|
15150
|
+
// Create a mock voicea channel
|
|
15151
|
+
mockVoiceaChannel = {
|
|
15152
|
+
on: sinon.stub(),
|
|
15153
|
+
off: sinon.stub(),
|
|
15154
|
+
onSpokenLanguageUpdate: sinon.stub(),
|
|
15155
|
+
onCaptionServiceIdUpdate: sinon.stub(),
|
|
15156
|
+
requestLanguage: sinon.stub(),
|
|
15157
|
+
setSpokenLanguage: sinon.stub(),
|
|
15158
|
+
turnOnCaptions: sinon.stub().resolves(),
|
|
15159
|
+
listenToEvents: sinon.stub(),
|
|
15160
|
+
deregisterEvents: sinon.stub(),
|
|
15161
|
+
getIsCaptionBoxOn: sinon.stub().returns(false),
|
|
15162
|
+
updateSubchannelSubscriptions: sinon.stub(),
|
|
15163
|
+
switchLLMChannel: sinon.stub().resolves(),
|
|
15164
|
+
isLLMConnected: sinon.stub().returns(true),
|
|
15165
|
+
getKeepTranscriptionSubscribed: sinon.stub().returns(false),
|
|
15166
|
+
};
|
|
14926
15167
|
|
|
14927
|
-
|
|
14928
|
-
|
|
14929
|
-
'llm-default-session',
|
|
14930
|
-
meeting.id
|
|
14931
|
-
);
|
|
14932
|
-
assert.calledWithExactly(
|
|
14933
|
-
webex.internal.llm.clearDatachannelToken,
|
|
14934
|
-
'llm-practice-session',
|
|
14935
|
-
meeting.id
|
|
14936
|
-
);
|
|
14937
|
-
assert.callCount(webex.internal.llm.clearDatachannelToken, 2);
|
|
14938
|
-
});
|
|
14939
|
-
});
|
|
15168
|
+
webex.internal.llm.createChannel = sinon.stub().returns(mockChannel);
|
|
15169
|
+
webex.internal.voicea.createChannel = sinon.stub().returns(mockVoiceaChannel);
|
|
14940
15170
|
|
|
14941
|
-
|
|
14942
|
-
|
|
14943
|
-
webex.internal.llm.isConnected = sinon.stub().returns(false);
|
|
14944
|
-
webex.internal.llm.getLocusUrl = sinon.stub();
|
|
14945
|
-
webex.internal.llm.getDatachannelUrl = sinon.stub();
|
|
14946
|
-
webex.internal.llm.registerAndConnect = sinon.stub().resolves('something');
|
|
14947
|
-
webex.internal.llm.setRefreshHandler = sinon.stub();
|
|
14948
|
-
webex.internal.llm.disconnectLLM = sinon.stub().resolves();
|
|
14949
|
-
webex.internal.llm.on = sinon.stub();
|
|
14950
|
-
webex.internal.llm.off = sinon.stub();
|
|
14951
|
-
webex.internal.llm.getDatachannelToken = sinon.stub().returns(undefined);
|
|
14952
|
-
webex.internal.llm.setDatachannelToken = sinon.stub();
|
|
15171
|
+
// voiceaChannel is created in the Meeting constructor
|
|
15172
|
+
meeting.voiceaChannel = mockVoiceaChannel;
|
|
14953
15173
|
|
|
14954
15174
|
meeting.processRelayEvent = sinon.stub();
|
|
14955
15175
|
meeting.processLocusLLMEvent = sinon.stub();
|
|
15176
|
+
meeting.handleLLMOnline = sinon.stub();
|
|
14956
15177
|
meeting.clearLLMHealthCheckTimer = sinon.stub();
|
|
14957
15178
|
meeting.startLLMHealthCheckTimer = sinon.stub();
|
|
15179
|
+
meeting.annotation.registerChannel = sinon.stub();
|
|
14958
15180
|
|
|
14959
15181
|
meeting.webinar.isJoinPracticeSessionDataChannel = sinon.stub().returns(false);
|
|
14960
15182
|
});
|
|
15183
|
+
|
|
14961
15184
|
it('does not connect if the call is not joined yet', async () => {
|
|
14962
15185
|
meeting.joinedWith = {state: 'any other state'};
|
|
14963
|
-
webex.internal.llm.getLocusUrl.returns('a url');
|
|
14964
15186
|
|
|
14965
15187
|
meeting.locusInfo = {
|
|
14966
15188
|
syncAllHashTreeDatasets: sinon.stub().resolves(),
|
|
@@ -14970,12 +15192,11 @@ describe('plugin-meetings', () => {
|
|
|
14970
15192
|
|
|
14971
15193
|
const result = await meeting.updateLLMConnection();
|
|
14972
15194
|
|
|
14973
|
-
assert.notCalled(webex.internal.llm.
|
|
14974
|
-
assert.notCalled(webex.internal.llm.disconnectLLM);
|
|
15195
|
+
assert.notCalled(webex.internal.llm.createChannel);
|
|
14975
15196
|
assert.equal(result, undefined);
|
|
14976
|
-
assert.notCalled(meeting.webex.internal.llm.on);
|
|
14977
15197
|
});
|
|
14978
|
-
|
|
15198
|
+
|
|
15199
|
+
it('creates a channel and connects when joined', async () => {
|
|
14979
15200
|
meeting.joinedWith = {state: 'JOINED'};
|
|
14980
15201
|
meeting.locusInfo = {
|
|
14981
15202
|
syncAllHashTreeDatasets: sinon.stub().resolves(),
|
|
@@ -14984,36 +15205,60 @@ describe('plugin-meetings', () => {
|
|
|
14984
15205
|
};
|
|
14985
15206
|
|
|
14986
15207
|
const result = await meeting.updateLLMConnection();
|
|
14987
|
-
|
|
15208
|
+
|
|
15209
|
+
assert.calledOnce(webex.internal.llm.createChannel);
|
|
14988
15210
|
assert.calledWithExactly(
|
|
14989
|
-
|
|
15211
|
+
mockChannel.registerAndConnect,
|
|
14990
15212
|
'a url',
|
|
14991
15213
|
'a datachannel url',
|
|
14992
15214
|
undefined
|
|
14993
15215
|
);
|
|
14994
15216
|
assert.equal(result, 'something');
|
|
15217
|
+
assert.calledOnceWithExactly(meeting.locusInfo.syncAllHashTreeDatasets, {onlyLLM: true});
|
|
15218
|
+
});
|
|
15219
|
+
|
|
15220
|
+
it('sets up event listeners on the channel after connection', async () => {
|
|
15221
|
+
meeting.joinedWith = {state: 'JOINED'};
|
|
15222
|
+
meeting.locusInfo = {
|
|
15223
|
+
syncAllHashTreeDatasets: sinon.stub().resolves(),
|
|
15224
|
+
url: 'a url',
|
|
15225
|
+
info: {datachannelUrl: 'a datachannel url'},
|
|
15226
|
+
};
|
|
15227
|
+
|
|
15228
|
+
await meeting.updateLLMConnection();
|
|
15229
|
+
|
|
15230
|
+
assert.calledWithExactly(mockChannel.off, 'event:relay.event', meeting.processRelayEvent);
|
|
15231
|
+
assert.calledWithExactly(mockChannel.on, 'event:relay.event', meeting.processRelayEvent);
|
|
14995
15232
|
assert.calledWithExactly(
|
|
14996
|
-
|
|
14997
|
-
'event:relay.event',
|
|
14998
|
-
meeting.processRelayEvent
|
|
14999
|
-
);
|
|
15000
|
-
assert.calledWithExactly(
|
|
15001
|
-
meeting.webex.internal.llm.off,
|
|
15233
|
+
mockChannel.off,
|
|
15002
15234
|
'event:locus.state_message',
|
|
15003
15235
|
meeting.processLocusLLMEvent
|
|
15004
15236
|
);
|
|
15005
15237
|
assert.calledWithExactly(
|
|
15006
|
-
|
|
15007
|
-
'event:relay.event',
|
|
15008
|
-
meeting.processRelayEvent
|
|
15009
|
-
);
|
|
15010
|
-
assert.calledWithExactly(
|
|
15011
|
-
meeting.webex.internal.llm.on,
|
|
15238
|
+
mockChannel.on,
|
|
15012
15239
|
'event:locus.state_message',
|
|
15013
15240
|
meeting.processLocusLLMEvent
|
|
15014
15241
|
);
|
|
15242
|
+
assert.calledWithExactly(mockChannel.off, 'online', meeting.handleLLMOnline);
|
|
15243
|
+
assert.calledWithExactly(mockChannel.on, 'online', meeting.handleLLMOnline);
|
|
15244
|
+
});
|
|
15245
|
+
|
|
15246
|
+
it('sets refresh handler before registration', async () => {
|
|
15247
|
+
meeting.joinedWith = {state: 'JOINED'};
|
|
15248
|
+
meeting.locusInfo = {
|
|
15249
|
+
syncAllHashTreeDatasets: sinon.stub().resolves(),
|
|
15250
|
+
url: 'a url',
|
|
15251
|
+
info: {datachannelUrl: 'a datachannel url'},
|
|
15252
|
+
};
|
|
15253
|
+
|
|
15254
|
+
await meeting.updateLLMConnection();
|
|
15255
|
+
|
|
15256
|
+
assert.calledOnceWithExactly(mockChannel.setRefreshHandler, sinon.match.func);
|
|
15257
|
+
// Verify setRefreshHandler was called before registerAndConnect
|
|
15258
|
+
assert.isTrue(mockChannel.setRefreshHandler.calledBefore(mockChannel.registerAndConnect));
|
|
15015
15259
|
});
|
|
15016
|
-
|
|
15260
|
+
|
|
15261
|
+
it('skips reconnect when already connected to same URLs', async () => {
|
|
15017
15262
|
meeting.joinedWith = {state: 'JOINED'};
|
|
15018
15263
|
meeting.locusInfo = {
|
|
15019
15264
|
syncAllHashTreeDatasets: sinon.stub().resolves(),
|
|
@@ -15021,146 +15266,112 @@ describe('plugin-meetings', () => {
|
|
|
15021
15266
|
info: {datachannelUrl: 'a datachannel url'},
|
|
15022
15267
|
};
|
|
15023
15268
|
|
|
15269
|
+
// Set up existing channel with matching URLs
|
|
15270
|
+
const existingChannel = {
|
|
15271
|
+
isConnected: sinon.stub().returns(true),
|
|
15272
|
+
isConnecting: sinon.stub().returns(false),
|
|
15273
|
+
getLocusUrl: sinon.stub().returns('a url'),
|
|
15274
|
+
getDatachannelUrl: sinon.stub().returns('a datachannel url'),
|
|
15275
|
+
};
|
|
15276
|
+
meeting.llmChannel = existingChannel;
|
|
15277
|
+
|
|
15024
15278
|
const result = await meeting.updateLLMConnection();
|
|
15025
15279
|
|
|
15026
|
-
assert.notCalled(webex.internal.llm.
|
|
15027
|
-
assert.
|
|
15028
|
-
webex.internal.llm.registerAndConnect,
|
|
15029
|
-
'a url',
|
|
15030
|
-
'a datachannel url',
|
|
15031
|
-
undefined
|
|
15032
|
-
);
|
|
15033
|
-
assert.calledOnceWithExactly(
|
|
15034
|
-
webex.internal.llm.setRefreshHandler,
|
|
15035
|
-
sinon.match.func,
|
|
15036
|
-
'llm-default-session',
|
|
15037
|
-
meeting.id
|
|
15038
|
-
);
|
|
15039
|
-
assert.equal(result, 'something');
|
|
15040
|
-
assert.calledOnceWithExactly(meeting.locusInfo.syncAllHashTreeDatasets, {onlyLLM: true});
|
|
15280
|
+
assert.notCalled(webex.internal.llm.createChannel);
|
|
15281
|
+
assert.equal(result, undefined);
|
|
15041
15282
|
});
|
|
15042
|
-
|
|
15283
|
+
|
|
15284
|
+
it('disconnects and reconnects when locus URL changes', async () => {
|
|
15043
15285
|
meeting.joinedWith = {state: 'JOINED'};
|
|
15044
15286
|
|
|
15045
|
-
|
|
15046
|
-
|
|
15287
|
+
// Set up existing channel with different URL
|
|
15288
|
+
const existingChannel = {
|
|
15289
|
+
isConnected: sinon.stub().returns(true),
|
|
15290
|
+
isConnecting: sinon.stub().returns(false),
|
|
15291
|
+
getLocusUrl: sinon.stub().returns('old url'),
|
|
15292
|
+
getDatachannelUrl: sinon.stub().returns('a datachannel url'),
|
|
15293
|
+
disconnect: sinon.stub().resolves(),
|
|
15294
|
+
off: sinon.stub(),
|
|
15295
|
+
};
|
|
15296
|
+
meeting.llmChannel = existingChannel;
|
|
15297
|
+
const originalVoiceaChannel = meeting.voiceaChannel;
|
|
15047
15298
|
|
|
15048
15299
|
meeting.locusInfo = {
|
|
15049
15300
|
syncAllHashTreeDatasets: sinon.stub().resolves(),
|
|
15050
15301
|
url: 'a different url',
|
|
15051
15302
|
info: {datachannelUrl: 'a datachannel url'},
|
|
15052
|
-
self: {},
|
|
15053
15303
|
};
|
|
15054
15304
|
|
|
15055
15305
|
const result = await meeting.updateLLMConnection();
|
|
15056
15306
|
|
|
15307
|
+
// Should disconnect old channel
|
|
15308
|
+
assert.calledOnce(existingChannel.disconnect);
|
|
15309
|
+
// Should create new channel
|
|
15310
|
+
assert.calledOnce(webex.internal.llm.createChannel);
|
|
15311
|
+
// Should connect with new URL
|
|
15057
15312
|
assert.calledWithExactly(
|
|
15058
|
-
|
|
15059
|
-
{
|
|
15060
|
-
code: 3050,
|
|
15061
|
-
reason: 'done (permanent)',
|
|
15062
|
-
},
|
|
15063
|
-
'llm-default-session',
|
|
15064
|
-
meeting.id
|
|
15065
|
-
);
|
|
15066
|
-
|
|
15067
|
-
assert.calledWithExactly(
|
|
15068
|
-
webex.internal.llm.registerAndConnect,
|
|
15313
|
+
mockChannel.registerAndConnect,
|
|
15069
15314
|
'a different url',
|
|
15070
15315
|
'a datachannel url',
|
|
15071
15316
|
undefined
|
|
15072
15317
|
);
|
|
15073
|
-
|
|
15074
|
-
assert.
|
|
15075
|
-
|
|
15076
|
-
assert.calledWithExactly(
|
|
15077
|
-
meeting.webex.internal.llm.off,
|
|
15078
|
-
'event:relay.event',
|
|
15079
|
-
meeting.processRelayEvent
|
|
15080
|
-
);
|
|
15081
|
-
assert.calledWithExactly(
|
|
15082
|
-
meeting.webex.internal.llm.off,
|
|
15083
|
-
'event:locus.state_message',
|
|
15084
|
-
meeting.processLocusLLMEvent
|
|
15085
|
-
);
|
|
15086
|
-
assert.callCount(meeting.webex.internal.llm.off, 4);
|
|
15087
|
-
|
|
15088
|
-
assert.calledWithExactly(
|
|
15089
|
-
meeting.webex.internal.llm.on,
|
|
15090
|
-
'event:relay.event',
|
|
15091
|
-
meeting.processRelayEvent
|
|
15092
|
-
);
|
|
15093
|
-
assert.calledWithExactly(
|
|
15094
|
-
meeting.webex.internal.llm.on,
|
|
15095
|
-
'event:locus.state_message',
|
|
15096
|
-
meeting.processLocusLLMEvent
|
|
15097
|
-
);
|
|
15098
|
-
assert.isFalse(
|
|
15099
|
-
meeting.webex.internal.llm.off.calledWithExactly('online', meeting.handleLLMOnline)
|
|
15100
|
-
);
|
|
15318
|
+
// voiceaChannel should be preserved during transient reconnect
|
|
15319
|
+
assert.strictEqual(meeting.voiceaChannel, originalVoiceaChannel);
|
|
15320
|
+
assert.notCalled(mockVoiceaChannel.deregisterEvents);
|
|
15101
15321
|
});
|
|
15102
|
-
|
|
15322
|
+
|
|
15323
|
+
it('disconnects and reconnects when datachannel URL changes', async () => {
|
|
15103
15324
|
meeting.joinedWith = {state: 'JOINED'};
|
|
15104
|
-
|
|
15105
|
-
|
|
15325
|
+
|
|
15326
|
+
// Set up existing channel with different datachannel URL
|
|
15327
|
+
const existingChannel = {
|
|
15328
|
+
isConnected: sinon.stub().returns(true),
|
|
15329
|
+
isConnecting: sinon.stub().returns(false),
|
|
15330
|
+
getLocusUrl: sinon.stub().returns('a url'),
|
|
15331
|
+
getDatachannelUrl: sinon.stub().returns('old datachannel url'),
|
|
15332
|
+
disconnect: sinon.stub().resolves(),
|
|
15333
|
+
off: sinon.stub(),
|
|
15334
|
+
};
|
|
15335
|
+
meeting.llmChannel = existingChannel;
|
|
15336
|
+
const originalVoiceaChannel = meeting.voiceaChannel;
|
|
15106
15337
|
|
|
15107
15338
|
meeting.locusInfo = {
|
|
15108
15339
|
syncAllHashTreeDatasets: sinon.stub().resolves(),
|
|
15109
15340
|
url: 'a url',
|
|
15110
15341
|
info: {datachannelUrl: 'a different datachannel url'},
|
|
15111
|
-
self: {},
|
|
15112
15342
|
};
|
|
15113
15343
|
|
|
15114
|
-
|
|
15344
|
+
await meeting.updateLLMConnection();
|
|
15115
15345
|
|
|
15346
|
+
// Should disconnect old channel
|
|
15347
|
+
assert.calledOnce(existingChannel.disconnect);
|
|
15348
|
+
// Should create new channel
|
|
15349
|
+
assert.calledOnce(webex.internal.llm.createChannel);
|
|
15350
|
+
// Should connect with new datachannel URL
|
|
15116
15351
|
assert.calledWithExactly(
|
|
15117
|
-
|
|
15118
|
-
{
|
|
15119
|
-
code: 3050,
|
|
15120
|
-
reason: 'done (permanent)',
|
|
15121
|
-
},
|
|
15122
|
-
'llm-default-session',
|
|
15123
|
-
meeting.id
|
|
15124
|
-
);
|
|
15125
|
-
|
|
15126
|
-
assert.calledWithExactly(
|
|
15127
|
-
webex.internal.llm.registerAndConnect,
|
|
15352
|
+
mockChannel.registerAndConnect,
|
|
15128
15353
|
'a url',
|
|
15129
15354
|
'a different datachannel url',
|
|
15130
15355
|
undefined
|
|
15131
15356
|
);
|
|
15132
|
-
|
|
15133
|
-
assert.
|
|
15134
|
-
|
|
15135
|
-
assert.calledWithExactly(
|
|
15136
|
-
meeting.webex.internal.llm.off,
|
|
15137
|
-
'event:relay.event',
|
|
15138
|
-
meeting.processRelayEvent
|
|
15139
|
-
);
|
|
15140
|
-
assert.calledWithExactly(
|
|
15141
|
-
meeting.webex.internal.llm.off,
|
|
15142
|
-
'event:locus.state_message',
|
|
15143
|
-
meeting.processLocusLLMEvent
|
|
15144
|
-
);
|
|
15145
|
-
|
|
15146
|
-
assert.calledWithExactly(
|
|
15147
|
-
meeting.webex.internal.llm.on,
|
|
15148
|
-
'event:relay.event',
|
|
15149
|
-
meeting.processRelayEvent
|
|
15150
|
-
);
|
|
15151
|
-
assert.calledWithExactly(
|
|
15152
|
-
meeting.webex.internal.llm.on,
|
|
15153
|
-
'event:locus.state_message',
|
|
15154
|
-
meeting.processLocusLLMEvent
|
|
15155
|
-
);
|
|
15156
|
-
assert.isFalse(
|
|
15157
|
-
meeting.webex.internal.llm.off.calledWithExactly('online', meeting.handleLLMOnline)
|
|
15158
|
-
);
|
|
15357
|
+
// voiceaChannel should be preserved during transient reconnect
|
|
15358
|
+
assert.strictEqual(meeting.voiceaChannel, originalVoiceaChannel);
|
|
15359
|
+
assert.notCalled(mockVoiceaChannel.deregisterEvents);
|
|
15159
15360
|
});
|
|
15160
|
-
|
|
15361
|
+
|
|
15362
|
+
it('disconnects when state changes to not joined', async () => {
|
|
15161
15363
|
meeting.joinedWith = {state: 'any other state'};
|
|
15162
|
-
|
|
15163
|
-
|
|
15364
|
+
|
|
15365
|
+
// Set up existing connected channel
|
|
15366
|
+
const existingChannel = {
|
|
15367
|
+
isConnected: sinon.stub().returns(true),
|
|
15368
|
+
isConnecting: sinon.stub().returns(false),
|
|
15369
|
+
getLocusUrl: sinon.stub().returns('a url'),
|
|
15370
|
+
getDatachannelUrl: sinon.stub().returns('a datachannel url'),
|
|
15371
|
+
disconnect: sinon.stub().resolves(),
|
|
15372
|
+
off: sinon.stub(),
|
|
15373
|
+
};
|
|
15374
|
+
meeting.llmChannel = existingChannel;
|
|
15164
15375
|
|
|
15165
15376
|
meeting.locusInfo = {
|
|
15166
15377
|
syncAllHashTreeDatasets: sinon.stub().resolves(),
|
|
@@ -15170,81 +15381,57 @@ describe('plugin-meetings', () => {
|
|
|
15170
15381
|
|
|
15171
15382
|
const result = await meeting.updateLLMConnection();
|
|
15172
15383
|
|
|
15173
|
-
assert.
|
|
15174
|
-
|
|
15175
|
-
{
|
|
15176
|
-
code: 3050,
|
|
15177
|
-
reason: 'done (permanent)',
|
|
15178
|
-
},
|
|
15179
|
-
'llm-default-session',
|
|
15180
|
-
meeting.id
|
|
15181
|
-
);
|
|
15182
|
-
assert.notCalled(webex.internal.llm.registerAndConnect);
|
|
15384
|
+
assert.calledOnce(existingChannel.disconnect);
|
|
15385
|
+
assert.notCalled(webex.internal.llm.createChannel);
|
|
15183
15386
|
assert.equal(result, undefined);
|
|
15184
|
-
assert.isFalse(
|
|
15185
|
-
meeting.webex.internal.llm.off.calledWithExactly('online', meeting.handleLLMOnline)
|
|
15186
|
-
);
|
|
15187
15387
|
});
|
|
15188
|
-
it('rethrows disconnect errors during reconnect cleanup after removing relay listeners and timer', async () => {
|
|
15189
|
-
const disconnectError = new Error('disconnect failed');
|
|
15190
15388
|
|
|
15389
|
+
it('passes pending datachannel token to registerAndConnect', async () => {
|
|
15191
15390
|
meeting.joinedWith = {state: 'JOINED'};
|
|
15192
|
-
|
|
15193
|
-
webex.internal.llm.getLocusUrl.returns('a url');
|
|
15194
|
-
webex.internal.llm.disconnectLLM.rejects(disconnectError);
|
|
15195
|
-
|
|
15391
|
+
meeting._pendingDatachannelToken = 'pending-token';
|
|
15196
15392
|
meeting.locusInfo = {
|
|
15197
15393
|
syncAllHashTreeDatasets: sinon.stub().resolves(),
|
|
15198
|
-
url: 'a
|
|
15394
|
+
url: 'a url',
|
|
15199
15395
|
info: {datachannelUrl: 'a datachannel url'},
|
|
15200
|
-
self: {},
|
|
15201
15396
|
};
|
|
15202
15397
|
|
|
15203
|
-
|
|
15204
|
-
await meeting.updateLLMConnection();
|
|
15205
|
-
assert.fail('Expected updateLLMConnection to reject when disconnectLLM fails');
|
|
15206
|
-
} catch (error) {
|
|
15207
|
-
assert.equal(error, disconnectError);
|
|
15208
|
-
}
|
|
15398
|
+
await meeting.updateLLMConnection();
|
|
15209
15399
|
|
|
15210
|
-
assert.notCalled(webex.internal.llm.registerAndConnect);
|
|
15211
|
-
assert.calledWithExactly(
|
|
15212
|
-
meeting.webex.internal.llm.off,
|
|
15213
|
-
'event:relay.event',
|
|
15214
|
-
meeting.processRelayEvent
|
|
15215
|
-
);
|
|
15216
15400
|
assert.calledWithExactly(
|
|
15217
|
-
|
|
15218
|
-
'
|
|
15219
|
-
|
|
15220
|
-
|
|
15221
|
-
assert.isFalse(
|
|
15222
|
-
meeting.webex.internal.llm.off.calledWithExactly('online', meeting.handleLLMOnline)
|
|
15401
|
+
mockChannel.registerAndConnect,
|
|
15402
|
+
'a url',
|
|
15403
|
+
'a datachannel url',
|
|
15404
|
+
'pending-token'
|
|
15223
15405
|
);
|
|
15224
|
-
|
|
15406
|
+
// Pending token should be set on channel
|
|
15407
|
+
assert.calledWithExactly(mockChannel.setDatachannelToken, 'pending-token');
|
|
15408
|
+
// Pending token should be cleared
|
|
15409
|
+
assert.isUndefined(meeting._pendingDatachannelToken);
|
|
15225
15410
|
});
|
|
15226
|
-
|
|
15411
|
+
|
|
15412
|
+
it('uses channel token if no pending token', async () => {
|
|
15227
15413
|
meeting.joinedWith = {state: 'JOINED'};
|
|
15414
|
+
mockChannel.getDatachannelToken.returns('channel-token');
|
|
15228
15415
|
meeting.locusInfo = {
|
|
15229
15416
|
syncAllHashTreeDatasets: sinon.stub().resolves(),
|
|
15230
15417
|
url: 'a url',
|
|
15231
|
-
info: {
|
|
15232
|
-
datachannelUrl: 'a datachannel url',
|
|
15233
|
-
practiceSessionDatachannelUrl: 'ps-url',
|
|
15234
|
-
},
|
|
15418
|
+
info: {datachannelUrl: 'a datachannel url'},
|
|
15235
15419
|
};
|
|
15236
|
-
meeting.webinar.isJoinPracticeSessionDataChannel.returns(true);
|
|
15237
15420
|
|
|
15238
15421
|
await meeting.updateLLMConnection();
|
|
15239
15422
|
|
|
15240
15423
|
assert.calledWithExactly(
|
|
15241
|
-
|
|
15424
|
+
mockChannel.registerAndConnect,
|
|
15242
15425
|
'a url',
|
|
15243
15426
|
'a datachannel url',
|
|
15244
|
-
|
|
15427
|
+
'channel-token'
|
|
15245
15428
|
);
|
|
15246
15429
|
});
|
|
15247
|
-
|
|
15430
|
+
|
|
15431
|
+
it('clears llmChannel on registration failure', async () => {
|
|
15432
|
+
const registerError = new Error('registration failed');
|
|
15433
|
+
mockChannel.registerAndConnect.rejects(registerError);
|
|
15434
|
+
|
|
15248
15435
|
meeting.joinedWith = {state: 'JOINED'};
|
|
15249
15436
|
meeting.locusInfo = {
|
|
15250
15437
|
syncAllHashTreeDatasets: sinon.stub().resolves(),
|
|
@@ -15252,397 +15439,371 @@ describe('plugin-meetings', () => {
|
|
|
15252
15439
|
info: {datachannelUrl: 'a datachannel url'},
|
|
15253
15440
|
};
|
|
15254
15441
|
|
|
15255
|
-
|
|
15256
|
-
|
|
15257
|
-
.
|
|
15442
|
+
try {
|
|
15443
|
+
await meeting.updateLLMConnection();
|
|
15444
|
+
assert.fail('Expected updateLLMConnection to reject');
|
|
15445
|
+
} catch (error) {
|
|
15446
|
+
assert.equal(error, registerError);
|
|
15447
|
+
}
|
|
15448
|
+
|
|
15449
|
+
assert.isUndefined(meeting.llmChannel);
|
|
15450
|
+
});
|
|
15451
|
+
|
|
15452
|
+
it('starts LLM health check timer after successful connection', async () => {
|
|
15453
|
+
meeting.joinedWith = {state: 'JOINED'};
|
|
15454
|
+
meeting.locusInfo = {
|
|
15455
|
+
syncAllHashTreeDatasets: sinon.stub().resolves(),
|
|
15456
|
+
url: 'a url',
|
|
15457
|
+
info: {datachannelUrl: 'a datachannel url'},
|
|
15458
|
+
};
|
|
15258
15459
|
|
|
15259
15460
|
await meeting.updateLLMConnection();
|
|
15260
15461
|
|
|
15261
|
-
assert.
|
|
15262
|
-
|
|
15263
|
-
|
|
15264
|
-
|
|
15265
|
-
|
|
15266
|
-
|
|
15267
|
-
|
|
15462
|
+
assert.calledOnce(meeting.startLLMHealthCheckTimer);
|
|
15463
|
+
});
|
|
15464
|
+
|
|
15465
|
+
it('reuses voiceaChannel after successful connection', async () => {
|
|
15466
|
+
meeting.joinedWith = {state: 'JOINED'};
|
|
15467
|
+
meeting.locusInfo = {
|
|
15468
|
+
syncAllHashTreeDatasets: sinon.stub().resolves(),
|
|
15469
|
+
url: 'a url',
|
|
15470
|
+
info: {datachannelUrl: 'a datachannel url'},
|
|
15471
|
+
};
|
|
15472
|
+
|
|
15473
|
+
await meeting.updateLLMConnection();
|
|
15474
|
+
|
|
15475
|
+
assert.notCalled(webex.internal.voicea.createChannel);
|
|
15476
|
+
assert.strictEqual(meeting.voiceaChannel, mockVoiceaChannel);
|
|
15477
|
+
assert.calledOnceWithExactly(mockVoiceaChannel.switchLLMChannel, mockChannel);
|
|
15268
15478
|
});
|
|
15269
|
-
|
|
15479
|
+
|
|
15480
|
+
it('creates and binds a voiceaChannel after the previous channel was cleaned up', async () => {
|
|
15270
15481
|
meeting.joinedWith = {state: 'JOINED'};
|
|
15482
|
+
meeting.voiceaChannel = undefined;
|
|
15271
15483
|
meeting.locusInfo = {
|
|
15272
15484
|
syncAllHashTreeDatasets: sinon.stub().resolves(),
|
|
15273
15485
|
url: 'a url',
|
|
15274
15486
|
info: {datachannelUrl: 'a datachannel url'},
|
|
15275
15487
|
};
|
|
15276
15488
|
|
|
15277
|
-
|
|
15489
|
+
await meeting.updateLLMConnection();
|
|
15490
|
+
|
|
15491
|
+
assert.calledOnceWithExactly(webex.internal.voicea.createChannel);
|
|
15492
|
+
assert.strictEqual(meeting.voiceaChannel, mockVoiceaChannel);
|
|
15493
|
+
assert.calledOnceWithExactly(mockVoiceaChannel.switchLLMChannel, mockChannel);
|
|
15494
|
+
});
|
|
15495
|
+
|
|
15496
|
+
it('skips switchLLMChannel when practice session is active', async () => {
|
|
15497
|
+
meeting.joinedWith = {state: 'JOINED'};
|
|
15498
|
+
meeting.webinar.isPracticeSessionLLMChannelConnected = sinon.stub().returns(true);
|
|
15499
|
+
meeting.locusInfo = {
|
|
15500
|
+
syncAllHashTreeDatasets: sinon.stub().resolves(),
|
|
15501
|
+
url: 'a url',
|
|
15502
|
+
info: {datachannelUrl: 'a datachannel url'},
|
|
15503
|
+
};
|
|
15278
15504
|
|
|
15279
15505
|
await meeting.updateLLMConnection();
|
|
15280
15506
|
|
|
15281
|
-
|
|
15282
|
-
|
|
15283
|
-
|
|
15284
|
-
|
|
15285
|
-
undefined
|
|
15286
|
-
);
|
|
15507
|
+
// switchLLMChannel should NOT be called when practice session is active
|
|
15508
|
+
// because practice session manages its own voicea binding
|
|
15509
|
+
assert.notCalled(mockVoiceaChannel.switchLLMChannel);
|
|
15510
|
+
});
|
|
15287
15511
|
|
|
15288
|
-
|
|
15512
|
+
it('logs warning when switchLLMChannel fails', async () => {
|
|
15513
|
+
meeting.joinedWith = {state: 'JOINED'};
|
|
15514
|
+
mockVoiceaChannel.switchLLMChannel.rejects(new Error('switch failed'));
|
|
15515
|
+
meeting.locusInfo = {
|
|
15516
|
+
syncAllHashTreeDatasets: sinon.stub().resolves(),
|
|
15517
|
+
url: 'a url',
|
|
15518
|
+
info: {datachannelUrl: 'a datachannel url'},
|
|
15519
|
+
};
|
|
15520
|
+
|
|
15521
|
+
// Should not throw - fire-and-forget behavior
|
|
15522
|
+
const result = await meeting.updateLLMConnection();
|
|
15523
|
+
|
|
15524
|
+
assert.equal(result, 'something');
|
|
15289
15525
|
});
|
|
15290
15526
|
|
|
15291
|
-
it('
|
|
15527
|
+
it('starts transcription after LLM connects when Locus transcription is active', async () => {
|
|
15292
15528
|
meeting.joinedWith = {state: 'JOINED'};
|
|
15529
|
+
meeting.areVoiceaEventsSetup = false;
|
|
15530
|
+
meeting.startTranscription = sinon.stub().resolves();
|
|
15293
15531
|
meeting.locusInfo = {
|
|
15294
15532
|
syncAllHashTreeDatasets: sinon.stub().resolves(),
|
|
15295
15533
|
url: 'a url',
|
|
15296
15534
|
info: {datachannelUrl: 'a datachannel url'},
|
|
15535
|
+
controls: {transcribe: {transcribing: true}},
|
|
15297
15536
|
};
|
|
15298
15537
|
|
|
15299
|
-
|
|
15300
|
-
|
|
15538
|
+
await meeting.updateLLMConnection();
|
|
15539
|
+
await mockVoiceaChannel.switchLLMChannel.firstCall.returnValue;
|
|
15540
|
+
|
|
15541
|
+
assert.calledOnce(meeting.startTranscription);
|
|
15542
|
+
});
|
|
15543
|
+
|
|
15544
|
+
it('does not start transcription after LLM connects when Locus transcription is inactive', async () => {
|
|
15545
|
+
meeting.joinedWith = {state: 'JOINED'};
|
|
15546
|
+
meeting.areVoiceaEventsSetup = false;
|
|
15547
|
+
meeting.startTranscription = sinon.stub().resolves();
|
|
15548
|
+
meeting.locusInfo = {
|
|
15549
|
+
syncAllHashTreeDatasets: sinon.stub().resolves(),
|
|
15550
|
+
url: 'a url',
|
|
15551
|
+
info: {datachannelUrl: 'a datachannel url'},
|
|
15552
|
+
controls: {transcribe: {transcribing: false}},
|
|
15553
|
+
};
|
|
15301
15554
|
|
|
15302
15555
|
await meeting.updateLLMConnection();
|
|
15303
15556
|
|
|
15304
|
-
assert.
|
|
15305
|
-
webex.internal.llm.registerAndConnect,
|
|
15306
|
-
'a url',
|
|
15307
|
-
'a datachannel url',
|
|
15308
|
-
undefined
|
|
15309
|
-
);
|
|
15310
|
-
assert.notCalled(webex.internal.llm.setDatachannelToken);
|
|
15557
|
+
assert.notCalled(meeting.startTranscription);
|
|
15311
15558
|
});
|
|
15312
15559
|
|
|
15313
|
-
|
|
15314
|
-
|
|
15315
|
-
|
|
15316
|
-
|
|
15317
|
-
|
|
15318
|
-
|
|
15319
|
-
|
|
15320
|
-
|
|
15321
|
-
|
|
15322
|
-
|
|
15323
|
-
});
|
|
15560
|
+
it('does not start transcription when areVoiceaEventsSetup is already true', async () => {
|
|
15561
|
+
meeting.joinedWith = {state: 'JOINED'};
|
|
15562
|
+
meeting.areVoiceaEventsSetup = true;
|
|
15563
|
+
meeting.startTranscription = sinon.stub().resolves();
|
|
15564
|
+
meeting.locusInfo = {
|
|
15565
|
+
syncAllHashTreeDatasets: sinon.stub().resolves(),
|
|
15566
|
+
url: 'a url',
|
|
15567
|
+
info: {datachannelUrl: 'a datachannel url'},
|
|
15568
|
+
controls: {transcribe: {transcribing: true}},
|
|
15569
|
+
};
|
|
15324
15570
|
|
|
15325
|
-
|
|
15326
|
-
meeting.joinedWith = {state: 'JOINED'};
|
|
15327
|
-
webex.internal.llm.isConnected.returns(true);
|
|
15328
|
-
webex.internal.llm.getOwnerMeetingId.returns('some-other-meeting-id');
|
|
15329
|
-
// Locus/datachannel URL mismatch is the *normal* case when
|
|
15330
|
-
// another meeting owns the live socket -- each meeting has its
|
|
15331
|
-
// own locus URL. URL mismatch must NOT trigger a reclaim,
|
|
15332
|
-
// because doing so would tear down the owning meeting's healthy
|
|
15333
|
-
// LLM socket and break its data channel.
|
|
15334
|
-
webex.internal.llm.getLocusUrl.returns('owner-locus-url');
|
|
15335
|
-
webex.internal.llm.getDatachannelUrl.returns('owner-dc-url');
|
|
15336
|
-
meeting.locusInfo = {
|
|
15337
|
-
syncAllHashTreeDatasets: sinon.stub().resolves(),
|
|
15338
|
-
url: 'a different url',
|
|
15339
|
-
info: {datachannelUrl: 'a different datachannel url'},
|
|
15340
|
-
self: {},
|
|
15341
|
-
};
|
|
15571
|
+
await meeting.updateLLMConnection();
|
|
15342
15572
|
|
|
15343
|
-
|
|
15344
|
-
|
|
15345
|
-
assert.equal(result, undefined);
|
|
15346
|
-
assert.notCalled(webex.internal.llm.disconnectLLM);
|
|
15347
|
-
assert.notCalled(webex.internal.llm.registerAndConnect);
|
|
15348
|
-
assert.notCalled(webex.internal.llm.setOwnerMeetingId);
|
|
15349
|
-
assert.notCalled(meeting.startLLMHealthCheckTimer);
|
|
15350
|
-
});
|
|
15351
|
-
|
|
15352
|
-
it('clears stale owner tag in cleanup finally block even when disconnectLLM rejects', async () => {
|
|
15353
|
-
meeting.joinedWith = {state: 'JOINED'};
|
|
15354
|
-
webex.internal.llm.isConnected.returns(true);
|
|
15355
|
-
webex.internal.llm.getOwnerMeetingId.returns(meeting.id);
|
|
15356
|
-
webex.internal.llm.getLocusUrl.returns('a url');
|
|
15357
|
-
webex.internal.llm.getDatachannelUrl.returns('a datachannel url');
|
|
15358
|
-
webex.internal.llm.disconnectLLM.rejects(new Error('disconnect failed'));
|
|
15359
|
-
meeting.locusInfo = {
|
|
15360
|
-
syncAllHashTreeDatasets: sinon.stub().resolves(),
|
|
15361
|
-
url: 'a different url',
|
|
15362
|
-
info: {datachannelUrl: 'a datachannel url'},
|
|
15363
|
-
self: {},
|
|
15364
|
-
};
|
|
15573
|
+
assert.notCalled(meeting.startTranscription);
|
|
15574
|
+
});
|
|
15365
15575
|
|
|
15366
|
-
|
|
15367
|
-
|
|
15368
|
-
|
|
15369
|
-
|
|
15370
|
-
|
|
15576
|
+
forEach(
|
|
15577
|
+
[
|
|
15578
|
+
{
|
|
15579
|
+
description: 'does not start transcription when voiceaChannel is disconnected',
|
|
15580
|
+
voiceaChannel: {isLLMConnected: sinon.stub().returns(false)},
|
|
15581
|
+
},
|
|
15582
|
+
{
|
|
15583
|
+
description: 'does not start transcription when voiceaChannel is unavailable',
|
|
15584
|
+
voiceaChannel: undefined,
|
|
15585
|
+
},
|
|
15586
|
+
],
|
|
15587
|
+
({description, voiceaChannel}) => {
|
|
15588
|
+
it(description, () => {
|
|
15589
|
+
meeting.areVoiceaEventsSetup = false;
|
|
15590
|
+
meeting.locusInfo = {controls: {transcribe: {transcribing: true}}};
|
|
15591
|
+
meeting.startTranscription = sinon.stub().resolves();
|
|
15592
|
+
meeting.voiceaChannel = voiceaChannel;
|
|
15371
15593
|
|
|
15372
|
-
|
|
15373
|
-
// subsequent reconnect attempt from any meeting is not blocked.
|
|
15374
|
-
assert.calledWith(webex.internal.llm.setOwnerMeetingId, undefined);
|
|
15375
|
-
});
|
|
15594
|
+
meeting.startTranscriptionIfNeeded();
|
|
15376
15595
|
|
|
15377
|
-
|
|
15378
|
-
meeting.joinedWith = {state: 'JOINED'};
|
|
15379
|
-
webex.internal.llm.isConnected.returns(true);
|
|
15380
|
-
webex.internal.llm.getOwnerMeetingId.returns(meeting.id);
|
|
15381
|
-
webex.internal.llm.getLocusUrl.returns('a url');
|
|
15382
|
-
webex.internal.llm.getDatachannelUrl.returns('a datachannel url');
|
|
15383
|
-
webex.internal.llm.disconnectLLM.callsFake(async () => {
|
|
15384
|
-
webex.internal.llm.getOwnerMeetingId.returns('new-owner-id');
|
|
15385
|
-
throw new Error('disconnect failed');
|
|
15596
|
+
assert.notCalled(meeting.startTranscription);
|
|
15386
15597
|
});
|
|
15387
|
-
|
|
15388
|
-
|
|
15389
|
-
url: 'a different url',
|
|
15390
|
-
info: {datachannelUrl: 'a datachannel url'},
|
|
15391
|
-
self: {},
|
|
15392
|
-
};
|
|
15598
|
+
}
|
|
15599
|
+
);
|
|
15393
15600
|
|
|
15394
|
-
|
|
15395
|
-
|
|
15396
|
-
|
|
15397
|
-
|
|
15398
|
-
|
|
15601
|
+
it('registers annotation channel when not in practice session', async () => {
|
|
15602
|
+
meeting.joinedWith = {state: 'JOINED'};
|
|
15603
|
+
meeting.locusInfo = {
|
|
15604
|
+
syncAllHashTreeDatasets: sinon.stub().resolves(),
|
|
15605
|
+
url: 'a url',
|
|
15606
|
+
info: {datachannelUrl: 'a datachannel url'},
|
|
15607
|
+
};
|
|
15608
|
+
meeting.webinar.isJoinPracticeSessionDataChannel.returns(false);
|
|
15399
15609
|
|
|
15400
|
-
|
|
15401
|
-
assert.equal(webex.internal.llm.getOwnerMeetingId(), 'new-owner-id');
|
|
15402
|
-
});
|
|
15403
|
-
|
|
15404
|
-
it('proceeds normally when LLM is connected and owned by this meeting with URL change', async () => {
|
|
15405
|
-
meeting.joinedWith = {state: 'JOINED'};
|
|
15406
|
-
webex.internal.llm.isConnected.returns(true);
|
|
15407
|
-
webex.internal.llm.getOwnerMeetingId.returns(meeting.id);
|
|
15408
|
-
webex.internal.llm.getLocusUrl.returns('a url');
|
|
15409
|
-
webex.internal.llm.getDatachannelUrl.returns('a datachannel url');
|
|
15410
|
-
meeting.locusInfo = {
|
|
15411
|
-
syncAllHashTreeDatasets: sinon.stub().resolves(),
|
|
15412
|
-
url: 'a different url',
|
|
15413
|
-
info: {datachannelUrl: 'a datachannel url'},
|
|
15414
|
-
self: {},
|
|
15415
|
-
};
|
|
15610
|
+
await meeting.updateLLMConnection();
|
|
15416
15611
|
|
|
15417
|
-
|
|
15612
|
+
assert.calledOnceWithExactly(meeting.annotation.registerChannel, mockChannel);
|
|
15613
|
+
});
|
|
15418
15614
|
|
|
15419
|
-
|
|
15420
|
-
|
|
15421
|
-
|
|
15422
|
-
|
|
15423
|
-
|
|
15424
|
-
|
|
15425
|
-
|
|
15426
|
-
|
|
15427
|
-
);
|
|
15428
|
-
assert.calledWithExactly(
|
|
15429
|
-
webex.internal.llm.registerAndConnect,
|
|
15430
|
-
'a different url',
|
|
15431
|
-
'a datachannel url',
|
|
15432
|
-
undefined
|
|
15433
|
-
);
|
|
15434
|
-
// setOwnerMeetingId is called twice: first with undefined in
|
|
15435
|
-
// cleanupLLMConneciton's finally block (so a failed disconnect
|
|
15436
|
-
// cannot leave a stale owner), then with this meeting's id
|
|
15437
|
-
// after registerAndConnect resolves.
|
|
15438
|
-
assert.calledTwice(webex.internal.llm.setOwnerMeetingId);
|
|
15439
|
-
assert.calledWith(webex.internal.llm.setOwnerMeetingId.firstCall, undefined);
|
|
15440
|
-
assert.calledWith(webex.internal.llm.setOwnerMeetingId.lastCall, meeting.id);
|
|
15441
|
-
});
|
|
15442
|
-
|
|
15443
|
-
it('claims ownership after successful registerAndConnect on initial connect', async () => {
|
|
15444
|
-
meeting.joinedWith = {state: 'JOINED'};
|
|
15445
|
-
webex.internal.llm.isConnected.returns(false);
|
|
15446
|
-
webex.internal.llm.getOwnerMeetingId.returns(undefined);
|
|
15447
|
-
meeting.locusInfo = {
|
|
15448
|
-
syncAllHashTreeDatasets: sinon.stub().resolves(),
|
|
15449
|
-
url: 'a url',
|
|
15450
|
-
info: {datachannelUrl: 'a datachannel url'},
|
|
15451
|
-
};
|
|
15615
|
+
it('does not register annotation channel when in practice session', async () => {
|
|
15616
|
+
meeting.joinedWith = {state: 'JOINED'};
|
|
15617
|
+
meeting.locusInfo = {
|
|
15618
|
+
syncAllHashTreeDatasets: sinon.stub().resolves(),
|
|
15619
|
+
url: 'a url',
|
|
15620
|
+
info: {datachannelUrl: 'a datachannel url'},
|
|
15621
|
+
};
|
|
15622
|
+
meeting.webinar.isJoinPracticeSessionDataChannel.returns(true);
|
|
15452
15623
|
|
|
15453
|
-
|
|
15624
|
+
await meeting.updateLLMConnection();
|
|
15454
15625
|
|
|
15455
|
-
|
|
15456
|
-
|
|
15457
|
-
webex.internal.llm.setRefreshHandler,
|
|
15458
|
-
sinon.match.func,
|
|
15459
|
-
'llm-default-session',
|
|
15460
|
-
meeting.id
|
|
15461
|
-
);
|
|
15462
|
-
assert.calledOnceWithExactly(webex.internal.llm.setOwnerMeetingId, meeting.id);
|
|
15463
|
-
});
|
|
15464
|
-
|
|
15465
|
-
it('proceeds to connect when LLM is not connected even if another ownerId lingers', async () => {
|
|
15466
|
-
// Defensive path: if the LLM reports not-connected but an old
|
|
15467
|
-
// ownerId is still present (e.g. race before a successful
|
|
15468
|
-
// connections.delete), this meeting can still claim a fresh
|
|
15469
|
-
// connection.
|
|
15470
|
-
meeting.joinedWith = {state: 'JOINED'};
|
|
15471
|
-
webex.internal.llm.isConnected.returns(false);
|
|
15472
|
-
webex.internal.llm.getOwnerMeetingId.returns('stale-owner-id');
|
|
15473
|
-
webex.internal.llm.getDatachannelToken.onFirstCall().returns(undefined);
|
|
15474
|
-
webex.internal.llm.getDatachannelToken.onSecondCall().returns('recovered-token');
|
|
15475
|
-
meeting.locusInfo = {
|
|
15476
|
-
syncAllHashTreeDatasets: sinon.stub().resolves(),
|
|
15477
|
-
url: 'a url',
|
|
15478
|
-
info: {datachannelUrl: 'a datachannel url'},
|
|
15479
|
-
};
|
|
15626
|
+
assert.notCalled(meeting.annotation.registerChannel);
|
|
15627
|
+
});
|
|
15480
15628
|
|
|
15481
|
-
|
|
15629
|
+
it('still need connect main session data channel when PS started', async () => {
|
|
15630
|
+
meeting.joinedWith = {state: 'JOINED'};
|
|
15631
|
+
meeting.locusInfo = {
|
|
15632
|
+
syncAllHashTreeDatasets: sinon.stub().resolves(),
|
|
15633
|
+
url: 'a url',
|
|
15634
|
+
info: {
|
|
15635
|
+
datachannelUrl: 'a datachannel url',
|
|
15636
|
+
practiceSessionDatachannelUrl: 'ps-url',
|
|
15637
|
+
},
|
|
15638
|
+
};
|
|
15639
|
+
meeting.webinar.isJoinPracticeSessionDataChannel.returns(true);
|
|
15482
15640
|
|
|
15483
|
-
|
|
15484
|
-
|
|
15485
|
-
|
|
15486
|
-
|
|
15487
|
-
|
|
15488
|
-
|
|
15489
|
-
|
|
15490
|
-
|
|
15491
|
-
'llm-default-session'
|
|
15492
|
-
);
|
|
15493
|
-
assert.calledOnceWithExactly(
|
|
15494
|
-
webex.internal.llm.registerAndConnect,
|
|
15495
|
-
'a url',
|
|
15496
|
-
'a datachannel url',
|
|
15497
|
-
'recovered-token'
|
|
15498
|
-
);
|
|
15499
|
-
assert.calledWithExactly(
|
|
15500
|
-
webex.internal.llm.setRefreshHandler.firstCall,
|
|
15501
|
-
sinon.match.func,
|
|
15502
|
-
'llm-default-session',
|
|
15503
|
-
undefined
|
|
15504
|
-
);
|
|
15505
|
-
assert.calledTwice(webex.internal.llm.setRefreshHandler);
|
|
15506
|
-
assert.calledWithExactly(
|
|
15507
|
-
webex.internal.llm.setRefreshHandler.secondCall,
|
|
15508
|
-
sinon.match.func,
|
|
15509
|
-
'llm-default-session',
|
|
15510
|
-
meeting.id
|
|
15511
|
-
);
|
|
15512
|
-
assert.calledOnceWithExactly(webex.internal.llm.setOwnerMeetingId, meeting.id);
|
|
15513
|
-
});
|
|
15641
|
+
await meeting.updateLLMConnection();
|
|
15642
|
+
|
|
15643
|
+
assert.calledWithExactly(
|
|
15644
|
+
mockChannel.registerAndConnect,
|
|
15645
|
+
'a url',
|
|
15646
|
+
'a datachannel url',
|
|
15647
|
+
undefined
|
|
15648
|
+
);
|
|
15514
15649
|
});
|
|
15515
15650
|
|
|
15516
15651
|
describe('#clearMeetingData', () => {
|
|
15652
|
+
let existingChannel;
|
|
15653
|
+
|
|
15517
15654
|
beforeEach(() => {
|
|
15518
|
-
|
|
15519
|
-
|
|
15520
|
-
|
|
15655
|
+
existingChannel = {
|
|
15656
|
+
isConnected: sinon.stub().returns(true),
|
|
15657
|
+
disconnect: sinon.stub().resolves(),
|
|
15658
|
+
off: sinon.stub(),
|
|
15659
|
+
};
|
|
15660
|
+
meeting.llmChannel = existingChannel;
|
|
15661
|
+
|
|
15521
15662
|
meeting.annotation.deregisterEvents = sinon.stub();
|
|
15522
15663
|
meeting.clearLLMHealthCheckTimer = sinon.stub();
|
|
15523
15664
|
meeting.stopTranscription = sinon.stub();
|
|
15524
|
-
meeting.clearDataChannelToken = sinon.stub();
|
|
15525
15665
|
meeting.shareStatus = 'no-share';
|
|
15526
15666
|
});
|
|
15527
15667
|
|
|
15528
|
-
it('disconnects llm and removes
|
|
15668
|
+
it('disconnects llm channel and removes listeners during meeting data cleanup', async () => {
|
|
15529
15669
|
await meeting.clearMeetingData();
|
|
15530
15670
|
|
|
15531
|
-
assert.
|
|
15532
|
-
|
|
15533
|
-
{
|
|
15534
|
-
code: 3050,
|
|
15535
|
-
reason: 'done (permanent)',
|
|
15536
|
-
},
|
|
15537
|
-
'llm-default-session',
|
|
15538
|
-
meeting.id
|
|
15539
|
-
);
|
|
15540
|
-
assert.calledWithExactly(webex.internal.llm.off, 'online', meeting.handleLLMOnline);
|
|
15671
|
+
assert.calledOnce(existingChannel.disconnect);
|
|
15672
|
+
assert.calledWithExactly(existingChannel.off, 'online', meeting.handleLLMOnline);
|
|
15541
15673
|
assert.calledWithExactly(
|
|
15542
|
-
|
|
15674
|
+
existingChannel.off,
|
|
15543
15675
|
'event:relay.event',
|
|
15544
15676
|
meeting.processRelayEvent
|
|
15545
15677
|
);
|
|
15546
15678
|
assert.calledWithExactly(
|
|
15547
|
-
|
|
15679
|
+
existingChannel.off,
|
|
15548
15680
|
'event:locus.state_message',
|
|
15549
15681
|
meeting.processLocusLLMEvent
|
|
15550
15682
|
);
|
|
15551
|
-
assert.
|
|
15552
|
-
|
|
15553
|
-
|
|
15554
|
-
|
|
15555
|
-
|
|
15556
|
-
// MEETING_STOPPED_RECEIVING_TRANSCRIPTION.
|
|
15557
|
-
assert.notCalled(meeting.stopTranscription);
|
|
15558
|
-
assert.notCalled(meeting.annotation.deregisterEvents);
|
|
15559
|
-
});
|
|
15560
|
-
it('continues cleanup when disconnectLLM fails during meeting data cleanup', async () => {
|
|
15561
|
-
webex.internal.llm.disconnectLLM.rejects(new Error('disconnect failed'));
|
|
15683
|
+
assert.called(meeting.clearLLMHealthCheckTimer);
|
|
15684
|
+
});
|
|
15685
|
+
|
|
15686
|
+
it('continues cleanup when disconnect fails', async () => {
|
|
15687
|
+
existingChannel.disconnect.rejects(new Error('disconnect failed'));
|
|
15562
15688
|
|
|
15563
15689
|
await meeting.clearMeetingData();
|
|
15564
15690
|
|
|
15565
|
-
assert.calledWithExactly(
|
|
15691
|
+
assert.calledWithExactly(existingChannel.off, 'online', meeting.handleLLMOnline);
|
|
15566
15692
|
assert.calledWithExactly(
|
|
15567
|
-
|
|
15693
|
+
existingChannel.off,
|
|
15568
15694
|
'event:relay.event',
|
|
15569
15695
|
meeting.processRelayEvent
|
|
15570
15696
|
);
|
|
15571
|
-
assert.
|
|
15572
|
-
webex.internal.llm.off,
|
|
15573
|
-
'event:locus.state_message',
|
|
15574
|
-
meeting.processLocusLLMEvent
|
|
15575
|
-
);
|
|
15576
|
-
assert.calledOnce(meeting.clearLLMHealthCheckTimer);
|
|
15577
|
-
assert.calledOnce(meeting.clearDataChannelToken);
|
|
15578
|
-
assert.notCalled(meeting.stopTranscription);
|
|
15579
|
-
assert.notCalled(meeting.annotation.deregisterEvents);
|
|
15697
|
+
assert.called(meeting.clearLLMHealthCheckTimer);
|
|
15580
15698
|
});
|
|
15581
15699
|
|
|
15582
|
-
|
|
15583
|
-
|
|
15584
|
-
webex.internal.llm.getOwnerMeetingId = sinon.stub();
|
|
15585
|
-
});
|
|
15700
|
+
it('handles cleanup when no llmChannel exists', async () => {
|
|
15701
|
+
meeting.llmChannel = undefined;
|
|
15586
15702
|
|
|
15587
|
-
|
|
15588
|
-
|
|
15589
|
-
|
|
15590
|
-
await meeting.clearMeetingData();
|
|
15591
|
-
|
|
15592
|
-
assert.notCalled(webex.internal.llm.disconnectLLM);
|
|
15593
|
-
// clearDataChannelToken is always delegated; llm enforces
|
|
15594
|
-
// ownership and no-ops for non-owners internally.
|
|
15595
|
-
assert.calledOnce(meeting.clearDataChannelToken);
|
|
15596
|
-
// Listeners owned by *this* Meeting instance must still be
|
|
15597
|
-
// removed so a leaving subordinate meeting stops receiving
|
|
15598
|
-
// relay/locus events from the shared singleton.
|
|
15599
|
-
assert.calledWithExactly(webex.internal.llm.off, 'online', meeting.handleLLMOnline);
|
|
15600
|
-
assert.calledWithExactly(
|
|
15601
|
-
webex.internal.llm.off,
|
|
15602
|
-
'event:relay.event',
|
|
15603
|
-
meeting.processRelayEvent
|
|
15604
|
-
);
|
|
15605
|
-
assert.calledWithExactly(
|
|
15606
|
-
webex.internal.llm.off,
|
|
15607
|
-
'event:locus.state_message',
|
|
15608
|
-
meeting.processLocusLLMEvent
|
|
15609
|
-
);
|
|
15610
|
-
assert.calledOnce(meeting.clearLLMHealthCheckTimer);
|
|
15611
|
-
});
|
|
15703
|
+
// Should not throw
|
|
15704
|
+
await meeting.clearMeetingData();
|
|
15612
15705
|
|
|
15613
|
-
|
|
15614
|
-
|
|
15706
|
+
assert.called(meeting.clearLLMHealthCheckTimer);
|
|
15707
|
+
});
|
|
15708
|
+
});
|
|
15615
15709
|
|
|
15616
|
-
|
|
15710
|
+
describe('#cleanupLLMConneciton', () => {
|
|
15711
|
+
let existingChannel;
|
|
15617
15712
|
|
|
15618
|
-
|
|
15619
|
-
|
|
15620
|
-
|
|
15621
|
-
|
|
15622
|
-
|
|
15623
|
-
|
|
15624
|
-
|
|
15625
|
-
meeting.id
|
|
15626
|
-
);
|
|
15627
|
-
assert.calledOnce(meeting.clearDataChannelToken);
|
|
15628
|
-
});
|
|
15713
|
+
beforeEach(() => {
|
|
15714
|
+
existingChannel = {
|
|
15715
|
+
isConnected: sinon.stub().returns(true),
|
|
15716
|
+
disconnect: sinon.stub().resolves(),
|
|
15717
|
+
off: sinon.stub(),
|
|
15718
|
+
};
|
|
15719
|
+
meeting.llmChannel = existingChannel;
|
|
15629
15720
|
|
|
15630
|
-
|
|
15631
|
-
|
|
15721
|
+
meeting.annotation.deregisterEvents = sinon.stub();
|
|
15722
|
+
meeting.clearLLMHealthCheckTimer = sinon.stub();
|
|
15723
|
+
});
|
|
15632
15724
|
|
|
15633
|
-
|
|
15725
|
+
forEach(
|
|
15726
|
+
[
|
|
15727
|
+
{
|
|
15728
|
+
description: 'destroys voiceaChannel when preserveVoiceaChannel is false (default)',
|
|
15729
|
+
llmChannelDefined: true,
|
|
15730
|
+
options: undefined,
|
|
15731
|
+
expectedVoiceaPreserved: false,
|
|
15732
|
+
},
|
|
15733
|
+
{
|
|
15734
|
+
description:
|
|
15735
|
+
'destroys voiceaChannel when preserveVoiceaChannel is explicitly false',
|
|
15736
|
+
llmChannelDefined: true,
|
|
15737
|
+
options: {preserveVoiceaChannel: false},
|
|
15738
|
+
expectedVoiceaPreserved: false,
|
|
15739
|
+
},
|
|
15740
|
+
{
|
|
15741
|
+
description: 'preserves voiceaChannel when preserveVoiceaChannel is true',
|
|
15742
|
+
llmChannelDefined: true,
|
|
15743
|
+
options: {preserveVoiceaChannel: true},
|
|
15744
|
+
expectedVoiceaPreserved: true,
|
|
15745
|
+
},
|
|
15746
|
+
{
|
|
15747
|
+
description:
|
|
15748
|
+
'cleans up voiceaChannel even when llmChannel is undefined (failed transient reconnect)',
|
|
15749
|
+
llmChannelDefined: false,
|
|
15750
|
+
options: {preserveVoiceaChannel: false},
|
|
15751
|
+
expectedVoiceaPreserved: false,
|
|
15752
|
+
},
|
|
15753
|
+
{
|
|
15754
|
+
description:
|
|
15755
|
+
'preserves voiceaChannel when llmChannel is undefined and preserveVoiceaChannel is true',
|
|
15756
|
+
llmChannelDefined: false,
|
|
15757
|
+
options: {preserveVoiceaChannel: true},
|
|
15758
|
+
expectedVoiceaPreserved: true,
|
|
15759
|
+
},
|
|
15760
|
+
],
|
|
15761
|
+
({description, llmChannelDefined, options, expectedVoiceaPreserved}) => {
|
|
15762
|
+
it(description, async () => {
|
|
15763
|
+
if (!llmChannelDefined) {
|
|
15764
|
+
meeting.llmChannel = undefined;
|
|
15765
|
+
}
|
|
15766
|
+
const originalVoiceaChannel = meeting.voiceaChannel;
|
|
15634
15767
|
|
|
15635
|
-
|
|
15636
|
-
|
|
15637
|
-
{
|
|
15638
|
-
|
|
15639
|
-
|
|
15640
|
-
}
|
|
15641
|
-
|
|
15642
|
-
|
|
15643
|
-
|
|
15644
|
-
|
|
15645
|
-
|
|
15768
|
+
await meeting.cleanupLLMConneciton(options);
|
|
15769
|
+
|
|
15770
|
+
if (expectedVoiceaPreserved) {
|
|
15771
|
+
assert.notCalled(mockVoiceaChannel.deregisterEvents);
|
|
15772
|
+
assert.strictEqual(meeting.voiceaChannel, originalVoiceaChannel);
|
|
15773
|
+
} else {
|
|
15774
|
+
assert.calledOnce(mockVoiceaChannel.deregisterEvents);
|
|
15775
|
+
assert.isUndefined(meeting.voiceaChannel);
|
|
15776
|
+
}
|
|
15777
|
+
assert.isUndefined(meeting.llmChannel);
|
|
15778
|
+
});
|
|
15779
|
+
}
|
|
15780
|
+
);
|
|
15781
|
+
|
|
15782
|
+
it('passes throwOnError alongside preserveVoiceaChannel', async () => {
|
|
15783
|
+
existingChannel.disconnect.rejects(new Error('disconnect failed'));
|
|
15784
|
+
|
|
15785
|
+
// Should not throw when throwOnError is false
|
|
15786
|
+
await meeting.cleanupLLMConneciton({throwOnError: false, preserveVoiceaChannel: true});
|
|
15787
|
+
|
|
15788
|
+
assert.notCalled(mockVoiceaChannel.deregisterEvents);
|
|
15789
|
+
assert.isDefined(meeting.voiceaChannel);
|
|
15790
|
+
});
|
|
15791
|
+
|
|
15792
|
+
it('cleans up LLM event listeners regardless of preserveVoiceaChannel', async () => {
|
|
15793
|
+
await meeting.cleanupLLMConneciton({preserveVoiceaChannel: true});
|
|
15794
|
+
|
|
15795
|
+
assert.calledWithExactly(existingChannel.off, 'online', meeting.handleLLMOnline);
|
|
15796
|
+
assert.calledWithExactly(
|
|
15797
|
+
existingChannel.off,
|
|
15798
|
+
'event:relay.event',
|
|
15799
|
+
meeting.processRelayEvent
|
|
15800
|
+
);
|
|
15801
|
+
assert.calledWithExactly(
|
|
15802
|
+
existingChannel.off,
|
|
15803
|
+
'event:locus.state_message',
|
|
15804
|
+
meeting.processLocusLLMEvent
|
|
15805
|
+
);
|
|
15806
|
+
assert.called(meeting.clearLLMHealthCheckTimer);
|
|
15646
15807
|
});
|
|
15647
15808
|
});
|
|
15648
15809
|
});
|
|
@@ -17479,6 +17640,123 @@ describe('plugin-meetings', () => {
|
|
|
17479
17640
|
});
|
|
17480
17641
|
});
|
|
17481
17642
|
});
|
|
17643
|
+
describe('#isLLMConnected', () => {
|
|
17644
|
+
it('returns true when main LLM channel is connected and not in practice session', () => {
|
|
17645
|
+
meeting.webinar = {
|
|
17646
|
+
isJoinPracticeSessionDataChannel: sinon.stub().returns(false),
|
|
17647
|
+
};
|
|
17648
|
+
meeting.llmChannel = {
|
|
17649
|
+
isConnected: sinon.stub().returns(true),
|
|
17650
|
+
};
|
|
17651
|
+
|
|
17652
|
+
const result = meeting.isLLMConnected();
|
|
17653
|
+
|
|
17654
|
+
expect(result).to.equal(true);
|
|
17655
|
+
});
|
|
17656
|
+
|
|
17657
|
+
it('returns false when main LLM channel is not connected and not in practice session', () => {
|
|
17658
|
+
meeting.webinar = {
|
|
17659
|
+
isJoinPracticeSessionDataChannel: sinon.stub().returns(false),
|
|
17660
|
+
};
|
|
17661
|
+
meeting.llmChannel = {
|
|
17662
|
+
isConnected: sinon.stub().returns(false),
|
|
17663
|
+
};
|
|
17664
|
+
|
|
17665
|
+
const result = meeting.isLLMConnected();
|
|
17666
|
+
|
|
17667
|
+
expect(result).to.equal(false);
|
|
17668
|
+
});
|
|
17669
|
+
|
|
17670
|
+
it('returns false when no LLM channel exists and not in practice session', () => {
|
|
17671
|
+
meeting.webinar = {
|
|
17672
|
+
isJoinPracticeSessionDataChannel: sinon.stub().returns(false),
|
|
17673
|
+
};
|
|
17674
|
+
meeting.llmChannel = undefined;
|
|
17675
|
+
|
|
17676
|
+
const result = meeting.isLLMConnected();
|
|
17677
|
+
|
|
17678
|
+
expect(result).to.equal(false);
|
|
17679
|
+
});
|
|
17680
|
+
|
|
17681
|
+
it('returns practice session LLM channel status when in practice session', () => {
|
|
17682
|
+
meeting.webinar = {
|
|
17683
|
+
isJoinPracticeSessionDataChannel: sinon.stub().returns(true),
|
|
17684
|
+
isPracticeSessionLLMChannelConnected: sinon.stub().returns(true),
|
|
17685
|
+
};
|
|
17686
|
+
meeting.llmChannel = {
|
|
17687
|
+
isConnected: sinon.stub().returns(false),
|
|
17688
|
+
};
|
|
17689
|
+
|
|
17690
|
+
const result = meeting.isLLMConnected();
|
|
17691
|
+
|
|
17692
|
+
expect(result).to.equal(true);
|
|
17693
|
+
sinon.assert.calledOnce(meeting.webinar.isPracticeSessionLLMChannelConnected);
|
|
17694
|
+
sinon.assert.notCalled(meeting.llmChannel.isConnected);
|
|
17695
|
+
});
|
|
17696
|
+
|
|
17697
|
+
it('returns false when webinar is undefined', () => {
|
|
17698
|
+
meeting.webinar = undefined;
|
|
17699
|
+
meeting.llmChannel = {
|
|
17700
|
+
isConnected: sinon.stub().returns(true),
|
|
17701
|
+
};
|
|
17702
|
+
|
|
17703
|
+
const result = meeting.isLLMConnected();
|
|
17704
|
+
|
|
17705
|
+
expect(result).to.equal(true);
|
|
17706
|
+
});
|
|
17707
|
+
});
|
|
17708
|
+
describe('#getLLMLocusUrl', () => {
|
|
17709
|
+
it('returns locus URL from main LLM channel when not in practice session', () => {
|
|
17710
|
+
meeting.webinar = {
|
|
17711
|
+
isJoinPracticeSessionDataChannel: sinon.stub().returns(false),
|
|
17712
|
+
};
|
|
17713
|
+
meeting.llmChannel = {
|
|
17714
|
+
getLocusUrl: sinon.stub().returns('https://locus.example.com/main'),
|
|
17715
|
+
};
|
|
17716
|
+
|
|
17717
|
+
const result = meeting.getLLMLocusUrl();
|
|
17718
|
+
|
|
17719
|
+
expect(result).to.equal('https://locus.example.com/main');
|
|
17720
|
+
});
|
|
17721
|
+
|
|
17722
|
+
it('returns undefined when no LLM channel exists and not in practice session', () => {
|
|
17723
|
+
meeting.webinar = {
|
|
17724
|
+
isJoinPracticeSessionDataChannel: sinon.stub().returns(false),
|
|
17725
|
+
};
|
|
17726
|
+
meeting.llmChannel = undefined;
|
|
17727
|
+
|
|
17728
|
+
const result = meeting.getLLMLocusUrl();
|
|
17729
|
+
|
|
17730
|
+
expect(result).to.be.undefined;
|
|
17731
|
+
});
|
|
17732
|
+
|
|
17733
|
+
it('returns practice session locus URL when in practice session', () => {
|
|
17734
|
+
meeting.webinar = {
|
|
17735
|
+
isJoinPracticeSessionDataChannel: sinon.stub().returns(true),
|
|
17736
|
+
getPracticeSessionLocusUrl: sinon.stub().returns('https://locus.example.com/practice'),
|
|
17737
|
+
};
|
|
17738
|
+
meeting.llmChannel = {
|
|
17739
|
+
getLocusUrl: sinon.stub().returns('https://locus.example.com/main'),
|
|
17740
|
+
};
|
|
17741
|
+
|
|
17742
|
+
const result = meeting.getLLMLocusUrl();
|
|
17743
|
+
|
|
17744
|
+
expect(result).to.equal('https://locus.example.com/practice');
|
|
17745
|
+
sinon.assert.calledOnce(meeting.webinar.getPracticeSessionLocusUrl);
|
|
17746
|
+
sinon.assert.notCalled(meeting.llmChannel.getLocusUrl);
|
|
17747
|
+
});
|
|
17748
|
+
|
|
17749
|
+
it('returns main channel locus URL when webinar is undefined', () => {
|
|
17750
|
+
meeting.webinar = undefined;
|
|
17751
|
+
meeting.llmChannel = {
|
|
17752
|
+
getLocusUrl: sinon.stub().returns('https://locus.example.com/main'),
|
|
17753
|
+
};
|
|
17754
|
+
|
|
17755
|
+
const result = meeting.getLLMLocusUrl();
|
|
17756
|
+
|
|
17757
|
+
expect(result).to.equal('https://locus.example.com/main');
|
|
17758
|
+
});
|
|
17759
|
+
});
|
|
17482
17760
|
describe('#getDataChannelTokenType', () => {
|
|
17483
17761
|
it('returns PracticeSession when webinar is in practice session mode', () => {
|
|
17484
17762
|
meeting.webinar = {
|