@webex/calling 3.10.0-next.13 → 3.10.0-next.15

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 (95) hide show
  1. package/dist/CallHistory/CallHistory.js +118 -124
  2. package/dist/CallHistory/CallHistory.js.map +1 -1
  3. package/dist/CallHistory/CallHistory.test.js +189 -201
  4. package/dist/CallHistory/CallHistory.test.js.map +1 -1
  5. package/dist/CallSettings/CallSettings.js +17 -18
  6. package/dist/CallSettings/CallSettings.js.map +1 -1
  7. package/dist/CallSettings/CallSettings.test.js +14 -14
  8. package/dist/CallSettings/CallSettings.test.js.map +1 -1
  9. package/dist/CallSettings/UcmBackendConnector.js +71 -24
  10. package/dist/CallSettings/UcmBackendConnector.js.map +1 -1
  11. package/dist/CallSettings/UcmBackendConnector.test.js +136 -47
  12. package/dist/CallSettings/UcmBackendConnector.test.js.map +1 -1
  13. package/dist/CallSettings/WxCallBackendConnector.js +135 -137
  14. package/dist/CallSettings/WxCallBackendConnector.js.map +1 -1
  15. package/dist/CallSettings/WxCallBackendConnector.test.js +145 -149
  16. package/dist/CallSettings/WxCallBackendConnector.test.js.map +1 -1
  17. package/dist/CallingClient/CallingClient.js +198 -201
  18. package/dist/CallingClient/CallingClient.js.map +1 -1
  19. package/dist/CallingClient/CallingClient.test.js +168 -168
  20. package/dist/CallingClient/CallingClient.test.js.map +1 -1
  21. package/dist/CallingClient/calling/CallerId/index.js +7 -8
  22. package/dist/CallingClient/calling/CallerId/index.js.map +1 -1
  23. package/dist/CallingClient/calling/CallerId/index.test.js +24 -24
  24. package/dist/CallingClient/calling/CallerId/index.test.js.map +1 -1
  25. package/dist/CallingClient/calling/call.js +364 -366
  26. package/dist/CallingClient/calling/call.js.map +1 -1
  27. package/dist/CallingClient/calling/call.test.js +340 -340
  28. package/dist/CallingClient/calling/call.test.js.map +1 -1
  29. package/dist/CallingClient/calling/callManager.js +15 -18
  30. package/dist/CallingClient/calling/callManager.js.map +1 -1
  31. package/dist/CallingClient/calling/callManager.test.js +113 -113
  32. package/dist/CallingClient/calling/callManager.test.js.map +1 -1
  33. package/dist/CallingClient/line/index.js +57 -74
  34. package/dist/CallingClient/line/index.js.map +1 -1
  35. package/dist/CallingClient/line/line.test.js +22 -22
  36. package/dist/CallingClient/line/line.test.js.map +1 -1
  37. package/dist/CallingClient/registration/register.js +293 -300
  38. package/dist/CallingClient/registration/register.js.map +1 -1
  39. package/dist/CallingClient/registration/register.test.js +246 -246
  40. package/dist/CallingClient/registration/register.test.js.map +1 -1
  41. package/dist/CallingClient/registration/webWorker.js +24 -24
  42. package/dist/CallingClient/registration/webWorker.js.map +1 -1
  43. package/dist/CallingClient/registration/webWorker.test.js +20 -20
  44. package/dist/CallingClient/registration/webWorker.test.js.map +1 -1
  45. package/dist/CallingClient/windowsChromiumIceWarmupUtils.js +28 -28
  46. package/dist/CallingClient/windowsChromiumIceWarmupUtils.js.map +1 -1
  47. package/dist/Contacts/ContactsClient.js +250 -253
  48. package/dist/Contacts/ContactsClient.js.map +1 -1
  49. package/dist/Contacts/ContactsClient.test.js +60 -60
  50. package/dist/Contacts/ContactsClient.test.js.map +1 -1
  51. package/dist/Errors/catalog/CallError.js +7 -10
  52. package/dist/Errors/catalog/CallError.js.map +1 -1
  53. package/dist/Errors/catalog/CallingDeviceError.js +6 -9
  54. package/dist/Errors/catalog/CallingDeviceError.js.map +1 -1
  55. package/dist/Errors/catalog/ExtendedError.js +6 -8
  56. package/dist/Errors/catalog/ExtendedError.js.map +1 -1
  57. package/dist/Errors/catalog/LineError.js +6 -9
  58. package/dist/Errors/catalog/LineError.js.map +1 -1
  59. package/dist/Events/impl/index.js +11 -13
  60. package/dist/Events/impl/index.js.map +1 -1
  61. package/dist/Metrics/index.js +1 -2
  62. package/dist/Metrics/index.js.map +1 -1
  63. package/dist/SDKConnector/index.js +1 -2
  64. package/dist/SDKConnector/index.js.map +1 -1
  65. package/dist/Voicemail/BroadworksBackendConnector.js +126 -127
  66. package/dist/Voicemail/BroadworksBackendConnector.js.map +1 -1
  67. package/dist/Voicemail/BroadworksBackendConnector.test.js +98 -98
  68. package/dist/Voicemail/BroadworksBackendConnector.test.js.map +1 -1
  69. package/dist/Voicemail/UcmBackendConnector.js +84 -85
  70. package/dist/Voicemail/UcmBackendConnector.js.map +1 -1
  71. package/dist/Voicemail/UcmBackendConnector.test.js +72 -72
  72. package/dist/Voicemail/UcmBackendConnector.test.js.map +1 -1
  73. package/dist/Voicemail/Voicemail.js +58 -61
  74. package/dist/Voicemail/Voicemail.js.map +1 -1
  75. package/dist/Voicemail/Voicemail.test.js +20 -20
  76. package/dist/Voicemail/Voicemail.test.js.map +1 -1
  77. package/dist/Voicemail/WxCallBackendConnector.js +116 -117
  78. package/dist/Voicemail/WxCallBackendConnector.js.map +1 -1
  79. package/dist/Voicemail/WxCallBackendConnector.test.js +140 -140
  80. package/dist/Voicemail/WxCallBackendConnector.test.js.map +1 -1
  81. package/dist/common/Utils.js +168 -167
  82. package/dist/common/Utils.js.map +1 -1
  83. package/dist/common/Utils.test.js +120 -120
  84. package/dist/common/Utils.test.js.map +1 -1
  85. package/dist/common/constants.js +3 -1
  86. package/dist/common/constants.js.map +1 -1
  87. package/dist/common/testUtil.js +3 -3
  88. package/dist/common/testUtil.js.map +1 -1
  89. package/dist/module/CallSettings/UcmBackendConnector.js +20 -6
  90. package/dist/module/common/constants.js +2 -0
  91. package/dist/types/CallSettings/UcmBackendConnector.d.ts +1 -0
  92. package/dist/types/CallSettings/UcmBackendConnector.d.ts.map +1 -1
  93. package/dist/types/common/constants.d.ts +2 -0
  94. package/dist/types/common/constants.d.ts.map +1 -1
  95. package/package.json +2 -2
@@ -143,7 +143,7 @@ describe('Registration Tests', function () {
143
143
  jest.useRealTimers();
144
144
  });
145
145
  it('verify successful registration', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee() {
146
- return _regenerator.default.wrap(function _callee$(_context) {
146
+ return _regenerator.default.wrap(function (_context) {
147
147
  while (1) switch (_context.prev = _context.next) {
148
148
  case 0:
149
149
  webex.request.mockReturnValueOnce({
@@ -152,9 +152,9 @@ describe('Registration Tests', function () {
152
152
  trackingid: 'webex-js-sdk_06bafdd0-2f9b-4cd7-b438-9c0d95ecec9b_15'
153
153
  }
154
154
  });
155
- _context.next = 3;
155
+ _context.next = 1;
156
156
  return reg.triggerRegistration();
157
- case 3:
157
+ case 1:
158
158
  expect(webex.request).toBeCalledOnceWith(_objectSpread(_objectSpread({}, mockResponse), {}, {
159
159
  method: 'POST'
160
160
  }));
@@ -169,7 +169,7 @@ describe('Registration Tests', function () {
169
169
  method: 'register'
170
170
  }));
171
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);
172
- case 10:
172
+ case 2:
173
173
  case "end":
174
174
  return _context.stop();
175
175
  }
@@ -177,7 +177,7 @@ describe('Registration Tests', function () {
177
177
  })));
178
178
  it('verify failure registration', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee2() {
179
179
  var error;
180
- return _regenerator.default.wrap(function _callee2$(_context2) {
180
+ return _regenerator.default.wrap(function (_context2) {
181
181
  while (1) switch (_context2.prev = _context2.next) {
182
182
  case 0:
183
183
  webex.request.mockRejectedValue({
@@ -185,9 +185,9 @@ describe('Registration Tests', function () {
185
185
  statusCode: 401,
186
186
  headers: {}
187
187
  });
188
- _context2.next = 3;
188
+ _context2.next = 1;
189
189
  return reg.triggerRegistration();
190
- case 3:
190
+ case 1:
191
191
  expect(webex.request).toBeCalledOnceWith(_objectSpread(_objectSpread({}, mockResponse), {}, {
192
192
  method: 'POST'
193
193
  }));
@@ -197,14 +197,14 @@ describe('Registration Tests', function () {
197
197
  expect(lineEmitter).nthCalledWith(1, _types4.LINE_EVENTS.CONNECTING);
198
198
  expect(lineEmitter).nthCalledWith(2, _types4.LINE_EVENTS.ERROR, undefined, error);
199
199
  expect(metricSpy).toBeCalledWith(_types5.METRIC_EVENT.REGISTRATION_ERROR, _types5.REG_ACTION.REGISTER, _types5.METRIC_TYPE.BEHAVIORAL, _constants.REGISTRATION_UTIL, 'PRIMARY', '', undefined, error);
200
- case 10:
200
+ case 2:
201
201
  case "end":
202
202
  return _context2.stop();
203
203
  }
204
204
  }, _callee2);
205
205
  })));
206
206
  it('verify failure registration 403-101', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee3() {
207
- return _regenerator.default.wrap(function _callee3$(_context3) {
207
+ return _regenerator.default.wrap(function (_context3) {
208
208
  while (1) switch (_context3.prev = _context3.next) {
209
209
  case 0:
210
210
  webex.request.mockRejectedValueOnce({
@@ -229,9 +229,9 @@ describe('Registration Tests', function () {
229
229
  });
230
230
  });
231
231
  expect(reg.getStatus()).toEqual(_types.RegistrationStatus.IDLE);
232
- _context3.next = 5;
232
+ _context3.next = 1;
233
233
  return reg.triggerRegistration();
234
- case 5:
234
+ case 1:
235
235
  expect(webex.request).toBeCalledTimes(2);
236
236
  expect(webex.request).toBeCalledWith(_objectSpread(_objectSpread({}, mockResponse), {}, {
237
237
  method: 'POST'
@@ -250,7 +250,7 @@ describe('Registration Tests', function () {
250
250
  expect(lineEmitter).nthCalledWith(3, _types4.LINE_EVENTS.CONNECTING);
251
251
  expect(lineEmitter).nthCalledWith(4, _types4.LINE_EVENTS.REGISTERED, _registerFixtures.mockPostResponse);
252
252
  expect(metricSpy).toBeCalledWith(_types5.METRIC_EVENT.REGISTRATION, _types5.REG_ACTION.REGISTER, _types5.METRIC_TYPE.BEHAVIORAL, _constants.REGISTRATION_UTIL, 'UNKNOWN', 'webex-js-sdk_06bafdd0-2f9b-4cd7-b438-9c0d95ecec9b_15', undefined, undefined);
253
- case 18:
253
+ case 2:
254
254
  case "end":
255
255
  return _context3.stop();
256
256
  }
@@ -270,15 +270,15 @@ describe('Registration Tests', function () {
270
270
  jest.clearAllMocks();
271
271
  });
272
272
  it('handle 429 received during initial registration failure and first attempt with primary', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee4() {
273
- return _regenerator.default.wrap(function _callee4$(_context4) {
273
+ return _regenerator.default.wrap(function (_context4) {
274
274
  while (1) switch (_context4.prev = _context4.next) {
275
275
  case 0:
276
276
  jest.useFakeTimers();
277
277
  logSpy.mockClear();
278
278
  webex.request.mockRejectedValueOnce(failurePayload429One).mockRejectedValueOnce(failurePayload429Two).mockRejectedValueOnce(failurePayload);
279
- _context4.next = 5;
279
+ _context4.next = 1;
280
280
  return reg.triggerRegistration();
281
- case 5:
281
+ case 1:
282
282
  /* Initial registration failed with 429 with higher retyrAfter, interval should be updtaed with retryAfter.
283
283
  * The first attempt to register with primary should be made after retryAfter seconds.
284
284
  */
@@ -295,9 +295,9 @@ describe('Registration Tests', function () {
295
295
  retry429Spy.mockClear();
296
296
  failoverSpy.mockClear();
297
297
  jest.advanceTimersByTime(Number(failurePayload429One.headers['retry-after']) * _constants.SEC_TO_MSEC_MFACTOR);
298
- _context4.next = 16;
298
+ _context4.next = 2;
299
299
  return flushPromises();
300
- case 16:
300
+ case 2:
301
301
  /* The first attempt to register with primary failed with 429 with lower retryAfter, interval should remain the same.
302
302
  * The second attempt to register with primary will be scheduled as per the interval calculated.
303
303
  */
@@ -312,9 +312,9 @@ describe('Registration Tests', function () {
312
312
  retry429Spy.mockClear();
313
313
  failoverSpy.mockClear();
314
314
  jest.advanceTimersByTime(43 * _constants.SEC_TO_MSEC_MFACTOR);
315
- _context4.next = 25;
315
+ _context4.next = 3;
316
316
  return flushPromises();
317
- case 25:
317
+ case 3:
318
318
  /* The second attempt to register with primary failed with 500, the retryAfter should be undefined.
319
319
  * The third attempt to register with primary will be scheduled as per the interval calculated.
320
320
  */
@@ -325,23 +325,23 @@ describe('Registration Tests', function () {
325
325
  expect(retry429Spy).not.toBeCalled();
326
326
  expect(reg.retryAfter).toEqual(undefined);
327
327
  expect(failoverSpy).toBeCalledOnceWith(3, 85);
328
- case 29:
328
+ case 4:
329
329
  case "end":
330
330
  return _context4.stop();
331
331
  }
332
332
  }, _callee4);
333
333
  })));
334
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() {
335
- return _regenerator.default.wrap(function _callee5$(_context5) {
335
+ return _regenerator.default.wrap(function (_context5) {
336
336
  while (1) switch (_context5.prev = _context5.next) {
337
337
  case 0:
338
338
  reg.isCCFlow = true;
339
339
  jest.spyOn(reg, 'getRegRetryInterval').mockReturnValueOnce(33).mockReturnValueOnce(40).mockReturnValueOnce(47).mockReturnValueOnce(52);
340
340
  jest.useFakeTimers();
341
341
  webex.request.mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload429One).mockResolvedValueOnce(successPayload);
342
- _context5.next = 6;
342
+ _context5.next = 1;
343
343
  return reg.triggerRegistration();
344
- case 6:
344
+ case 1:
345
345
  expect(webex.request).toHaveBeenNthCalledWith(1, _objectSpread(_objectSpread({}, mockResponse), {}, {
346
346
  method: 'POST',
347
347
  uri: "".concat(mobiusUris.primary[0], "device")
@@ -352,9 +352,9 @@ describe('Registration Tests', function () {
352
352
  expect(logSpy).toBeCalledWith("Scheduled retry with primary in 33 seconds, number of attempts : 1", loggerContext);
353
353
  failoverSpy.mockClear();
354
354
  jest.advanceTimersByTime(33 * _constants.SEC_TO_MSEC_MFACTOR);
355
- _context5.next = 15;
355
+ _context5.next = 2;
356
356
  return flushPromises();
357
- case 15:
357
+ case 2:
358
358
  expect(webex.request).toHaveBeenNthCalledWith(2, _objectSpread(_objectSpread({}, mockResponse), {}, {
359
359
  method: 'POST',
360
360
  uri: "".concat(mobiusUris.primary[0], "device")
@@ -365,9 +365,9 @@ describe('Registration Tests', function () {
365
365
  logSpy.mockClear();
366
366
  failoverSpy.mockClear();
367
367
  jest.advanceTimersByTime(40 * _constants.SEC_TO_MSEC_MFACTOR);
368
- _context5.next = 24;
368
+ _context5.next = 3;
369
369
  return flushPromises();
370
- case 24:
370
+ case 3:
371
371
  expect(webex.request).toHaveBeenNthCalledWith(3, _objectSpread(_objectSpread({}, mockResponse), {}, {
372
372
  method: 'POST',
373
373
  uri: "".concat(mobiusUris.primary[0], "device")
@@ -381,23 +381,23 @@ describe('Registration Tests', function () {
381
381
  uri: "".concat(mobiusUris.backup[0], "device")
382
382
  }));
383
383
  expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
384
- case 31:
384
+ case 4:
385
385
  case "end":
386
386
  return _context5.stop();
387
387
  }
388
388
  }, _callee5);
389
389
  })));
390
390
  it('handle 429 received while the last attempt for primary', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee6() {
391
- return _regenerator.default.wrap(function _callee6$(_context6) {
391
+ return _regenerator.default.wrap(function (_context6) {
392
392
  while (1) switch (_context6.prev = _context6.next) {
393
393
  case 0:
394
394
  reg.isCCFlow = true;
395
395
  jest.spyOn(reg, 'getRegRetryInterval').mockReturnValueOnce(33).mockReturnValueOnce(40).mockReturnValueOnce(47).mockReturnValueOnce(52);
396
396
  jest.useFakeTimers();
397
397
  webex.request.mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload429One).mockResolvedValueOnce(successPayload);
398
- _context6.next = 6;
398
+ _context6.next = 1;
399
399
  return reg.triggerRegistration();
400
- case 6:
400
+ case 1:
401
401
  /* Initial registration and first 2 attempts with primary failed with non-final 5xx error responses.
402
402
  * Last attempt with primary failed with 429, the retryAfter should be used to schedule the next attempt but
403
403
  * the failover is triggered before the scheduling logic kicks in.
@@ -412,9 +412,9 @@ describe('Registration Tests', function () {
412
412
  expect(logSpy).toBeCalledWith("Scheduled retry with primary in 33 seconds, number of attempts : 1", loggerContext);
413
413
  failoverSpy.mockClear();
414
414
  jest.advanceTimersByTime(33 * _constants.SEC_TO_MSEC_MFACTOR);
415
- _context6.next = 15;
415
+ _context6.next = 2;
416
416
  return flushPromises();
417
- case 15:
417
+ case 2:
418
418
  expect(webex.request).toHaveBeenNthCalledWith(2, _objectSpread(_objectSpread({}, mockResponse), {}, {
419
419
  method: 'POST',
420
420
  uri: "".concat(mobiusUris.primary[0], "device")
@@ -425,9 +425,9 @@ describe('Registration Tests', function () {
425
425
  logSpy.mockClear();
426
426
  failoverSpy.mockClear();
427
427
  jest.advanceTimersByTime(40 * _constants.SEC_TO_MSEC_MFACTOR);
428
- _context6.next = 24;
428
+ _context6.next = 3;
429
429
  return flushPromises();
430
- case 24:
430
+ case 3:
431
431
  expect(webex.request).toHaveBeenNthCalledWith(3, _objectSpread(_objectSpread({}, mockResponse), {}, {
432
432
  method: 'POST',
433
433
  uri: "".concat(mobiusUris.primary[0], "device")
@@ -437,9 +437,9 @@ describe('Registration Tests', function () {
437
437
  expect(logSpy).toBeCalledWith("Scheduled retry with primary in 41 seconds, number of attempts : 3", loggerContext);
438
438
  failoverSpy.mockClear();
439
439
  jest.advanceTimersByTime(41 * _constants.SEC_TO_MSEC_MFACTOR);
440
- _context6.next = 32;
440
+ _context6.next = 4;
441
441
  return flushPromises();
442
- case 32:
442
+ case 4:
443
443
  expect(webex.request).toHaveBeenNthCalledWith(4, _objectSpread(_objectSpread({}, mockResponse), {}, {
444
444
  method: 'POST',
445
445
  uri: "".concat(mobiusUris.primary[0], "device")
@@ -452,26 +452,26 @@ describe('Registration Tests', function () {
452
452
  uri: "".concat(mobiusUris.backup[0], "device")
453
453
  }));
454
454
  expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
455
- case 38:
455
+ case 5:
456
456
  case "end":
457
457
  return _context6.stop();
458
458
  }
459
459
  }, _callee6);
460
460
  })));
461
461
  it('handle 429 received while failing over to backup server for CC flow', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee7() {
462
- return _regenerator.default.wrap(function _callee7$(_context7) {
462
+ return _regenerator.default.wrap(function (_context7) {
463
463
  while (1) switch (_context7.prev = _context7.next) {
464
464
  case 0:
465
465
  reg.isCCFlow = true;
466
466
  jest.useFakeTimers();
467
467
  webex.request.mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload429One).mockResolvedValueOnce(successPayload);
468
- _context7.next = 5;
468
+ _context7.next = 1;
469
469
  return reg.triggerRegistration();
470
- case 5:
470
+ case 1:
471
471
  jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
472
- _context7.next = 8;
472
+ _context7.next = 2;
473
473
  return flushPromises();
474
- case 8:
474
+ case 2:
475
475
  expect(webex.request).toBeCalledTimes(3);
476
476
  expect(webex.request).toHaveBeenNthCalledWith(1, _objectSpread(_objectSpread({}, mockResponse), {}, {
477
477
  method: 'POST',
@@ -493,31 +493,31 @@ describe('Registration Tests', function () {
493
493
  expect(logSpy).toBeCalledWith("Scheduled retry with backup servers in ".concat(failurePayload429One.headers['retry-after'], " seconds."), loggerContext);
494
494
  webex.request.mockClear();
495
495
  jest.advanceTimersByTime(Number(failurePayload429One.headers['retry-after']) * _constants.SEC_TO_MSEC_MFACTOR);
496
- _context7.next = 18;
496
+ _context7.next = 3;
497
497
  return flushPromises();
498
- case 18:
498
+ case 3:
499
499
  expect(webex.request).toBeCalledOnceWith(_objectSpread(_objectSpread({}, mockResponse), {}, {
500
500
  method: 'POST',
501
501
  uri: "".concat(mobiusUris.backup[0], "device")
502
502
  }));
503
503
  expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
504
- case 20:
504
+ case 4:
505
505
  case "end":
506
506
  return _context7.stop();
507
507
  }
508
508
  }, _callee7);
509
509
  })));
510
510
  it('checking the retryAfter exceeding the threshold timers in first attempt itself', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee8() {
511
- return _regenerator.default.wrap(function _callee8$(_context8) {
511
+ return _regenerator.default.wrap(function (_context8) {
512
512
  while (1) switch (_context8.prev = _context8.next) {
513
513
  case 0:
514
514
  reg.isCCFlow = true;
515
515
  jest.useFakeTimers();
516
516
  jest.spyOn(reg, 'getRegRetryInterval').mockReturnValueOnce(40);
517
517
  webex.request.mockRejectedValueOnce(failurePayload429Three);
518
- _context8.next = 6;
518
+ _context8.next = 1;
519
519
  return reg.triggerRegistration();
520
- case 6:
520
+ case 1:
521
521
  expect(webex.request).toHaveBeenNthCalledWith(1, _objectSpread(_objectSpread({}, mockResponse), {}, {
522
522
  method: 'POST',
523
523
  uri: "".concat(mobiusUris.primary[0], "device")
@@ -531,23 +531,23 @@ describe('Registration Tests', function () {
531
531
  method: 'POST',
532
532
  uri: "".concat(mobiusUris.backup[0], "device")
533
533
  }));
534
- case 13:
534
+ case 2:
535
535
  case "end":
536
536
  return _context8.stop();
537
537
  }
538
538
  }, _callee8);
539
539
  })));
540
540
  it('checking the retryAfter exceeding the threshold timers in later attempts', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee9() {
541
- return _regenerator.default.wrap(function _callee9$(_context9) {
541
+ return _regenerator.default.wrap(function (_context9) {
542
542
  while (1) switch (_context9.prev = _context9.next) {
543
543
  case 0:
544
544
  reg.isCCFlow = true;
545
545
  jest.useFakeTimers();
546
546
  jest.spyOn(reg, 'getRegRetryInterval').mockReturnValueOnce(39).mockReturnValueOnce(43);
547
547
  webex.request.mockRejectedValueOnce(failurePayload429One).mockRejectedValueOnce(failurePayload429Four).mockResolvedValueOnce(successPayload);
548
- _context9.next = 6;
548
+ _context9.next = 1;
549
549
  return reg.triggerRegistration();
550
- case 6:
550
+ case 1:
551
551
  expect(webex.request).toHaveBeenNthCalledWith(1, _objectSpread(_objectSpread({}, mockResponse), {}, {
552
552
  method: 'POST',
553
553
  uri: "".concat(mobiusUris.primary[0], "device")
@@ -557,9 +557,9 @@ describe('Registration Tests', function () {
557
557
  expect(logSpy).toBeCalledWith("Scheduled retry with primary in ".concat(failurePayload429One.headers['retry-after'], " seconds, number of attempts : 1"), loggerContext);
558
558
  failoverSpy.mockClear();
559
559
  jest.advanceTimersByTime(Number(failurePayload429One.headers['retry-after']) * _constants.SEC_TO_MSEC_MFACTOR);
560
- _context9.next = 14;
560
+ _context9.next = 2;
561
561
  return flushPromises();
562
- case 14:
562
+ case 2:
563
563
  expect(webex.request).toHaveBeenNthCalledWith(2, _objectSpread(_objectSpread({}, mockResponse), {}, {
564
564
  method: 'POST',
565
565
  uri: "".concat(mobiusUris.primary[0], "device")
@@ -574,7 +574,7 @@ describe('Registration Tests', function () {
574
574
  uri: "".concat(mobiusUris.backup[0], "device")
575
575
  }));
576
576
  expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
577
- case 22:
577
+ case 3:
578
578
  case "end":
579
579
  return _context9.stop();
580
580
  }
@@ -592,7 +592,7 @@ describe('Registration Tests', function () {
592
592
  });
593
593
  it('should schedule retry when 429 with retry-after < 60 seconds during reconnect', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee0() {
594
594
  var failurePayload429Small;
595
- return _regenerator.default.wrap(function _callee0$(_context0) {
595
+ return _regenerator.default.wrap(function (_context0) {
596
596
  while (1) switch (_context0.prev = _context0.next) {
597
597
  case 0:
598
598
  restartSpy = jest.spyOn(reg, 'restartRegistration');
@@ -605,9 +605,9 @@ describe('Registration Tests', function () {
605
605
  }
606
606
  };
607
607
  webex.request.mockRejectedValueOnce(failurePayload429Small).mockResolvedValueOnce(successPayload);
608
- _context0.next = 6;
608
+ _context0.next = 1;
609
609
  return reg.reconnectOnFailure(_constants.RECONNECT_ON_FAILURE_UTIL);
610
- case 6:
610
+ case 1:
611
611
  // This call is being used to set the retry-after value
612
612
  // Verify restore is invoked first and retry-after captured before scheduling
613
613
  expect(restoreSpy).toBeCalledOnceWith(_constants.RECONNECT_ON_FAILURE_UTIL);
@@ -615,12 +615,12 @@ describe('Registration Tests', function () {
615
615
  expect(reg.retryAfter).toEqual(undefined); // Clear retryAfter after 429 retry
616
616
 
617
617
  jest.advanceTimersByTime(40 * _constants.SEC_TO_MSEC_MFACTOR);
618
- _context0.next = 12;
618
+ _context0.next = 2;
619
619
  return flushPromises();
620
- case 12:
620
+ case 2:
621
621
  expect(restartSpy).toHaveBeenCalledTimes(1);
622
622
  expect(restartSpy).toHaveBeenCalledWith(_constants.RECONNECT_ON_FAILURE_UTIL);
623
- case 14:
623
+ case 3:
624
624
  case "end":
625
625
  return _context0.stop();
626
626
  }
@@ -628,7 +628,7 @@ describe('Registration Tests', function () {
628
628
  })));
629
629
  it('should try backup servers when 429 with retry-after >= 60 seconds on primary during reconnect', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee1() {
630
630
  var attemptRegistrationWithServersSpy, failurePayload429Small;
631
- return _regenerator.default.wrap(function _callee1$(_context1) {
631
+ return _regenerator.default.wrap(function (_context1) {
632
632
  while (1) switch (_context1.prev = _context1.next) {
633
633
  case 0:
634
634
  // Setup: Register successfully with primary first
@@ -642,17 +642,17 @@ describe('Registration Tests', function () {
642
642
  }
643
643
  };
644
644
  webex.request.mockRejectedValueOnce(failurePayload429Small).mockResolvedValueOnce(successPayload);
645
- _context1.next = 6;
645
+ _context1.next = 1;
646
646
  return reg.reconnectOnFailure(_constants.RECONNECT_ON_FAILURE_UTIL);
647
- case 6:
647
+ case 1:
648
648
  // This call is being used to trigger the retry
649
649
  // Verify restore gets invoked, 429 with retry-after is observed and captured
650
650
  expect(restoreSpy).toBeCalledOnceWith(_constants.RECONNECT_ON_FAILURE_UTIL);
651
651
  expect(retry429Spy).toBeCalledOnceWith(100, _constants.RECONNECT_ON_FAILURE_UTIL);
652
652
  jest.advanceTimersByTime(40 * _constants.SEC_TO_MSEC_MFACTOR);
653
- _context1.next = 11;
653
+ _context1.next = 2;
654
654
  return flushPromises();
655
- case 11:
655
+ case 2:
656
656
  expect(attemptRegistrationWithServersSpy).toHaveBeenCalledTimes(2);
657
657
  expect(attemptRegistrationWithServersSpy).toHaveBeenNthCalledWith(1, _constants.RECONNECT_ON_FAILURE_UTIL, [mobiusUris.primary[0]]);
658
658
  // Immediately try backup servers when retry-after >= 60 seconds on primary
@@ -660,7 +660,7 @@ describe('Registration Tests', function () {
660
660
  expect(restartSpy).not.toHaveBeenCalledTimes(1);
661
661
  expect(restartSpy).not.toHaveBeenCalledWith(_constants.RECONNECT_ON_FAILURE_UTIL);
662
662
  expect(reg.retryAfter).toEqual(undefined); // Clear retryAfter after 429 retry
663
- case 17:
663
+ case 3:
664
664
  case "end":
665
665
  return _context1.stop();
666
666
  }
@@ -668,7 +668,7 @@ describe('Registration Tests', function () {
668
668
  })));
669
669
  it('should restart registration with primary if we get 429 while on backup', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee10() {
670
670
  var attemptRegistrationWithServersSpy, failurePayload429Small;
671
- return _regenerator.default.wrap(function _callee10$(_context10) {
671
+ return _regenerator.default.wrap(function (_context10) {
672
672
  while (1) switch (_context10.prev = _context10.next) {
673
673
  case 0:
674
674
  // Setup: Register successfully with primary first
@@ -683,9 +683,9 @@ describe('Registration Tests', function () {
683
683
  }
684
684
  };
685
685
  webex.request.mockRejectedValueOnce(failurePayload429Small).mockResolvedValueOnce(successPayload).mockRejectedValueOnce(failurePayload429Small).mockResolvedValueOnce(successPayload);
686
- _context10.next = 7;
686
+ _context10.next = 1;
687
687
  return reg.reconnectOnFailure(_constants.RECONNECT_ON_FAILURE_UTIL);
688
- case 7:
688
+ case 1:
689
689
  // This call is being used to trigger the retry
690
690
  // Verify restore path taken first and 429 handling captured
691
691
  expect(restoreSpy).toBeCalledOnceWith(_constants.RECONNECT_ON_FAILURE_UTIL);
@@ -693,16 +693,16 @@ describe('Registration Tests', function () {
693
693
  // No failover scheduling expected in this path
694
694
  expect(failoverSpy).not.toBeCalled();
695
695
  jest.advanceTimersByTime(40 * _constants.SEC_TO_MSEC_MFACTOR);
696
- _context10.next = 13;
696
+ _context10.next = 2;
697
697
  return flushPromises();
698
- case 13:
698
+ case 2:
699
699
  expect(attemptRegistrationWithServersSpy).toHaveBeenCalledTimes(2);
700
700
  expect(attemptRegistrationWithServersSpy).toHaveBeenNthCalledWith(1, _constants.RECONNECT_ON_FAILURE_UTIL, [mobiusUris.backup[0]]);
701
701
  // Immediately try primary servers when retry-after >= 60 seconds on backup
702
702
  expect(restartSpy).toHaveBeenCalledTimes(1);
703
703
  expect(restartSpy).toHaveBeenCalledWith(_constants.RECONNECT_ON_FAILURE_UTIL);
704
704
  expect(attemptRegistrationWithServersSpy).toHaveBeenNthCalledWith(2, _constants.RECONNECT_ON_FAILURE_UTIL, [mobiusUris.primary[0]]);
705
- case 18:
705
+ case 3:
706
706
  case "end":
707
707
  return _context10.stop();
708
708
  }
@@ -720,7 +720,7 @@ describe('Registration Tests', function () {
720
720
  });
721
721
  it('should schedule retry when 429 with retry-after < 60 seconds during handleConnectionRestoration', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee11() {
722
722
  var failurePayload429Small;
723
- return _regenerator.default.wrap(function _callee11$(_context11) {
723
+ return _regenerator.default.wrap(function (_context11) {
724
724
  while (1) switch (_context11.prev = _context11.next) {
725
725
  case 0:
726
726
  reg.setActiveMobiusUrl(mobiusUris.primary[0]);
@@ -732,20 +732,20 @@ describe('Registration Tests', function () {
732
732
  }
733
733
  };
734
734
  webex.request.mockRejectedValueOnce(failurePayload429Small).mockResolvedValueOnce(successPayload).mockRejectedValueOnce(failurePayload429Small).mockResolvedValueOnce(successPayload);
735
- _context11.next = 5;
735
+ _context11.next = 1;
736
736
  return reg.handleConnectionRestoration(true);
737
- case 5:
737
+ case 1:
738
738
  expect(restoreSpy).toBeCalledOnceWith(_constants.METHODS.HANDLE_CONNECTION_RESTORATION);
739
739
  expect(restartSpy).not.toBeCalled();
740
740
  expect(reg.retryAfter).toEqual(undefined); // Clear retryAfter after 429 retry
741
741
 
742
742
  jest.advanceTimersByTime(40 * _constants.SEC_TO_MSEC_MFACTOR);
743
- _context11.next = 11;
743
+ _context11.next = 2;
744
744
  return flushPromises();
745
- case 11:
745
+ case 2:
746
746
  expect(restartSpy).toHaveBeenCalledTimes(1);
747
747
  expect(restartSpy).toHaveBeenCalledWith(_constants.METHODS.HANDLE_CONNECTION_RESTORATION);
748
- case 13:
748
+ case 3:
749
749
  case "end":
750
750
  return _context11.stop();
751
751
  }
@@ -753,7 +753,7 @@ describe('Registration Tests', function () {
753
753
  })));
754
754
  it('should try backup servers when 429 with retry-after >= 60 seconds on primary during handleConnectionRestoration', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee12() {
755
755
  var attemptRegistrationWithServersSpy, failurePayload429Small;
756
- return _regenerator.default.wrap(function _callee12$(_context12) {
756
+ return _regenerator.default.wrap(function (_context12) {
757
757
  while (1) switch (_context12.prev = _context12.next) {
758
758
  case 0:
759
759
  attemptRegistrationWithServersSpy = jest.spyOn(reg, 'attemptRegistrationWithServers');
@@ -766,22 +766,22 @@ describe('Registration Tests', function () {
766
766
  }
767
767
  };
768
768
  webex.request.mockRejectedValueOnce(failurePayload429Small).mockResolvedValueOnce(successPayload).mockRejectedValueOnce(failurePayload429Small).mockResolvedValueOnce(successPayload);
769
- _context12.next = 6;
769
+ _context12.next = 1;
770
770
  return reg.handleConnectionRestoration(true);
771
- case 6:
771
+ case 1:
772
772
  expect(restoreSpy).toBeCalledOnceWith(_constants.METHODS.HANDLE_CONNECTION_RESTORATION);
773
773
  expect(retry429Spy).toBeCalledOnceWith(100, _constants.METHODS.HANDLE_CONNECTION_RESTORATION);
774
774
  jest.advanceTimersByTime(40 * _constants.SEC_TO_MSEC_MFACTOR);
775
- _context12.next = 11;
775
+ _context12.next = 2;
776
776
  return flushPromises();
777
- case 11:
777
+ case 2:
778
778
  expect(attemptRegistrationWithServersSpy).toHaveBeenCalledTimes(2);
779
779
  expect(attemptRegistrationWithServersSpy).toHaveBeenNthCalledWith(1, _constants.METHODS.HANDLE_CONNECTION_RESTORATION, [mobiusUris.primary[0]]);
780
780
  // Immediately try backup servers when retry-after >= 60 seconds on primary
781
781
  expect(attemptRegistrationWithServersSpy).toHaveBeenNthCalledWith(2, _constants.METHODS.HANDLE_CONNECTION_RESTORATION, mobiusUris.backup);
782
782
  expect(restartSpy).not.toHaveBeenCalledTimes(1);
783
783
  expect(restartSpy).not.toHaveBeenCalledWith(_constants.METHODS.HANDLE_CONNECTION_RESTORATION);
784
- case 16:
784
+ case 3:
785
785
  case "end":
786
786
  return _context12.stop();
787
787
  }
@@ -790,20 +790,20 @@ describe('Registration Tests', function () {
790
790
  });
791
791
  describe('Registration failover tests', function () {
792
792
  it('verify unreachable primary with reachable backup servers', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee13() {
793
- return _regenerator.default.wrap(function _callee13$(_context13) {
793
+ return _regenerator.default.wrap(function (_context13) {
794
794
  while (1) switch (_context13.prev = _context13.next) {
795
795
  case 0:
796
796
  jest.useFakeTimers();
797
797
  // try the primary twice and register successfully with backup servers
798
798
  webex.request.mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload).mockResolvedValueOnce(successPayload);
799
799
  expect(reg.getStatus()).toEqual(_types.RegistrationStatus.IDLE);
800
- _context13.next = 5;
800
+ _context13.next = 1;
801
801
  return reg.triggerRegistration();
802
- case 5:
802
+ case 1:
803
803
  jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
804
- _context13.next = 8;
804
+ _context13.next = 2;
805
805
  return flushPromises();
806
- case 8:
806
+ case 2:
807
807
  expect(webex.request).toBeCalledTimes(3);
808
808
  expect(webex.request).toBeCalledWith(_objectSpread(_objectSpread({}, mockResponse), {}, {
809
809
  method: 'POST',
@@ -817,14 +817,14 @@ describe('Registration Tests', function () {
817
817
  /* Active Url must match with the backup url as per the test */
818
818
  expect(reg.getActiveMobiusUrl()).toEqual(mobiusUris.backup[0]);
819
819
  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);
820
- case 14:
820
+ case 3:
821
821
  case "end":
822
822
  return _context13.stop();
823
823
  }
824
824
  }, _callee13);
825
825
  })));
826
826
  it('cc: verify unreachable primary with reachable backup server', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee14() {
827
- return _regenerator.default.wrap(function _callee14$(_context14) {
827
+ return _regenerator.default.wrap(function (_context14) {
828
828
  while (1) switch (_context14.prev = _context14.next) {
829
829
  case 0:
830
830
  setupRegistration(_objectSpread(_objectSpread({}, MockServiceData), {}, {
@@ -833,13 +833,13 @@ describe('Registration Tests', function () {
833
833
  jest.useFakeTimers();
834
834
  webex.request.mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload).mockResolvedValueOnce(successPayload);
835
835
  expect(reg.getStatus()).toEqual(_types.RegistrationStatus.IDLE);
836
- _context14.next = 6;
836
+ _context14.next = 1;
837
837
  return reg.triggerRegistration();
838
- case 6:
838
+ case 1:
839
839
  jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
840
- _context14.next = 9;
840
+ _context14.next = 2;
841
841
  return flushPromises();
842
- case 9:
842
+ case 2:
843
843
  expect(webex.request).toBeCalledTimes(3);
844
844
  expect(webex.request).toBeCalledWith(_objectSpread(_objectSpread({}, ccMockResponse), {}, {
845
845
  method: 'POST',
@@ -852,31 +852,31 @@ describe('Registration Tests', function () {
852
852
  expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
853
853
  /* Active Url must match with the backup url as per the test */
854
854
  expect(reg.getActiveMobiusUrl()).toEqual(mobiusUris.backup[0]);
855
- case 14:
855
+ case 3:
856
856
  case "end":
857
857
  return _context14.stop();
858
858
  }
859
859
  }, _callee14);
860
860
  })));
861
861
  it('verify unreachable primary and backup servers', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee15() {
862
- return _regenerator.default.wrap(function _callee15$(_context15) {
862
+ return _regenerator.default.wrap(function (_context15) {
863
863
  while (1) switch (_context15.prev = _context15.next) {
864
864
  case 0:
865
865
  jest.useFakeTimers();
866
866
  // try the primary twice and register successfully with backup servers
867
867
  webex.request.mockRejectedValue(failurePayload);
868
868
  expect(reg.getStatus()).toEqual(_types.RegistrationStatus.IDLE);
869
- _context15.next = 5;
869
+ _context15.next = 1;
870
870
  return reg.triggerRegistration();
871
- case 5:
871
+ case 1:
872
872
  jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
873
- _context15.next = 8;
873
+ _context15.next = 2;
874
874
  return flushPromises();
875
- case 8:
875
+ case 2:
876
876
  jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
877
- _context15.next = 11;
877
+ _context15.next = 3;
878
878
  return flushPromises();
879
- case 11:
879
+ case 3:
880
880
  /*
881
881
  * 2 calls for primary -> initial and after timer expiry.
882
882
  * 2 calls for each backup entry -> 2 * 2 = 4.
@@ -897,7 +897,7 @@ describe('Registration Tests', function () {
897
897
  uri: "".concat(mobiusUris.backup[1], "device")
898
898
  }));
899
899
  expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
900
- case 17:
900
+ case 4:
901
901
  case "end":
902
902
  return _context15.stop();
903
903
  }
@@ -907,7 +907,7 @@ describe('Registration Tests', function () {
907
907
  describe('Registration failback tests', function () {
908
908
  var isPrimaryActiveSpy;
909
909
  beforeEach(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee16() {
910
- return _regenerator.default.wrap(function _callee16$(_context16) {
910
+ return _regenerator.default.wrap(function (_context16) {
911
911
  while (1) switch (_context16.prev = _context16.next) {
912
912
  case 0:
913
913
  isPrimaryActiveSpy = jest.spyOn(reg, 'isPrimaryActive');
@@ -915,13 +915,13 @@ describe('Registration Tests', function () {
915
915
  /* keep keepalive as active so that it wont interfere with the failback tests */
916
916
  jest.useFakeTimers();
917
917
  postRegistrationSpy.mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload).mockResolvedValueOnce(successPayload);
918
- _context16.next = 6;
918
+ _context16.next = 1;
919
919
  return reg.triggerRegistration();
920
- case 6:
920
+ case 1:
921
921
  jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
922
- _context16.next = 9;
922
+ _context16.next = 2;
923
923
  return flushPromises();
924
- case 9:
924
+ case 2:
925
925
  reg.rehomingIntervalMin = _constants.DEFAULT_REHOMING_INTERVAL_MIN;
926
926
  reg.rehomingIntervalMax = _constants.DEFAULT_REHOMING_INTERVAL_MAX;
927
927
 
@@ -931,7 +931,7 @@ describe('Registration Tests', function () {
931
931
  /* Active Url must match with the backup url as per the test */
932
932
  expect(reg.getActiveMobiusUrl()).toStrictEqual(mobiusUris.backup[0]);
933
933
  expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
934
- case 14:
934
+ case 3:
935
935
  case "end":
936
936
  return _context16.stop();
937
937
  }
@@ -942,7 +942,7 @@ describe('Registration Tests', function () {
942
942
  jest.clearAllMocks();
943
943
  });
944
944
  it('verify 429 error with failback to primary after initial registration with backup: Restore failure', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee17() {
945
- return _regenerator.default.wrap(function _callee17$(_context17) {
945
+ return _regenerator.default.wrap(function (_context17) {
946
946
  while (1) switch (_context17.prev = _context17.next) {
947
947
  case 0:
948
948
  // delete should be successful
@@ -959,17 +959,17 @@ describe('Registration Tests', function () {
959
959
 
960
960
  /* Wait for failback to be triggered. */
961
961
  jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
962
- _context17.next = 5;
962
+ _context17.next = 1;
963
963
  return flushPromises();
964
- case 5:
964
+ case 1:
965
965
  expect(infoSpy).toBeCalledWith("Attempting failback to primary.", {
966
966
  method: 'executeFailback',
967
967
  file: _constants.REGISTRATION_FILE
968
968
  });
969
969
  jest.advanceTimersByTime(10000);
970
- _context17.next = 9;
970
+ _context17.next = 2;
971
971
  return flushPromises();
972
- case 9:
972
+ case 2:
973
973
  expect(retry429Spy).toBeCalledWith(failurePayload429Two.headers['retry-after'], 'executeFailback');
974
974
  // After handling 429 during failback, the counter is incremented to 1
975
975
  expect(reg.failback429RetryAttempts).toBe(1);
@@ -981,23 +981,23 @@ describe('Registration Tests', function () {
981
981
  expect(reg.failbackTimer).not.toBe(undefined); // Timer is set in handle429Retry
982
982
  expect(reg.rehomingIntervalMin).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MIN);
983
983
  expect(reg.rehomingIntervalMax).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MAX);
984
- case 17:
984
+ case 3:
985
985
  case "end":
986
986
  return _context17.stop();
987
987
  }
988
988
  }, _callee17);
989
989
  })));
990
990
  it('verify unsuccessful failback to primary after initial registration with backup: Restore failure', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee18() {
991
- return _regenerator.default.wrap(function _callee18$(_context18) {
991
+ return _regenerator.default.wrap(function (_context18) {
992
992
  while (1) switch (_context18.prev = _context18.next) {
993
993
  case 0:
994
994
  postRegistrationSpy.mockRejectedValue(failurePayload);
995
995
 
996
996
  /* Wait for failback to be triggered. */
997
997
  jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
998
- _context18.next = 4;
998
+ _context18.next = 1;
999
999
  return flushPromises();
1000
- case 4:
1000
+ case 1:
1001
1001
  expect(infoSpy).toBeCalledWith("Attempting failback to primary.", {
1002
1002
  method: 'executeFailback',
1003
1003
  file: _constants.REGISTRATION_FILE
@@ -1008,7 +1008,7 @@ describe('Registration Tests', function () {
1008
1008
  expect(restartSpy).toBeCalledOnceWith(_constants.FAILBACK_UTIL);
1009
1009
  expect(reg.rehomingIntervalMin).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MIN);
1010
1010
  expect(reg.rehomingIntervalMax).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MAX);
1011
- case 11:
1011
+ case 2:
1012
1012
  case "end":
1013
1013
  return _context18.stop();
1014
1014
  }
@@ -1016,7 +1016,7 @@ describe('Registration Tests', function () {
1016
1016
  })));
1017
1017
  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 _callee19() {
1018
1018
  var finalErrorPayload;
1019
- return _regenerator.default.wrap(function _callee19$(_context19) {
1019
+ return _regenerator.default.wrap(function (_context19) {
1020
1020
  while (1) switch (_context19.prev = _context19.next) {
1021
1021
  case 0:
1022
1022
  finalErrorPayload = {
@@ -1027,9 +1027,9 @@ describe('Registration Tests', function () {
1027
1027
  postRegistrationSpy.mockRejectedValue(finalErrorPayload).mockRejectedValueOnce(failurePayload);
1028
1028
  /* Wait for failback to be triggered. */
1029
1029
  jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
1030
- _context19.next = 6;
1030
+ _context19.next = 1;
1031
1031
  return flushPromises();
1032
- case 6:
1032
+ case 1:
1033
1033
  expect(infoSpy).toBeCalledWith("Attempting failback to primary.", {
1034
1034
  method: 'executeFailback',
1035
1035
  file: _constants.REGISTRATION_FILE
@@ -1040,23 +1040,23 @@ describe('Registration Tests', function () {
1040
1040
  expect(reg.failbackTimer).toBe(undefined);
1041
1041
  expect(reg.rehomingIntervalMin).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MIN);
1042
1042
  expect(reg.rehomingIntervalMax).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MAX);
1043
- case 13:
1043
+ case 2:
1044
1044
  case "end":
1045
1045
  return _context19.stop();
1046
1046
  }
1047
1047
  }, _callee19);
1048
1048
  })));
1049
1049
  it('verify unsuccessful failback to primary after initial registration with backup: Restore success', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee20() {
1050
- return _regenerator.default.wrap(function _callee20$(_context20) {
1050
+ return _regenerator.default.wrap(function (_context20) {
1051
1051
  while (1) switch (_context20.prev = _context20.next) {
1052
1052
  case 0:
1053
1053
  postRegistrationSpy.mockRejectedValueOnce(failurePayload).mockResolvedValue(successPayload);
1054
1054
 
1055
1055
  /* Wait for failback to be triggered. */
1056
1056
  jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
1057
- _context20.next = 4;
1057
+ _context20.next = 1;
1058
1058
  return flushPromises();
1059
- case 4:
1059
+ case 1:
1060
1060
  expect(infoSpy).toBeCalledWith("Attempting failback to primary.", {
1061
1061
  method: 'executeFailback',
1062
1062
  file: _constants.REGISTRATION_FILE
@@ -1068,23 +1068,23 @@ describe('Registration Tests', function () {
1068
1068
  expect(restartSpy).not.toBeCalled();
1069
1069
  expect(reg.rehomingIntervalMin).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MIN);
1070
1070
  expect(reg.rehomingIntervalMax).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MAX);
1071
- case 11:
1071
+ case 2:
1072
1072
  case "end":
1073
1073
  return _context20.stop();
1074
1074
  }
1075
1075
  }, _callee20);
1076
1076
  })));
1077
1077
  it('verify successful failback to primary after initial registration with backup', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee21() {
1078
- return _regenerator.default.wrap(function _callee21$(_context21) {
1078
+ return _regenerator.default.wrap(function (_context21) {
1079
1079
  while (1) switch (_context21.prev = _context21.next) {
1080
1080
  case 0:
1081
1081
  postRegistrationSpy.mockResolvedValue(successPayload);
1082
1082
 
1083
1083
  /* Wait for failback to be triggered. */
1084
1084
  jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
1085
- _context21.next = 4;
1085
+ _context21.next = 1;
1086
1086
  return flushPromises();
1087
- case 4:
1087
+ case 1:
1088
1088
  expect(infoSpy).toBeCalledWith("Attempting failback to primary.", {
1089
1089
  method: 'executeFailback',
1090
1090
  file: _constants.REGISTRATION_FILE
@@ -1098,14 +1098,14 @@ describe('Registration Tests', function () {
1098
1098
  expect(restoreSpy).not.toBeCalled();
1099
1099
  expect(reg.rehomingIntervalMin).toBe(_registerFixtures.mockPostResponse.rehomingIntervalMin);
1100
1100
  expect(reg.rehomingIntervalMax).toBe(_registerFixtures.mockPostResponse.rehomingIntervalMax);
1101
- case 12:
1101
+ case 2:
1102
1102
  case "end":
1103
1103
  return _context21.stop();
1104
1104
  }
1105
1105
  }, _callee21);
1106
1106
  })));
1107
1107
  it('verify unsuccessful failback attempt due to active call', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee22() {
1108
- return _regenerator.default.wrap(function _callee22$(_context22) {
1108
+ return _regenerator.default.wrap(function (_context22) {
1109
1109
  while (1) switch (_context22.prev = _context22.next) {
1110
1110
  case 0:
1111
1111
  /** create a new call */
@@ -1115,9 +1115,9 @@ describe('Registration Tests', function () {
1115
1115
 
1116
1116
  /* Wait for failback to be triggered. */
1117
1117
  jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
1118
- _context22.next = 6;
1118
+ _context22.next = 1;
1119
1119
  return flushPromises();
1120
- case 6:
1120
+ case 1:
1121
1121
  expect(infoSpy).toBeCalledWith("Active calls present or primary Mobius is down, deferring failback to next cycle.", {
1122
1122
  method: 'executeFailback',
1123
1123
  file: _constants.REGISTRATION_FILE
@@ -1135,23 +1135,23 @@ describe('Registration Tests', function () {
1135
1135
  });
1136
1136
  expect(reg.rehomingIntervalMin).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MIN);
1137
1137
  expect(reg.rehomingIntervalMax).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MAX);
1138
- case 15:
1138
+ case 2:
1139
1139
  case "end":
1140
1140
  return _context22.stop();
1141
1141
  }
1142
1142
  }, _callee22);
1143
1143
  })));
1144
1144
  it('verify unsuccessful failback attempt due to primary server being down', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee23() {
1145
- return _regenerator.default.wrap(function _callee23$(_context23) {
1145
+ return _regenerator.default.wrap(function (_context23) {
1146
1146
  while (1) switch (_context23.prev = _context23.next) {
1147
1147
  case 0:
1148
1148
  isPrimaryActiveSpy.mockReturnValue(false);
1149
1149
 
1150
1150
  /* Wait for failback to be triggered. */
1151
1151
  jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
1152
- _context23.next = 4;
1152
+ _context23.next = 1;
1153
1153
  return flushPromises();
1154
- case 4:
1154
+ case 1:
1155
1155
  expect(infoSpy).toBeCalledWith("Active calls present or primary Mobius is down, deferring failback to next cycle.", {
1156
1156
  method: 'executeFailback',
1157
1157
  file: _constants.REGISTRATION_FILE
@@ -1161,7 +1161,7 @@ describe('Registration Tests', function () {
1161
1161
  expect(deregisterSpy).not.toBeCalled();
1162
1162
  expect(reg.getActiveMobiusUrl()).toStrictEqual(mobiusUris.backup[0]);
1163
1163
  expect(reg.getStatus()).toBe(_types.RegistrationStatus.ACTIVE);
1164
- case 8:
1164
+ case 2:
1165
1165
  case "end":
1166
1166
  return _context23.stop();
1167
1167
  }
@@ -1173,17 +1173,17 @@ describe('Registration Tests', function () {
1173
1173
  describe('Keep-alive Tests', function () {
1174
1174
  var beforeEachSetupForKeepalive = /*#__PURE__*/function () {
1175
1175
  var _ref24 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee24() {
1176
- return _regenerator.default.wrap(function _callee24$(_context24) {
1176
+ return _regenerator.default.wrap(function (_context24) {
1177
1177
  while (1) switch (_context24.prev = _context24.next) {
1178
1178
  case 0:
1179
1179
  postRegistrationSpy.mockResolvedValueOnce(successPayload);
1180
1180
  jest.useFakeTimers();
1181
- _context24.next = 4;
1181
+ _context24.next = 1;
1182
1182
  return reg.triggerRegistration();
1183
- case 4:
1183
+ case 1:
1184
1184
  expect(reg.getStatus()).toBe(_types.RegistrationStatus.ACTIVE);
1185
1185
  expect(reg.webWorker).toBeDefined();
1186
- case 6:
1186
+ case 2:
1187
1187
  case "end":
1188
1188
  return _context24.stop();
1189
1189
  }
@@ -1205,13 +1205,13 @@ describe('Registration Tests', function () {
1205
1205
  });
1206
1206
  it('verify successful keep-alive cases', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee25() {
1207
1207
  var postMessageSpy;
1208
- return _regenerator.default.wrap(function _callee25$(_context25) {
1208
+ return _regenerator.default.wrap(function (_context25) {
1209
1209
  while (1) switch (_context25.prev = _context25.next) {
1210
1210
  case 0:
1211
1211
  postMessageSpy = jest.spyOn(Worker.prototype, 'postMessage');
1212
- _context25.next = 3;
1212
+ _context25.next = 1;
1213
1213
  return beforeEachSetupForKeepalive();
1214
- case 3:
1214
+ case 1:
1215
1215
  expect(reg.webWorker).toBeDefined();
1216
1216
  expect(postMessageSpy).toHaveBeenCalledWith(expect.objectContaining({
1217
1217
  type: 'START_KEEPALIVE',
@@ -1228,7 +1228,7 @@ describe('Registration Tests', function () {
1228
1228
  }
1229
1229
  });
1230
1230
  expect(lineEmitter).toBeCalledWith(_types4.LINE_EVENTS.RECONNECTED);
1231
- case 7:
1231
+ case 2:
1232
1232
  case "end":
1233
1233
  return _context25.stop();
1234
1234
  }
@@ -1236,12 +1236,12 @@ describe('Registration Tests', function () {
1236
1236
  })));
1237
1237
  it('verify failure keep-alive cases: Retry Success', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee26() {
1238
1238
  var worker;
1239
- return _regenerator.default.wrap(function _callee26$(_context26) {
1239
+ return _regenerator.default.wrap(function (_context26) {
1240
1240
  while (1) switch (_context26.prev = _context26.next) {
1241
1241
  case 0:
1242
- _context26.next = 2;
1242
+ _context26.next = 1;
1243
1243
  return beforeEachSetupForKeepalive();
1244
- case 2:
1244
+ case 1:
1245
1245
  worker = reg.webWorker;
1246
1246
  lineEmitter.mockClear();
1247
1247
  worker.onmessage({
@@ -1260,7 +1260,7 @@ describe('Registration Tests', function () {
1260
1260
  }
1261
1261
  });
1262
1262
  expect(lineEmitter).toHaveBeenCalledWith(_types4.LINE_EVENTS.RECONNECTED);
1263
- case 7:
1263
+ case 2:
1264
1264
  case "end":
1265
1265
  return _context26.stop();
1266
1266
  }
@@ -1268,12 +1268,12 @@ describe('Registration Tests', function () {
1268
1268
  })));
1269
1269
  it('verify failure keep-alive cases: Restore failure', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee27() {
1270
1270
  var reconnectSpy, restoreSpy, restartRegSpy, RETRY_COUNT_THRESHOLD, failureEvent;
1271
- return _regenerator.default.wrap(function _callee27$(_context27) {
1271
+ return _regenerator.default.wrap(function (_context27) {
1272
1272
  while (1) switch (_context27.prev = _context27.next) {
1273
1273
  case 0:
1274
- _context27.next = 2;
1274
+ _context27.next = 1;
1275
1275
  return beforeEachSetupForKeepalive();
1276
- case 2:
1276
+ case 1:
1277
1277
  reconnectSpy = jest.spyOn(reg, 'reconnectOnFailure');
1278
1278
  restoreSpy = jest.spyOn(reg, 'restorePreviousRegistration');
1279
1279
  restartRegSpy = jest.spyOn(reg, 'restartRegistration'); // Clear previous event emissions
@@ -1298,9 +1298,9 @@ describe('Registration Tests', function () {
1298
1298
  }
1299
1299
  };
1300
1300
  reg.webWorker.onmessage(failureEvent);
1301
- _context27.next = 14;
1301
+ _context27.next = 2;
1302
1302
  return flushPromises();
1303
- case 14:
1303
+ case 2:
1304
1304
  expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
1305
1305
  expect(lineEmitter).toHaveBeenCalledWith(_types4.LINE_EVENTS.UNREGISTERED);
1306
1306
  expect(reconnectSpy).toBeCalledOnceWith(_constants.RECONNECT_ON_FAILURE_UTIL);
@@ -1311,7 +1311,7 @@ describe('Registration Tests', function () {
1311
1311
  file: _constants.REGISTRATION_FILE,
1312
1312
  method: 'startKeepaliveTimer'
1313
1313
  }));
1314
- case 21:
1314
+ case 3:
1315
1315
  case "end":
1316
1316
  return _context27.stop();
1317
1317
  }
@@ -1319,12 +1319,12 @@ describe('Registration Tests', function () {
1319
1319
  })));
1320
1320
  it('verify failure keep-alive cases: Restore Success', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee28() {
1321
1321
  var reconnectSpy, url;
1322
- return _regenerator.default.wrap(function _callee28$(_context28) {
1322
+ return _regenerator.default.wrap(function (_context28) {
1323
1323
  while (1) switch (_context28.prev = _context28.next) {
1324
1324
  case 0:
1325
- _context28.next = 2;
1325
+ _context28.next = 1;
1326
1326
  return beforeEachSetupForKeepalive();
1327
- case 2:
1327
+ case 1:
1328
1328
  expect(reg.webWorker).toBeDefined();
1329
1329
  reconnectSpy = jest.spyOn(reg, 'reconnectOnFailure');
1330
1330
  url = 'https://mobius-dfw.webex.com/api/v1/calling/web/';
@@ -1338,18 +1338,18 @@ describe('Registration Tests', function () {
1338
1338
  }
1339
1339
  });
1340
1340
  jest.advanceTimersByTime(1000);
1341
- _context28.next = 9;
1341
+ _context28.next = 2;
1342
1342
  return flushPromises();
1343
- case 9:
1343
+ case 2:
1344
1344
  expect(reg.webWorker).toBeUndefined();
1345
1345
  expect(reconnectSpy).toBeCalledOnceWith(_constants.RECONNECT_ON_FAILURE_UTIL);
1346
1346
  webex.request.mockResolvedValueOnce(successPayload);
1347
- _context28.next = 14;
1347
+ _context28.next = 3;
1348
1348
  return reg.triggerRegistration();
1349
- case 14:
1350
- _context28.next = 16;
1349
+ case 3:
1350
+ _context28.next = 4;
1351
1351
  return flushPromises();
1352
- case 16:
1352
+ case 4:
1353
1353
  expect(reg.webWorker).toBeDefined();
1354
1354
  reg.webWorker.onmessage({
1355
1355
  data: {
@@ -1360,9 +1360,9 @@ describe('Registration Tests', function () {
1360
1360
 
1361
1361
  // Advance timers and flush any remaining promises.
1362
1362
  jest.advanceTimersByTime(1000);
1363
- _context28.next = 21;
1363
+ _context28.next = 5;
1364
1364
  return flushPromises();
1365
- case 21:
1365
+ case 5:
1366
1366
  expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
1367
1367
  // reconnectSpy should have been called only once.
1368
1368
  expect(reconnectSpy).toBeCalledTimes(1);
@@ -1370,19 +1370,19 @@ describe('Registration Tests', function () {
1370
1370
  expect(restartSpy).toBeCalledOnceWith(_constants.RECONNECT_ON_FAILURE_UTIL);
1371
1371
  // Active Mobius URL should remain unchanged.
1372
1372
  expect(reg.getActiveMobiusUrl()).toStrictEqual(url);
1373
- case 26:
1373
+ case 6:
1374
1374
  case "end":
1375
1375
  return _context28.stop();
1376
1376
  }
1377
1377
  }, _callee28);
1378
1378
  })));
1379
1379
  it('verify failure followed by recovery of keepalive', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee29() {
1380
- return _regenerator.default.wrap(function _callee29$(_context29) {
1380
+ return _regenerator.default.wrap(function (_context29) {
1381
1381
  while (1) switch (_context29.prev = _context29.next) {
1382
1382
  case 0:
1383
- _context29.next = 2;
1383
+ _context29.next = 1;
1384
1384
  return beforeEachSetupForKeepalive();
1385
- case 2:
1385
+ case 1:
1386
1386
  expect(reg.getStatus()).toBe(_types.RegistrationStatus.ACTIVE);
1387
1387
  expect(reg.webWorker).toBeDefined();
1388
1388
  webex.request.mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload).mockResolvedValue(successPayload);
@@ -1393,17 +1393,17 @@ describe('Registration Tests', function () {
1393
1393
  keepAliveRetryCount: reg.isCCFlow ? 4 : 5
1394
1394
  }
1395
1395
  });
1396
- _context29.next = 8;
1396
+ _context29.next = 2;
1397
1397
  return flushPromises();
1398
- case 8:
1398
+ case 2:
1399
1399
  expect(reg.webWorker).toBeUndefined();
1400
1400
  expect(handleErrorSpy).toBeCalledTimes(3);
1401
- _context29.next = 12;
1401
+ _context29.next = 3;
1402
1402
  return reg.triggerRegistration();
1403
- case 12:
1404
- _context29.next = 14;
1403
+ case 3:
1404
+ _context29.next = 4;
1405
1405
  return flushPromises();
1406
- case 14:
1406
+ case 4:
1407
1407
  expect(reg.webWorker).toBeDefined();
1408
1408
  reg.webWorker.onmessage({
1409
1409
  data: {
@@ -1411,9 +1411,9 @@ describe('Registration Tests', function () {
1411
1411
  statusCode: 200
1412
1412
  }
1413
1413
  });
1414
- _context29.next = 18;
1414
+ _context29.next = 5;
1415
1415
  return flushPromises();
1416
- case 18:
1416
+ case 5:
1417
1417
  // In a complete failure‐then-recovery scenario, we expect another failure event to have been handled.
1418
1418
  // For that, simulate a second failure event on the new worker.
1419
1419
  reg.webWorker.onmessage({
@@ -1423,18 +1423,18 @@ describe('Registration Tests', function () {
1423
1423
  keepAliveRetryCount: reg.isCCFlow ? 4 : 5
1424
1424
  }
1425
1425
  });
1426
- _context29.next = 21;
1426
+ _context29.next = 6;
1427
1427
  return flushPromises();
1428
- case 21:
1428
+ case 6:
1429
1429
  expect(handleErrorSpy).toBeCalledTimes(4);
1430
1430
 
1431
1431
  // And then re-register successfully:
1432
- _context29.next = 24;
1432
+ _context29.next = 7;
1433
1433
  return reg.triggerRegistration();
1434
- case 24:
1435
- _context29.next = 26;
1434
+ case 7:
1435
+ _context29.next = 8;
1436
1436
  return flushPromises();
1437
- case 26:
1437
+ case 8:
1438
1438
  expect(reg.webWorker).toBeDefined();
1439
1439
  reg.webWorker.onmessage({
1440
1440
  data: {
@@ -1442,12 +1442,12 @@ describe('Registration Tests', function () {
1442
1442
  statusCode: 200
1443
1443
  }
1444
1444
  });
1445
- _context29.next = 30;
1445
+ _context29.next = 9;
1446
1446
  return flushPromises();
1447
- case 30:
1447
+ case 9:
1448
1448
  expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
1449
1449
  expect(reg.webWorker).toBeDefined();
1450
- case 32:
1450
+ case 10:
1451
1451
  case "end":
1452
1452
  return _context29.stop();
1453
1453
  }
@@ -1455,20 +1455,20 @@ describe('Registration Tests', function () {
1455
1455
  })));
1456
1456
  it('cc: verify failover to backup server after 4 keep alive failure with primary server', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee30() {
1457
1457
  var clearKeepaliveSpy, reconnectSpy;
1458
- return _regenerator.default.wrap(function _callee30$(_context30) {
1458
+ return _regenerator.default.wrap(function (_context30) {
1459
1459
  while (1) switch (_context30.prev = _context30.next) {
1460
1460
  case 0:
1461
1461
  // Register with contact center service
1462
1462
  setupRegistration(_objectSpread(_objectSpread({}, MockServiceData), {}, {
1463
1463
  indicator: _types.ServiceIndicator.CONTACT_CENTER
1464
1464
  }));
1465
- _context30.next = 3;
1465
+ _context30.next = 1;
1466
1466
  return beforeEachSetupForKeepalive();
1467
- case 3:
1467
+ case 1:
1468
1468
  webex.request.mockResolvedValueOnce(successPayload);
1469
- _context30.next = 6;
1469
+ _context30.next = 2;
1470
1470
  return reg.triggerRegistration();
1471
- case 6:
1471
+ case 2:
1472
1472
  expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
1473
1473
  expect(reg.webWorker).toBeDefined();
1474
1474
 
@@ -1486,9 +1486,9 @@ describe('Registration Tests', function () {
1486
1486
  });
1487
1487
 
1488
1488
  // Wait for any asynchronous actions to complete
1489
- _context30.next = 13;
1489
+ _context30.next = 3;
1490
1490
  return flushPromises();
1491
- case 13:
1491
+ case 3:
1492
1492
  // Verify that the keepalive timer was cleared and reconnectOnFailure was triggered
1493
1493
  expect(clearKeepaliveSpy).toHaveBeenCalled();
1494
1494
  expect(reconnectSpy).toHaveBeenCalledWith(_constants.RECONNECT_ON_FAILURE_UTIL);
@@ -1496,7 +1496,7 @@ describe('Registration Tests', function () {
1496
1496
  // Verify that the active Mobius URL has been updated to the backup server and registration is active
1497
1497
  expect(reg.getActiveMobiusUrl()).toEqual(mobiusUris.backup[0]);
1498
1498
  expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
1499
- case 17:
1499
+ case 4:
1500
1500
  case "end":
1501
1501
  return _context30.stop();
1502
1502
  }
@@ -1504,12 +1504,12 @@ describe('Registration Tests', function () {
1504
1504
  })));
1505
1505
  it('verify failure keep-alive case with active call present: Restore Success after call ends', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee31() {
1506
1506
  var reconnectSpy, restoreSpy, restartRegSpy, clearTimerSpy, threshold, failureEvent;
1507
- return _regenerator.default.wrap(function _callee31$(_context31) {
1507
+ return _regenerator.default.wrap(function (_context31) {
1508
1508
  while (1) switch (_context31.prev = _context31.next) {
1509
1509
  case 0:
1510
- _context31.next = 2;
1510
+ _context31.next = 1;
1511
1511
  return beforeEachSetupForKeepalive();
1512
- case 2:
1512
+ case 1:
1513
1513
  reconnectSpy = jest.spyOn(reg, 'reconnectOnFailure');
1514
1514
  restoreSpy = jest.spyOn(reg, 'restorePreviousRegistration');
1515
1515
  restartRegSpy = jest.spyOn(reg, 'restartRegistration'); // Simulate an active call.
@@ -1527,9 +1527,9 @@ describe('Registration Tests', function () {
1527
1527
  }
1528
1528
  };
1529
1529
  reg.webWorker.onmessage(failureEvent);
1530
- _context31.next = 13;
1530
+ _context31.next = 2;
1531
1531
  return flushPromises();
1532
- case 13:
1532
+ case 2:
1533
1533
  // At this point, clearKeepaliveTimer was called so the worker is terminated.
1534
1534
  expect(clearTimerSpy).toHaveBeenCalled();
1535
1535
  expect(reg.webWorker).toBeUndefined();
@@ -1552,12 +1552,12 @@ describe('Registration Tests', function () {
1552
1552
  webex.request.mockResolvedValueOnce(successPayload);
1553
1553
 
1554
1554
  // Call reconnectOnFailure manually. With no active calls, this should trigger re-registration.
1555
- _context31.next = 29;
1555
+ _context31.next = 3;
1556
1556
  return reg.reconnectOnFailure(_constants.CALLS_CLEARED_HANDLER_UTIL);
1557
- case 29:
1558
- _context31.next = 31;
1557
+ case 3:
1558
+ _context31.next = 4;
1559
1559
  return flushPromises();
1560
- case 31:
1560
+ case 4:
1561
1561
  expect((0, _keys.default)(reg.callManager.getActiveCalls()).length).toBe(0);
1562
1562
  // After re-registration, registration status becomes ACTIVE and a new worker is created.
1563
1563
  expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
@@ -1566,7 +1566,7 @@ describe('Registration Tests', function () {
1566
1566
  expect(restoreSpy).toBeCalledOnceWith(_constants.CALLS_CLEARED_HANDLER_UTIL);
1567
1567
  expect(restartRegSpy).not.toBeCalled();
1568
1568
  expect(reg.reconnectPending).toStrictEqual(false);
1569
- case 38:
1569
+ case 5:
1570
1570
  case "end":
1571
1571
  return _context31.stop();
1572
1572
  }
@@ -1574,12 +1574,12 @@ describe('Registration Tests', function () {
1574
1574
  })));
1575
1575
  it('checks for keep-alive failure with final error: 404', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee32() {
1576
1576
  var reconnectSpy, restoreSpy, restartRegSpy, clearTimerSpy, handle404CbSpy, registerSpy;
1577
- return _regenerator.default.wrap(function _callee32$(_context32) {
1577
+ return _regenerator.default.wrap(function (_context32) {
1578
1578
  while (1) switch (_context32.prev = _context32.next) {
1579
1579
  case 0:
1580
- _context32.next = 2;
1580
+ _context32.next = 1;
1581
1581
  return beforeEachSetupForKeepalive();
1582
- case 2:
1582
+ case 1:
1583
1583
  webex.request.mockResolvedValueOnce(successPayload);
1584
1584
  reconnectSpy = jest.spyOn(reg, 'reconnectOnFailure');
1585
1585
  restoreSpy = jest.spyOn(reg, 'restorePreviousRegistration');
@@ -1596,9 +1596,9 @@ describe('Registration Tests', function () {
1596
1596
  keepAliveRetryCount: 1
1597
1597
  }
1598
1598
  });
1599
- _context32.next = 12;
1599
+ _context32.next = 2;
1600
1600
  return flushPromises();
1601
- case 12:
1601
+ case 2:
1602
1602
  expect(warnSpy).toBeCalledWith('Keep-alive missed 1 times. Status -> 404 ', expect.objectContaining({
1603
1603
  file: _constants.REGISTRATION_FILE,
1604
1604
  method: 'startKeepaliveTimer'
@@ -1618,7 +1618,7 @@ describe('Registration Tests', function () {
1618
1618
  expect(reg.reconnectPending).toStrictEqual(false);
1619
1619
  expect(handle404CbSpy).toBeCalledOnceWith(_constants.KEEPALIVE_UTIL);
1620
1620
  expect(registerSpy).toBeCalledOnceWith(_constants.KEEPALIVE_UTIL);
1621
- case 23:
1621
+ case 3:
1622
1622
  case "end":
1623
1623
  return _context32.stop();
1624
1624
  }
@@ -1627,12 +1627,12 @@ describe('Registration Tests', function () {
1627
1627
  it('checks for keep-alive failure with 429', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee33() {
1628
1628
  var _reg$deviceInfo$devic;
1629
1629
  var keepaliveSpy, postMessageSpy, clearTimerSpy, retry429Spy;
1630
- return _regenerator.default.wrap(function _callee33$(_context33) {
1630
+ return _regenerator.default.wrap(function (_context33) {
1631
1631
  while (1) switch (_context33.prev = _context33.next) {
1632
1632
  case 0:
1633
- _context33.next = 2;
1633
+ _context33.next = 1;
1634
1634
  return beforeEachSetupForKeepalive();
1635
- case 2:
1635
+ case 1:
1636
1636
  keepaliveSpy = jest.spyOn(reg, 'startKeepaliveTimer');
1637
1637
  postMessageSpy = jest.spyOn(Worker.prototype, 'postMessage');
1638
1638
  clearTimerSpy = jest.spyOn(reg, 'clearKeepaliveTimer');
@@ -1649,9 +1649,9 @@ describe('Registration Tests', function () {
1649
1649
  keepAliveRetryCount: 1
1650
1650
  }
1651
1651
  });
1652
- _context33.next = 9;
1652
+ _context33.next = 2;
1653
1653
  return flushPromises();
1654
- case 9:
1654
+ case 2:
1655
1655
  expect(warnSpy).toBeCalledWith('Keep-alive missed 1 times. Status -> 429 ', expect.objectContaining({
1656
1656
  file: _constants.REGISTRATION_FILE,
1657
1657
  method: 'startKeepaliveTimer'
@@ -1671,9 +1671,9 @@ describe('Registration Tests', function () {
1671
1671
  expect(reg.keepaliveTimer).toBe(undefined);
1672
1672
  expect(reg.webWorker).toBeUndefined();
1673
1673
  jest.advanceTimersByTime(20 * _constants.SEC_TO_MSEC_MFACTOR);
1674
- _context33.next = 19;
1674
+ _context33.next = 3;
1675
1675
  return flushPromises();
1676
- case 19:
1676
+ case 3:
1677
1677
  expect(keepaliveSpy).toBeCalledOnceWith((_reg$deviceInfo$devic = reg.deviceInfo.device) === null || _reg$deviceInfo$devic === void 0 ? void 0 : _reg$deviceInfo$devic.uri, reg.deviceInfo.keepaliveInterval, 'UNKNOWN');
1678
1678
  expect(logSpy).toBeCalledWith('Resuming keepalive after 20 seconds', {
1679
1679
  file: _constants.REGISTRATION_FILE,
@@ -1688,7 +1688,7 @@ describe('Registration Tests', function () {
1688
1688
  retryCountThreshold: expect.any(Number),
1689
1689
  url: expect.any(String)
1690
1690
  }));
1691
- case 23:
1691
+ case 4:
1692
1692
  case "end":
1693
1693
  return _context33.stop();
1694
1694
  }
@@ -1696,12 +1696,12 @@ describe('Registration Tests', function () {
1696
1696
  })));
1697
1697
  it('ensure retryAfter is set when 429 occurs during failover retry', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee34() {
1698
1698
  var retry429Spy;
1699
- return _regenerator.default.wrap(function _callee34$(_context34) {
1699
+ return _regenerator.default.wrap(function (_context34) {
1700
1700
  while (1) switch (_context34.prev = _context34.next) {
1701
1701
  case 0:
1702
- _context34.next = 2;
1702
+ _context34.next = 1;
1703
1703
  return beforeEachSetupForKeepalive();
1704
- case 2:
1704
+ case 1:
1705
1705
  // Simulate loss of registration so failover path attempts a new registration
1706
1706
  reg.clearKeepaliveTimer();
1707
1707
  reg.setStatus(_types.RegistrationStatus.INACTIVE);
@@ -1710,17 +1710,17 @@ describe('Registration Tests', function () {
1710
1710
  webex.request.mockRejectedValueOnce(failurePayload429One);
1711
1711
 
1712
1712
  // Directly schedule the failover attempt
1713
- _context34.next = 9;
1713
+ _context34.next = 2;
1714
1714
  return reg.startFailoverTimer();
1715
- case 9:
1715
+ case 2:
1716
1716
  jest.advanceTimersByTime(33 * _constants.SEC_TO_MSEC_MFACTOR);
1717
- _context34.next = 12;
1717
+ _context34.next = 3;
1718
1718
  return flushPromises();
1719
- case 12:
1719
+ case 3:
1720
1720
  expect(retry429Spy).toBeCalledWith(failurePayload429One.headers['retry-after'], 'startFailoverTimer');
1721
1721
  expect(reg.retryAfter).toEqual(failurePayload429One.headers['retry-after']);
1722
1722
  jest.useRealTimers();
1723
- case 15:
1723
+ case 4:
1724
1724
  case "end":
1725
1725
  return _context34.stop();
1726
1726
  }
@@ -1728,12 +1728,12 @@ describe('Registration Tests', function () {
1728
1728
  })));
1729
1729
  it('sets retryAfter when reconnectOnFailure caller receives 429 after keepalive threshold miss', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee35() {
1730
1730
  var retry429Spy, threshold;
1731
- return _regenerator.default.wrap(function _callee35$(_context35) {
1731
+ return _regenerator.default.wrap(function (_context35) {
1732
1732
  while (1) switch (_context35.prev = _context35.next) {
1733
1733
  case 0:
1734
- _context35.next = 2;
1734
+ _context35.next = 1;
1735
1735
  return beforeEachSetupForKeepalive();
1736
- case 2:
1736
+ case 1:
1737
1737
  retry429Spy = jest.spyOn(reg, 'handle429Retry'); // On reconnectOnFailure(RECONNECT_ON_FAILURE_UTIL) first restore attempt, make registration respond with 429 (retry-after: 20)
1738
1738
  webex.request.mockRejectedValueOnce({
1739
1739
  statusCode: 429,
@@ -1754,13 +1754,13 @@ describe('Registration Tests', function () {
1754
1754
  keepAliveRetryCount: threshold
1755
1755
  }
1756
1756
  });
1757
- _context35.next = 8;
1757
+ _context35.next = 2;
1758
1758
  return flushPromises();
1759
- case 8:
1759
+ case 2:
1760
1760
  // handle429Retry is called with caller 'reconnectOnFailure' → else branch executes and sets retryAfter
1761
1761
  expect(retry429Spy).toBeCalledOnceWith(20, _constants.RECONNECT_ON_FAILURE_UTIL);
1762
1762
  expect(reg.retryAfter).toEqual(undefined); // Clear retryAfter after 429 retry
1763
- case 10:
1763
+ case 3:
1764
1764
  case "end":
1765
1765
  return _context35.stop();
1766
1766
  }
@@ -1770,23 +1770,23 @@ describe('Registration Tests', function () {
1770
1770
  describe('Primary server status checks', function () {
1771
1771
  it('success: primary server status to be up', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee36() {
1772
1772
  var pingSuccessPayload, status;
1773
- return _regenerator.default.wrap(function _callee36$(_context36) {
1773
+ return _regenerator.default.wrap(function (_context36) {
1774
1774
  while (1) switch (_context36.prev = _context36.next) {
1775
1775
  case 0:
1776
1776
  pingSuccessPayload = {
1777
1777
  statusCode: 200
1778
1778
  };
1779
1779
  webex.request.mockResolvedValue(pingSuccessPayload);
1780
- _context36.next = 4;
1780
+ _context36.next = 1;
1781
1781
  return reg.isPrimaryActive();
1782
- case 4:
1782
+ case 1:
1783
1783
  status = _context36.sent;
1784
1784
  expect(webex.request).toBeCalledWith(_objectSpread({
1785
1785
  method: 'GET',
1786
1786
  uri: "https://mobius-dfw.webex.com/api/v1/ping"
1787
1787
  }, (0, _testUtil.getMockRequestTemplate)()));
1788
1788
  expect(status).toEqual(true);
1789
- case 7:
1789
+ case 2:
1790
1790
  case "end":
1791
1791
  return _context36.stop();
1792
1792
  }
@@ -1794,23 +1794,23 @@ describe('Registration Tests', function () {
1794
1794
  })));
1795
1795
  it('failed: primary server status to be down', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee37() {
1796
1796
  var pingFailurePayload, status;
1797
- return _regenerator.default.wrap(function _callee37$(_context37) {
1797
+ return _regenerator.default.wrap(function (_context37) {
1798
1798
  while (1) switch (_context37.prev = _context37.next) {
1799
1799
  case 0:
1800
1800
  pingFailurePayload = {
1801
1801
  statusCode: 500
1802
1802
  };
1803
1803
  webex.request.mockResolvedValue(pingFailurePayload);
1804
- _context37.next = 4;
1804
+ _context37.next = 1;
1805
1805
  return reg.isPrimaryActive();
1806
- case 4:
1806
+ case 1:
1807
1807
  status = _context37.sent;
1808
1808
  expect(webex.request).toBeCalledWith(_objectSpread({
1809
1809
  method: 'GET',
1810
1810
  uri: "https://mobius-dfw.webex.com/api/v1/ping"
1811
1811
  }, (0, _testUtil.getMockRequestTemplate)()));
1812
1812
  expect(status).toEqual(false);
1813
- case 7:
1813
+ case 2:
1814
1814
  case "end":
1815
1815
  return _context37.stop();
1816
1816
  }