@webex/calling 3.8.1 → 3.9.0-multi-llms.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 (193) hide show
  1. package/dist/CallHistory/CallHistory.js +51 -46
  2. package/dist/CallHistory/CallHistory.js.map +1 -1
  3. package/dist/CallHistory/CallHistory.test.js +146 -147
  4. package/dist/CallHistory/CallHistory.test.js.map +1 -1
  5. package/dist/CallHistory/callHistoryFixtures.js.map +1 -1
  6. package/dist/CallHistory/constants.js.map +1 -1
  7. package/dist/CallHistory/types.js.map +1 -1
  8. package/dist/CallSettings/CallSettings.js +8 -8
  9. package/dist/CallSettings/CallSettings.js.map +1 -1
  10. package/dist/CallSettings/CallSettings.test.js +1 -1
  11. package/dist/CallSettings/CallSettings.test.js.map +1 -1
  12. package/dist/CallSettings/UcmBackendConnector.js +12 -11
  13. package/dist/CallSettings/UcmBackendConnector.js.map +1 -1
  14. package/dist/CallSettings/UcmBackendConnector.test.js +9 -10
  15. package/dist/CallSettings/UcmBackendConnector.test.js.map +1 -1
  16. package/dist/CallSettings/WxCallBackendConnector.js +68 -61
  17. package/dist/CallSettings/WxCallBackendConnector.js.map +1 -1
  18. package/dist/CallSettings/WxCallBackendConnector.test.js +168 -102
  19. package/dist/CallSettings/WxCallBackendConnector.test.js.map +1 -1
  20. package/dist/CallSettings/constants.js.map +1 -1
  21. package/dist/CallSettings/testFixtures.js.map +1 -1
  22. package/dist/CallSettings/types.js.map +1 -1
  23. package/dist/CallingClient/CallingClient.js +530 -219
  24. package/dist/CallingClient/CallingClient.js.map +1 -1
  25. package/dist/CallingClient/CallingClient.test.js +500 -291
  26. package/dist/CallingClient/CallingClient.test.js.map +1 -1
  27. package/dist/CallingClient/callRecordFixtures.js.map +1 -1
  28. package/dist/CallingClient/calling/CallerId/index.js +2 -2
  29. package/dist/CallingClient/calling/CallerId/index.js.map +1 -1
  30. package/dist/CallingClient/calling/CallerId/index.test.js +8 -7
  31. package/dist/CallingClient/calling/CallerId/index.test.js.map +1 -1
  32. package/dist/CallingClient/calling/CallerId/types.js.map +1 -1
  33. package/dist/CallingClient/calling/call.js +369 -333
  34. package/dist/CallingClient/calling/call.js.map +1 -1
  35. package/dist/CallingClient/calling/call.test.js +411 -410
  36. package/dist/CallingClient/calling/call.test.js.map +1 -1
  37. package/dist/CallingClient/calling/callManager.js +3 -4
  38. package/dist/CallingClient/calling/callManager.js.map +1 -1
  39. package/dist/CallingClient/calling/callManager.test.js +67 -68
  40. package/dist/CallingClient/calling/callManager.test.js.map +1 -1
  41. package/dist/CallingClient/calling/index.js.map +1 -1
  42. package/dist/CallingClient/calling/types.js.map +1 -1
  43. package/dist/CallingClient/callingClientFixtures.js.map +1 -1
  44. package/dist/CallingClient/constants.js +11 -8
  45. package/dist/CallingClient/constants.js.map +1 -1
  46. package/dist/CallingClient/line/index.js +10 -11
  47. package/dist/CallingClient/line/index.js.map +1 -1
  48. package/dist/CallingClient/line/line.test.js +12 -17
  49. package/dist/CallingClient/line/line.test.js.map +1 -1
  50. package/dist/CallingClient/line/types.js.map +1 -1
  51. package/dist/CallingClient/registration/index.js.map +1 -1
  52. package/dist/CallingClient/registration/register.js +557 -442
  53. package/dist/CallingClient/registration/register.js.map +1 -1
  54. package/dist/CallingClient/registration/register.test.js +526 -395
  55. package/dist/CallingClient/registration/register.test.js.map +1 -1
  56. package/dist/CallingClient/registration/registerFixtures.js.map +1 -1
  57. package/dist/CallingClient/registration/types.js.map +1 -1
  58. package/dist/CallingClient/registration/webWorker.js +116 -0
  59. package/dist/CallingClient/registration/webWorker.js.map +1 -0
  60. package/dist/CallingClient/registration/webWorker.test.js +256 -0
  61. package/dist/CallingClient/registration/webWorker.test.js.map +1 -0
  62. package/dist/CallingClient/registration/webWorkerStr.js +15 -0
  63. package/dist/CallingClient/registration/webWorkerStr.js.map +1 -0
  64. package/dist/CallingClient/types.js.map +1 -1
  65. package/dist/CallingClient/windowsChromiumIceWarmupUtils.js +142 -0
  66. package/dist/CallingClient/windowsChromiumIceWarmupUtils.js.map +1 -0
  67. package/dist/Contacts/ContactsClient.js +244 -238
  68. package/dist/Contacts/ContactsClient.js.map +1 -1
  69. package/dist/Contacts/ContactsClient.test.js +89 -90
  70. package/dist/Contacts/ContactsClient.test.js.map +1 -1
  71. package/dist/Contacts/constants.js +2 -2
  72. package/dist/Contacts/constants.js.map +1 -1
  73. package/dist/Contacts/contactFixtures.js.map +1 -1
  74. package/dist/Contacts/types.js.map +1 -1
  75. package/dist/Errors/catalog/CallError.js +2 -2
  76. package/dist/Errors/catalog/CallError.js.map +1 -1
  77. package/dist/Errors/catalog/CallingDeviceError.js +2 -2
  78. package/dist/Errors/catalog/CallingDeviceError.js.map +1 -1
  79. package/dist/Errors/catalog/ExtendedError.js +3 -3
  80. package/dist/Errors/catalog/ExtendedError.js.map +1 -1
  81. package/dist/Errors/catalog/LineError.js +2 -2
  82. package/dist/Errors/catalog/LineError.js.map +1 -1
  83. package/dist/Errors/index.js.map +1 -1
  84. package/dist/Errors/types.js +2 -0
  85. package/dist/Errors/types.js.map +1 -1
  86. package/dist/Events/impl/index.js +2 -2
  87. package/dist/Events/impl/index.js.map +1 -1
  88. package/dist/Events/types.js.map +1 -1
  89. package/dist/Logger/index.js.map +1 -1
  90. package/dist/Logger/index.test.js.map +1 -1
  91. package/dist/Logger/types.js.map +1 -1
  92. package/dist/Metrics/index.js +175 -86
  93. package/dist/Metrics/index.js.map +1 -1
  94. package/dist/Metrics/index.test.js +70 -4
  95. package/dist/Metrics/index.test.js.map +1 -1
  96. package/dist/Metrics/types.js +15 -1
  97. package/dist/Metrics/types.js.map +1 -1
  98. package/dist/SDKConnector/index.js +0 -1
  99. package/dist/SDKConnector/index.js.map +1 -1
  100. package/dist/SDKConnector/index.test.js.map +1 -1
  101. package/dist/SDKConnector/types.js.map +1 -1
  102. package/dist/SDKConnector/utils.js.map +1 -1
  103. package/dist/SDKConnector/utils.test.js.map +1 -1
  104. package/dist/Voicemail/BroadworksBackendConnector.js +42 -39
  105. package/dist/Voicemail/BroadworksBackendConnector.js.map +1 -1
  106. package/dist/Voicemail/BroadworksBackendConnector.test.js +119 -120
  107. package/dist/Voicemail/BroadworksBackendConnector.test.js.map +1 -1
  108. package/dist/Voicemail/UcmBackendConnector.js +54 -47
  109. package/dist/Voicemail/UcmBackendConnector.js.map +1 -1
  110. package/dist/Voicemail/UcmBackendConnector.test.js +73 -74
  111. package/dist/Voicemail/UcmBackendConnector.test.js.map +1 -1
  112. package/dist/Voicemail/Voicemail.js +12 -11
  113. package/dist/Voicemail/Voicemail.js.map +1 -1
  114. package/dist/Voicemail/Voicemail.test.js +2 -2
  115. package/dist/Voicemail/Voicemail.test.js.map +1 -1
  116. package/dist/Voicemail/WxCallBackendConnector.js +78 -70
  117. package/dist/Voicemail/WxCallBackendConnector.js.map +1 -1
  118. package/dist/Voicemail/WxCallBackendConnector.test.js +184 -185
  119. package/dist/Voicemail/WxCallBackendConnector.test.js.map +1 -1
  120. package/dist/Voicemail/constants.js.map +1 -1
  121. package/dist/Voicemail/types.js.map +1 -1
  122. package/dist/Voicemail/voicemailFixture.js.map +1 -1
  123. package/dist/api.js.map +1 -1
  124. package/dist/common/Utils.js +125 -99
  125. package/dist/common/Utils.js.map +1 -1
  126. package/dist/common/Utils.test.js +283 -143
  127. package/dist/common/Utils.test.js.map +1 -1
  128. package/dist/common/constants.js.map +1 -1
  129. package/dist/common/index.js.map +1 -1
  130. package/dist/common/testUtil.js +1 -1
  131. package/dist/common/testUtil.js.map +1 -1
  132. package/dist/common/types.js +8 -1
  133. package/dist/common/types.js.map +1 -1
  134. package/dist/index.js +5 -5
  135. package/dist/index.js.map +1 -1
  136. package/dist/module/CallHistory/CallHistory.js +4 -0
  137. package/dist/module/CallSettings/UcmBackendConnector.js +1 -0
  138. package/dist/module/CallSettings/WxCallBackendConnector.js +8 -1
  139. package/dist/module/CallingClient/CallingClient.js +199 -42
  140. package/dist/module/CallingClient/calling/call.js +79 -43
  141. package/dist/module/CallingClient/constants.js +10 -6
  142. package/dist/module/CallingClient/line/index.js +3 -3
  143. package/dist/module/CallingClient/registration/register.js +111 -72
  144. package/dist/module/CallingClient/registration/webWorker.js +60 -0
  145. package/dist/module/CallingClient/registration/webWorkerStr.js +93 -0
  146. package/dist/module/CallingClient/windowsChromiumIceWarmupUtils.js +59 -0
  147. package/dist/module/Contacts/ContactsClient.js +23 -17
  148. package/dist/module/Contacts/constants.js +1 -1
  149. package/dist/module/Errors/types.js +2 -0
  150. package/dist/module/Metrics/index.js +94 -33
  151. package/dist/module/Metrics/types.js +14 -0
  152. package/dist/module/Voicemail/BroadworksBackendConnector.js +3 -0
  153. package/dist/module/Voicemail/UcmBackendConnector.js +6 -0
  154. package/dist/module/Voicemail/WxCallBackendConnector.js +8 -0
  155. package/dist/module/common/Utils.js +37 -12
  156. package/dist/module/common/types.js +7 -0
  157. package/dist/types/CallHistory/CallHistory.d.ts.map +1 -1
  158. package/dist/types/CallSettings/UcmBackendConnector.d.ts.map +1 -1
  159. package/dist/types/CallSettings/WxCallBackendConnector.d.ts.map +1 -1
  160. package/dist/types/CallSettings/types.d.ts +1 -1
  161. package/dist/types/CallSettings/types.d.ts.map +1 -1
  162. package/dist/types/CallingClient/CallingClient.d.ts +12 -1
  163. package/dist/types/CallingClient/CallingClient.d.ts.map +1 -1
  164. package/dist/types/CallingClient/calling/call.d.ts.map +1 -1
  165. package/dist/types/CallingClient/calling/types.d.ts +2 -1
  166. package/dist/types/CallingClient/calling/types.d.ts.map +1 -1
  167. package/dist/types/CallingClient/constants.d.ts +10 -6
  168. package/dist/types/CallingClient/constants.d.ts.map +1 -1
  169. package/dist/types/CallingClient/line/index.d.ts.map +1 -1
  170. package/dist/types/CallingClient/registration/register.d.ts +2 -2
  171. package/dist/types/CallingClient/registration/register.d.ts.map +1 -1
  172. package/dist/types/CallingClient/registration/types.d.ts.map +1 -1
  173. package/dist/types/CallingClient/registration/webWorker.d.ts +3 -0
  174. package/dist/types/CallingClient/registration/webWorker.d.ts.map +1 -0
  175. package/dist/types/CallingClient/registration/webWorkerStr.d.ts +3 -0
  176. package/dist/types/CallingClient/registration/webWorkerStr.d.ts.map +1 -0
  177. package/dist/types/CallingClient/windowsChromiumIceWarmupUtils.d.ts +5 -0
  178. package/dist/types/CallingClient/windowsChromiumIceWarmupUtils.d.ts.map +1 -0
  179. package/dist/types/Contacts/ContactsClient.d.ts.map +1 -1
  180. package/dist/types/Contacts/constants.d.ts +1 -1
  181. package/dist/types/Contacts/constants.d.ts.map +1 -1
  182. package/dist/types/Errors/types.d.ts +2 -0
  183. package/dist/types/Errors/types.d.ts.map +1 -1
  184. package/dist/types/Metrics/index.d.ts.map +1 -1
  185. package/dist/types/Metrics/types.d.ts +20 -4
  186. package/dist/types/Metrics/types.d.ts.map +1 -1
  187. package/dist/types/Voicemail/BroadworksBackendConnector.d.ts.map +1 -1
  188. package/dist/types/Voicemail/UcmBackendConnector.d.ts.map +1 -1
  189. package/dist/types/Voicemail/WxCallBackendConnector.d.ts.map +1 -1
  190. package/dist/types/common/Utils.d.ts.map +1 -1
  191. package/dist/types/common/types.d.ts +13 -0
  192. package/dist/types/common/types.d.ts.map +1 -1
  193. package/package.json +10 -8
@@ -10,11 +10,13 @@ var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/defi
10
10
  var _WeakMap = require("@babel/runtime-corejs2/core-js/weak-map");
11
11
  var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
12
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"));
13
17
  var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
14
18
  var _values = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/values"));
15
19
  var _keys = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/keys"));
16
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
17
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
18
20
  var _asyncMutex = require("async-mutex");
19
21
  var Media = _interopRequireWildcard(require("@webex/internal-media-core"));
20
22
  var _types = require("../Logger/types");
@@ -32,8 +34,9 @@ var _callingClientFixtures = require("./callingClientFixtures");
32
34
  var _line = _interopRequireDefault(require("./line"));
33
35
  var _registerFixtures = require("./registration/registerFixtures");
34
36
  var _constants2 = require("../common/constants");
35
- function _getRequireWildcardCache(e) { if ("function" != typeof _WeakMap) return null; var r = new _WeakMap(), t = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
36
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? _Object$getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? _Object$defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
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); }
37
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; }
38
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 */
39
42
  global.crypto = {
@@ -41,15 +44,6 @@ global.crypto = {
41
44
  return '12345678-1234-5678-1234-567812345678';
42
45
  }
43
46
  };
44
- jest.mock('../common/Utils', function () {
45
- var originalModule = jest.requireActual('../common/Utils');
46
- return _objectSpread(_objectSpread({}, originalModule), {}, {
47
- uploadLogs: jest.fn().mockImplementation(function () {
48
- return _promise.default.resolve(undefined);
49
- }),
50
- handleCallingClientErrors: jest.fn()
51
- });
52
- });
53
47
  jest.spyOn(utils, 'uploadLogs').mockResolvedValue(undefined);
54
48
  describe('CallingClient Tests', function () {
55
49
  // Common initializers
@@ -60,7 +54,8 @@ describe('CallingClient Tests', function () {
60
54
  webex.internal.services['_hostCatalog'] = _callingClientFixtures.mockCatalogUS;
61
55
  var defaultServiceIndicator = _types2.ServiceIndicator.CALLING;
62
56
  var callManager = (0, _callManager.getCallManager)(webex, defaultServiceIndicator);
63
- var logSpy = jest.spyOn(_Logger.default, 'info');
57
+ var infoSpy = jest.spyOn(_Logger.default, 'info');
58
+ var logSpy = jest.spyOn(_Logger.default, 'log');
64
59
  var warnSpy = jest.spyOn(_Logger.default, 'warn');
65
60
  var originalProcessNextTick = process.nextTick;
66
61
  function flushPromises() {
@@ -74,7 +69,7 @@ describe('CallingClient Tests', function () {
74
69
  webex.internal.services['_serviceUrls']['mobius'] = 'https://mobius.aintgen-a-1.int.infra.webex.com/api/v1';
75
70
  webex.internal.services['_hostCatalog'] = _callingClientFixtures.mockCatalogUS;
76
71
  });
77
- it('should set mobiusServiceHost correctly when URL is valid', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
72
+ it('should set mobiusServiceHost correctly when URL is valid', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee() {
78
73
  var urlSpy, callingClient;
79
74
  return _regenerator.default.wrap(function _callee$(_context) {
80
75
  while (1) switch (_context.prev = _context.next) {
@@ -101,7 +96,7 @@ describe('CallingClient Tests', function () {
101
96
  }
102
97
  }, _callee);
103
98
  })));
104
- it('should use default mobius service host when Service URL is invalid', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
99
+ it('should use default mobius service host when Service URL is invalid', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee2() {
105
100
  var callingClient;
106
101
  return _regenerator.default.wrap(function _callee2$(_context2) {
107
102
  while (1) switch (_context2.prev = _context2.next) {
@@ -136,11 +131,11 @@ describe('CallingClient Tests', function () {
136
131
  * No input sdk config to callingClient, it should default to service type
137
132
  * calling and empty domain value.
138
133
  */
139
- it('Verify valid calling serviceData with no input sdk config', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
134
+ it('Verify valid calling serviceData with no input sdk config', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee4() {
140
135
  return _regenerator.default.wrap(function _callee4$(_context4) {
141
136
  while (1) switch (_context4.prev = _context4.next) {
142
137
  case 0:
143
- expect( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
138
+ expect(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee3() {
144
139
  return _regenerator.default.wrap(function _callee3$(_context3) {
145
140
  while (1) switch (_context3.prev = _context3.next) {
146
141
  case 0:
@@ -169,7 +164,7 @@ describe('CallingClient Tests', function () {
169
164
  * It should default to service type calling and empty domain value.
170
165
  *
171
166
  */
172
- it('Verify invalid empty service indicator, empty domain', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
167
+ it('Verify invalid empty service indicator, empty domain', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee6() {
173
168
  var serviceDataObj;
174
169
  return _regenerator.default.wrap(function _callee6$(_context6) {
175
170
  while (1) switch (_context6.prev = _context6.next) {
@@ -179,7 +174,7 @@ describe('CallingClient Tests', function () {
179
174
  indicator: '',
180
175
  domain: ''
181
176
  };
182
- expect( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
177
+ expect(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee5() {
183
178
  return _regenerator.default.wrap(function _callee5$(_context5) {
184
179
  while (1) switch (_context5.prev = _context5.next) {
185
180
  case 0:
@@ -211,7 +206,7 @@ describe('CallingClient Tests', function () {
211
206
  *
212
207
  * INDICATOR value MUST MATCH with one of the values in ServiceIndicator enum.
213
208
  */
214
- it('Verify invalid service indicator, valid domain', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
209
+ it('Verify invalid service indicator, valid domain', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee7() {
215
210
  var serviceDataObj;
216
211
  return _regenerator.default.wrap(function _callee7$(_context7) {
217
212
  while (1) switch (_context7.prev = _context7.next) {
@@ -252,7 +247,7 @@ describe('CallingClient Tests', function () {
252
247
  * DOMAIN field for service type calling is allowed to be empty but if it carries a non-empty
253
248
  * string then it must be of valid domain type.
254
249
  */
255
- it('CALLING: verify invalid service domain', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
250
+ it('CALLING: verify invalid service domain', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee8() {
256
251
  var serviceDataObj;
257
252
  return _regenerator.default.wrap(function _callee8$(_context8) {
258
253
  while (1) switch (_context8.prev = _context8.next) {
@@ -291,16 +286,16 @@ describe('CallingClient Tests', function () {
291
286
  *
292
287
  * DOMAIN field for service type 'calling' is allowed to be empty.
293
288
  */
294
- it('CALLING: verify valid empty service domain', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10() {
289
+ it('CALLING: verify valid empty service domain', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee0() {
295
290
  var serviceDataObj;
296
- return _regenerator.default.wrap(function _callee10$(_context10) {
297
- while (1) switch (_context10.prev = _context10.next) {
291
+ return _regenerator.default.wrap(function _callee0$(_context0) {
292
+ while (1) switch (_context0.prev = _context0.next) {
298
293
  case 0:
299
294
  serviceDataObj = {
300
295
  indicator: _types2.ServiceIndicator.CALLING,
301
296
  domain: ''
302
297
  };
303
- expect( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9() {
298
+ expect(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee9() {
304
299
  return _regenerator.default.wrap(function _callee9$(_context9) {
305
300
  while (1) switch (_context9.prev = _context9.next) {
306
301
  case 0:
@@ -319,9 +314,9 @@ describe('CallingClient Tests', function () {
319
314
  }))).not.toThrow(Error);
320
315
  case 2:
321
316
  case "end":
322
- return _context10.stop();
317
+ return _context0.stop();
323
318
  }
324
- }, _callee10);
319
+ }, _callee0);
325
320
  })));
326
321
 
327
322
  /**
@@ -332,35 +327,35 @@ describe('CallingClient Tests', function () {
332
327
  *
333
328
  * DOMAIN field for service type 'contactcenter' must carry a non-empty valid domain type string.
334
329
  */
335
- it('ContactCenter: verify empty invalid service domain', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11() {
330
+ it('ContactCenter: verify empty invalid service domain', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee1() {
336
331
  var serviceDataObj;
337
- return _regenerator.default.wrap(function _callee11$(_context11) {
338
- while (1) switch (_context11.prev = _context11.next) {
332
+ return _regenerator.default.wrap(function _callee1$(_context1) {
333
+ while (1) switch (_context1.prev = _context1.next) {
339
334
  case 0:
340
335
  serviceDataObj = {
341
336
  indicator: _types2.ServiceIndicator.CONTACT_CENTER,
342
337
  domain: ''
343
338
  };
344
- _context11.prev = 1;
345
- _context11.next = 4;
339
+ _context1.prev = 1;
340
+ _context1.next = 4;
346
341
  return (0, _CallingClient.createClient)(webex, {
347
342
  serviceData: serviceDataObj
348
343
  });
349
344
  case 4:
350
- callingClient = _context11.sent;
351
- _context11.next = 10;
345
+ callingClient = _context1.sent;
346
+ _context1.next = 10;
352
347
  break;
353
348
  case 7:
354
- _context11.prev = 7;
355
- _context11.t0 = _context11["catch"](1);
356
- expect(_context11.t0.message).toEqual('Invalid service domain.');
349
+ _context1.prev = 7;
350
+ _context1.t0 = _context1["catch"](1);
351
+ expect(_context1.t0.message).toEqual('Invalid service domain.');
357
352
  case 10:
358
353
  expect.assertions(1);
359
354
  case 11:
360
355
  case "end":
361
- return _context11.stop();
356
+ return _context1.stop();
362
357
  }
363
- }, _callee11, null, [[1, 7]]);
358
+ }, _callee1, null, [[1, 7]]);
364
359
  })));
365
360
 
366
361
  /**
@@ -371,58 +366,58 @@ describe('CallingClient Tests', function () {
371
366
  *
372
367
  * DOMAIN field for service type 'contactcenter' must carry a non-empty valid domain type string.
373
368
  */
374
- it('ContactCenter: verify valid service domain', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13() {
369
+ it('ContactCenter: verify valid service domain', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee11() {
375
370
  var serviceDataObj;
376
- return _regenerator.default.wrap(function _callee13$(_context13) {
377
- while (1) switch (_context13.prev = _context13.next) {
371
+ return _regenerator.default.wrap(function _callee11$(_context11) {
372
+ while (1) switch (_context11.prev = _context11.next) {
378
373
  case 0:
379
374
  serviceDataObj = {
380
375
  indicator: _types2.ServiceIndicator.CONTACT_CENTER,
381
376
  domain: 'test.example.com'
382
377
  };
383
- expect( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12() {
384
- return _regenerator.default.wrap(function _callee12$(_context12) {
385
- while (1) switch (_context12.prev = _context12.next) {
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) {
386
381
  case 0:
387
- _context12.next = 2;
382
+ _context10.next = 2;
388
383
  return (0, _CallingClient.createClient)(webex, {
389
384
  serviceData: serviceDataObj
390
385
  });
391
386
  case 2:
392
- callingClient = _context12.sent;
387
+ callingClient = _context10.sent;
393
388
  expect(callingClient).toBeTruthy();
394
389
  case 4:
395
390
  case "end":
396
- return _context12.stop();
391
+ return _context10.stop();
397
392
  }
398
- }, _callee12);
393
+ }, _callee10);
399
394
  }))).not.toThrow(Error);
400
395
  case 2:
401
396
  case "end":
402
- return _context13.stop();
397
+ return _context11.stop();
403
398
  }
404
- }, _callee13);
399
+ }, _callee11);
405
400
  })));
406
- it('Get current log level', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14() {
407
- return _regenerator.default.wrap(function _callee14$(_context14) {
408
- while (1) switch (_context14.prev = _context14.next) {
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) {
409
404
  case 0:
410
- _context14.next = 2;
405
+ _context12.next = 2;
411
406
  return (0, _CallingClient.createClient)(webex, {
412
407
  logger: {
413
408
  level: _types.LOGGER.INFO
414
409
  }
415
410
  });
416
411
  case 2:
417
- callingClient = _context14.sent;
412
+ callingClient = _context12.sent;
418
413
  expect(callingClient).toBeTruthy();
419
414
  expect(callingClient.getLoggingLevel).toBeTruthy();
420
415
  expect(callingClient.getLoggingLevel()).toEqual(_types.LOGGER.INFO);
421
416
  case 6:
422
417
  case "end":
423
- return _context14.stop();
418
+ return _context12.stop();
424
419
  }
425
- }, _callee14);
420
+ }, _callee12);
426
421
  })));
427
422
  });
428
423
  describe('Mobius Server discovery tests', function () {
@@ -435,19 +430,19 @@ describe('CallingClient Tests', function () {
435
430
  callingClient = undefined;
436
431
  jest.useRealTimers();
437
432
  });
438
- it('verify successful mobius server url discovery', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15() {
439
- return _regenerator.default.wrap(function _callee15$(_context15) {
440
- while (1) switch (_context15.prev = _context15.next) {
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) {
441
436
  case 0:
442
437
  webex.request.mockResolvedValueOnce(_callingClientFixtures.ipPayload).mockResolvedValueOnce(_callingClientFixtures.regionPayload).mockResolvedValueOnce(_callingClientFixtures.discoveryPayload);
443
- _context15.next = 3;
438
+ _context13.next = 3;
444
439
  return (0, _CallingClient.createClient)(webex, {
445
440
  logger: {
446
441
  level: _types.LOGGER.INFO
447
442
  }
448
443
  });
449
444
  case 3:
450
- callingClient = _context15.sent;
445
+ callingClient = _context13.sent;
451
446
  expect(webex.request).toBeCalledTimes(3);
452
447
  expect(callingClient.primaryMobiusUris).toEqual([_callingClientFixtures.primaryUrl]);
453
448
  expect(handleErrorSpy).not.toBeCalled();
@@ -469,27 +464,27 @@ describe('CallingClient Tests', function () {
469
464
  }));
470
465
  case 10:
471
466
  case "end":
472
- return _context15.stop();
467
+ return _context13.stop();
473
468
  }
474
- }, _callee15);
469
+ }, _callee13);
475
470
  })));
476
- it('case when region discovery fails', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee16() {
471
+ it('case when region discovery fails', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee14() {
477
472
  var failurePayload;
478
- return _regenerator.default.wrap(function _callee16$(_context16) {
479
- while (1) switch (_context16.prev = _context16.next) {
473
+ return _regenerator.default.wrap(function _callee14$(_context14) {
474
+ while (1) switch (_context14.prev = _context14.next) {
480
475
  case 0:
481
476
  failurePayload = {
482
477
  statusCode: 500
483
478
  };
484
- webex.request.mockRejectedValueOnce(failurePayload);
485
- _context16.next = 4;
479
+ webex.request.mockRejectedValue(failurePayload);
480
+ _context14.next = 4;
486
481
  return (0, _CallingClient.createClient)(webex, {
487
482
  logger: {
488
483
  level: _types.LOGGER.INFO
489
484
  }
490
485
  });
491
486
  case 4:
492
- callingClient = _context16.sent;
487
+ callingClient = _context14.sent;
493
488
  expect(webex.request).nthCalledWith(1, _objectSpread(_objectSpread({}, (0, _testUtil.getMockRequestTemplate)()), {}, {
494
489
  uri: 'https://mobius-us-east-1.prod.infra.webex.com/api/v1/calling/web/myip',
495
490
  method: 'GET'
@@ -511,30 +506,69 @@ describe('CallingClient Tests', function () {
511
506
  method: 'getMobiusServers'
512
507
  });
513
508
  expect(callingClient.primaryMobiusUris).toEqual(["".concat(callingClient['mobiusHost']).concat(_constants.URL_ENDPOINT)]);
514
- expect(warnSpy).toBeCalledWith("Couldn't resolve the region and country code. Defaulting to the catalog entries to discover mobius servers", '');
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
+ }));
515
513
  case 12:
516
514
  case "end":
517
- return _context16.stop();
515
+ return _context14.stop();
518
516
  }
519
- }, _callee16);
517
+ }, _callee14);
520
518
  })));
521
- it('when region discovery succeeds but region based mobius url discovery fails', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee17() {
519
+ it('case when /myIP failed with 401', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee15() {
522
520
  var failurePayload;
523
- return _regenerator.default.wrap(function _callee17$(_context17) {
524
- while (1) switch (_context17.prev = _context17.next) {
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) {
525
559
  case 0:
526
560
  failurePayload = {
527
561
  statusCode: 500
528
562
  };
529
563
  webex.request.mockResolvedValueOnce(_callingClientFixtures.ipPayload).mockResolvedValueOnce(_callingClientFixtures.regionPayload).mockRejectedValueOnce(failurePayload);
530
- _context17.next = 4;
564
+ _context16.next = 4;
531
565
  return (0, _CallingClient.createClient)(webex, {
532
566
  logger: {
533
567
  level: _types.LOGGER.INFO
534
568
  }
535
569
  });
536
570
  case 4:
537
- callingClient = _context17.sent;
571
+ callingClient = _context16.sent;
538
572
  expect(handleErrorSpy).toBeCalledWith(failurePayload, expect.anything(), {
539
573
  file: _constants.CALLING_CLIENT_FILE,
540
574
  method: 'getMobiusServers'
@@ -552,22 +586,66 @@ describe('CallingClient Tests', function () {
552
586
  addAuthHeader: false,
553
587
  headers: (0, _defineProperty2.default)({}, _constants.SPARK_USER_AGENT, null)
554
588
  });
555
- expect(warnSpy).toBeCalledWith("Couldn't resolve the region and country code. Defaulting to the catalog entries to discover mobius servers", '');
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
+ }));
556
636
  case 11:
557
637
  case "end":
558
638
  return _context17.stop();
559
639
  }
560
640
  }, _callee17);
561
641
  })));
562
- it('Verify successful mobius server url discovery after initializing callingClient through a config', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee18() {
563
- var infoSpy;
642
+ it('Verify successful mobius server url discovery after initializing callingClient through a config', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee18() {
564
643
  return _regenerator.default.wrap(function _callee18$(_context18) {
565
644
  while (1) switch (_context18.prev = _context18.next) {
566
645
  case 0:
567
- infoSpy = jest.spyOn(_Logger.default, 'info');
568
646
  infoSpy.mockReset();
569
647
  webex.request.mockResolvedValueOnce(_callingClientFixtures.discoveryPayload);
570
- _context18.next = 5;
648
+ _context18.next = 4;
571
649
  return (0, _CallingClient.createClient)(webex, {
572
650
  discovery: {
573
651
  region: 'AP-SOUTHEAST',
@@ -577,7 +655,7 @@ describe('CallingClient Tests', function () {
577
655
  level: _types.LOGGER.INFO
578
656
  }
579
657
  });
580
- case 5:
658
+ case 4:
581
659
  callingClient = _context18.sent;
582
660
  expect(callingClient.primaryMobiusUris).toEqual([_callingClientFixtures.primaryUrl]);
583
661
  expect(infoSpy).toHaveBeenCalledWith(_constants2.METHOD_START_MESSAGE, {
@@ -589,7 +667,7 @@ describe('CallingClient Tests', function () {
589
667
  method: 'GET'
590
668
  }));
591
669
  expect(handleErrorSpy).not.toHaveBeenCalled();
592
- case 10:
670
+ case 9:
593
671
  case "end":
594
672
  return _context18.stop();
595
673
  }
@@ -599,7 +677,7 @@ describe('CallingClient Tests', function () {
599
677
  describe('Testing each cluster present withing host catalog', function () {
600
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'];
601
679
  var checkCluster = /*#__PURE__*/function () {
602
- var _ref19 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee19(mockServiceHosts, mockCatalog) {
680
+ var _ref19 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee19(mockServiceHosts, mockCatalog) {
603
681
  var callingClient;
604
682
  return _regenerator.default.wrap(function _callee19$(_context19) {
605
683
  while (1) switch (_context19.prev = _context19.next) {
@@ -625,7 +703,7 @@ describe('CallingClient Tests', function () {
625
703
  };
626
704
  }();
627
705
  it.each(mobiusCluster)('%s', /*#__PURE__*/function () {
628
- var _ref20 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee20(clusterName) {
706
+ var _ref20 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee20(clusterName) {
629
707
  return _regenerator.default.wrap(function _callee20$(_context20) {
630
708
  while (1) switch (_context20.prev = _context20.next) {
631
709
  case 0:
@@ -654,268 +732,312 @@ describe('CallingClient Tests', function () {
654
732
  };
655
733
  }());
656
734
  });
657
- describe('Network activity detection tests', function () {
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 () {
658
772
  var callingClient;
659
773
  var line;
660
774
  var reg;
661
- var restoreSpy;
662
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
775
+ var windowEventSpy;
663
776
  var deRegSpy;
777
+ var restoreSpy;
664
778
  var restartRegisterSpy;
665
779
  var registerSpy;
666
- beforeEach( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee21() {
667
- return _regenerator.default.wrap(function _callee21$(_context21) {
668
- while (1) switch (_context21.prev = _context21.next) {
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) {
669
784
  case 0:
670
785
  jest.useFakeTimers();
671
786
  webex.request.mockResolvedValueOnce(_callingClientFixtures.ipPayload).mockResolvedValueOnce(_callingClientFixtures.regionPayload).mockResolvedValueOnce(_callingClientFixtures.discoveryPayload).mockResolvedValueOnce(_callingClientFixtures.registrationPayload);
672
- _context21.next = 4;
787
+ windowEventSpy = jest.spyOn(window, 'addEventListener');
788
+ _context22.next = 5;
673
789
  return (0, _CallingClient.createClient)(webex, {
674
790
  logger: {
675
791
  level: _types.LOGGER.INFO
676
792
  }
677
793
  });
678
- case 4:
679
- callingClient = _context21.sent;
794
+ case 5:
795
+ callingClient = _context22.sent;
680
796
  line = (0, _values.default)(callingClient.lineDict)[0];
681
797
  reg = line.registration;
682
- _context21.next = 9;
798
+ _context22.next = 10;
683
799
  return line.register();
684
- case 9:
685
- deRegSpy = jest.spyOn(line.registration, 'deregister');
800
+ case 10:
801
+ deRegSpy = jest.spyOn(reg, 'deregister');
686
802
  restoreSpy = jest.spyOn(reg, 'restorePreviousRegistration');
687
803
  restartRegisterSpy = jest.spyOn(reg, 'restartRegistration');
688
804
  registerSpy = jest.spyOn(reg, 'attemptRegistrationWithServers');
689
- case 13:
805
+ metricSpy = jest.spyOn(callingClient['metricManager'], 'submitConnectionMetrics');
806
+ case 15:
690
807
  case "end":
691
- return _context21.stop();
808
+ return _context22.stop();
692
809
  }
693
- }, _callee21);
810
+ }, _callee22);
694
811
  })));
695
812
  afterEach(function () {
696
813
  jest.clearAllTimers();
697
814
  jest.clearAllMocks();
698
815
  callingClient.removeAllListeners();
816
+ callingClient['callManager'].callCollection = {};
699
817
  callManager.removeAllListeners();
700
818
  callingClient = undefined;
701
819
  jest.useRealTimers();
702
820
  });
703
- it('detect a network flap in mercury connection', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee22() {
704
- return _regenerator.default.wrap(function _callee22$(_context22) {
705
- while (1) switch (_context22.prev = _context22.next) {
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) {
706
825
  case 0:
707
- expect(line.getStatus()).toEqual(_types2.RegistrationStatus.ACTIVE);
708
-
709
- /* Set mercury connection to be down and execute a delay of 2.5 seconds */
710
- webex.internal.mercury.connected = false;
711
- jest.advanceTimersByTime(_constants.NETWORK_FLAP_TIMEOUT + 500);
712
-
713
- /* We should be detecting the network flap */
714
- expect(warnSpy).toBeCalledOnceWith('Network has flapped, waiting for mercury connection to be up', {
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'), {
715
834
  file: _constants.CALLING_CLIENT_FILE,
716
- method: _constants.NETWORK_CHANGE_DETECTION_UTIL
835
+ method: 'pingExternal'
717
836
  });
718
-
719
- /* Set mercury connection to be up and execute a delay of 2.5 seconds */
720
- webex.internal.mercury.connected = true;
721
- logSpy.mockReset();
722
- jest.advanceTimersByTime(_constants.NETWORK_FLAP_TIMEOUT + 500);
723
- _context22.next = 9;
724
- return flushPromises();
837
+ expect(callingClient['isNetworkDown']).toBe(true);
838
+ expect(clearKeepaliveSpy).toHaveBeenCalled();
725
839
  case 9:
726
- _Logger.default.info('Mercury connection is up again, re-registering with Webex Calling if needed', {
727
- file: _constants.REGISTRATION_FILE,
728
- method: 'handleConnectionRestoration'
729
- });
730
-
731
- /* We should be detecting the network recovery */
732
- expect(logSpy).toHaveBeenCalledWith('Mercury connection is up again, re-registering with Webex Calling if needed', {
733
- file: _constants.REGISTRATION_FILE,
734
- method: 'handleConnectionRestoration'
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'
735
879
  });
736
- expect(restoreSpy).toHaveBeenCalledWith('handleConnectionRestoration');
737
- expect(restartRegisterSpy).toHaveBeenCalledWith('handleConnectionRestoration');
738
- expect(webex.request).toHaveBeenCalledTimes(6);
739
- expect(registerSpy).toHaveBeenCalledWith('handleConnectionRestoration', [reg.getActiveMobiusUrl()]);
740
- expect(registerSpy).toHaveBeenCalledWith('handleConnectionRestoration', [_callingClientFixtures.primaryUrl]);
741
- case 16:
880
+ case 5:
742
881
  case "end":
743
- return _context22.stop();
882
+ return _context25.stop();
744
883
  }
745
- }, _callee22);
884
+ }, _callee25);
746
885
  })));
747
- it('Simulate a network flap with no active calls and re-verify registration: Restore Failure', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee23() {
748
- var failurePayload, mockRegistrationBody, successPayload;
749
- return _regenerator.default.wrap(function _callee23$(_context23) {
750
- while (1) switch (_context23.prev = _context23.next) {
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) {
751
890
  case 0:
752
- expect(line.getStatus()).toEqual(_types2.RegistrationStatus.ACTIVE);
753
- failurePayload = {
754
- statusCode: 500,
755
- body: ''
756
- };
757
- mockRegistrationBody = (0, _testUtil.getMockDeviceInfo)();
758
- successPayload = {
759
- statusCode: 200,
760
- body: mockRegistrationBody
761
- };
762
- webex.request.mockRejectedValueOnce(failurePayload).mockResolvedValueOnce(successPayload);
763
-
764
- /* Set mercury connection to be down and execute a delay of 2.5 seconds */
765
- webex.internal.mercury.connected = false;
766
- jest.advanceTimersByTime(_constants.NETWORK_FLAP_TIMEOUT + 500);
767
-
768
- /* We should be detecting the network flap */
769
- expect(warnSpy).toBeCalledWith('Network has flapped, waiting for mercury connection to be up', {
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'), {
770
896
  file: _constants.CALLING_CLIENT_FILE,
771
- method: _constants.NETWORK_CHANGE_DETECTION_UTIL
897
+ method: 'handleMercuryOffline'
772
898
  });
773
-
774
- /* Set mercury connection to be up and execute a delay of 2.5 seconds */
775
- webex.internal.mercury.connected = true;
776
- logSpy.mockReset();
777
- jest.advanceTimersByTime(_constants.NETWORK_FLAP_TIMEOUT + 500);
778
- _context23.next = 13;
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;
779
923
  return flushPromises();
780
- case 13:
781
- _Logger.default.info('Mercury connection is up again, re-registering with Webex Calling if needed', {
782
- file: _constants.REGISTRATION_FILE,
783
- method: 'handleConnectionRestoration'
784
- });
785
-
786
- /* We should be detecting the network recovery */
787
- expect(logSpy).toBeCalledWith('Mercury connection is up again, re-registering with Webex Calling if needed', {
924
+ case 10:
925
+ expect(handleConnectionRestoreSpy).toHaveBeenCalledWith(true);
926
+ expect(logSpy).toHaveBeenCalledWith('Network is up again, re-registering with Webex Calling if needed', {
788
927
  file: _constants.REGISTRATION_FILE,
789
928
  method: 'handleConnectionRestoration'
790
929
  });
930
+ expect(deRegSpy).toHaveBeenCalledWith();
791
931
  expect(restoreSpy).toHaveBeenCalledWith('handleConnectionRestoration');
792
932
  expect(restartRegisterSpy).toHaveBeenCalledWith('handleConnectionRestoration');
793
- expect(webex.request).toHaveBeenCalledTimes(6);
794
933
  expect(registerSpy).toHaveBeenCalledWith('handleConnectionRestoration', [reg.getActiveMobiusUrl()]);
795
934
  expect(registerSpy).toHaveBeenCalledWith('handleConnectionRestoration', [_callingClientFixtures.primaryUrl]);
796
- case 20:
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:
797
937
  case "end":
798
- return _context23.stop();
938
+ return _context27.stop();
799
939
  }
800
- }, _callee23);
940
+ }, _callee27);
801
941
  })));
802
- it('Simulate a network flap before initial registration is done', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee24() {
803
- var handleConnectionRestoreSpy;
804
- return _regenerator.default.wrap(function _callee24$(_context24) {
805
- while (1) switch (_context24.prev = _context24.next) {
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) {
806
946
  case 0:
807
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';
808
951
  reg.setStatus(_types2.RegistrationStatus.IDLE);
809
-
810
- /* Set mercury connection to be down and execute a delay of 2.5 seconds */
811
- webex.internal.mercury.connected = false;
812
- jest.advanceTimersByTime(_constants.NETWORK_FLAP_TIMEOUT + 500);
813
-
814
- /* We should be detecting the network flap */
815
- expect(warnSpy).toBeCalledOnceWith('Network has flapped, waiting for mercury connection to be up', {
816
- file: _constants.CALLING_CLIENT_FILE,
817
- method: _constants.NETWORK_CHANGE_DETECTION_UTIL
818
- });
819
-
820
- /* Set mercury connection to be up and execute a delay of 2.5 seconds */
821
- webex.internal.mercury.connected = true;
822
- jest.advanceTimersByTime(_constants.NETWORK_FLAP_TIMEOUT + 500);
823
- _context24.next = 9;
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;
824
959
  return flushPromises();
825
- case 9:
826
- /* We should be detecting the network recovery */
827
- expect(logSpy).not.toBeCalledWith('Mercury connection is up again, re-registering with Webex Calling if needed', {
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', {
828
963
  file: _constants.REGISTRATION_FILE,
829
964
  method: 'handleConnectionRestoration'
830
965
  });
831
-
832
- /*
833
- * When initial registration is not done, network flap
834
- * will not trigger de-registration/registration
835
- */
836
- expect(handleConnectionRestoreSpy).not.toBeCalledOnceWith();
837
- case 11:
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:
838
973
  case "end":
839
- return _context24.stop();
974
+ return _context28.stop();
840
975
  }
841
- }, _callee24);
976
+ }, _callee28);
842
977
  })));
843
- it('Simulate a network flap with 1 active call', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee25() {
844
- return _regenerator.default.wrap(function _callee25$(_context25) {
845
- while (1) switch (_context25.prev = _context25.next) {
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) {
846
982
  case 0:
847
- expect(line.getStatus()).toEqual(_types2.RegistrationStatus.ACTIVE);
848
-
849
- /** create a new call */
850
- reg.callManager.createCall();
851
- expect((0, _keys.default)(reg.callManager.getActiveCalls()).length).toBe(1);
852
-
853
- /* Set mercury connection to be down and execute a delay of 2.5 seconds */
854
- webex.internal.mercury.connected = false;
855
- jest.advanceTimersByTime(_constants.NETWORK_FLAP_TIMEOUT + 500);
856
- _context25.next = 7;
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;
857
994
  return flushPromises();
858
- case 7:
859
- /* We should be detecting the network flap */
860
- expect(warnSpy).not.toBeCalledOnceWith('Network has flapped, waiting for mercury connection to be up', {
995
+ case 11:
996
+ expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining('Call Keepalive failed'), {
861
997
  file: _constants.CALLING_CLIENT_FILE,
862
- method: 'handleConnectionRestoration'
863
- });
864
-
865
- /* Set mercury connection to be up and execute a delay of 2.5 seconds */
866
- webex.internal.mercury.connected = true;
867
- jest.advanceTimersByTime(_constants.NETWORK_FLAP_TIMEOUT + 500);
868
- _context25.next = 12;
869
- return flushPromises();
870
- case 12:
871
- /* We should be detecting the network recovery */
872
- expect(logSpy).not.toBeCalledOnceWith('Mercury connection is up again, re-registering with Webex Calling if needed', {
873
- file: _constants.REGISTRATION_FILE,
874
- method: 'handleConnectionRestoration'
998
+ method: 'checkCallStatus'
875
999
  });
876
- expect(registerSpy).not.toBeCalledWith(true);
877
- case 14:
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:
878
1005
  case "end":
879
- return _context25.stop();
1006
+ return _context29.stop();
880
1007
  }
881
- }, _callee25);
1008
+ }, _callee29);
882
1009
  })));
883
- });
884
- describe('Line creation tests', function () {
885
- var callingClient;
886
- var line;
887
- beforeEach( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee26() {
888
- return _regenerator.default.wrap(function _callee26$(_context26) {
889
- while (1) switch (_context26.prev = _context26.next) {
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) {
890
1014
  case 0:
891
- _context26.next = 2;
892
- return (0, _CallingClient.createClient)(webex);
893
- case 2:
894
- callingClient = _context26.sent;
895
- line = (0, _values.default)(callingClient.lineDict)[0];
896
- case 4:
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:
897
1036
  case "end":
898
- return _context26.stop();
1037
+ return _context30.stop();
899
1038
  }
900
- }, _callee26);
1039
+ }, _callee30);
901
1040
  })));
902
- afterEach(function () {
903
- jest.clearAllTimers();
904
- jest.clearAllMocks();
905
- callingClient.removeAllListeners();
906
- callManager.removeAllListeners();
907
- callingClient = undefined;
908
- jest.useRealTimers();
909
- });
910
- it('verify line dict successfully created', function () {
911
- expect(callingClient.lineDict).toBeTruthy();
912
- expect(line).toBeTruthy();
913
- expect((0, _keys.default)(callingClient.lineDict).length).toEqual(1);
914
- });
915
- it('verify getLines response', function () {
916
- expect(callingClient.getLines).toBeTruthy();
917
- expect(callingClient.getLines()).toEqual(callingClient.lineDict);
918
- });
919
1041
  });
920
1042
 
921
1043
  // Calling related test cases
@@ -932,15 +1054,15 @@ describe('CallingClient Tests', function () {
932
1054
  });
933
1055
  var callingClient;
934
1056
  var line;
935
- beforeAll( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee27() {
1057
+ beforeAll(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee31() {
936
1058
  var calls;
937
- return _regenerator.default.wrap(function _callee27$(_context27) {
938
- while (1) switch (_context27.prev = _context27.next) {
1059
+ return _regenerator.default.wrap(function _callee31$(_context31) {
1060
+ while (1) switch (_context31.prev = _context31.next) {
939
1061
  case 0:
940
- _context27.next = 2;
1062
+ _context31.next = 2;
941
1063
  return (0, _CallingClient.createClient)(webex);
942
1064
  case 2:
943
- callingClient = _context27.sent;
1065
+ callingClient = _context31.sent;
944
1066
  line = new _line.default(userId, clientDeviceUri, mutex, primaryMobiusUris(), backupMobiusUris(), _types.LOGGER.INFO);
945
1067
  calls = (0, _values.default)(callManager.getActiveCalls());
946
1068
  calls.forEach(function (call) {
@@ -948,9 +1070,9 @@ describe('CallingClient Tests', function () {
948
1070
  });
949
1071
  case 6:
950
1072
  case "end":
951
- return _context27.stop();
1073
+ return _context31.stop();
952
1074
  }
953
- }, _callee27);
1075
+ }, _callee31);
954
1076
  })));
955
1077
  afterAll(function () {
956
1078
  callingClient.removeAllListeners();
@@ -1033,23 +1155,23 @@ describe('CallingClient Tests', function () {
1033
1155
  describe('Call Session Event test', function () {
1034
1156
  var mockOn = webex.internal.mercury.on;
1035
1157
  var callingClient;
1036
- beforeEach( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee28() {
1037
- return _regenerator.default.wrap(function _callee28$(_context28) {
1038
- while (1) switch (_context28.prev = _context28.next) {
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) {
1039
1161
  case 0:
1040
- _context28.next = 2;
1162
+ _context32.next = 2;
1041
1163
  return (0, _CallingClient.createClient)(webex, {
1042
1164
  logger: {
1043
1165
  level: _types.LOGGER.INFO
1044
1166
  }
1045
1167
  });
1046
1168
  case 2:
1047
- callingClient = _context28.sent;
1169
+ callingClient = _context32.sent;
1048
1170
  case 3:
1049
1171
  case "end":
1050
- return _context28.stop();
1172
+ return _context32.stop();
1051
1173
  }
1052
- }, _callee28);
1174
+ }, _callee32);
1053
1175
  })));
1054
1176
  afterEach(function () {
1055
1177
  callingClient.removeAllListeners();
@@ -1076,5 +1198,92 @@ describe('CallingClient Tests', function () {
1076
1198
  callSessionCallback(_callRecordFixtures.MOCK_MULTIPLE_SESSIONS_EVENT);
1077
1199
  });
1078
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
+ });
1079
1288
  });
1080
1289
  //# sourceMappingURL=CallingClient.test.js.map