@webex/calling 3.8.1-web-workers-keepalive.2 → 3.9.0-multiple-llm.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 (183) 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 +491 -200
  24. package/dist/CallingClient/CallingClient.js.map +1 -1
  25. package/dist/CallingClient/CallingClient.test.js +501 -294
  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 +10 -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 +10 -9
  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 +321 -232
  53. package/dist/CallingClient/registration/register.js.map +1 -1
  54. package/dist/CallingClient/registration/register.test.js +242 -160
  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 +5 -4
  59. package/dist/CallingClient/registration/webWorker.js.map +1 -1
  60. package/dist/CallingClient/registration/webWorker.test.js +14 -14
  61. package/dist/CallingClient/registration/webWorker.test.js.map +1 -1
  62. package/dist/CallingClient/registration/webWorkerStr.js.map +1 -1
  63. package/dist/CallingClient/types.js.map +1 -1
  64. package/dist/CallingClient/windowsChromiumIceWarmupUtils.js +142 -0
  65. package/dist/CallingClient/windowsChromiumIceWarmupUtils.js.map +1 -0
  66. package/dist/Contacts/ContactsClient.js +244 -238
  67. package/dist/Contacts/ContactsClient.js.map +1 -1
  68. package/dist/Contacts/ContactsClient.test.js +89 -90
  69. package/dist/Contacts/ContactsClient.test.js.map +1 -1
  70. package/dist/Contacts/constants.js +2 -2
  71. package/dist/Contacts/constants.js.map +1 -1
  72. package/dist/Contacts/contactFixtures.js.map +1 -1
  73. package/dist/Contacts/types.js.map +1 -1
  74. package/dist/Errors/catalog/CallError.js +2 -2
  75. package/dist/Errors/catalog/CallError.js.map +1 -1
  76. package/dist/Errors/catalog/CallingDeviceError.js +2 -2
  77. package/dist/Errors/catalog/CallingDeviceError.js.map +1 -1
  78. package/dist/Errors/catalog/ExtendedError.js +3 -3
  79. package/dist/Errors/catalog/ExtendedError.js.map +1 -1
  80. package/dist/Errors/catalog/LineError.js +2 -2
  81. package/dist/Errors/catalog/LineError.js.map +1 -1
  82. package/dist/Errors/index.js.map +1 -1
  83. package/dist/Errors/types.js.map +1 -1
  84. package/dist/Events/impl/index.js +2 -2
  85. package/dist/Events/impl/index.js.map +1 -1
  86. package/dist/Events/types.js.map +1 -1
  87. package/dist/Logger/index.js.map +1 -1
  88. package/dist/Logger/index.test.js.map +1 -1
  89. package/dist/Logger/types.js.map +1 -1
  90. package/dist/Metrics/index.js +166 -84
  91. package/dist/Metrics/index.js.map +1 -1
  92. package/dist/Metrics/index.test.js +60 -0
  93. package/dist/Metrics/index.test.js.map +1 -1
  94. package/dist/Metrics/types.js +15 -1
  95. package/dist/Metrics/types.js.map +1 -1
  96. package/dist/SDKConnector/index.js +0 -1
  97. package/dist/SDKConnector/index.js.map +1 -1
  98. package/dist/SDKConnector/index.test.js.map +1 -1
  99. package/dist/SDKConnector/types.js.map +1 -1
  100. package/dist/SDKConnector/utils.js.map +1 -1
  101. package/dist/SDKConnector/utils.test.js.map +1 -1
  102. package/dist/Voicemail/BroadworksBackendConnector.js +42 -39
  103. package/dist/Voicemail/BroadworksBackendConnector.js.map +1 -1
  104. package/dist/Voicemail/BroadworksBackendConnector.test.js +119 -120
  105. package/dist/Voicemail/BroadworksBackendConnector.test.js.map +1 -1
  106. package/dist/Voicemail/UcmBackendConnector.js +54 -47
  107. package/dist/Voicemail/UcmBackendConnector.js.map +1 -1
  108. package/dist/Voicemail/UcmBackendConnector.test.js +73 -74
  109. package/dist/Voicemail/UcmBackendConnector.test.js.map +1 -1
  110. package/dist/Voicemail/Voicemail.js +12 -11
  111. package/dist/Voicemail/Voicemail.js.map +1 -1
  112. package/dist/Voicemail/Voicemail.test.js +2 -2
  113. package/dist/Voicemail/Voicemail.test.js.map +1 -1
  114. package/dist/Voicemail/WxCallBackendConnector.js +78 -70
  115. package/dist/Voicemail/WxCallBackendConnector.js.map +1 -1
  116. package/dist/Voicemail/WxCallBackendConnector.test.js +184 -185
  117. package/dist/Voicemail/WxCallBackendConnector.test.js.map +1 -1
  118. package/dist/Voicemail/constants.js.map +1 -1
  119. package/dist/Voicemail/types.js.map +1 -1
  120. package/dist/Voicemail/voicemailFixture.js.map +1 -1
  121. package/dist/api.js.map +1 -1
  122. package/dist/common/Utils.js +97 -72
  123. package/dist/common/Utils.js.map +1 -1
  124. package/dist/common/Utils.test.js +283 -143
  125. package/dist/common/Utils.test.js.map +1 -1
  126. package/dist/common/constants.js.map +1 -1
  127. package/dist/common/index.js.map +1 -1
  128. package/dist/common/testUtil.js +1 -1
  129. package/dist/common/testUtil.js.map +1 -1
  130. package/dist/common/types.js.map +1 -1
  131. package/dist/index.js +5 -5
  132. package/dist/index.js.map +1 -1
  133. package/dist/module/CallHistory/CallHistory.js +4 -0
  134. package/dist/module/CallSettings/UcmBackendConnector.js +1 -0
  135. package/dist/module/CallSettings/WxCallBackendConnector.js +8 -1
  136. package/dist/module/CallingClient/CallingClient.js +197 -40
  137. package/dist/module/CallingClient/calling/call.js +79 -43
  138. package/dist/module/CallingClient/constants.js +9 -6
  139. package/dist/module/CallingClient/line/index.js +3 -3
  140. package/dist/module/CallingClient/registration/register.js +50 -14
  141. package/dist/module/CallingClient/registration/webWorker.js +2 -1
  142. package/dist/module/CallingClient/windowsChromiumIceWarmupUtils.js +59 -0
  143. package/dist/module/Contacts/ContactsClient.js +23 -17
  144. package/dist/module/Contacts/constants.js +1 -1
  145. package/dist/module/Metrics/index.js +86 -32
  146. package/dist/module/Metrics/types.js +14 -0
  147. package/dist/module/Voicemail/BroadworksBackendConnector.js +3 -0
  148. package/dist/module/Voicemail/UcmBackendConnector.js +6 -0
  149. package/dist/module/Voicemail/WxCallBackendConnector.js +8 -0
  150. package/dist/module/common/Utils.js +35 -11
  151. package/dist/types/CallHistory/CallHistory.d.ts.map +1 -1
  152. package/dist/types/CallSettings/UcmBackendConnector.d.ts.map +1 -1
  153. package/dist/types/CallSettings/WxCallBackendConnector.d.ts.map +1 -1
  154. package/dist/types/CallSettings/types.d.ts +1 -1
  155. package/dist/types/CallSettings/types.d.ts.map +1 -1
  156. package/dist/types/CallingClient/CallingClient.d.ts +12 -1
  157. package/dist/types/CallingClient/CallingClient.d.ts.map +1 -1
  158. package/dist/types/CallingClient/calling/call.d.ts.map +1 -1
  159. package/dist/types/CallingClient/calling/types.d.ts +2 -1
  160. package/dist/types/CallingClient/calling/types.d.ts.map +1 -1
  161. package/dist/types/CallingClient/constants.d.ts +9 -6
  162. package/dist/types/CallingClient/constants.d.ts.map +1 -1
  163. package/dist/types/CallingClient/line/index.d.ts.map +1 -1
  164. package/dist/types/CallingClient/registration/register.d.ts +1 -0
  165. package/dist/types/CallingClient/registration/register.d.ts.map +1 -1
  166. package/dist/types/CallingClient/registration/types.d.ts.map +1 -1
  167. package/dist/types/CallingClient/registration/webWorker.d.ts +2 -1
  168. package/dist/types/CallingClient/registration/webWorker.d.ts.map +1 -1
  169. package/dist/types/CallingClient/windowsChromiumIceWarmupUtils.d.ts +5 -0
  170. package/dist/types/CallingClient/windowsChromiumIceWarmupUtils.d.ts.map +1 -0
  171. package/dist/types/Contacts/ContactsClient.d.ts.map +1 -1
  172. package/dist/types/Contacts/constants.d.ts +1 -1
  173. package/dist/types/Contacts/constants.d.ts.map +1 -1
  174. package/dist/types/Metrics/index.d.ts.map +1 -1
  175. package/dist/types/Metrics/types.d.ts +18 -3
  176. package/dist/types/Metrics/types.d.ts.map +1 -1
  177. package/dist/types/Voicemail/BroadworksBackendConnector.d.ts.map +1 -1
  178. package/dist/types/Voicemail/UcmBackendConnector.d.ts.map +1 -1
  179. package/dist/types/Voicemail/WxCallBackendConnector.d.ts.map +1 -1
  180. package/dist/types/common/Utils.d.ts.map +1 -1
  181. package/dist/types/common/types.d.ts +1 -0
  182. package/dist/types/common/types.d.ts.map +1 -1
  183. package/package.json +10 -9
@@ -29,8 +29,7 @@ var _constants = require("../constants");
29
29
  var _types4 = require("../line/types");
30
30
  var _LineError = require("../../Errors/catalog/LineError");
31
31
  var _types5 = require("../../Metrics/types");
32
- 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); }
33
- 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; }
32
+ 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); }
34
33
  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; }
35
34
  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 @typescript-eslint/no-shadow */
36
35
  var webex = (0, _testUtil.getTestUtilsWebex)();
@@ -117,6 +116,7 @@ describe('Registration Tests', function () {
117
116
  var restartSpy;
118
117
  var restoreSpy;
119
118
  var postRegistrationSpy;
119
+ var deregisterSpy;
120
120
  var failoverSpy;
121
121
  var retry429Spy;
122
122
  var metricSpy;
@@ -128,6 +128,7 @@ describe('Registration Tests', function () {
128
128
  restartSpy = jest.spyOn(reg, 'restartRegistration');
129
129
  restoreSpy = jest.spyOn(reg, 'restorePreviousRegistration');
130
130
  postRegistrationSpy = jest.spyOn(reg, 'postRegistration');
131
+ deregisterSpy = jest.spyOn(reg, 'deregister');
131
132
  failoverSpy = jest.spyOn(reg, 'startFailoverTimer');
132
133
  retry429Spy = jest.spyOn(reg, 'handle429Retry');
133
134
  metricSpy = jest.spyOn(reg.metricManager, 'submitRegistrationMetric');
@@ -141,7 +142,7 @@ describe('Registration Tests', function () {
141
142
  jest.clearAllMocks();
142
143
  jest.useRealTimers();
143
144
  });
144
- it('verify successful registration', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
145
+ it('verify successful registration', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee() {
145
146
  return _regenerator.default.wrap(function _callee$(_context) {
146
147
  while (1) switch (_context.prev = _context.next) {
147
148
  case 0:
@@ -163,9 +164,9 @@ describe('Registration Tests', function () {
163
164
  expect(lineEmitter).toBeCalledWith(_types4.LINE_EVENTS.REGISTERED, _registerFixtures.mockPostResponse);
164
165
 
165
166
  // Check that log.log was called for successful registration
166
- expect(logSpy).toBeCalledWith("Registration successful for deviceId: ".concat(_registerFixtures.mockPostResponse.device.deviceId, " userId: ").concat(_registerFixtures.mockPostResponse.userId), expect.objectContaining({
167
+ expect(logSpy).toBeCalledWith("Registration successful for deviceId: ".concat(_registerFixtures.mockPostResponse.device.deviceId, " userId: ").concat(_registerFixtures.mockPostResponse.userId, " responseTrackingId: webex-js-sdk_06bafdd0-2f9b-4cd7-b438-9c0d95ecec9b_15"), expect.objectContaining({
167
168
  file: _constants.REGISTRATION_FILE,
168
- method: expect.any(String)
169
+ method: 'register'
169
170
  }));
170
171
  expect(metricSpy).toBeCalledWith(_types5.METRIC_EVENT.REGISTRATION, _types5.REG_ACTION.REGISTER, _types5.METRIC_TYPE.BEHAVIORAL, _constants.REGISTRATION_UTIL, 'PRIMARY', 'webex-js-sdk_06bafdd0-2f9b-4cd7-b438-9c0d95ecec9b_15', undefined, undefined);
171
172
  case 10:
@@ -174,7 +175,7 @@ describe('Registration Tests', function () {
174
175
  }
175
176
  }, _callee);
176
177
  })));
177
- it('verify failure registration', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
178
+ it('verify failure registration', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee2() {
178
179
  var error;
179
180
  return _regenerator.default.wrap(function _callee2$(_context2) {
180
181
  while (1) switch (_context2.prev = _context2.next) {
@@ -202,7 +203,7 @@ describe('Registration Tests', function () {
202
203
  }
203
204
  }, _callee2);
204
205
  })));
205
- it('verify failure registration 403-101', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
206
+ it('verify failure registration 403-101', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee3() {
206
207
  return _regenerator.default.wrap(function _callee3$(_context3) {
207
208
  while (1) switch (_context3.prev = _context3.next) {
208
209
  case 0:
@@ -268,7 +269,7 @@ describe('Registration Tests', function () {
268
269
  mobiusUris.backup.push(_registerFixtures.URL);
269
270
  jest.clearAllMocks();
270
271
  });
271
- it('handle 429 received during initial registration failure and first attempt with primary', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
272
+ it('handle 429 received during initial registration failure and first attempt with primary', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee4() {
272
273
  return _regenerator.default.wrap(function _callee4$(_context4) {
273
274
  while (1) switch (_context4.prev = _context4.next) {
274
275
  case 0:
@@ -330,7 +331,7 @@ describe('Registration Tests', function () {
330
331
  }
331
332
  }, _callee4);
332
333
  })));
333
- it('handle 429 received with higher retryAfter than the interval when interval with elapsedTime is already reaching threshold timer so we failover immediately', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
334
+ it('handle 429 received with higher retryAfter than the interval when interval with elapsedTime is already reaching threshold timer so we failover immediately', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee5() {
334
335
  return _regenerator.default.wrap(function _callee5$(_context5) {
335
336
  while (1) switch (_context5.prev = _context5.next) {
336
337
  case 0:
@@ -386,7 +387,7 @@ describe('Registration Tests', function () {
386
387
  }
387
388
  }, _callee5);
388
389
  })));
389
- it('handle 429 received while the last attempt for primary', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
390
+ it('handle 429 received while the last attempt for primary', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee6() {
390
391
  return _regenerator.default.wrap(function _callee6$(_context6) {
391
392
  while (1) switch (_context6.prev = _context6.next) {
392
393
  case 0:
@@ -457,7 +458,7 @@ describe('Registration Tests', function () {
457
458
  }
458
459
  }, _callee6);
459
460
  })));
460
- it('handle 429 received while failing over to backup server for CC flow', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
461
+ it('handle 429 received while failing over to backup server for CC flow', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee7() {
461
462
  return _regenerator.default.wrap(function _callee7$(_context7) {
462
463
  while (1) switch (_context7.prev = _context7.next) {
463
464
  case 0:
@@ -467,7 +468,7 @@ describe('Registration Tests', function () {
467
468
  _context7.next = 5;
468
469
  return reg.triggerRegistration();
469
470
  case 5:
470
- jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_FOR_CC_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
471
+ jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
471
472
  _context7.next = 8;
472
473
  return flushPromises();
473
474
  case 8:
@@ -506,7 +507,7 @@ describe('Registration Tests', function () {
506
507
  }
507
508
  }, _callee7);
508
509
  })));
509
- it('checking the retryAfter exceeding the threshold timers in first attempt itself', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
510
+ it('checking the retryAfter exceeding the threshold timers in first attempt itself', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee8() {
510
511
  return _regenerator.default.wrap(function _callee8$(_context8) {
511
512
  while (1) switch (_context8.prev = _context8.next) {
512
513
  case 0:
@@ -536,7 +537,7 @@ describe('Registration Tests', function () {
536
537
  }
537
538
  }, _callee8);
538
539
  })));
539
- it('checking the retryAfter exceeding the threshold timers in later attempts', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9() {
540
+ it('checking the retryAfter exceeding the threshold timers in later attempts', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee9() {
540
541
  return _regenerator.default.wrap(function _callee9$(_context9) {
541
542
  while (1) switch (_context9.prev = _context9.next) {
542
543
  case 0:
@@ -581,19 +582,19 @@ describe('Registration Tests', function () {
581
582
  })));
582
583
  });
583
584
  describe('Registration failover tests', function () {
584
- it('verify unreachable primary with reachable backup servers', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10() {
585
- return _regenerator.default.wrap(function _callee10$(_context10) {
586
- while (1) switch (_context10.prev = _context10.next) {
585
+ it('verify unreachable primary with reachable backup servers', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee0() {
586
+ return _regenerator.default.wrap(function _callee0$(_context0) {
587
+ while (1) switch (_context0.prev = _context0.next) {
587
588
  case 0:
588
589
  jest.useFakeTimers();
589
590
  // try the primary twice and register successfully with backup servers
590
591
  webex.request.mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload).mockResolvedValueOnce(successPayload);
591
592
  expect(reg.getStatus()).toEqual(_types.RegistrationStatus.IDLE);
592
- _context10.next = 5;
593
+ _context0.next = 5;
593
594
  return reg.triggerRegistration();
594
595
  case 5:
595
596
  jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
596
- _context10.next = 8;
597
+ _context0.next = 8;
597
598
  return flushPromises();
598
599
  case 8:
599
600
  expect(webex.request).toBeCalledTimes(3);
@@ -611,13 +612,13 @@ describe('Registration Tests', function () {
611
612
  expect(metricSpy).toHaveBeenNthCalledWith(3, _types5.METRIC_EVENT.REGISTRATION, _types5.REG_ACTION.REGISTER, _types5.METRIC_TYPE.BEHAVIORAL, _constants.FAILOVER_UTIL, 'BACKUP', 'webex-js-sdk_06bafdd0-2f9b-4cd7-b438-9c0d95ecec9b_15', undefined, undefined);
612
613
  case 14:
613
614
  case "end":
614
- return _context10.stop();
615
+ return _context0.stop();
615
616
  }
616
- }, _callee10);
617
+ }, _callee0);
617
618
  })));
618
- it('cc: verify unreachable primary with reachable backup server', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11() {
619
- return _regenerator.default.wrap(function _callee11$(_context11) {
620
- while (1) switch (_context11.prev = _context11.next) {
619
+ it('cc: verify unreachable primary with reachable backup server', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee1() {
620
+ return _regenerator.default.wrap(function _callee1$(_context1) {
621
+ while (1) switch (_context1.prev = _context1.next) {
621
622
  case 0:
622
623
  setupRegistration(_objectSpread(_objectSpread({}, MockServiceData), {}, {
623
624
  indicator: _types.ServiceIndicator.CONTACT_CENTER
@@ -625,11 +626,11 @@ describe('Registration Tests', function () {
625
626
  jest.useFakeTimers();
626
627
  webex.request.mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload).mockResolvedValueOnce(successPayload);
627
628
  expect(reg.getStatus()).toEqual(_types.RegistrationStatus.IDLE);
628
- _context11.next = 6;
629
+ _context1.next = 6;
629
630
  return reg.triggerRegistration();
630
631
  case 6:
631
- jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_FOR_CC_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
632
- _context11.next = 9;
632
+ jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
633
+ _context1.next = 9;
633
634
  return flushPromises();
634
635
  case 9:
635
636
  expect(webex.request).toBeCalledTimes(3);
@@ -646,27 +647,27 @@ describe('Registration Tests', function () {
646
647
  expect(reg.getActiveMobiusUrl()).toEqual(mobiusUris.backup[0]);
647
648
  case 14:
648
649
  case "end":
649
- return _context11.stop();
650
+ return _context1.stop();
650
651
  }
651
- }, _callee11);
652
+ }, _callee1);
652
653
  })));
653
- it('verify unreachable primary and backup servers', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12() {
654
- return _regenerator.default.wrap(function _callee12$(_context12) {
655
- while (1) switch (_context12.prev = _context12.next) {
654
+ it('verify unreachable primary and backup servers', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee10() {
655
+ return _regenerator.default.wrap(function _callee10$(_context10) {
656
+ while (1) switch (_context10.prev = _context10.next) {
656
657
  case 0:
657
658
  jest.useFakeTimers();
658
659
  // try the primary twice and register successfully with backup servers
659
660
  webex.request.mockRejectedValue(failurePayload);
660
661
  expect(reg.getStatus()).toEqual(_types.RegistrationStatus.IDLE);
661
- _context12.next = 5;
662
+ _context10.next = 5;
662
663
  return reg.triggerRegistration();
663
664
  case 5:
664
665
  jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
665
- _context12.next = 8;
666
+ _context10.next = 8;
666
667
  return flushPromises();
667
668
  case 8:
668
669
  jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
669
- _context12.next = 11;
670
+ _context10.next = 11;
670
671
  return flushPromises();
671
672
  case 11:
672
673
  /*
@@ -691,26 +692,29 @@ describe('Registration Tests', function () {
691
692
  expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
692
693
  case 17:
693
694
  case "end":
694
- return _context12.stop();
695
+ return _context10.stop();
695
696
  }
696
- }, _callee12);
697
+ }, _callee10);
697
698
  })));
698
699
  });
699
700
  describe('Registration failback tests', function () {
700
- beforeEach( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13() {
701
- return _regenerator.default.wrap(function _callee13$(_context13) {
702
- while (1) switch (_context13.prev = _context13.next) {
701
+ var isPrimaryActiveSpy;
702
+ beforeEach(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee11() {
703
+ return _regenerator.default.wrap(function _callee11$(_context11) {
704
+ while (1) switch (_context11.prev = _context11.next) {
703
705
  case 0:
706
+ isPrimaryActiveSpy = jest.spyOn(reg, 'isPrimaryActive');
707
+ isPrimaryActiveSpy.mockReturnValue(true);
704
708
  /* keep keepalive as active so that it wont interfere with the failback tests */
705
709
  jest.useFakeTimers();
706
710
  postRegistrationSpy.mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload).mockResolvedValueOnce(successPayload);
707
- _context13.next = 4;
711
+ _context11.next = 6;
708
712
  return reg.triggerRegistration();
709
- case 4:
713
+ case 6:
710
714
  jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
711
- _context13.next = 7;
715
+ _context11.next = 9;
712
716
  return flushPromises();
713
- case 7:
717
+ case 9:
714
718
  reg.rehomingIntervalMin = _constants.DEFAULT_REHOMING_INTERVAL_MIN;
715
719
  reg.rehomingIntervalMax = _constants.DEFAULT_REHOMING_INTERVAL_MAX;
716
720
 
@@ -720,19 +724,19 @@ describe('Registration Tests', function () {
720
724
  /* Active Url must match with the backup url as per the test */
721
725
  expect(reg.getActiveMobiusUrl()).toStrictEqual(mobiusUris.backup[0]);
722
726
  expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
723
- case 12:
727
+ case 14:
724
728
  case "end":
725
- return _context13.stop();
729
+ return _context11.stop();
726
730
  }
727
- }, _callee13);
731
+ }, _callee11);
728
732
  })));
729
733
  afterEach(function () {
730
734
  jest.clearAllTimers();
731
735
  jest.clearAllMocks();
732
736
  });
733
- it('verify 429 error with failback to primary after initial registration with backup: Restore failure', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14() {
734
- return _regenerator.default.wrap(function _callee14$(_context14) {
735
- while (1) switch (_context14.prev = _context14.next) {
737
+ it('verify 429 error with failback to primary after initial registration with backup: Restore failure', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee12() {
738
+ return _regenerator.default.wrap(function _callee12$(_context12) {
739
+ while (1) switch (_context12.prev = _context12.next) {
736
740
  case 0:
737
741
  // delete should be successful
738
742
  global.fetch = jest.fn(function () {
@@ -746,7 +750,7 @@ describe('Registration Tests', function () {
746
750
 
747
751
  /* Wait for failback to be triggered. */
748
752
  jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
749
- _context14.next = 5;
753
+ _context12.next = 5;
750
754
  return flushPromises();
751
755
  case 5:
752
756
  expect(infoSpy).toBeCalledWith("Attempting failback to primary.", {
@@ -754,7 +758,7 @@ describe('Registration Tests', function () {
754
758
  file: _constants.REGISTRATION_FILE
755
759
  });
756
760
  jest.advanceTimersByTime(10000);
757
- _context14.next = 9;
761
+ _context12.next = 9;
758
762
  return flushPromises();
759
763
  case 9:
760
764
  expect(retry429Spy).toBeCalledWith(failurePayload429Two.headers['retry-after'], 'executeFailback');
@@ -767,19 +771,19 @@ describe('Registration Tests', function () {
767
771
  expect(reg.rehomingIntervalMax).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MAX);
768
772
  case 17:
769
773
  case "end":
770
- return _context14.stop();
774
+ return _context12.stop();
771
775
  }
772
- }, _callee14);
776
+ }, _callee12);
773
777
  })));
774
- it('verify unsuccessful failback to primary after initial registration with backup: Restore failure', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15() {
775
- return _regenerator.default.wrap(function _callee15$(_context15) {
776
- while (1) switch (_context15.prev = _context15.next) {
778
+ it('verify unsuccessful failback to primary after initial registration with backup: Restore failure', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee13() {
779
+ return _regenerator.default.wrap(function _callee13$(_context13) {
780
+ while (1) switch (_context13.prev = _context13.next) {
777
781
  case 0:
778
782
  postRegistrationSpy.mockRejectedValue(failurePayload);
779
783
 
780
784
  /* Wait for failback to be triggered. */
781
785
  jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
782
- _context15.next = 4;
786
+ _context13.next = 4;
783
787
  return flushPromises();
784
788
  case 4:
785
789
  expect(infoSpy).toBeCalledWith("Attempting failback to primary.", {
@@ -794,14 +798,14 @@ describe('Registration Tests', function () {
794
798
  expect(reg.rehomingIntervalMax).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MAX);
795
799
  case 11:
796
800
  case "end":
797
- return _context15.stop();
801
+ return _context13.stop();
798
802
  }
799
- }, _callee15);
803
+ }, _callee13);
800
804
  })));
801
- it('verify unsuccessful failback to primary after initial registration with backup: Restore failure with final error', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee16() {
805
+ it('verify unsuccessful failback to primary after initial registration with backup: Restore failure with final error', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee14() {
802
806
  var finalErrorPayload;
803
- return _regenerator.default.wrap(function _callee16$(_context16) {
804
- while (1) switch (_context16.prev = _context16.next) {
807
+ return _regenerator.default.wrap(function _callee14$(_context14) {
808
+ while (1) switch (_context14.prev = _context14.next) {
805
809
  case 0:
806
810
  finalErrorPayload = {
807
811
  statusCode: 401,
@@ -811,7 +815,7 @@ describe('Registration Tests', function () {
811
815
  postRegistrationSpy.mockRejectedValue(finalErrorPayload).mockRejectedValueOnce(failurePayload);
812
816
  /* Wait for failback to be triggered. */
813
817
  jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
814
- _context16.next = 6;
818
+ _context14.next = 6;
815
819
  return flushPromises();
816
820
  case 6:
817
821
  expect(infoSpy).toBeCalledWith("Attempting failback to primary.", {
@@ -826,19 +830,19 @@ describe('Registration Tests', function () {
826
830
  expect(reg.rehomingIntervalMax).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MAX);
827
831
  case 13:
828
832
  case "end":
829
- return _context16.stop();
833
+ return _context14.stop();
830
834
  }
831
- }, _callee16);
835
+ }, _callee14);
832
836
  })));
833
- it('verify unsuccessful failback to primary after initial registration with backup: Restore success', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee17() {
834
- return _regenerator.default.wrap(function _callee17$(_context17) {
835
- while (1) switch (_context17.prev = _context17.next) {
837
+ it('verify unsuccessful failback to primary after initial registration with backup: Restore success', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee15() {
838
+ return _regenerator.default.wrap(function _callee15$(_context15) {
839
+ while (1) switch (_context15.prev = _context15.next) {
836
840
  case 0:
837
841
  postRegistrationSpy.mockRejectedValueOnce(failurePayload).mockResolvedValue(successPayload);
838
842
 
839
843
  /* Wait for failback to be triggered. */
840
844
  jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
841
- _context17.next = 4;
845
+ _context15.next = 4;
842
846
  return flushPromises();
843
847
  case 4:
844
848
  expect(infoSpy).toBeCalledWith("Attempting failback to primary.", {
@@ -854,19 +858,19 @@ describe('Registration Tests', function () {
854
858
  expect(reg.rehomingIntervalMax).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MAX);
855
859
  case 11:
856
860
  case "end":
857
- return _context17.stop();
861
+ return _context15.stop();
858
862
  }
859
- }, _callee17);
863
+ }, _callee15);
860
864
  })));
861
- it('verify successful failback to primary after initial registration with backup', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee18() {
862
- return _regenerator.default.wrap(function _callee18$(_context18) {
863
- while (1) switch (_context18.prev = _context18.next) {
865
+ it('verify successful failback to primary after initial registration with backup', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee16() {
866
+ return _regenerator.default.wrap(function _callee16$(_context16) {
867
+ while (1) switch (_context16.prev = _context16.next) {
864
868
  case 0:
865
869
  postRegistrationSpy.mockResolvedValue(successPayload);
866
870
 
867
871
  /* Wait for failback to be triggered. */
868
872
  jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
869
- _context18.next = 4;
873
+ _context16.next = 4;
870
874
  return flushPromises();
871
875
  case 4:
872
876
  expect(infoSpy).toBeCalledWith("Attempting failback to primary.", {
@@ -875,21 +879,22 @@ describe('Registration Tests', function () {
875
879
  });
876
880
 
877
881
  /* Active Url must now match with the primary url */
882
+ expect(deregisterSpy).toBeCalledOnceWith();
878
883
  expect(reg.getActiveMobiusUrl()).toStrictEqual(mobiusUris.primary[0]);
879
884
  expect(reg.getStatus()).toBe(_types.RegistrationStatus.ACTIVE);
880
885
  expect(reg.failbackTimer).toBe(undefined);
881
886
  expect(restoreSpy).not.toBeCalled();
882
887
  expect(reg.rehomingIntervalMin).toBe(_registerFixtures.mockPostResponse.rehomingIntervalMin);
883
888
  expect(reg.rehomingIntervalMax).toBe(_registerFixtures.mockPostResponse.rehomingIntervalMax);
884
- case 11:
889
+ case 12:
885
890
  case "end":
886
- return _context18.stop();
891
+ return _context16.stop();
887
892
  }
888
- }, _callee18);
893
+ }, _callee16);
889
894
  })));
890
- it('verify unsuccessful failback attempt due to active call', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee19() {
891
- return _regenerator.default.wrap(function _callee19$(_context19) {
892
- while (1) switch (_context19.prev = _context19.next) {
895
+ it('verify unsuccessful failback attempt due to active call', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee17() {
896
+ return _regenerator.default.wrap(function _callee17$(_context17) {
897
+ while (1) switch (_context17.prev = _context17.next) {
893
898
  case 0:
894
899
  /** create a new call */
895
900
  reg.callManager.createCall();
@@ -898,10 +903,10 @@ describe('Registration Tests', function () {
898
903
 
899
904
  /* Wait for failback to be triggered. */
900
905
  jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
901
- _context19.next = 6;
906
+ _context17.next = 6;
902
907
  return flushPromises();
903
908
  case 6:
904
- expect(infoSpy).toBeCalledWith("Active calls present, deferring failback to next cycle.", {
909
+ expect(infoSpy).toBeCalledWith("Active calls present or primary Mobius is down, deferring failback to next cycle.", {
905
910
  method: 'executeFailback',
906
911
  file: _constants.REGISTRATION_FILE
907
912
  });
@@ -909,44 +914,71 @@ describe('Registration Tests', function () {
909
914
  /* Active Url should still match backup url */
910
915
  expect(reg.getActiveMobiusUrl()).toStrictEqual(mobiusUris.backup[0]);
911
916
  expect(reg.getStatus()).toBe(_types.RegistrationStatus.ACTIVE);
917
+ expect(deregisterSpy).not.toBeCalled();
912
918
  expect(restoreSpy).not.toBeCalled();
913
919
  expect(restartSpy).not.toBeCalled();
914
- expect(infoSpy).toBeCalledWith('Active calls present, deferring failback to next cycle.', {
920
+ expect(infoSpy).toBeCalledWith('Active calls present or primary Mobius is down, deferring failback to next cycle.', {
915
921
  file: _constants.REGISTRATION_FILE,
916
922
  method: _constants.FAILBACK_UTIL
917
923
  });
918
924
  expect(reg.rehomingIntervalMin).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MIN);
919
925
  expect(reg.rehomingIntervalMax).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MAX);
920
- case 14:
926
+ case 15:
927
+ case "end":
928
+ return _context17.stop();
929
+ }
930
+ }, _callee17);
931
+ })));
932
+ it('verify unsuccessful failback attempt due to primary server being down', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee18() {
933
+ return _regenerator.default.wrap(function _callee18$(_context18) {
934
+ while (1) switch (_context18.prev = _context18.next) {
935
+ case 0:
936
+ isPrimaryActiveSpy.mockReturnValue(false);
937
+
938
+ /* Wait for failback to be triggered. */
939
+ jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
940
+ _context18.next = 4;
941
+ return flushPromises();
942
+ case 4:
943
+ expect(infoSpy).toBeCalledWith("Active calls present or primary Mobius is down, deferring failback to next cycle.", {
944
+ method: 'executeFailback',
945
+ file: _constants.REGISTRATION_FILE
946
+ });
947
+
948
+ /* Active Url should still match backup url */
949
+ expect(deregisterSpy).not.toBeCalled();
950
+ expect(reg.getActiveMobiusUrl()).toStrictEqual(mobiusUris.backup[0]);
951
+ expect(reg.getStatus()).toBe(_types.RegistrationStatus.ACTIVE);
952
+ case 8:
921
953
  case "end":
922
- return _context19.stop();
954
+ return _context18.stop();
923
955
  }
924
- }, _callee19);
956
+ }, _callee18);
925
957
  })));
926
958
  });
927
959
 
928
960
  // Keep-alive related test cases
929
961
  describe('Keep-alive Tests', function () {
930
962
  var beforeEachSetupForKeepalive = /*#__PURE__*/function () {
931
- var _ref20 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee20() {
932
- return _regenerator.default.wrap(function _callee20$(_context20) {
933
- while (1) switch (_context20.prev = _context20.next) {
963
+ var _ref19 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee19() {
964
+ return _regenerator.default.wrap(function _callee19$(_context19) {
965
+ while (1) switch (_context19.prev = _context19.next) {
934
966
  case 0:
935
967
  postRegistrationSpy.mockResolvedValueOnce(successPayload);
936
968
  jest.useFakeTimers();
937
- _context20.next = 4;
969
+ _context19.next = 4;
938
970
  return reg.triggerRegistration();
939
971
  case 4:
940
972
  expect(reg.getStatus()).toBe(_types.RegistrationStatus.ACTIVE);
941
973
  expect(reg.webWorker).toBeDefined();
942
974
  case 6:
943
975
  case "end":
944
- return _context20.stop();
976
+ return _context19.stop();
945
977
  }
946
- }, _callee20);
978
+ }, _callee19);
947
979
  }));
948
980
  return function beforeEachSetupForKeepalive() {
949
- return _ref20.apply(this, arguments);
981
+ return _ref19.apply(this, arguments);
950
982
  };
951
983
  }();
952
984
  afterEach(function () {
@@ -959,13 +991,13 @@ describe('Registration Tests', function () {
959
991
  call.end();
960
992
  });
961
993
  });
962
- it('verify successful keep-alive cases', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee21() {
994
+ it('verify successful keep-alive cases', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee20() {
963
995
  var postMessageSpy;
964
- return _regenerator.default.wrap(function _callee21$(_context21) {
965
- while (1) switch (_context21.prev = _context21.next) {
996
+ return _regenerator.default.wrap(function _callee20$(_context20) {
997
+ while (1) switch (_context20.prev = _context20.next) {
966
998
  case 0:
967
999
  postMessageSpy = jest.spyOn(Worker.prototype, 'postMessage');
968
- _context21.next = 3;
1000
+ _context20.next = 3;
969
1001
  return beforeEachSetupForKeepalive();
970
1002
  case 3:
971
1003
  expect(reg.webWorker).toBeDefined();
@@ -986,16 +1018,16 @@ describe('Registration Tests', function () {
986
1018
  expect(lineEmitter).toBeCalledWith(_types4.LINE_EVENTS.RECONNECTED);
987
1019
  case 7:
988
1020
  case "end":
989
- return _context21.stop();
1021
+ return _context20.stop();
990
1022
  }
991
- }, _callee21);
1023
+ }, _callee20);
992
1024
  })));
993
- it('verify failure keep-alive cases: Retry Success', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee22() {
1025
+ it('verify failure keep-alive cases: Retry Success', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee21() {
994
1026
  var worker;
995
- return _regenerator.default.wrap(function _callee22$(_context22) {
996
- while (1) switch (_context22.prev = _context22.next) {
1027
+ return _regenerator.default.wrap(function _callee21$(_context21) {
1028
+ while (1) switch (_context21.prev = _context21.next) {
997
1029
  case 0:
998
- _context22.next = 2;
1030
+ _context21.next = 2;
999
1031
  return beforeEachSetupForKeepalive();
1000
1032
  case 2:
1001
1033
  worker = reg.webWorker;
@@ -1018,16 +1050,16 @@ describe('Registration Tests', function () {
1018
1050
  expect(lineEmitter).toHaveBeenCalledWith(_types4.LINE_EVENTS.RECONNECTED);
1019
1051
  case 7:
1020
1052
  case "end":
1021
- return _context22.stop();
1053
+ return _context21.stop();
1022
1054
  }
1023
- }, _callee22);
1055
+ }, _callee21);
1024
1056
  })));
1025
- it('verify failure keep-alive cases: Restore failure', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee23() {
1057
+ it('verify failure keep-alive cases: Restore failure', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee22() {
1026
1058
  var reconnectSpy, restoreSpy, restartRegSpy, RETRY_COUNT_THRESHOLD, failureEvent;
1027
- return _regenerator.default.wrap(function _callee23$(_context23) {
1028
- while (1) switch (_context23.prev = _context23.next) {
1059
+ return _regenerator.default.wrap(function _callee22$(_context22) {
1060
+ while (1) switch (_context22.prev = _context22.next) {
1029
1061
  case 0:
1030
- _context23.next = 2;
1062
+ _context22.next = 2;
1031
1063
  return beforeEachSetupForKeepalive();
1032
1064
  case 2:
1033
1065
  reconnectSpy = jest.spyOn(reg, 'reconnectOnFailure');
@@ -1054,7 +1086,7 @@ describe('Registration Tests', function () {
1054
1086
  }
1055
1087
  };
1056
1088
  reg.webWorker.onmessage(failureEvent);
1057
- _context23.next = 14;
1089
+ _context22.next = 14;
1058
1090
  return flushPromises();
1059
1091
  case 14:
1060
1092
  expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
@@ -1069,16 +1101,16 @@ describe('Registration Tests', function () {
1069
1101
  }));
1070
1102
  case 21:
1071
1103
  case "end":
1072
- return _context23.stop();
1104
+ return _context22.stop();
1073
1105
  }
1074
- }, _callee23);
1106
+ }, _callee22);
1075
1107
  })));
1076
- it('verify failure keep-alive cases: Restore Success', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee24() {
1108
+ it('verify failure keep-alive cases: Restore Success', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee23() {
1077
1109
  var reconnectSpy, url;
1078
- return _regenerator.default.wrap(function _callee24$(_context24) {
1079
- while (1) switch (_context24.prev = _context24.next) {
1110
+ return _regenerator.default.wrap(function _callee23$(_context23) {
1111
+ while (1) switch (_context23.prev = _context23.next) {
1080
1112
  case 0:
1081
- _context24.next = 2;
1113
+ _context23.next = 2;
1082
1114
  return beforeEachSetupForKeepalive();
1083
1115
  case 2:
1084
1116
  expect(reg.webWorker).toBeDefined();
@@ -1094,16 +1126,16 @@ describe('Registration Tests', function () {
1094
1126
  }
1095
1127
  });
1096
1128
  jest.advanceTimersByTime(1000);
1097
- _context24.next = 9;
1129
+ _context23.next = 9;
1098
1130
  return flushPromises();
1099
1131
  case 9:
1100
1132
  expect(reg.webWorker).toBeUndefined();
1101
1133
  expect(reconnectSpy).toBeCalledOnceWith(reg.startKeepaliveTimer.name);
1102
1134
  webex.request.mockResolvedValueOnce(successPayload);
1103
- _context24.next = 14;
1135
+ _context23.next = 14;
1104
1136
  return reg.triggerRegistration();
1105
1137
  case 14:
1106
- _context24.next = 16;
1138
+ _context23.next = 16;
1107
1139
  return flushPromises();
1108
1140
  case 16:
1109
1141
  expect(reg.webWorker).toBeDefined();
@@ -1116,7 +1148,7 @@ describe('Registration Tests', function () {
1116
1148
 
1117
1149
  // Advance timers and flush any remaining promises.
1118
1150
  jest.advanceTimersByTime(1000);
1119
- _context24.next = 21;
1151
+ _context23.next = 21;
1120
1152
  return flushPromises();
1121
1153
  case 21:
1122
1154
  expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
@@ -1128,15 +1160,15 @@ describe('Registration Tests', function () {
1128
1160
  expect(reg.getActiveMobiusUrl()).toStrictEqual(url);
1129
1161
  case 26:
1130
1162
  case "end":
1131
- return _context24.stop();
1163
+ return _context23.stop();
1132
1164
  }
1133
- }, _callee24);
1165
+ }, _callee23);
1134
1166
  })));
1135
- it('verify failure followed by recovery of keepalive', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee25() {
1136
- return _regenerator.default.wrap(function _callee25$(_context25) {
1137
- while (1) switch (_context25.prev = _context25.next) {
1167
+ it('verify failure followed by recovery of keepalive', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee24() {
1168
+ return _regenerator.default.wrap(function _callee24$(_context24) {
1169
+ while (1) switch (_context24.prev = _context24.next) {
1138
1170
  case 0:
1139
- _context25.next = 2;
1171
+ _context24.next = 2;
1140
1172
  return beforeEachSetupForKeepalive();
1141
1173
  case 2:
1142
1174
  expect(reg.getStatus()).toBe(_types.RegistrationStatus.ACTIVE);
@@ -1149,15 +1181,15 @@ describe('Registration Tests', function () {
1149
1181
  keepAliveRetryCount: reg.isCCFlow ? 4 : 5
1150
1182
  }
1151
1183
  });
1152
- _context25.next = 8;
1184
+ _context24.next = 8;
1153
1185
  return flushPromises();
1154
1186
  case 8:
1155
1187
  expect(reg.webWorker).toBeUndefined();
1156
1188
  expect(handleErrorSpy).toBeCalledTimes(3);
1157
- _context25.next = 12;
1189
+ _context24.next = 12;
1158
1190
  return reg.triggerRegistration();
1159
1191
  case 12:
1160
- _context25.next = 14;
1192
+ _context24.next = 14;
1161
1193
  return flushPromises();
1162
1194
  case 14:
1163
1195
  expect(reg.webWorker).toBeDefined();
@@ -1167,7 +1199,7 @@ describe('Registration Tests', function () {
1167
1199
  statusCode: 200
1168
1200
  }
1169
1201
  });
1170
- _context25.next = 18;
1202
+ _context24.next = 18;
1171
1203
  return flushPromises();
1172
1204
  case 18:
1173
1205
  // In a complete failure‐then-recovery scenario, we expect another failure event to have been handled.
@@ -1179,16 +1211,16 @@ describe('Registration Tests', function () {
1179
1211
  keepAliveRetryCount: reg.isCCFlow ? 4 : 5
1180
1212
  }
1181
1213
  });
1182
- _context25.next = 21;
1214
+ _context24.next = 21;
1183
1215
  return flushPromises();
1184
1216
  case 21:
1185
1217
  expect(handleErrorSpy).toBeCalledTimes(4);
1186
1218
 
1187
1219
  // And then re-register successfully:
1188
- _context25.next = 24;
1220
+ _context24.next = 24;
1189
1221
  return reg.triggerRegistration();
1190
1222
  case 24:
1191
- _context25.next = 26;
1223
+ _context24.next = 26;
1192
1224
  return flushPromises();
1193
1225
  case 26:
1194
1226
  expect(reg.webWorker).toBeDefined();
@@ -1198,31 +1230,31 @@ describe('Registration Tests', function () {
1198
1230
  statusCode: 200
1199
1231
  }
1200
1232
  });
1201
- _context25.next = 30;
1233
+ _context24.next = 30;
1202
1234
  return flushPromises();
1203
1235
  case 30:
1204
1236
  expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
1205
1237
  expect(reg.webWorker).toBeDefined();
1206
1238
  case 32:
1207
1239
  case "end":
1208
- return _context25.stop();
1240
+ return _context24.stop();
1209
1241
  }
1210
- }, _callee25);
1242
+ }, _callee24);
1211
1243
  })));
1212
- it('cc: verify failover to backup server after 4 keep alive failure with primary server', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee26() {
1244
+ it('cc: verify failover to backup server after 4 keep alive failure with primary server', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee25() {
1213
1245
  var clearKeepaliveSpy, reconnectSpy;
1214
- return _regenerator.default.wrap(function _callee26$(_context26) {
1215
- while (1) switch (_context26.prev = _context26.next) {
1246
+ return _regenerator.default.wrap(function _callee25$(_context25) {
1247
+ while (1) switch (_context25.prev = _context25.next) {
1216
1248
  case 0:
1217
1249
  // Register with contact center service
1218
1250
  setupRegistration(_objectSpread(_objectSpread({}, MockServiceData), {}, {
1219
1251
  indicator: _types.ServiceIndicator.CONTACT_CENTER
1220
1252
  }));
1221
- _context26.next = 3;
1253
+ _context25.next = 3;
1222
1254
  return beforeEachSetupForKeepalive();
1223
1255
  case 3:
1224
1256
  webex.request.mockResolvedValueOnce(successPayload);
1225
- _context26.next = 6;
1257
+ _context25.next = 6;
1226
1258
  return reg.triggerRegistration();
1227
1259
  case 6:
1228
1260
  expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
@@ -1242,7 +1274,7 @@ describe('Registration Tests', function () {
1242
1274
  });
1243
1275
 
1244
1276
  // Wait for any asynchronous actions to complete
1245
- _context26.next = 13;
1277
+ _context25.next = 13;
1246
1278
  return flushPromises();
1247
1279
  case 13:
1248
1280
  // Verify that the keepalive timer was cleared and reconnectOnFailure was triggered
@@ -1254,16 +1286,16 @@ describe('Registration Tests', function () {
1254
1286
  expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
1255
1287
  case 17:
1256
1288
  case "end":
1257
- return _context26.stop();
1289
+ return _context25.stop();
1258
1290
  }
1259
- }, _callee26);
1291
+ }, _callee25);
1260
1292
  })));
1261
- it('verify failure keep-alive case with active call present: Restore Success after call ends', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee27() {
1293
+ it('verify failure keep-alive case with active call present: Restore Success after call ends', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee26() {
1262
1294
  var reconnectSpy, restoreSpy, restartRegSpy, clearTimerSpy, threshold, failureEvent;
1263
- return _regenerator.default.wrap(function _callee27$(_context27) {
1264
- while (1) switch (_context27.prev = _context27.next) {
1295
+ return _regenerator.default.wrap(function _callee26$(_context26) {
1296
+ while (1) switch (_context26.prev = _context26.next) {
1265
1297
  case 0:
1266
- _context27.next = 2;
1298
+ _context26.next = 2;
1267
1299
  return beforeEachSetupForKeepalive();
1268
1300
  case 2:
1269
1301
  reconnectSpy = jest.spyOn(reg, 'reconnectOnFailure');
@@ -1283,7 +1315,7 @@ describe('Registration Tests', function () {
1283
1315
  }
1284
1316
  };
1285
1317
  reg.webWorker.onmessage(failureEvent);
1286
- _context27.next = 13;
1318
+ _context26.next = 13;
1287
1319
  return flushPromises();
1288
1320
  case 13:
1289
1321
  // At this point, clearKeepaliveTimer was called so the worker is terminated.
@@ -1308,10 +1340,10 @@ describe('Registration Tests', function () {
1308
1340
  webex.request.mockResolvedValueOnce(successPayload);
1309
1341
 
1310
1342
  // Call reconnectOnFailure manually. With no active calls, this should trigger re-registration.
1311
- _context27.next = 29;
1343
+ _context26.next = 29;
1312
1344
  return reg.reconnectOnFailure(_constants.CALLS_CLEARED_HANDLER_UTIL);
1313
1345
  case 29:
1314
- _context27.next = 31;
1346
+ _context26.next = 31;
1315
1347
  return flushPromises();
1316
1348
  case 31:
1317
1349
  expect((0, _keys.default)(reg.callManager.getActiveCalls()).length).toBe(0);
@@ -1324,16 +1356,16 @@ describe('Registration Tests', function () {
1324
1356
  expect(reg.reconnectPending).toStrictEqual(false);
1325
1357
  case 38:
1326
1358
  case "end":
1327
- return _context27.stop();
1359
+ return _context26.stop();
1328
1360
  }
1329
- }, _callee27);
1361
+ }, _callee26);
1330
1362
  })));
1331
- it('checks for keep-alive failure with final error: 404', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee28() {
1363
+ it('checks for keep-alive failure with final error: 404', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee27() {
1332
1364
  var reconnectSpy, restoreSpy, restartRegSpy, clearTimerSpy;
1333
- return _regenerator.default.wrap(function _callee28$(_context28) {
1334
- while (1) switch (_context28.prev = _context28.next) {
1365
+ return _regenerator.default.wrap(function _callee27$(_context27) {
1366
+ while (1) switch (_context27.prev = _context27.next) {
1335
1367
  case 0:
1336
- _context28.next = 2;
1368
+ _context27.next = 2;
1337
1369
  return beforeEachSetupForKeepalive();
1338
1370
  case 2:
1339
1371
  reconnectSpy = jest.spyOn(reg, 'reconnectOnFailure');
@@ -1350,7 +1382,7 @@ describe('Registration Tests', function () {
1350
1382
  keepAliveRetryCount: 1
1351
1383
  }
1352
1384
  });
1353
- _context28.next = 10;
1385
+ _context27.next = 10;
1354
1386
  return flushPromises();
1355
1387
  case 10:
1356
1388
  expect(warnSpy).toBeCalledWith('Keep-alive missed 1 times. Status -> 404 ', expect.objectContaining({
@@ -1373,11 +1405,61 @@ describe('Registration Tests', function () {
1373
1405
  expect(reg.keepaliveTimer).toBe(undefined);
1374
1406
  expect(reg.webWorker).toBeUndefined();
1375
1407
  case 21:
1408
+ case "end":
1409
+ return _context27.stop();
1410
+ }
1411
+ }, _callee27);
1412
+ })));
1413
+ });
1414
+ describe('Primary server status checks', function () {
1415
+ it('success: primary server status to be up', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee28() {
1416
+ var pingSuccessPayload, status;
1417
+ return _regenerator.default.wrap(function _callee28$(_context28) {
1418
+ while (1) switch (_context28.prev = _context28.next) {
1419
+ case 0:
1420
+ pingSuccessPayload = {
1421
+ statusCode: 200
1422
+ };
1423
+ webex.request.mockResolvedValue(pingSuccessPayload);
1424
+ _context28.next = 4;
1425
+ return reg.isPrimaryActive();
1426
+ case 4:
1427
+ status = _context28.sent;
1428
+ expect(webex.request).toBeCalledWith(_objectSpread({
1429
+ method: 'GET',
1430
+ uri: "https://mobius-dfw.webex.com/api/v1/ping"
1431
+ }, (0, _testUtil.getMockRequestTemplate)()));
1432
+ expect(status).toEqual(true);
1433
+ case 7:
1376
1434
  case "end":
1377
1435
  return _context28.stop();
1378
1436
  }
1379
1437
  }, _callee28);
1380
1438
  })));
1439
+ it('failed: primary server status to be down', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee29() {
1440
+ var pingFailurePayload, status;
1441
+ return _regenerator.default.wrap(function _callee29$(_context29) {
1442
+ while (1) switch (_context29.prev = _context29.next) {
1443
+ case 0:
1444
+ pingFailurePayload = {
1445
+ statusCode: 500
1446
+ };
1447
+ webex.request.mockResolvedValue(pingFailurePayload);
1448
+ _context29.next = 4;
1449
+ return reg.isPrimaryActive();
1450
+ case 4:
1451
+ status = _context29.sent;
1452
+ expect(webex.request).toBeCalledWith(_objectSpread({
1453
+ method: 'GET',
1454
+ uri: "https://mobius-dfw.webex.com/api/v1/ping"
1455
+ }, (0, _testUtil.getMockRequestTemplate)()));
1456
+ expect(status).toEqual(false);
1457
+ case 7:
1458
+ case "end":
1459
+ return _context29.stop();
1460
+ }
1461
+ }, _callee29);
1462
+ })));
1381
1463
  });
1382
1464
  });
1383
1465
  //# sourceMappingURL=register.test.js.map