@webex/calling 3.10.0-next.15 → 3.10.0-next.17
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.
- package/dist/CallingClient/constants.js +3 -2
- package/dist/CallingClient/constants.js.map +1 -1
- package/dist/CallingClient/registration/register.js +434 -337
- package/dist/CallingClient/registration/register.js.map +1 -1
- package/dist/CallingClient/registration/register.test.js +245 -181
- package/dist/CallingClient/registration/register.test.js.map +1 -1
- package/dist/CallingClient/registration/types.js.map +1 -1
- package/dist/SDKConnector/types.js.map +1 -1
- package/dist/module/CallingClient/constants.js +1 -0
- package/dist/module/CallingClient/registration/register.js +65 -1
- package/dist/types/CallingClient/constants.d.ts +1 -0
- package/dist/types/CallingClient/constants.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/register.d.ts +4 -0
- package/dist/types/CallingClient/registration/register.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/types.d.ts +6 -0
- package/dist/types/CallingClient/registration/types.d.ts.map +1 -1
- package/dist/types/SDKConnector/types.d.ts +6 -0
- package/dist/types/SDKConnector/types.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -10,9 +10,12 @@ var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/defi
|
|
|
10
10
|
var _WeakMap = require("@babel/runtime-corejs2/core-js/weak-map");
|
|
11
11
|
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
12
12
|
var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
|
|
13
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/slicedToArray"));
|
|
13
14
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
|
|
14
15
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
15
16
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
17
|
+
var _now = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/date/now"));
|
|
18
|
+
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
|
|
16
19
|
var _keys = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/keys"));
|
|
17
20
|
var _values = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/values"));
|
|
18
21
|
var _asyncMutex = require("async-mutex");
|
|
@@ -141,6 +144,7 @@ describe('Registration Tests', function () {
|
|
|
141
144
|
jest.clearAllTimers();
|
|
142
145
|
jest.clearAllMocks();
|
|
143
146
|
jest.useRealTimers();
|
|
147
|
+
localStorage.clear();
|
|
144
148
|
});
|
|
145
149
|
it('verify successful registration', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
146
150
|
return _regenerator.default.wrap(function (_context) {
|
|
@@ -789,19 +793,77 @@ describe('Registration Tests', function () {
|
|
|
789
793
|
})));
|
|
790
794
|
});
|
|
791
795
|
describe('Registration failover tests', function () {
|
|
792
|
-
it('
|
|
796
|
+
it('persists failover state in localStorage when primary retry is scheduled', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee13() {
|
|
797
|
+
var key, raw, state;
|
|
793
798
|
return _regenerator.default.wrap(function (_context13) {
|
|
794
799
|
while (1) switch (_context13.prev = _context13.next) {
|
|
800
|
+
case 0:
|
|
801
|
+
jest.useFakeTimers();
|
|
802
|
+
// Force initial registration to fail to schedule failover
|
|
803
|
+
webex.request.mockRejectedValueOnce(failurePayload);
|
|
804
|
+
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.IDLE);
|
|
805
|
+
_context13.next = 1;
|
|
806
|
+
return reg.triggerRegistration();
|
|
807
|
+
case 1:
|
|
808
|
+
// A failover timer should be scheduled; verify localStorage contains state
|
|
809
|
+
key = "wxc-failover-state.".concat(webex.internal.device.userId);
|
|
810
|
+
raw = localStorage.getItem(key);
|
|
811
|
+
expect(raw).toBeTruthy();
|
|
812
|
+
state = JSON.parse(raw);
|
|
813
|
+
expect(state).toEqual(expect.objectContaining({
|
|
814
|
+
attempt: 1,
|
|
815
|
+
timeElapsed: 0,
|
|
816
|
+
retryScheduledTime: expect.any(Number),
|
|
817
|
+
serverType: 'primary'
|
|
818
|
+
}));
|
|
819
|
+
case 2:
|
|
820
|
+
case "end":
|
|
821
|
+
return _context13.stop();
|
|
822
|
+
}
|
|
823
|
+
}, _callee13);
|
|
824
|
+
})));
|
|
825
|
+
it('resumes failover from localStorage on triggerRegistration', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee14() {
|
|
826
|
+
var key, now, failoverSpy, _failoverSpy$mock$cal, attemptArg, timeElapsedArg;
|
|
827
|
+
return _regenerator.default.wrap(function (_context14) {
|
|
828
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
829
|
+
case 0:
|
|
830
|
+
jest.useFakeTimers();
|
|
831
|
+
key = "wxc-failover-state.".concat(webex.internal.device.userId);
|
|
832
|
+
now = Math.floor((0, _now.default)() / 1000); // Seed a cached state indicating a retry should have already occurred 5s ago
|
|
833
|
+
localStorage.setItem(key, (0, _stringify.default)({
|
|
834
|
+
attempt: 3,
|
|
835
|
+
timeElapsed: 12,
|
|
836
|
+
retryScheduledTime: now - 5,
|
|
837
|
+
serverType: 'primary'
|
|
838
|
+
}));
|
|
839
|
+
failoverSpy = jest.spyOn(reg, 'startFailoverTimer');
|
|
840
|
+
webex.request.mockResolvedValueOnce(successPayload);
|
|
841
|
+
_context14.next = 1;
|
|
842
|
+
return reg.triggerRegistration();
|
|
843
|
+
case 1:
|
|
844
|
+
expect(failoverSpy).toHaveBeenCalledTimes(1);
|
|
845
|
+
_failoverSpy$mock$cal = (0, _slicedToArray2.default)(failoverSpy.mock.calls[0], 2), attemptArg = _failoverSpy$mock$cal[0], timeElapsedArg = _failoverSpy$mock$cal[1];
|
|
846
|
+
expect(attemptArg).toBe(3);
|
|
847
|
+
expect(timeElapsedArg).toBeGreaterThanOrEqual(12);
|
|
848
|
+
case 2:
|
|
849
|
+
case "end":
|
|
850
|
+
return _context14.stop();
|
|
851
|
+
}
|
|
852
|
+
}, _callee14);
|
|
853
|
+
})));
|
|
854
|
+
it('verify unreachable primary with reachable backup servers', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee15() {
|
|
855
|
+
return _regenerator.default.wrap(function (_context15) {
|
|
856
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
795
857
|
case 0:
|
|
796
858
|
jest.useFakeTimers();
|
|
797
859
|
// try the primary twice and register successfully with backup servers
|
|
798
860
|
webex.request.mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload).mockResolvedValueOnce(successPayload);
|
|
799
861
|
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.IDLE);
|
|
800
|
-
|
|
862
|
+
_context15.next = 1;
|
|
801
863
|
return reg.triggerRegistration();
|
|
802
864
|
case 1:
|
|
803
865
|
jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
|
|
804
|
-
|
|
866
|
+
_context15.next = 2;
|
|
805
867
|
return flushPromises();
|
|
806
868
|
case 2:
|
|
807
869
|
expect(webex.request).toBeCalledTimes(3);
|
|
@@ -819,13 +881,13 @@ describe('Registration Tests', function () {
|
|
|
819
881
|
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
882
|
case 3:
|
|
821
883
|
case "end":
|
|
822
|
-
return
|
|
884
|
+
return _context15.stop();
|
|
823
885
|
}
|
|
824
|
-
},
|
|
886
|
+
}, _callee15);
|
|
825
887
|
})));
|
|
826
|
-
it('cc: verify unreachable primary with reachable backup server', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
827
|
-
return _regenerator.default.wrap(function (
|
|
828
|
-
while (1) switch (
|
|
888
|
+
it('cc: verify unreachable primary with reachable backup server', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee16() {
|
|
889
|
+
return _regenerator.default.wrap(function (_context16) {
|
|
890
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
829
891
|
case 0:
|
|
830
892
|
setupRegistration(_objectSpread(_objectSpread({}, MockServiceData), {}, {
|
|
831
893
|
indicator: _types.ServiceIndicator.CONTACT_CENTER
|
|
@@ -833,11 +895,11 @@ describe('Registration Tests', function () {
|
|
|
833
895
|
jest.useFakeTimers();
|
|
834
896
|
webex.request.mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload).mockResolvedValueOnce(successPayload);
|
|
835
897
|
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.IDLE);
|
|
836
|
-
|
|
898
|
+
_context16.next = 1;
|
|
837
899
|
return reg.triggerRegistration();
|
|
838
900
|
case 1:
|
|
839
901
|
jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
|
|
840
|
-
|
|
902
|
+
_context16.next = 2;
|
|
841
903
|
return flushPromises();
|
|
842
904
|
case 2:
|
|
843
905
|
expect(webex.request).toBeCalledTimes(3);
|
|
@@ -854,27 +916,27 @@ describe('Registration Tests', function () {
|
|
|
854
916
|
expect(reg.getActiveMobiusUrl()).toEqual(mobiusUris.backup[0]);
|
|
855
917
|
case 3:
|
|
856
918
|
case "end":
|
|
857
|
-
return
|
|
919
|
+
return _context16.stop();
|
|
858
920
|
}
|
|
859
|
-
},
|
|
921
|
+
}, _callee16);
|
|
860
922
|
})));
|
|
861
|
-
it('verify unreachable primary and backup servers', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
862
|
-
return _regenerator.default.wrap(function (
|
|
863
|
-
while (1) switch (
|
|
923
|
+
it('verify unreachable primary and backup servers', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee17() {
|
|
924
|
+
return _regenerator.default.wrap(function (_context17) {
|
|
925
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
864
926
|
case 0:
|
|
865
927
|
jest.useFakeTimers();
|
|
866
928
|
// try the primary twice and register successfully with backup servers
|
|
867
929
|
webex.request.mockRejectedValue(failurePayload);
|
|
868
930
|
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.IDLE);
|
|
869
|
-
|
|
931
|
+
_context17.next = 1;
|
|
870
932
|
return reg.triggerRegistration();
|
|
871
933
|
case 1:
|
|
872
934
|
jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
|
|
873
|
-
|
|
935
|
+
_context17.next = 2;
|
|
874
936
|
return flushPromises();
|
|
875
937
|
case 2:
|
|
876
938
|
jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
|
|
877
|
-
|
|
939
|
+
_context17.next = 3;
|
|
878
940
|
return flushPromises();
|
|
879
941
|
case 3:
|
|
880
942
|
/*
|
|
@@ -899,27 +961,27 @@ describe('Registration Tests', function () {
|
|
|
899
961
|
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
|
|
900
962
|
case 4:
|
|
901
963
|
case "end":
|
|
902
|
-
return
|
|
964
|
+
return _context17.stop();
|
|
903
965
|
}
|
|
904
|
-
},
|
|
966
|
+
}, _callee17);
|
|
905
967
|
})));
|
|
906
968
|
});
|
|
907
969
|
describe('Registration failback tests', function () {
|
|
908
970
|
var isPrimaryActiveSpy;
|
|
909
|
-
beforeEach(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
910
|
-
return _regenerator.default.wrap(function (
|
|
911
|
-
while (1) switch (
|
|
971
|
+
beforeEach(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee18() {
|
|
972
|
+
return _regenerator.default.wrap(function (_context18) {
|
|
973
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
912
974
|
case 0:
|
|
913
975
|
isPrimaryActiveSpy = jest.spyOn(reg, 'isPrimaryActive');
|
|
914
976
|
isPrimaryActiveSpy.mockReturnValue(true);
|
|
915
977
|
/* keep keepalive as active so that it wont interfere with the failback tests */
|
|
916
978
|
jest.useFakeTimers();
|
|
917
979
|
postRegistrationSpy.mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload).mockResolvedValueOnce(successPayload);
|
|
918
|
-
|
|
980
|
+
_context18.next = 1;
|
|
919
981
|
return reg.triggerRegistration();
|
|
920
982
|
case 1:
|
|
921
983
|
jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
|
|
922
|
-
|
|
984
|
+
_context18.next = 2;
|
|
923
985
|
return flushPromises();
|
|
924
986
|
case 2:
|
|
925
987
|
reg.rehomingIntervalMin = _constants.DEFAULT_REHOMING_INTERVAL_MIN;
|
|
@@ -933,17 +995,17 @@ describe('Registration Tests', function () {
|
|
|
933
995
|
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
|
|
934
996
|
case 3:
|
|
935
997
|
case "end":
|
|
936
|
-
return
|
|
998
|
+
return _context18.stop();
|
|
937
999
|
}
|
|
938
|
-
},
|
|
1000
|
+
}, _callee18);
|
|
939
1001
|
})));
|
|
940
1002
|
afterEach(function () {
|
|
941
1003
|
jest.clearAllTimers();
|
|
942
1004
|
jest.clearAllMocks();
|
|
943
1005
|
});
|
|
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
|
|
945
|
-
return _regenerator.default.wrap(function (
|
|
946
|
-
while (1) switch (
|
|
1006
|
+
it('verify 429 error with failback to primary after initial registration with backup: Restore failure', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee19() {
|
|
1007
|
+
return _regenerator.default.wrap(function (_context19) {
|
|
1008
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
947
1009
|
case 0:
|
|
948
1010
|
// delete should be successful
|
|
949
1011
|
global.fetch = jest.fn(function () {
|
|
@@ -959,7 +1021,7 @@ describe('Registration Tests', function () {
|
|
|
959
1021
|
|
|
960
1022
|
/* Wait for failback to be triggered. */
|
|
961
1023
|
jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
|
|
962
|
-
|
|
1024
|
+
_context19.next = 1;
|
|
963
1025
|
return flushPromises();
|
|
964
1026
|
case 1:
|
|
965
1027
|
expect(infoSpy).toBeCalledWith("Attempting failback to primary.", {
|
|
@@ -967,7 +1029,7 @@ describe('Registration Tests', function () {
|
|
|
967
1029
|
file: _constants.REGISTRATION_FILE
|
|
968
1030
|
});
|
|
969
1031
|
jest.advanceTimersByTime(10000);
|
|
970
|
-
|
|
1032
|
+
_context19.next = 2;
|
|
971
1033
|
return flushPromises();
|
|
972
1034
|
case 2:
|
|
973
1035
|
expect(retry429Spy).toBeCalledWith(failurePayload429Two.headers['retry-after'], 'executeFailback');
|
|
@@ -983,19 +1045,19 @@ describe('Registration Tests', function () {
|
|
|
983
1045
|
expect(reg.rehomingIntervalMax).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MAX);
|
|
984
1046
|
case 3:
|
|
985
1047
|
case "end":
|
|
986
|
-
return
|
|
1048
|
+
return _context19.stop();
|
|
987
1049
|
}
|
|
988
|
-
},
|
|
1050
|
+
}, _callee19);
|
|
989
1051
|
})));
|
|
990
|
-
it('verify unsuccessful failback to primary after initial registration with backup: Restore failure', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
991
|
-
return _regenerator.default.wrap(function (
|
|
992
|
-
while (1) switch (
|
|
1052
|
+
it('verify unsuccessful failback to primary after initial registration with backup: Restore failure', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee20() {
|
|
1053
|
+
return _regenerator.default.wrap(function (_context20) {
|
|
1054
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
993
1055
|
case 0:
|
|
994
1056
|
postRegistrationSpy.mockRejectedValue(failurePayload);
|
|
995
1057
|
|
|
996
1058
|
/* Wait for failback to be triggered. */
|
|
997
1059
|
jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
|
|
998
|
-
|
|
1060
|
+
_context20.next = 1;
|
|
999
1061
|
return flushPromises();
|
|
1000
1062
|
case 1:
|
|
1001
1063
|
expect(infoSpy).toBeCalledWith("Attempting failback to primary.", {
|
|
@@ -1010,14 +1072,14 @@ describe('Registration Tests', function () {
|
|
|
1010
1072
|
expect(reg.rehomingIntervalMax).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MAX);
|
|
1011
1073
|
case 2:
|
|
1012
1074
|
case "end":
|
|
1013
|
-
return
|
|
1075
|
+
return _context20.stop();
|
|
1014
1076
|
}
|
|
1015
|
-
},
|
|
1077
|
+
}, _callee20);
|
|
1016
1078
|
})));
|
|
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
|
|
1079
|
+
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 _callee21() {
|
|
1018
1080
|
var finalErrorPayload;
|
|
1019
|
-
return _regenerator.default.wrap(function (
|
|
1020
|
-
while (1) switch (
|
|
1081
|
+
return _regenerator.default.wrap(function (_context21) {
|
|
1082
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1021
1083
|
case 0:
|
|
1022
1084
|
finalErrorPayload = {
|
|
1023
1085
|
statusCode: 401,
|
|
@@ -1027,7 +1089,7 @@ describe('Registration Tests', function () {
|
|
|
1027
1089
|
postRegistrationSpy.mockRejectedValue(finalErrorPayload).mockRejectedValueOnce(failurePayload);
|
|
1028
1090
|
/* Wait for failback to be triggered. */
|
|
1029
1091
|
jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
|
|
1030
|
-
|
|
1092
|
+
_context21.next = 1;
|
|
1031
1093
|
return flushPromises();
|
|
1032
1094
|
case 1:
|
|
1033
1095
|
expect(infoSpy).toBeCalledWith("Attempting failback to primary.", {
|
|
@@ -1042,19 +1104,19 @@ describe('Registration Tests', function () {
|
|
|
1042
1104
|
expect(reg.rehomingIntervalMax).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MAX);
|
|
1043
1105
|
case 2:
|
|
1044
1106
|
case "end":
|
|
1045
|
-
return
|
|
1107
|
+
return _context21.stop();
|
|
1046
1108
|
}
|
|
1047
|
-
},
|
|
1109
|
+
}, _callee21);
|
|
1048
1110
|
})));
|
|
1049
|
-
it('verify unsuccessful failback to primary after initial registration with backup: Restore success', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
1050
|
-
return _regenerator.default.wrap(function (
|
|
1051
|
-
while (1) switch (
|
|
1111
|
+
it('verify unsuccessful failback to primary after initial registration with backup: Restore success', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee22() {
|
|
1112
|
+
return _regenerator.default.wrap(function (_context22) {
|
|
1113
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1052
1114
|
case 0:
|
|
1053
1115
|
postRegistrationSpy.mockRejectedValueOnce(failurePayload).mockResolvedValue(successPayload);
|
|
1054
1116
|
|
|
1055
1117
|
/* Wait for failback to be triggered. */
|
|
1056
1118
|
jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
|
|
1057
|
-
|
|
1119
|
+
_context22.next = 1;
|
|
1058
1120
|
return flushPromises();
|
|
1059
1121
|
case 1:
|
|
1060
1122
|
expect(infoSpy).toBeCalledWith("Attempting failback to primary.", {
|
|
@@ -1070,19 +1132,19 @@ describe('Registration Tests', function () {
|
|
|
1070
1132
|
expect(reg.rehomingIntervalMax).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MAX);
|
|
1071
1133
|
case 2:
|
|
1072
1134
|
case "end":
|
|
1073
|
-
return
|
|
1135
|
+
return _context22.stop();
|
|
1074
1136
|
}
|
|
1075
|
-
},
|
|
1137
|
+
}, _callee22);
|
|
1076
1138
|
})));
|
|
1077
|
-
it('verify successful failback to primary after initial registration with backup', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
1078
|
-
return _regenerator.default.wrap(function (
|
|
1079
|
-
while (1) switch (
|
|
1139
|
+
it('verify successful failback to primary after initial registration with backup', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee23() {
|
|
1140
|
+
return _regenerator.default.wrap(function (_context23) {
|
|
1141
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1080
1142
|
case 0:
|
|
1081
1143
|
postRegistrationSpy.mockResolvedValue(successPayload);
|
|
1082
1144
|
|
|
1083
1145
|
/* Wait for failback to be triggered. */
|
|
1084
1146
|
jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
|
|
1085
|
-
|
|
1147
|
+
_context23.next = 1;
|
|
1086
1148
|
return flushPromises();
|
|
1087
1149
|
case 1:
|
|
1088
1150
|
expect(infoSpy).toBeCalledWith("Attempting failback to primary.", {
|
|
@@ -1100,13 +1162,13 @@ describe('Registration Tests', function () {
|
|
|
1100
1162
|
expect(reg.rehomingIntervalMax).toBe(_registerFixtures.mockPostResponse.rehomingIntervalMax);
|
|
1101
1163
|
case 2:
|
|
1102
1164
|
case "end":
|
|
1103
|
-
return
|
|
1165
|
+
return _context23.stop();
|
|
1104
1166
|
}
|
|
1105
|
-
},
|
|
1167
|
+
}, _callee23);
|
|
1106
1168
|
})));
|
|
1107
|
-
it('verify unsuccessful failback attempt due to active call', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
1108
|
-
return _regenerator.default.wrap(function (
|
|
1109
|
-
while (1) switch (
|
|
1169
|
+
it('verify unsuccessful failback attempt due to active call', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee24() {
|
|
1170
|
+
return _regenerator.default.wrap(function (_context24) {
|
|
1171
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1110
1172
|
case 0:
|
|
1111
1173
|
/** create a new call */
|
|
1112
1174
|
reg.callManager.createCall();
|
|
@@ -1115,7 +1177,7 @@ describe('Registration Tests', function () {
|
|
|
1115
1177
|
|
|
1116
1178
|
/* Wait for failback to be triggered. */
|
|
1117
1179
|
jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
|
|
1118
|
-
|
|
1180
|
+
_context24.next = 1;
|
|
1119
1181
|
return flushPromises();
|
|
1120
1182
|
case 1:
|
|
1121
1183
|
expect(infoSpy).toBeCalledWith("Active calls present or primary Mobius is down, deferring failback to next cycle.", {
|
|
@@ -1137,19 +1199,19 @@ describe('Registration Tests', function () {
|
|
|
1137
1199
|
expect(reg.rehomingIntervalMax).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MAX);
|
|
1138
1200
|
case 2:
|
|
1139
1201
|
case "end":
|
|
1140
|
-
return
|
|
1202
|
+
return _context24.stop();
|
|
1141
1203
|
}
|
|
1142
|
-
},
|
|
1204
|
+
}, _callee24);
|
|
1143
1205
|
})));
|
|
1144
|
-
it('verify unsuccessful failback attempt due to primary server being down', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
1145
|
-
return _regenerator.default.wrap(function (
|
|
1146
|
-
while (1) switch (
|
|
1206
|
+
it('verify unsuccessful failback attempt due to primary server being down', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee25() {
|
|
1207
|
+
return _regenerator.default.wrap(function (_context25) {
|
|
1208
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
1147
1209
|
case 0:
|
|
1148
1210
|
isPrimaryActiveSpy.mockReturnValue(false);
|
|
1149
1211
|
|
|
1150
1212
|
/* Wait for failback to be triggered. */
|
|
1151
1213
|
jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
|
|
1152
|
-
|
|
1214
|
+
_context25.next = 1;
|
|
1153
1215
|
return flushPromises();
|
|
1154
1216
|
case 1:
|
|
1155
1217
|
expect(infoSpy).toBeCalledWith("Active calls present or primary Mobius is down, deferring failback to next cycle.", {
|
|
@@ -1163,34 +1225,34 @@ describe('Registration Tests', function () {
|
|
|
1163
1225
|
expect(reg.getStatus()).toBe(_types.RegistrationStatus.ACTIVE);
|
|
1164
1226
|
case 2:
|
|
1165
1227
|
case "end":
|
|
1166
|
-
return
|
|
1228
|
+
return _context25.stop();
|
|
1167
1229
|
}
|
|
1168
|
-
},
|
|
1230
|
+
}, _callee25);
|
|
1169
1231
|
})));
|
|
1170
1232
|
});
|
|
1171
1233
|
|
|
1172
1234
|
// Keep-alive related test cases
|
|
1173
1235
|
describe('Keep-alive Tests', function () {
|
|
1174
1236
|
var beforeEachSetupForKeepalive = /*#__PURE__*/function () {
|
|
1175
|
-
var
|
|
1176
|
-
return _regenerator.default.wrap(function (
|
|
1177
|
-
while (1) switch (
|
|
1237
|
+
var _ref26 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee26() {
|
|
1238
|
+
return _regenerator.default.wrap(function (_context26) {
|
|
1239
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
1178
1240
|
case 0:
|
|
1179
1241
|
postRegistrationSpy.mockResolvedValueOnce(successPayload);
|
|
1180
1242
|
jest.useFakeTimers();
|
|
1181
|
-
|
|
1243
|
+
_context26.next = 1;
|
|
1182
1244
|
return reg.triggerRegistration();
|
|
1183
1245
|
case 1:
|
|
1184
1246
|
expect(reg.getStatus()).toBe(_types.RegistrationStatus.ACTIVE);
|
|
1185
1247
|
expect(reg.webWorker).toBeDefined();
|
|
1186
1248
|
case 2:
|
|
1187
1249
|
case "end":
|
|
1188
|
-
return
|
|
1250
|
+
return _context26.stop();
|
|
1189
1251
|
}
|
|
1190
|
-
},
|
|
1252
|
+
}, _callee26);
|
|
1191
1253
|
}));
|
|
1192
1254
|
return function beforeEachSetupForKeepalive() {
|
|
1193
|
-
return
|
|
1255
|
+
return _ref26.apply(this, arguments);
|
|
1194
1256
|
};
|
|
1195
1257
|
}();
|
|
1196
1258
|
afterEach(function () {
|
|
@@ -1203,13 +1265,13 @@ describe('Registration Tests', function () {
|
|
|
1203
1265
|
call.end();
|
|
1204
1266
|
});
|
|
1205
1267
|
});
|
|
1206
|
-
it('verify successful keep-alive cases', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
1268
|
+
it('verify successful keep-alive cases', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee27() {
|
|
1207
1269
|
var postMessageSpy;
|
|
1208
|
-
return _regenerator.default.wrap(function (
|
|
1209
|
-
while (1) switch (
|
|
1270
|
+
return _regenerator.default.wrap(function (_context27) {
|
|
1271
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
1210
1272
|
case 0:
|
|
1211
1273
|
postMessageSpy = jest.spyOn(Worker.prototype, 'postMessage');
|
|
1212
|
-
|
|
1274
|
+
_context27.next = 1;
|
|
1213
1275
|
return beforeEachSetupForKeepalive();
|
|
1214
1276
|
case 1:
|
|
1215
1277
|
expect(reg.webWorker).toBeDefined();
|
|
@@ -1230,16 +1292,16 @@ describe('Registration Tests', function () {
|
|
|
1230
1292
|
expect(lineEmitter).toBeCalledWith(_types4.LINE_EVENTS.RECONNECTED);
|
|
1231
1293
|
case 2:
|
|
1232
1294
|
case "end":
|
|
1233
|
-
return
|
|
1295
|
+
return _context27.stop();
|
|
1234
1296
|
}
|
|
1235
|
-
},
|
|
1297
|
+
}, _callee27);
|
|
1236
1298
|
})));
|
|
1237
|
-
it('verify failure keep-alive cases: Retry Success', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
1299
|
+
it('verify failure keep-alive cases: Retry Success', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee28() {
|
|
1238
1300
|
var worker;
|
|
1239
|
-
return _regenerator.default.wrap(function (
|
|
1240
|
-
while (1) switch (
|
|
1301
|
+
return _regenerator.default.wrap(function (_context28) {
|
|
1302
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
1241
1303
|
case 0:
|
|
1242
|
-
|
|
1304
|
+
_context28.next = 1;
|
|
1243
1305
|
return beforeEachSetupForKeepalive();
|
|
1244
1306
|
case 1:
|
|
1245
1307
|
worker = reg.webWorker;
|
|
@@ -1262,16 +1324,16 @@ describe('Registration Tests', function () {
|
|
|
1262
1324
|
expect(lineEmitter).toHaveBeenCalledWith(_types4.LINE_EVENTS.RECONNECTED);
|
|
1263
1325
|
case 2:
|
|
1264
1326
|
case "end":
|
|
1265
|
-
return
|
|
1327
|
+
return _context28.stop();
|
|
1266
1328
|
}
|
|
1267
|
-
},
|
|
1329
|
+
}, _callee28);
|
|
1268
1330
|
})));
|
|
1269
|
-
it('verify failure keep-alive cases: Restore failure', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
1331
|
+
it('verify failure keep-alive cases: Restore failure', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee29() {
|
|
1270
1332
|
var reconnectSpy, restoreSpy, restartRegSpy, RETRY_COUNT_THRESHOLD, failureEvent;
|
|
1271
|
-
return _regenerator.default.wrap(function (
|
|
1272
|
-
while (1) switch (
|
|
1333
|
+
return _regenerator.default.wrap(function (_context29) {
|
|
1334
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
1273
1335
|
case 0:
|
|
1274
|
-
|
|
1336
|
+
_context29.next = 1;
|
|
1275
1337
|
return beforeEachSetupForKeepalive();
|
|
1276
1338
|
case 1:
|
|
1277
1339
|
reconnectSpy = jest.spyOn(reg, 'reconnectOnFailure');
|
|
@@ -1298,7 +1360,7 @@ describe('Registration Tests', function () {
|
|
|
1298
1360
|
}
|
|
1299
1361
|
};
|
|
1300
1362
|
reg.webWorker.onmessage(failureEvent);
|
|
1301
|
-
|
|
1363
|
+
_context29.next = 2;
|
|
1302
1364
|
return flushPromises();
|
|
1303
1365
|
case 2:
|
|
1304
1366
|
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
|
|
@@ -1313,16 +1375,16 @@ describe('Registration Tests', function () {
|
|
|
1313
1375
|
}));
|
|
1314
1376
|
case 3:
|
|
1315
1377
|
case "end":
|
|
1316
|
-
return
|
|
1378
|
+
return _context29.stop();
|
|
1317
1379
|
}
|
|
1318
|
-
},
|
|
1380
|
+
}, _callee29);
|
|
1319
1381
|
})));
|
|
1320
|
-
it('verify failure keep-alive cases: Restore Success', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
1382
|
+
it('verify failure keep-alive cases: Restore Success', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee30() {
|
|
1321
1383
|
var reconnectSpy, url;
|
|
1322
|
-
return _regenerator.default.wrap(function (
|
|
1323
|
-
while (1) switch (
|
|
1384
|
+
return _regenerator.default.wrap(function (_context30) {
|
|
1385
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
1324
1386
|
case 0:
|
|
1325
|
-
|
|
1387
|
+
_context30.next = 1;
|
|
1326
1388
|
return beforeEachSetupForKeepalive();
|
|
1327
1389
|
case 1:
|
|
1328
1390
|
expect(reg.webWorker).toBeDefined();
|
|
@@ -1338,16 +1400,17 @@ describe('Registration Tests', function () {
|
|
|
1338
1400
|
}
|
|
1339
1401
|
});
|
|
1340
1402
|
jest.advanceTimersByTime(1000);
|
|
1341
|
-
|
|
1403
|
+
_context30.next = 2;
|
|
1342
1404
|
return flushPromises();
|
|
1343
1405
|
case 2:
|
|
1344
1406
|
expect(reg.webWorker).toBeUndefined();
|
|
1345
1407
|
expect(reconnectSpy).toBeCalledOnceWith(_constants.RECONNECT_ON_FAILURE_UTIL);
|
|
1408
|
+
localStorage.clear();
|
|
1346
1409
|
webex.request.mockResolvedValueOnce(successPayload);
|
|
1347
|
-
|
|
1410
|
+
_context30.next = 3;
|
|
1348
1411
|
return reg.triggerRegistration();
|
|
1349
1412
|
case 3:
|
|
1350
|
-
|
|
1413
|
+
_context30.next = 4;
|
|
1351
1414
|
return flushPromises();
|
|
1352
1415
|
case 4:
|
|
1353
1416
|
expect(reg.webWorker).toBeDefined();
|
|
@@ -1360,7 +1423,7 @@ describe('Registration Tests', function () {
|
|
|
1360
1423
|
|
|
1361
1424
|
// Advance timers and flush any remaining promises.
|
|
1362
1425
|
jest.advanceTimersByTime(1000);
|
|
1363
|
-
|
|
1426
|
+
_context30.next = 5;
|
|
1364
1427
|
return flushPromises();
|
|
1365
1428
|
case 5:
|
|
1366
1429
|
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
|
|
@@ -1372,15 +1435,15 @@ describe('Registration Tests', function () {
|
|
|
1372
1435
|
expect(reg.getActiveMobiusUrl()).toStrictEqual(url);
|
|
1373
1436
|
case 6:
|
|
1374
1437
|
case "end":
|
|
1375
|
-
return
|
|
1438
|
+
return _context30.stop();
|
|
1376
1439
|
}
|
|
1377
|
-
},
|
|
1440
|
+
}, _callee30);
|
|
1378
1441
|
})));
|
|
1379
|
-
it('verify failure followed by recovery of keepalive', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
1380
|
-
return _regenerator.default.wrap(function (
|
|
1381
|
-
while (1) switch (
|
|
1442
|
+
it('verify failure followed by recovery of keepalive', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee31() {
|
|
1443
|
+
return _regenerator.default.wrap(function (_context31) {
|
|
1444
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
1382
1445
|
case 0:
|
|
1383
|
-
|
|
1446
|
+
_context31.next = 1;
|
|
1384
1447
|
return beforeEachSetupForKeepalive();
|
|
1385
1448
|
case 1:
|
|
1386
1449
|
expect(reg.getStatus()).toBe(_types.RegistrationStatus.ACTIVE);
|
|
@@ -1393,15 +1456,16 @@ describe('Registration Tests', function () {
|
|
|
1393
1456
|
keepAliveRetryCount: reg.isCCFlow ? 4 : 5
|
|
1394
1457
|
}
|
|
1395
1458
|
});
|
|
1396
|
-
|
|
1459
|
+
_context31.next = 2;
|
|
1397
1460
|
return flushPromises();
|
|
1398
1461
|
case 2:
|
|
1399
1462
|
expect(reg.webWorker).toBeUndefined();
|
|
1400
1463
|
expect(handleErrorSpy).toBeCalledTimes(3);
|
|
1401
|
-
|
|
1464
|
+
localStorage.clear();
|
|
1465
|
+
_context31.next = 3;
|
|
1402
1466
|
return reg.triggerRegistration();
|
|
1403
1467
|
case 3:
|
|
1404
|
-
|
|
1468
|
+
_context31.next = 4;
|
|
1405
1469
|
return flushPromises();
|
|
1406
1470
|
case 4:
|
|
1407
1471
|
expect(reg.webWorker).toBeDefined();
|
|
@@ -1411,7 +1475,7 @@ describe('Registration Tests', function () {
|
|
|
1411
1475
|
statusCode: 200
|
|
1412
1476
|
}
|
|
1413
1477
|
});
|
|
1414
|
-
|
|
1478
|
+
_context31.next = 5;
|
|
1415
1479
|
return flushPromises();
|
|
1416
1480
|
case 5:
|
|
1417
1481
|
// In a complete failure‐then-recovery scenario, we expect another failure event to have been handled.
|
|
@@ -1423,16 +1487,16 @@ describe('Registration Tests', function () {
|
|
|
1423
1487
|
keepAliveRetryCount: reg.isCCFlow ? 4 : 5
|
|
1424
1488
|
}
|
|
1425
1489
|
});
|
|
1426
|
-
|
|
1490
|
+
_context31.next = 6;
|
|
1427
1491
|
return flushPromises();
|
|
1428
1492
|
case 6:
|
|
1429
1493
|
expect(handleErrorSpy).toBeCalledTimes(4);
|
|
1430
1494
|
|
|
1431
1495
|
// And then re-register successfully:
|
|
1432
|
-
|
|
1496
|
+
_context31.next = 7;
|
|
1433
1497
|
return reg.triggerRegistration();
|
|
1434
1498
|
case 7:
|
|
1435
|
-
|
|
1499
|
+
_context31.next = 8;
|
|
1436
1500
|
return flushPromises();
|
|
1437
1501
|
case 8:
|
|
1438
1502
|
expect(reg.webWorker).toBeDefined();
|
|
@@ -1442,31 +1506,31 @@ describe('Registration Tests', function () {
|
|
|
1442
1506
|
statusCode: 200
|
|
1443
1507
|
}
|
|
1444
1508
|
});
|
|
1445
|
-
|
|
1509
|
+
_context31.next = 9;
|
|
1446
1510
|
return flushPromises();
|
|
1447
1511
|
case 9:
|
|
1448
1512
|
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
|
|
1449
1513
|
expect(reg.webWorker).toBeDefined();
|
|
1450
1514
|
case 10:
|
|
1451
1515
|
case "end":
|
|
1452
|
-
return
|
|
1516
|
+
return _context31.stop();
|
|
1453
1517
|
}
|
|
1454
|
-
},
|
|
1518
|
+
}, _callee31);
|
|
1455
1519
|
})));
|
|
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
|
|
1520
|
+
it('cc: verify failover to backup server after 4 keep alive failure with primary server', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee32() {
|
|
1457
1521
|
var clearKeepaliveSpy, reconnectSpy;
|
|
1458
|
-
return _regenerator.default.wrap(function (
|
|
1459
|
-
while (1) switch (
|
|
1522
|
+
return _regenerator.default.wrap(function (_context32) {
|
|
1523
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
1460
1524
|
case 0:
|
|
1461
1525
|
// Register with contact center service
|
|
1462
1526
|
setupRegistration(_objectSpread(_objectSpread({}, MockServiceData), {}, {
|
|
1463
1527
|
indicator: _types.ServiceIndicator.CONTACT_CENTER
|
|
1464
1528
|
}));
|
|
1465
|
-
|
|
1529
|
+
_context32.next = 1;
|
|
1466
1530
|
return beforeEachSetupForKeepalive();
|
|
1467
1531
|
case 1:
|
|
1468
1532
|
webex.request.mockResolvedValueOnce(successPayload);
|
|
1469
|
-
|
|
1533
|
+
_context32.next = 2;
|
|
1470
1534
|
return reg.triggerRegistration();
|
|
1471
1535
|
case 2:
|
|
1472
1536
|
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
|
|
@@ -1486,7 +1550,7 @@ describe('Registration Tests', function () {
|
|
|
1486
1550
|
});
|
|
1487
1551
|
|
|
1488
1552
|
// Wait for any asynchronous actions to complete
|
|
1489
|
-
|
|
1553
|
+
_context32.next = 3;
|
|
1490
1554
|
return flushPromises();
|
|
1491
1555
|
case 3:
|
|
1492
1556
|
// Verify that the keepalive timer was cleared and reconnectOnFailure was triggered
|
|
@@ -1498,16 +1562,16 @@ describe('Registration Tests', function () {
|
|
|
1498
1562
|
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
|
|
1499
1563
|
case 4:
|
|
1500
1564
|
case "end":
|
|
1501
|
-
return
|
|
1565
|
+
return _context32.stop();
|
|
1502
1566
|
}
|
|
1503
|
-
},
|
|
1567
|
+
}, _callee32);
|
|
1504
1568
|
})));
|
|
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
|
|
1569
|
+
it('verify failure keep-alive case with active call present: Restore Success after call ends', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee33() {
|
|
1506
1570
|
var reconnectSpy, restoreSpy, restartRegSpy, clearTimerSpy, threshold, failureEvent;
|
|
1507
|
-
return _regenerator.default.wrap(function (
|
|
1508
|
-
while (1) switch (
|
|
1571
|
+
return _regenerator.default.wrap(function (_context33) {
|
|
1572
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
1509
1573
|
case 0:
|
|
1510
|
-
|
|
1574
|
+
_context33.next = 1;
|
|
1511
1575
|
return beforeEachSetupForKeepalive();
|
|
1512
1576
|
case 1:
|
|
1513
1577
|
reconnectSpy = jest.spyOn(reg, 'reconnectOnFailure');
|
|
@@ -1527,7 +1591,7 @@ describe('Registration Tests', function () {
|
|
|
1527
1591
|
}
|
|
1528
1592
|
};
|
|
1529
1593
|
reg.webWorker.onmessage(failureEvent);
|
|
1530
|
-
|
|
1594
|
+
_context33.next = 2;
|
|
1531
1595
|
return flushPromises();
|
|
1532
1596
|
case 2:
|
|
1533
1597
|
// At this point, clearKeepaliveTimer was called so the worker is terminated.
|
|
@@ -1552,10 +1616,10 @@ describe('Registration Tests', function () {
|
|
|
1552
1616
|
webex.request.mockResolvedValueOnce(successPayload);
|
|
1553
1617
|
|
|
1554
1618
|
// Call reconnectOnFailure manually. With no active calls, this should trigger re-registration.
|
|
1555
|
-
|
|
1619
|
+
_context33.next = 3;
|
|
1556
1620
|
return reg.reconnectOnFailure(_constants.CALLS_CLEARED_HANDLER_UTIL);
|
|
1557
1621
|
case 3:
|
|
1558
|
-
|
|
1622
|
+
_context33.next = 4;
|
|
1559
1623
|
return flushPromises();
|
|
1560
1624
|
case 4:
|
|
1561
1625
|
expect((0, _keys.default)(reg.callManager.getActiveCalls()).length).toBe(0);
|
|
@@ -1568,16 +1632,16 @@ describe('Registration Tests', function () {
|
|
|
1568
1632
|
expect(reg.reconnectPending).toStrictEqual(false);
|
|
1569
1633
|
case 5:
|
|
1570
1634
|
case "end":
|
|
1571
|
-
return
|
|
1635
|
+
return _context33.stop();
|
|
1572
1636
|
}
|
|
1573
|
-
},
|
|
1637
|
+
}, _callee33);
|
|
1574
1638
|
})));
|
|
1575
|
-
it('checks for keep-alive failure with final error: 404', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
1639
|
+
it('checks for keep-alive failure with final error: 404', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee34() {
|
|
1576
1640
|
var reconnectSpy, restoreSpy, restartRegSpy, clearTimerSpy, handle404CbSpy, registerSpy;
|
|
1577
|
-
return _regenerator.default.wrap(function (
|
|
1578
|
-
while (1) switch (
|
|
1641
|
+
return _regenerator.default.wrap(function (_context34) {
|
|
1642
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
1579
1643
|
case 0:
|
|
1580
|
-
|
|
1644
|
+
_context34.next = 1;
|
|
1581
1645
|
return beforeEachSetupForKeepalive();
|
|
1582
1646
|
case 1:
|
|
1583
1647
|
webex.request.mockResolvedValueOnce(successPayload);
|
|
@@ -1596,7 +1660,7 @@ describe('Registration Tests', function () {
|
|
|
1596
1660
|
keepAliveRetryCount: 1
|
|
1597
1661
|
}
|
|
1598
1662
|
});
|
|
1599
|
-
|
|
1663
|
+
_context34.next = 2;
|
|
1600
1664
|
return flushPromises();
|
|
1601
1665
|
case 2:
|
|
1602
1666
|
expect(warnSpy).toBeCalledWith('Keep-alive missed 1 times. Status -> 404 ', expect.objectContaining({
|
|
@@ -1620,17 +1684,17 @@ describe('Registration Tests', function () {
|
|
|
1620
1684
|
expect(registerSpy).toBeCalledOnceWith(_constants.KEEPALIVE_UTIL);
|
|
1621
1685
|
case 3:
|
|
1622
1686
|
case "end":
|
|
1623
|
-
return
|
|
1687
|
+
return _context34.stop();
|
|
1624
1688
|
}
|
|
1625
|
-
},
|
|
1689
|
+
}, _callee34);
|
|
1626
1690
|
})));
|
|
1627
|
-
it('checks for keep-alive failure with 429', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
1691
|
+
it('checks for keep-alive failure with 429', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee35() {
|
|
1628
1692
|
var _reg$deviceInfo$devic;
|
|
1629
1693
|
var keepaliveSpy, postMessageSpy, clearTimerSpy, retry429Spy;
|
|
1630
|
-
return _regenerator.default.wrap(function (
|
|
1631
|
-
while (1) switch (
|
|
1694
|
+
return _regenerator.default.wrap(function (_context35) {
|
|
1695
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
1632
1696
|
case 0:
|
|
1633
|
-
|
|
1697
|
+
_context35.next = 1;
|
|
1634
1698
|
return beforeEachSetupForKeepalive();
|
|
1635
1699
|
case 1:
|
|
1636
1700
|
keepaliveSpy = jest.spyOn(reg, 'startKeepaliveTimer');
|
|
@@ -1649,7 +1713,7 @@ describe('Registration Tests', function () {
|
|
|
1649
1713
|
keepAliveRetryCount: 1
|
|
1650
1714
|
}
|
|
1651
1715
|
});
|
|
1652
|
-
|
|
1716
|
+
_context35.next = 2;
|
|
1653
1717
|
return flushPromises();
|
|
1654
1718
|
case 2:
|
|
1655
1719
|
expect(warnSpy).toBeCalledWith('Keep-alive missed 1 times. Status -> 429 ', expect.objectContaining({
|
|
@@ -1671,7 +1735,7 @@ describe('Registration Tests', function () {
|
|
|
1671
1735
|
expect(reg.keepaliveTimer).toBe(undefined);
|
|
1672
1736
|
expect(reg.webWorker).toBeUndefined();
|
|
1673
1737
|
jest.advanceTimersByTime(20 * _constants.SEC_TO_MSEC_MFACTOR);
|
|
1674
|
-
|
|
1738
|
+
_context35.next = 3;
|
|
1675
1739
|
return flushPromises();
|
|
1676
1740
|
case 3:
|
|
1677
1741
|
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');
|
|
@@ -1690,16 +1754,16 @@ describe('Registration Tests', function () {
|
|
|
1690
1754
|
}));
|
|
1691
1755
|
case 4:
|
|
1692
1756
|
case "end":
|
|
1693
|
-
return
|
|
1757
|
+
return _context35.stop();
|
|
1694
1758
|
}
|
|
1695
|
-
},
|
|
1759
|
+
}, _callee35);
|
|
1696
1760
|
})));
|
|
1697
|
-
it('ensure retryAfter is set when 429 occurs during failover retry', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
1761
|
+
it('ensure retryAfter is set when 429 occurs during failover retry', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee36() {
|
|
1698
1762
|
var retry429Spy;
|
|
1699
|
-
return _regenerator.default.wrap(function (
|
|
1700
|
-
while (1) switch (
|
|
1763
|
+
return _regenerator.default.wrap(function (_context36) {
|
|
1764
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
1701
1765
|
case 0:
|
|
1702
|
-
|
|
1766
|
+
_context36.next = 1;
|
|
1703
1767
|
return beforeEachSetupForKeepalive();
|
|
1704
1768
|
case 1:
|
|
1705
1769
|
// Simulate loss of registration so failover path attempts a new registration
|
|
@@ -1710,11 +1774,11 @@ describe('Registration Tests', function () {
|
|
|
1710
1774
|
webex.request.mockRejectedValueOnce(failurePayload429One);
|
|
1711
1775
|
|
|
1712
1776
|
// Directly schedule the failover attempt
|
|
1713
|
-
|
|
1777
|
+
_context36.next = 2;
|
|
1714
1778
|
return reg.startFailoverTimer();
|
|
1715
1779
|
case 2:
|
|
1716
1780
|
jest.advanceTimersByTime(33 * _constants.SEC_TO_MSEC_MFACTOR);
|
|
1717
|
-
|
|
1781
|
+
_context36.next = 3;
|
|
1718
1782
|
return flushPromises();
|
|
1719
1783
|
case 3:
|
|
1720
1784
|
expect(retry429Spy).toBeCalledWith(failurePayload429One.headers['retry-after'], 'startFailoverTimer');
|
|
@@ -1722,16 +1786,16 @@ describe('Registration Tests', function () {
|
|
|
1722
1786
|
jest.useRealTimers();
|
|
1723
1787
|
case 4:
|
|
1724
1788
|
case "end":
|
|
1725
|
-
return
|
|
1789
|
+
return _context36.stop();
|
|
1726
1790
|
}
|
|
1727
|
-
},
|
|
1791
|
+
}, _callee36);
|
|
1728
1792
|
})));
|
|
1729
|
-
it('sets retryAfter when reconnectOnFailure caller receives 429 after keepalive threshold miss', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
1793
|
+
it('sets retryAfter when reconnectOnFailure caller receives 429 after keepalive threshold miss', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee37() {
|
|
1730
1794
|
var retry429Spy, threshold;
|
|
1731
|
-
return _regenerator.default.wrap(function (
|
|
1732
|
-
while (1) switch (
|
|
1795
|
+
return _regenerator.default.wrap(function (_context37) {
|
|
1796
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
1733
1797
|
case 0:
|
|
1734
|
-
|
|
1798
|
+
_context37.next = 1;
|
|
1735
1799
|
return beforeEachSetupForKeepalive();
|
|
1736
1800
|
case 1:
|
|
1737
1801
|
retry429Spy = jest.spyOn(reg, 'handle429Retry'); // On reconnectOnFailure(RECONNECT_ON_FAILURE_UTIL) first restore attempt, make registration respond with 429 (retry-after: 20)
|
|
@@ -1754,7 +1818,7 @@ describe('Registration Tests', function () {
|
|
|
1754
1818
|
keepAliveRetryCount: threshold
|
|
1755
1819
|
}
|
|
1756
1820
|
});
|
|
1757
|
-
|
|
1821
|
+
_context37.next = 2;
|
|
1758
1822
|
return flushPromises();
|
|
1759
1823
|
case 2:
|
|
1760
1824
|
// handle429Retry is called with caller 'reconnectOnFailure' → else branch executes and sets retryAfter
|
|
@@ -1762,25 +1826,25 @@ describe('Registration Tests', function () {
|
|
|
1762
1826
|
expect(reg.retryAfter).toEqual(undefined); // Clear retryAfter after 429 retry
|
|
1763
1827
|
case 3:
|
|
1764
1828
|
case "end":
|
|
1765
|
-
return
|
|
1829
|
+
return _context37.stop();
|
|
1766
1830
|
}
|
|
1767
|
-
},
|
|
1831
|
+
}, _callee37);
|
|
1768
1832
|
})));
|
|
1769
1833
|
});
|
|
1770
1834
|
describe('Primary server status checks', function () {
|
|
1771
|
-
it('success: primary server status to be up', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
1835
|
+
it('success: primary server status to be up', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee38() {
|
|
1772
1836
|
var pingSuccessPayload, status;
|
|
1773
|
-
return _regenerator.default.wrap(function (
|
|
1774
|
-
while (1) switch (
|
|
1837
|
+
return _regenerator.default.wrap(function (_context38) {
|
|
1838
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
1775
1839
|
case 0:
|
|
1776
1840
|
pingSuccessPayload = {
|
|
1777
1841
|
statusCode: 200
|
|
1778
1842
|
};
|
|
1779
1843
|
webex.request.mockResolvedValue(pingSuccessPayload);
|
|
1780
|
-
|
|
1844
|
+
_context38.next = 1;
|
|
1781
1845
|
return reg.isPrimaryActive();
|
|
1782
1846
|
case 1:
|
|
1783
|
-
status =
|
|
1847
|
+
status = _context38.sent;
|
|
1784
1848
|
expect(webex.request).toBeCalledWith(_objectSpread({
|
|
1785
1849
|
method: 'GET',
|
|
1786
1850
|
uri: "https://mobius-dfw.webex.com/api/v1/ping"
|
|
@@ -1788,23 +1852,23 @@ describe('Registration Tests', function () {
|
|
|
1788
1852
|
expect(status).toEqual(true);
|
|
1789
1853
|
case 2:
|
|
1790
1854
|
case "end":
|
|
1791
|
-
return
|
|
1855
|
+
return _context38.stop();
|
|
1792
1856
|
}
|
|
1793
|
-
},
|
|
1857
|
+
}, _callee38);
|
|
1794
1858
|
})));
|
|
1795
|
-
it('failed: primary server status to be down', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
1859
|
+
it('failed: primary server status to be down', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee39() {
|
|
1796
1860
|
var pingFailurePayload, status;
|
|
1797
|
-
return _regenerator.default.wrap(function (
|
|
1798
|
-
while (1) switch (
|
|
1861
|
+
return _regenerator.default.wrap(function (_context39) {
|
|
1862
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
1799
1863
|
case 0:
|
|
1800
1864
|
pingFailurePayload = {
|
|
1801
1865
|
statusCode: 500
|
|
1802
1866
|
};
|
|
1803
1867
|
webex.request.mockResolvedValue(pingFailurePayload);
|
|
1804
|
-
|
|
1868
|
+
_context39.next = 1;
|
|
1805
1869
|
return reg.isPrimaryActive();
|
|
1806
1870
|
case 1:
|
|
1807
|
-
status =
|
|
1871
|
+
status = _context39.sent;
|
|
1808
1872
|
expect(webex.request).toBeCalledWith(_objectSpread({
|
|
1809
1873
|
method: 'GET',
|
|
1810
1874
|
uri: "https://mobius-dfw.webex.com/api/v1/ping"
|
|
@@ -1812,9 +1876,9 @@ describe('Registration Tests', function () {
|
|
|
1812
1876
|
expect(status).toEqual(false);
|
|
1813
1877
|
case 2:
|
|
1814
1878
|
case "end":
|
|
1815
|
-
return
|
|
1879
|
+
return _context39.stop();
|
|
1816
1880
|
}
|
|
1817
|
-
},
|
|
1881
|
+
}, _callee39);
|
|
1818
1882
|
})));
|
|
1819
1883
|
});
|
|
1820
1884
|
});
|