@webex/calling 3.8.0-next.31 → 3.8.0-next.33

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 (145) hide show
  1. package/dist/CallHistory/CallHistory.js +100 -63
  2. package/dist/CallHistory/CallHistory.js.map +1 -1
  3. package/dist/CallHistory/CallHistory.test.js +115 -19
  4. package/dist/CallHistory/CallHistory.test.js.map +1 -1
  5. package/dist/CallHistory/constants.js +9 -1
  6. package/dist/CallHistory/constants.js.map +1 -1
  7. package/dist/CallSettings/CallSettings.js +46 -13
  8. package/dist/CallSettings/CallSettings.js.map +1 -1
  9. package/dist/CallSettings/UcmBackendConnector.js +62 -18
  10. package/dist/CallSettings/UcmBackendConnector.js.map +1 -1
  11. package/dist/CallSettings/UcmBackendConnector.test.js +70 -7
  12. package/dist/CallSettings/UcmBackendConnector.test.js.map +1 -1
  13. package/dist/CallSettings/WxCallBackendConnector.js +153 -103
  14. package/dist/CallSettings/WxCallBackendConnector.js.map +1 -1
  15. package/dist/CallSettings/WxCallBackendConnector.test.js +52 -15
  16. package/dist/CallSettings/WxCallBackendConnector.test.js.map +1 -1
  17. package/dist/CallSettings/constants.js +15 -1
  18. package/dist/CallSettings/constants.js.map +1 -1
  19. package/dist/CallingClient/CallingClient.js +148 -107
  20. package/dist/CallingClient/CallingClient.js.map +1 -1
  21. package/dist/CallingClient/CallingClient.test.js +53 -24
  22. package/dist/CallingClient/CallingClient.test.js.map +1 -1
  23. package/dist/CallingClient/calling/call.js +251 -189
  24. package/dist/CallingClient/calling/call.js.map +1 -1
  25. package/dist/CallingClient/calling/call.test.js +96 -41
  26. package/dist/CallingClient/calling/call.test.js.map +1 -1
  27. package/dist/CallingClient/calling/callManager.js +73 -48
  28. package/dist/CallingClient/calling/callManager.js.map +1 -1
  29. package/dist/CallingClient/calling/callManager.test.js +96 -37
  30. package/dist/CallingClient/calling/callManager.test.js.map +1 -1
  31. package/dist/CallingClient/constants.js +104 -3
  32. package/dist/CallingClient/constants.js.map +1 -1
  33. package/dist/CallingClient/line/index.js +47 -18
  34. package/dist/CallingClient/line/index.js.map +1 -1
  35. package/dist/CallingClient/line/line.test.js +2 -2
  36. package/dist/CallingClient/line/line.test.js.map +1 -1
  37. package/dist/CallingClient/registration/register.js +261 -219
  38. package/dist/CallingClient/registration/register.js.map +1 -1
  39. package/dist/CallingClient/registration/register.test.js +533 -155
  40. package/dist/CallingClient/registration/register.test.js.map +1 -1
  41. package/dist/CallingClient/registration/types.js.map +1 -1
  42. package/dist/Contacts/ContactsClient.js +156 -102
  43. package/dist/Contacts/ContactsClient.js.map +1 -1
  44. package/dist/Contacts/ContactsClient.test.js +197 -49
  45. package/dist/Contacts/ContactsClient.test.js.map +1 -1
  46. package/dist/Contacts/constants.js +11 -1
  47. package/dist/Contacts/constants.js.map +1 -1
  48. package/dist/Events/impl/index.js +1 -1
  49. package/dist/Events/impl/index.js.map +1 -1
  50. package/dist/Metrics/index.js +93 -39
  51. package/dist/Metrics/index.js.map +1 -1
  52. package/dist/Metrics/types.js +4 -1
  53. package/dist/Metrics/types.js.map +1 -1
  54. package/dist/SDKConnector/types.js.map +1 -1
  55. package/dist/Voicemail/BroadworksBackendConnector.js +154 -91
  56. package/dist/Voicemail/BroadworksBackendConnector.js.map +1 -1
  57. package/dist/Voicemail/BroadworksBackendConnector.test.js +99 -19
  58. package/dist/Voicemail/BroadworksBackendConnector.test.js.map +1 -1
  59. package/dist/Voicemail/UcmBackendConnector.js +105 -54
  60. package/dist/Voicemail/UcmBackendConnector.js.map +1 -1
  61. package/dist/Voicemail/UcmBackendConnector.test.js +127 -17
  62. package/dist/Voicemail/UcmBackendConnector.test.js.map +1 -1
  63. package/dist/Voicemail/Voicemail.js +198 -79
  64. package/dist/Voicemail/Voicemail.js.map +1 -1
  65. package/dist/Voicemail/Voicemail.test.js +188 -23
  66. package/dist/Voicemail/Voicemail.test.js.map +1 -1
  67. package/dist/Voicemail/WxCallBackendConnector.js +123 -76
  68. package/dist/Voicemail/WxCallBackendConnector.js.map +1 -1
  69. package/dist/Voicemail/WxCallBackendConnector.test.js +69 -6
  70. package/dist/Voicemail/WxCallBackendConnector.test.js.map +1 -1
  71. package/dist/Voicemail/constants.js +25 -1
  72. package/dist/Voicemail/constants.js.map +1 -1
  73. package/dist/common/Utils.js +167 -104
  74. package/dist/common/Utils.js.map +1 -1
  75. package/dist/common/Utils.test.js +199 -35
  76. package/dist/common/Utils.test.js.map +1 -1
  77. package/dist/common/constants.js +2 -1
  78. package/dist/common/constants.js.map +1 -1
  79. package/dist/common/types.js.map +1 -1
  80. package/dist/module/CallHistory/CallHistory.js +32 -13
  81. package/dist/module/CallHistory/constants.js +6 -0
  82. package/dist/module/CallSettings/CallSettings.js +36 -3
  83. package/dist/module/CallSettings/UcmBackendConnector.js +50 -5
  84. package/dist/module/CallSettings/WxCallBackendConnector.js +54 -18
  85. package/dist/module/CallSettings/constants.js +12 -0
  86. package/dist/module/CallingClient/CallingClient.js +52 -14
  87. package/dist/module/CallingClient/calling/call.js +172 -121
  88. package/dist/module/CallingClient/calling/callManager.js +51 -26
  89. package/dist/module/CallingClient/constants.js +101 -2
  90. package/dist/module/CallingClient/line/index.js +37 -8
  91. package/dist/module/CallingClient/registration/register.js +90 -54
  92. package/dist/module/Contacts/ContactsClient.js +65 -21
  93. package/dist/module/Contacts/constants.js +10 -0
  94. package/dist/module/Events/impl/index.js +1 -1
  95. package/dist/module/Metrics/index.js +49 -1
  96. package/dist/module/Metrics/types.js +3 -0
  97. package/dist/module/Voicemail/BroadworksBackendConnector.js +66 -17
  98. package/dist/module/Voicemail/UcmBackendConnector.js +51 -11
  99. package/dist/module/Voicemail/Voicemail.js +109 -9
  100. package/dist/module/Voicemail/WxCallBackendConnector.js +50 -17
  101. package/dist/module/Voicemail/constants.js +21 -0
  102. package/dist/module/common/Utils.js +50 -12
  103. package/dist/module/common/constants.js +1 -0
  104. package/dist/types/CallHistory/CallHistory.d.ts.map +1 -1
  105. package/dist/types/CallHistory/constants.d.ts +6 -0
  106. package/dist/types/CallHistory/constants.d.ts.map +1 -1
  107. package/dist/types/CallSettings/CallSettings.d.ts.map +1 -1
  108. package/dist/types/CallSettings/UcmBackendConnector.d.ts.map +1 -1
  109. package/dist/types/CallSettings/WxCallBackendConnector.d.ts.map +1 -1
  110. package/dist/types/CallSettings/constants.d.ts +12 -0
  111. package/dist/types/CallSettings/constants.d.ts.map +1 -1
  112. package/dist/types/CallingClient/CallingClient.d.ts +2 -3
  113. package/dist/types/CallingClient/CallingClient.d.ts.map +1 -1
  114. package/dist/types/CallingClient/calling/call.d.ts.map +1 -1
  115. package/dist/types/CallingClient/calling/callManager.d.ts.map +1 -1
  116. package/dist/types/CallingClient/constants.d.ts +101 -2
  117. package/dist/types/CallingClient/constants.d.ts.map +1 -1
  118. package/dist/types/CallingClient/line/index.d.ts.map +1 -1
  119. package/dist/types/CallingClient/registration/register.d.ts +3 -1
  120. package/dist/types/CallingClient/registration/register.d.ts.map +1 -1
  121. package/dist/types/CallingClient/registration/types.d.ts +1 -0
  122. package/dist/types/CallingClient/registration/types.d.ts.map +1 -1
  123. package/dist/types/Contacts/ContactsClient.d.ts.map +1 -1
  124. package/dist/types/Contacts/constants.d.ts +10 -0
  125. package/dist/types/Contacts/constants.d.ts.map +1 -1
  126. package/dist/types/Metrics/index.d.ts +1 -1
  127. package/dist/types/Metrics/index.d.ts.map +1 -1
  128. package/dist/types/Metrics/types.d.ts +5 -1
  129. package/dist/types/Metrics/types.d.ts.map +1 -1
  130. package/dist/types/SDKConnector/types.d.ts +8 -2
  131. package/dist/types/SDKConnector/types.d.ts.map +1 -1
  132. package/dist/types/Voicemail/BroadworksBackendConnector.d.ts.map +1 -1
  133. package/dist/types/Voicemail/UcmBackendConnector.d.ts.map +1 -1
  134. package/dist/types/Voicemail/Voicemail.d.ts +1 -1
  135. package/dist/types/Voicemail/Voicemail.d.ts.map +1 -1
  136. package/dist/types/Voicemail/WxCallBackendConnector.d.ts.map +1 -1
  137. package/dist/types/Voicemail/constants.d.ts +21 -0
  138. package/dist/types/Voicemail/constants.d.ts.map +1 -1
  139. package/dist/types/common/Utils.d.ts +4 -4
  140. package/dist/types/common/Utils.d.ts.map +1 -1
  141. package/dist/types/common/constants.d.ts +1 -0
  142. package/dist/types/common/constants.d.ts.map +1 -1
  143. package/dist/types/common/types.d.ts +12 -0
  144. package/dist/types/common/types.d.ts.map +1 -1
  145. package/package.json +1 -1
@@ -37,9 +37,11 @@ var MockServiceData = {
37
37
  indicator: _types.ServiceIndicator.CALLING,
38
38
  domain: ''
39
39
  };
40
- var logSpy = jest.spyOn(_Logger.default, 'info');
40
+ var logSpy = jest.spyOn(_Logger.default, 'log');
41
+ var infoSpy = jest.spyOn(_Logger.default, 'info');
41
42
  var warnSpy = jest.spyOn(_Logger.default, 'warn');
42
43
  var handleErrorSpy = jest.spyOn(utils, 'handleRegistrationErrors');
44
+ jest.spyOn(utils, 'uploadLogs').mockResolvedValue();
43
45
  describe('Registration Tests', function () {
44
46
  var originalProcessNextTick = process.nextTick;
45
47
  function flushPromises() {
@@ -72,9 +74,33 @@ describe('Registration Tests', function () {
72
74
  statusCode: 500,
73
75
  body: _registerFixtures.mockPostResponse
74
76
  };
75
- var failurePayload429 = {
77
+ var failurePayload429One = {
76
78
  statusCode: 429,
77
- body: _registerFixtures.mockPostResponse
79
+ body: _registerFixtures.mockPostResponse,
80
+ headers: {
81
+ 'retry-after': 42
82
+ }
83
+ };
84
+ var failurePayload429Two = {
85
+ statusCode: 429,
86
+ body: _registerFixtures.mockPostResponse,
87
+ headers: {
88
+ 'retry-after': 33
89
+ }
90
+ };
91
+ var failurePayload429Three = {
92
+ statusCode: 429,
93
+ body: _registerFixtures.mockPostResponse,
94
+ headers: {
95
+ 'retry-after': 136
96
+ }
97
+ };
98
+ var failurePayload429Four = {
99
+ statusCode: 429,
100
+ body: _registerFixtures.mockPostResponse,
101
+ headers: {
102
+ 'retry-after': 81
103
+ }
78
104
  };
79
105
  var successPayload = {
80
106
  statusCode: 200,
@@ -82,18 +108,20 @@ describe('Registration Tests', function () {
82
108
  };
83
109
  var reg;
84
110
  var restartSpy;
85
- var failbackRetry429Spy;
86
111
  var restoreSpy;
87
112
  var postRegistrationSpy;
113
+ var failoverSpy;
114
+ var retry429Spy;
88
115
  var setupRegistration = function setupRegistration(mockServiceData) {
89
116
  var mutex = new _asyncMutex.Mutex();
90
117
  reg = (0, _register.createRegistration)(webex, mockServiceData, mutex, lineEmitter, _types2.LOGGER.INFO);
91
118
  reg.setMobiusServers(mobiusUris.primary, mobiusUris.backup);
92
119
  jest.clearAllMocks();
93
120
  restartSpy = jest.spyOn(reg, 'restartRegistration');
94
- failbackRetry429Spy = jest.spyOn(reg, _constants.FAILBACK_429_RETRY_UTIL);
95
121
  restoreSpy = jest.spyOn(reg, 'restorePreviousRegistration');
96
122
  postRegistrationSpy = jest.spyOn(reg, 'postRegistration');
123
+ failoverSpy = jest.spyOn(reg, 'startFailoverTimer');
124
+ retry429Spy = jest.spyOn(reg, 'handle429Retry');
97
125
  };
98
126
  beforeEach(function () {
99
127
  setupRegistration(MockServiceData);
@@ -121,7 +149,13 @@ describe('Registration Tests', function () {
121
149
  expect(lineEmitter).toBeCalledTimes(2);
122
150
  expect(lineEmitter).toBeCalledWith(_types4.LINE_EVENTS.CONNECTING);
123
151
  expect(lineEmitter).toBeCalledWith(_types4.LINE_EVENTS.REGISTERED, _registerFixtures.mockPostResponse);
124
- case 8:
152
+
153
+ // Check that log.log was called for successful registration
154
+ expect(logSpy).toBeCalledWith("Registration successful for deviceId: ".concat(_registerFixtures.mockPostResponse.device.deviceId, " userId: ").concat(_registerFixtures.mockPostResponse.userId), expect.objectContaining({
155
+ file: _constants.REGISTRATION_FILE,
156
+ method: expect.any(String)
157
+ }));
158
+ case 9:
125
159
  case "end":
126
160
  return _context.stop();
127
161
  }
@@ -188,8 +222,8 @@ describe('Registration Tests', function () {
188
222
  headers: expect.anything()
189
223
  });
190
224
  expect(warnSpy).toBeCalledWith('User device limit exceeded', expect.anything());
191
- expect(logSpy).toBeCalledWith('Registration restoration in progress.', expect.anything());
192
- expect(logSpy).toBeCalledWith('Registration restored successfully.', expect.anything());
225
+ expect(infoSpy).toBeCalledWith('Registration restoration in progress.', expect.anything());
226
+ expect(infoSpy).toBeCalledWith('Registration restored successfully.', expect.anything());
193
227
  expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
194
228
  expect(lineEmitter).toBeCalledTimes(4);
195
229
  expect(lineEmitter).nthCalledWith(1, _types4.LINE_EVENTS.CONNECTING);
@@ -202,20 +236,345 @@ describe('Registration Tests', function () {
202
236
  }
203
237
  }, _callee3);
204
238
  })));
205
- describe('Registration failover tests', function () {
206
- it('verify unreachable primary with reachable backup servers', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
239
+ describe('429 handling tests', function () {
240
+ var loggerContext = {
241
+ file: _constants.REGISTRATION_FILE,
242
+ method: _constants.FAILOVER_UTIL
243
+ };
244
+ var logSpy = jest.spyOn(_Logger.default, 'log');
245
+ beforeEach(function () {
246
+ mobiusUris.backup.pop();
247
+ });
248
+ afterEach(function () {
249
+ mobiusUris.backup.push(_registerFixtures.URL);
250
+ jest.clearAllMocks();
251
+ });
252
+ it('handle 429 received during initial registration failure and first attempt with primary', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
207
253
  return _regenerator.default.wrap(function _callee4$(_context4) {
208
254
  while (1) switch (_context4.prev = _context4.next) {
255
+ case 0:
256
+ jest.useFakeTimers();
257
+ logSpy.mockClear();
258
+ webex.request.mockRejectedValueOnce(failurePayload429One).mockRejectedValueOnce(failurePayload429Two).mockRejectedValueOnce(failurePayload);
259
+ _context4.next = 5;
260
+ return reg.triggerRegistration();
261
+ case 5:
262
+ /* Initial registration failed with 429 with higher retyrAfter, interval should be updtaed with retryAfter.
263
+ * The first attempt to register with primary should be made after retryAfter seconds.
264
+ */
265
+
266
+ expect(webex.request).toHaveBeenNthCalledWith(1, _objectSpread(_objectSpread({}, mockResponse), {}, {
267
+ method: 'POST',
268
+ uri: "".concat(mobiusUris.primary[0], "device")
269
+ }));
270
+ expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
271
+ expect(retry429Spy).toBeCalledOnceWith(failurePayload429One.headers['retry-after'], 'triggerRegistration');
272
+ expect(reg.retryAfter).toEqual(failurePayload429One.headers['retry-after']);
273
+ expect(failoverSpy).toBeCalledOnceWith();
274
+ expect(logSpy).toBeCalledWith("Scheduled retry with primary in ".concat(failurePayload429One.headers['retry-after'], " seconds, number of attempts : 1"), loggerContext);
275
+ retry429Spy.mockClear();
276
+ failoverSpy.mockClear();
277
+ jest.advanceTimersByTime(Number(failurePayload429One.headers['retry-after']) * _constants.SEC_TO_MSEC_MFACTOR);
278
+ _context4.next = 16;
279
+ return flushPromises();
280
+ case 16:
281
+ /* The first attempt to register with primary failed with 429 with lower retryAfter, interval should remain the same.
282
+ * The second attempt to register with primary will be scheduled as per the interval calculated.
283
+ */
284
+
285
+ expect(webex.request).toHaveBeenNthCalledWith(2, _objectSpread(_objectSpread({}, mockResponse), {}, {
286
+ method: 'POST',
287
+ uri: "".concat(mobiusUris.primary[0], "device")
288
+ }));
289
+ expect(retry429Spy).toBeCalledOnceWith(failurePayload429Two.headers['retry-after'], 'startFailoverTimer');
290
+ expect(reg.retryAfter).toEqual(failurePayload429Two.headers['retry-after']);
291
+ expect(failoverSpy).toBeCalledOnceWith(2, failurePayload429One.headers['retry-after']);
292
+ retry429Spy.mockClear();
293
+ failoverSpy.mockClear();
294
+ jest.advanceTimersByTime(43 * _constants.SEC_TO_MSEC_MFACTOR);
295
+ _context4.next = 25;
296
+ return flushPromises();
297
+ case 25:
298
+ /* The second attempt to register with primary failed with 500, the retryAfter should be undefined.
299
+ * The third attempt to register with primary will be scheduled as per the interval calculated.
300
+ */
301
+ expect(webex.request).toHaveBeenNthCalledWith(3, _objectSpread(_objectSpread({}, mockResponse), {}, {
302
+ method: 'POST',
303
+ uri: "".concat(mobiusUris.primary[0], "device")
304
+ }));
305
+ expect(retry429Spy).not.toBeCalled();
306
+ expect(reg.retryAfter).toEqual(undefined);
307
+ expect(failoverSpy).toBeCalledOnceWith(3, 85);
308
+ case 29:
309
+ case "end":
310
+ return _context4.stop();
311
+ }
312
+ }, _callee4);
313
+ })));
314
+ 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() {
315
+ return _regenerator.default.wrap(function _callee5$(_context5) {
316
+ while (1) switch (_context5.prev = _context5.next) {
317
+ case 0:
318
+ reg.isCCFlow = true;
319
+ jest.spyOn(reg, 'getRegRetryInterval').mockReturnValueOnce(33).mockReturnValueOnce(40).mockReturnValueOnce(47).mockReturnValueOnce(52);
320
+ jest.useFakeTimers();
321
+ webex.request.mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload429One).mockResolvedValueOnce(successPayload);
322
+ _context5.next = 6;
323
+ return reg.triggerRegistration();
324
+ case 6:
325
+ expect(webex.request).toHaveBeenNthCalledWith(1, _objectSpread(_objectSpread({}, mockResponse), {}, {
326
+ method: 'POST',
327
+ uri: "".concat(mobiusUris.primary[0], "device")
328
+ }));
329
+ expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
330
+ expect(retry429Spy).not.toBeCalled();
331
+ expect(failoverSpy).toBeCalledOnceWith();
332
+ expect(logSpy).toBeCalledWith("Scheduled retry with primary in 33 seconds, number of attempts : 1", loggerContext);
333
+ failoverSpy.mockClear();
334
+ jest.advanceTimersByTime(33 * _constants.SEC_TO_MSEC_MFACTOR);
335
+ _context5.next = 15;
336
+ return flushPromises();
337
+ case 15:
338
+ expect(webex.request).toHaveBeenNthCalledWith(2, _objectSpread(_objectSpread({}, mockResponse), {}, {
339
+ method: 'POST',
340
+ uri: "".concat(mobiusUris.primary[0], "device")
341
+ }));
342
+ expect(retry429Spy).not.toBeCalled();
343
+ expect(failoverSpy).toBeCalledOnceWith(2, 33);
344
+ expect(logSpy).toBeCalledWith("Scheduled retry with primary in 40 seconds, number of attempts : 2", loggerContext);
345
+ logSpy.mockClear();
346
+ failoverSpy.mockClear();
347
+ jest.advanceTimersByTime(40 * _constants.SEC_TO_MSEC_MFACTOR);
348
+ _context5.next = 24;
349
+ return flushPromises();
350
+ case 24:
351
+ expect(webex.request).toHaveBeenNthCalledWith(3, _objectSpread(_objectSpread({}, mockResponse), {}, {
352
+ method: 'POST',
353
+ uri: "".concat(mobiusUris.primary[0], "device")
354
+ }));
355
+ expect(retry429Spy).toBeCalledOnceWith(failurePayload429One.headers['retry-after'], 'startFailoverTimer');
356
+ expect(failoverSpy).toBeCalledOnceWith(3, 73);
357
+ expect(logSpy).not.toBeCalledWith("Scheduled retry with primary in ".concat(failurePayload429One.headers['retry-after'], " seconds, number of attempts : 3"), loggerContext);
358
+ expect(infoSpy).toBeCalledWith("Failing over to backup servers.", loggerContext);
359
+ expect(webex.request).toHaveBeenNthCalledWith(4, _objectSpread(_objectSpread({}, mockResponse), {}, {
360
+ method: 'POST',
361
+ uri: "".concat(mobiusUris.backup[0], "device")
362
+ }));
363
+ expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
364
+ case 31:
365
+ case "end":
366
+ return _context5.stop();
367
+ }
368
+ }, _callee5);
369
+ })));
370
+ it('handle 429 received while the last attempt for primary', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
371
+ return _regenerator.default.wrap(function _callee6$(_context6) {
372
+ while (1) switch (_context6.prev = _context6.next) {
373
+ case 0:
374
+ reg.isCCFlow = true;
375
+ jest.spyOn(reg, 'getRegRetryInterval').mockReturnValueOnce(33).mockReturnValueOnce(40).mockReturnValueOnce(47).mockReturnValueOnce(52);
376
+ jest.useFakeTimers();
377
+ webex.request.mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload429One).mockResolvedValueOnce(successPayload);
378
+ _context6.next = 6;
379
+ return reg.triggerRegistration();
380
+ case 6:
381
+ /* Initial registration and first 2 attempts with primary failed with non-final 5xx error responses.
382
+ * Last attempt with primary failed with 429, the retryAfter should be used to schedule the next attempt but
383
+ * the failover is triggered before the scheduling logic kicks in.
384
+ */
385
+ expect(webex.request).toHaveBeenNthCalledWith(1, _objectSpread(_objectSpread({}, mockResponse), {}, {
386
+ method: 'POST',
387
+ uri: "".concat(mobiusUris.primary[0], "device")
388
+ }));
389
+ expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
390
+ expect(retry429Spy).not.toBeCalled();
391
+ expect(failoverSpy).toBeCalledOnceWith();
392
+ expect(logSpy).toBeCalledWith("Scheduled retry with primary in 33 seconds, number of attempts : 1", loggerContext);
393
+ failoverSpy.mockClear();
394
+ jest.advanceTimersByTime(33 * _constants.SEC_TO_MSEC_MFACTOR);
395
+ _context6.next = 15;
396
+ return flushPromises();
397
+ case 15:
398
+ expect(webex.request).toHaveBeenNthCalledWith(2, _objectSpread(_objectSpread({}, mockResponse), {}, {
399
+ method: 'POST',
400
+ uri: "".concat(mobiusUris.primary[0], "device")
401
+ }));
402
+ expect(retry429Spy).not.toBeCalled();
403
+ expect(failoverSpy).toBeCalledOnceWith(2, 33);
404
+ expect(logSpy).toBeCalledWith("Scheduled retry with primary in 40 seconds, number of attempts : 2", loggerContext);
405
+ logSpy.mockClear();
406
+ failoverSpy.mockClear();
407
+ jest.advanceTimersByTime(40 * _constants.SEC_TO_MSEC_MFACTOR);
408
+ _context6.next = 24;
409
+ return flushPromises();
410
+ case 24:
411
+ expect(webex.request).toHaveBeenNthCalledWith(3, _objectSpread(_objectSpread({}, mockResponse), {}, {
412
+ method: 'POST',
413
+ uri: "".concat(mobiusUris.primary[0], "device")
414
+ }));
415
+ expect(retry429Spy).not.toBeCalled();
416
+ expect(failoverSpy).toBeCalledOnceWith(3, 73);
417
+ expect(logSpy).toBeCalledWith("Scheduled retry with primary in 41 seconds, number of attempts : 3", loggerContext);
418
+ failoverSpy.mockClear();
419
+ jest.advanceTimersByTime(41 * _constants.SEC_TO_MSEC_MFACTOR);
420
+ _context6.next = 32;
421
+ return flushPromises();
422
+ case 32:
423
+ expect(webex.request).toHaveBeenNthCalledWith(4, _objectSpread(_objectSpread({}, mockResponse), {}, {
424
+ method: 'POST',
425
+ uri: "".concat(mobiusUris.primary[0], "device")
426
+ }));
427
+ expect(retry429Spy).toBeCalledOnceWith(failurePayload429One.headers['retry-after'], 'startFailoverTimer');
428
+ expect(failoverSpy).toBeCalledOnceWith(4, 114);
429
+ expect(infoSpy).toBeCalledWith("Failing over to backup servers.", loggerContext);
430
+ expect(webex.request).toHaveBeenNthCalledWith(5, _objectSpread(_objectSpread({}, mockResponse), {}, {
431
+ method: 'POST',
432
+ uri: "".concat(mobiusUris.backup[0], "device")
433
+ }));
434
+ expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
435
+ case 38:
436
+ case "end":
437
+ return _context6.stop();
438
+ }
439
+ }, _callee6);
440
+ })));
441
+ it('handle 429 received while failing over to backup server for CC flow', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
442
+ return _regenerator.default.wrap(function _callee7$(_context7) {
443
+ while (1) switch (_context7.prev = _context7.next) {
444
+ case 0:
445
+ reg.isCCFlow = true;
446
+ jest.useFakeTimers();
447
+ webex.request.mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload429One).mockResolvedValueOnce(successPayload);
448
+ _context7.next = 5;
449
+ return reg.triggerRegistration();
450
+ case 5:
451
+ jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_FOR_CC_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
452
+ _context7.next = 8;
453
+ return flushPromises();
454
+ case 8:
455
+ expect(webex.request).toBeCalledTimes(3);
456
+ expect(webex.request).toHaveBeenNthCalledWith(1, _objectSpread(_objectSpread({}, mockResponse), {}, {
457
+ method: 'POST',
458
+ uri: "".concat(mobiusUris.primary[0], "device")
459
+ }));
460
+ expect(webex.request).toHaveBeenNthCalledWith(2, _objectSpread(_objectSpread({}, mockResponse), {}, {
461
+ method: 'POST',
462
+ uri: "".concat(mobiusUris.primary[0], "device")
463
+ }));
464
+
465
+ /* Failover to backup server failed with 429, the retryAfter is used to schedule the next attempt with backup server.
466
+ * Interval will be updated with retryAfter as interval calculated is less than the retryAfter.
467
+ */
468
+ expect(webex.request).toHaveBeenNthCalledWith(3, _objectSpread(_objectSpread({}, mockResponse), {}, {
469
+ method: 'POST',
470
+ uri: "".concat(mobiusUris.backup[0], "device")
471
+ }));
472
+ expect(retry429Spy).toBeCalledOnceWith(failurePayload429One.headers['retry-after'], 'startFailoverTimer');
473
+ expect(logSpy).toBeCalledWith("Scheduled retry with backup servers in ".concat(failurePayload429One.headers['retry-after'], " seconds."), loggerContext);
474
+ webex.request.mockClear();
475
+ jest.advanceTimersByTime(Number(failurePayload429One.headers['retry-after']) * _constants.SEC_TO_MSEC_MFACTOR);
476
+ _context7.next = 18;
477
+ return flushPromises();
478
+ case 18:
479
+ expect(webex.request).toBeCalledOnceWith(_objectSpread(_objectSpread({}, mockResponse), {}, {
480
+ method: 'POST',
481
+ uri: "".concat(mobiusUris.backup[0], "device")
482
+ }));
483
+ expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
484
+ case 20:
485
+ case "end":
486
+ return _context7.stop();
487
+ }
488
+ }, _callee7);
489
+ })));
490
+ it('checking the retryAfter exceeding the threshold timers in first attempt itself', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
491
+ return _regenerator.default.wrap(function _callee8$(_context8) {
492
+ while (1) switch (_context8.prev = _context8.next) {
493
+ case 0:
494
+ reg.isCCFlow = true;
495
+ jest.useFakeTimers();
496
+ jest.spyOn(reg, 'getRegRetryInterval').mockReturnValueOnce(40);
497
+ webex.request.mockRejectedValueOnce(failurePayload429Three);
498
+ _context8.next = 6;
499
+ return reg.triggerRegistration();
500
+ case 6:
501
+ expect(webex.request).toHaveBeenNthCalledWith(1, _objectSpread(_objectSpread({}, mockResponse), {}, {
502
+ method: 'POST',
503
+ uri: "".concat(mobiusUris.primary[0], "device")
504
+ }));
505
+ expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
506
+ expect(failoverSpy).toBeCalledOnceWith();
507
+ expect(infoSpy).toBeCalledWith("Failing over to backup servers.", loggerContext);
508
+ expect(logSpy).not.toBeCalledWith("Scheduled retry with primary in 40 seconds, number of attempts : 1", loggerContext);
509
+ expect(logSpy).not.toBeCalledWith("Scheduled retry with primary in ".concat(failurePayload429Three.headers['retry-after'], " seconds, number of attempts : 1"), loggerContext);
510
+ expect(webex.request).toHaveBeenNthCalledWith(2, _objectSpread(_objectSpread({}, mockResponse), {}, {
511
+ method: 'POST',
512
+ uri: "".concat(mobiusUris.backup[0], "device")
513
+ }));
514
+ case 13:
515
+ case "end":
516
+ return _context8.stop();
517
+ }
518
+ }, _callee8);
519
+ })));
520
+ it('checking the retryAfter exceeding the threshold timers in later attempts', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9() {
521
+ return _regenerator.default.wrap(function _callee9$(_context9) {
522
+ while (1) switch (_context9.prev = _context9.next) {
523
+ case 0:
524
+ reg.isCCFlow = true;
525
+ jest.useFakeTimers();
526
+ jest.spyOn(reg, 'getRegRetryInterval').mockReturnValueOnce(39).mockReturnValueOnce(43);
527
+ webex.request.mockRejectedValueOnce(failurePayload429One).mockRejectedValueOnce(failurePayload429Four).mockResolvedValueOnce(successPayload);
528
+ _context9.next = 6;
529
+ return reg.triggerRegistration();
530
+ case 6:
531
+ expect(webex.request).toHaveBeenNthCalledWith(1, _objectSpread(_objectSpread({}, mockResponse), {}, {
532
+ method: 'POST',
533
+ uri: "".concat(mobiusUris.primary[0], "device")
534
+ }));
535
+ expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
536
+ expect(failoverSpy).toBeCalledOnceWith();
537
+ expect(logSpy).toBeCalledWith("Scheduled retry with primary in ".concat(failurePayload429One.headers['retry-after'], " seconds, number of attempts : 1"), loggerContext);
538
+ failoverSpy.mockClear();
539
+ jest.advanceTimersByTime(Number(failurePayload429One.headers['retry-after']) * _constants.SEC_TO_MSEC_MFACTOR);
540
+ _context9.next = 14;
541
+ return flushPromises();
542
+ case 14:
543
+ expect(webex.request).toHaveBeenNthCalledWith(2, _objectSpread(_objectSpread({}, mockResponse), {}, {
544
+ method: 'POST',
545
+ uri: "".concat(mobiusUris.primary[0], "device")
546
+ }));
547
+ expect(failoverSpy).toBeCalledOnceWith(2, failurePayload429One.headers['retry-after']);
548
+ expect(logSpy).not.toBeCalledWith("Scheduled retry with primary in 43 seconds, number of attempts : 2", loggerContext);
549
+ expect(infoSpy).toBeCalledWith("Failing over to backup servers.", loggerContext);
550
+ expect(logSpy).not.toBeCalledWith("Scheduled retry with primary in ".concat(failurePayload429Four.headers['retry-after'], " seconds, number of attempts : 2"), loggerContext);
551
+ expect(infoSpy).toBeCalledWith("Failing over to backup servers.", loggerContext);
552
+ expect(webex.request).toHaveBeenNthCalledWith(3, _objectSpread(_objectSpread({}, mockResponse), {}, {
553
+ method: 'POST',
554
+ uri: "".concat(mobiusUris.backup[0], "device")
555
+ }));
556
+ expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
557
+ case 22:
558
+ case "end":
559
+ return _context9.stop();
560
+ }
561
+ }, _callee9);
562
+ })));
563
+ });
564
+ describe('Registration failover tests', function () {
565
+ it('verify unreachable primary with reachable backup servers', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10() {
566
+ return _regenerator.default.wrap(function _callee10$(_context10) {
567
+ while (1) switch (_context10.prev = _context10.next) {
209
568
  case 0:
210
569
  jest.useFakeTimers();
211
570
  // try the primary twice and register successfully with backup servers
212
571
  webex.request.mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload).mockResolvedValueOnce(successPayload);
213
572
  expect(reg.getStatus()).toEqual(_types.RegistrationStatus.IDLE);
214
- _context4.next = 5;
573
+ _context10.next = 5;
215
574
  return reg.triggerRegistration();
216
575
  case 5:
217
576
  jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
218
- _context4.next = 8;
577
+ _context10.next = 8;
219
578
  return flushPromises();
220
579
  case 8:
221
580
  expect(webex.request).toBeCalledTimes(3);
@@ -232,13 +591,13 @@ describe('Registration Tests', function () {
232
591
  expect(reg.getActiveMobiusUrl()).toEqual(mobiusUris.backup[0]);
233
592
  case 13:
234
593
  case "end":
235
- return _context4.stop();
594
+ return _context10.stop();
236
595
  }
237
- }, _callee4);
596
+ }, _callee10);
238
597
  })));
239
- it('cc: verify unreachable primary with reachable backup server', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
240
- return _regenerator.default.wrap(function _callee5$(_context5) {
241
- while (1) switch (_context5.prev = _context5.next) {
598
+ it('cc: verify unreachable primary with reachable backup server', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11() {
599
+ return _regenerator.default.wrap(function _callee11$(_context11) {
600
+ while (1) switch (_context11.prev = _context11.next) {
242
601
  case 0:
243
602
  setupRegistration(_objectSpread(_objectSpread({}, MockServiceData), {}, {
244
603
  indicator: _types.ServiceIndicator.CONTACT_CENTER
@@ -246,11 +605,11 @@ describe('Registration Tests', function () {
246
605
  jest.useFakeTimers();
247
606
  webex.request.mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload).mockResolvedValueOnce(successPayload);
248
607
  expect(reg.getStatus()).toEqual(_types.RegistrationStatus.IDLE);
249
- _context5.next = 6;
608
+ _context11.next = 6;
250
609
  return reg.triggerRegistration();
251
610
  case 6:
252
611
  jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_FOR_CC_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
253
- _context5.next = 9;
612
+ _context11.next = 9;
254
613
  return flushPromises();
255
614
  case 9:
256
615
  expect(webex.request).toBeCalledTimes(3);
@@ -267,27 +626,27 @@ describe('Registration Tests', function () {
267
626
  expect(reg.getActiveMobiusUrl()).toEqual(mobiusUris.backup[0]);
268
627
  case 14:
269
628
  case "end":
270
- return _context5.stop();
629
+ return _context11.stop();
271
630
  }
272
- }, _callee5);
631
+ }, _callee11);
273
632
  })));
274
- it('verify unreachable primary and backup servers', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
275
- return _regenerator.default.wrap(function _callee6$(_context6) {
276
- while (1) switch (_context6.prev = _context6.next) {
633
+ it('verify unreachable primary and backup servers', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12() {
634
+ return _regenerator.default.wrap(function _callee12$(_context12) {
635
+ while (1) switch (_context12.prev = _context12.next) {
277
636
  case 0:
278
637
  jest.useFakeTimers();
279
638
  // try the primary twice and register successfully with backup servers
280
639
  webex.request.mockRejectedValue(failurePayload);
281
640
  expect(reg.getStatus()).toEqual(_types.RegistrationStatus.IDLE);
282
- _context6.next = 5;
641
+ _context12.next = 5;
283
642
  return reg.triggerRegistration();
284
643
  case 5:
285
644
  jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
286
- _context6.next = 8;
645
+ _context12.next = 8;
287
646
  return flushPromises();
288
647
  case 8:
289
648
  jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
290
- _context6.next = 11;
649
+ _context12.next = 11;
291
650
  return flushPromises();
292
651
  case 11:
293
652
  /*
@@ -312,25 +671,25 @@ describe('Registration Tests', function () {
312
671
  expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
313
672
  case 17:
314
673
  case "end":
315
- return _context6.stop();
674
+ return _context12.stop();
316
675
  }
317
- }, _callee6);
676
+ }, _callee12);
318
677
  })));
319
678
  });
320
679
  describe('Registration failback tests', function () {
321
- beforeEach( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
322
- return _regenerator.default.wrap(function _callee7$(_context7) {
323
- while (1) switch (_context7.prev = _context7.next) {
680
+ beforeEach( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13() {
681
+ return _regenerator.default.wrap(function _callee13$(_context13) {
682
+ while (1) switch (_context13.prev = _context13.next) {
324
683
  case 0:
325
684
  /* keep keepalive as active so that it wont interfere with the failback tests */
326
685
  jest.spyOn(reg, 'postKeepAlive').mockResolvedValue(successPayload);
327
686
  jest.useFakeTimers();
328
687
  postRegistrationSpy.mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload).mockResolvedValueOnce(successPayload);
329
- _context7.next = 5;
688
+ _context13.next = 5;
330
689
  return reg.triggerRegistration();
331
690
  case 5:
332
691
  jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
333
- _context7.next = 8;
692
+ _context13.next = 8;
334
693
  return flushPromises();
335
694
  case 8:
336
695
  reg.rehomingIntervalMin = _constants.DEFAULT_REHOMING_INTERVAL_MIN;
@@ -344,17 +703,17 @@ describe('Registration Tests', function () {
344
703
  expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
345
704
  case 13:
346
705
  case "end":
347
- return _context7.stop();
706
+ return _context13.stop();
348
707
  }
349
- }, _callee7);
708
+ }, _callee13);
350
709
  })));
351
710
  afterEach(function () {
352
711
  jest.clearAllTimers();
353
712
  jest.clearAllMocks();
354
713
  });
355
- it('verify 429 error with failback to primary after initial registration with backup: Restore failure', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
356
- return _regenerator.default.wrap(function _callee8$(_context8) {
357
- while (1) switch (_context8.prev = _context8.next) {
714
+ 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() {
715
+ return _regenerator.default.wrap(function _callee14$(_context14) {
716
+ while (1) switch (_context14.prev = _context14.next) {
358
717
  case 0:
359
718
  // delete should be successful
360
719
  global.fetch = jest.fn(function () {
@@ -364,61 +723,66 @@ describe('Registration Tests', function () {
364
723
  }
365
724
  });
366
725
  });
367
- postRegistrationSpy.mockRejectedValue(failurePayload429);
726
+ postRegistrationSpy.mockRejectedValue(failurePayload429Two);
368
727
 
369
728
  /* Wait for failback to be triggered. */
370
729
  jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
371
- _context8.next = 5;
730
+ _context14.next = 5;
372
731
  return flushPromises();
373
732
  case 5:
374
- expect(logSpy).toBeCalledWith("Attempting failback to primary.", {
733
+ expect(infoSpy).toBeCalledWith("Attempting failback to primary.", {
375
734
  method: 'executeFailback',
376
735
  file: _constants.REGISTRATION_FILE
377
736
  });
378
- expect(failbackRetry429Spy).toBeCalledOnceWith();
737
+ jest.advanceTimersByTime(10000);
738
+ _context14.next = 9;
739
+ return flushPromises();
740
+ case 9:
741
+ expect(retry429Spy).toBeCalledWith(failurePayload429Two.headers['retry-after'], 'executeFailback');
379
742
  expect(reg.failback429RetryAttempts).toBe(0);
380
743
  expect(reg.getStatus()).toBe(_types.RegistrationStatus.INACTIVE);
381
- expect(restoreSpy).toBeCalledOnceWith(_constants.FAILBACK_429_RETRY_UTIL);
382
- expect(restartSpy).toBeCalledOnceWith(_constants.FAILBACK_429_RETRY_UTIL);
744
+ expect(restoreSpy).toBeCalledOnceWith(_constants.REG_429_RETRY_UTIL);
745
+ expect(restartSpy).toBeCalledOnceWith(_constants.REG_429_RETRY_UTIL);
383
746
  expect(reg.failbackTimer).toBe(undefined);
384
747
  expect(reg.rehomingIntervalMin).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MIN);
385
748
  expect(reg.rehomingIntervalMax).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MAX);
386
- case 14:
749
+ case 17:
387
750
  case "end":
388
- return _context8.stop();
751
+ return _context14.stop();
389
752
  }
390
- }, _callee8);
753
+ }, _callee14);
391
754
  })));
392
- it('verify unsuccessful failback to primary after initial registration with backup: Restore failure', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9() {
393
- return _regenerator.default.wrap(function _callee9$(_context9) {
394
- while (1) switch (_context9.prev = _context9.next) {
755
+ it('verify unsuccessful failback to primary after initial registration with backup: Restore failure', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15() {
756
+ return _regenerator.default.wrap(function _callee15$(_context15) {
757
+ while (1) switch (_context15.prev = _context15.next) {
395
758
  case 0:
396
759
  postRegistrationSpy.mockRejectedValue(failurePayload);
397
760
 
398
761
  /* Wait for failback to be triggered. */
399
762
  jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
400
- _context9.next = 4;
763
+ _context15.next = 4;
401
764
  return flushPromises();
402
765
  case 4:
403
- expect(logSpy).toBeCalledWith("Attempting failback to primary.", {
766
+ expect(infoSpy).toBeCalledWith("Attempting failback to primary.", {
404
767
  method: 'executeFailback',
405
768
  file: _constants.REGISTRATION_FILE
406
769
  });
407
770
  expect(reg.getStatus()).toBe(_types.RegistrationStatus.INACTIVE);
408
771
  expect(restoreSpy).toBeCalledOnceWith(_constants.FAILBACK_UTIL);
772
+ expect(reg.getStatus()).toBe(_types.RegistrationStatus.INACTIVE);
409
773
  expect(restartSpy).toBeCalledOnceWith(_constants.FAILBACK_UTIL);
410
774
  expect(reg.rehomingIntervalMin).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MIN);
411
775
  expect(reg.rehomingIntervalMax).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MAX);
412
- case 10:
776
+ case 11:
413
777
  case "end":
414
- return _context9.stop();
778
+ return _context15.stop();
415
779
  }
416
- }, _callee9);
780
+ }, _callee15);
417
781
  })));
418
- 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 _callee10() {
782
+ 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() {
419
783
  var finalErrorPayload;
420
- return _regenerator.default.wrap(function _callee10$(_context10) {
421
- while (1) switch (_context10.prev = _context10.next) {
784
+ return _regenerator.default.wrap(function _callee16$(_context16) {
785
+ while (1) switch (_context16.prev = _context16.next) {
422
786
  case 0:
423
787
  finalErrorPayload = {
424
788
  statusCode: 401,
@@ -428,10 +792,10 @@ describe('Registration Tests', function () {
428
792
  postRegistrationSpy.mockRejectedValue(finalErrorPayload).mockRejectedValueOnce(failurePayload);
429
793
  /* Wait for failback to be triggered. */
430
794
  jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
431
- _context10.next = 6;
795
+ _context16.next = 6;
432
796
  return flushPromises();
433
797
  case 6:
434
- expect(logSpy).toBeCalledWith("Attempting failback to primary.", {
798
+ expect(infoSpy).toBeCalledWith("Attempting failback to primary.", {
435
799
  method: 'executeFailback',
436
800
  file: _constants.REGISTRATION_FILE
437
801
  });
@@ -443,22 +807,22 @@ describe('Registration Tests', function () {
443
807
  expect(reg.rehomingIntervalMax).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MAX);
444
808
  case 13:
445
809
  case "end":
446
- return _context10.stop();
810
+ return _context16.stop();
447
811
  }
448
- }, _callee10);
812
+ }, _callee16);
449
813
  })));
450
- it('verify unsuccessful failback to primary after initial registration with backup: Restore success', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11() {
451
- return _regenerator.default.wrap(function _callee11$(_context11) {
452
- while (1) switch (_context11.prev = _context11.next) {
814
+ it('verify unsuccessful failback to primary after initial registration with backup: Restore success', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee17() {
815
+ return _regenerator.default.wrap(function _callee17$(_context17) {
816
+ while (1) switch (_context17.prev = _context17.next) {
453
817
  case 0:
454
818
  postRegistrationSpy.mockRejectedValueOnce(failurePayload).mockResolvedValue(successPayload);
455
819
 
456
820
  /* Wait for failback to be triggered. */
457
821
  jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
458
- _context11.next = 4;
822
+ _context17.next = 4;
459
823
  return flushPromises();
460
824
  case 4:
461
- expect(logSpy).toBeCalledWith("Attempting failback to primary.", {
825
+ expect(infoSpy).toBeCalledWith("Attempting failback to primary.", {
462
826
  method: 'executeFailback',
463
827
  file: _constants.REGISTRATION_FILE
464
828
  });
@@ -471,22 +835,22 @@ describe('Registration Tests', function () {
471
835
  expect(reg.rehomingIntervalMax).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MAX);
472
836
  case 11:
473
837
  case "end":
474
- return _context11.stop();
838
+ return _context17.stop();
475
839
  }
476
- }, _callee11);
840
+ }, _callee17);
477
841
  })));
478
- it('verify successful failback to primary after initial registration with backup', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12() {
479
- return _regenerator.default.wrap(function _callee12$(_context12) {
480
- while (1) switch (_context12.prev = _context12.next) {
842
+ it('verify successful failback to primary after initial registration with backup', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee18() {
843
+ return _regenerator.default.wrap(function _callee18$(_context18) {
844
+ while (1) switch (_context18.prev = _context18.next) {
481
845
  case 0:
482
846
  postRegistrationSpy.mockResolvedValue(successPayload);
483
847
 
484
848
  /* Wait for failback to be triggered. */
485
849
  jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
486
- _context12.next = 4;
850
+ _context18.next = 4;
487
851
  return flushPromises();
488
852
  case 4:
489
- expect(logSpy).toBeCalledWith("Attempting failback to primary.", {
853
+ expect(infoSpy).toBeCalledWith("Attempting failback to primary.", {
490
854
  method: 'executeFailback',
491
855
  file: _constants.REGISTRATION_FILE
492
856
  });
@@ -500,13 +864,13 @@ describe('Registration Tests', function () {
500
864
  expect(reg.rehomingIntervalMax).toBe(_registerFixtures.mockPostResponse.rehomingIntervalMax);
501
865
  case 11:
502
866
  case "end":
503
- return _context12.stop();
867
+ return _context18.stop();
504
868
  }
505
- }, _callee12);
869
+ }, _callee18);
506
870
  })));
507
- it('verify unsuccessful failback attempt due to active call', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13() {
508
- return _regenerator.default.wrap(function _callee13$(_context13) {
509
- while (1) switch (_context13.prev = _context13.next) {
871
+ it('verify unsuccessful failback attempt due to active call', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee19() {
872
+ return _regenerator.default.wrap(function _callee19$(_context19) {
873
+ while (1) switch (_context19.prev = _context19.next) {
510
874
  case 0:
511
875
  /** create a new call */
512
876
  reg.callManager.createCall();
@@ -515,10 +879,10 @@ describe('Registration Tests', function () {
515
879
 
516
880
  /* Wait for failback to be triggered. */
517
881
  jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
518
- _context13.next = 6;
882
+ _context19.next = 6;
519
883
  return flushPromises();
520
884
  case 6:
521
- expect(logSpy).toBeCalledWith("Active calls present, deferring failback to next cycle.", {
885
+ expect(infoSpy).toBeCalledWith("Active calls present, deferring failback to next cycle.", {
522
886
  method: 'executeFailback',
523
887
  file: _constants.REGISTRATION_FILE
524
888
  });
@@ -528,7 +892,7 @@ describe('Registration Tests', function () {
528
892
  expect(reg.getStatus()).toBe(_types.RegistrationStatus.ACTIVE);
529
893
  expect(restoreSpy).not.toBeCalled();
530
894
  expect(restartSpy).not.toBeCalled();
531
- expect(logSpy).toBeCalledWith('Active calls present, deferring failback to next cycle.', {
895
+ expect(infoSpy).toBeCalledWith('Active calls present, deferring failback to next cycle.', {
532
896
  file: _constants.REGISTRATION_FILE,
533
897
  method: _constants.FAILBACK_UTIL
534
898
  });
@@ -536,9 +900,9 @@ describe('Registration Tests', function () {
536
900
  expect(reg.rehomingIntervalMax).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MAX);
537
901
  case 14:
538
902
  case "end":
539
- return _context13.stop();
903
+ return _context19.stop();
540
904
  }
541
- }, _callee13);
905
+ }, _callee19);
542
906
  })));
543
907
  });
544
908
 
@@ -552,24 +916,24 @@ describe('Registration Tests', function () {
552
916
  device: _registerFixtures.mockPostResponse.device
553
917
  };
554
918
  var beforeEachSetupForKeepalive = /*#__PURE__*/function () {
555
- var _ref14 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14() {
556
- return _regenerator.default.wrap(function _callee14$(_context14) {
557
- while (1) switch (_context14.prev = _context14.next) {
919
+ var _ref20 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee20() {
920
+ return _regenerator.default.wrap(function _callee20$(_context20) {
921
+ while (1) switch (_context20.prev = _context20.next) {
558
922
  case 0:
559
923
  postRegistrationSpy.mockResolvedValueOnce(successPayload);
560
924
  jest.useFakeTimers();
561
- _context14.next = 4;
925
+ _context20.next = 4;
562
926
  return reg.triggerRegistration();
563
927
  case 4:
564
928
  expect(reg.getStatus()).toBe(_types.RegistrationStatus.ACTIVE);
565
929
  case 5:
566
930
  case "end":
567
- return _context14.stop();
931
+ return _context20.stop();
568
932
  }
569
- }, _callee14);
933
+ }, _callee20);
570
934
  }));
571
935
  return function beforeEachSetupForKeepalive() {
572
- return _ref14.apply(this, arguments);
936
+ return _ref20.apply(this, arguments);
573
937
  };
574
938
  }();
575
939
  afterEach(function () {
@@ -585,12 +949,12 @@ describe('Registration Tests', function () {
585
949
  call.end();
586
950
  });
587
951
  });
588
- it('verify successful keep-alive cases', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15() {
952
+ it('verify successful keep-alive cases', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee21() {
589
953
  var keepAlivePayload, funcSpy;
590
- return _regenerator.default.wrap(function _callee15$(_context15) {
591
- while (1) switch (_context15.prev = _context15.next) {
954
+ return _regenerator.default.wrap(function _callee21$(_context21) {
955
+ while (1) switch (_context21.prev = _context21.next) {
592
956
  case 0:
593
- _context15.next = 2;
957
+ _context21.next = 2;
594
958
  return beforeEachSetupForKeepalive();
595
959
  case 2:
596
960
  keepAlivePayload = {
@@ -600,23 +964,25 @@ describe('Registration Tests', function () {
600
964
  webex.request.mockReturnValue(keepAlivePayload);
601
965
  funcSpy = jest.spyOn(reg, 'postKeepAlive');
602
966
  jest.advanceTimersByTime(2 * _registerFixtures.mockPostResponse.keepaliveInterval * _constants.SEC_TO_MSEC_MFACTOR);
603
- _context15.next = 8;
967
+ _context21.next = 8;
604
968
  return flushPromises();
605
969
  case 8:
606
970
  expect(funcSpy).toBeCalledTimes(2); // should be called 2 times: first try and after the interval.
607
- expect(logSpy).lastCalledWith('Sent Keepalive, status: 200', logObj);
608
- case 10:
971
+
972
+ expect(logSpy).toBeCalledWith('Sent Keepalive, status: 200', logObj);
973
+ expect(infoSpy).not.toBeCalledWith('Sent Keepalive, status: 200', logObj);
974
+ case 11:
609
975
  case "end":
610
- return _context15.stop();
976
+ return _context21.stop();
611
977
  }
612
- }, _callee15);
978
+ }, _callee21);
613
979
  })));
614
- it('verify failure keep-alive cases: Retry Success', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee16() {
980
+ it('verify failure keep-alive cases: Retry Success', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee22() {
615
981
  var failurePayload, successPayload, timer;
616
- return _regenerator.default.wrap(function _callee16$(_context16) {
617
- while (1) switch (_context16.prev = _context16.next) {
982
+ return _regenerator.default.wrap(function _callee22$(_context22) {
983
+ while (1) switch (_context22.prev = _context22.next) {
618
984
  case 0:
619
- _context16.next = 2;
985
+ _context22.next = 2;
620
986
  return beforeEachSetupForKeepalive();
621
987
  case 2:
622
988
  failurePayload = {
@@ -631,7 +997,7 @@ describe('Registration Tests', function () {
631
997
  lineEmitter.mockClear();
632
998
  webex.request.mockRejectedValueOnce(failurePayload).mockResolvedValue(successPayload);
633
999
  jest.advanceTimersByTime(2 * _registerFixtures.mockPostResponse.keepaliveInterval * _constants.SEC_TO_MSEC_MFACTOR);
634
- _context16.next = 10;
1000
+ _context22.next = 10;
635
1001
  return flushPromises();
636
1002
  case 10:
637
1003
  expect(handleErrorSpy).toBeCalledOnceWith(failurePayload, expect.anything(), {
@@ -645,16 +1011,16 @@ describe('Registration Tests', function () {
645
1011
  expect(lineEmitter).toBeCalledTimes(2);
646
1012
  case 16:
647
1013
  case "end":
648
- return _context16.stop();
1014
+ return _context22.stop();
649
1015
  }
650
- }, _callee16);
1016
+ }, _callee22);
651
1017
  })));
652
- it('verify failure keep-alive cases: Restore failure', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee17() {
1018
+ it('verify failure keep-alive cases: Restore failure', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee23() {
653
1019
  var restoreSpy, restartRegSpy, reconnectSpy, failurePayload, clearIntervalSpy, timer;
654
- return _regenerator.default.wrap(function _callee17$(_context17) {
655
- while (1) switch (_context17.prev = _context17.next) {
1020
+ return _regenerator.default.wrap(function _callee23$(_context23) {
1021
+ while (1) switch (_context23.prev = _context23.next) {
656
1022
  case 0:
657
- _context17.next = 2;
1023
+ _context23.next = 2;
658
1024
  return beforeEachSetupForKeepalive();
659
1025
  case 2:
660
1026
  restoreSpy = jest.spyOn(reg, 'restorePreviousRegistration');
@@ -670,7 +1036,7 @@ describe('Registration Tests', function () {
670
1036
  expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
671
1037
  timer = reg.keepaliveTimer;
672
1038
  jest.advanceTimersByTime(5 * _registerFixtures.mockPostResponse.keepaliveInterval * _constants.SEC_TO_MSEC_MFACTOR);
673
- _context17.next = 14;
1039
+ _context23.next = 14;
674
1040
  return flushPromises();
675
1041
  case 14:
676
1042
  expect(clearIntervalSpy).toBeCalledOnceWith(timer);
@@ -683,8 +1049,16 @@ describe('Registration Tests', function () {
683
1049
  expect(reconnectSpy).toBeCalledOnceWith(_constants.KEEPALIVE_UTIL);
684
1050
  expect(restoreSpy).toBeCalledOnceWith(_constants.KEEPALIVE_UTIL);
685
1051
  expect(restartRegSpy).toBeCalledOnceWith(_constants.KEEPALIVE_UTIL);
1052
+ expect(warnSpy).toHaveBeenCalledWith('Keep-alive missed 1 times. Status -> 503 ', expect.objectContaining({
1053
+ file: _constants.REGISTRATION_FILE,
1054
+ method: 'startKeepaliveTimer'
1055
+ }));
686
1056
  expect(webex.request).toBeCalledTimes(7);
687
1057
  expect(reg.keepaliveTimer).toBe(undefined);
1058
+ expect(warnSpy).toHaveBeenCalledWith('Keep-alive missed 1 times. Status -> 503 ', expect.objectContaining({
1059
+ file: _constants.REGISTRATION_FILE,
1060
+ method: 'startKeepaliveTimer'
1061
+ }));
688
1062
  expect(lineEmitter).nthCalledWith(1, _types4.LINE_EVENTS.RECONNECTING);
689
1063
  expect(lineEmitter).nthCalledWith(4, _types4.LINE_EVENTS.RECONNECTING);
690
1064
  expect(lineEmitter).nthCalledWith(5, _types4.LINE_EVENTS.UNREGISTERED);
@@ -695,18 +1069,18 @@ describe('Registration Tests', function () {
695
1069
  expect(lineEmitter).nthCalledWith(8, _types4.LINE_EVENTS.CONNECTING);
696
1070
  expect(lineEmitter).nthCalledWith(9, _types4.LINE_EVENTS.UNREGISTERED);
697
1071
  expect(lineEmitter).toBeCalledTimes(9);
698
- case 31:
1072
+ case 33:
699
1073
  case "end":
700
- return _context17.stop();
1074
+ return _context23.stop();
701
1075
  }
702
- }, _callee17);
1076
+ }, _callee23);
703
1077
  })));
704
- it('verify failure keep-alive cases: Restore Success', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee18() {
1078
+ it('verify failure keep-alive cases: Restore Success', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee24() {
705
1079
  var restoreSpy, restartRegSpy, reconnectSpy, failurePayload, successPayload, clearIntervalSpy, url, timer;
706
- return _regenerator.default.wrap(function _callee18$(_context18) {
707
- while (1) switch (_context18.prev = _context18.next) {
1080
+ return _regenerator.default.wrap(function _callee24$(_context24) {
1081
+ while (1) switch (_context24.prev = _context24.next) {
708
1082
  case 0:
709
- _context18.next = 2;
1083
+ _context24.next = 2;
710
1084
  return beforeEachSetupForKeepalive();
711
1085
  case 2:
712
1086
  restoreSpy = jest.spyOn(reg, 'restorePreviousRegistration');
@@ -732,7 +1106,7 @@ describe('Registration Tests', function () {
732
1106
  reg.setActiveMobiusUrl(url);
733
1107
  timer = reg.keepaliveTimer;
734
1108
  jest.advanceTimersByTime(5 * _registerFixtures.mockPostResponse.keepaliveInterval * _constants.SEC_TO_MSEC_MFACTOR);
735
- _context18.next = 16;
1109
+ _context24.next = 16;
736
1110
  return flushPromises();
737
1111
  case 16:
738
1112
  expect(clearIntervalSpy).toBeCalledOnceWith(timer);
@@ -747,16 +1121,16 @@ describe('Registration Tests', function () {
747
1121
  expect(reg.keepaliveTimer).not.toBe(timer);
748
1122
  case 26:
749
1123
  case "end":
750
- return _context18.stop();
1124
+ return _context24.stop();
751
1125
  }
752
- }, _callee18);
1126
+ }, _callee24);
753
1127
  })));
754
- it('verify failure followed by recovery of keepalive', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee19() {
1128
+ it('verify failure followed by recovery of keepalive', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee25() {
755
1129
  var failurePayload, successPayload, clearIntervalSpy, timer;
756
- return _regenerator.default.wrap(function _callee19$(_context19) {
757
- while (1) switch (_context19.prev = _context19.next) {
1130
+ return _regenerator.default.wrap(function _callee25$(_context25) {
1131
+ while (1) switch (_context25.prev = _context25.next) {
758
1132
  case 0:
759
- _context19.next = 2;
1133
+ _context25.next = 2;
760
1134
  return beforeEachSetupForKeepalive();
761
1135
  case 2:
762
1136
  failurePayload = {
@@ -772,7 +1146,7 @@ describe('Registration Tests', function () {
772
1146
  expect(reg.getStatus()).toBe(_types.RegistrationStatus.ACTIVE);
773
1147
  timer = reg.keepaliveTimer; // sendKeepAlive tries to retry 3 times and receiving success on third time
774
1148
  jest.advanceTimersByTime(3 * _registerFixtures.mockPostResponse.keepaliveInterval * _constants.SEC_TO_MSEC_MFACTOR);
775
- _context19.next = 11;
1149
+ _context25.next = 11;
776
1150
  return flushPromises();
777
1151
  case 11:
778
1152
  expect(webex.request).toBeCalledTimes(3);
@@ -782,20 +1156,20 @@ describe('Registration Tests', function () {
782
1156
  expect(reg.keepaliveTimer).toBe(timer);
783
1157
  case 16:
784
1158
  case "end":
785
- return _context19.stop();
1159
+ return _context25.stop();
786
1160
  }
787
- }, _callee19);
1161
+ }, _callee25);
788
1162
  })));
789
- it('cc: verify failover to backup server after 4 keep alive failure with primary server', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee20() {
1163
+ 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() {
790
1164
  var failurePayload, successPayload, clearIntervalSpy, timer;
791
- return _regenerator.default.wrap(function _callee20$(_context20) {
792
- while (1) switch (_context20.prev = _context20.next) {
1165
+ return _regenerator.default.wrap(function _callee26$(_context26) {
1166
+ while (1) switch (_context26.prev = _context26.next) {
793
1167
  case 0:
794
1168
  // Register with contact center service
795
1169
  setupRegistration(_objectSpread(_objectSpread({}, MockServiceData), {}, {
796
1170
  indicator: _types.ServiceIndicator.CONTACT_CENTER
797
1171
  }));
798
- _context20.next = 3;
1172
+ _context26.next = 3;
799
1173
  return beforeEachSetupForKeepalive();
800
1174
  case 3:
801
1175
  failurePayload = {
@@ -811,7 +1185,7 @@ describe('Registration Tests', function () {
811
1185
  expect(reg.getStatus()).toBe(_types.RegistrationStatus.ACTIVE);
812
1186
  timer = reg.keepaliveTimer;
813
1187
  jest.advanceTimersByTime(5 * _registerFixtures.mockPostResponse.keepaliveInterval * _constants.SEC_TO_MSEC_MFACTOR);
814
- _context20.next = 12;
1188
+ _context26.next = 12;
815
1189
  return flushPromises();
816
1190
  case 12:
817
1191
  expect(clearIntervalSpy).toBeCalledOnceWith(timer);
@@ -819,7 +1193,7 @@ describe('Registration Tests', function () {
819
1193
  expect(reg.keepaliveTimer).not.toBe(timer);
820
1194
  webex.request.mockResolvedValue(successPayload);
821
1195
  jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_FOR_CC_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
822
- _context20.next = 19;
1196
+ _context26.next = 19;
823
1197
  return flushPromises();
824
1198
  case 19:
825
1199
  /* Active Url must match with the backup url as per the test */
@@ -827,16 +1201,16 @@ describe('Registration Tests', function () {
827
1201
  expect(reg.getStatus()).toBe(_types.RegistrationStatus.ACTIVE);
828
1202
  case 21:
829
1203
  case "end":
830
- return _context20.stop();
1204
+ return _context26.stop();
831
1205
  }
832
- }, _callee20);
1206
+ }, _callee26);
833
1207
  })));
834
- it('verify final error for keep-alive', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee21() {
1208
+ it('verify final error for keep-alive', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee27() {
835
1209
  var restoreSpy, restartRegSpy, reconnectSpy, failurePayload, clearIntervalSpy;
836
- return _regenerator.default.wrap(function _callee21$(_context21) {
837
- while (1) switch (_context21.prev = _context21.next) {
1210
+ return _regenerator.default.wrap(function _callee27$(_context27) {
1211
+ while (1) switch (_context27.prev = _context27.next) {
838
1212
  case 0:
839
- _context21.next = 2;
1213
+ _context27.next = 2;
840
1214
  return beforeEachSetupForKeepalive();
841
1215
  case 2:
842
1216
  restoreSpy = jest.spyOn(reg, 'restorePreviousRegistration');
@@ -852,7 +1226,7 @@ describe('Registration Tests', function () {
852
1226
 
853
1227
  /* send one keepalive */
854
1228
  jest.advanceTimersByTime(_registerFixtures.mockPostResponse.keepaliveInterval * _constants.SEC_TO_MSEC_MFACTOR);
855
- _context21.next = 12;
1229
+ _context27.next = 12;
856
1230
  return flushPromises();
857
1231
  case 12:
858
1232
  expect(clearIntervalSpy).toBeCalledTimes(1);
@@ -872,18 +1246,22 @@ describe('Registration Tests', function () {
872
1246
  file: _constants.REGISTRATION_FILE,
873
1247
  method: _constants.KEEPALIVE_UTIL
874
1248
  });
875
- case 21:
1249
+ expect(warnSpy).toBeCalledWith('Keep-alive missed 1 times. Status -> 404 ', expect.objectContaining({
1250
+ file: _constants.REGISTRATION_FILE,
1251
+ method: 'startKeepaliveTimer'
1252
+ }));
1253
+ case 22:
876
1254
  case "end":
877
- return _context21.stop();
1255
+ return _context27.stop();
878
1256
  }
879
- }, _callee21);
1257
+ }, _callee27);
880
1258
  })));
881
- it('verify failure keep-alive case with active call present: Restore Success after call ends', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee22() {
1259
+ it('verify failure keep-alive case with active call present: Restore Success after call ends', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee28() {
882
1260
  var restoreSpy, restartRegSpy, reconnectSpy, failurePayload, successPayload, clearIntervalSpy, url, timer, call;
883
- return _regenerator.default.wrap(function _callee22$(_context22) {
884
- while (1) switch (_context22.prev = _context22.next) {
1261
+ return _regenerator.default.wrap(function _callee28$(_context28) {
1262
+ while (1) switch (_context28.prev = _context28.next) {
885
1263
  case 0:
886
- _context22.next = 2;
1264
+ _context28.next = 2;
887
1265
  return beforeEachSetupForKeepalive();
888
1266
  case 2:
889
1267
  restoreSpy = jest.spyOn(reg, 'restorePreviousRegistration');
@@ -912,7 +1290,7 @@ describe('Registration Tests', function () {
912
1290
 
913
1291
  /* send one keepalive */
914
1292
  jest.advanceTimersByTime(5 * _registerFixtures.mockPostResponse.keepaliveInterval * _constants.SEC_TO_MSEC_MFACTOR);
915
- _context22.next = 18;
1293
+ _context28.next = 18;
916
1294
  return flushPromises();
917
1295
  case 18:
918
1296
  expect(clearIntervalSpy).toBeCalledOnceWith(timer);
@@ -925,7 +1303,7 @@ describe('Registration Tests', function () {
925
1303
  expect(restoreSpy).not.toBeCalled();
926
1304
  expect(restartRegSpy).not.toBeCalled();
927
1305
  expect(reg.reconnectPending).toStrictEqual(true);
928
- expect(logSpy).toBeCalledWith('Active call(s) present, deferred reconnect till call cleanup.', {
1306
+ expect(infoSpy).toBeCalledWith('Active call(s) present, deferred reconnect till call cleanup.', {
929
1307
  file: _constants.REGISTRATION_FILE,
930
1308
  method: expect.any(String)
931
1309
  });
@@ -933,7 +1311,7 @@ describe('Registration Tests', function () {
933
1311
 
934
1312
  /* simulate call disconnect and Calling client will trigger reconnect upon receiving disconnect event from CallManager */
935
1313
  reg.callManager.callCollection = {};
936
- _context22.next = 33;
1314
+ _context28.next = 33;
937
1315
  return reg.reconnectOnFailure(_constants.CALLS_CLEARED_HANDLER_UTIL);
938
1316
  case 33:
939
1317
  expect((0, _keys.default)(reg.callManager.getActiveCalls()).length).toBe(0);
@@ -947,9 +1325,9 @@ describe('Registration Tests', function () {
947
1325
  expect(reg.keepaliveTimer).not.toBe(timer);
948
1326
  case 42:
949
1327
  case "end":
950
- return _context22.stop();
1328
+ return _context28.stop();
951
1329
  }
952
- }, _callee22);
1330
+ }, _callee28);
953
1331
  })));
954
1332
  });
955
1333
  });