@webex/plugin-meetings 3.12.0-next.171 → 3.12.0-next.172
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/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/meeting/index.js +327 -292
- 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/meetings/index.js +4 -1
- package/dist/meetings/index.js.map +1 -1
- package/dist/types/annotation/index.d.ts +19 -0
- package/dist/types/meeting/index.d.ts +46 -12
- package/dist/types/meeting/util.d.ts +3 -1
- package/dist/webinar/index.js +298 -255
- package/dist/webinar/index.js.map +1 -1
- package/package.json +9 -9
- package/src/annotation/index.ts +55 -25
- package/src/breakouts/index.ts +33 -11
- package/src/interceptors/dataChannelAuthToken.ts +48 -77
- package/src/meeting/index.ts +296 -289
- package/src/meeting/util.ts +2 -2
- package/src/meetings/index.ts +2 -1
- 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/interceptors/dataChannelAuthToken.ts +81 -99
- package/test/unit/spec/meeting/index.js +939 -705
- package/test/unit/spec/meeting/utils.js +16 -2
- package/test/unit/spec/meetings/index.js +5 -0
- package/test/unit/spec/webinar/index.ts +886 -718
|
@@ -5,113 +5,140 @@ import MockWebex from '@webex/test-helper-mock-webex';
|
|
|
5
5
|
import uuid from 'uuid';
|
|
6
6
|
import sinon from 'sinon';
|
|
7
7
|
import {DataChannelTokenType} from '@webex/internal-plugin-llm';
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
const PRACTICE_SESSION_KEY = LLM_PRACTICE_SESSION || DataChannelTokenType.PracticeSession;
|
|
8
|
+
import {LOCUS_LLM_EVENT, SHARE_STATUS} from '@webex/plugin-meetings/src/constants';
|
|
11
9
|
|
|
12
10
|
describe('plugin-meetings', () => {
|
|
13
11
|
describe('Webinar', () => {
|
|
12
|
+
let webex;
|
|
13
|
+
let webinar;
|
|
14
|
+
let uuidStub;
|
|
15
|
+
let getUserTokenStub;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Creates a mock LLM channel with all the expected methods
|
|
19
|
+
*/
|
|
20
|
+
function createMockLLMChannel(overrides = {}) {
|
|
21
|
+
return {
|
|
22
|
+
registerAndConnect: sinon.stub().resolves('REGISTER_AND_CONNECT_RESULT'),
|
|
23
|
+
disconnect: sinon.stub().resolves(),
|
|
24
|
+
isConnected: sinon.stub().returns(false),
|
|
25
|
+
isConnecting: sinon.stub().returns(false),
|
|
26
|
+
getLocusUrl: sinon.stub().returns(undefined),
|
|
27
|
+
getDatachannelUrl: sinon.stub().returns(undefined),
|
|
28
|
+
getDatachannelToken: sinon.stub().returns(undefined),
|
|
29
|
+
setDatachannelToken: sinon.stub(),
|
|
30
|
+
getBinding: sinon.stub().returns(undefined),
|
|
31
|
+
setRefreshHandler: sinon.stub(),
|
|
32
|
+
on: sinon.stub(),
|
|
33
|
+
off: sinon.stub(),
|
|
34
|
+
...overrides,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
14
37
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
38
|
+
beforeEach(() => {
|
|
39
|
+
// @ts-ignore
|
|
40
|
+
getUserTokenStub = sinon.stub().resolves('test-token');
|
|
41
|
+
uuidStub = sinon.stub(uuid, 'v4').returns('test-uuid');
|
|
42
|
+
webex = new MockWebex({});
|
|
43
|
+
webex.internal.mercury.on = sinon.stub();
|
|
44
|
+
webinar = new Webinar({}, {parent: webex});
|
|
45
|
+
webinar.locusUrl = 'locusUrl';
|
|
46
|
+
webinar.webcastInstanceUrl = 'webcastInstanceUrl';
|
|
47
|
+
webex.request = sinon.stub().returns(Promise.resolve('REQUEST_RETURN_VALUE'));
|
|
48
|
+
webex.meetings = {};
|
|
49
|
+
webex.credentials.getUserToken = getUserTokenStub;
|
|
50
|
+
webex.meetings.getMeetingByType = sinon.stub();
|
|
51
|
+
webex.internal.voicea.announce = sinon.stub();
|
|
19
52
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
webex.internal.mercury.on = sinon.stub();
|
|
26
|
-
webinar = new Webinar({}, {parent: webex});
|
|
27
|
-
webinar.locusUrl = 'locusUrl';
|
|
28
|
-
webinar.webcastInstanceUrl = 'webcastInstanceUrl';
|
|
29
|
-
webex.request = sinon.stub().returns(Promise.resolve('REQUEST_RETURN_VALUE'));
|
|
30
|
-
webex.meetings = {};
|
|
31
|
-
webex.credentials.getUserToken = getUserTokenStub;
|
|
32
|
-
webex.meetings.getMeetingByType = sinon.stub();
|
|
33
|
-
webex.internal.voicea.announce = sinon.stub();
|
|
34
|
-
|
|
35
|
-
webex.internal.llm = {
|
|
36
|
-
getDatachannelToken: sinon.stub().returns(undefined),
|
|
37
|
-
setDatachannelToken: sinon.stub(),
|
|
38
|
-
setRefreshHandler: sinon.stub(),
|
|
39
|
-
getOwnerMeetingId: sinon.stub().returns(undefined),
|
|
40
|
-
resolveSessionOwnership: sinon.stub().callsFake((ownerMeetingId, sessionId) => {
|
|
41
|
-
const currentOwner = webex.internal.llm.getOwnerMeetingId(sessionId);
|
|
42
|
-
|
|
43
|
-
return {
|
|
44
|
-
currentOwner,
|
|
45
|
-
isOwner: !currentOwner || !ownerMeetingId || currentOwner === ownerMeetingId,
|
|
46
|
-
};
|
|
47
|
-
}),
|
|
48
|
-
setOwnerMeetingId: sinon.stub(),
|
|
49
|
-
isDataChannelTokenEnabled: sinon.stub().resolves(false),
|
|
50
|
-
isConnected: sinon.stub().returns(false),
|
|
51
|
-
disconnectLLM: sinon.stub().resolves(),
|
|
52
|
-
off: sinon.stub(),
|
|
53
|
-
on: sinon.stub(),
|
|
54
|
-
getLocusUrl: sinon.stub().returns('old-locus-url'),
|
|
55
|
-
getDatachannelUrl: sinon.stub().returns('old-dc-url'),
|
|
56
|
-
registerAndConnect: sinon.stub().resolves('REGISTER_AND_CONNECT_RESULT'),
|
|
57
|
-
};
|
|
58
|
-
});
|
|
53
|
+
// Factory pattern: createChannel returns a mock channel
|
|
54
|
+
webex.internal.llm = {
|
|
55
|
+
isDataChannelTokenEnabled: sinon.stub().resolves(false),
|
|
56
|
+
createChannel: sinon.stub().callsFake(() => createMockLLMChannel()),
|
|
57
|
+
};
|
|
59
58
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
// Mock voicea createChannel for practice session
|
|
60
|
+
webex.internal.voicea.createChannel = sinon.stub().callsFake(() => ({
|
|
61
|
+
on: sinon.stub(),
|
|
62
|
+
off: sinon.stub(),
|
|
63
|
+
announce: sinon.stub(),
|
|
64
|
+
turnOnCaptions: sinon.stub().resolves(),
|
|
65
|
+
deregisterEvents: sinon.stub(),
|
|
66
|
+
getIsCaptionBoxOn: sinon.stub().returns(false),
|
|
67
|
+
updateSubchannelSubscriptions: sinon.stub(),
|
|
68
|
+
}));
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
afterEach(() => {
|
|
72
|
+
sinon.restore();
|
|
73
|
+
});
|
|
63
74
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
75
|
+
describe('#locusUrlUpdate', () => {
|
|
76
|
+
it('sets the locus url', () => {
|
|
77
|
+
webinar.locusUrlUpdate('newUrl');
|
|
67
78
|
|
|
68
|
-
|
|
69
|
-
});
|
|
79
|
+
assert.equal(webinar.locusUrl, 'newUrl');
|
|
70
80
|
});
|
|
81
|
+
});
|
|
71
82
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
83
|
+
describe('#updateWebcastUrl', () => {
|
|
84
|
+
it('sets the webcast instance url', () => {
|
|
85
|
+
webinar.updateWebcastUrl({resources: {webcastInstance: {url: 'newUrl'}}});
|
|
75
86
|
|
|
76
|
-
|
|
77
|
-
});
|
|
87
|
+
assert.equal(webinar.webcastInstanceUrl, 'newUrl');
|
|
78
88
|
});
|
|
89
|
+
});
|
|
79
90
|
|
|
91
|
+
describe('#updateCanManageWebcast', () => {
|
|
92
|
+
it('sets the webcast instance url when valid', () => {
|
|
93
|
+
webinar.updateWebcastUrl({resources: {webcastInstance: {url: 'newUrl'}}});
|
|
94
|
+
assert.equal(
|
|
95
|
+
webinar.webcastInstanceUrl,
|
|
96
|
+
'newUrl',
|
|
97
|
+
'webcast instance URL should be updated'
|
|
98
|
+
);
|
|
99
|
+
});
|
|
80
100
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
webinar.updateWebcastUrl({});
|
|
89
|
-
assert.isUndefined(webinar.webcastInstanceUrl, 'webcast instance URL should be undefined');
|
|
90
|
-
});
|
|
101
|
+
it('handles missing resources gracefully', () => {
|
|
102
|
+
webinar.updateWebcastUrl({});
|
|
103
|
+
assert.isUndefined(
|
|
104
|
+
webinar.webcastInstanceUrl,
|
|
105
|
+
'webcast instance URL should be undefined'
|
|
106
|
+
);
|
|
107
|
+
});
|
|
91
108
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
109
|
+
it('handles missing webcastInstance gracefully', () => {
|
|
110
|
+
webinar.updateWebcastUrl({resources: {}});
|
|
111
|
+
assert.isUndefined(
|
|
112
|
+
webinar.webcastInstanceUrl,
|
|
113
|
+
'webcast instance URL should be undefined'
|
|
114
|
+
);
|
|
115
|
+
});
|
|
96
116
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
117
|
+
it('handles missing URL gracefully', () => {
|
|
118
|
+
webinar.updateWebcastUrl({resources: {webcastInstance: {}}});
|
|
119
|
+
assert.isUndefined(
|
|
120
|
+
webinar.webcastInstanceUrl,
|
|
121
|
+
'webcast instance URL should be undefined'
|
|
122
|
+
);
|
|
101
123
|
});
|
|
124
|
+
});
|
|
102
125
|
|
|
103
126
|
describe('#updateRoleChanged', () => {
|
|
104
127
|
it('updates roles when promoted from attendee to panelist', () => {
|
|
105
128
|
const payload = {
|
|
106
129
|
oldRoles: ['ATTENDEE'],
|
|
107
|
-
newRoles: ['PANELIST']
|
|
130
|
+
newRoles: ['PANELIST'],
|
|
108
131
|
};
|
|
109
132
|
|
|
110
133
|
const result = webinar.updateRoleChanged(payload);
|
|
111
134
|
|
|
112
135
|
assert.equal(webinar.selfIsPanelist, true, 'self should be a panelist');
|
|
113
136
|
assert.equal(webinar.selfIsAttendee, false, 'self should not be an attendee');
|
|
114
|
-
assert.equal(
|
|
137
|
+
assert.equal(
|
|
138
|
+
webinar.canManageWebcast,
|
|
139
|
+
false,
|
|
140
|
+
'self should not have manage webcast capability'
|
|
141
|
+
);
|
|
115
142
|
assert.equal(result.isPromoted, true, 'should indicate promotion');
|
|
116
143
|
assert.equal(result.isDemoted, false, 'should not indicate demotion');
|
|
117
144
|
});
|
|
@@ -119,14 +146,18 @@ describe('plugin-meetings', () => {
|
|
|
119
146
|
it('updates roles when demoted from panelist to attendee', () => {
|
|
120
147
|
const payload = {
|
|
121
148
|
oldRoles: ['PANELIST'],
|
|
122
|
-
newRoles: ['ATTENDEE']
|
|
149
|
+
newRoles: ['ATTENDEE'],
|
|
123
150
|
};
|
|
124
151
|
|
|
125
152
|
const result = webinar.updateRoleChanged(payload);
|
|
126
153
|
|
|
127
154
|
assert.equal(webinar.selfIsPanelist, false, 'self should not be a panelist');
|
|
128
155
|
assert.equal(webinar.selfIsAttendee, true, 'self should be an attendee');
|
|
129
|
-
assert.equal(
|
|
156
|
+
assert.equal(
|
|
157
|
+
webinar.canManageWebcast,
|
|
158
|
+
false,
|
|
159
|
+
'self should not have manage webcast capability'
|
|
160
|
+
);
|
|
130
161
|
assert.equal(result.isPromoted, false, 'should not indicate promotion');
|
|
131
162
|
assert.equal(result.isDemoted, true, 'should indicate demotion');
|
|
132
163
|
});
|
|
@@ -134,14 +165,18 @@ describe('plugin-meetings', () => {
|
|
|
134
165
|
it('updates roles when attendee just join meeting', () => {
|
|
135
166
|
const payload = {
|
|
136
167
|
oldRoles: [''],
|
|
137
|
-
newRoles: ['ATTENDEE']
|
|
168
|
+
newRoles: ['ATTENDEE'],
|
|
138
169
|
};
|
|
139
170
|
|
|
140
171
|
const result = webinar.updateRoleChanged(payload);
|
|
141
172
|
|
|
142
173
|
assert.equal(webinar.selfIsPanelist, false, 'self should not be a panelist');
|
|
143
174
|
assert.equal(webinar.selfIsAttendee, true, 'self should be an attendee');
|
|
144
|
-
assert.equal(
|
|
175
|
+
assert.equal(
|
|
176
|
+
webinar.canManageWebcast,
|
|
177
|
+
false,
|
|
178
|
+
'self should not have manage webcast capability'
|
|
179
|
+
);
|
|
145
180
|
assert.equal(result.isPromoted, false, 'should not indicate promotion');
|
|
146
181
|
assert.equal(result.isDemoted, true, 'should indicate demotion');
|
|
147
182
|
});
|
|
@@ -149,14 +184,18 @@ describe('plugin-meetings', () => {
|
|
|
149
184
|
it('updates roles when promoted to moderator', () => {
|
|
150
185
|
const payload = {
|
|
151
186
|
oldRoles: ['PANELIST'],
|
|
152
|
-
newRoles: ['MODERATOR']
|
|
187
|
+
newRoles: ['MODERATOR'],
|
|
153
188
|
};
|
|
154
189
|
|
|
155
190
|
const result = webinar.updateRoleChanged(payload);
|
|
156
191
|
|
|
157
192
|
assert.equal(webinar.selfIsPanelist, false, 'self should not be a panelist');
|
|
158
193
|
assert.equal(webinar.selfIsAttendee, false, 'self should not be an attendee');
|
|
159
|
-
assert.equal(
|
|
194
|
+
assert.equal(
|
|
195
|
+
webinar.canManageWebcast,
|
|
196
|
+
true,
|
|
197
|
+
'self should have manage webcast capability'
|
|
198
|
+
);
|
|
160
199
|
assert.equal(result.isPromoted, false, 'should not indicate promotion');
|
|
161
200
|
assert.equal(result.isDemoted, false, 'should not indicate demotion');
|
|
162
201
|
});
|
|
@@ -164,703 +203,743 @@ describe('plugin-meetings', () => {
|
|
|
164
203
|
it('updates roles when unchanged (remains as panelist)', () => {
|
|
165
204
|
const payload = {
|
|
166
205
|
oldRoles: ['PANELIST'],
|
|
167
|
-
newRoles: ['PANELIST']
|
|
206
|
+
newRoles: ['PANELIST'],
|
|
168
207
|
};
|
|
169
208
|
|
|
170
209
|
const result = webinar.updateRoleChanged(payload);
|
|
171
210
|
|
|
172
211
|
assert.equal(webinar.selfIsPanelist, true, 'self should remain a panelist');
|
|
173
212
|
assert.equal(webinar.selfIsAttendee, false, 'self should not be an attendee');
|
|
174
|
-
assert.equal(
|
|
213
|
+
assert.equal(
|
|
214
|
+
webinar.canManageWebcast,
|
|
215
|
+
false,
|
|
216
|
+
'self should not have manage webcast capability'
|
|
217
|
+
);
|
|
175
218
|
assert.equal(result.isPromoted, false, 'should not indicate promotion');
|
|
176
219
|
assert.equal(result.isDemoted, false, 'should not indicate demotion');
|
|
177
220
|
});
|
|
178
221
|
|
|
179
|
-
|
|
180
|
-
|
|
222
|
+
it('handles missing role payload safely', () => {
|
|
223
|
+
const updateStatusByRoleStub = sinon.stub(webinar, 'updateStatusByRole');
|
|
181
224
|
|
|
182
|
-
|
|
225
|
+
const result = webinar.updateRoleChanged(undefined);
|
|
183
226
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
227
|
+
assert.equal(webinar.selfIsPanelist, false);
|
|
228
|
+
assert.equal(webinar.selfIsAttendee, false);
|
|
229
|
+
assert.equal(webinar.canManageWebcast, false);
|
|
230
|
+
assert.deepEqual(result, {isPromoted: false, isDemoted: false});
|
|
231
|
+
assert.calledOnceWithExactly(updateStatusByRoleStub, {
|
|
232
|
+
isPromoted: false,
|
|
233
|
+
isDemoted: false,
|
|
234
|
+
});
|
|
235
|
+
});
|
|
189
236
|
});
|
|
190
|
-
});
|
|
191
237
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
238
|
+
describe('#getValidatedWebinarMeeting', () => {
|
|
239
|
+
it('returns the meeting when its locusUrl matches the webinar locusUrl', () => {
|
|
240
|
+
const meeting = {locusUrl: 'locusUrl'};
|
|
241
|
+
webex.meetings.getMeetingByType = sinon.stub().returns(meeting);
|
|
242
|
+
webinar.locusUrl = 'locusUrl';
|
|
197
243
|
|
|
198
|
-
|
|
199
|
-
|
|
244
|
+
assert.equal(webinar.getValidatedWebinarMeeting(), meeting);
|
|
245
|
+
});
|
|
200
246
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
247
|
+
it('returns undefined and warns when the resolved meeting locusUrl does not match', () => {
|
|
248
|
+
const warnStub = sinon.stub(LoggerProxy.logger, 'warn');
|
|
249
|
+
const meeting = {locusUrl: 'other-locus-url'};
|
|
250
|
+
webex.meetings.getMeetingByType = sinon.stub().returns(meeting);
|
|
251
|
+
webinar.locusUrl = 'locusUrl';
|
|
206
252
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
253
|
+
assert.isUndefined(webinar.getValidatedWebinarMeeting());
|
|
254
|
+
assert.calledOnce(warnStub);
|
|
255
|
+
});
|
|
210
256
|
|
|
211
|
-
|
|
212
|
-
|
|
257
|
+
it('returns undefined when no meeting is resolved', () => {
|
|
258
|
+
webex.meetings.getMeetingByType = sinon.stub().returns(undefined);
|
|
213
259
|
|
|
214
|
-
|
|
215
|
-
|
|
260
|
+
assert.isUndefined(webinar.getValidatedWebinarMeeting());
|
|
261
|
+
});
|
|
216
262
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
263
|
+
it('returns undefined and warns when webinar locusUrl is not yet initialized', () => {
|
|
264
|
+
const warnStub = sinon.stub(LoggerProxy.logger, 'warn');
|
|
265
|
+
const meeting = {locusUrl: 'some-url'};
|
|
266
|
+
webex.meetings.getMeetingByType = sinon.stub().returns(meeting);
|
|
267
|
+
webinar.locusUrl = undefined;
|
|
222
268
|
|
|
223
|
-
|
|
224
|
-
|
|
269
|
+
assert.isUndefined(webinar.getValidatedWebinarMeeting());
|
|
270
|
+
assert.calledOnce(warnStub);
|
|
271
|
+
});
|
|
225
272
|
});
|
|
226
|
-
});
|
|
227
273
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
274
|
+
describe('#cleanUp', () => {
|
|
275
|
+
it('delegates to cleanupPSDataChannel', () => {
|
|
276
|
+
const cleanupPSDataChannelStub = sinon.stub(webinar, 'cleanupPSDataChannel').resolves();
|
|
231
277
|
|
|
232
|
-
|
|
278
|
+
webinar.cleanUp();
|
|
233
279
|
|
|
234
|
-
|
|
280
|
+
assert.calledOnceWithExactly(cleanupPSDataChannelStub);
|
|
281
|
+
});
|
|
235
282
|
});
|
|
236
|
-
});
|
|
237
283
|
|
|
238
|
-
|
|
239
|
-
|
|
284
|
+
describe('#getPracticeSessionBinding', () => {
|
|
285
|
+
it('returns binding when practice session channel exists and is connected', () => {
|
|
286
|
+
const mockChannel = createMockLLMChannel({
|
|
287
|
+
getBinding: sinon.stub().returns('test-binding-123'),
|
|
288
|
+
});
|
|
289
|
+
webinar._practiceSessionLLMChannel = mockChannel;
|
|
240
290
|
|
|
241
|
-
|
|
242
|
-
webinar.meetingId = 'meeting-id';
|
|
243
|
-
relayListener = sinon.stub();
|
|
244
|
-
webinar.llmListeners = {relay: relayListener, locusLLM: null};
|
|
245
|
-
});
|
|
291
|
+
const binding = webinar.getPracticeSessionBinding();
|
|
246
292
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
webinar.
|
|
255
|
-
);
|
|
256
|
-
assert.calledWithExactly(
|
|
257
|
-
webex.internal.llm.off,
|
|
258
|
-
`event:relay.event:${PRACTICE_SESSION_KEY}`,
|
|
259
|
-
relayListener
|
|
260
|
-
);
|
|
261
|
-
assert.isNull(webinar.llmListeners.relay);
|
|
262
|
-
});
|
|
293
|
+
assert.equal(binding, 'test-binding-123');
|
|
294
|
+
assert.calledOnce(mockChannel.getBinding);
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
it('returns undefined when no practice session channel exists', () => {
|
|
298
|
+
webinar._practiceSessionLLMChannel = undefined;
|
|
299
|
+
|
|
300
|
+
const binding = webinar.getPracticeSessionBinding();
|
|
263
301
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
webex.internal.llm.disconnectLLM.resolves(false);
|
|
267
|
-
|
|
268
|
-
await webinar.cleanupPSDataChannel();
|
|
269
|
-
|
|
270
|
-
assert.calledOnceWithExactly(
|
|
271
|
-
webex.internal.llm.disconnectLLM,
|
|
272
|
-
{code: 3050, reason: 'done (permanent)'},
|
|
273
|
-
PRACTICE_SESSION_KEY,
|
|
274
|
-
webinar.meetingId
|
|
275
|
-
);
|
|
276
|
-
assert.notCalled(webex.internal.llm.setOwnerMeetingId);
|
|
277
|
-
assert.calledOnceWithExactly(
|
|
278
|
-
webex.internal.llm.off,
|
|
279
|
-
`event:relay.event:${PRACTICE_SESSION_KEY}`,
|
|
280
|
-
relayListener
|
|
281
|
-
);
|
|
302
|
+
assert.isUndefined(binding);
|
|
303
|
+
});
|
|
282
304
|
});
|
|
283
305
|
|
|
284
|
-
|
|
285
|
-
|
|
306
|
+
describe('#getPracticeSessionLocusUrl', () => {
|
|
307
|
+
it('returns locus URL when practice session channel exists', () => {
|
|
308
|
+
const mockChannel = createMockLLMChannel({
|
|
309
|
+
getLocusUrl: sinon.stub().returns('https://locus.example.com/practice'),
|
|
310
|
+
});
|
|
311
|
+
webinar._practiceSessionLLMChannel = mockChannel;
|
|
286
312
|
|
|
287
|
-
|
|
313
|
+
const locusUrl = webinar.getPracticeSessionLocusUrl();
|
|
288
314
|
|
|
289
|
-
|
|
290
|
-
(
|
|
291
|
-
);
|
|
292
|
-
assert.equal(relayOffCalls.length, 0);
|
|
293
|
-
});
|
|
315
|
+
assert.equal(locusUrl, 'https://locus.example.com/practice');
|
|
316
|
+
assert.calledOnce(mockChannel.getLocusUrl);
|
|
317
|
+
});
|
|
294
318
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
webex.internal.llm.disconnectLLM.rejects(disconnectError);
|
|
319
|
+
it('returns undefined when no practice session channel exists', () => {
|
|
320
|
+
webinar._practiceSessionLLMChannel = undefined;
|
|
298
321
|
|
|
299
|
-
|
|
322
|
+
const locusUrl = webinar.getPracticeSessionLocusUrl();
|
|
300
323
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
} catch (error) {
|
|
304
|
-
caughtError = error;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
assert.equal(caughtError, disconnectError);
|
|
308
|
-
assert.calledOnceWithExactly(
|
|
309
|
-
webex.internal.llm.setOwnerMeetingId,
|
|
310
|
-
undefined,
|
|
311
|
-
PRACTICE_SESSION_KEY
|
|
312
|
-
);
|
|
313
|
-
assert.calledOnceWithExactly(
|
|
314
|
-
webex.internal.llm.off,
|
|
315
|
-
`event:relay.event:${PRACTICE_SESSION_KEY}`,
|
|
316
|
-
relayListener
|
|
317
|
-
);
|
|
318
|
-
assert.notOk(webinar._practiceSessionRelayListener);
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
it('disconnects and removes the tracked locusLLM listener', async () => {
|
|
322
|
-
const locusLLMListener = sinon.stub();
|
|
323
|
-
webinar.llmListeners.locusLLM = locusLLMListener;
|
|
324
|
-
|
|
325
|
-
await webinar.cleanupPSDataChannel();
|
|
326
|
-
|
|
327
|
-
assert.calledWithExactly(
|
|
328
|
-
webex.internal.llm.off,
|
|
329
|
-
`${LOCUS_LLM_EVENT}:${LLM_PRACTICE_SESSION}`,
|
|
330
|
-
locusLLMListener
|
|
331
|
-
);
|
|
332
|
-
assert.isNull(webinar.llmListeners.locusLLM);
|
|
324
|
+
assert.isUndefined(locusUrl);
|
|
325
|
+
});
|
|
333
326
|
});
|
|
334
327
|
|
|
335
|
-
|
|
336
|
-
|
|
328
|
+
describe('#ensurePracticeSessionDatachannelToken', () => {
|
|
329
|
+
let meeting;
|
|
337
330
|
|
|
338
|
-
|
|
331
|
+
beforeEach(() => {
|
|
332
|
+
meeting = {
|
|
333
|
+
refreshDataChannelToken: sinon.stub().resolves({
|
|
334
|
+
body: {datachannelToken: 'refreshed-token'},
|
|
335
|
+
}),
|
|
336
|
+
};
|
|
337
|
+
});
|
|
339
338
|
|
|
340
|
-
|
|
341
|
-
(
|
|
342
|
-
);
|
|
343
|
-
assert.equal(locusLLMOffCalls.length, 0);
|
|
344
|
-
});
|
|
339
|
+
it('returns undefined when data channel token is not enabled', async () => {
|
|
340
|
+
webex.internal.llm.isDataChannelTokenEnabled.resolves(false);
|
|
345
341
|
|
|
346
|
-
|
|
347
|
-
webex.meetings.getMeetingByType = sinon.stub();
|
|
342
|
+
const token = await webinar.ensurePracticeSessionDatachannelToken(meeting);
|
|
348
343
|
|
|
349
|
-
|
|
344
|
+
assert.isUndefined(token);
|
|
345
|
+
assert.notCalled(meeting.refreshDataChannelToken);
|
|
346
|
+
});
|
|
350
347
|
|
|
351
|
-
|
|
352
|
-
|
|
348
|
+
it('returns cached token from channel when available', async () => {
|
|
349
|
+
webex.internal.llm.isDataChannelTokenEnabled.resolves(true);
|
|
350
|
+
const mockChannel = createMockLLMChannel({
|
|
351
|
+
getDatachannelToken: sinon.stub().returns('cached-channel-token'),
|
|
352
|
+
});
|
|
353
|
+
webinar._practiceSessionLLMChannel = mockChannel;
|
|
353
354
|
|
|
354
|
-
|
|
355
|
-
const listener = sinon.stub();
|
|
356
|
-
webinar._pendingOnlineListener = listener;
|
|
355
|
+
const token = await webinar.ensurePracticeSessionDatachannelToken(meeting);
|
|
357
356
|
|
|
358
|
-
|
|
357
|
+
assert.equal(token, 'cached-channel-token');
|
|
358
|
+
assert.notCalled(meeting.refreshDataChannelToken);
|
|
359
|
+
});
|
|
359
360
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
361
|
+
it('returns pending token when available', async () => {
|
|
362
|
+
webex.internal.llm.isDataChannelTokenEnabled.resolves(true);
|
|
363
|
+
webinar._pendingPracticeSessionDatachannelToken = 'pending-token';
|
|
363
364
|
|
|
364
|
-
|
|
365
|
-
webinar._pendingOnlineListener = null;
|
|
365
|
+
const token = await webinar.ensurePracticeSessionDatachannelToken(meeting);
|
|
366
366
|
|
|
367
|
-
|
|
367
|
+
assert.equal(token, 'pending-token');
|
|
368
|
+
assert.notCalled(meeting.refreshDataChannelToken);
|
|
369
|
+
});
|
|
368
370
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
});
|
|
371
|
+
it('refreshes token when no cached token exists', async () => {
|
|
372
|
+
webex.internal.llm.isDataChannelTokenEnabled.resolves(true);
|
|
373
|
+
webinar._practiceSessionLLMChannel = undefined;
|
|
374
|
+
webinar._pendingPracticeSessionDatachannelToken = undefined;
|
|
374
375
|
|
|
375
|
-
|
|
376
|
-
let meeting;
|
|
377
|
-
let processRelayEvent;
|
|
378
|
-
let processLocusLLMEvent;
|
|
376
|
+
const token = await webinar.ensurePracticeSessionDatachannelToken(meeting);
|
|
379
377
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
url: 'locus-url',
|
|
392
|
-
info: {practiceSessionDatachannelUrl: 'dc-url'},
|
|
393
|
-
},
|
|
394
|
-
};
|
|
378
|
+
assert.equal(token, 'refreshed-token');
|
|
379
|
+
assert.calledOnce(meeting.refreshDataChannelToken);
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
it('stores refreshed token on channel when channel exists', async () => {
|
|
383
|
+
webex.internal.llm.isDataChannelTokenEnabled.resolves(true);
|
|
384
|
+
const mockChannel = createMockLLMChannel({
|
|
385
|
+
getDatachannelToken: sinon.stub().returns(undefined),
|
|
386
|
+
setDatachannelToken: sinon.stub(),
|
|
387
|
+
});
|
|
388
|
+
webinar._practiceSessionLLMChannel = mockChannel;
|
|
395
389
|
|
|
396
|
-
|
|
390
|
+
await webinar.ensurePracticeSessionDatachannelToken(meeting);
|
|
397
391
|
|
|
398
|
-
|
|
399
|
-
webex.internal.llm.isConnected = sinon.stub().callsFake((sessionId) => {
|
|
400
|
-
return sessionId !== PRACTICE_SESSION_KEY;
|
|
392
|
+
assert.calledOnceWithExactly(mockChannel.setDatachannelToken, 'refreshed-token');
|
|
401
393
|
});
|
|
402
394
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
395
|
+
it('stores refreshed token as pending when no channel exists', async () => {
|
|
396
|
+
webex.internal.llm.isDataChannelTokenEnabled.resolves(true);
|
|
397
|
+
webinar._practiceSessionLLMChannel = undefined;
|
|
398
|
+
webinar._pendingPracticeSessionDatachannelToken = undefined;
|
|
399
|
+
|
|
400
|
+
await webinar.ensurePracticeSessionDatachannelToken(meeting);
|
|
401
|
+
|
|
402
|
+
assert.equal(webinar._pendingPracticeSessionDatachannelToken, 'refreshed-token');
|
|
407
403
|
});
|
|
408
404
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
405
|
+
it('returns undefined and logs warning when refresh fails', async () => {
|
|
406
|
+
webex.internal.llm.isDataChannelTokenEnabled.resolves(true);
|
|
407
|
+
webinar._practiceSessionLLMChannel = undefined;
|
|
408
|
+
webinar._pendingPracticeSessionDatachannelToken = undefined;
|
|
409
|
+
meeting.refreshDataChannelToken.rejects(new Error('refresh failed'));
|
|
410
|
+
const warnStub = sinon.stub(LoggerProxy.logger, 'warn');
|
|
411
|
+
|
|
412
|
+
const token = await webinar.ensurePracticeSessionDatachannelToken(meeting);
|
|
413
|
+
|
|
414
|
+
assert.isUndefined(token);
|
|
415
|
+
assert.calledOnce(warnStub);
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
it('returns undefined when refresh returns no token', async () => {
|
|
419
|
+
webex.internal.llm.isDataChannelTokenEnabled.resolves(true);
|
|
420
|
+
webinar._practiceSessionLLMChannel = undefined;
|
|
421
|
+
webinar._pendingPracticeSessionDatachannelToken = undefined;
|
|
422
|
+
meeting.refreshDataChannelToken.resolves({body: {}});
|
|
423
|
+
|
|
424
|
+
const token = await webinar.ensurePracticeSessionDatachannelToken(meeting);
|
|
415
425
|
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
webex.internal.llm.getDatachannelToken = sinon.stub().callsFake((tokenType) => {
|
|
419
|
-
if (tokenType === DataChannelTokenType.PracticeSession) return undefined;
|
|
420
|
-
|
|
421
|
-
return undefined;
|
|
422
|
-
});
|
|
423
|
-
meeting.refreshDataChannelToken = sinon.stub().resolves({
|
|
424
|
-
body: {
|
|
425
|
-
datachannelToken: 'ps-token-from-refresh',
|
|
426
|
-
dataChannelTokenType: DataChannelTokenType.PracticeSession,
|
|
427
|
-
},
|
|
428
|
-
});
|
|
429
|
-
|
|
430
|
-
await webinar.updatePSDataChannel();
|
|
431
|
-
|
|
432
|
-
assert.calledOnceWithExactly(meeting.refreshDataChannelToken);
|
|
433
|
-
assert.calledWithExactly(
|
|
434
|
-
webex.internal.llm.setDatachannelToken,
|
|
435
|
-
'ps-token-from-refresh',
|
|
436
|
-
DataChannelTokenType.PracticeSession,
|
|
437
|
-
'meeting-id'
|
|
438
|
-
);
|
|
439
|
-
assert.calledWith(
|
|
440
|
-
webex.internal.llm.registerAndConnect,
|
|
441
|
-
'locus-url',
|
|
442
|
-
'dc-url',
|
|
443
|
-
'ps-token-from-refresh',
|
|
444
|
-
PRACTICE_SESSION_KEY
|
|
445
|
-
);
|
|
426
|
+
assert.isUndefined(token);
|
|
427
|
+
});
|
|
446
428
|
});
|
|
447
429
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
430
|
+
describe('#cleanupPSDataChannel', () => {
|
|
431
|
+
let mockPSChannel;
|
|
432
|
+
let meeting;
|
|
433
|
+
let mockVoiceaChannel;
|
|
451
434
|
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
435
|
+
beforeEach(() => {
|
|
436
|
+
webinar.meetingId = 'meeting-id';
|
|
437
|
+
mockPSChannel = createMockLLMChannel();
|
|
438
|
+
webinar._practiceSessionLLMChannel = mockPSChannel;
|
|
439
|
+
mockVoiceaChannel = {
|
|
440
|
+
switchLLMChannel: sinon.stub().resolves(),
|
|
441
|
+
getKeepTranscriptionSubscribed: sinon.stub().returns(false),
|
|
442
|
+
};
|
|
443
|
+
meeting = {
|
|
444
|
+
id: 'meeting-id',
|
|
445
|
+
locusUrl: 'locusUrl',
|
|
446
|
+
processRelayEvent: sinon.stub(),
|
|
447
|
+
processLocusLLMEvent: sinon.stub(),
|
|
448
|
+
handleLLMOnline: sinon.stub(),
|
|
449
|
+
llmChannel: createMockLLMChannel(),
|
|
450
|
+
voiceaChannel: mockVoiceaChannel,
|
|
451
|
+
startTranscriptionIfNeeded: sinon.stub(),
|
|
452
|
+
annotation: {registerChannel: sinon.stub()},
|
|
453
|
+
trigger: sinon.stub(),
|
|
454
|
+
transcription: {captions: []},
|
|
455
|
+
};
|
|
456
|
+
webex.meetings.getMeetingByType = sinon.stub().returns(meeting);
|
|
457
|
+
});
|
|
458
458
|
|
|
459
|
-
|
|
459
|
+
it('disconnects the practice session channel and removes listeners', async () => {
|
|
460
|
+
await webinar.cleanupPSDataChannel();
|
|
460
461
|
|
|
461
|
-
|
|
462
|
+
assert.calledOnceWithExactly(mockPSChannel.disconnect, {
|
|
463
|
+
code: 3050,
|
|
464
|
+
reason: 'done (permanent)',
|
|
465
|
+
});
|
|
466
|
+
assert.calledWithExactly(
|
|
467
|
+
mockPSChannel.off,
|
|
468
|
+
'event:relay.event',
|
|
469
|
+
meeting.processRelayEvent
|
|
470
|
+
);
|
|
471
|
+
assert.calledWithExactly(
|
|
472
|
+
mockPSChannel.off,
|
|
473
|
+
LOCUS_LLM_EVENT,
|
|
474
|
+
meeting.processLocusLLMEvent
|
|
475
|
+
);
|
|
476
|
+
assert.calledWithExactly(mockPSChannel.off, 'online', meeting.handleLLMOnline);
|
|
477
|
+
assert.isUndefined(webinar._practiceSessionLLMChannel);
|
|
478
|
+
});
|
|
462
479
|
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
},
|
|
480
|
+
it('switches annotation back to meeting default channel after cleanup', async () => {
|
|
481
|
+
await webinar.cleanupPSDataChannel();
|
|
482
|
+
|
|
483
|
+
assert.calledOnceWithExactly(meeting.annotation.registerChannel, meeting.llmChannel);
|
|
468
484
|
});
|
|
469
485
|
|
|
470
|
-
|
|
486
|
+
it('removes listeners even when disconnect throws', async () => {
|
|
487
|
+
const disconnectError = new Error('disconnect failed');
|
|
488
|
+
mockPSChannel.disconnect.rejects(disconnectError);
|
|
471
489
|
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
490
|
+
let caughtError;
|
|
491
|
+
try {
|
|
492
|
+
await webinar.cleanupPSDataChannel();
|
|
493
|
+
} catch (error) {
|
|
494
|
+
caughtError = error;
|
|
495
|
+
}
|
|
475
496
|
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
497
|
+
assert.equal(caughtError, disconnectError);
|
|
498
|
+
assert.calledWithExactly(
|
|
499
|
+
mockPSChannel.off,
|
|
500
|
+
'event:relay.event',
|
|
501
|
+
meeting.processRelayEvent
|
|
502
|
+
);
|
|
503
|
+
assert.calledWithExactly(
|
|
504
|
+
mockPSChannel.off,
|
|
505
|
+
LOCUS_LLM_EVENT,
|
|
506
|
+
meeting.processLocusLLMEvent
|
|
507
|
+
);
|
|
508
|
+
assert.isUndefined(webinar._practiceSessionLLMChannel);
|
|
509
|
+
});
|
|
479
510
|
|
|
480
|
-
|
|
511
|
+
it('removes a pending online listener if one exists', async () => {
|
|
512
|
+
const listener = sinon.stub();
|
|
513
|
+
webinar._pendingOnlineListener = listener;
|
|
481
514
|
|
|
482
|
-
|
|
483
|
-
assert.calledOnceWithExactly(cleanupPSDataChannelStub);
|
|
484
|
-
assert.notCalled(webex.internal.llm.registerAndConnect);
|
|
485
|
-
});
|
|
515
|
+
await webinar.cleanupPSDataChannel();
|
|
486
516
|
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
517
|
+
assert.calledWith(meeting.llmChannel.off, 'online', listener);
|
|
518
|
+
assert.isNull(webinar._pendingOnlineListener);
|
|
519
|
+
});
|
|
490
520
|
|
|
491
|
-
|
|
521
|
+
it('no-ops when no practice session channel exists', async () => {
|
|
522
|
+
webinar._practiceSessionLLMChannel = undefined;
|
|
492
523
|
|
|
493
|
-
|
|
494
|
-
assert.calledOnceWithExactly(cleanupPSDataChannelStub);
|
|
495
|
-
assert.notCalled(webex.internal.llm.registerAndConnect);
|
|
496
|
-
});
|
|
524
|
+
await webinar.cleanupPSDataChannel();
|
|
497
525
|
|
|
498
|
-
|
|
499
|
-
|
|
526
|
+
assert.notCalled(mockPSChannel.disconnect);
|
|
527
|
+
assert.calledOnceWithExactly(mockVoiceaChannel.switchLLMChannel, meeting.llmChannel);
|
|
528
|
+
assert.calledOnceWithExactly(meeting.startTranscriptionIfNeeded);
|
|
529
|
+
});
|
|
500
530
|
|
|
501
|
-
|
|
531
|
+
it('switches voicea channel back to main meeting LLM channel when main channel is connected', async () => {
|
|
532
|
+
meeting.llmChannel.isConnected.returns(true);
|
|
502
533
|
|
|
503
|
-
|
|
504
|
-
assert.notCalled(webex.internal.llm.setRefreshHandler);
|
|
505
|
-
assert.notCalled(webex.internal.llm.setOwnerMeetingId);
|
|
506
|
-
assert.notCalled(webex.internal.llm.registerAndConnect);
|
|
507
|
-
});
|
|
534
|
+
await webinar.cleanupPSDataChannel();
|
|
508
535
|
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
webex.internal.llm.getDatachannelUrl.returns('dc-url');
|
|
513
|
-
const cleanupPSDataChannelStub = sinon.stub(webinar, 'cleanupPSDataChannel').resolves();
|
|
536
|
+
assert.calledOnceWithExactly(mockVoiceaChannel.switchLLMChannel, meeting.llmChannel);
|
|
537
|
+
assert.calledOnceWithExactly(meeting.startTranscriptionIfNeeded);
|
|
538
|
+
});
|
|
514
539
|
|
|
515
|
-
|
|
540
|
+
it('switches voicea to main channel even when not connected (defers caption restoration)', async () => {
|
|
541
|
+
meeting.llmChannel.isConnected.returns(false);
|
|
516
542
|
|
|
517
|
-
|
|
518
|
-
assert.notCalled(cleanupPSDataChannelStub);
|
|
519
|
-
assert.notCalled(webex.internal.llm.registerAndConnect);
|
|
520
|
-
});
|
|
543
|
+
await webinar.cleanupPSDataChannel();
|
|
521
544
|
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
'meeting-id',
|
|
529
|
-
PRACTICE_SESSION_KEY
|
|
530
|
-
);
|
|
531
|
-
assert.calledWith(
|
|
532
|
-
webex.internal.llm.registerAndConnect,
|
|
533
|
-
'locus-url',
|
|
534
|
-
'dc-url',
|
|
535
|
-
'ps-token',
|
|
536
|
-
PRACTICE_SESSION_KEY
|
|
537
|
-
);
|
|
538
|
-
assert.calledOnceWithExactly(webex.internal.voicea.announce);
|
|
539
|
-
assert.equal(result, 'REGISTER_AND_CONNECT_RESULT');
|
|
540
|
-
});
|
|
545
|
+
// Should still switch voicea to main channel - switchLLMChannel handles
|
|
546
|
+
// the deferred case by registering an 'online' listener
|
|
547
|
+
assert.calledOnceWithExactly(mockVoiceaChannel.switchLLMChannel, meeting.llmChannel);
|
|
548
|
+
// Should still disconnect the practice session channel
|
|
549
|
+
assert.calledOnce(mockPSChannel.disconnect);
|
|
550
|
+
});
|
|
541
551
|
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
return undefined;
|
|
546
|
-
});
|
|
547
|
-
|
|
548
|
-
await webinar.updatePSDataChannel();
|
|
549
|
-
|
|
550
|
-
assert.calledWithExactly(
|
|
551
|
-
webex.internal.llm.getDatachannelToken,
|
|
552
|
-
DataChannelTokenType.PracticeSession,
|
|
553
|
-
webinar.meetingId
|
|
554
|
-
);
|
|
555
|
-
assert.notCalled(webex.internal.llm.setDatachannelToken);
|
|
556
|
-
assert.calledWith(
|
|
557
|
-
webex.internal.llm.registerAndConnect,
|
|
558
|
-
'locus-url',
|
|
559
|
-
'dc-url',
|
|
560
|
-
'cached-token',
|
|
561
|
-
PRACTICE_SESSION_KEY
|
|
562
|
-
);
|
|
563
|
-
});
|
|
552
|
+
it('switches voicea to final main channel after disconnect when main channel was replaced during practice disconnect', async () => {
|
|
553
|
+
// Main channel connected initially
|
|
554
|
+
meeting.llmChannel.isConnected.returns(true);
|
|
564
555
|
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
556
|
+
const newLLMChannel = {
|
|
557
|
+
isConnected: sinon.stub().returns(true),
|
|
558
|
+
on: sinon.stub(),
|
|
559
|
+
off: sinon.stub(),
|
|
560
|
+
};
|
|
568
561
|
|
|
569
|
-
|
|
562
|
+
// Simulate main channel being replaced during practice disconnect
|
|
563
|
+
mockPSChannel.disconnect.callsFake(async () => {
|
|
564
|
+
meeting.llmChannel = newLLMChannel;
|
|
565
|
+
});
|
|
570
566
|
|
|
571
|
-
|
|
572
|
-
assert.calledOnce(webex.internal.llm.registerAndConnect);
|
|
573
|
-
});
|
|
567
|
+
await webinar.cleanupPSDataChannel();
|
|
574
568
|
|
|
575
|
-
|
|
576
|
-
|
|
569
|
+
// With reconciler pattern: single switch point after disconnect picks up the new channel
|
|
570
|
+
// (reconciler handles the actual rebinding internally)
|
|
571
|
+
assert.calledOnce(mockVoiceaChannel.switchLLMChannel);
|
|
572
|
+
assert.calledWith(mockVoiceaChannel.switchLLMChannel, newLLMChannel);
|
|
573
|
+
});
|
|
577
574
|
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
575
|
+
it('does not switch voicea channel when meeting has no voiceaChannel', async () => {
|
|
576
|
+
meeting.voiceaChannel = undefined;
|
|
577
|
+
|
|
578
|
+
await webinar.cleanupPSDataChannel();
|
|
579
|
+
|
|
580
|
+
// Should not throw - cleanup should continue without voicea switch
|
|
581
|
+
assert.calledOnce(mockPSChannel.disconnect);
|
|
582
|
+
});
|
|
585
583
|
});
|
|
586
584
|
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
585
|
+
describe('#updatePSDataChannel', () => {
|
|
586
|
+
let meeting;
|
|
587
|
+
let mockPSChannel;
|
|
588
|
+
let mockVoiceaChannel;
|
|
590
589
|
|
|
591
|
-
|
|
590
|
+
beforeEach(() => {
|
|
591
|
+
webinar.meetingId = 'meeting-id';
|
|
592
|
+
mockPSChannel = createMockLLMChannel({
|
|
593
|
+
isConnected: sinon.stub().returns(false),
|
|
594
|
+
getLocusUrl: sinon.stub().returns('old-locus-url'),
|
|
595
|
+
getDatachannelUrl: sinon.stub().returns('old-dc-url'),
|
|
596
|
+
getDatachannelToken: sinon.stub().callsFake((tokenType) => {
|
|
597
|
+
if (tokenType === DataChannelTokenType.PracticeSession) return 'ps-token';
|
|
598
|
+
return undefined;
|
|
599
|
+
}),
|
|
600
|
+
});
|
|
601
|
+
mockVoiceaChannel = {
|
|
602
|
+
switchLLMChannel: sinon.stub().resolves(),
|
|
603
|
+
getKeepTranscriptionSubscribed: sinon.stub().returns(false),
|
|
604
|
+
};
|
|
592
605
|
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
);
|
|
598
|
-
assert.equal(webinar.llmListeners.relay, processRelayEvent);
|
|
599
|
-
});
|
|
606
|
+
// Default session channel on the meeting
|
|
607
|
+
const mockDefaultChannel = createMockLLMChannel({
|
|
608
|
+
isConnected: sinon.stub().returns(true),
|
|
609
|
+
});
|
|
600
610
|
|
|
601
|
-
|
|
602
|
-
|
|
611
|
+
meeting = {
|
|
612
|
+
id: 'meeting-id',
|
|
613
|
+
locusUrl: 'locusUrl',
|
|
614
|
+
isJoined: sinon.stub().returns(true),
|
|
615
|
+
processRelayEvent: sinon.stub(),
|
|
616
|
+
processLocusLLMEvent: sinon.stub(),
|
|
617
|
+
handleLLMOnline: sinon.stub(),
|
|
618
|
+
startTranscriptionIfNeeded: sinon.stub(),
|
|
619
|
+
llmChannel: mockDefaultChannel,
|
|
620
|
+
voiceaChannel: mockVoiceaChannel,
|
|
621
|
+
annotation: {registerChannel: sinon.stub()},
|
|
622
|
+
locusInfo: {
|
|
623
|
+
url: 'locus-url',
|
|
624
|
+
info: {practiceSessionDatachannelUrl: 'dc-url'},
|
|
625
|
+
},
|
|
626
|
+
refreshDataChannelToken: sinon.stub().resolves({
|
|
627
|
+
body: {
|
|
628
|
+
datachannelToken: 'ps-token',
|
|
629
|
+
dataChannelTokenType: DataChannelTokenType.PracticeSession,
|
|
630
|
+
},
|
|
631
|
+
}),
|
|
632
|
+
voiceaListenerCallbacks: {},
|
|
633
|
+
trigger: sinon.stub(),
|
|
634
|
+
transcription: {captions: []},
|
|
635
|
+
};
|
|
603
636
|
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
webex.internal.llm.on,
|
|
607
|
-
`${LOCUS_LLM_EVENT}:${LLM_PRACTICE_SESSION}`,
|
|
608
|
-
processLocusLLMEvent
|
|
609
|
-
);
|
|
610
|
-
});
|
|
637
|
+
webex.meetings.getMeetingByType = sinon.stub().returns(meeting);
|
|
638
|
+
webex.internal.llm.createChannel = sinon.stub().returns(mockPSChannel);
|
|
611
639
|
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
640
|
+
// Ensure connect path is eligible
|
|
641
|
+
webinar.selfIsPanelist = true;
|
|
642
|
+
webinar.practiceSessionEnabled = true;
|
|
615
643
|
|
|
616
|
-
|
|
644
|
+
// Set a pending token so the channel can connect without requiring token refresh
|
|
645
|
+
webinar._pendingPracticeSessionDatachannelToken = 'ps-token';
|
|
646
|
+
});
|
|
617
647
|
|
|
618
|
-
|
|
619
|
-
webex.internal.llm.
|
|
620
|
-
|
|
621
|
-
previousListener
|
|
622
|
-
);
|
|
623
|
-
assert.equal(webinar.llmListeners.locusLLM, processLocusLLMEvent);
|
|
624
|
-
});
|
|
648
|
+
it('refreshes practice-session token before register when cached token is missing', async () => {
|
|
649
|
+
webex.internal.llm.isDataChannelTokenEnabled.resolves(true);
|
|
650
|
+
webinar._pendingPracticeSessionDatachannelToken = undefined; // Clear the pending token
|
|
625
651
|
|
|
626
|
-
|
|
627
|
-
webex.internal.voicea.getKeepTranscriptionSubscribed = sinon.stub().returns(true);
|
|
652
|
+
await webinar.updatePSDataChannel();
|
|
628
653
|
|
|
629
|
-
|
|
654
|
+
assert.calledOnceWithExactly(meeting.refreshDataChannelToken);
|
|
655
|
+
assert.calledWith(
|
|
656
|
+
mockPSChannel.registerAndConnect,
|
|
657
|
+
'locus-url',
|
|
658
|
+
'dc-url',
|
|
659
|
+
'ps-token' // Token from refreshDataChannelToken
|
|
660
|
+
);
|
|
661
|
+
});
|
|
630
662
|
|
|
631
|
-
|
|
632
|
-
|
|
663
|
+
it('does not reconnect if practice-session eligibility changes during async token refresh', async () => {
|
|
664
|
+
webex.internal.llm.isDataChannelTokenEnabled.resolves(true);
|
|
665
|
+
mockPSChannel.getDatachannelToken.returns(undefined);
|
|
633
666
|
|
|
634
|
-
|
|
635
|
-
|
|
667
|
+
let resolveRefresh;
|
|
668
|
+
meeting.refreshDataChannelToken = sinon.stub().returns(
|
|
669
|
+
new Promise((resolve) => {
|
|
670
|
+
resolveRefresh = resolve;
|
|
671
|
+
})
|
|
672
|
+
);
|
|
636
673
|
|
|
637
|
-
|
|
674
|
+
const updatePromise = webinar.updatePSDataChannel();
|
|
638
675
|
|
|
639
|
-
|
|
640
|
-
});
|
|
676
|
+
webinar.practiceSessionEnabled = false;
|
|
641
677
|
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
// Should return undefined immediately (deferred)
|
|
649
|
-
assert.isUndefined(result);
|
|
650
|
-
// Should register an 'online' listener but NOT call registerAndConnect yet
|
|
651
|
-
assert.calledWith(webex.internal.llm.on, 'online', sinon.match.func);
|
|
652
|
-
assert.notCalled(webex.internal.llm.registerAndConnect);
|
|
653
|
-
assert.notCalled(webex.internal.llm.setRefreshHandler);
|
|
654
|
-
assert.notCalled(webex.internal.llm.setOwnerMeetingId);
|
|
655
|
-
// Should store the pending listener
|
|
656
|
-
assert.isNotNull(webinar._pendingOnlineListener);
|
|
657
|
-
});
|
|
678
|
+
resolveRefresh({
|
|
679
|
+
body: {
|
|
680
|
+
datachannelToken: 'stale-ps-token',
|
|
681
|
+
dataChannelTokenType: DataChannelTokenType.PracticeSession,
|
|
682
|
+
},
|
|
683
|
+
});
|
|
658
684
|
|
|
659
|
-
|
|
660
|
-
webex.internal.llm.isConnected = sinon.stub().returns(false);
|
|
685
|
+
const result = await updatePromise;
|
|
661
686
|
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
687
|
+
assert.isUndefined(result);
|
|
688
|
+
assert.notCalled(mockPSChannel.registerAndConnect);
|
|
689
|
+
});
|
|
665
690
|
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
});
|
|
691
|
+
it('no-ops when practice session join eligibility is false', async () => {
|
|
692
|
+
webinar.practiceSessionEnabled = false;
|
|
693
|
+
const cleanupPSDataChannelStub = sinon.stub(webinar, 'cleanupPSDataChannel').resolves();
|
|
670
694
|
|
|
671
|
-
|
|
672
|
-
// Default session is not connected initially
|
|
673
|
-
webex.internal.llm.isConnected = sinon.stub().returns(false);
|
|
695
|
+
const result = await webinar.updatePSDataChannel();
|
|
674
696
|
|
|
675
|
-
|
|
697
|
+
assert.isUndefined(result);
|
|
698
|
+
assert.calledOnceWithExactly(cleanupPSDataChannelStub);
|
|
699
|
+
assert.notCalled(mockPSChannel.registerAndConnect);
|
|
700
|
+
});
|
|
676
701
|
|
|
677
|
-
|
|
678
|
-
|
|
702
|
+
it('no-ops when meeting is not joined', async () => {
|
|
703
|
+
meeting.isJoined.returns(false);
|
|
704
|
+
const cleanupPSDataChannelStub = sinon.stub(webinar, 'cleanupPSDataChannel').resolves();
|
|
679
705
|
|
|
680
|
-
|
|
681
|
-
const onlineCall = webex.internal.llm.on.args.find(([event]) => event === 'online');
|
|
682
|
-
assert.isDefined(onlineCall, 'should have registered an online listener');
|
|
706
|
+
const result = await webinar.updatePSDataChannel();
|
|
683
707
|
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
708
|
+
assert.isUndefined(result);
|
|
709
|
+
assert.calledOnceWithExactly(cleanupPSDataChannelStub);
|
|
710
|
+
assert.notCalled(mockPSChannel.registerAndConnect);
|
|
687
711
|
});
|
|
688
712
|
|
|
689
|
-
|
|
690
|
-
|
|
713
|
+
it('no-ops when practiceSessionDatachannelUrl is missing', async () => {
|
|
714
|
+
meeting.locusInfo.info.practiceSessionDatachannelUrl = undefined;
|
|
691
715
|
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
716
|
+
const result = await webinar.updatePSDataChannel();
|
|
717
|
+
|
|
718
|
+
assert.isUndefined(result);
|
|
719
|
+
assert.notCalled(webex.internal.llm.createChannel);
|
|
720
|
+
});
|
|
697
721
|
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
722
|
+
it('no-ops when already connected to the same endpoints', async () => {
|
|
723
|
+
// Set up existing channel already connected to same endpoints
|
|
724
|
+
const existingChannel = createMockLLMChannel({
|
|
725
|
+
isConnected: sinon.stub().returns(true),
|
|
726
|
+
getLocusUrl: sinon.stub().returns('locus-url'),
|
|
727
|
+
getDatachannelUrl: sinon.stub().returns('dc-url'),
|
|
728
|
+
});
|
|
729
|
+
webinar._practiceSessionLLMChannel = existingChannel;
|
|
730
|
+
const cleanupPSDataChannelStub = sinon.stub(webinar, 'cleanupPSDataChannel').resolves();
|
|
701
731
|
|
|
702
|
-
|
|
732
|
+
const result = await webinar.updatePSDataChannel();
|
|
703
733
|
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
734
|
+
assert.isUndefined(result);
|
|
735
|
+
assert.notCalled(cleanupPSDataChannelStub);
|
|
736
|
+
assert.notCalled(webex.internal.llm.createChannel);
|
|
737
|
+
});
|
|
707
738
|
|
|
708
|
-
|
|
709
|
-
|
|
739
|
+
it('connects when eligible', async () => {
|
|
740
|
+
const result = await webinar.updatePSDataChannel();
|
|
710
741
|
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
742
|
+
assert.calledOnce(webex.internal.llm.createChannel);
|
|
743
|
+
assert.calledWith(mockPSChannel.registerAndConnect, 'locus-url', 'dc-url', 'ps-token');
|
|
744
|
+
assert.equal(result, 'REGISTER_AND_CONNECT_RESULT');
|
|
714
745
|
});
|
|
715
746
|
|
|
716
|
-
|
|
717
|
-
|
|
747
|
+
it('sets up refresh handler on the channel', async () => {
|
|
748
|
+
await webinar.updatePSDataChannel();
|
|
718
749
|
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
750
|
+
assert.calledOnce(mockPSChannel.setRefreshHandler);
|
|
751
|
+
// The refresh handler should call meeting.refreshDataChannelToken
|
|
752
|
+
const refreshHandler = mockPSChannel.setRefreshHandler.firstCall.args[0];
|
|
753
|
+
refreshHandler();
|
|
754
|
+
assert.calledOnce(meeting.refreshDataChannelToken);
|
|
755
|
+
});
|
|
722
756
|
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
757
|
+
it('registers event listeners on the practice session channel', async () => {
|
|
758
|
+
await webinar.updatePSDataChannel();
|
|
759
|
+
|
|
760
|
+
assert.calledWith(mockPSChannel.on, 'event:relay.event', meeting.processRelayEvent);
|
|
761
|
+
assert.calledWith(mockPSChannel.on, LOCUS_LLM_EVENT, meeting.processLocusLLMEvent);
|
|
762
|
+
assert.calledWith(mockPSChannel.on, 'online', meeting.handleLLMOnline);
|
|
727
763
|
});
|
|
728
764
|
|
|
729
|
-
|
|
765
|
+
it('switches annotation to practice session channel after connect', async () => {
|
|
766
|
+
await webinar.updatePSDataChannel();
|
|
730
767
|
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
768
|
+
assert.calledOnceWithExactly(meeting.annotation.registerChannel, mockPSChannel);
|
|
769
|
+
});
|
|
770
|
+
|
|
771
|
+
it('cleans up the existing practice session channel before reconnecting to new endpoints', async () => {
|
|
772
|
+
// Set up existing channel connected to different endpoints
|
|
773
|
+
const existingChannel = createMockLLMChannel({
|
|
774
|
+
isConnected: sinon.stub().returns(true),
|
|
775
|
+
getLocusUrl: sinon.stub().returns('old-locus-url'),
|
|
776
|
+
getDatachannelUrl: sinon.stub().returns('old-dc-url'),
|
|
777
|
+
});
|
|
778
|
+
webinar._practiceSessionLLMChannel = existingChannel;
|
|
779
|
+
const cleanupPSDataChannelStub = sinon.stub(webinar, 'cleanupPSDataChannel').resolves();
|
|
780
|
+
|
|
781
|
+
await webinar.updatePSDataChannel();
|
|
738
782
|
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
webex.internal.llm.isConnected = sinon.stub().callsFake((sessionId) => {
|
|
742
|
-
return sessionId !== undefined;
|
|
783
|
+
assert.calledOnceWithExactly(cleanupPSDataChannelStub);
|
|
784
|
+
assert.calledOnce(mockPSChannel.registerAndConnect);
|
|
743
785
|
});
|
|
744
786
|
|
|
745
|
-
|
|
787
|
+
it('switches voicea channel to practice session LLM channel after connect', async () => {
|
|
788
|
+
await webinar.updatePSDataChannel();
|
|
746
789
|
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
});
|
|
790
|
+
assert.calledOnceWithExactly(mockVoiceaChannel.switchLLMChannel, mockPSChannel);
|
|
791
|
+
assert.calledOnceWithExactly(meeting.startTranscriptionIfNeeded);
|
|
792
|
+
});
|
|
751
793
|
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
webex.internal.llm.isConnected = sinon.stub().returns(false);
|
|
794
|
+
it('does not call switchLLMChannel when meeting has no voiceaChannel', async () => {
|
|
795
|
+
meeting.voiceaChannel = undefined;
|
|
755
796
|
|
|
756
|
-
|
|
797
|
+
await webinar.updatePSDataChannel();
|
|
757
798
|
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
assert.notCalled(webex.internal.llm.registerAndConnect);
|
|
762
|
-
});
|
|
799
|
+
// Should complete without error
|
|
800
|
+
assert.calledOnce(mockPSChannel.registerAndConnect);
|
|
801
|
+
});
|
|
763
802
|
|
|
764
|
-
|
|
765
|
-
|
|
803
|
+
it('defers connect when default session is not yet connected', async () => {
|
|
804
|
+
// Default session is not connected initially
|
|
805
|
+
meeting.llmChannel.isConnected.returns(false);
|
|
766
806
|
|
|
767
|
-
|
|
768
|
-
webex.internal.llm.isDataChannelTokenEnabled.resolves(true);
|
|
769
|
-
webex.internal.llm.getDatachannelToken = sinon.stub().returns(undefined);
|
|
807
|
+
const result = await webinar.updatePSDataChannel();
|
|
770
808
|
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
809
|
+
// Should return undefined immediately (deferred)
|
|
810
|
+
assert.isUndefined(result);
|
|
811
|
+
// Should register an 'online' listener but NOT call registerAndConnect yet
|
|
812
|
+
assert.calledWith(meeting.llmChannel.on, 'online', sinon.match.func);
|
|
813
|
+
assert.notCalled(mockPSChannel.registerAndConnect);
|
|
814
|
+
// Should store the pending listener
|
|
815
|
+
assert.isNotNull(webinar._pendingOnlineListener);
|
|
816
|
+
});
|
|
777
817
|
|
|
778
|
-
|
|
818
|
+
it('does not register duplicate online listeners on repeated calls', async () => {
|
|
819
|
+
meeting.llmChannel.isConnected.returns(false);
|
|
779
820
|
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
821
|
+
await webinar.updatePSDataChannel();
|
|
822
|
+
await webinar.updatePSDataChannel();
|
|
823
|
+
await webinar.updatePSDataChannel();
|
|
824
|
+
|
|
825
|
+
// Only one 'online' listener should have been registered
|
|
826
|
+
const onlineCalls = meeting.llmChannel.on.args.filter(([event]) => event === 'online');
|
|
827
|
+
assert.equal(onlineCalls.length, 1, 'should register exactly one online listener');
|
|
786
828
|
});
|
|
787
829
|
|
|
788
|
-
|
|
830
|
+
it('re-invokes updatePSDataChannel when default session comes online', async () => {
|
|
831
|
+
meeting.llmChannel.isConnected.returns(false);
|
|
789
832
|
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
});
|
|
833
|
+
const updatePSDataChannelSpy = sinon.spy(webinar, 'updatePSDataChannel');
|
|
834
|
+
|
|
835
|
+
// First call defers
|
|
836
|
+
await webinar.updatePSDataChannel();
|
|
795
837
|
|
|
796
|
-
|
|
797
|
-
|
|
838
|
+
// Capture the 'online' listener
|
|
839
|
+
const onlineCall = meeting.llmChannel.on.args.find(([event]) => event === 'online');
|
|
840
|
+
assert.isDefined(onlineCall, 'should have registered an online listener');
|
|
798
841
|
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
ownerMeetingId = 'other-meeting-id';
|
|
842
|
+
// Now simulate default session coming online
|
|
843
|
+
meeting.llmChannel.isConnected.returns(true);
|
|
802
844
|
|
|
803
|
-
|
|
845
|
+
// Fire the captured listener
|
|
846
|
+
onlineCall[1]();
|
|
847
|
+
|
|
848
|
+
// The listener should have cleared itself, removed itself, and re-called updatePSDataChannel
|
|
849
|
+
assert.isNull(webinar._pendingOnlineListener);
|
|
850
|
+
assert.calledWith(meeting.llmChannel.off, 'online', sinon.match.func);
|
|
851
|
+
assert.equal(updatePSDataChannelSpy.callCount, 2);
|
|
804
852
|
});
|
|
805
853
|
|
|
806
|
-
|
|
854
|
+
it('does not reconnect with stale data if demoted before default session comes online', async () => {
|
|
855
|
+
meeting.llmChannel.isConnected.returns(false);
|
|
807
856
|
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
857
|
+
await webinar.updatePSDataChannel();
|
|
858
|
+
|
|
859
|
+
// Capture the 'online' listener
|
|
860
|
+
const onlineCall = meeting.llmChannel.on.args.find(([event]) => event === 'online');
|
|
861
|
+
assert.isDefined(onlineCall);
|
|
862
|
+
|
|
863
|
+
// Simulate demotion while waiting
|
|
864
|
+
webinar.selfIsPanelist = false;
|
|
865
|
+
|
|
866
|
+
// Now default session comes online
|
|
867
|
+
meeting.llmChannel.isConnected.returns(true);
|
|
868
|
+
|
|
869
|
+
// Fire the listener — re-invokes updatePSDataChannel which will see isPracticeSession = false
|
|
870
|
+
onlineCall[1]();
|
|
871
|
+
|
|
872
|
+
// Should NOT have called registerAndConnect since the user is no longer eligible
|
|
873
|
+
assert.notCalled(mockPSChannel.registerAndConnect);
|
|
874
|
+
});
|
|
875
|
+
|
|
876
|
+
it('proceeds immediately when default session is already connected', async () => {
|
|
877
|
+
meeting.llmChannel.isConnected.returns(true);
|
|
878
|
+
|
|
879
|
+
const result = await webinar.updatePSDataChannel();
|
|
880
|
+
|
|
881
|
+
assert.calledOnce(mockPSChannel.registerAndConnect);
|
|
882
|
+
assert.equal(result, 'REGISTER_AND_CONNECT_RESULT');
|
|
883
|
+
});
|
|
884
|
+
|
|
885
|
+
it('clears channel reference when registerAndConnect rejects', async () => {
|
|
886
|
+
const registerError = new Error('register failed');
|
|
887
|
+
mockPSChannel.registerAndConnect.rejects(registerError);
|
|
816
888
|
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
889
|
+
try {
|
|
890
|
+
await webinar.updatePSDataChannel();
|
|
891
|
+
assert.fail('Expected updatePSDataChannel to reject when registerAndConnect fails');
|
|
892
|
+
} catch (error) {
|
|
893
|
+
assert.equal(error, registerError);
|
|
894
|
+
}
|
|
820
895
|
|
|
821
|
-
|
|
822
|
-
webex.internal.llm.setOwnerMeetingId.callsFake((id) => {
|
|
823
|
-
ownerMeetingId = id;
|
|
896
|
+
assert.isUndefined(webinar._practiceSessionLLMChannel);
|
|
824
897
|
});
|
|
825
|
-
webex.internal.llm.registerAndConnect = sinon.stub().rejects(registerError);
|
|
826
898
|
|
|
827
|
-
|
|
899
|
+
it('stores pending token on channel when one exists', async () => {
|
|
900
|
+
webinar._pendingPracticeSessionDatachannelToken = 'pending-token';
|
|
901
|
+
|
|
828
902
|
await webinar.updatePSDataChannel();
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
assert.
|
|
832
|
-
}
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
903
|
+
|
|
904
|
+
assert.calledOnceWithExactly(mockPSChannel.setDatachannelToken, 'pending-token');
|
|
905
|
+
assert.isUndefined(webinar._pendingPracticeSessionDatachannelToken);
|
|
906
|
+
});
|
|
907
|
+
|
|
908
|
+
it('disconnects and returns undefined when channel replaced mid-connect', async () => {
|
|
909
|
+
// Simulate a race condition where another updatePSDataChannel call replaces the channel
|
|
910
|
+
// while registerAndConnect is in progress
|
|
911
|
+
const replacementChannel = createMockLLMChannel();
|
|
912
|
+
mockPSChannel.registerAndConnect = sinon.stub().callsFake(async () => {
|
|
913
|
+
// Mid-connect, another call replaces the channel
|
|
914
|
+
webinar._practiceSessionLLMChannel = replacementChannel;
|
|
915
|
+
return 'CONNECT_RESULT';
|
|
916
|
+
});
|
|
917
|
+
|
|
918
|
+
const result = await webinar.updatePSDataChannel();
|
|
919
|
+
|
|
920
|
+
// Original channel should be disconnected (replaced scenario)
|
|
921
|
+
assert.calledOnceWithExactly(mockPSChannel.disconnect, {code: 3050, reason: 'replaced'});
|
|
922
|
+
// Should return undefined since the channel was replaced
|
|
923
|
+
assert.isUndefined(result);
|
|
924
|
+
});
|
|
847
925
|
});
|
|
848
926
|
|
|
849
927
|
describe('#updateStatusByRole', () => {
|
|
850
928
|
let updateMediaShares;
|
|
851
929
|
beforeEach(() => {
|
|
852
|
-
updateMediaShares = sinon.stub()
|
|
930
|
+
updateMediaShares = sinon.stub();
|
|
853
931
|
webinar.webex.meetings = {
|
|
854
932
|
getMeetingByType: sinon.stub().returns({
|
|
855
|
-
id: 'meeting-id',
|
|
933
|
+
id: 'meeting-id',
|
|
934
|
+
locusUrl: 'locusUrl',
|
|
856
935
|
isJoined: sinon.stub().returns(false),
|
|
857
936
|
updateLLMConnection: sinon.stub(),
|
|
858
937
|
shareStatus: SHARE_STATUS.WHITEBOARD_SHARE_ACTIVE,
|
|
859
938
|
locusInfo: {
|
|
860
939
|
mediaShares: 'mediaShares',
|
|
861
|
-
updateMediaShares: updateMediaShares
|
|
862
|
-
}
|
|
863
|
-
})
|
|
940
|
+
updateMediaShares: updateMediaShares,
|
|
941
|
+
},
|
|
942
|
+
}),
|
|
864
943
|
};
|
|
865
944
|
});
|
|
866
945
|
|
|
@@ -869,7 +948,6 @@ describe('plugin-meetings', () => {
|
|
|
869
948
|
});
|
|
870
949
|
|
|
871
950
|
it('trigger updateMediaShares if promoted', () => {
|
|
872
|
-
|
|
873
951
|
const roleChange = {isPromoted: true, isDemoted: false};
|
|
874
952
|
|
|
875
953
|
webinar.updateStatusByRole(roleChange);
|
|
@@ -878,7 +956,6 @@ describe('plugin-meetings', () => {
|
|
|
878
956
|
});
|
|
879
957
|
|
|
880
958
|
it('Not trigger updateMediaShares if no role change', () => {
|
|
881
|
-
|
|
882
959
|
const roleChange = {isPromoted: false, isDemoted: false};
|
|
883
960
|
|
|
884
961
|
webinar.updateStatusByRole(roleChange);
|
|
@@ -886,7 +963,6 @@ describe('plugin-meetings', () => {
|
|
|
886
963
|
assert.notCalled(updateMediaShares);
|
|
887
964
|
});
|
|
888
965
|
it('trigger updateMediaShares if is promoted', () => {
|
|
889
|
-
|
|
890
966
|
const roleChange = {isPromoted: true, isDemoted: false};
|
|
891
967
|
|
|
892
968
|
webinar.updateStatusByRole(roleChange);
|
|
@@ -895,7 +971,6 @@ describe('plugin-meetings', () => {
|
|
|
895
971
|
});
|
|
896
972
|
|
|
897
973
|
it('trigger updateMediaShares if is attendee with whiteboard share', () => {
|
|
898
|
-
|
|
899
974
|
const roleChange = {isPromoted: false, isDemoted: true};
|
|
900
975
|
|
|
901
976
|
webinar.updateStatusByRole(roleChange);
|
|
@@ -904,18 +979,18 @@ describe('plugin-meetings', () => {
|
|
|
904
979
|
});
|
|
905
980
|
|
|
906
981
|
it('Not trigger updateMediaShares if is attendee with screen share', () => {
|
|
907
|
-
|
|
908
982
|
webinar.webex.meetings = {
|
|
909
983
|
getMeetingByType: sinon.stub().returns({
|
|
910
|
-
id: 'meeting-id',
|
|
984
|
+
id: 'meeting-id',
|
|
985
|
+
locusUrl: 'locusUrl',
|
|
911
986
|
isJoined: sinon.stub().returns(false),
|
|
912
987
|
updateLLMConnection: sinon.stub(),
|
|
913
988
|
shareStatus: SHARE_STATUS.REMOTE_SHARE_ACTIVE,
|
|
914
989
|
locusInfo: {
|
|
915
990
|
mediaShares: 'mediaShares',
|
|
916
|
-
updateMediaShares: updateMediaShares
|
|
917
|
-
}
|
|
918
|
-
})
|
|
991
|
+
updateMediaShares: updateMediaShares,
|
|
992
|
+
},
|
|
993
|
+
}),
|
|
919
994
|
};
|
|
920
995
|
|
|
921
996
|
const roleChange = {isPromoted: false, isDemoted: true};
|
|
@@ -925,28 +1000,34 @@ describe('plugin-meetings', () => {
|
|
|
925
1000
|
assert.notCalled(updateMediaShares);
|
|
926
1001
|
});
|
|
927
1002
|
|
|
928
|
-
|
|
929
|
-
|
|
1003
|
+
it('updates PS data channel based on join eligibility', () => {
|
|
1004
|
+
const updatePSDataChannelStub = sinon.stub(webinar, 'updatePSDataChannel').resolves();
|
|
930
1005
|
|
|
931
|
-
|
|
1006
|
+
webinar.updateStatusByRole({isPromoted: false, isDemoted: false});
|
|
932
1007
|
|
|
933
|
-
|
|
934
|
-
|
|
1008
|
+
assert.calledOnceWithExactly(updatePSDataChannelStub);
|
|
1009
|
+
});
|
|
935
1010
|
});
|
|
936
1011
|
|
|
937
|
-
describe(
|
|
1012
|
+
describe('#setPracticeSessionState', () => {
|
|
938
1013
|
[true, false].forEach((enabled) => {
|
|
939
|
-
it(`sends a PATCH request to ${
|
|
1014
|
+
it(`sends a PATCH request to ${
|
|
1015
|
+
enabled ? 'enable' : 'disable'
|
|
1016
|
+
} the practice session`, async () => {
|
|
940
1017
|
const result = await webinar.setPracticeSessionState(enabled);
|
|
941
1018
|
assert.calledOnce(webex.request);
|
|
942
1019
|
assert.calledWith(webex.request, {
|
|
943
|
-
method:
|
|
1020
|
+
method: 'PATCH',
|
|
944
1021
|
uri: `${webinar.locusUrl}/controls`,
|
|
945
1022
|
body: {
|
|
946
|
-
practiceSession: {
|
|
947
|
-
}
|
|
1023
|
+
practiceSession: {enabled},
|
|
1024
|
+
},
|
|
948
1025
|
});
|
|
949
|
-
assert.equal(
|
|
1026
|
+
assert.equal(
|
|
1027
|
+
result,
|
|
1028
|
+
'REQUEST_RETURN_VALUE',
|
|
1029
|
+
'should return the resolved value from the request'
|
|
1030
|
+
);
|
|
950
1031
|
});
|
|
951
1032
|
});
|
|
952
1033
|
|
|
@@ -960,7 +1041,11 @@ describe('plugin-meetings', () => {
|
|
|
960
1041
|
} catch (error) {
|
|
961
1042
|
assert.equal(error.message, 'API_ERROR', 'should throw the correct error');
|
|
962
1043
|
assert.calledOnce(errorLogger);
|
|
963
|
-
assert.calledWith(
|
|
1044
|
+
assert.calledWith(
|
|
1045
|
+
errorLogger,
|
|
1046
|
+
'Meeting:webinar#setPracticeSessionState failed',
|
|
1047
|
+
sinon.match.instanceOf(Error)
|
|
1048
|
+
);
|
|
964
1049
|
}
|
|
965
1050
|
|
|
966
1051
|
errorLogger.restore();
|
|
@@ -1007,37 +1092,37 @@ describe('plugin-meetings', () => {
|
|
|
1007
1092
|
|
|
1008
1093
|
assert.equal(webinar.practiceSessionEnabled, false);
|
|
1009
1094
|
});
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1095
|
+
it('triggers PS data channel update using computed eligibility', () => {
|
|
1096
|
+
webinar.selfIsPanelist = true;
|
|
1097
|
+
const updatePSDataChannelStub = sinon.stub(webinar, 'updatePSDataChannel').resolves();
|
|
1013
1098
|
|
|
1014
|
-
|
|
1099
|
+
webinar.updatePracticeSessionStatus({enabled: true});
|
|
1015
1100
|
|
|
1016
|
-
|
|
1017
|
-
|
|
1101
|
+
assert.calledOnceWithExactly(updatePSDataChannelStub);
|
|
1102
|
+
});
|
|
1018
1103
|
});
|
|
1019
1104
|
|
|
1020
|
-
describe(
|
|
1105
|
+
describe('#startWebcast', () => {
|
|
1021
1106
|
const meeting = {
|
|
1022
1107
|
locusId: 'locusId',
|
|
1023
1108
|
correlationId: 'correlationId',
|
|
1024
|
-
}
|
|
1109
|
+
};
|
|
1025
1110
|
const layout = {
|
|
1026
1111
|
videoLayout: 'Prominent',
|
|
1027
1112
|
contentLayout: 'Prominent',
|
|
1028
1113
|
syncStageLayout: false,
|
|
1029
1114
|
syncStageInMeeting: false,
|
|
1030
|
-
}
|
|
1115
|
+
};
|
|
1031
1116
|
it(`sends a PUT request to start the webcast`, async () => {
|
|
1032
1117
|
const result = await webinar.startWebcast(meeting, layout);
|
|
1033
1118
|
assert.calledOnce(webex.request);
|
|
1034
1119
|
assert.calledWith(webex.request, {
|
|
1035
|
-
method:
|
|
1120
|
+
method: 'PUT',
|
|
1036
1121
|
uri: `${webinar.webcastInstanceUrl}/streaming`,
|
|
1037
1122
|
headers: {
|
|
1038
1123
|
authorization: 'test-token',
|
|
1039
1124
|
trackingId: 'webex-js-sdk_test-uuid',
|
|
1040
|
-
'Content-Type': 'application/json'
|
|
1125
|
+
'Content-Type': 'application/json',
|
|
1041
1126
|
},
|
|
1042
1127
|
body: {
|
|
1043
1128
|
action: 'start',
|
|
@@ -1046,9 +1131,13 @@ describe('plugin-meetings', () => {
|
|
|
1046
1131
|
correlationId: meeting.correlationId,
|
|
1047
1132
|
},
|
|
1048
1133
|
layout,
|
|
1049
|
-
}
|
|
1134
|
+
},
|
|
1050
1135
|
});
|
|
1051
|
-
assert.equal(
|
|
1136
|
+
assert.equal(
|
|
1137
|
+
result,
|
|
1138
|
+
'REQUEST_RETURN_VALUE',
|
|
1139
|
+
'should return the resolved value from the request'
|
|
1140
|
+
);
|
|
1052
1141
|
});
|
|
1053
1142
|
|
|
1054
1143
|
it('should handle undefined meeting parameter', async () => {
|
|
@@ -1058,9 +1147,16 @@ describe('plugin-meetings', () => {
|
|
|
1058
1147
|
await webinar.startWebcast(undefined, layout);
|
|
1059
1148
|
assert.fail('startWebcast should throw an error');
|
|
1060
1149
|
} catch (error) {
|
|
1061
|
-
assert.equal(
|
|
1150
|
+
assert.equal(
|
|
1151
|
+
error.message,
|
|
1152
|
+
'Meeting parameter does not meet expectations',
|
|
1153
|
+
'should throw the correct error'
|
|
1154
|
+
);
|
|
1062
1155
|
assert.calledOnce(errorLogger);
|
|
1063
|
-
assert.calledWith(
|
|
1156
|
+
assert.calledWith(
|
|
1157
|
+
errorLogger,
|
|
1158
|
+
`Meeting:webinar#startWebcast failed --> meeting parameter : ${undefined}`
|
|
1159
|
+
);
|
|
1064
1160
|
} finally {
|
|
1065
1161
|
errorLogger.restore();
|
|
1066
1162
|
}
|
|
@@ -1076,30 +1172,38 @@ describe('plugin-meetings', () => {
|
|
|
1076
1172
|
} catch (error) {
|
|
1077
1173
|
assert.equal(error.message, 'API_ERROR', 'should throw the correct error');
|
|
1078
1174
|
assert.calledOnce(errorLogger);
|
|
1079
|
-
assert.calledWith(
|
|
1175
|
+
assert.calledWith(
|
|
1176
|
+
errorLogger,
|
|
1177
|
+
'Meeting:webinar#startWebcast failed',
|
|
1178
|
+
sinon.match.instanceOf(Error)
|
|
1179
|
+
);
|
|
1080
1180
|
} finally {
|
|
1081
1181
|
errorLogger.restore();
|
|
1082
1182
|
}
|
|
1083
1183
|
});
|
|
1084
1184
|
});
|
|
1085
1185
|
|
|
1086
|
-
describe(
|
|
1186
|
+
describe('#stopWebcast', () => {
|
|
1087
1187
|
it(`sends a PUT request to stop the webcast`, async () => {
|
|
1088
1188
|
const result = await webinar.stopWebcast();
|
|
1089
1189
|
assert.calledOnce(webex.request);
|
|
1090
1190
|
assert.calledWith(webex.request, {
|
|
1091
|
-
method:
|
|
1191
|
+
method: 'PUT',
|
|
1092
1192
|
uri: `${webinar.webcastInstanceUrl}/streaming`,
|
|
1093
1193
|
headers: {
|
|
1094
1194
|
authorization: 'test-token',
|
|
1095
1195
|
trackingId: 'webex-js-sdk_test-uuid',
|
|
1096
|
-
'Content-Type': 'application/json'
|
|
1196
|
+
'Content-Type': 'application/json',
|
|
1097
1197
|
},
|
|
1098
1198
|
body: {
|
|
1099
1199
|
action: 'stop',
|
|
1100
|
-
}
|
|
1200
|
+
},
|
|
1101
1201
|
});
|
|
1102
|
-
assert.equal(
|
|
1202
|
+
assert.equal(
|
|
1203
|
+
result,
|
|
1204
|
+
'REQUEST_RETURN_VALUE',
|
|
1205
|
+
'should return the resolved value from the request'
|
|
1206
|
+
);
|
|
1103
1207
|
});
|
|
1104
1208
|
|
|
1105
1209
|
it('handles API call failures gracefully', async () => {
|
|
@@ -1112,27 +1216,34 @@ describe('plugin-meetings', () => {
|
|
|
1112
1216
|
} catch (error) {
|
|
1113
1217
|
assert.equal(error.message, 'API_ERROR', 'should throw the correct error');
|
|
1114
1218
|
assert.calledOnce(errorLogger);
|
|
1115
|
-
assert.calledWith(
|
|
1219
|
+
assert.calledWith(
|
|
1220
|
+
errorLogger,
|
|
1221
|
+
'Meeting:webinar#stopWebcast failed',
|
|
1222
|
+
sinon.match.instanceOf(Error)
|
|
1223
|
+
);
|
|
1116
1224
|
} finally {
|
|
1117
1225
|
errorLogger.restore();
|
|
1118
1226
|
}
|
|
1119
1227
|
});
|
|
1120
1228
|
});
|
|
1121
1229
|
|
|
1122
|
-
|
|
1123
|
-
describe("#queryWebcastLayout", () => {
|
|
1230
|
+
describe('#queryWebcastLayout', () => {
|
|
1124
1231
|
it(`sends a GET request to query the webcast layout`, async () => {
|
|
1125
1232
|
const result = await webinar.queryWebcastLayout();
|
|
1126
1233
|
assert.calledOnce(webex.request);
|
|
1127
1234
|
assert.calledWith(webex.request, {
|
|
1128
|
-
method:
|
|
1235
|
+
method: 'GET',
|
|
1129
1236
|
uri: `${webinar.webcastInstanceUrl}/layout`,
|
|
1130
1237
|
headers: {
|
|
1131
1238
|
authorization: 'test-token',
|
|
1132
1239
|
trackingId: 'webex-js-sdk_test-uuid',
|
|
1133
1240
|
},
|
|
1134
1241
|
});
|
|
1135
|
-
assert.equal(
|
|
1242
|
+
assert.equal(
|
|
1243
|
+
result,
|
|
1244
|
+
'REQUEST_RETURN_VALUE',
|
|
1245
|
+
'should return the resolved value from the request'
|
|
1246
|
+
);
|
|
1136
1247
|
});
|
|
1137
1248
|
|
|
1138
1249
|
it('handles API call failures gracefully', async () => {
|
|
@@ -1145,36 +1256,44 @@ describe('plugin-meetings', () => {
|
|
|
1145
1256
|
} catch (error) {
|
|
1146
1257
|
assert.equal(error.message, 'API_ERROR', 'should throw the correct error');
|
|
1147
1258
|
assert.calledOnce(errorLogger);
|
|
1148
|
-
assert.calledWith(
|
|
1259
|
+
assert.calledWith(
|
|
1260
|
+
errorLogger,
|
|
1261
|
+
'Meeting:webinar#queryWebcastLayout failed',
|
|
1262
|
+
sinon.match.instanceOf(Error)
|
|
1263
|
+
);
|
|
1149
1264
|
} finally {
|
|
1150
1265
|
errorLogger.restore();
|
|
1151
1266
|
}
|
|
1152
1267
|
});
|
|
1153
1268
|
});
|
|
1154
1269
|
|
|
1155
|
-
describe(
|
|
1270
|
+
describe('#updateWebcastLayout', () => {
|
|
1156
1271
|
const layout = {
|
|
1157
1272
|
videoLayout: 'Prominent',
|
|
1158
1273
|
contentLayout: 'Prominent',
|
|
1159
1274
|
syncStageLayout: false,
|
|
1160
1275
|
syncStageInMeeting: false,
|
|
1161
|
-
}
|
|
1276
|
+
};
|
|
1162
1277
|
it(`sends a PUT request to update the webcast layout`, async () => {
|
|
1163
1278
|
const result = await webinar.updateWebcastLayout(layout);
|
|
1164
1279
|
assert.calledOnce(webex.request);
|
|
1165
1280
|
assert.calledWith(webex.request, {
|
|
1166
|
-
method:
|
|
1281
|
+
method: 'PUT',
|
|
1167
1282
|
uri: `${webinar.webcastInstanceUrl}/layout`,
|
|
1168
1283
|
headers: {
|
|
1169
1284
|
authorization: 'test-token',
|
|
1170
1285
|
trackingId: 'webex-js-sdk_test-uuid',
|
|
1171
|
-
'Content-Type': 'application/json'
|
|
1286
|
+
'Content-Type': 'application/json',
|
|
1172
1287
|
},
|
|
1173
1288
|
body: {
|
|
1174
|
-
...layout
|
|
1175
|
-
}
|
|
1289
|
+
...layout,
|
|
1290
|
+
},
|
|
1176
1291
|
});
|
|
1177
|
-
assert.equal(
|
|
1292
|
+
assert.equal(
|
|
1293
|
+
result,
|
|
1294
|
+
'REQUEST_RETURN_VALUE',
|
|
1295
|
+
'should return the resolved value from the request'
|
|
1296
|
+
);
|
|
1178
1297
|
});
|
|
1179
1298
|
|
|
1180
1299
|
it('handles API call failures gracefully', async () => {
|
|
@@ -1187,30 +1306,40 @@ describe('plugin-meetings', () => {
|
|
|
1187
1306
|
} catch (error) {
|
|
1188
1307
|
assert.equal(error.message, 'API_ERROR', 'should throw the correct error');
|
|
1189
1308
|
assert.calledOnce(errorLogger);
|
|
1190
|
-
assert.calledWith(
|
|
1309
|
+
assert.calledWith(
|
|
1310
|
+
errorLogger,
|
|
1311
|
+
'Meeting:webinar#updateWebcastLayout failed',
|
|
1312
|
+
sinon.match.instanceOf(Error)
|
|
1313
|
+
);
|
|
1191
1314
|
} finally {
|
|
1192
1315
|
errorLogger.restore();
|
|
1193
1316
|
}
|
|
1194
1317
|
});
|
|
1195
1318
|
});
|
|
1196
1319
|
|
|
1197
|
-
describe(
|
|
1320
|
+
describe('#searchWebcastAttendees', () => {
|
|
1198
1321
|
const queryString = 'queryString';
|
|
1199
1322
|
const specialCharsQuery = 'query@string!';
|
|
1200
1323
|
const emptyQuery = '';
|
|
1201
1324
|
|
|
1202
|
-
it(
|
|
1325
|
+
it('sends a GET request to search the webcast attendees', async () => {
|
|
1203
1326
|
const result = await webinar.searchWebcastAttendees(queryString);
|
|
1204
1327
|
assert.calledOnce(webex.request);
|
|
1205
1328
|
assert.calledWith(webex.request, {
|
|
1206
|
-
method:
|
|
1207
|
-
uri: `${webinar.webcastInstanceUrl}/attendees?keyword=${encodeURIComponent(
|
|
1329
|
+
method: 'GET',
|
|
1330
|
+
uri: `${webinar.webcastInstanceUrl}/attendees?keyword=${encodeURIComponent(
|
|
1331
|
+
queryString
|
|
1332
|
+
)}`,
|
|
1208
1333
|
headers: {
|
|
1209
1334
|
authorization: 'test-token',
|
|
1210
1335
|
trackingId: 'webex-js-sdk_test-uuid',
|
|
1211
1336
|
},
|
|
1212
1337
|
});
|
|
1213
|
-
assert.equal(
|
|
1338
|
+
assert.equal(
|
|
1339
|
+
result,
|
|
1340
|
+
'REQUEST_RETURN_VALUE',
|
|
1341
|
+
'should return the resolved value from the request'
|
|
1342
|
+
);
|
|
1214
1343
|
});
|
|
1215
1344
|
|
|
1216
1345
|
it('handles API call failures gracefully', async () => {
|
|
@@ -1223,55 +1352,74 @@ describe('plugin-meetings', () => {
|
|
|
1223
1352
|
} catch (error) {
|
|
1224
1353
|
assert.equal(error.message, 'API_ERROR', 'should throw the correct error');
|
|
1225
1354
|
assert.calledOnce(errorLogger);
|
|
1226
|
-
assert.calledWith(
|
|
1355
|
+
assert.calledWith(
|
|
1356
|
+
errorLogger,
|
|
1357
|
+
'Meeting:webinar#searchWebcastAttendees failed',
|
|
1358
|
+
sinon.match.instanceOf(Error)
|
|
1359
|
+
);
|
|
1227
1360
|
} finally {
|
|
1228
1361
|
errorLogger.restore();
|
|
1229
1362
|
}
|
|
1230
1363
|
});
|
|
1231
1364
|
|
|
1232
|
-
it(
|
|
1365
|
+
it('should handle empty query string', async () => {
|
|
1233
1366
|
const result = await webinar.searchWebcastAttendees(emptyQuery);
|
|
1234
1367
|
assert.calledOnce(webex.request);
|
|
1235
1368
|
assert.calledWith(webex.request, {
|
|
1236
|
-
method:
|
|
1237
|
-
uri: `${webinar.webcastInstanceUrl}/attendees?keyword=${encodeURIComponent(
|
|
1369
|
+
method: 'GET',
|
|
1370
|
+
uri: `${webinar.webcastInstanceUrl}/attendees?keyword=${encodeURIComponent(
|
|
1371
|
+
emptyQuery
|
|
1372
|
+
)}`,
|
|
1238
1373
|
headers: {
|
|
1239
1374
|
authorization: 'test-token',
|
|
1240
1375
|
trackingId: 'webex-js-sdk_test-uuid',
|
|
1241
1376
|
},
|
|
1242
1377
|
});
|
|
1243
|
-
assert.equal(
|
|
1378
|
+
assert.equal(
|
|
1379
|
+
result,
|
|
1380
|
+
'REQUEST_RETURN_VALUE',
|
|
1381
|
+
'should return the resolved value from the request'
|
|
1382
|
+
);
|
|
1244
1383
|
});
|
|
1245
1384
|
|
|
1246
|
-
it(
|
|
1385
|
+
it('should handle query string with special characters', async () => {
|
|
1247
1386
|
const result = await webinar.searchWebcastAttendees(specialCharsQuery);
|
|
1248
1387
|
assert.calledOnce(webex.request);
|
|
1249
1388
|
assert.calledWith(webex.request, {
|
|
1250
|
-
method:
|
|
1251
|
-
uri: `${webinar.webcastInstanceUrl}/attendees?keyword=${encodeURIComponent(
|
|
1389
|
+
method: 'GET',
|
|
1390
|
+
uri: `${webinar.webcastInstanceUrl}/attendees?keyword=${encodeURIComponent(
|
|
1391
|
+
specialCharsQuery
|
|
1392
|
+
)}`,
|
|
1252
1393
|
headers: {
|
|
1253
1394
|
authorization: 'test-token',
|
|
1254
1395
|
trackingId: 'webex-js-sdk_test-uuid',
|
|
1255
1396
|
},
|
|
1256
1397
|
});
|
|
1257
|
-
assert.equal(
|
|
1398
|
+
assert.equal(
|
|
1399
|
+
result,
|
|
1400
|
+
'REQUEST_RETURN_VALUE',
|
|
1401
|
+
'should return the resolved value from the request'
|
|
1402
|
+
);
|
|
1258
1403
|
});
|
|
1259
1404
|
});
|
|
1260
1405
|
|
|
1261
|
-
|
|
1262
|
-
describe("#viewAllWebcastAttendees", () => {
|
|
1406
|
+
describe('#viewAllWebcastAttendees', () => {
|
|
1263
1407
|
it(`sends a GET request to view all the webcast attendees`, async () => {
|
|
1264
1408
|
const result = await webinar.viewAllWebcastAttendees();
|
|
1265
1409
|
assert.calledOnce(webex.request);
|
|
1266
1410
|
assert.calledWith(webex.request, {
|
|
1267
|
-
method:
|
|
1411
|
+
method: 'GET',
|
|
1268
1412
|
uri: `${webinar.webcastInstanceUrl}/attendees`,
|
|
1269
1413
|
headers: {
|
|
1270
1414
|
authorization: 'test-token',
|
|
1271
1415
|
trackingId: 'webex-js-sdk_test-uuid',
|
|
1272
1416
|
},
|
|
1273
1417
|
});
|
|
1274
|
-
assert.equal(
|
|
1418
|
+
assert.equal(
|
|
1419
|
+
result,
|
|
1420
|
+
'REQUEST_RETURN_VALUE',
|
|
1421
|
+
'should return the resolved value from the request'
|
|
1422
|
+
);
|
|
1275
1423
|
});
|
|
1276
1424
|
|
|
1277
1425
|
it('handles API call failures gracefully', async () => {
|
|
@@ -1284,27 +1432,35 @@ describe('plugin-meetings', () => {
|
|
|
1284
1432
|
} catch (error) {
|
|
1285
1433
|
assert.equal(error.message, 'API_ERROR', 'should throw the correct error');
|
|
1286
1434
|
assert.calledOnce(errorLogger);
|
|
1287
|
-
assert.calledWith(
|
|
1435
|
+
assert.calledWith(
|
|
1436
|
+
errorLogger,
|
|
1437
|
+
'Meeting:webinar#viewAllWebcastAttendees failed',
|
|
1438
|
+
sinon.match.instanceOf(Error)
|
|
1439
|
+
);
|
|
1288
1440
|
} finally {
|
|
1289
1441
|
errorLogger.restore();
|
|
1290
1442
|
}
|
|
1291
1443
|
});
|
|
1292
1444
|
});
|
|
1293
1445
|
|
|
1294
|
-
describe(
|
|
1295
|
-
const participantId = 'participantId'
|
|
1446
|
+
describe('#expelWebcastAttendee', () => {
|
|
1447
|
+
const participantId = 'participantId';
|
|
1296
1448
|
it(`sends a DELETE request to expel the webcast attendee`, async () => {
|
|
1297
1449
|
const result = await webinar.expelWebcastAttendee(participantId);
|
|
1298
1450
|
assert.calledOnce(webex.request);
|
|
1299
1451
|
assert.calledWith(webex.request, {
|
|
1300
|
-
method:
|
|
1452
|
+
method: 'DELETE',
|
|
1301
1453
|
uri: `${webinar.webcastInstanceUrl}/attendees/${participantId}`,
|
|
1302
1454
|
headers: {
|
|
1303
1455
|
authorization: 'test-token',
|
|
1304
1456
|
trackingId: 'webex-js-sdk_test-uuid',
|
|
1305
1457
|
},
|
|
1306
1458
|
});
|
|
1307
|
-
assert.equal(
|
|
1459
|
+
assert.equal(
|
|
1460
|
+
result,
|
|
1461
|
+
'REQUEST_RETURN_VALUE',
|
|
1462
|
+
'should return the resolved value from the request'
|
|
1463
|
+
);
|
|
1308
1464
|
});
|
|
1309
1465
|
|
|
1310
1466
|
it('handles API call failures gracefully', async () => {
|
|
@@ -1317,14 +1473,18 @@ describe('plugin-meetings', () => {
|
|
|
1317
1473
|
} catch (error) {
|
|
1318
1474
|
assert.equal(error.message, 'API_ERROR', 'should throw the correct error');
|
|
1319
1475
|
assert.calledOnce(errorLogger);
|
|
1320
|
-
assert.calledWith(
|
|
1476
|
+
assert.calledWith(
|
|
1477
|
+
errorLogger,
|
|
1478
|
+
'Meeting:webinar#expelWebcastAttendee failed',
|
|
1479
|
+
sinon.match.instanceOf(Error)
|
|
1480
|
+
);
|
|
1321
1481
|
} finally {
|
|
1322
1482
|
errorLogger.restore();
|
|
1323
1483
|
}
|
|
1324
1484
|
});
|
|
1325
1485
|
});
|
|
1326
1486
|
|
|
1327
|
-
describe(
|
|
1487
|
+
describe('#searchLargeScaleWebinarAttendees', () => {
|
|
1328
1488
|
const attendeeSearchUrl = 'https://locusUrl/attendees/search';
|
|
1329
1489
|
const params = {
|
|
1330
1490
|
queryString: 'queryString',
|
|
@@ -1335,40 +1495,46 @@ describe('plugin-meetings', () => {
|
|
|
1335
1495
|
// @ts-ignore
|
|
1336
1496
|
webinar.webex.meetings = {
|
|
1337
1497
|
getMeetingByType: sinon.stub().returns({
|
|
1338
|
-
id: 'meeting-id',
|
|
1498
|
+
id: 'meeting-id',
|
|
1499
|
+
locusUrl: 'locusUrl',
|
|
1339
1500
|
locusInfo: {
|
|
1340
|
-
links:{
|
|
1501
|
+
links: {
|
|
1341
1502
|
resources: {
|
|
1342
1503
|
attendeeSearch: {
|
|
1343
|
-
url: attendeeSearchUrl
|
|
1344
|
-
}
|
|
1345
|
-
}
|
|
1346
|
-
}
|
|
1347
|
-
}
|
|
1348
|
-
})
|
|
1504
|
+
url: attendeeSearchUrl,
|
|
1505
|
+
},
|
|
1506
|
+
},
|
|
1507
|
+
},
|
|
1508
|
+
},
|
|
1509
|
+
}),
|
|
1349
1510
|
};
|
|
1350
1511
|
});
|
|
1351
1512
|
|
|
1352
1513
|
it('throws an error if attendeeSearchUrl is not available', async () => {
|
|
1353
1514
|
webinar.webex.meetings = {
|
|
1354
1515
|
getMeetingByType: sinon.stub().returns({
|
|
1355
|
-
id: 'meeting-id',
|
|
1516
|
+
id: 'meeting-id',
|
|
1517
|
+
locusUrl: 'locusUrl',
|
|
1356
1518
|
locusInfo: {
|
|
1357
|
-
links:{
|
|
1519
|
+
links: {
|
|
1358
1520
|
resources: {
|
|
1359
1521
|
attendeeSearch: {
|
|
1360
|
-
url: null
|
|
1361
|
-
}
|
|
1362
|
-
}
|
|
1363
|
-
}
|
|
1364
|
-
}
|
|
1365
|
-
})
|
|
1522
|
+
url: null,
|
|
1523
|
+
},
|
|
1524
|
+
},
|
|
1525
|
+
},
|
|
1526
|
+
},
|
|
1527
|
+
}),
|
|
1366
1528
|
};
|
|
1367
1529
|
try {
|
|
1368
1530
|
await webinar.searchLargeScaleWebinarAttendees(params);
|
|
1369
1531
|
assert.fail('searchLargeScaleWebinarAttendees should throw an error');
|
|
1370
1532
|
} catch (error) {
|
|
1371
|
-
assert.equal(
|
|
1533
|
+
assert.equal(
|
|
1534
|
+
error.message,
|
|
1535
|
+
'Meeting:webinar5k#Attendee search url is not available',
|
|
1536
|
+
'should throw the correct error'
|
|
1537
|
+
);
|
|
1372
1538
|
}
|
|
1373
1539
|
});
|
|
1374
1540
|
|
|
@@ -1377,7 +1543,9 @@ describe('plugin-meetings', () => {
|
|
|
1377
1543
|
assert.calledOnce(webex.request);
|
|
1378
1544
|
assert.calledWith(webex.request, {
|
|
1379
1545
|
method: 'GET',
|
|
1380
|
-
uri: `${attendeeSearchUrl}?search_text=${encodeURIComponent(
|
|
1546
|
+
uri: `${attendeeSearchUrl}?search_text=${encodeURIComponent(
|
|
1547
|
+
params.queryString
|
|
1548
|
+
)}&limit=50`,
|
|
1381
1549
|
headers: {
|
|
1382
1550
|
authorization: 'test-token',
|
|
1383
1551
|
trackingId: 'webex-js-sdk_test-uuid',
|
|
@@ -1429,5 +1597,5 @@ describe('plugin-meetings', () => {
|
|
|
1429
1597
|
}
|
|
1430
1598
|
});
|
|
1431
1599
|
});
|
|
1432
|
-
})
|
|
1600
|
+
});
|
|
1433
1601
|
})
|