@webex/plugin-meetings 3.11.0 → 3.12.0-llmrefactor.1

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