@webex/calling 3.10.0 → 3.11.0

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 (221) hide show
  1. package/dist/module/CallHistory/CallHistory.js +20 -11
  2. package/dist/module/CallSettings/UcmBackendConnector.js +21 -8
  3. package/dist/module/CallSettings/WxCallBackendConnector.js +10 -15
  4. package/dist/module/CallingClient/CallingClient.js +83 -123
  5. package/dist/module/CallingClient/calling/call.js +73 -58
  6. package/dist/module/CallingClient/calling/callManager.js +7 -0
  7. package/dist/module/CallingClient/constants.js +3 -0
  8. package/dist/module/CallingClient/registration/register.js +85 -5
  9. package/dist/module/CallingClient/registration/webWorker.js +2 -2
  10. package/dist/module/CallingClient/registration/webWorkerStr.js +2 -2
  11. package/dist/module/Contacts/ContactsClient.js +19 -25
  12. package/dist/module/Events/impl/index.js +1 -1
  13. package/dist/module/Logger/index.js +2 -2
  14. package/dist/module/Voicemail/BroadworksBackendConnector.js +10 -18
  15. package/dist/module/Voicemail/UcmBackendConnector.js +7 -11
  16. package/dist/module/Voicemail/Voicemail.js +42 -68
  17. package/dist/module/Voicemail/WxCallBackendConnector.js +14 -28
  18. package/dist/module/common/Utils.js +31 -5
  19. package/dist/module/common/constants.js +2 -0
  20. package/dist/module/common/testUtil.js +1 -0
  21. package/dist/types/CallHistory/CallHistory.d.ts.map +1 -1
  22. package/dist/types/CallSettings/UcmBackendConnector.d.ts +1 -0
  23. package/dist/types/CallSettings/UcmBackendConnector.d.ts.map +1 -1
  24. package/dist/types/CallSettings/WxCallBackendConnector.d.ts.map +1 -1
  25. package/dist/types/CallingClient/CallingClient.d.ts.map +1 -1
  26. package/dist/types/CallingClient/calling/call.d.ts +4 -0
  27. package/dist/types/CallingClient/calling/call.d.ts.map +1 -1
  28. package/dist/types/CallingClient/calling/callManager.d.ts.map +1 -1
  29. package/dist/types/CallingClient/constants.d.ts +3 -0
  30. package/dist/types/CallingClient/constants.d.ts.map +1 -1
  31. package/dist/types/CallingClient/registration/register.d.ts +4 -0
  32. package/dist/types/CallingClient/registration/register.d.ts.map +1 -1
  33. package/dist/types/CallingClient/registration/types.d.ts +6 -0
  34. package/dist/types/CallingClient/registration/types.d.ts.map +1 -1
  35. package/dist/types/CallingClient/registration/webWorkerStr.d.ts +1 -1
  36. package/dist/types/CallingClient/registration/webWorkerStr.d.ts.map +1 -1
  37. package/dist/types/Contacts/ContactsClient.d.ts +1 -0
  38. package/dist/types/Contacts/ContactsClient.d.ts.map +1 -1
  39. package/dist/types/Logger/index.d.ts +1 -2
  40. package/dist/types/Logger/index.d.ts.map +1 -1
  41. package/dist/types/SDKConnector/types.d.ts +16 -0
  42. package/dist/types/SDKConnector/types.d.ts.map +1 -1
  43. package/dist/types/Voicemail/BroadworksBackendConnector.d.ts.map +1 -1
  44. package/dist/types/Voicemail/UcmBackendConnector.d.ts.map +1 -1
  45. package/dist/types/Voicemail/Voicemail.d.ts.map +1 -1
  46. package/dist/types/Voicemail/WxCallBackendConnector.d.ts.map +1 -1
  47. package/dist/types/common/Utils.d.ts +1 -1
  48. package/dist/types/common/Utils.d.ts.map +1 -1
  49. package/dist/types/common/constants.d.ts +2 -0
  50. package/dist/types/common/constants.d.ts.map +1 -1
  51. package/dist/types/common/testUtil.d.ts +1 -0
  52. package/dist/types/common/testUtil.d.ts.map +1 -1
  53. package/package.json +4 -4
  54. package/dist/CallHistory/CallHistory.js +0 -584
  55. package/dist/CallHistory/CallHistory.js.map +0 -1
  56. package/dist/CallHistory/CallHistory.test.js +0 -813
  57. package/dist/CallHistory/CallHistory.test.js.map +0 -1
  58. package/dist/CallHistory/callHistoryFixtures.js +0 -650
  59. package/dist/CallHistory/callHistoryFixtures.js.map +0 -1
  60. package/dist/CallHistory/constants.js +0 -38
  61. package/dist/CallHistory/constants.js.map +0 -1
  62. package/dist/CallHistory/types.js +0 -7
  63. package/dist/CallHistory/types.js.map +0 -1
  64. package/dist/CallSettings/CallSettings.js +0 -312
  65. package/dist/CallSettings/CallSettings.js.map +0 -1
  66. package/dist/CallSettings/CallSettings.test.js +0 -122
  67. package/dist/CallSettings/CallSettings.test.js.map +0 -1
  68. package/dist/CallSettings/UcmBackendConnector.js +0 -261
  69. package/dist/CallSettings/UcmBackendConnector.js.map +0 -1
  70. package/dist/CallSettings/UcmBackendConnector.test.js +0 -321
  71. package/dist/CallSettings/UcmBackendConnector.test.js.map +0 -1
  72. package/dist/CallSettings/WxCallBackendConnector.js +0 -604
  73. package/dist/CallSettings/WxCallBackendConnector.js.map +0 -1
  74. package/dist/CallSettings/WxCallBackendConnector.test.js +0 -905
  75. package/dist/CallSettings/WxCallBackendConnector.test.js.map +0 -1
  76. package/dist/CallSettings/constants.js +0 -31
  77. package/dist/CallSettings/constants.js.map +0 -1
  78. package/dist/CallSettings/testFixtures.js +0 -68
  79. package/dist/CallSettings/testFixtures.js.map +0 -1
  80. package/dist/CallSettings/types.js +0 -7
  81. package/dist/CallSettings/types.js.map +0 -1
  82. package/dist/CallingClient/CallingClient.js +0 -1071
  83. package/dist/CallingClient/CallingClient.js.map +0 -1
  84. package/dist/CallingClient/CallingClient.test.js +0 -1289
  85. package/dist/CallingClient/CallingClient.test.js.map +0 -1
  86. package/dist/CallingClient/callRecordFixtures.js +0 -101
  87. package/dist/CallingClient/callRecordFixtures.js.map +0 -1
  88. package/dist/CallingClient/calling/CallerId/index.js +0 -276
  89. package/dist/CallingClient/calling/CallerId/index.js.map +0 -1
  90. package/dist/CallingClient/calling/CallerId/index.test.js +0 -275
  91. package/dist/CallingClient/calling/CallerId/index.test.js.map +0 -1
  92. package/dist/CallingClient/calling/CallerId/types.js +0 -7
  93. package/dist/CallingClient/calling/CallerId/types.js.map +0 -1
  94. package/dist/CallingClient/calling/call.js +0 -3444
  95. package/dist/CallingClient/calling/call.js.map +0 -1
  96. package/dist/CallingClient/calling/call.test.js +0 -3260
  97. package/dist/CallingClient/calling/call.test.js.map +0 -1
  98. package/dist/CallingClient/calling/callManager.js +0 -456
  99. package/dist/CallingClient/calling/callManager.js.map +0 -1
  100. package/dist/CallingClient/calling/callManager.test.js +0 -741
  101. package/dist/CallingClient/calling/callManager.test.js.map +0 -1
  102. package/dist/CallingClient/calling/index.js +0 -30
  103. package/dist/CallingClient/calling/index.js.map +0 -1
  104. package/dist/CallingClient/calling/types.js +0 -74
  105. package/dist/CallingClient/calling/types.js.map +0 -1
  106. package/dist/CallingClient/callingClientFixtures.js +0 -143
  107. package/dist/CallingClient/callingClientFixtures.js.map +0 -1
  108. package/dist/CallingClient/constants.js +0 -237
  109. package/dist/CallingClient/constants.js.map +0 -1
  110. package/dist/CallingClient/line/index.js +0 -349
  111. package/dist/CallingClient/line/index.js.map +0 -1
  112. package/dist/CallingClient/line/line.test.js +0 -327
  113. package/dist/CallingClient/line/line.test.js.map +0 -1
  114. package/dist/CallingClient/line/types.js +0 -21
  115. package/dist/CallingClient/line/types.js.map +0 -1
  116. package/dist/CallingClient/registration/index.js +0 -19
  117. package/dist/CallingClient/registration/index.js.map +0 -1
  118. package/dist/CallingClient/registration/register.js +0 -1538
  119. package/dist/CallingClient/registration/register.js.map +0 -1
  120. package/dist/CallingClient/registration/register.test.js +0 -1537
  121. package/dist/CallingClient/registration/register.test.js.map +0 -1
  122. package/dist/CallingClient/registration/registerFixtures.js +0 -36
  123. package/dist/CallingClient/registration/registerFixtures.js.map +0 -1
  124. package/dist/CallingClient/registration/types.js +0 -7
  125. package/dist/CallingClient/registration/types.js.map +0 -1
  126. package/dist/CallingClient/registration/webWorker.js +0 -130
  127. package/dist/CallingClient/registration/webWorker.js.map +0 -1
  128. package/dist/CallingClient/registration/webWorker.test.js +0 -303
  129. package/dist/CallingClient/registration/webWorker.test.js.map +0 -1
  130. package/dist/CallingClient/registration/webWorkerStr.js +0 -15
  131. package/dist/CallingClient/registration/webWorkerStr.js.map +0 -1
  132. package/dist/CallingClient/types.js +0 -7
  133. package/dist/CallingClient/types.js.map +0 -1
  134. package/dist/CallingClient/windowsChromiumIceWarmupUtils.js +0 -142
  135. package/dist/CallingClient/windowsChromiumIceWarmupUtils.js.map +0 -1
  136. package/dist/Contacts/ContactsClient.js +0 -1215
  137. package/dist/Contacts/ContactsClient.js.map +0 -1
  138. package/dist/Contacts/ContactsClient.test.js +0 -1003
  139. package/dist/Contacts/ContactsClient.test.js.map +0 -1
  140. package/dist/Contacts/constants.js +0 -40
  141. package/dist/Contacts/constants.js.map +0 -1
  142. package/dist/Contacts/contactFixtures.js +0 -430
  143. package/dist/Contacts/contactFixtures.js.map +0 -1
  144. package/dist/Contacts/types.js +0 -43
  145. package/dist/Contacts/types.js.map +0 -1
  146. package/dist/Errors/catalog/CallError.js +0 -92
  147. package/dist/Errors/catalog/CallError.js.map +0 -1
  148. package/dist/Errors/catalog/CallingDeviceError.js +0 -86
  149. package/dist/Errors/catalog/CallingDeviceError.js.map +0 -1
  150. package/dist/Errors/catalog/ExtendedError.js +0 -44
  151. package/dist/Errors/catalog/ExtendedError.js.map +0 -1
  152. package/dist/Errors/catalog/LineError.js +0 -88
  153. package/dist/Errors/catalog/LineError.js.map +0 -1
  154. package/dist/Errors/index.js +0 -28
  155. package/dist/Errors/index.js.map +0 -1
  156. package/dist/Errors/types.js +0 -59
  157. package/dist/Errors/types.js.map +0 -1
  158. package/dist/Events/impl/index.js +0 -81
  159. package/dist/Events/impl/index.js.map +0 -1
  160. package/dist/Events/types.js +0 -107
  161. package/dist/Events/types.js.map +0 -1
  162. package/dist/Logger/index.js +0 -228
  163. package/dist/Logger/index.js.map +0 -1
  164. package/dist/Logger/index.test.js +0 -87
  165. package/dist/Logger/index.test.js.map +0 -1
  166. package/dist/Logger/types.js +0 -34
  167. package/dist/Logger/types.js.map +0 -1
  168. package/dist/Metrics/index.js +0 -535
  169. package/dist/Metrics/index.js.map +0 -1
  170. package/dist/Metrics/index.test.js +0 -463
  171. package/dist/Metrics/index.test.js.map +0 -1
  172. package/dist/Metrics/types.js +0 -64
  173. package/dist/Metrics/types.js.map +0 -1
  174. package/dist/SDKConnector/index.js +0 -103
  175. package/dist/SDKConnector/index.js.map +0 -1
  176. package/dist/SDKConnector/index.test.js +0 -9
  177. package/dist/SDKConnector/index.test.js.map +0 -1
  178. package/dist/SDKConnector/types.js +0 -7
  179. package/dist/SDKConnector/types.js.map +0 -1
  180. package/dist/SDKConnector/utils.js +0 -39
  181. package/dist/SDKConnector/utils.js.map +0 -1
  182. package/dist/SDKConnector/utils.test.js +0 -9
  183. package/dist/SDKConnector/utils.test.js.map +0 -1
  184. package/dist/Voicemail/BroadworksBackendConnector.js +0 -707
  185. package/dist/Voicemail/BroadworksBackendConnector.js.map +0 -1
  186. package/dist/Voicemail/BroadworksBackendConnector.test.js +0 -812
  187. package/dist/Voicemail/BroadworksBackendConnector.test.js.map +0 -1
  188. package/dist/Voicemail/UcmBackendConnector.js +0 -632
  189. package/dist/Voicemail/UcmBackendConnector.js.map +0 -1
  190. package/dist/Voicemail/UcmBackendConnector.test.js +0 -738
  191. package/dist/Voicemail/UcmBackendConnector.test.js.map +0 -1
  192. package/dist/Voicemail/Voicemail.js +0 -500
  193. package/dist/Voicemail/Voicemail.js.map +0 -1
  194. package/dist/Voicemail/Voicemail.test.js +0 -391
  195. package/dist/Voicemail/Voicemail.test.js.map +0 -1
  196. package/dist/Voicemail/WxCallBackendConnector.js +0 -671
  197. package/dist/Voicemail/WxCallBackendConnector.js.map +0 -1
  198. package/dist/Voicemail/WxCallBackendConnector.test.js +0 -1199
  199. package/dist/Voicemail/WxCallBackendConnector.test.js.map +0 -1
  200. package/dist/Voicemail/constants.js +0 -61
  201. package/dist/Voicemail/constants.js.map +0 -1
  202. package/dist/Voicemail/types.js +0 -7
  203. package/dist/Voicemail/types.js.map +0 -1
  204. package/dist/Voicemail/voicemailFixture.js +0 -524
  205. package/dist/Voicemail/voicemailFixture.js.map +0 -1
  206. package/dist/api.js +0 -157
  207. package/dist/api.js.map +0 -1
  208. package/dist/common/Utils.js +0 -1451
  209. package/dist/common/Utils.js.map +0 -1
  210. package/dist/common/Utils.test.js +0 -1744
  211. package/dist/common/Utils.test.js.map +0 -1
  212. package/dist/common/constants.js +0 -60
  213. package/dist/common/constants.js.map +0 -1
  214. package/dist/common/index.js +0 -19
  215. package/dist/common/index.js.map +0 -1
  216. package/dist/common/testUtil.js +0 -982
  217. package/dist/common/testUtil.js.map +0 -1
  218. package/dist/common/types.js +0 -75
  219. package/dist/common/types.js.map +0 -1
  220. package/dist/index.js +0 -321
  221. package/dist/index.js.map +0 -1
@@ -1,1289 +0,0 @@
1
- "use strict";
2
-
3
- var _typeof = require("@babel/runtime-corejs2/helpers/typeof");
4
- var _Object$keys2 = require("@babel/runtime-corejs2/core-js/object/keys");
5
- var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs2/core-js/object/get-own-property-symbols");
6
- var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
7
- var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptors");
8
- var _Object$defineProperties = require("@babel/runtime-corejs2/core-js/object/define-properties");
9
- var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
10
- var _WeakMap = require("@babel/runtime-corejs2/core-js/weak-map");
11
- var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
12
- var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
13
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
14
- var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
15
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
16
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
17
- var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
18
- var _values = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/values"));
19
- var _keys = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/keys"));
20
- var _asyncMutex = require("async-mutex");
21
- var Media = _interopRequireWildcard(require("@webex/internal-media-core"));
22
- var _types = require("../Logger/types");
23
- var _testUtil = require("../common/testUtil");
24
- var _types2 = require("../common/types");
25
- var _types3 = require("../Events/types");
26
- var _Logger = _interopRequireDefault(require("../Logger"));
27
- var _CallingClient = require("./CallingClient");
28
- var _Utils = _interopRequireWildcard(require("../common/Utils"));
29
- var utils = _Utils;
30
- var _callManager = require("./calling/callManager");
31
- var _constants = require("./constants");
32
- var _callRecordFixtures = require("./callRecordFixtures");
33
- var _callingClientFixtures = require("./callingClientFixtures");
34
- var _line = _interopRequireDefault(require("./line"));
35
- var _registerFixtures = require("./registration/registerFixtures");
36
- var _constants2 = require("../common/constants");
37
- var _types4 = require("../Metrics/types");
38
- var _windowsChromiumIceWarmupUtils = _interopRequireDefault(require("./windowsChromiumIceWarmupUtils"));
39
- function _interopRequireWildcard(e, t) { if ("function" == typeof _WeakMap) var r = new _WeakMap(), n = new _WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = _Object$defineProperty) && _Object$getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
40
- function ownKeys(e, r) { var t = _Object$keys2(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
41
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; } /* eslint-disable dot-notation */
42
- global.crypto = {
43
- randomUUID: function randomUUID() {
44
- return '12345678-1234-5678-1234-567812345678';
45
- }
46
- };
47
- jest.spyOn(utils, 'uploadLogs').mockResolvedValue(undefined);
48
- describe('CallingClient Tests', function () {
49
- // Common initializers
50
-
51
- var handleErrorSpy = jest.spyOn(utils, 'handleCallingClientErrors');
52
- var setLoggerSpy = jest.spyOn(Media, 'setLogger');
53
- var webex = (0, _testUtil.getTestUtilsWebex)();
54
- webex.internal.services['_hostCatalog'] = _callingClientFixtures.mockCatalogUS;
55
- var defaultServiceIndicator = _types2.ServiceIndicator.CALLING;
56
- var callManager = (0, _callManager.getCallManager)(webex, defaultServiceIndicator);
57
- var infoSpy = jest.spyOn(_Logger.default, 'info');
58
- var logSpy = jest.spyOn(_Logger.default, 'log');
59
- var warnSpy = jest.spyOn(_Logger.default, 'warn');
60
- var originalProcessNextTick = process.nextTick;
61
- function flushPromises() {
62
- return new _promise.default(function (resolve) {
63
- originalProcessNextTick(resolve);
64
- });
65
- }
66
- describe('CallingClient pick Mobius cluster using Service Host Tests', function () {
67
- afterAll(function () {
68
- callManager.removeAllListeners();
69
- webex.internal.services['_serviceUrls']['mobius'] = 'https://mobius.aintgen-a-1.int.infra.webex.com/api/v1';
70
- webex.internal.services['_hostCatalog'] = _callingClientFixtures.mockCatalogUS;
71
- });
72
- it('should set mobiusServiceHost correctly when URL is valid', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee() {
73
- var urlSpy, callingClient;
74
- return _regenerator.default.wrap(function _callee$(_context) {
75
- while (1) switch (_context.prev = _context.next) {
76
- case 0:
77
- webex.internal.services._hostCatalog = _callingClientFixtures.mockCatalogEU;
78
- webex.internal.services['_serviceUrls']['mobius'] = 'https://mobius-eu-central-1.prod.infra.webex.com/api/v1';
79
- urlSpy = jest.spyOn(window, 'URL').mockImplementation(function (url) {
80
- return new window.URL(url);
81
- });
82
- _context.next = 5;
83
- return (0, _CallingClient.createClient)(webex, {
84
- logger: {
85
- level: _types.LOGGER.INFO
86
- }
87
- });
88
- case 5:
89
- callingClient = _context.sent;
90
- expect(urlSpy).toHaveBeenCalledWith('https://mobius-eu-central-1.prod.infra.webex.com/api/v1');
91
- expect(callingClient['mobiusClusters']).toStrictEqual(_callingClientFixtures.mockEUServiceHosts);
92
- urlSpy.mockRestore();
93
- case 9:
94
- case "end":
95
- return _context.stop();
96
- }
97
- }, _callee);
98
- })));
99
- it('should use default mobius service host when Service URL is invalid', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee2() {
100
- var callingClient;
101
- return _regenerator.default.wrap(function _callee2$(_context2) {
102
- while (1) switch (_context2.prev = _context2.next) {
103
- case 0:
104
- webex.internal.services._hostCatalog = _callingClientFixtures.mockCatalogUS;
105
- webex.internal.services._serviceUrls.mobius = 'invalid-url';
106
- _context2.next = 4;
107
- return (0, _CallingClient.createClient)(webex, {
108
- logger: {
109
- level: _types.LOGGER.INFO
110
- }
111
- });
112
- case 4:
113
- callingClient = _context2.sent;
114
- expect(setLoggerSpy).toHaveBeenCalledTimes(1);
115
- expect(callingClient['mobiusClusters']).toStrictEqual(_callingClientFixtures.mockUSServiceHosts);
116
- case 7:
117
- case "end":
118
- return _context2.stop();
119
- }
120
- }, _callee2);
121
- })));
122
- });
123
- describe('ServiceData tests', function () {
124
- var callingClient;
125
- afterEach(function () {
126
- callManager.removeAllListeners();
127
- callingClient = undefined;
128
- });
129
-
130
- /**
131
- * No input sdk config to callingClient, it should default to service type
132
- * calling and empty domain value.
133
- */
134
- it('Verify valid calling serviceData with no input sdk config', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee4() {
135
- return _regenerator.default.wrap(function _callee4$(_context4) {
136
- while (1) switch (_context4.prev = _context4.next) {
137
- case 0:
138
- expect(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee3() {
139
- return _regenerator.default.wrap(function _callee3$(_context3) {
140
- while (1) switch (_context3.prev = _context3.next) {
141
- case 0:
142
- _context3.next = 2;
143
- return (0, _CallingClient.createClient)(webex);
144
- case 2:
145
- callingClient = _context3.sent;
146
- expect(callingClient).toBeTruthy();
147
- case 4:
148
- case "end":
149
- return _context3.stop();
150
- }
151
- }, _callee3);
152
- }))).not.toThrow(Error);
153
- case 1:
154
- case "end":
155
- return _context4.stop();
156
- }
157
- }, _callee4);
158
- })));
159
-
160
- /**
161
- * Input sdk config to callingClient with serviceData carrying empty string for
162
- * both indicator and domain in it.
163
- *
164
- * It should default to service type calling and empty domain value.
165
- *
166
- */
167
- it('Verify invalid empty service indicator, empty domain', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee6() {
168
- var serviceDataObj;
169
- return _regenerator.default.wrap(function _callee6$(_context6) {
170
- while (1) switch (_context6.prev = _context6.next) {
171
- case 0:
172
- /* eslint-disable @typescript-eslint/no-explicit-any */
173
- serviceDataObj = {
174
- indicator: '',
175
- domain: ''
176
- };
177
- expect(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee5() {
178
- return _regenerator.default.wrap(function _callee5$(_context5) {
179
- while (1) switch (_context5.prev = _context5.next) {
180
- case 0:
181
- _context5.next = 2;
182
- return (0, _CallingClient.createClient)(webex, {
183
- serviceData: serviceDataObj
184
- });
185
- case 2:
186
- callingClient = _context5.sent;
187
- expect(callingClient).toBeTruthy();
188
- case 4:
189
- case "end":
190
- return _context5.stop();
191
- }
192
- }, _callee5);
193
- }))).not.toThrow(Error);
194
- case 2:
195
- case "end":
196
- return _context6.stop();
197
- }
198
- }, _callee6);
199
- })));
200
-
201
- /**
202
- * Input sdk config to callingClient with serviceData carrying invalid value for indicator
203
- * and valid domain type string for domain field in it.
204
- *
205
- * It should throw error and abort execution as indicator value is invalid.
206
- *
207
- * INDICATOR value MUST MATCH with one of the values in ServiceIndicator enum.
208
- */
209
- it('Verify invalid service indicator, valid domain', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee7() {
210
- var serviceDataObj;
211
- return _regenerator.default.wrap(function _callee7$(_context7) {
212
- while (1) switch (_context7.prev = _context7.next) {
213
- case 0:
214
- /* eslint-disable @typescript-eslint/no-explicit-any */
215
- serviceDataObj = {
216
- indicator: 'test',
217
- domain: 'test.example.com'
218
- };
219
- _context7.prev = 1;
220
- _context7.next = 4;
221
- return (0, _CallingClient.createClient)(webex, {
222
- serviceData: serviceDataObj
223
- });
224
- case 4:
225
- callingClient = _context7.sent;
226
- _context7.next = 10;
227
- break;
228
- case 7:
229
- _context7.prev = 7;
230
- _context7.t0 = _context7["catch"](1);
231
- expect(_context7.t0.message).toEqual('Invalid service indicator, Allowed values are: calling, contactcenter and guestcalling');
232
- case 10:
233
- expect.assertions(1);
234
- case 11:
235
- case "end":
236
- return _context7.stop();
237
- }
238
- }, _callee7, null, [[1, 7]]);
239
- })));
240
-
241
- /**
242
- * Input sdk config to callingClient with serviceData carrying valid value for indicator
243
- * 'calling', but an invalid domain type string for domain field in it.
244
- *
245
- * It should throw error and abort execution as domain value is invalid.
246
- *
247
- * DOMAIN field for service type calling is allowed to be empty but if it carries a non-empty
248
- * string then it must be of valid domain type.
249
- */
250
- it('CALLING: verify invalid service domain', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee8() {
251
- var serviceDataObj;
252
- return _regenerator.default.wrap(function _callee8$(_context8) {
253
- while (1) switch (_context8.prev = _context8.next) {
254
- case 0:
255
- serviceDataObj = {
256
- indicator: _types2.ServiceIndicator.CALLING,
257
- domain: 'test'
258
- };
259
- _context8.prev = 1;
260
- _context8.next = 4;
261
- return (0, _CallingClient.createClient)(webex, {
262
- serviceData: serviceDataObj
263
- });
264
- case 4:
265
- callingClient = _context8.sent;
266
- _context8.next = 10;
267
- break;
268
- case 7:
269
- _context8.prev = 7;
270
- _context8.t0 = _context8["catch"](1);
271
- expect(_context8.t0.message).toEqual('Invalid service domain.');
272
- case 10:
273
- expect.assertions(1);
274
- case 11:
275
- case "end":
276
- return _context8.stop();
277
- }
278
- }, _callee8, null, [[1, 7]]);
279
- })));
280
-
281
- /**
282
- * Input sdk config to callingClient with serviceData carrying valid value for indicator
283
- * 'calling', and an empty string for domain field in it.
284
- *
285
- * Execution should proceed properly and createRegistration should be called with same serviceData.
286
- *
287
- * DOMAIN field for service type 'calling' is allowed to be empty.
288
- */
289
- it('CALLING: verify valid empty service domain', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee0() {
290
- var serviceDataObj;
291
- return _regenerator.default.wrap(function _callee0$(_context0) {
292
- while (1) switch (_context0.prev = _context0.next) {
293
- case 0:
294
- serviceDataObj = {
295
- indicator: _types2.ServiceIndicator.CALLING,
296
- domain: ''
297
- };
298
- expect(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee9() {
299
- return _regenerator.default.wrap(function _callee9$(_context9) {
300
- while (1) switch (_context9.prev = _context9.next) {
301
- case 0:
302
- _context9.next = 2;
303
- return (0, _CallingClient.createClient)(webex, {
304
- serviceData: serviceDataObj
305
- });
306
- case 2:
307
- callingClient = _context9.sent;
308
- expect(callingClient).toBeTruthy();
309
- case 4:
310
- case "end":
311
- return _context9.stop();
312
- }
313
- }, _callee9);
314
- }))).not.toThrow(Error);
315
- case 2:
316
- case "end":
317
- return _context0.stop();
318
- }
319
- }, _callee0);
320
- })));
321
-
322
- /**
323
- * Input sdk config to callingClient with serviceData carrying valid value for indicator
324
- * 'contactcenter', but an empty string for domain field in it.
325
- *
326
- * It should throw error and abort execution as domain value is invalid.
327
- *
328
- * DOMAIN field for service type 'contactcenter' must carry a non-empty valid domain type string.
329
- */
330
- it('ContactCenter: verify empty invalid service domain', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee1() {
331
- var serviceDataObj;
332
- return _regenerator.default.wrap(function _callee1$(_context1) {
333
- while (1) switch (_context1.prev = _context1.next) {
334
- case 0:
335
- serviceDataObj = {
336
- indicator: _types2.ServiceIndicator.CONTACT_CENTER,
337
- domain: ''
338
- };
339
- _context1.prev = 1;
340
- _context1.next = 4;
341
- return (0, _CallingClient.createClient)(webex, {
342
- serviceData: serviceDataObj
343
- });
344
- case 4:
345
- callingClient = _context1.sent;
346
- _context1.next = 10;
347
- break;
348
- case 7:
349
- _context1.prev = 7;
350
- _context1.t0 = _context1["catch"](1);
351
- expect(_context1.t0.message).toEqual('Invalid service domain.');
352
- case 10:
353
- expect.assertions(1);
354
- case 11:
355
- case "end":
356
- return _context1.stop();
357
- }
358
- }, _callee1, null, [[1, 7]]);
359
- })));
360
-
361
- /**
362
- * Input sdk config to callingClient with serviceData carrying valid value for indicator
363
- * 'contactcenter' , and a valid domain type string for domain field in it.
364
- *
365
- * Execution should proceed properly and createRegistration should be called with same serviceData.
366
- *
367
- * DOMAIN field for service type 'contactcenter' must carry a non-empty valid domain type string.
368
- */
369
- it('ContactCenter: verify valid service domain', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee11() {
370
- var serviceDataObj;
371
- return _regenerator.default.wrap(function _callee11$(_context11) {
372
- while (1) switch (_context11.prev = _context11.next) {
373
- case 0:
374
- serviceDataObj = {
375
- indicator: _types2.ServiceIndicator.CONTACT_CENTER,
376
- domain: 'test.example.com'
377
- };
378
- expect(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee10() {
379
- return _regenerator.default.wrap(function _callee10$(_context10) {
380
- while (1) switch (_context10.prev = _context10.next) {
381
- case 0:
382
- _context10.next = 2;
383
- return (0, _CallingClient.createClient)(webex, {
384
- serviceData: serviceDataObj
385
- });
386
- case 2:
387
- callingClient = _context10.sent;
388
- expect(callingClient).toBeTruthy();
389
- case 4:
390
- case "end":
391
- return _context10.stop();
392
- }
393
- }, _callee10);
394
- }))).not.toThrow(Error);
395
- case 2:
396
- case "end":
397
- return _context11.stop();
398
- }
399
- }, _callee11);
400
- })));
401
- it('Get current log level', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee12() {
402
- return _regenerator.default.wrap(function _callee12$(_context12) {
403
- while (1) switch (_context12.prev = _context12.next) {
404
- case 0:
405
- _context12.next = 2;
406
- return (0, _CallingClient.createClient)(webex, {
407
- logger: {
408
- level: _types.LOGGER.INFO
409
- }
410
- });
411
- case 2:
412
- callingClient = _context12.sent;
413
- expect(callingClient).toBeTruthy();
414
- expect(callingClient.getLoggingLevel).toBeTruthy();
415
- expect(callingClient.getLoggingLevel()).toEqual(_types.LOGGER.INFO);
416
- case 6:
417
- case "end":
418
- return _context12.stop();
419
- }
420
- }, _callee12);
421
- })));
422
- });
423
- describe('Mobius Server discovery tests', function () {
424
- var callingClient;
425
- afterEach(function () {
426
- jest.clearAllTimers();
427
- jest.clearAllMocks();
428
- callingClient.removeAllListeners();
429
- callManager.removeAllListeners();
430
- callingClient = undefined;
431
- jest.useRealTimers();
432
- });
433
- it('verify successful mobius server url discovery', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee13() {
434
- return _regenerator.default.wrap(function _callee13$(_context13) {
435
- while (1) switch (_context13.prev = _context13.next) {
436
- case 0:
437
- webex.request.mockResolvedValueOnce(_callingClientFixtures.ipPayload).mockResolvedValueOnce(_callingClientFixtures.regionPayload).mockResolvedValueOnce(_callingClientFixtures.discoveryPayload);
438
- _context13.next = 3;
439
- return (0, _CallingClient.createClient)(webex, {
440
- logger: {
441
- level: _types.LOGGER.INFO
442
- }
443
- });
444
- case 3:
445
- callingClient = _context13.sent;
446
- expect(webex.request).toBeCalledTimes(3);
447
- expect(callingClient.primaryMobiusUris).toEqual([_callingClientFixtures.primaryUrl]);
448
- expect(handleErrorSpy).not.toBeCalled();
449
- expect(webex.request).nthCalledWith(1, _objectSpread(_objectSpread({
450
- method: 'GET'
451
- }, (0, _testUtil.getMockRequestTemplate)()), {}, {
452
- uri: "".concat(callingClient['mobiusHost']).concat(_constants.URL_ENDPOINT).concat(_constants.IP_ENDPOINT)
453
- }));
454
- expect(webex.request).nthCalledWith(2, {
455
- method: 'GET',
456
- uri: "".concat(_constants.DISCOVERY_URL, "/").concat(_callingClientFixtures.myIP),
457
- addAuthHeader: false,
458
- headers: (0, _defineProperty2.default)({}, _constants.SPARK_USER_AGENT, null)
459
- });
460
- expect(webex.request).nthCalledWith(3, _objectSpread(_objectSpread({
461
- method: 'GET'
462
- }, (0, _testUtil.getMockRequestTemplate)()), {}, {
463
- uri: "".concat(callingClient['mobiusHost']).concat(_constants.URL_ENDPOINT, "?regionCode=").concat(_callingClientFixtures.regionBody.clientRegion, "&countryCode=").concat(_callingClientFixtures.regionBody.countryCode)
464
- }));
465
- case 10:
466
- case "end":
467
- return _context13.stop();
468
- }
469
- }, _callee13);
470
- })));
471
- it('case when region discovery fails', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee14() {
472
- var failurePayload;
473
- return _regenerator.default.wrap(function _callee14$(_context14) {
474
- while (1) switch (_context14.prev = _context14.next) {
475
- case 0:
476
- failurePayload = {
477
- statusCode: 500
478
- };
479
- webex.request.mockRejectedValue(failurePayload);
480
- _context14.next = 4;
481
- return (0, _CallingClient.createClient)(webex, {
482
- logger: {
483
- level: _types.LOGGER.INFO
484
- }
485
- });
486
- case 4:
487
- callingClient = _context14.sent;
488
- expect(webex.request).nthCalledWith(1, _objectSpread(_objectSpread({}, (0, _testUtil.getMockRequestTemplate)()), {}, {
489
- uri: 'https://mobius-us-east-1.prod.infra.webex.com/api/v1/calling/web/myip',
490
- method: 'GET'
491
- }));
492
- expect(webex.request).nthCalledWith(2, _objectSpread(_objectSpread({}, (0, _testUtil.getMockRequestTemplate)()), {}, {
493
- uri: 'https://mobius-ca-central-1.prod.infra.webex.com/api/v1/calling/web/myip',
494
- method: 'GET'
495
- }));
496
- expect(webex.request).nthCalledWith(3, _objectSpread(_objectSpread({}, (0, _testUtil.getMockRequestTemplate)()), {}, {
497
- uri: 'https://mobius-eu-central-1.prod.infra.webex.com/api/v1/calling/web/myip',
498
- method: 'GET'
499
- }));
500
- expect(webex.request).nthCalledWith(4, _objectSpread(_objectSpread({}, (0, _testUtil.getMockRequestTemplate)()), {}, {
501
- uri: 'https://mobius-ap-southeast-2.prod.infra.webex.com/api/v1/calling/web/myip',
502
- method: 'GET'
503
- }));
504
- expect(handleErrorSpy).toBeCalledWith(failurePayload, expect.anything(), {
505
- file: _constants.CALLING_CLIENT_FILE,
506
- method: 'getMobiusServers'
507
- });
508
- expect(callingClient.primaryMobiusUris).toEqual(["".concat(callingClient['mobiusHost']).concat(_constants.URL_ENDPOINT)]);
509
- expect(warnSpy).toBeCalledWith("Couldn't resolve the region and country code. Defaulting to the catalog entries to discover mobius servers", expect.objectContaining({
510
- file: _constants.CALLING_CLIENT_FILE,
511
- method: 'getMobiusServers'
512
- }));
513
- case 12:
514
- case "end":
515
- return _context14.stop();
516
- }
517
- }, _callee14);
518
- })));
519
- it('case when /myIP failed with 401', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee15() {
520
- var failurePayload;
521
- return _regenerator.default.wrap(function _callee15$(_context15) {
522
- while (1) switch (_context15.prev = _context15.next) {
523
- case 0:
524
- failurePayload = {
525
- statusCode: 401
526
- };
527
- webex.request.mockRejectedValueOnce(failurePayload);
528
- _context15.next = 4;
529
- return (0, _CallingClient.createClient)(webex, {
530
- logger: {
531
- level: _types.LOGGER.INFO
532
- }
533
- });
534
- case 4:
535
- callingClient = _context15.sent;
536
- expect(webex.request).toBeCalledOnceWith(_objectSpread(_objectSpread({}, (0, _testUtil.getMockRequestTemplate)()), {}, {
537
- uri: 'https://mobius-us-east-1.prod.infra.webex.com/api/v1/calling/web/myip',
538
- method: 'GET'
539
- }));
540
- expect(handleErrorSpy).toBeCalledOnceWith(failurePayload, expect.anything(), {
541
- file: _constants.CALLING_CLIENT_FILE,
542
- method: 'getMobiusServers'
543
- });
544
- expect(callingClient.primaryMobiusUris).toEqual(["".concat(callingClient['mobiusHost']).concat(_constants.URL_ENDPOINT)]);
545
- expect(warnSpy).toBeCalledWith("Couldn't resolve the region and country code. Defaulting to the catalog entries to discover mobius servers", expect.objectContaining({
546
- file: _constants.CALLING_CLIENT_FILE,
547
- method: 'getMobiusServers'
548
- }));
549
- case 9:
550
- case "end":
551
- return _context15.stop();
552
- }
553
- }, _callee15);
554
- })));
555
- it('when region discovery succeeds but region based mobius url discovery fails', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee16() {
556
- var failurePayload;
557
- return _regenerator.default.wrap(function _callee16$(_context16) {
558
- while (1) switch (_context16.prev = _context16.next) {
559
- case 0:
560
- failurePayload = {
561
- statusCode: 500
562
- };
563
- webex.request.mockResolvedValueOnce(_callingClientFixtures.ipPayload).mockResolvedValueOnce(_callingClientFixtures.regionPayload).mockRejectedValueOnce(failurePayload);
564
- _context16.next = 4;
565
- return (0, _CallingClient.createClient)(webex, {
566
- logger: {
567
- level: _types.LOGGER.INFO
568
- }
569
- });
570
- case 4:
571
- callingClient = _context16.sent;
572
- expect(handleErrorSpy).toBeCalledWith(failurePayload, expect.anything(), {
573
- file: _constants.CALLING_CLIENT_FILE,
574
- method: 'getMobiusServers'
575
- });
576
- expect(webex.request).toBeCalledTimes(3);
577
- expect(callingClient.primaryMobiusUris).toEqual(["".concat(callingClient['mobiusHost']).concat(_constants.URL_ENDPOINT)]);
578
- expect(webex.request).nthCalledWith(1, _objectSpread(_objectSpread({
579
- method: 'GET'
580
- }, (0, _testUtil.getMockRequestTemplate)()), {}, {
581
- uri: "".concat(callingClient['mobiusHost']).concat(_constants.URL_ENDPOINT).concat(_constants.IP_ENDPOINT)
582
- }));
583
- expect(webex.request).nthCalledWith(2, {
584
- method: 'GET',
585
- uri: "".concat(_constants.DISCOVERY_URL, "/").concat(_callingClientFixtures.myIP),
586
- addAuthHeader: false,
587
- headers: (0, _defineProperty2.default)({}, _constants.SPARK_USER_AGENT, null)
588
- });
589
- expect(warnSpy).toBeCalledWith("Couldn't resolve the region and country code. Defaulting to the catalog entries to discover mobius servers", expect.objectContaining({
590
- file: _constants.CALLING_CLIENT_FILE,
591
- method: 'getMobiusServers'
592
- }));
593
- case 11:
594
- case "end":
595
- return _context16.stop();
596
- }
597
- }, _callee16);
598
- })));
599
- it('case when discovery failed with 401', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee17() {
600
- var failurePayload;
601
- return _regenerator.default.wrap(function _callee17$(_context17) {
602
- while (1) switch (_context17.prev = _context17.next) {
603
- case 0:
604
- failurePayload = {
605
- statusCode: 401
606
- };
607
- webex.request.mockResolvedValueOnce(_callingClientFixtures.ipPayload).mockRejectedValueOnce(failurePayload);
608
- _context17.next = 4;
609
- return (0, _CallingClient.createClient)(webex, {
610
- logger: {
611
- level: _types.LOGGER.INFO
612
- }
613
- });
614
- case 4:
615
- callingClient = _context17.sent;
616
- expect(webex.request).toBeCalledTimes(2);
617
- expect(webex.request).nthCalledWith(1, _objectSpread(_objectSpread({}, (0, _testUtil.getMockRequestTemplate)()), {}, {
618
- uri: 'https://mobius-us-east-1.prod.infra.webex.com/api/v1/calling/web/myip',
619
- method: 'GET'
620
- }));
621
- expect(webex.request).nthCalledWith(2, {
622
- method: 'GET',
623
- uri: "".concat(_constants.DISCOVERY_URL, "/").concat(_callingClientFixtures.myIP),
624
- addAuthHeader: false,
625
- headers: (0, _defineProperty2.default)({}, _constants.SPARK_USER_AGENT, null)
626
- });
627
- expect(handleErrorSpy).toBeCalledOnceWith(failurePayload, expect.anything(), {
628
- file: _constants.CALLING_CLIENT_FILE,
629
- method: 'getMobiusServers'
630
- });
631
- expect(callingClient.primaryMobiusUris).toEqual(["".concat(callingClient['mobiusHost']).concat(_constants.URL_ENDPOINT)]);
632
- expect(warnSpy).toBeCalledWith("Couldn't resolve the region and country code. Defaulting to the catalog entries to discover mobius servers", expect.objectContaining({
633
- file: _constants.CALLING_CLIENT_FILE,
634
- method: 'getMobiusServers'
635
- }));
636
- case 11:
637
- case "end":
638
- return _context17.stop();
639
- }
640
- }, _callee17);
641
- })));
642
- it('Verify successful mobius server url discovery after initializing callingClient through a config', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee18() {
643
- return _regenerator.default.wrap(function _callee18$(_context18) {
644
- while (1) switch (_context18.prev = _context18.next) {
645
- case 0:
646
- infoSpy.mockReset();
647
- webex.request.mockResolvedValueOnce(_callingClientFixtures.discoveryPayload);
648
- _context18.next = 4;
649
- return (0, _CallingClient.createClient)(webex, {
650
- discovery: {
651
- region: 'AP-SOUTHEAST',
652
- country: 'IN'
653
- },
654
- logger: {
655
- level: _types.LOGGER.INFO
656
- }
657
- });
658
- case 4:
659
- callingClient = _context18.sent;
660
- expect(callingClient.primaryMobiusUris).toEqual([_callingClientFixtures.primaryUrl]);
661
- expect(infoSpy).toHaveBeenCalledWith(_constants2.METHOD_START_MESSAGE, {
662
- file: 'CallingClient',
663
- method: 'getMobiusServers'
664
- });
665
- expect(webex.request).toBeCalledOnceWith(_objectSpread(_objectSpread({}, (0, _testUtil.getMockRequestTemplate)()), {}, {
666
- uri: "".concat(callingClient['mobiusHost']).concat(_constants.URL_ENDPOINT, "?regionCode=").concat(_callingClientFixtures.regionBody.clientRegion, "&countryCode=").concat(_callingClientFixtures.regionBody.countryCode),
667
- method: 'GET'
668
- }));
669
- expect(handleErrorSpy).not.toHaveBeenCalled();
670
- case 9:
671
- case "end":
672
- return _context18.stop();
673
- }
674
- }, _callee18);
675
- })));
676
- });
677
- describe('Testing each cluster present withing host catalog', function () {
678
- var mobiusCluster = ['mobius-eu-central-1.prod.infra.webex.com', 'mobius-us-east-1.int.infra.webex.com', 'mobius-eu-central-1.int.infra.webex.com'];
679
- var checkCluster = /*#__PURE__*/function () {
680
- var _ref19 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee19(mockServiceHosts, mockCatalog) {
681
- var callingClient;
682
- return _regenerator.default.wrap(function _callee19$(_context19) {
683
- while (1) switch (_context19.prev = _context19.next) {
684
- case 0:
685
- webex.internal.services._hostCatalog = mockCatalog;
686
- _context19.next = 3;
687
- return (0, _CallingClient.createClient)(webex, {
688
- logger: {
689
- level: _types.LOGGER.INFO
690
- }
691
- });
692
- case 3:
693
- callingClient = _context19.sent;
694
- expect(callingClient['mobiusClusters']).toStrictEqual(mockServiceHosts);
695
- case 5:
696
- case "end":
697
- return _context19.stop();
698
- }
699
- }, _callee19);
700
- }));
701
- return function checkCluster(_x, _x2) {
702
- return _ref19.apply(this, arguments);
703
- };
704
- }();
705
- it.each(mobiusCluster)('%s', /*#__PURE__*/function () {
706
- var _ref20 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee20(clusterName) {
707
- return _regenerator.default.wrap(function _callee20$(_context20) {
708
- while (1) switch (_context20.prev = _context20.next) {
709
- case 0:
710
- _context20.t0 = clusterName;
711
- _context20.next = _context20.t0 === 'mobius-eu-central-1.prod.infra.webex.com' ? 3 : _context20.t0 === 'mobius-us-east-1.int.infra.webex.com' ? 5 : _context20.t0 === 'mobius-eu-central-1.int.infra.webex.com' ? 7 : 9;
712
- break;
713
- case 3:
714
- checkCluster(_callingClientFixtures.mockEUServiceHosts, _callingClientFixtures.mockCatalogEU);
715
- return _context20.abrupt("break", 10);
716
- case 5:
717
- checkCluster(_callingClientFixtures.mockIntServiceHosts, _callingClientFixtures.mockCatalogUSInt);
718
- return _context20.abrupt("break", 10);
719
- case 7:
720
- checkCluster(_callingClientFixtures.mockEUIntServiceHosts, _callingClientFixtures.mockCatalogEUInt);
721
- return _context20.abrupt("break", 10);
722
- case 9:
723
- return _context20.abrupt("break", 10);
724
- case 10:
725
- case "end":
726
- return _context20.stop();
727
- }
728
- }, _callee20);
729
- }));
730
- return function (_x3) {
731
- return _ref20.apply(this, arguments);
732
- };
733
- }());
734
- });
735
- describe('Line creation tests', function () {
736
- var callingClient;
737
- var line;
738
- beforeEach(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee21() {
739
- return _regenerator.default.wrap(function _callee21$(_context21) {
740
- while (1) switch (_context21.prev = _context21.next) {
741
- case 0:
742
- _context21.next = 2;
743
- return (0, _CallingClient.createClient)(webex);
744
- case 2:
745
- callingClient = _context21.sent;
746
- line = (0, _values.default)(callingClient.lineDict)[0];
747
- case 4:
748
- case "end":
749
- return _context21.stop();
750
- }
751
- }, _callee21);
752
- })));
753
- afterEach(function () {
754
- jest.clearAllTimers();
755
- jest.clearAllMocks();
756
- callingClient.removeAllListeners();
757
- callManager.removeAllListeners();
758
- callingClient = undefined;
759
- jest.useRealTimers();
760
- });
761
- it('verify line dict successfully created', function () {
762
- expect(callingClient.lineDict).toBeTruthy();
763
- expect(line).toBeTruthy();
764
- expect((0, _keys.default)(callingClient.lineDict).length).toEqual(1);
765
- });
766
- it('verify getLines response', function () {
767
- expect(callingClient.getLines).toBeTruthy();
768
- expect(callingClient.getLines()).toEqual(callingClient.lineDict);
769
- });
770
- });
771
- describe('Connectivity and Mercury event handlers', function () {
772
- var callingClient;
773
- var line;
774
- var reg;
775
- var windowEventSpy;
776
- var deRegSpy;
777
- var restoreSpy;
778
- var restartRegisterSpy;
779
- var registerSpy;
780
- var metricSpy;
781
- beforeEach(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee22() {
782
- return _regenerator.default.wrap(function _callee22$(_context22) {
783
- while (1) switch (_context22.prev = _context22.next) {
784
- case 0:
785
- jest.useFakeTimers();
786
- webex.request.mockResolvedValueOnce(_callingClientFixtures.ipPayload).mockResolvedValueOnce(_callingClientFixtures.regionPayload).mockResolvedValueOnce(_callingClientFixtures.discoveryPayload).mockResolvedValueOnce(_callingClientFixtures.registrationPayload);
787
- windowEventSpy = jest.spyOn(window, 'addEventListener');
788
- _context22.next = 5;
789
- return (0, _CallingClient.createClient)(webex, {
790
- logger: {
791
- level: _types.LOGGER.INFO
792
- }
793
- });
794
- case 5:
795
- callingClient = _context22.sent;
796
- line = (0, _values.default)(callingClient.lineDict)[0];
797
- reg = line.registration;
798
- _context22.next = 10;
799
- return line.register();
800
- case 10:
801
- deRegSpy = jest.spyOn(reg, 'deregister');
802
- restoreSpy = jest.spyOn(reg, 'restorePreviousRegistration');
803
- restartRegisterSpy = jest.spyOn(reg, 'restartRegistration');
804
- registerSpy = jest.spyOn(reg, 'attemptRegistrationWithServers');
805
- metricSpy = jest.spyOn(callingClient['metricManager'], 'submitConnectionMetrics');
806
- case 15:
807
- case "end":
808
- return _context22.stop();
809
- }
810
- }, _callee22);
811
- })));
812
- afterEach(function () {
813
- jest.clearAllTimers();
814
- jest.clearAllMocks();
815
- callingClient.removeAllListeners();
816
- callingClient['callManager'].callCollection = {};
817
- callManager.removeAllListeners();
818
- callingClient = undefined;
819
- jest.useRealTimers();
820
- });
821
- it('window offline handler sets networkDown and clears keepalive when network is unreachable', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee23() {
822
- var g, clearKeepaliveSpy, offlineCb;
823
- return _regenerator.default.wrap(function _callee23$(_context23) {
824
- while (1) switch (_context23.prev = _context23.next) {
825
- case 0:
826
- g = global;
827
- g.fetch = jest.fn().mockRejectedValueOnce(new Error('network fail'));
828
- clearKeepaliveSpy = jest.spyOn(reg, 'clearKeepaliveTimer');
829
- offlineCb = windowEventSpy.mock.calls[1][1];
830
- _context23.next = 6;
831
- return offlineCb();
832
- case 6:
833
- expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining('Network connectivity probe failed'), {
834
- file: _constants.CALLING_CLIENT_FILE,
835
- method: 'pingExternal'
836
- });
837
- expect(callingClient['isNetworkDown']).toBe(true);
838
- expect(clearKeepaliveSpy).toHaveBeenCalled();
839
- case 9:
840
- case "end":
841
- return _context23.stop();
842
- }
843
- }, _callee23);
844
- })));
845
- it('window offline handler does not clear keepalive when network is reachable', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee24() {
846
- var g, clearKeepaliveSpy, offlineCb;
847
- return _regenerator.default.wrap(function _callee24$(_context24) {
848
- while (1) switch (_context24.prev = _context24.next) {
849
- case 0:
850
- g = global;
851
- g.fetch = jest.fn().mockResolvedValueOnce({});
852
- clearKeepaliveSpy = jest.spyOn(reg, 'clearKeepaliveTimer');
853
- offlineCb = windowEventSpy.mock.calls[1][1];
854
- _context24.next = 6;
855
- return offlineCb();
856
- case 6:
857
- expect(g.fetch).toHaveBeenCalledWith('https://www.google.com/generate_204', expect.any(Object));
858
- expect(callingClient['isNetworkDown']).toBe(false);
859
- expect(clearKeepaliveSpy).not.toHaveBeenCalled();
860
- case 9:
861
- case "end":
862
- return _context24.stop();
863
- }
864
- }, _callee24);
865
- })));
866
- it('window online handler sets networkUpTimestamp and logs', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee25() {
867
- var onlineCb;
868
- return _regenerator.default.wrap(function _callee25$(_context25) {
869
- while (1) switch (_context25.prev = _context25.next) {
870
- case 0:
871
- onlineCb = windowEventSpy.mock.calls[0][1];
872
- _context25.next = 3;
873
- return onlineCb();
874
- case 3:
875
- expect(callingClient['networkUpTimestamp']).toEqual(expect.any(String));
876
- expect(infoSpy).toHaveBeenCalledWith(_constants2.METHOD_START_MESSAGE, {
877
- file: _constants.CALLING_CLIENT_FILE,
878
- method: 'handleNetworkOnline'
879
- });
880
- case 5:
881
- case "end":
882
- return _context25.stop();
883
- }
884
- }, _callee25);
885
- })));
886
- it('mercury offline submits metrics and sets timestamp', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee26() {
887
- var mercuryOfflineCb;
888
- return _regenerator.default.wrap(function _callee26$(_context26) {
889
- while (1) switch (_context26.prev = _context26.next) {
890
- case 0:
891
- mercuryOfflineCb = webex.internal.mercury.on.mock.calls[1][1];
892
- _context26.next = 3;
893
- return mercuryOfflineCb();
894
- case 3:
895
- expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining('Mercury down, waiting for connection to be up'), {
896
- file: _constants.CALLING_CLIENT_FILE,
897
- method: 'handleMercuryOffline'
898
- });
899
- expect(callingClient['mercuryDownTimestamp']).toEqual(expect.any(String));
900
- expect(metricSpy).toHaveBeenCalledWith(_types4.METRIC_EVENT.CONNECTION_ERROR, _types4.CONNECTION_ACTION.MERCURY_DOWN, _types4.METRIC_TYPE.BEHAVIORAL, expect.any(String), '');
901
- case 6:
902
- case "end":
903
- return _context26.stop();
904
- }
905
- }, _callee26);
906
- })));
907
- it('handles reconnection with no active calls after network flap, once mercury comes back up', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee27() {
908
- var handleConnectionRestoreSpy, mercuryOnlineCb;
909
- return _regenerator.default.wrap(function _callee27$(_context27) {
910
- while (1) switch (_context27.prev = _context27.next) {
911
- case 0:
912
- handleConnectionRestoreSpy = jest.spyOn(reg, 'handleConnectionRestoration');
913
- callingClient['isNetworkDown'] = true;
914
- callingClient['networkDownTimestamp'] = '2023-01-01T00:00:00.000Z';
915
- callingClient['networkUpTimestamp'] = '2023-01-01T00:01:00.000Z';
916
- mercuryOnlineCb = webex.internal.mercury.on.mock.calls[2][1];
917
- _context27.next = 7;
918
- return mercuryOnlineCb();
919
- case 7:
920
- // Run the interval once
921
- jest.advanceTimersByTime(_constants.NETWORK_FLAP_TIMEOUT + 100);
922
- _context27.next = 10;
923
- return flushPromises();
924
- case 10:
925
- expect(handleConnectionRestoreSpy).toHaveBeenCalledWith(true);
926
- expect(logSpy).toHaveBeenCalledWith('Network is up again, re-registering with Webex Calling if needed', {
927
- file: _constants.REGISTRATION_FILE,
928
- method: 'handleConnectionRestoration'
929
- });
930
- expect(deRegSpy).toHaveBeenCalledWith();
931
- expect(restoreSpy).toHaveBeenCalledWith('handleConnectionRestoration');
932
- expect(restartRegisterSpy).toHaveBeenCalledWith('handleConnectionRestoration');
933
- expect(registerSpy).toHaveBeenCalledWith('handleConnectionRestoration', [reg.getActiveMobiusUrl()]);
934
- expect(registerSpy).toHaveBeenCalledWith('handleConnectionRestoration', [_callingClientFixtures.primaryUrl]);
935
- expect(metricSpy).toHaveBeenCalledWith(_types4.METRIC_EVENT.CONNECTION_ERROR, _types4.CONNECTION_ACTION.NETWORK_FLAP, _types4.METRIC_TYPE.BEHAVIORAL, '2023-01-01T00:00:00.000Z', '2023-01-01T00:01:00.000Z');
936
- case 18:
937
- case "end":
938
- return _context27.stop();
939
- }
940
- }, _callee27);
941
- })));
942
- it('no reconnection for idle registration with no active calls after network flap, once mercury comes back up', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee28() {
943
- var handleConnectionRestoreSpy, mercuryOnlineCb;
944
- return _regenerator.default.wrap(function _callee28$(_context28) {
945
- while (1) switch (_context28.prev = _context28.next) {
946
- case 0:
947
- handleConnectionRestoreSpy = jest.spyOn(reg, 'handleConnectionRestoration');
948
- callingClient['isNetworkDown'] = true;
949
- callingClient['networkDownTimestamp'] = '2023-01-01T00:00:00.000Z';
950
- callingClient['networkUpTimestamp'] = '2023-01-01T00:01:00.000Z';
951
- reg.setStatus(_types2.RegistrationStatus.IDLE);
952
- mercuryOnlineCb = webex.internal.mercury.on.mock.calls[2][1];
953
- _context28.next = 8;
954
- return mercuryOnlineCb();
955
- case 8:
956
- // Run the interval once
957
- jest.advanceTimersByTime(_constants.NETWORK_FLAP_TIMEOUT + 100);
958
- _context28.next = 11;
959
- return flushPromises();
960
- case 11:
961
- expect(handleConnectionRestoreSpy).not.toHaveBeenCalledWith(true);
962
- expect(logSpy).not.toHaveBeenCalledWith('Network is up again, re-registering with Webex Calling if needed', {
963
- file: _constants.REGISTRATION_FILE,
964
- method: 'handleConnectionRestoration'
965
- });
966
- expect(deRegSpy).not.toHaveBeenCalledWith();
967
- expect(restoreSpy).not.toHaveBeenCalledWith('handleConnectionRestoration');
968
- expect(restartRegisterSpy).not.toHaveBeenCalledWith('handleConnectionRestoration');
969
- expect(registerSpy).not.toHaveBeenCalledWith('handleConnectionRestoration', [reg.getActiveMobiusUrl()]);
970
- expect(registerSpy).not.toHaveBeenCalledWith('handleConnectionRestoration', [_callingClientFixtures.primaryUrl]);
971
- expect(metricSpy).toHaveBeenCalledWith(_types4.METRIC_EVENT.CONNECTION_ERROR, _types4.CONNECTION_ACTION.NETWORK_FLAP, _types4.METRIC_TYPE.BEHAVIORAL, '2023-01-01T00:00:00.000Z', '2023-01-01T00:01:00.000Z');
972
- case 19:
973
- case "end":
974
- return _context28.stop();
975
- }
976
- }, _callee28);
977
- })));
978
- it('handle calls status check once mercury comes back up after a network flap', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee29() {
979
- var call, callKeepaliveSpy, deleteSpy, mercuryOnlineCb;
980
- return _regenerator.default.wrap(function _callee29$(_context29) {
981
- while (1) switch (_context29.prev = _context29.next) {
982
- case 0:
983
- callingClient['isNetworkDown'] = true;
984
- call = callingClient['callManager'].createCall();
985
- callKeepaliveSpy = jest.spyOn(call, 'postStatus').mockRejectedValueOnce(new Error('keepalive fail'));
986
- deleteSpy = jest.spyOn(call, 'delete');
987
- expect((0, _keys.default)(callingClient['callManager'].getActiveCalls()).length).toBe(1);
988
- mercuryOnlineCb = webex.internal.mercury.on.mock.calls[2][1];
989
- _context29.next = 8;
990
- return mercuryOnlineCb();
991
- case 8:
992
- expect(callKeepaliveSpy).toHaveBeenCalled();
993
- _context29.next = 11;
994
- return flushPromises();
995
- case 11:
996
- expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining('Call Keepalive failed'), {
997
- file: _constants.CALLING_CLIENT_FILE,
998
- method: 'checkCallStatus'
999
- });
1000
- expect(call['callStateMachine'].state.value).toBe('S_CALL_CLEARED');
1001
- expect(deleteSpy).toHaveBeenCalled();
1002
- expect((0, _keys.default)(reg.callManager.getActiveCalls()).length).toBe(0);
1003
- expect(metricSpy).toHaveBeenCalledWith(_types4.METRIC_EVENT.CONNECTION_ERROR, _types4.CONNECTION_ACTION.NETWORK_FLAP, _types4.METRIC_TYPE.BEHAVIORAL, expect.any(String), expect.any(String));
1004
- case 16:
1005
- case "end":
1006
- return _context29.stop();
1007
- }
1008
- }, _callee29);
1009
- })));
1010
- it('handle calls status check once mercury comes back up with stable network', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee30() {
1011
- var call, callKeepaliveSpy, deleteSpy, mercuryOnlineCb;
1012
- return _regenerator.default.wrap(function _callee30$(_context30) {
1013
- while (1) switch (_context30.prev = _context30.next) {
1014
- case 0:
1015
- call = callingClient['callManager'].createCall();
1016
- callKeepaliveSpy = jest.spyOn(call, 'postStatus').mockRejectedValueOnce(new Error('keepalive fail'));
1017
- deleteSpy = jest.spyOn(call, 'delete');
1018
- expect((0, _keys.default)(callingClient['callManager'].getActiveCalls()).length).toBe(1);
1019
- mercuryOnlineCb = webex.internal.mercury.on.mock.calls[2][1];
1020
- _context30.next = 7;
1021
- return mercuryOnlineCb();
1022
- case 7:
1023
- expect(callKeepaliveSpy).toHaveBeenCalled();
1024
- _context30.next = 10;
1025
- return flushPromises();
1026
- case 10:
1027
- expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining('Call Keepalive failed'), {
1028
- file: _constants.CALLING_CLIENT_FILE,
1029
- method: 'checkCallStatus'
1030
- });
1031
- expect(call['callStateMachine'].state.value).toBe('S_CALL_CLEARED');
1032
- expect(deleteSpy).toHaveBeenCalled();
1033
- expect((0, _keys.default)(reg.callManager.getActiveCalls()).length).toBe(0);
1034
- expect(metricSpy).toHaveBeenCalledWith(_types4.METRIC_EVENT.CONNECTION_ERROR, _types4.CONNECTION_ACTION.MERCURY_UP, _types4.METRIC_TYPE.BEHAVIORAL, expect.any(String), expect.any(String));
1035
- case 15:
1036
- case "end":
1037
- return _context30.stop();
1038
- }
1039
- }, _callee30);
1040
- })));
1041
- });
1042
-
1043
- // Calling related test cases
1044
- describe('Calling tests', function () {
1045
- var mutex = new _asyncMutex.Mutex();
1046
- var userId = webex.internal.device.userId;
1047
- var clientDeviceUri = webex.internal.device.url;
1048
- var mobiusUris = (0, _Utils.filterMobiusUris)((0, _testUtil.getMobiusDiscoveryResponse)(), _registerFixtures.URL);
1049
- var primaryMobiusUris = jest.fn(function () {
1050
- return mobiusUris.primary;
1051
- });
1052
- var backupMobiusUris = jest.fn(function () {
1053
- return mobiusUris.backup;
1054
- });
1055
- var callingClient;
1056
- var line;
1057
- beforeAll(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee31() {
1058
- var calls;
1059
- return _regenerator.default.wrap(function _callee31$(_context31) {
1060
- while (1) switch (_context31.prev = _context31.next) {
1061
- case 0:
1062
- _context31.next = 2;
1063
- return (0, _CallingClient.createClient)(webex);
1064
- case 2:
1065
- callingClient = _context31.sent;
1066
- line = new _line.default(userId, clientDeviceUri, mutex, primaryMobiusUris(), backupMobiusUris(), _types.LOGGER.INFO);
1067
- calls = (0, _values.default)(callManager.getActiveCalls());
1068
- calls.forEach(function (call) {
1069
- call.end();
1070
- });
1071
- case 6:
1072
- case "end":
1073
- return _context31.stop();
1074
- }
1075
- }, _callee31);
1076
- })));
1077
- afterAll(function () {
1078
- callingClient.removeAllListeners();
1079
- callManager.removeAllListeners();
1080
- });
1081
- it('verify calling client object', function () {
1082
- expect(callingClient.getSDKConnector().getWebex().internal.device.userId).toBe('8a67806f-fc4d-446b-a131-31e71ea5b0e9');
1083
- });
1084
- it('returns undefined when there is no connected call', function () {
1085
- line.register();
1086
- line.makeCall({
1087
- address: '123456',
1088
- type: _types2.CallType.URI
1089
- });
1090
- expect(callingClient.getConnectedCall()).toEqual(undefined);
1091
- });
1092
- it('returns the connected call', function () {
1093
- line.register();
1094
- var mockCall = line.makeCall({
1095
- address: '1234',
1096
- type: _types2.CallType.URI
1097
- });
1098
- var mockCall2 = line.makeCall({
1099
- address: '5678',
1100
- type: _types2.CallType.URI
1101
- });
1102
- // Connected call
1103
- mockCall['connected'] = true;
1104
- mockCall['earlyMedia'] = false;
1105
- mockCall['callStateMachine'].state.value = 'S_CALL_ESTABLISHED';
1106
-
1107
- // Held call
1108
- mockCall2['connected'] = true;
1109
- mockCall2['held'] = true;
1110
- mockCall2['earlyMedia'] = false;
1111
- mockCall2['callStateMachine'].state.value = 'S_CALL_HOLD';
1112
- var mockActiveCalls = {
1113
- mockCorrelationId: mockCall,
1114
- mockCorrelationId2: mockCall2
1115
- };
1116
- jest.spyOn(callManager, 'getActiveCalls').mockReturnValue(mockActiveCalls);
1117
- expect(callingClient.getConnectedCall()).toEqual(mockCall);
1118
- });
1119
- it('returns all active calls', function () {
1120
- callingClient.lineDict = {
1121
- mockDeviceId: {
1122
- lineId: 'mockLineId'
1123
- },
1124
- mockDeviceId2: {
1125
- lineId: 'mockLineId2'
1126
- }
1127
- };
1128
- var mockCall = line.makeCall({
1129
- address: '1234',
1130
- type: _types2.CallType.URI
1131
- });
1132
- var mockCall2 = line.makeCall({
1133
- address: '5678',
1134
- type: _types2.CallType.URI
1135
- });
1136
- var mockCall3 = line.makeCall({
1137
- address: '9101',
1138
- type: _types2.CallType.URI
1139
- });
1140
- mockCall.lineId = 'mockLineId';
1141
- mockCall2.lineId = 'mockLineId2';
1142
- mockCall3.lineId = 'mockLineId2';
1143
- var mockActiveCalls = {
1144
- mockCorrelationId: mockCall,
1145
- mockCorrelationId2: mockCall2,
1146
- mockCorrelationId3: mockCall3
1147
- };
1148
- jest.spyOn(callManager, 'getActiveCalls').mockReturnValue(mockActiveCalls);
1149
- expect(callingClient.getActiveCalls()).toEqual({
1150
- mockLineId: [mockCall],
1151
- mockLineId2: [mockCall2, mockCall3]
1152
- });
1153
- });
1154
- });
1155
- describe('Call Session Event test', function () {
1156
- var mockOn = webex.internal.mercury.on;
1157
- var callingClient;
1158
- beforeEach(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee32() {
1159
- return _regenerator.default.wrap(function _callee32$(_context32) {
1160
- while (1) switch (_context32.prev = _context32.next) {
1161
- case 0:
1162
- _context32.next = 2;
1163
- return (0, _CallingClient.createClient)(webex, {
1164
- logger: {
1165
- level: _types.LOGGER.INFO
1166
- }
1167
- });
1168
- case 2:
1169
- callingClient = _context32.sent;
1170
- case 3:
1171
- case "end":
1172
- return _context32.stop();
1173
- }
1174
- }, _callee32);
1175
- })));
1176
- afterEach(function () {
1177
- callingClient.removeAllListeners();
1178
- callManager.removeAllListeners();
1179
- });
1180
- it('verify the recent user session event ', function (done) {
1181
- expect.assertions(2);
1182
- callingClient.on(_types3.CALLING_CLIENT_EVENT_KEYS.USER_SESSION_INFO, function (event) {
1183
- expect(event.data).toEqual(_callRecordFixtures.MOCK_SESSION_EVENT.data);
1184
- done();
1185
- });
1186
- expect(mockOn.mock.calls[0][0]).toEqual(_types3.MOBIUS_EVENT_KEYS.CALL_SESSION_EVENT_INCLUSIVE);
1187
- var callSessionCallback = mockOn.mock.calls[0][1];
1188
- callSessionCallback(_callRecordFixtures.MOCK_SESSION_EVENT);
1189
- });
1190
- it('drop the recent user session if there is no webex calling type', function (done) {
1191
- expect.assertions(2);
1192
- callingClient.on(_types3.CALLING_CLIENT_EVENT_KEYS.USER_SESSION_INFO, function (event) {
1193
- expect(event.data.userSessions.userSessions.length).toEqual(1);
1194
- done();
1195
- });
1196
- expect(mockOn.mock.calls[0][0]).toEqual(_types3.MOBIUS_EVENT_KEYS.CALL_SESSION_EVENT_INCLUSIVE);
1197
- var callSessionCallback = mockOn.mock.calls[0][1];
1198
- callSessionCallback(_callRecordFixtures.MOCK_MULTIPLE_SESSIONS_EVENT);
1199
- });
1200
- });
1201
- describe('windowsChromiumIceWarmup', function () {
1202
- var origRTCPeerConnection;
1203
- beforeAll(function () {
1204
- var _class;
1205
- origRTCPeerConnection = global.RTCPeerConnection;
1206
- // Minimal mock for RTCPeerConnection
1207
- global.RTCPeerConnection = (_class = /*#__PURE__*/function () {
1208
- function _class() {
1209
- (0, _classCallCheck2.default)(this, _class);
1210
- (0, _defineProperty2.default)(this, "iceGatheringState", 'complete');
1211
- (0, _defineProperty2.default)(this, "localDescription", null);
1212
- (0, _defineProperty2.default)(this, "remoteDescription", null);
1213
- (0, _defineProperty2.default)(this, "onicecandidate", null);
1214
- this.constructor.instances.push(this);
1215
- }
1216
- (0, _createClass2.default)(_class, [{
1217
- key: "createDataChannel",
1218
- value: function createDataChannel() {
1219
- return {};
1220
- }
1221
- }, {
1222
- key: "addTransceiver",
1223
- value: function addTransceiver() {
1224
- return {};
1225
- }
1226
- }, {
1227
- key: "createOffer",
1228
- value: function createOffer() {
1229
- return _promise.default.resolve({
1230
- sdp: 'offer',
1231
- type: 'offer'
1232
- });
1233
- }
1234
- }, {
1235
- key: "setLocalDescription",
1236
- value: function setLocalDescription(desc) {
1237
- this.localDescription = desc;
1238
- return _promise.default.resolve();
1239
- }
1240
- }, {
1241
- key: "setRemoteDescription",
1242
- value: function setRemoteDescription(desc) {
1243
- this.remoteDescription = desc;
1244
- return _promise.default.resolve();
1245
- }
1246
- }, {
1247
- key: "createAnswer",
1248
- value: function createAnswer() {
1249
- return _promise.default.resolve({
1250
- sdp: 'answer',
1251
- type: 'answer'
1252
- });
1253
- }
1254
- }, {
1255
- key: "addIceCandidate",
1256
- value: function addIceCandidate() {
1257
- return _promise.default.resolve();
1258
- }
1259
- }, {
1260
- key: "close",
1261
- value: function close() {}
1262
- }, {
1263
- key: "addEventListener",
1264
- value: function addEventListener() {}
1265
- }, {
1266
- key: "removeEventListener",
1267
- value: function removeEventListener() {}
1268
- }]);
1269
- return _class;
1270
- }(), (0, _defineProperty2.default)(_class, "instances", []), _class);
1271
- });
1272
- afterAll(function () {
1273
- global.RTCPeerConnection = origRTCPeerConnection;
1274
- });
1275
- it('should complete without throwing', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee33() {
1276
- return _regenerator.default.wrap(function _callee33$(_context33) {
1277
- while (1) switch (_context33.prev = _context33.next) {
1278
- case 0:
1279
- _context33.next = 2;
1280
- return expect((0, _windowsChromiumIceWarmupUtils.default)({})).resolves.not.toThrow();
1281
- case 2:
1282
- case "end":
1283
- return _context33.stop();
1284
- }
1285
- }, _callee33);
1286
- })));
1287
- });
1288
- });
1289
- //# sourceMappingURL=CallingClient.test.js.map