@webex/calling 3.8.1 → 3.9.0-multi-llms.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CallHistory/CallHistory.js +51 -46
- package/dist/CallHistory/CallHistory.js.map +1 -1
- package/dist/CallHistory/CallHistory.test.js +146 -147
- package/dist/CallHistory/CallHistory.test.js.map +1 -1
- package/dist/CallHistory/callHistoryFixtures.js.map +1 -1
- package/dist/CallHistory/constants.js.map +1 -1
- package/dist/CallHistory/types.js.map +1 -1
- package/dist/CallSettings/CallSettings.js +8 -8
- package/dist/CallSettings/CallSettings.js.map +1 -1
- package/dist/CallSettings/CallSettings.test.js +1 -1
- package/dist/CallSettings/CallSettings.test.js.map +1 -1
- package/dist/CallSettings/UcmBackendConnector.js +12 -11
- package/dist/CallSettings/UcmBackendConnector.js.map +1 -1
- package/dist/CallSettings/UcmBackendConnector.test.js +9 -10
- package/dist/CallSettings/UcmBackendConnector.test.js.map +1 -1
- package/dist/CallSettings/WxCallBackendConnector.js +68 -61
- package/dist/CallSettings/WxCallBackendConnector.js.map +1 -1
- package/dist/CallSettings/WxCallBackendConnector.test.js +168 -102
- package/dist/CallSettings/WxCallBackendConnector.test.js.map +1 -1
- package/dist/CallSettings/constants.js.map +1 -1
- package/dist/CallSettings/testFixtures.js.map +1 -1
- package/dist/CallSettings/types.js.map +1 -1
- package/dist/CallingClient/CallingClient.js +530 -219
- package/dist/CallingClient/CallingClient.js.map +1 -1
- package/dist/CallingClient/CallingClient.test.js +500 -291
- package/dist/CallingClient/CallingClient.test.js.map +1 -1
- package/dist/CallingClient/callRecordFixtures.js.map +1 -1
- package/dist/CallingClient/calling/CallerId/index.js +2 -2
- package/dist/CallingClient/calling/CallerId/index.js.map +1 -1
- package/dist/CallingClient/calling/CallerId/index.test.js +8 -7
- package/dist/CallingClient/calling/CallerId/index.test.js.map +1 -1
- package/dist/CallingClient/calling/CallerId/types.js.map +1 -1
- package/dist/CallingClient/calling/call.js +369 -333
- package/dist/CallingClient/calling/call.js.map +1 -1
- package/dist/CallingClient/calling/call.test.js +411 -410
- package/dist/CallingClient/calling/call.test.js.map +1 -1
- package/dist/CallingClient/calling/callManager.js +3 -4
- package/dist/CallingClient/calling/callManager.js.map +1 -1
- package/dist/CallingClient/calling/callManager.test.js +67 -68
- package/dist/CallingClient/calling/callManager.test.js.map +1 -1
- package/dist/CallingClient/calling/index.js.map +1 -1
- package/dist/CallingClient/calling/types.js.map +1 -1
- package/dist/CallingClient/callingClientFixtures.js.map +1 -1
- package/dist/CallingClient/constants.js +11 -8
- package/dist/CallingClient/constants.js.map +1 -1
- package/dist/CallingClient/line/index.js +10 -11
- package/dist/CallingClient/line/index.js.map +1 -1
- package/dist/CallingClient/line/line.test.js +12 -17
- package/dist/CallingClient/line/line.test.js.map +1 -1
- package/dist/CallingClient/line/types.js.map +1 -1
- package/dist/CallingClient/registration/index.js.map +1 -1
- package/dist/CallingClient/registration/register.js +557 -442
- package/dist/CallingClient/registration/register.js.map +1 -1
- package/dist/CallingClient/registration/register.test.js +526 -395
- package/dist/CallingClient/registration/register.test.js.map +1 -1
- package/dist/CallingClient/registration/registerFixtures.js.map +1 -1
- package/dist/CallingClient/registration/types.js.map +1 -1
- package/dist/CallingClient/registration/webWorker.js +116 -0
- package/dist/CallingClient/registration/webWorker.js.map +1 -0
- package/dist/CallingClient/registration/webWorker.test.js +256 -0
- package/dist/CallingClient/registration/webWorker.test.js.map +1 -0
- package/dist/CallingClient/registration/webWorkerStr.js +15 -0
- package/dist/CallingClient/registration/webWorkerStr.js.map +1 -0
- package/dist/CallingClient/types.js.map +1 -1
- package/dist/CallingClient/windowsChromiumIceWarmupUtils.js +142 -0
- package/dist/CallingClient/windowsChromiumIceWarmupUtils.js.map +1 -0
- package/dist/Contacts/ContactsClient.js +244 -238
- package/dist/Contacts/ContactsClient.js.map +1 -1
- package/dist/Contacts/ContactsClient.test.js +89 -90
- package/dist/Contacts/ContactsClient.test.js.map +1 -1
- package/dist/Contacts/constants.js +2 -2
- package/dist/Contacts/constants.js.map +1 -1
- package/dist/Contacts/contactFixtures.js.map +1 -1
- package/dist/Contacts/types.js.map +1 -1
- package/dist/Errors/catalog/CallError.js +2 -2
- package/dist/Errors/catalog/CallError.js.map +1 -1
- package/dist/Errors/catalog/CallingDeviceError.js +2 -2
- package/dist/Errors/catalog/CallingDeviceError.js.map +1 -1
- package/dist/Errors/catalog/ExtendedError.js +3 -3
- package/dist/Errors/catalog/ExtendedError.js.map +1 -1
- package/dist/Errors/catalog/LineError.js +2 -2
- package/dist/Errors/catalog/LineError.js.map +1 -1
- package/dist/Errors/index.js.map +1 -1
- package/dist/Errors/types.js +2 -0
- package/dist/Errors/types.js.map +1 -1
- package/dist/Events/impl/index.js +2 -2
- package/dist/Events/impl/index.js.map +1 -1
- package/dist/Events/types.js.map +1 -1
- package/dist/Logger/index.js.map +1 -1
- package/dist/Logger/index.test.js.map +1 -1
- package/dist/Logger/types.js.map +1 -1
- package/dist/Metrics/index.js +175 -86
- package/dist/Metrics/index.js.map +1 -1
- package/dist/Metrics/index.test.js +70 -4
- package/dist/Metrics/index.test.js.map +1 -1
- package/dist/Metrics/types.js +15 -1
- package/dist/Metrics/types.js.map +1 -1
- package/dist/SDKConnector/index.js +0 -1
- package/dist/SDKConnector/index.js.map +1 -1
- package/dist/SDKConnector/index.test.js.map +1 -1
- package/dist/SDKConnector/types.js.map +1 -1
- package/dist/SDKConnector/utils.js.map +1 -1
- package/dist/SDKConnector/utils.test.js.map +1 -1
- package/dist/Voicemail/BroadworksBackendConnector.js +42 -39
- package/dist/Voicemail/BroadworksBackendConnector.js.map +1 -1
- package/dist/Voicemail/BroadworksBackendConnector.test.js +119 -120
- package/dist/Voicemail/BroadworksBackendConnector.test.js.map +1 -1
- package/dist/Voicemail/UcmBackendConnector.js +54 -47
- package/dist/Voicemail/UcmBackendConnector.js.map +1 -1
- package/dist/Voicemail/UcmBackendConnector.test.js +73 -74
- package/dist/Voicemail/UcmBackendConnector.test.js.map +1 -1
- package/dist/Voicemail/Voicemail.js +12 -11
- package/dist/Voicemail/Voicemail.js.map +1 -1
- package/dist/Voicemail/Voicemail.test.js +2 -2
- package/dist/Voicemail/Voicemail.test.js.map +1 -1
- package/dist/Voicemail/WxCallBackendConnector.js +78 -70
- package/dist/Voicemail/WxCallBackendConnector.js.map +1 -1
- package/dist/Voicemail/WxCallBackendConnector.test.js +184 -185
- package/dist/Voicemail/WxCallBackendConnector.test.js.map +1 -1
- package/dist/Voicemail/constants.js.map +1 -1
- package/dist/Voicemail/types.js.map +1 -1
- package/dist/Voicemail/voicemailFixture.js.map +1 -1
- package/dist/api.js.map +1 -1
- package/dist/common/Utils.js +125 -99
- package/dist/common/Utils.js.map +1 -1
- package/dist/common/Utils.test.js +283 -143
- package/dist/common/Utils.test.js.map +1 -1
- package/dist/common/constants.js.map +1 -1
- package/dist/common/index.js.map +1 -1
- package/dist/common/testUtil.js +1 -1
- package/dist/common/testUtil.js.map +1 -1
- package/dist/common/types.js +8 -1
- package/dist/common/types.js.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/module/CallHistory/CallHistory.js +4 -0
- package/dist/module/CallSettings/UcmBackendConnector.js +1 -0
- package/dist/module/CallSettings/WxCallBackendConnector.js +8 -1
- package/dist/module/CallingClient/CallingClient.js +199 -42
- package/dist/module/CallingClient/calling/call.js +79 -43
- package/dist/module/CallingClient/constants.js +10 -6
- package/dist/module/CallingClient/line/index.js +3 -3
- package/dist/module/CallingClient/registration/register.js +111 -72
- package/dist/module/CallingClient/registration/webWorker.js +60 -0
- package/dist/module/CallingClient/registration/webWorkerStr.js +93 -0
- package/dist/module/CallingClient/windowsChromiumIceWarmupUtils.js +59 -0
- package/dist/module/Contacts/ContactsClient.js +23 -17
- package/dist/module/Contacts/constants.js +1 -1
- package/dist/module/Errors/types.js +2 -0
- package/dist/module/Metrics/index.js +94 -33
- package/dist/module/Metrics/types.js +14 -0
- package/dist/module/Voicemail/BroadworksBackendConnector.js +3 -0
- package/dist/module/Voicemail/UcmBackendConnector.js +6 -0
- package/dist/module/Voicemail/WxCallBackendConnector.js +8 -0
- package/dist/module/common/Utils.js +37 -12
- package/dist/module/common/types.js +7 -0
- package/dist/types/CallHistory/CallHistory.d.ts.map +1 -1
- package/dist/types/CallSettings/UcmBackendConnector.d.ts.map +1 -1
- package/dist/types/CallSettings/WxCallBackendConnector.d.ts.map +1 -1
- package/dist/types/CallSettings/types.d.ts +1 -1
- package/dist/types/CallSettings/types.d.ts.map +1 -1
- package/dist/types/CallingClient/CallingClient.d.ts +12 -1
- package/dist/types/CallingClient/CallingClient.d.ts.map +1 -1
- package/dist/types/CallingClient/calling/call.d.ts.map +1 -1
- package/dist/types/CallingClient/calling/types.d.ts +2 -1
- package/dist/types/CallingClient/calling/types.d.ts.map +1 -1
- package/dist/types/CallingClient/constants.d.ts +10 -6
- package/dist/types/CallingClient/constants.d.ts.map +1 -1
- package/dist/types/CallingClient/line/index.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/register.d.ts +2 -2
- package/dist/types/CallingClient/registration/register.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/types.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/webWorker.d.ts +3 -0
- package/dist/types/CallingClient/registration/webWorker.d.ts.map +1 -0
- package/dist/types/CallingClient/registration/webWorkerStr.d.ts +3 -0
- package/dist/types/CallingClient/registration/webWorkerStr.d.ts.map +1 -0
- package/dist/types/CallingClient/windowsChromiumIceWarmupUtils.d.ts +5 -0
- package/dist/types/CallingClient/windowsChromiumIceWarmupUtils.d.ts.map +1 -0
- package/dist/types/Contacts/ContactsClient.d.ts.map +1 -1
- package/dist/types/Contacts/constants.d.ts +1 -1
- package/dist/types/Contacts/constants.d.ts.map +1 -1
- package/dist/types/Errors/types.d.ts +2 -0
- package/dist/types/Errors/types.d.ts.map +1 -1
- package/dist/types/Metrics/index.d.ts.map +1 -1
- package/dist/types/Metrics/types.d.ts +20 -4
- package/dist/types/Metrics/types.d.ts.map +1 -1
- package/dist/types/Voicemail/BroadworksBackendConnector.d.ts.map +1 -1
- package/dist/types/Voicemail/UcmBackendConnector.d.ts.map +1 -1
- package/dist/types/Voicemail/WxCallBackendConnector.d.ts.map +1 -1
- package/dist/types/common/Utils.d.ts.map +1 -1
- package/dist/types/common/types.d.ts +13 -0
- package/dist/types/common/types.d.ts.map +1 -1
- package/package.json +10 -8
|
@@ -28,8 +28,8 @@ var _types3 = require("../../Errors/types");
|
|
|
28
28
|
var _constants = require("../constants");
|
|
29
29
|
var _types4 = require("../line/types");
|
|
30
30
|
var _LineError = require("../../Errors/catalog/LineError");
|
|
31
|
-
|
|
32
|
-
function _interopRequireWildcard(e, r) { if (!
|
|
31
|
+
var _types5 = require("../../Metrics/types");
|
|
32
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof _WeakMap) var r = new _WeakMap(), n = new _WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = _Object$defineProperty) && _Object$getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
33
33
|
function ownKeys(e, r) { var t = _Object$keys2(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
34
34
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; } /* eslint-disable @typescript-eslint/no-shadow */
|
|
35
35
|
var webex = (0, _testUtil.getTestUtilsWebex)();
|
|
@@ -72,7 +72,10 @@ describe('Registration Tests', function () {
|
|
|
72
72
|
});
|
|
73
73
|
var failurePayload = {
|
|
74
74
|
statusCode: 500,
|
|
75
|
-
body: _registerFixtures.mockPostResponse
|
|
75
|
+
body: _registerFixtures.mockPostResponse,
|
|
76
|
+
headers: {
|
|
77
|
+
trackingid: 'webex-js-sdk_06bafdd0-2f9b-4cd7-b438-9c0d95ecec9b_15'
|
|
78
|
+
}
|
|
76
79
|
};
|
|
77
80
|
var failurePayload429One = {
|
|
78
81
|
statusCode: 429,
|
|
@@ -104,14 +107,19 @@ describe('Registration Tests', function () {
|
|
|
104
107
|
};
|
|
105
108
|
var successPayload = {
|
|
106
109
|
statusCode: 200,
|
|
107
|
-
body: _registerFixtures.mockPostResponse
|
|
110
|
+
body: _registerFixtures.mockPostResponse,
|
|
111
|
+
headers: {
|
|
112
|
+
trackingid: 'webex-js-sdk_06bafdd0-2f9b-4cd7-b438-9c0d95ecec9b_15'
|
|
113
|
+
}
|
|
108
114
|
};
|
|
109
115
|
var reg;
|
|
110
116
|
var restartSpy;
|
|
111
117
|
var restoreSpy;
|
|
112
118
|
var postRegistrationSpy;
|
|
119
|
+
var deregisterSpy;
|
|
113
120
|
var failoverSpy;
|
|
114
121
|
var retry429Spy;
|
|
122
|
+
var metricSpy;
|
|
115
123
|
var setupRegistration = function setupRegistration(mockServiceData) {
|
|
116
124
|
var mutex = new _asyncMutex.Mutex();
|
|
117
125
|
reg = (0, _register.createRegistration)(webex, mockServiceData, mutex, lineEmitter, _types2.LOGGER.INFO);
|
|
@@ -120,8 +128,10 @@ describe('Registration Tests', function () {
|
|
|
120
128
|
restartSpy = jest.spyOn(reg, 'restartRegistration');
|
|
121
129
|
restoreSpy = jest.spyOn(reg, 'restorePreviousRegistration');
|
|
122
130
|
postRegistrationSpy = jest.spyOn(reg, 'postRegistration');
|
|
131
|
+
deregisterSpy = jest.spyOn(reg, 'deregister');
|
|
123
132
|
failoverSpy = jest.spyOn(reg, 'startFailoverTimer');
|
|
124
133
|
retry429Spy = jest.spyOn(reg, 'handle429Retry');
|
|
134
|
+
metricSpy = jest.spyOn(reg.metricManager, 'submitRegistrationMetric');
|
|
125
135
|
};
|
|
126
136
|
beforeEach(function () {
|
|
127
137
|
setupRegistration(MockServiceData);
|
|
@@ -132,12 +142,15 @@ describe('Registration Tests', function () {
|
|
|
132
142
|
jest.clearAllMocks();
|
|
133
143
|
jest.useRealTimers();
|
|
134
144
|
});
|
|
135
|
-
it('verify successful registration', /*#__PURE__*/(0, _asyncToGenerator2.default)(
|
|
145
|
+
it('verify successful registration', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
136
146
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
137
147
|
while (1) switch (_context.prev = _context.next) {
|
|
138
148
|
case 0:
|
|
139
149
|
webex.request.mockReturnValueOnce({
|
|
140
|
-
body: _registerFixtures.mockPostResponse
|
|
150
|
+
body: _registerFixtures.mockPostResponse,
|
|
151
|
+
headers: {
|
|
152
|
+
trackingid: 'webex-js-sdk_06bafdd0-2f9b-4cd7-b438-9c0d95ecec9b_15'
|
|
153
|
+
}
|
|
141
154
|
});
|
|
142
155
|
_context.next = 3;
|
|
143
156
|
return reg.triggerRegistration();
|
|
@@ -151,24 +164,26 @@ describe('Registration Tests', function () {
|
|
|
151
164
|
expect(lineEmitter).toBeCalledWith(_types4.LINE_EVENTS.REGISTERED, _registerFixtures.mockPostResponse);
|
|
152
165
|
|
|
153
166
|
// Check that log.log was called for successful registration
|
|
154
|
-
expect(logSpy).toBeCalledWith("Registration successful for deviceId: ".concat(_registerFixtures.mockPostResponse.device.deviceId, " userId: ").concat(_registerFixtures.mockPostResponse.userId), expect.objectContaining({
|
|
167
|
+
expect(logSpy).toBeCalledWith("Registration successful for deviceId: ".concat(_registerFixtures.mockPostResponse.device.deviceId, " userId: ").concat(_registerFixtures.mockPostResponse.userId, " responseTrackingId: webex-js-sdk_06bafdd0-2f9b-4cd7-b438-9c0d95ecec9b_15"), expect.objectContaining({
|
|
155
168
|
file: _constants.REGISTRATION_FILE,
|
|
156
|
-
method:
|
|
169
|
+
method: 'register'
|
|
157
170
|
}));
|
|
158
|
-
|
|
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:
|
|
159
173
|
case "end":
|
|
160
174
|
return _context.stop();
|
|
161
175
|
}
|
|
162
176
|
}, _callee);
|
|
163
177
|
})));
|
|
164
|
-
it('verify failure registration', /*#__PURE__*/(0, _asyncToGenerator2.default)(
|
|
178
|
+
it('verify failure registration', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
165
179
|
var error;
|
|
166
180
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
167
181
|
while (1) switch (_context2.prev = _context2.next) {
|
|
168
182
|
case 0:
|
|
169
183
|
webex.request.mockRejectedValue({
|
|
170
184
|
body: _registerFixtures.mockPostResponse,
|
|
171
|
-
statusCode: 401
|
|
185
|
+
statusCode: 401,
|
|
186
|
+
headers: {}
|
|
172
187
|
});
|
|
173
188
|
_context2.next = 3;
|
|
174
189
|
return reg.triggerRegistration();
|
|
@@ -181,13 +196,14 @@ describe('Registration Tests', function () {
|
|
|
181
196
|
expect(lineEmitter).toBeCalledTimes(2);
|
|
182
197
|
expect(lineEmitter).nthCalledWith(1, _types4.LINE_EVENTS.CONNECTING);
|
|
183
198
|
expect(lineEmitter).nthCalledWith(2, _types4.LINE_EVENTS.ERROR, undefined, error);
|
|
184
|
-
|
|
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:
|
|
185
201
|
case "end":
|
|
186
202
|
return _context2.stop();
|
|
187
203
|
}
|
|
188
204
|
}, _callee2);
|
|
189
205
|
})));
|
|
190
|
-
it('verify failure registration 403-101', /*#__PURE__*/(0, _asyncToGenerator2.default)(
|
|
206
|
+
it('verify failure registration 403-101', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
191
207
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
192
208
|
while (1) switch (_context3.prev = _context3.next) {
|
|
193
209
|
case 0:
|
|
@@ -200,7 +216,10 @@ describe('Registration Tests', function () {
|
|
|
200
216
|
statusCode: 403
|
|
201
217
|
}).mockResolvedValueOnce({
|
|
202
218
|
statusCode: 200,
|
|
203
|
-
body: _registerFixtures.mockPostResponse
|
|
219
|
+
body: _registerFixtures.mockPostResponse,
|
|
220
|
+
headers: {
|
|
221
|
+
trackingid: 'webex-js-sdk_06bafdd0-2f9b-4cd7-b438-9c0d95ecec9b_15'
|
|
222
|
+
}
|
|
204
223
|
});
|
|
205
224
|
global.fetch = jest.fn(function () {
|
|
206
225
|
return _promise.default.resolve({
|
|
@@ -230,7 +249,8 @@ describe('Registration Tests', function () {
|
|
|
230
249
|
expect(lineEmitter).nthCalledWith(2, _types4.LINE_EVENTS.UNREGISTERED);
|
|
231
250
|
expect(lineEmitter).nthCalledWith(3, _types4.LINE_EVENTS.CONNECTING);
|
|
232
251
|
expect(lineEmitter).nthCalledWith(4, _types4.LINE_EVENTS.REGISTERED, _registerFixtures.mockPostResponse);
|
|
233
|
-
|
|
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:
|
|
234
254
|
case "end":
|
|
235
255
|
return _context3.stop();
|
|
236
256
|
}
|
|
@@ -249,7 +269,7 @@ describe('Registration Tests', function () {
|
|
|
249
269
|
mobiusUris.backup.push(_registerFixtures.URL);
|
|
250
270
|
jest.clearAllMocks();
|
|
251
271
|
});
|
|
252
|
-
it('handle 429 received during initial registration failure and first attempt with primary', /*#__PURE__*/(0, _asyncToGenerator2.default)(
|
|
272
|
+
it('handle 429 received during initial registration failure and first attempt with primary', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee4() {
|
|
253
273
|
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
254
274
|
while (1) switch (_context4.prev = _context4.next) {
|
|
255
275
|
case 0:
|
|
@@ -311,7 +331,7 @@ describe('Registration Tests', function () {
|
|
|
311
331
|
}
|
|
312
332
|
}, _callee4);
|
|
313
333
|
})));
|
|
314
|
-
it('handle 429 received with higher retryAfter than the interval when interval with elapsedTime is already reaching threshold timer so we failover immediately', /*#__PURE__*/(0, _asyncToGenerator2.default)(
|
|
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() {
|
|
315
335
|
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
316
336
|
while (1) switch (_context5.prev = _context5.next) {
|
|
317
337
|
case 0:
|
|
@@ -367,7 +387,7 @@ describe('Registration Tests', function () {
|
|
|
367
387
|
}
|
|
368
388
|
}, _callee5);
|
|
369
389
|
})));
|
|
370
|
-
it('handle 429 received while the last attempt for primary', /*#__PURE__*/(0, _asyncToGenerator2.default)(
|
|
390
|
+
it('handle 429 received while the last attempt for primary', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee6() {
|
|
371
391
|
return _regenerator.default.wrap(function _callee6$(_context6) {
|
|
372
392
|
while (1) switch (_context6.prev = _context6.next) {
|
|
373
393
|
case 0:
|
|
@@ -438,7 +458,7 @@ describe('Registration Tests', function () {
|
|
|
438
458
|
}
|
|
439
459
|
}, _callee6);
|
|
440
460
|
})));
|
|
441
|
-
it('handle 429 received while failing over to backup server for CC flow', /*#__PURE__*/(0, _asyncToGenerator2.default)(
|
|
461
|
+
it('handle 429 received while failing over to backup server for CC flow', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee7() {
|
|
442
462
|
return _regenerator.default.wrap(function _callee7$(_context7) {
|
|
443
463
|
while (1) switch (_context7.prev = _context7.next) {
|
|
444
464
|
case 0:
|
|
@@ -448,7 +468,7 @@ describe('Registration Tests', function () {
|
|
|
448
468
|
_context7.next = 5;
|
|
449
469
|
return reg.triggerRegistration();
|
|
450
470
|
case 5:
|
|
451
|
-
jest.advanceTimersByTime(_constants.
|
|
471
|
+
jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
|
|
452
472
|
_context7.next = 8;
|
|
453
473
|
return flushPromises();
|
|
454
474
|
case 8:
|
|
@@ -487,7 +507,7 @@ describe('Registration Tests', function () {
|
|
|
487
507
|
}
|
|
488
508
|
}, _callee7);
|
|
489
509
|
})));
|
|
490
|
-
it('checking the retryAfter exceeding the threshold timers in first attempt itself', /*#__PURE__*/(0, _asyncToGenerator2.default)(
|
|
510
|
+
it('checking the retryAfter exceeding the threshold timers in first attempt itself', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee8() {
|
|
491
511
|
return _regenerator.default.wrap(function _callee8$(_context8) {
|
|
492
512
|
while (1) switch (_context8.prev = _context8.next) {
|
|
493
513
|
case 0:
|
|
@@ -517,7 +537,7 @@ describe('Registration Tests', function () {
|
|
|
517
537
|
}
|
|
518
538
|
}, _callee8);
|
|
519
539
|
})));
|
|
520
|
-
it('checking the retryAfter exceeding the threshold timers in later attempts', /*#__PURE__*/(0, _asyncToGenerator2.default)(
|
|
540
|
+
it('checking the retryAfter exceeding the threshold timers in later attempts', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee9() {
|
|
521
541
|
return _regenerator.default.wrap(function _callee9$(_context9) {
|
|
522
542
|
while (1) switch (_context9.prev = _context9.next) {
|
|
523
543
|
case 0:
|
|
@@ -562,19 +582,19 @@ describe('Registration Tests', function () {
|
|
|
562
582
|
})));
|
|
563
583
|
});
|
|
564
584
|
describe('Registration failover tests', function () {
|
|
565
|
-
it('verify unreachable primary with reachable backup servers', /*#__PURE__*/(0, _asyncToGenerator2.default)(
|
|
566
|
-
return _regenerator.default.wrap(function
|
|
567
|
-
while (1) switch (
|
|
585
|
+
it('verify unreachable primary with reachable backup servers', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee0() {
|
|
586
|
+
return _regenerator.default.wrap(function _callee0$(_context0) {
|
|
587
|
+
while (1) switch (_context0.prev = _context0.next) {
|
|
568
588
|
case 0:
|
|
569
589
|
jest.useFakeTimers();
|
|
570
590
|
// try the primary twice and register successfully with backup servers
|
|
571
591
|
webex.request.mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload).mockResolvedValueOnce(successPayload);
|
|
572
592
|
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.IDLE);
|
|
573
|
-
|
|
593
|
+
_context0.next = 5;
|
|
574
594
|
return reg.triggerRegistration();
|
|
575
595
|
case 5:
|
|
576
596
|
jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
|
|
577
|
-
|
|
597
|
+
_context0.next = 8;
|
|
578
598
|
return flushPromises();
|
|
579
599
|
case 8:
|
|
580
600
|
expect(webex.request).toBeCalledTimes(3);
|
|
@@ -589,15 +609,16 @@ describe('Registration Tests', function () {
|
|
|
589
609
|
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
|
|
590
610
|
/* Active Url must match with the backup url as per the test */
|
|
591
611
|
expect(reg.getActiveMobiusUrl()).toEqual(mobiusUris.backup[0]);
|
|
592
|
-
|
|
612
|
+
expect(metricSpy).toHaveBeenNthCalledWith(3, _types5.METRIC_EVENT.REGISTRATION, _types5.REG_ACTION.REGISTER, _types5.METRIC_TYPE.BEHAVIORAL, _constants.FAILOVER_UTIL, 'BACKUP', 'webex-js-sdk_06bafdd0-2f9b-4cd7-b438-9c0d95ecec9b_15', undefined, undefined);
|
|
613
|
+
case 14:
|
|
593
614
|
case "end":
|
|
594
|
-
return
|
|
615
|
+
return _context0.stop();
|
|
595
616
|
}
|
|
596
|
-
},
|
|
617
|
+
}, _callee0);
|
|
597
618
|
})));
|
|
598
|
-
it('cc: verify unreachable primary with reachable backup server', /*#__PURE__*/(0, _asyncToGenerator2.default)(
|
|
599
|
-
return _regenerator.default.wrap(function
|
|
600
|
-
while (1) switch (
|
|
619
|
+
it('cc: verify unreachable primary with reachable backup server', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee1() {
|
|
620
|
+
return _regenerator.default.wrap(function _callee1$(_context1) {
|
|
621
|
+
while (1) switch (_context1.prev = _context1.next) {
|
|
601
622
|
case 0:
|
|
602
623
|
setupRegistration(_objectSpread(_objectSpread({}, MockServiceData), {}, {
|
|
603
624
|
indicator: _types.ServiceIndicator.CONTACT_CENTER
|
|
@@ -605,11 +626,11 @@ describe('Registration Tests', function () {
|
|
|
605
626
|
jest.useFakeTimers();
|
|
606
627
|
webex.request.mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload).mockResolvedValueOnce(successPayload);
|
|
607
628
|
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.IDLE);
|
|
608
|
-
|
|
629
|
+
_context1.next = 6;
|
|
609
630
|
return reg.triggerRegistration();
|
|
610
631
|
case 6:
|
|
611
|
-
jest.advanceTimersByTime(_constants.
|
|
612
|
-
|
|
632
|
+
jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
|
|
633
|
+
_context1.next = 9;
|
|
613
634
|
return flushPromises();
|
|
614
635
|
case 9:
|
|
615
636
|
expect(webex.request).toBeCalledTimes(3);
|
|
@@ -626,27 +647,27 @@ describe('Registration Tests', function () {
|
|
|
626
647
|
expect(reg.getActiveMobiusUrl()).toEqual(mobiusUris.backup[0]);
|
|
627
648
|
case 14:
|
|
628
649
|
case "end":
|
|
629
|
-
return
|
|
650
|
+
return _context1.stop();
|
|
630
651
|
}
|
|
631
|
-
},
|
|
652
|
+
}, _callee1);
|
|
632
653
|
})));
|
|
633
|
-
it('verify unreachable primary and backup servers', /*#__PURE__*/(0, _asyncToGenerator2.default)(
|
|
634
|
-
return _regenerator.default.wrap(function
|
|
635
|
-
while (1) switch (
|
|
654
|
+
it('verify unreachable primary and backup servers', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee10() {
|
|
655
|
+
return _regenerator.default.wrap(function _callee10$(_context10) {
|
|
656
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
636
657
|
case 0:
|
|
637
658
|
jest.useFakeTimers();
|
|
638
659
|
// try the primary twice and register successfully with backup servers
|
|
639
660
|
webex.request.mockRejectedValue(failurePayload);
|
|
640
661
|
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.IDLE);
|
|
641
|
-
|
|
662
|
+
_context10.next = 5;
|
|
642
663
|
return reg.triggerRegistration();
|
|
643
664
|
case 5:
|
|
644
665
|
jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
|
|
645
|
-
|
|
666
|
+
_context10.next = 8;
|
|
646
667
|
return flushPromises();
|
|
647
668
|
case 8:
|
|
648
669
|
jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
|
|
649
|
-
|
|
670
|
+
_context10.next = 11;
|
|
650
671
|
return flushPromises();
|
|
651
672
|
case 11:
|
|
652
673
|
/*
|
|
@@ -671,27 +692,29 @@ describe('Registration Tests', function () {
|
|
|
671
692
|
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
|
|
672
693
|
case 17:
|
|
673
694
|
case "end":
|
|
674
|
-
return
|
|
695
|
+
return _context10.stop();
|
|
675
696
|
}
|
|
676
|
-
},
|
|
697
|
+
}, _callee10);
|
|
677
698
|
})));
|
|
678
699
|
});
|
|
679
700
|
describe('Registration failback tests', function () {
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
701
|
+
var isPrimaryActiveSpy;
|
|
702
|
+
beforeEach(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee11() {
|
|
703
|
+
return _regenerator.default.wrap(function _callee11$(_context11) {
|
|
704
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
683
705
|
case 0:
|
|
706
|
+
isPrimaryActiveSpy = jest.spyOn(reg, 'isPrimaryActive');
|
|
707
|
+
isPrimaryActiveSpy.mockReturnValue(true);
|
|
684
708
|
/* keep keepalive as active so that it wont interfere with the failback tests */
|
|
685
|
-
jest.spyOn(reg, 'postKeepAlive').mockResolvedValue(successPayload);
|
|
686
709
|
jest.useFakeTimers();
|
|
687
710
|
postRegistrationSpy.mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload).mockResolvedValueOnce(successPayload);
|
|
688
|
-
|
|
711
|
+
_context11.next = 6;
|
|
689
712
|
return reg.triggerRegistration();
|
|
690
|
-
case
|
|
713
|
+
case 6:
|
|
691
714
|
jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
|
|
692
|
-
|
|
715
|
+
_context11.next = 9;
|
|
693
716
|
return flushPromises();
|
|
694
|
-
case
|
|
717
|
+
case 9:
|
|
695
718
|
reg.rehomingIntervalMin = _constants.DEFAULT_REHOMING_INTERVAL_MIN;
|
|
696
719
|
reg.rehomingIntervalMax = _constants.DEFAULT_REHOMING_INTERVAL_MAX;
|
|
697
720
|
|
|
@@ -701,19 +724,19 @@ describe('Registration Tests', function () {
|
|
|
701
724
|
/* Active Url must match with the backup url as per the test */
|
|
702
725
|
expect(reg.getActiveMobiusUrl()).toStrictEqual(mobiusUris.backup[0]);
|
|
703
726
|
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
|
|
704
|
-
case
|
|
727
|
+
case 14:
|
|
705
728
|
case "end":
|
|
706
|
-
return
|
|
729
|
+
return _context11.stop();
|
|
707
730
|
}
|
|
708
|
-
},
|
|
731
|
+
}, _callee11);
|
|
709
732
|
})));
|
|
710
733
|
afterEach(function () {
|
|
711
734
|
jest.clearAllTimers();
|
|
712
735
|
jest.clearAllMocks();
|
|
713
736
|
});
|
|
714
|
-
it('verify 429 error with failback to primary after initial registration with backup: Restore failure', /*#__PURE__*/(0, _asyncToGenerator2.default)(
|
|
715
|
-
return _regenerator.default.wrap(function
|
|
716
|
-
while (1) switch (
|
|
737
|
+
it('verify 429 error with failback to primary after initial registration with backup: Restore failure', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee12() {
|
|
738
|
+
return _regenerator.default.wrap(function _callee12$(_context12) {
|
|
739
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
717
740
|
case 0:
|
|
718
741
|
// delete should be successful
|
|
719
742
|
global.fetch = jest.fn(function () {
|
|
@@ -727,7 +750,7 @@ describe('Registration Tests', function () {
|
|
|
727
750
|
|
|
728
751
|
/* Wait for failback to be triggered. */
|
|
729
752
|
jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
|
|
730
|
-
|
|
753
|
+
_context12.next = 5;
|
|
731
754
|
return flushPromises();
|
|
732
755
|
case 5:
|
|
733
756
|
expect(infoSpy).toBeCalledWith("Attempting failback to primary.", {
|
|
@@ -735,7 +758,7 @@ describe('Registration Tests', function () {
|
|
|
735
758
|
file: _constants.REGISTRATION_FILE
|
|
736
759
|
});
|
|
737
760
|
jest.advanceTimersByTime(10000);
|
|
738
|
-
|
|
761
|
+
_context12.next = 9;
|
|
739
762
|
return flushPromises();
|
|
740
763
|
case 9:
|
|
741
764
|
expect(retry429Spy).toBeCalledWith(failurePayload429Two.headers['retry-after'], 'executeFailback');
|
|
@@ -748,19 +771,19 @@ describe('Registration Tests', function () {
|
|
|
748
771
|
expect(reg.rehomingIntervalMax).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MAX);
|
|
749
772
|
case 17:
|
|
750
773
|
case "end":
|
|
751
|
-
return
|
|
774
|
+
return _context12.stop();
|
|
752
775
|
}
|
|
753
|
-
},
|
|
776
|
+
}, _callee12);
|
|
754
777
|
})));
|
|
755
|
-
it('verify unsuccessful failback to primary after initial registration with backup: Restore failure', /*#__PURE__*/(0, _asyncToGenerator2.default)(
|
|
756
|
-
return _regenerator.default.wrap(function
|
|
757
|
-
while (1) switch (
|
|
778
|
+
it('verify unsuccessful failback to primary after initial registration with backup: Restore failure', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee13() {
|
|
779
|
+
return _regenerator.default.wrap(function _callee13$(_context13) {
|
|
780
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
758
781
|
case 0:
|
|
759
782
|
postRegistrationSpy.mockRejectedValue(failurePayload);
|
|
760
783
|
|
|
761
784
|
/* Wait for failback to be triggered. */
|
|
762
785
|
jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
|
|
763
|
-
|
|
786
|
+
_context13.next = 4;
|
|
764
787
|
return flushPromises();
|
|
765
788
|
case 4:
|
|
766
789
|
expect(infoSpy).toBeCalledWith("Attempting failback to primary.", {
|
|
@@ -775,14 +798,14 @@ describe('Registration Tests', function () {
|
|
|
775
798
|
expect(reg.rehomingIntervalMax).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MAX);
|
|
776
799
|
case 11:
|
|
777
800
|
case "end":
|
|
778
|
-
return
|
|
801
|
+
return _context13.stop();
|
|
779
802
|
}
|
|
780
|
-
},
|
|
803
|
+
}, _callee13);
|
|
781
804
|
})));
|
|
782
|
-
it('verify unsuccessful failback to primary after initial registration with backup: Restore failure with final error', /*#__PURE__*/(0, _asyncToGenerator2.default)(
|
|
805
|
+
it('verify unsuccessful failback to primary after initial registration with backup: Restore failure with final error', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee14() {
|
|
783
806
|
var finalErrorPayload;
|
|
784
|
-
return _regenerator.default.wrap(function
|
|
785
|
-
while (1) switch (
|
|
807
|
+
return _regenerator.default.wrap(function _callee14$(_context14) {
|
|
808
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
786
809
|
case 0:
|
|
787
810
|
finalErrorPayload = {
|
|
788
811
|
statusCode: 401,
|
|
@@ -792,7 +815,7 @@ describe('Registration Tests', function () {
|
|
|
792
815
|
postRegistrationSpy.mockRejectedValue(finalErrorPayload).mockRejectedValueOnce(failurePayload);
|
|
793
816
|
/* Wait for failback to be triggered. */
|
|
794
817
|
jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
|
|
795
|
-
|
|
818
|
+
_context14.next = 6;
|
|
796
819
|
return flushPromises();
|
|
797
820
|
case 6:
|
|
798
821
|
expect(infoSpy).toBeCalledWith("Attempting failback to primary.", {
|
|
@@ -807,19 +830,19 @@ describe('Registration Tests', function () {
|
|
|
807
830
|
expect(reg.rehomingIntervalMax).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MAX);
|
|
808
831
|
case 13:
|
|
809
832
|
case "end":
|
|
810
|
-
return
|
|
833
|
+
return _context14.stop();
|
|
811
834
|
}
|
|
812
|
-
},
|
|
835
|
+
}, _callee14);
|
|
813
836
|
})));
|
|
814
|
-
it('verify unsuccessful failback to primary after initial registration with backup: Restore success', /*#__PURE__*/(0, _asyncToGenerator2.default)(
|
|
815
|
-
return _regenerator.default.wrap(function
|
|
816
|
-
while (1) switch (
|
|
837
|
+
it('verify unsuccessful failback to primary after initial registration with backup: Restore success', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee15() {
|
|
838
|
+
return _regenerator.default.wrap(function _callee15$(_context15) {
|
|
839
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
817
840
|
case 0:
|
|
818
841
|
postRegistrationSpy.mockRejectedValueOnce(failurePayload).mockResolvedValue(successPayload);
|
|
819
842
|
|
|
820
843
|
/* Wait for failback to be triggered. */
|
|
821
844
|
jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
|
|
822
|
-
|
|
845
|
+
_context15.next = 4;
|
|
823
846
|
return flushPromises();
|
|
824
847
|
case 4:
|
|
825
848
|
expect(infoSpy).toBeCalledWith("Attempting failback to primary.", {
|
|
@@ -835,19 +858,19 @@ describe('Registration Tests', function () {
|
|
|
835
858
|
expect(reg.rehomingIntervalMax).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MAX);
|
|
836
859
|
case 11:
|
|
837
860
|
case "end":
|
|
838
|
-
return
|
|
861
|
+
return _context15.stop();
|
|
839
862
|
}
|
|
840
|
-
},
|
|
863
|
+
}, _callee15);
|
|
841
864
|
})));
|
|
842
|
-
it('verify successful failback to primary after initial registration with backup', /*#__PURE__*/(0, _asyncToGenerator2.default)(
|
|
843
|
-
return _regenerator.default.wrap(function
|
|
844
|
-
while (1) switch (
|
|
865
|
+
it('verify successful failback to primary after initial registration with backup', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee16() {
|
|
866
|
+
return _regenerator.default.wrap(function _callee16$(_context16) {
|
|
867
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
845
868
|
case 0:
|
|
846
869
|
postRegistrationSpy.mockResolvedValue(successPayload);
|
|
847
870
|
|
|
848
871
|
/* Wait for failback to be triggered. */
|
|
849
872
|
jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
|
|
850
|
-
|
|
873
|
+
_context16.next = 4;
|
|
851
874
|
return flushPromises();
|
|
852
875
|
case 4:
|
|
853
876
|
expect(infoSpy).toBeCalledWith("Attempting failback to primary.", {
|
|
@@ -856,21 +879,22 @@ describe('Registration Tests', function () {
|
|
|
856
879
|
});
|
|
857
880
|
|
|
858
881
|
/* Active Url must now match with the primary url */
|
|
882
|
+
expect(deregisterSpy).toBeCalledOnceWith();
|
|
859
883
|
expect(reg.getActiveMobiusUrl()).toStrictEqual(mobiusUris.primary[0]);
|
|
860
884
|
expect(reg.getStatus()).toBe(_types.RegistrationStatus.ACTIVE);
|
|
861
885
|
expect(reg.failbackTimer).toBe(undefined);
|
|
862
886
|
expect(restoreSpy).not.toBeCalled();
|
|
863
887
|
expect(reg.rehomingIntervalMin).toBe(_registerFixtures.mockPostResponse.rehomingIntervalMin);
|
|
864
888
|
expect(reg.rehomingIntervalMax).toBe(_registerFixtures.mockPostResponse.rehomingIntervalMax);
|
|
865
|
-
case
|
|
889
|
+
case 12:
|
|
866
890
|
case "end":
|
|
867
|
-
return
|
|
891
|
+
return _context16.stop();
|
|
868
892
|
}
|
|
869
|
-
},
|
|
893
|
+
}, _callee16);
|
|
870
894
|
})));
|
|
871
|
-
it('verify unsuccessful failback attempt due to active call', /*#__PURE__*/(0, _asyncToGenerator2.default)(
|
|
872
|
-
return _regenerator.default.wrap(function
|
|
873
|
-
while (1) switch (
|
|
895
|
+
it('verify unsuccessful failback attempt due to active call', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee17() {
|
|
896
|
+
return _regenerator.default.wrap(function _callee17$(_context17) {
|
|
897
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
874
898
|
case 0:
|
|
875
899
|
/** create a new call */
|
|
876
900
|
reg.callManager.createCall();
|
|
@@ -879,10 +903,10 @@ describe('Registration Tests', function () {
|
|
|
879
903
|
|
|
880
904
|
/* Wait for failback to be triggered. */
|
|
881
905
|
jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
|
|
882
|
-
|
|
906
|
+
_context17.next = 6;
|
|
883
907
|
return flushPromises();
|
|
884
908
|
case 6:
|
|
885
|
-
expect(infoSpy).toBeCalledWith("Active calls present, deferring failback to next cycle.", {
|
|
909
|
+
expect(infoSpy).toBeCalledWith("Active calls present or primary Mobius is down, deferring failback to next cycle.", {
|
|
886
910
|
method: 'executeFailback',
|
|
887
911
|
file: _constants.REGISTRATION_FILE
|
|
888
912
|
});
|
|
@@ -890,445 +914,552 @@ describe('Registration Tests', function () {
|
|
|
890
914
|
/* Active Url should still match backup url */
|
|
891
915
|
expect(reg.getActiveMobiusUrl()).toStrictEqual(mobiusUris.backup[0]);
|
|
892
916
|
expect(reg.getStatus()).toBe(_types.RegistrationStatus.ACTIVE);
|
|
917
|
+
expect(deregisterSpy).not.toBeCalled();
|
|
893
918
|
expect(restoreSpy).not.toBeCalled();
|
|
894
919
|
expect(restartSpy).not.toBeCalled();
|
|
895
|
-
expect(infoSpy).toBeCalledWith('Active calls present, deferring failback to next cycle.', {
|
|
920
|
+
expect(infoSpy).toBeCalledWith('Active calls present or primary Mobius is down, deferring failback to next cycle.', {
|
|
896
921
|
file: _constants.REGISTRATION_FILE,
|
|
897
922
|
method: _constants.FAILBACK_UTIL
|
|
898
923
|
});
|
|
899
924
|
expect(reg.rehomingIntervalMin).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MIN);
|
|
900
925
|
expect(reg.rehomingIntervalMax).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MAX);
|
|
901
|
-
case
|
|
926
|
+
case 15:
|
|
902
927
|
case "end":
|
|
903
|
-
return
|
|
928
|
+
return _context17.stop();
|
|
904
929
|
}
|
|
905
|
-
},
|
|
930
|
+
}, _callee17);
|
|
931
|
+
})));
|
|
932
|
+
it('verify unsuccessful failback attempt due to primary server being down', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee18() {
|
|
933
|
+
return _regenerator.default.wrap(function _callee18$(_context18) {
|
|
934
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
935
|
+
case 0:
|
|
936
|
+
isPrimaryActiveSpy.mockReturnValue(false);
|
|
937
|
+
|
|
938
|
+
/* Wait for failback to be triggered. */
|
|
939
|
+
jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
|
|
940
|
+
_context18.next = 4;
|
|
941
|
+
return flushPromises();
|
|
942
|
+
case 4:
|
|
943
|
+
expect(infoSpy).toBeCalledWith("Active calls present or primary Mobius is down, deferring failback to next cycle.", {
|
|
944
|
+
method: 'executeFailback',
|
|
945
|
+
file: _constants.REGISTRATION_FILE
|
|
946
|
+
});
|
|
947
|
+
|
|
948
|
+
/* Active Url should still match backup url */
|
|
949
|
+
expect(deregisterSpy).not.toBeCalled();
|
|
950
|
+
expect(reg.getActiveMobiusUrl()).toStrictEqual(mobiusUris.backup[0]);
|
|
951
|
+
expect(reg.getStatus()).toBe(_types.RegistrationStatus.ACTIVE);
|
|
952
|
+
case 8:
|
|
953
|
+
case "end":
|
|
954
|
+
return _context18.stop();
|
|
955
|
+
}
|
|
956
|
+
}, _callee18);
|
|
906
957
|
})));
|
|
907
958
|
});
|
|
908
959
|
|
|
909
960
|
// Keep-alive related test cases
|
|
910
961
|
describe('Keep-alive Tests', function () {
|
|
911
|
-
var logObj = {
|
|
912
|
-
file: _constants.REGISTRATION_FILE,
|
|
913
|
-
method: 'startKeepaliveTimer'
|
|
914
|
-
};
|
|
915
|
-
var mockKeepAliveBody = {
|
|
916
|
-
device: _registerFixtures.mockPostResponse.device
|
|
917
|
-
};
|
|
918
962
|
var beforeEachSetupForKeepalive = /*#__PURE__*/function () {
|
|
919
|
-
var
|
|
920
|
-
return _regenerator.default.wrap(function
|
|
921
|
-
while (1) switch (
|
|
963
|
+
var _ref19 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee19() {
|
|
964
|
+
return _regenerator.default.wrap(function _callee19$(_context19) {
|
|
965
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
922
966
|
case 0:
|
|
923
967
|
postRegistrationSpy.mockResolvedValueOnce(successPayload);
|
|
924
968
|
jest.useFakeTimers();
|
|
925
|
-
|
|
969
|
+
_context19.next = 4;
|
|
926
970
|
return reg.triggerRegistration();
|
|
927
971
|
case 4:
|
|
928
972
|
expect(reg.getStatus()).toBe(_types.RegistrationStatus.ACTIVE);
|
|
929
|
-
|
|
973
|
+
expect(reg.webWorker).toBeDefined();
|
|
974
|
+
case 6:
|
|
930
975
|
case "end":
|
|
931
|
-
return
|
|
976
|
+
return _context19.stop();
|
|
932
977
|
}
|
|
933
|
-
},
|
|
978
|
+
}, _callee19);
|
|
934
979
|
}));
|
|
935
980
|
return function beforeEachSetupForKeepalive() {
|
|
936
|
-
return
|
|
981
|
+
return _ref19.apply(this, arguments);
|
|
937
982
|
};
|
|
938
983
|
}();
|
|
939
984
|
afterEach(function () {
|
|
940
985
|
jest.clearAllTimers();
|
|
941
986
|
jest.clearAllMocks();
|
|
942
|
-
|
|
943
|
-
clearInterval(reg.keepaliveTimer);
|
|
944
|
-
reg.keepaliveTimer = undefined;
|
|
945
|
-
}
|
|
987
|
+
reg.clearKeepaliveTimer();
|
|
946
988
|
reg.reconnectPending = false;
|
|
947
989
|
var calls = (0, _values.default)(reg.callManager.getActiveCalls());
|
|
948
990
|
calls.forEach(function (call) {
|
|
949
991
|
call.end();
|
|
950
992
|
});
|
|
951
993
|
});
|
|
952
|
-
it('verify successful keep-alive cases', /*#__PURE__*/(0, _asyncToGenerator2.default)(
|
|
953
|
-
var
|
|
994
|
+
it('verify successful keep-alive cases', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee20() {
|
|
995
|
+
var postMessageSpy;
|
|
996
|
+
return _regenerator.default.wrap(function _callee20$(_context20) {
|
|
997
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
998
|
+
case 0:
|
|
999
|
+
postMessageSpy = jest.spyOn(Worker.prototype, 'postMessage');
|
|
1000
|
+
_context20.next = 3;
|
|
1001
|
+
return beforeEachSetupForKeepalive();
|
|
1002
|
+
case 3:
|
|
1003
|
+
expect(reg.webWorker).toBeDefined();
|
|
1004
|
+
expect(postMessageSpy).toHaveBeenCalledWith(expect.objectContaining({
|
|
1005
|
+
type: 'START_KEEPALIVE',
|
|
1006
|
+
accessToken: expect.any(String),
|
|
1007
|
+
deviceUrl: expect.any(String),
|
|
1008
|
+
interval: expect.any(Number),
|
|
1009
|
+
retryCountThreshold: expect.any(Number),
|
|
1010
|
+
url: expect.any(String)
|
|
1011
|
+
}));
|
|
1012
|
+
reg.webWorker.onmessage({
|
|
1013
|
+
data: {
|
|
1014
|
+
type: 'KEEPALIVE_SUCCESS',
|
|
1015
|
+
statusCode: 200
|
|
1016
|
+
}
|
|
1017
|
+
});
|
|
1018
|
+
expect(lineEmitter).toBeCalledWith(_types4.LINE_EVENTS.RECONNECTED);
|
|
1019
|
+
case 7:
|
|
1020
|
+
case "end":
|
|
1021
|
+
return _context20.stop();
|
|
1022
|
+
}
|
|
1023
|
+
}, _callee20);
|
|
1024
|
+
})));
|
|
1025
|
+
it('verify failure keep-alive cases: Retry Success', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee21() {
|
|
1026
|
+
var worker;
|
|
954
1027
|
return _regenerator.default.wrap(function _callee21$(_context21) {
|
|
955
1028
|
while (1) switch (_context21.prev = _context21.next) {
|
|
956
1029
|
case 0:
|
|
957
1030
|
_context21.next = 2;
|
|
958
1031
|
return beforeEachSetupForKeepalive();
|
|
959
1032
|
case 2:
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
1033
|
+
worker = reg.webWorker;
|
|
1034
|
+
lineEmitter.mockClear();
|
|
1035
|
+
worker.onmessage({
|
|
1036
|
+
data: {
|
|
1037
|
+
type: 'KEEPALIVE_FAILURE',
|
|
1038
|
+
err: {
|
|
1039
|
+
statusCode: 503
|
|
1040
|
+
},
|
|
1041
|
+
keepAliveRetryCount: 1
|
|
1042
|
+
}
|
|
1043
|
+
});
|
|
1044
|
+
worker.onmessage({
|
|
1045
|
+
data: {
|
|
1046
|
+
type: 'KEEPALIVE_SUCCESS',
|
|
1047
|
+
statusCode: 200
|
|
1048
|
+
}
|
|
1049
|
+
});
|
|
1050
|
+
expect(lineEmitter).toHaveBeenCalledWith(_types4.LINE_EVENTS.RECONNECTED);
|
|
1051
|
+
case 7:
|
|
975
1052
|
case "end":
|
|
976
1053
|
return _context21.stop();
|
|
977
1054
|
}
|
|
978
1055
|
}, _callee21);
|
|
979
1056
|
})));
|
|
980
|
-
it('verify failure keep-alive cases:
|
|
981
|
-
var
|
|
1057
|
+
it('verify failure keep-alive cases: Restore failure', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee22() {
|
|
1058
|
+
var reconnectSpy, restoreSpy, restartRegSpy, RETRY_COUNT_THRESHOLD, failureEvent;
|
|
982
1059
|
return _regenerator.default.wrap(function _callee22$(_context22) {
|
|
983
1060
|
while (1) switch (_context22.prev = _context22.next) {
|
|
984
1061
|
case 0:
|
|
985
1062
|
_context22.next = 2;
|
|
986
1063
|
return beforeEachSetupForKeepalive();
|
|
987
1064
|
case 2:
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
};
|
|
992
|
-
successPayload = {
|
|
993
|
-
statusCode: 200,
|
|
994
|
-
body: mockKeepAliveBody
|
|
995
|
-
};
|
|
996
|
-
timer = reg.keepaliveTimer;
|
|
1065
|
+
reconnectSpy = jest.spyOn(reg, 'reconnectOnFailure');
|
|
1066
|
+
restoreSpy = jest.spyOn(reg, 'restorePreviousRegistration');
|
|
1067
|
+
restartRegSpy = jest.spyOn(reg, 'restartRegistration'); // Clear previous event emissions
|
|
997
1068
|
lineEmitter.mockClear();
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1069
|
+
|
|
1070
|
+
// Assume registration is active
|
|
1071
|
+
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
|
|
1072
|
+
|
|
1073
|
+
// Use fake timers to trigger keepalive initialization
|
|
1074
|
+
jest.useFakeTimers();
|
|
1075
|
+
jest.advanceTimersByTime(_registerFixtures.mockPostResponse.keepaliveInterval * _constants.SEC_TO_MSEC_MFACTOR);
|
|
1076
|
+
|
|
1077
|
+
// Simulate the worker sending a KEEPALIVE_FAILURE message with retry count at threshold.
|
|
1078
|
+
RETRY_COUNT_THRESHOLD = reg.isCCFlow ? 4 : 5;
|
|
1079
|
+
failureEvent = {
|
|
1080
|
+
data: {
|
|
1081
|
+
type: _types.WorkerMessageType.KEEPALIVE_FAILURE,
|
|
1082
|
+
err: {
|
|
1083
|
+
statusCode: 503
|
|
1084
|
+
},
|
|
1085
|
+
keepAliveRetryCount: RETRY_COUNT_THRESHOLD
|
|
1086
|
+
}
|
|
1087
|
+
};
|
|
1088
|
+
reg.webWorker.onmessage(failureEvent);
|
|
1089
|
+
_context22.next = 14;
|
|
1001
1090
|
return flushPromises();
|
|
1002
|
-
case
|
|
1003
|
-
expect(
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
expect(
|
|
1008
|
-
|
|
1009
|
-
expect(
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1091
|
+
case 14:
|
|
1092
|
+
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
|
|
1093
|
+
expect(lineEmitter).toHaveBeenCalledWith(_types4.LINE_EVENTS.UNREGISTERED);
|
|
1094
|
+
expect(reconnectSpy).toBeCalledOnceWith(_constants.KEEPALIVE_UTIL);
|
|
1095
|
+
expect(restoreSpy).toBeCalledOnceWith(_constants.KEEPALIVE_UTIL);
|
|
1096
|
+
expect(restartRegSpy).toBeCalledOnceWith(_constants.KEEPALIVE_UTIL);
|
|
1097
|
+
jest.useRealTimers();
|
|
1098
|
+
expect(warnSpy).toHaveBeenCalledWith('Keep-alive missed 5 times. Status -> 503 ', expect.objectContaining({
|
|
1099
|
+
file: _constants.REGISTRATION_FILE,
|
|
1100
|
+
method: 'startKeepaliveTimer'
|
|
1101
|
+
}));
|
|
1102
|
+
case 21:
|
|
1013
1103
|
case "end":
|
|
1014
1104
|
return _context22.stop();
|
|
1015
1105
|
}
|
|
1016
1106
|
}, _callee22);
|
|
1017
1107
|
})));
|
|
1018
|
-
it('verify failure keep-alive cases: Restore
|
|
1019
|
-
var
|
|
1108
|
+
it('verify failure keep-alive cases: Restore Success', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee23() {
|
|
1109
|
+
var reconnectSpy, url;
|
|
1020
1110
|
return _regenerator.default.wrap(function _callee23$(_context23) {
|
|
1021
1111
|
while (1) switch (_context23.prev = _context23.next) {
|
|
1022
1112
|
case 0:
|
|
1023
1113
|
_context23.next = 2;
|
|
1024
1114
|
return beforeEachSetupForKeepalive();
|
|
1025
1115
|
case 2:
|
|
1026
|
-
|
|
1027
|
-
restartRegSpy = jest.spyOn(reg, 'restartRegistration');
|
|
1116
|
+
expect(reg.webWorker).toBeDefined();
|
|
1028
1117
|
reconnectSpy = jest.spyOn(reg, 'reconnectOnFailure');
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1118
|
+
url = 'https://mobius-dfw.webex.com/api/v1/calling/web/';
|
|
1119
|
+
reg.webWorker.onmessage({
|
|
1120
|
+
data: {
|
|
1121
|
+
type: _types.WorkerMessageType.KEEPALIVE_FAILURE,
|
|
1122
|
+
err: {
|
|
1123
|
+
statusCode: 503
|
|
1124
|
+
},
|
|
1125
|
+
keepAliveRetryCount: 5
|
|
1126
|
+
}
|
|
1127
|
+
});
|
|
1128
|
+
jest.advanceTimersByTime(1000);
|
|
1129
|
+
_context23.next = 9;
|
|
1040
1130
|
return flushPromises();
|
|
1131
|
+
case 9:
|
|
1132
|
+
expect(reg.webWorker).toBeUndefined();
|
|
1133
|
+
expect(reconnectSpy).toBeCalledOnceWith(reg.startKeepaliveTimer.name);
|
|
1134
|
+
webex.request.mockResolvedValueOnce(successPayload);
|
|
1135
|
+
_context23.next = 14;
|
|
1136
|
+
return reg.triggerRegistration();
|
|
1041
1137
|
case 14:
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
expect(warnSpy).toHaveBeenCalledWith('Keep-alive missed 1 times. Status -> 503 ', expect.objectContaining({
|
|
1053
|
-
file: _constants.REGISTRATION_FILE,
|
|
1054
|
-
method: 'startKeepaliveTimer'
|
|
1055
|
-
}));
|
|
1056
|
-
expect(webex.request).toBeCalledTimes(7);
|
|
1057
|
-
expect(reg.keepaliveTimer).toBe(undefined);
|
|
1058
|
-
expect(warnSpy).toHaveBeenCalledWith('Keep-alive missed 1 times. Status -> 503 ', expect.objectContaining({
|
|
1059
|
-
file: _constants.REGISTRATION_FILE,
|
|
1060
|
-
method: 'startKeepaliveTimer'
|
|
1061
|
-
}));
|
|
1062
|
-
expect(lineEmitter).nthCalledWith(1, _types4.LINE_EVENTS.RECONNECTING);
|
|
1063
|
-
expect(lineEmitter).nthCalledWith(4, _types4.LINE_EVENTS.RECONNECTING);
|
|
1064
|
-
expect(lineEmitter).nthCalledWith(5, _types4.LINE_EVENTS.UNREGISTERED);
|
|
1138
|
+
_context23.next = 16;
|
|
1139
|
+
return flushPromises();
|
|
1140
|
+
case 16:
|
|
1141
|
+
expect(reg.webWorker).toBeDefined();
|
|
1142
|
+
reg.webWorker.onmessage({
|
|
1143
|
+
data: {
|
|
1144
|
+
type: _types.WorkerMessageType.KEEPALIVE_SUCCESS,
|
|
1145
|
+
statusCode: 200
|
|
1146
|
+
}
|
|
1147
|
+
});
|
|
1065
1148
|
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
expect(
|
|
1072
|
-
|
|
1149
|
+
// Advance timers and flush any remaining promises.
|
|
1150
|
+
jest.advanceTimersByTime(1000);
|
|
1151
|
+
_context23.next = 21;
|
|
1152
|
+
return flushPromises();
|
|
1153
|
+
case 21:
|
|
1154
|
+
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
|
|
1155
|
+
// reconnectSpy should have been called only once.
|
|
1156
|
+
expect(reconnectSpy).toBeCalledTimes(1);
|
|
1157
|
+
expect(restoreSpy).toBeCalledOnceWith(reg.startKeepaliveTimer.name);
|
|
1158
|
+
expect(restartSpy).toBeCalledOnceWith(reg.startKeepaliveTimer.name);
|
|
1159
|
+
// Active Mobius URL should remain unchanged.
|
|
1160
|
+
expect(reg.getActiveMobiusUrl()).toStrictEqual(url);
|
|
1161
|
+
case 26:
|
|
1073
1162
|
case "end":
|
|
1074
1163
|
return _context23.stop();
|
|
1075
1164
|
}
|
|
1076
1165
|
}, _callee23);
|
|
1077
1166
|
})));
|
|
1078
|
-
it('verify failure
|
|
1079
|
-
var restoreSpy, restartRegSpy, reconnectSpy, failurePayload, successPayload, clearIntervalSpy, url, timer;
|
|
1167
|
+
it('verify failure followed by recovery of keepalive', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee24() {
|
|
1080
1168
|
return _regenerator.default.wrap(function _callee24$(_context24) {
|
|
1081
1169
|
while (1) switch (_context24.prev = _context24.next) {
|
|
1082
1170
|
case 0:
|
|
1083
1171
|
_context24.next = 2;
|
|
1084
1172
|
return beforeEachSetupForKeepalive();
|
|
1085
1173
|
case 2:
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1174
|
+
expect(reg.getStatus()).toBe(_types.RegistrationStatus.ACTIVE);
|
|
1175
|
+
expect(reg.webWorker).toBeDefined();
|
|
1176
|
+
webex.request.mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload).mockResolvedValue(successPayload);
|
|
1177
|
+
reg.webWorker.onmessage({
|
|
1178
|
+
data: {
|
|
1179
|
+
type: _types.WorkerMessageType.KEEPALIVE_FAILURE,
|
|
1180
|
+
err: failurePayload,
|
|
1181
|
+
keepAliveRetryCount: reg.isCCFlow ? 4 : 5
|
|
1182
|
+
}
|
|
1183
|
+
});
|
|
1184
|
+
_context24.next = 8;
|
|
1185
|
+
return flushPromises();
|
|
1186
|
+
case 8:
|
|
1187
|
+
expect(reg.webWorker).toBeUndefined();
|
|
1188
|
+
expect(handleErrorSpy).toBeCalledTimes(3);
|
|
1189
|
+
_context24.next = 12;
|
|
1190
|
+
return reg.triggerRegistration();
|
|
1191
|
+
case 12:
|
|
1192
|
+
_context24.next = 14;
|
|
1193
|
+
return flushPromises();
|
|
1194
|
+
case 14:
|
|
1195
|
+
expect(reg.webWorker).toBeDefined();
|
|
1196
|
+
reg.webWorker.onmessage({
|
|
1197
|
+
data: {
|
|
1198
|
+
type: _types.WorkerMessageType.KEEPALIVE_SUCCESS,
|
|
1199
|
+
statusCode: 200
|
|
1200
|
+
}
|
|
1201
|
+
});
|
|
1202
|
+
_context24.next = 18;
|
|
1203
|
+
return flushPromises();
|
|
1204
|
+
case 18:
|
|
1205
|
+
// In a complete failure‐then-recovery scenario, we expect another failure event to have been handled.
|
|
1206
|
+
// For that, simulate a second failure event on the new worker.
|
|
1207
|
+
reg.webWorker.onmessage({
|
|
1208
|
+
data: {
|
|
1209
|
+
type: _types.WorkerMessageType.KEEPALIVE_FAILURE,
|
|
1210
|
+
err: failurePayload,
|
|
1211
|
+
keepAliveRetryCount: reg.isCCFlow ? 4 : 5
|
|
1212
|
+
}
|
|
1213
|
+
});
|
|
1214
|
+
_context24.next = 21;
|
|
1215
|
+
return flushPromises();
|
|
1216
|
+
case 21:
|
|
1217
|
+
expect(handleErrorSpy).toBeCalledTimes(4);
|
|
1102
1218
|
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
jest.advanceTimersByTime(5 * _registerFixtures.mockPostResponse.keepaliveInterval * _constants.SEC_TO_MSEC_MFACTOR);
|
|
1109
|
-
_context24.next = 16;
|
|
1219
|
+
// And then re-register successfully:
|
|
1220
|
+
_context24.next = 24;
|
|
1221
|
+
return reg.triggerRegistration();
|
|
1222
|
+
case 24:
|
|
1223
|
+
_context24.next = 26;
|
|
1110
1224
|
return flushPromises();
|
|
1111
|
-
case 16:
|
|
1112
|
-
expect(clearIntervalSpy).toBeCalledOnceWith(timer);
|
|
1113
|
-
expect(handleErrorSpy).toBeCalledTimes(5);
|
|
1114
|
-
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
|
|
1115
|
-
expect(reconnectSpy).toBeCalledOnceWith(_constants.KEEPALIVE_UTIL);
|
|
1116
|
-
expect(restoreSpy).toBeCalledOnceWith(_constants.KEEPALIVE_UTIL);
|
|
1117
|
-
expect(restartRegSpy).not.toBeCalled();
|
|
1118
|
-
expect(reg.getActiveMobiusUrl()).toStrictEqual(url);
|
|
1119
|
-
expect(reg.reconnectPending).toStrictEqual(false);
|
|
1120
|
-
expect(reg.keepaliveTimer).toBeTruthy();
|
|
1121
|
-
expect(reg.keepaliveTimer).not.toBe(timer);
|
|
1122
1225
|
case 26:
|
|
1226
|
+
expect(reg.webWorker).toBeDefined();
|
|
1227
|
+
reg.webWorker.onmessage({
|
|
1228
|
+
data: {
|
|
1229
|
+
type: _types.WorkerMessageType.KEEPALIVE_SUCCESS,
|
|
1230
|
+
statusCode: 200
|
|
1231
|
+
}
|
|
1232
|
+
});
|
|
1233
|
+
_context24.next = 30;
|
|
1234
|
+
return flushPromises();
|
|
1235
|
+
case 30:
|
|
1236
|
+
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
|
|
1237
|
+
expect(reg.webWorker).toBeDefined();
|
|
1238
|
+
case 32:
|
|
1123
1239
|
case "end":
|
|
1124
1240
|
return _context24.stop();
|
|
1125
1241
|
}
|
|
1126
1242
|
}, _callee24);
|
|
1127
1243
|
})));
|
|
1128
|
-
it('verify
|
|
1129
|
-
var
|
|
1244
|
+
it('cc: verify failover to backup server after 4 keep alive failure with primary server', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee25() {
|
|
1245
|
+
var clearKeepaliveSpy, reconnectSpy;
|
|
1130
1246
|
return _regenerator.default.wrap(function _callee25$(_context25) {
|
|
1131
1247
|
while (1) switch (_context25.prev = _context25.next) {
|
|
1132
1248
|
case 0:
|
|
1133
|
-
|
|
1249
|
+
// Register with contact center service
|
|
1250
|
+
setupRegistration(_objectSpread(_objectSpread({}, MockServiceData), {}, {
|
|
1251
|
+
indicator: _types.ServiceIndicator.CONTACT_CENTER
|
|
1252
|
+
}));
|
|
1253
|
+
_context25.next = 3;
|
|
1134
1254
|
return beforeEachSetupForKeepalive();
|
|
1135
|
-
case
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1255
|
+
case 3:
|
|
1256
|
+
webex.request.mockResolvedValueOnce(successPayload);
|
|
1257
|
+
_context25.next = 6;
|
|
1258
|
+
return reg.triggerRegistration();
|
|
1259
|
+
case 6:
|
|
1260
|
+
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
|
|
1261
|
+
expect(reg.webWorker).toBeDefined();
|
|
1262
|
+
|
|
1263
|
+
// Spy on clearKeepaliveTimer and simulate reconnectOnFailure behavior
|
|
1264
|
+
clearKeepaliveSpy = jest.spyOn(reg, 'clearKeepaliveTimer');
|
|
1265
|
+
reconnectSpy = jest.spyOn(reg, 'reconnectOnFailure'); // Simulate a KEEPALIVE_FAILURE message from the worker with a retry count equal to threshold (4 for CC)
|
|
1266
|
+
reg.webWorker.onmessage({
|
|
1267
|
+
data: {
|
|
1268
|
+
type: _types.WorkerMessageType.KEEPALIVE_FAILURE,
|
|
1269
|
+
err: {
|
|
1270
|
+
statusCode: 503
|
|
1271
|
+
},
|
|
1272
|
+
keepAliveRetryCount: 4
|
|
1273
|
+
}
|
|
1274
|
+
});
|
|
1275
|
+
|
|
1276
|
+
// Wait for any asynchronous actions to complete
|
|
1277
|
+
_context25.next = 13;
|
|
1150
1278
|
return flushPromises();
|
|
1151
|
-
case
|
|
1152
|
-
|
|
1153
|
-
expect(
|
|
1154
|
-
expect(
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1279
|
+
case 13:
|
|
1280
|
+
// Verify that the keepalive timer was cleared and reconnectOnFailure was triggered
|
|
1281
|
+
expect(clearKeepaliveSpy).toHaveBeenCalled();
|
|
1282
|
+
expect(reconnectSpy).toHaveBeenCalledWith(reg.startKeepaliveTimer.name);
|
|
1283
|
+
|
|
1284
|
+
// Verify that the active Mobius URL has been updated to the backup server and registration is active
|
|
1285
|
+
expect(reg.getActiveMobiusUrl()).toEqual(mobiusUris.backup[0]);
|
|
1286
|
+
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
|
|
1287
|
+
case 17:
|
|
1158
1288
|
case "end":
|
|
1159
1289
|
return _context25.stop();
|
|
1160
1290
|
}
|
|
1161
1291
|
}, _callee25);
|
|
1162
1292
|
})));
|
|
1163
|
-
it('
|
|
1164
|
-
var
|
|
1293
|
+
it('verify failure keep-alive case with active call present: Restore Success after call ends', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee26() {
|
|
1294
|
+
var reconnectSpy, restoreSpy, restartRegSpy, clearTimerSpy, threshold, failureEvent;
|
|
1165
1295
|
return _regenerator.default.wrap(function _callee26$(_context26) {
|
|
1166
1296
|
while (1) switch (_context26.prev = _context26.next) {
|
|
1167
1297
|
case 0:
|
|
1168
|
-
|
|
1169
|
-
setupRegistration(_objectSpread(_objectSpread({}, MockServiceData), {}, {
|
|
1170
|
-
indicator: _types.ServiceIndicator.CONTACT_CENTER
|
|
1171
|
-
}));
|
|
1172
|
-
_context26.next = 3;
|
|
1298
|
+
_context26.next = 2;
|
|
1173
1299
|
return beforeEachSetupForKeepalive();
|
|
1174
|
-
case
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1300
|
+
case 2:
|
|
1301
|
+
reconnectSpy = jest.spyOn(reg, 'reconnectOnFailure');
|
|
1302
|
+
restoreSpy = jest.spyOn(reg, 'restorePreviousRegistration');
|
|
1303
|
+
restartRegSpy = jest.spyOn(reg, 'restartRegistration'); // Simulate an active call.
|
|
1304
|
+
reg.callManager.createCall();
|
|
1305
|
+
expect((0, _keys.default)(reg.callManager.getActiveCalls()).length).toBe(1);
|
|
1306
|
+
clearTimerSpy = jest.spyOn(reg, 'clearKeepaliveTimer');
|
|
1307
|
+
threshold = reg.isCCFlow ? 4 : 5; // Simulate a KEEPALIVE_FAILURE event with a 503 error at threshold.
|
|
1308
|
+
failureEvent = {
|
|
1309
|
+
data: {
|
|
1310
|
+
type: _types.WorkerMessageType.KEEPALIVE_FAILURE,
|
|
1311
|
+
err: {
|
|
1312
|
+
statusCode: 503
|
|
1313
|
+
},
|
|
1314
|
+
keepAliveRetryCount: threshold
|
|
1315
|
+
}
|
|
1182
1316
|
};
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
expect(reg.getStatus()).toBe(_types.RegistrationStatus.ACTIVE);
|
|
1186
|
-
timer = reg.keepaliveTimer;
|
|
1187
|
-
jest.advanceTimersByTime(5 * _registerFixtures.mockPostResponse.keepaliveInterval * _constants.SEC_TO_MSEC_MFACTOR);
|
|
1188
|
-
_context26.next = 12;
|
|
1317
|
+
reg.webWorker.onmessage(failureEvent);
|
|
1318
|
+
_context26.next = 13;
|
|
1189
1319
|
return flushPromises();
|
|
1190
|
-
case
|
|
1191
|
-
|
|
1192
|
-
expect(
|
|
1193
|
-
expect(reg.
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1320
|
+
case 13:
|
|
1321
|
+
// At this point, clearKeepaliveTimer was called so the worker is terminated.
|
|
1322
|
+
expect(clearTimerSpy).toHaveBeenCalled();
|
|
1323
|
+
expect(reg.webWorker).toBeUndefined();
|
|
1324
|
+
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
|
|
1325
|
+
expect(lineEmitter).lastCalledWith(_types4.LINE_EVENTS.UNREGISTERED);
|
|
1326
|
+
expect(reg.keepaliveTimer).toStrictEqual(undefined);
|
|
1327
|
+
expect(reg.failbackTimer).toStrictEqual(undefined);
|
|
1328
|
+
expect(reconnectSpy).toBeCalledOnceWith(_constants.KEEPALIVE_UTIL);
|
|
1329
|
+
expect(restoreSpy).not.toBeCalled();
|
|
1330
|
+
expect(restartRegSpy).not.toBeCalled();
|
|
1331
|
+
expect(reg.reconnectPending).toStrictEqual(true);
|
|
1332
|
+
expect(infoSpy).toBeCalledWith('Active call(s) present, deferred reconnect till call cleanup.', {
|
|
1333
|
+
file: _constants.REGISTRATION_FILE,
|
|
1334
|
+
method: expect.any(String)
|
|
1335
|
+
});
|
|
1336
|
+
reconnectSpy.mockClear();
|
|
1337
|
+
|
|
1338
|
+
// Now simulate call cleanup.
|
|
1339
|
+
reg.callManager.callCollection = {};
|
|
1340
|
+
webex.request.mockResolvedValueOnce(successPayload);
|
|
1341
|
+
|
|
1342
|
+
// Call reconnectOnFailure manually. With no active calls, this should trigger re-registration.
|
|
1343
|
+
_context26.next = 29;
|
|
1344
|
+
return reg.reconnectOnFailure(_constants.CALLS_CLEARED_HANDLER_UTIL);
|
|
1345
|
+
case 29:
|
|
1346
|
+
_context26.next = 31;
|
|
1197
1347
|
return flushPromises();
|
|
1198
|
-
case
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
expect(reg.getStatus()).
|
|
1202
|
-
|
|
1348
|
+
case 31:
|
|
1349
|
+
expect((0, _keys.default)(reg.callManager.getActiveCalls()).length).toBe(0);
|
|
1350
|
+
// After re-registration, registration status becomes ACTIVE and a new worker is created.
|
|
1351
|
+
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
|
|
1352
|
+
expect(reg.webWorker).toBeDefined();
|
|
1353
|
+
expect(reconnectSpy).toBeCalledOnceWith(_constants.CALLS_CLEARED_HANDLER_UTIL);
|
|
1354
|
+
expect(restoreSpy).toBeCalledOnceWith(_constants.CALLS_CLEARED_HANDLER_UTIL);
|
|
1355
|
+
expect(restartRegSpy).not.toBeCalled();
|
|
1356
|
+
expect(reg.reconnectPending).toStrictEqual(false);
|
|
1357
|
+
case 38:
|
|
1203
1358
|
case "end":
|
|
1204
1359
|
return _context26.stop();
|
|
1205
1360
|
}
|
|
1206
1361
|
}, _callee26);
|
|
1207
1362
|
})));
|
|
1208
|
-
it('
|
|
1209
|
-
var restoreSpy, restartRegSpy,
|
|
1363
|
+
it('checks for keep-alive failure with final error: 404', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee27() {
|
|
1364
|
+
var reconnectSpy, restoreSpy, restartRegSpy, clearTimerSpy;
|
|
1210
1365
|
return _regenerator.default.wrap(function _callee27$(_context27) {
|
|
1211
1366
|
while (1) switch (_context27.prev = _context27.next) {
|
|
1212
1367
|
case 0:
|
|
1213
1368
|
_context27.next = 2;
|
|
1214
1369
|
return beforeEachSetupForKeepalive();
|
|
1215
1370
|
case 2:
|
|
1371
|
+
reconnectSpy = jest.spyOn(reg, 'reconnectOnFailure');
|
|
1216
1372
|
restoreSpy = jest.spyOn(reg, 'restorePreviousRegistration');
|
|
1217
1373
|
restartRegSpy = jest.spyOn(reg, 'restartRegistration');
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
jest.advanceTimersByTime(_registerFixtures.mockPostResponse.keepaliveInterval * _constants.SEC_TO_MSEC_MFACTOR);
|
|
1229
|
-
_context27.next = 12;
|
|
1230
|
-
return flushPromises();
|
|
1231
|
-
case 12:
|
|
1232
|
-
expect(clearIntervalSpy).toBeCalledTimes(1);
|
|
1233
|
-
expect(reg.getStatus()).toBe(_types.RegistrationStatus.INACTIVE);
|
|
1234
|
-
expect(reconnectSpy).not.toBeCalled();
|
|
1235
|
-
expect(restoreSpy).not.toBeCalled();
|
|
1236
|
-
expect(restartRegSpy).not.toBeCalled();
|
|
1237
|
-
expect(reg.reconnectPending).toStrictEqual(false);
|
|
1238
|
-
expect(webex.request).toBeCalledOnceWith({
|
|
1239
|
-
headers: mockResponse.headers,
|
|
1240
|
-
uri: "".concat(mockKeepAliveBody.device.uri, "/status"),
|
|
1241
|
-
method: 'POST',
|
|
1242
|
-
service: mockResponse.service
|
|
1243
|
-
});
|
|
1244
|
-
expect(reg.keepaliveTimer).toBe(undefined);
|
|
1245
|
-
expect(handleErrorSpy).toBeCalledOnceWith(failurePayload, expect.anything(), {
|
|
1246
|
-
file: _constants.REGISTRATION_FILE,
|
|
1247
|
-
method: _constants.KEEPALIVE_UTIL
|
|
1374
|
+
clearTimerSpy = jest.spyOn(reg, 'clearKeepaliveTimer');
|
|
1375
|
+
jest.spyOn(utils, 'handleRegistrationErrors').mockResolvedValue(true);
|
|
1376
|
+
reg.webWorker.onmessage({
|
|
1377
|
+
data: {
|
|
1378
|
+
type: _types.WorkerMessageType.KEEPALIVE_FAILURE,
|
|
1379
|
+
err: {
|
|
1380
|
+
statusCode: 404
|
|
1381
|
+
},
|
|
1382
|
+
keepAliveRetryCount: 1
|
|
1383
|
+
}
|
|
1248
1384
|
});
|
|
1385
|
+
_context27.next = 10;
|
|
1386
|
+
return flushPromises();
|
|
1387
|
+
case 10:
|
|
1249
1388
|
expect(warnSpy).toBeCalledWith('Keep-alive missed 1 times. Status -> 404 ', expect.objectContaining({
|
|
1250
1389
|
file: _constants.REGISTRATION_FILE,
|
|
1251
1390
|
method: 'startKeepaliveTimer'
|
|
1252
1391
|
}));
|
|
1253
|
-
|
|
1392
|
+
expect(handleErrorSpy).toBeCalledOnceWith({
|
|
1393
|
+
statusCode: 404
|
|
1394
|
+
}, expect.anything(), {
|
|
1395
|
+
file: _constants.REGISTRATION_FILE,
|
|
1396
|
+
method: _constants.KEEPALIVE_UTIL
|
|
1397
|
+
});
|
|
1398
|
+
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
|
|
1399
|
+
expect(lineEmitter).toHaveBeenCalledWith(_types4.LINE_EVENTS.UNREGISTERED);
|
|
1400
|
+
expect(clearTimerSpy).toBeCalledTimes(1);
|
|
1401
|
+
expect(reconnectSpy).not.toHaveBeenCalled();
|
|
1402
|
+
expect(restoreSpy).not.toHaveBeenCalled();
|
|
1403
|
+
expect(restartRegSpy).not.toHaveBeenCalled();
|
|
1404
|
+
expect(reg.reconnectPending).toStrictEqual(false);
|
|
1405
|
+
expect(reg.keepaliveTimer).toBe(undefined);
|
|
1406
|
+
expect(reg.webWorker).toBeUndefined();
|
|
1407
|
+
case 21:
|
|
1254
1408
|
case "end":
|
|
1255
1409
|
return _context27.stop();
|
|
1256
1410
|
}
|
|
1257
1411
|
}, _callee27);
|
|
1258
1412
|
})));
|
|
1259
|
-
|
|
1260
|
-
|
|
1413
|
+
});
|
|
1414
|
+
describe('Primary server status checks', function () {
|
|
1415
|
+
it('success: primary server status to be up', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee28() {
|
|
1416
|
+
var pingSuccessPayload, status;
|
|
1261
1417
|
return _regenerator.default.wrap(function _callee28$(_context28) {
|
|
1262
1418
|
while (1) switch (_context28.prev = _context28.next) {
|
|
1263
1419
|
case 0:
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
case 2:
|
|
1267
|
-
restoreSpy = jest.spyOn(reg, 'restorePreviousRegistration');
|
|
1268
|
-
restartRegSpy = jest.spyOn(reg, 'restartRegistration');
|
|
1269
|
-
reconnectSpy = jest.spyOn(reg, 'reconnectOnFailure');
|
|
1270
|
-
failurePayload = {
|
|
1271
|
-
statusCode: 503,
|
|
1272
|
-
body: mockKeepAliveBody
|
|
1273
|
-
};
|
|
1274
|
-
successPayload = {
|
|
1275
|
-
statusCode: 200,
|
|
1276
|
-
body: mockKeepAliveBody
|
|
1420
|
+
pingSuccessPayload = {
|
|
1421
|
+
statusCode: 200
|
|
1277
1422
|
};
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
expect((0, _keys.default)(reg.callManager.getActiveCalls()).length).toBe(1);
|
|
1290
|
-
|
|
1291
|
-
/* send one keepalive */
|
|
1292
|
-
jest.advanceTimersByTime(5 * _registerFixtures.mockPostResponse.keepaliveInterval * _constants.SEC_TO_MSEC_MFACTOR);
|
|
1293
|
-
_context28.next = 18;
|
|
1294
|
-
return flushPromises();
|
|
1295
|
-
case 18:
|
|
1296
|
-
expect(clearIntervalSpy).toBeCalledOnceWith(timer);
|
|
1297
|
-
expect(handleErrorSpy).toBeCalledTimes(5);
|
|
1298
|
-
expect(reg.keepaliveTimer).toStrictEqual(undefined);
|
|
1299
|
-
expect(reg.failbackTimer).toStrictEqual(undefined);
|
|
1300
|
-
expect(reg.getStatus()).toBe(_types.RegistrationStatus.INACTIVE);
|
|
1301
|
-
expect(lineEmitter).lastCalledWith(_types4.LINE_EVENTS.UNREGISTERED);
|
|
1302
|
-
expect(reconnectSpy).toBeCalledOnceWith(_constants.KEEPALIVE_UTIL);
|
|
1303
|
-
expect(restoreSpy).not.toBeCalled();
|
|
1304
|
-
expect(restartRegSpy).not.toBeCalled();
|
|
1305
|
-
expect(reg.reconnectPending).toStrictEqual(true);
|
|
1306
|
-
expect(infoSpy).toBeCalledWith('Active call(s) present, deferred reconnect till call cleanup.', {
|
|
1307
|
-
file: _constants.REGISTRATION_FILE,
|
|
1308
|
-
method: expect.any(String)
|
|
1309
|
-
});
|
|
1310
|
-
reconnectSpy.mockClear();
|
|
1311
|
-
|
|
1312
|
-
/* simulate call disconnect and Calling client will trigger reconnect upon receiving disconnect event from CallManager */
|
|
1313
|
-
reg.callManager.callCollection = {};
|
|
1314
|
-
_context28.next = 33;
|
|
1315
|
-
return reg.reconnectOnFailure(_constants.CALLS_CLEARED_HANDLER_UTIL);
|
|
1316
|
-
case 33:
|
|
1317
|
-
expect((0, _keys.default)(reg.callManager.getActiveCalls()).length).toBe(0);
|
|
1318
|
-
expect(reg.getStatus()).toBe(_types.RegistrationStatus.ACTIVE);
|
|
1319
|
-
expect(reconnectSpy).toBeCalledOnceWith(_constants.CALLS_CLEARED_HANDLER_UTIL);
|
|
1320
|
-
expect(restoreSpy).toBeCalledOnceWith(_constants.CALLS_CLEARED_HANDLER_UTIL);
|
|
1321
|
-
expect(restartRegSpy).not.toBeCalled();
|
|
1322
|
-
expect(reg.reconnectPending).toStrictEqual(false);
|
|
1323
|
-
expect(reg.getActiveMobiusUrl()).toStrictEqual(url);
|
|
1324
|
-
expect(reg.keepaliveTimer).toBeTruthy();
|
|
1325
|
-
expect(reg.keepaliveTimer).not.toBe(timer);
|
|
1326
|
-
case 42:
|
|
1423
|
+
webex.request.mockResolvedValue(pingSuccessPayload);
|
|
1424
|
+
_context28.next = 4;
|
|
1425
|
+
return reg.isPrimaryActive();
|
|
1426
|
+
case 4:
|
|
1427
|
+
status = _context28.sent;
|
|
1428
|
+
expect(webex.request).toBeCalledWith(_objectSpread({
|
|
1429
|
+
method: 'GET',
|
|
1430
|
+
uri: "https://mobius-dfw.webex.com/api/v1/ping"
|
|
1431
|
+
}, (0, _testUtil.getMockRequestTemplate)()));
|
|
1432
|
+
expect(status).toEqual(true);
|
|
1433
|
+
case 7:
|
|
1327
1434
|
case "end":
|
|
1328
1435
|
return _context28.stop();
|
|
1329
1436
|
}
|
|
1330
1437
|
}, _callee28);
|
|
1331
1438
|
})));
|
|
1439
|
+
it('failed: primary server status to be down', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee29() {
|
|
1440
|
+
var pingFailurePayload, status;
|
|
1441
|
+
return _regenerator.default.wrap(function _callee29$(_context29) {
|
|
1442
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
1443
|
+
case 0:
|
|
1444
|
+
pingFailurePayload = {
|
|
1445
|
+
statusCode: 500
|
|
1446
|
+
};
|
|
1447
|
+
webex.request.mockResolvedValue(pingFailurePayload);
|
|
1448
|
+
_context29.next = 4;
|
|
1449
|
+
return reg.isPrimaryActive();
|
|
1450
|
+
case 4:
|
|
1451
|
+
status = _context29.sent;
|
|
1452
|
+
expect(webex.request).toBeCalledWith(_objectSpread({
|
|
1453
|
+
method: 'GET',
|
|
1454
|
+
uri: "https://mobius-dfw.webex.com/api/v1/ping"
|
|
1455
|
+
}, (0, _testUtil.getMockRequestTemplate)()));
|
|
1456
|
+
expect(status).toEqual(false);
|
|
1457
|
+
case 7:
|
|
1458
|
+
case "end":
|
|
1459
|
+
return _context29.stop();
|
|
1460
|
+
}
|
|
1461
|
+
}, _callee29);
|
|
1462
|
+
})));
|
|
1332
1463
|
});
|
|
1333
1464
|
});
|
|
1334
1465
|
//# sourceMappingURL=register.test.js.map
|