@webex/calling 3.12.0-next.9 → 3.12.0-next.90
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/CallRecording/CallRecording.js +160 -0
- package/dist/CallRecording/CallRecording.js.map +1 -0
- package/dist/CallRecording/CallRecording.test.js +257 -0
- package/dist/CallRecording/CallRecording.test.js.map +1 -0
- package/dist/CallRecording/WxcCallRecordingConnector.js +577 -0
- package/dist/CallRecording/WxcCallRecordingConnector.js.map +1 -0
- package/dist/CallRecording/WxcCallRecordingConnector.test.js +652 -0
- package/dist/CallRecording/WxcCallRecordingConnector.test.js.map +1 -0
- package/dist/CallRecording/callRecordingFixtures.js +235 -0
- package/dist/CallRecording/callRecordingFixtures.js.map +1 -0
- package/dist/CallRecording/constants.js +50 -0
- package/dist/CallRecording/constants.js.map +1 -0
- package/dist/CallRecording/types.js +137 -0
- package/dist/CallRecording/types.js.map +1 -0
- package/dist/CallRecording/utils.js +42 -0
- package/dist/CallRecording/utils.js.map +1 -0
- package/dist/CallRecording/utils.test.js +97 -0
- package/dist/CallRecording/utils.test.js.map +1 -0
- package/dist/CallingClient/CallingClient.js +456 -226
- package/dist/CallingClient/CallingClient.js.map +1 -1
- package/dist/CallingClient/CallingClient.test.js +513 -154
- package/dist/CallingClient/CallingClient.test.js.map +1 -1
- package/dist/CallingClient/calling/call.js +634 -454
- package/dist/CallingClient/calling/call.js.map +1 -1
- package/dist/CallingClient/calling/call.test.js +809 -451
- package/dist/CallingClient/calling/call.test.js.map +1 -1
- package/dist/CallingClient/calling/callManager.js +106 -35
- package/dist/CallingClient/calling/callManager.js.map +1 -1
- package/dist/CallingClient/calling/callManager.test.js +140 -0
- package/dist/CallingClient/calling/callManager.test.js.map +1 -1
- package/dist/CallingClient/calling/types.js +5 -0
- package/dist/CallingClient/calling/types.js.map +1 -1
- package/dist/CallingClient/constants.js +32 -3
- package/dist/CallingClient/constants.js.map +1 -1
- package/dist/CallingClient/line/index.js +8 -1
- package/dist/CallingClient/line/index.js.map +1 -1
- package/dist/CallingClient/line/line.test.js +62 -10
- package/dist/CallingClient/line/line.test.js.map +1 -1
- package/dist/CallingClient/registration/register.js +890 -497
- package/dist/CallingClient/registration/register.js.map +1 -1
- package/dist/CallingClient/registration/register.test.js +649 -58
- package/dist/CallingClient/registration/register.test.js.map +1 -1
- package/dist/CallingClient/registration/types.js +26 -0
- package/dist/CallingClient/registration/types.js.map +1 -1
- package/dist/CallingClient/registration/webWorker.js +41 -104
- package/dist/CallingClient/registration/webWorker.js.map +1 -1
- package/dist/CallingClient/registration/webWorker.test.js +39 -153
- package/dist/CallingClient/registration/webWorker.test.js.map +1 -1
- package/dist/CallingClient/registration/webWorkerStr.js +1 -1
- package/dist/CallingClient/registration/webWorkerStr.js.map +1 -1
- package/dist/CallingClient/types.js +7 -0
- package/dist/CallingClient/types.js.map +1 -1
- package/dist/CallingClient/utils/constants.js +58 -0
- package/dist/CallingClient/utils/constants.js.map +1 -0
- package/dist/CallingClient/utils/index.js +63 -0
- package/dist/CallingClient/utils/index.js.map +1 -0
- package/dist/CallingClient/utils/mobiusSocketMapper.js +122 -0
- package/dist/CallingClient/utils/mobiusSocketMapper.js.map +1 -0
- package/dist/CallingClient/utils/mobiusSocketMapper.test.js +221 -0
- package/dist/CallingClient/utils/mobiusSocketMapper.test.js.map +1 -0
- package/dist/CallingClient/utils/request.js +435 -0
- package/dist/CallingClient/utils/request.js.map +1 -0
- package/dist/CallingClient/utils/request.test.js +999 -0
- package/dist/CallingClient/utils/request.test.js.map +1 -0
- package/dist/CallingClient/utils/types.js +7 -0
- package/dist/CallingClient/utils/types.js.map +1 -0
- package/dist/CallingClient/utils/wsFeatureFlag.js +70 -0
- package/dist/CallingClient/utils/wsFeatureFlag.js.map +1 -0
- package/dist/CallingClient/utils/wsFeatureFlag.test.js +139 -0
- package/dist/CallingClient/utils/wsFeatureFlag.test.js.map +1 -0
- package/dist/Contacts/ContactsClient.js +13 -11
- package/dist/Contacts/ContactsClient.js.map +1 -1
- package/dist/Contacts/ContactsClient.test.js +3 -8
- package/dist/Contacts/ContactsClient.test.js.map +1 -1
- package/dist/Errors/types.js +2 -0
- package/dist/Errors/types.js.map +1 -1
- package/dist/Events/types.js +38 -1
- package/dist/Events/types.js.map +1 -1
- package/dist/Metrics/index.js +63 -2
- package/dist/Metrics/index.js.map +1 -1
- package/dist/Metrics/index.test.js +357 -1
- package/dist/Metrics/index.test.js.map +1 -1
- package/dist/Metrics/types.js +19 -1
- package/dist/Metrics/types.js.map +1 -1
- package/dist/SDKConnector/types.js.map +1 -1
- package/dist/api.js +56 -0
- package/dist/api.js.map +1 -1
- package/dist/common/Utils.js +212 -71
- package/dist/common/Utils.js.map +1 -1
- package/dist/common/Utils.test.js +417 -181
- package/dist/common/Utils.test.js.map +1 -1
- package/dist/common/testUtil.js +10 -5
- package/dist/common/testUtil.js.map +1 -1
- package/dist/common/types.js +3 -0
- package/dist/common/types.js.map +1 -1
- package/dist/index.js +171 -40
- package/dist/index.js.map +1 -1
- package/dist/mobius-socket/config.js +24 -0
- package/dist/mobius-socket/config.js.map +1 -0
- package/dist/mobius-socket/errors.js +143 -0
- package/dist/mobius-socket/errors.js.map +1 -0
- package/dist/mobius-socket/errors.test.js +20 -0
- package/dist/mobius-socket/errors.test.js.map +1 -0
- package/dist/mobius-socket/index.js +57 -0
- package/dist/mobius-socket/index.js.map +1 -0
- package/dist/mobius-socket/mobius-socket-events.test.js +492 -0
- package/dist/mobius-socket/mobius-socket-events.test.js.map +1 -0
- package/dist/mobius-socket/mobius-socket.js +849 -0
- package/dist/mobius-socket/mobius-socket.js.map +1 -0
- package/dist/mobius-socket/mobius-socket.test.js +1898 -0
- package/dist/mobius-socket/mobius-socket.test.js.map +1 -0
- package/dist/mobius-socket/socket/constants.js +55 -0
- package/dist/mobius-socket/socket/constants.js.map +1 -0
- package/dist/mobius-socket/socket/index.js +15 -0
- package/dist/mobius-socket/socket/index.js.map +1 -0
- package/dist/mobius-socket/socket/socket-base.js +604 -0
- package/dist/mobius-socket/socket/socket-base.js.map +1 -0
- package/dist/mobius-socket/socket/socket.js +19 -0
- package/dist/mobius-socket/socket/socket.js.map +1 -0
- package/dist/mobius-socket/socket/socket.shim.js +26 -0
- package/dist/mobius-socket/socket/socket.shim.js.map +1 -0
- package/dist/mobius-socket/socket/types.js +7 -0
- package/dist/mobius-socket/socket/types.js.map +1 -0
- package/dist/mobius-socket/socket.test.js +727 -0
- package/dist/mobius-socket/socket.test.js.map +1 -0
- package/dist/mobius-socket/test/mocha-helpers.js +23 -0
- package/dist/mobius-socket/test/mocha-helpers.js.map +1 -0
- package/dist/mobius-socket/test/promise-tick.js +28 -0
- package/dist/mobius-socket/test/promise-tick.js.map +1 -0
- package/dist/mobius-socket/types.js +7 -0
- package/dist/mobius-socket/types.js.map +1 -0
- package/dist/module/CallRecording/CallRecording.js +56 -0
- package/dist/module/CallRecording/WxcCallRecordingConnector.js +257 -0
- package/dist/module/CallRecording/callRecordingFixtures.js +201 -0
- package/dist/module/CallRecording/constants.js +28 -0
- package/dist/module/CallRecording/types.js +19 -0
- package/dist/module/CallRecording/utils.js +14 -0
- package/dist/module/CallingClient/CallingClient.js +126 -10
- package/dist/module/CallingClient/calling/call.js +198 -66
- package/dist/module/CallingClient/calling/callManager.js +51 -11
- package/dist/module/CallingClient/calling/types.js +2 -0
- package/dist/module/CallingClient/constants.js +27 -0
- package/dist/module/CallingClient/line/index.js +4 -2
- package/dist/module/CallingClient/registration/register.js +266 -64
- package/dist/module/CallingClient/registration/types.js +5 -1
- package/dist/module/CallingClient/registration/webWorker.js +42 -61
- package/dist/module/CallingClient/registration/webWorkerStr.js +47 -82
- package/dist/module/CallingClient/utils/constants.js +36 -0
- package/dist/module/CallingClient/utils/index.js +5 -0
- package/dist/module/CallingClient/utils/mobiusSocketMapper.js +72 -0
- package/dist/module/CallingClient/utils/request.js +211 -0
- package/dist/module/CallingClient/utils/types.js +1 -0
- package/dist/module/CallingClient/utils/wsFeatureFlag.js +41 -0
- package/dist/module/Contacts/ContactsClient.js +1 -1
- package/dist/module/Errors/types.js +2 -0
- package/dist/module/Events/types.js +23 -0
- package/dist/module/Metrics/index.js +48 -1
- package/dist/module/Metrics/types.js +18 -0
- package/dist/module/api.js +3 -2
- package/dist/module/common/Utils.js +85 -22
- package/dist/module/common/testUtil.js +6 -1
- package/dist/module/common/types.js +3 -0
- package/dist/module/index.js +7 -3
- package/dist/module/mobius-socket/config.js +15 -0
- package/dist/module/mobius-socket/errors.js +58 -0
- package/dist/module/mobius-socket/index.js +24 -0
- package/dist/module/mobius-socket/mobius-socket.js +593 -0
- package/dist/module/mobius-socket/socket/constants.js +26 -0
- package/dist/module/mobius-socket/socket/index.js +4 -0
- package/dist/module/mobius-socket/socket/socket-base.js +368 -0
- package/dist/module/mobius-socket/socket/socket.js +9 -0
- package/dist/module/mobius-socket/socket/socket.shim.js +12 -0
- package/dist/module/mobius-socket/socket/types.js +1 -0
- package/dist/module/mobius-socket/types.js +1 -0
- package/dist/types/CallRecording/CallRecording.d.ts +18 -0
- package/dist/types/CallRecording/CallRecording.d.ts.map +1 -0
- package/dist/types/CallRecording/WxcCallRecordingConnector.d.ts +23 -0
- package/dist/types/CallRecording/WxcCallRecordingConnector.d.ts.map +1 -0
- package/dist/types/CallRecording/callRecordingFixtures.d.ts +61 -0
- package/dist/types/CallRecording/callRecordingFixtures.d.ts.map +1 -0
- package/dist/types/CallRecording/constants.d.ts +29 -0
- package/dist/types/CallRecording/constants.d.ts.map +1 -0
- package/dist/types/CallRecording/types.d.ts +176 -0
- package/dist/types/CallRecording/types.d.ts.map +1 -0
- package/dist/types/CallRecording/utils.d.ts +3 -0
- package/dist/types/CallRecording/utils.d.ts.map +1 -0
- package/dist/types/CallingClient/CallingClient.d.ts +8 -0
- package/dist/types/CallingClient/CallingClient.d.ts.map +1 -1
- package/dist/types/CallingClient/calling/call.d.ts +17 -3
- package/dist/types/CallingClient/calling/call.d.ts.map +1 -1
- package/dist/types/CallingClient/calling/callManager.d.ts +8 -4
- package/dist/types/CallingClient/calling/callManager.d.ts.map +1 -1
- package/dist/types/CallingClient/calling/types.d.ts +38 -9
- package/dist/types/CallingClient/calling/types.d.ts.map +1 -1
- package/dist/types/CallingClient/constants.d.ts +27 -0
- package/dist/types/CallingClient/constants.d.ts.map +1 -1
- package/dist/types/CallingClient/line/index.d.ts +1 -1
- package/dist/types/CallingClient/line/index.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/register.d.ts +8 -1
- package/dist/types/CallingClient/registration/register.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/types.d.ts +27 -2
- package/dist/types/CallingClient/registration/types.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/webWorker.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/webWorkerStr.d.ts +1 -1
- package/dist/types/CallingClient/registration/webWorkerStr.d.ts.map +1 -1
- package/dist/types/CallingClient/types.d.ts +4 -2
- package/dist/types/CallingClient/types.d.ts.map +1 -1
- package/dist/types/CallingClient/utils/constants.d.ts +35 -0
- package/dist/types/CallingClient/utils/constants.d.ts.map +1 -0
- package/dist/types/CallingClient/utils/index.d.ts +6 -0
- package/dist/types/CallingClient/utils/index.d.ts.map +1 -0
- package/dist/types/CallingClient/utils/mobiusSocketMapper.d.ts +5 -0
- package/dist/types/CallingClient/utils/mobiusSocketMapper.d.ts.map +1 -0
- package/dist/types/CallingClient/utils/request.d.ts +28 -0
- package/dist/types/CallingClient/utils/request.d.ts.map +1 -0
- package/dist/types/CallingClient/utils/types.d.ts +34 -0
- package/dist/types/CallingClient/utils/types.d.ts.map +1 -0
- package/dist/types/CallingClient/utils/wsFeatureFlag.d.ts +4 -0
- package/dist/types/CallingClient/utils/wsFeatureFlag.d.ts.map +1 -0
- package/dist/types/Errors/types.d.ts +2 -0
- package/dist/types/Errors/types.d.ts.map +1 -1
- package/dist/types/Events/types.d.ts +80 -6
- package/dist/types/Events/types.d.ts.map +1 -1
- package/dist/types/Metrics/index.d.ts.map +1 -1
- package/dist/types/Metrics/types.d.ts +19 -2
- package/dist/types/Metrics/types.d.ts.map +1 -1
- package/dist/types/SDKConnector/types.d.ts +39 -12
- package/dist/types/SDKConnector/types.d.ts.map +1 -1
- package/dist/types/api.d.ts +6 -4
- package/dist/types/api.d.ts.map +1 -1
- package/dist/types/common/Utils.d.ts +9 -4
- package/dist/types/common/Utils.d.ts.map +1 -1
- package/dist/types/common/testUtil.d.ts +5 -1
- package/dist/types/common/testUtil.d.ts.map +1 -1
- package/dist/types/common/types.d.ts +5 -1
- package/dist/types/common/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +9 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/mobius-socket/config.d.ts +17 -0
- package/dist/types/mobius-socket/config.d.ts.map +1 -0
- package/dist/types/mobius-socket/errors.d.ts +32 -0
- package/dist/types/mobius-socket/errors.d.ts.map +1 -0
- package/dist/types/mobius-socket/index.d.ts +14 -0
- package/dist/types/mobius-socket/index.d.ts.map +1 -0
- package/dist/types/mobius-socket/mobius-socket.d.ts +48 -0
- package/dist/types/mobius-socket/mobius-socket.d.ts.map +1 -0
- package/dist/types/mobius-socket/socket/constants.d.ts +27 -0
- package/dist/types/mobius-socket/socket/constants.d.ts.map +1 -0
- package/dist/types/mobius-socket/socket/index.d.ts +5 -0
- package/dist/types/mobius-socket/socket/index.d.ts.map +1 -0
- package/dist/types/mobius-socket/socket/socket-base.d.ts +43 -0
- package/dist/types/mobius-socket/socket/socket-base.d.ts.map +1 -0
- package/dist/types/mobius-socket/socket/socket.d.ts +6 -0
- package/dist/types/mobius-socket/socket/socket.d.ts.map +1 -0
- package/dist/types/mobius-socket/socket/socket.shim.d.ts +6 -0
- package/dist/types/mobius-socket/socket/socket.shim.d.ts.map +1 -0
- package/dist/types/mobius-socket/socket/types.d.ts +61 -0
- package/dist/types/mobius-socket/socket/types.d.ts.map +1 -0
- package/dist/types/mobius-socket/types.d.ts +21 -0
- package/dist/types/mobius-socket/types.d.ts.map +1 -0
- package/package.json +21 -5
- package/src/mobius-socket/socket/socket.shim.ts +22 -0
- package/src/mobius-socket/socket/socket.ts +14 -0
|
@@ -32,9 +32,17 @@ var _constants = require("../constants");
|
|
|
32
32
|
var _types4 = require("../line/types");
|
|
33
33
|
var _LineError = require("../../Errors/catalog/LineError");
|
|
34
34
|
var _types5 = require("../../Metrics/types");
|
|
35
|
+
var _request = require("../utils/request");
|
|
35
36
|
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); }
|
|
36
37
|
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; }
|
|
37
38
|
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 */
|
|
39
|
+
jest.mock('../../mobius-socket', function () {
|
|
40
|
+
return {
|
|
41
|
+
getMobiusSocketInstance: jest.fn().mockReturnValue({
|
|
42
|
+
sendWssRequest: jest.fn()
|
|
43
|
+
})
|
|
44
|
+
};
|
|
45
|
+
});
|
|
38
46
|
var webex = (0, _testUtil.getTestUtilsWebex)();
|
|
39
47
|
var MockServiceData = {
|
|
40
48
|
indicator: _types.ServiceIndicator.CALLING,
|
|
@@ -137,6 +145,11 @@ describe('Registration Tests', function () {
|
|
|
137
145
|
metricSpy = jest.spyOn(reg.metricManager, 'submitRegistrationMetric');
|
|
138
146
|
};
|
|
139
147
|
beforeEach(function () {
|
|
148
|
+
_request.APIRequest.resetInstance();
|
|
149
|
+
_request.APIRequest.getInstance({
|
|
150
|
+
webex: webex,
|
|
151
|
+
isMobiusSocketEnabled: false
|
|
152
|
+
});
|
|
140
153
|
setupRegistration(MockServiceData);
|
|
141
154
|
});
|
|
142
155
|
afterEach(function () {
|
|
@@ -170,7 +183,7 @@ describe('Registration Tests', function () {
|
|
|
170
183
|
// Check that log.log was called for successful registration
|
|
171
184
|
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({
|
|
172
185
|
file: _constants.REGISTRATION_FILE,
|
|
173
|
-
method:
|
|
186
|
+
method: _constants.REGISTER_UTIL
|
|
174
187
|
}));
|
|
175
188
|
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);
|
|
176
189
|
case 2:
|
|
@@ -218,6 +231,9 @@ describe('Registration Tests', function () {
|
|
|
218
231
|
devices: [_registerFixtures.mockPostResponse.device]
|
|
219
232
|
},
|
|
220
233
|
statusCode: 403
|
|
234
|
+
}).mockResolvedValueOnce({
|
|
235
|
+
statusCode: 200,
|
|
236
|
+
body: _registerFixtures.mockDeleteResponse
|
|
221
237
|
}).mockResolvedValueOnce({
|
|
222
238
|
statusCode: 200,
|
|
223
239
|
body: _registerFixtures.mockPostResponse,
|
|
@@ -225,25 +241,18 @@ describe('Registration Tests', function () {
|
|
|
225
241
|
trackingid: 'webex-js-sdk_06bafdd0-2f9b-4cd7-b438-9c0d95ecec9b_15'
|
|
226
242
|
}
|
|
227
243
|
});
|
|
228
|
-
global.fetch = jest.fn(function () {
|
|
229
|
-
return _promise.default.resolve({
|
|
230
|
-
json: function json() {
|
|
231
|
-
return _registerFixtures.mockDeleteResponse;
|
|
232
|
-
}
|
|
233
|
-
});
|
|
234
|
-
});
|
|
235
244
|
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.IDLE);
|
|
236
245
|
_context3.next = 1;
|
|
237
246
|
return reg.triggerRegistration();
|
|
238
247
|
case 1:
|
|
239
|
-
expect(webex.request).toBeCalledTimes(
|
|
248
|
+
expect(webex.request).toBeCalledTimes(3);
|
|
240
249
|
expect(webex.request).toBeCalledWith(_objectSpread(_objectSpread({}, mockResponse), {}, {
|
|
241
250
|
method: 'POST'
|
|
242
251
|
}));
|
|
243
|
-
expect(
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
});
|
|
252
|
+
expect(webex.request).toBeCalledWith(expect.objectContaining({
|
|
253
|
+
uri: _registerFixtures.mockPostResponse.device.uri,
|
|
254
|
+
method: 'DELETE'
|
|
255
|
+
}));
|
|
247
256
|
expect(warnSpy).toBeCalledWith('User device limit exceeded', expect.anything());
|
|
248
257
|
expect(infoSpy).toBeCalledWith('Registration restoration in progress.', expect.anything());
|
|
249
258
|
expect(infoSpy).toBeCalledWith('Registration restored successfully.', expect.anything());
|
|
@@ -1277,11 +1286,8 @@ describe('Registration Tests', function () {
|
|
|
1277
1286
|
expect(reg.webWorker).toBeDefined();
|
|
1278
1287
|
expect(postMessageSpy).toHaveBeenCalledWith(expect.objectContaining({
|
|
1279
1288
|
type: 'START_KEEPALIVE',
|
|
1280
|
-
accessToken: expect.any(String),
|
|
1281
|
-
deviceUrl: expect.any(String),
|
|
1282
1289
|
interval: expect.any(Number),
|
|
1283
|
-
retryCountThreshold: expect.any(Number)
|
|
1284
|
-
url: expect.any(String)
|
|
1290
|
+
retryCountThreshold: expect.any(Number)
|
|
1285
1291
|
}));
|
|
1286
1292
|
reg.webWorker.onmessage({
|
|
1287
1293
|
data: {
|
|
@@ -1690,7 +1696,7 @@ describe('Registration Tests', function () {
|
|
|
1690
1696
|
})));
|
|
1691
1697
|
it('checks for keep-alive failure with 429', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee35() {
|
|
1692
1698
|
var _reg$deviceInfo$devic;
|
|
1693
|
-
var keepaliveSpy, postMessageSpy, clearTimerSpy, retry429Spy;
|
|
1699
|
+
var keepaliveSpy, postMessageSpy, clearTimerSpy, retry429Spy, keepaliveInterval, retryAfter, adjustedResumeDelayMs;
|
|
1694
1700
|
return _regenerator.default.wrap(function (_context35) {
|
|
1695
1701
|
while (1) switch (_context35.prev = _context35.next) {
|
|
1696
1702
|
case 0:
|
|
@@ -1701,13 +1707,17 @@ describe('Registration Tests', function () {
|
|
|
1701
1707
|
postMessageSpy = jest.spyOn(Worker.prototype, 'postMessage');
|
|
1702
1708
|
clearTimerSpy = jest.spyOn(reg, 'clearKeepaliveTimer');
|
|
1703
1709
|
retry429Spy = jest.spyOn(reg, 'handle429Retry');
|
|
1710
|
+
keepaliveInterval = reg.deviceInfo.keepaliveInterval; // Choose a retryAfter strictly greater than keepaliveInterval so the
|
|
1711
|
+
// adjusted resume delay (retryAfter - keepaliveInterval) is positive and verifiable.
|
|
1712
|
+
retryAfter = keepaliveInterval + 30;
|
|
1713
|
+
adjustedResumeDelayMs = (retryAfter - keepaliveInterval) * _constants.SEC_TO_MSEC_MFACTOR;
|
|
1704
1714
|
reg.webWorker.onmessage({
|
|
1705
1715
|
data: {
|
|
1706
1716
|
type: _types.WorkerMessageType.KEEPALIVE_FAILURE,
|
|
1707
1717
|
err: {
|
|
1708
1718
|
statusCode: 429,
|
|
1709
1719
|
headers: {
|
|
1710
|
-
'retry-after':
|
|
1720
|
+
'retry-after': retryAfter
|
|
1711
1721
|
}
|
|
1712
1722
|
},
|
|
1713
1723
|
keepAliveRetryCount: 1
|
|
@@ -1723,47 +1733,112 @@ describe('Registration Tests', function () {
|
|
|
1723
1733
|
expect(handleErrorSpy).toBeCalledOnceWith({
|
|
1724
1734
|
statusCode: 429,
|
|
1725
1735
|
headers: {
|
|
1726
|
-
'retry-after':
|
|
1736
|
+
'retry-after': retryAfter
|
|
1727
1737
|
}
|
|
1728
1738
|
}, expect.anything(), {
|
|
1729
1739
|
file: _constants.REGISTRATION_FILE,
|
|
1730
1740
|
method: _constants.KEEPALIVE_UTIL
|
|
1731
1741
|
}, expect.anything());
|
|
1732
|
-
expect(retry429Spy).toBeCalledOnceWith(
|
|
1742
|
+
expect(retry429Spy).toBeCalledOnceWith(retryAfter, 'startKeepaliveTimer');
|
|
1733
1743
|
expect(clearTimerSpy).toBeCalledTimes(1);
|
|
1734
1744
|
expect(reg.reconnectPending).toStrictEqual(false);
|
|
1735
1745
|
expect(reg.keepaliveTimer).toBe(undefined);
|
|
1736
1746
|
expect(reg.webWorker).toBeUndefined();
|
|
1737
|
-
|
|
1747
|
+
|
|
1748
|
+
// Resume timer must NOT fire before the adjusted (retryAfter - keepaliveInterval) interval.
|
|
1749
|
+
jest.advanceTimersByTime(adjustedResumeDelayMs - 1);
|
|
1738
1750
|
_context35.next = 3;
|
|
1739
1751
|
return flushPromises();
|
|
1740
1752
|
case 3:
|
|
1741
|
-
expect(keepaliveSpy).
|
|
1742
|
-
expect(
|
|
1753
|
+
expect(keepaliveSpy).not.toBeCalled();
|
|
1754
|
+
expect(reg.webWorker).toBeUndefined();
|
|
1755
|
+
|
|
1756
|
+
// Advance the remaining 1ms to hit the exact adjusted timeout; keepalive must resume now.
|
|
1757
|
+
jest.advanceTimersByTime(1);
|
|
1758
|
+
_context35.next = 4;
|
|
1759
|
+
return flushPromises();
|
|
1760
|
+
case 4:
|
|
1761
|
+
expect(keepaliveSpy).toBeCalledOnceWith((_reg$deviceInfo$devic = reg.deviceInfo.device) === null || _reg$deviceInfo$devic === void 0 ? void 0 : _reg$deviceInfo$devic.uri, keepaliveInterval, 'UNKNOWN');
|
|
1762
|
+
expect(logSpy).toBeCalledWith("Resuming keepalive after ".concat(retryAfter, " seconds"), {
|
|
1743
1763
|
file: _constants.REGISTRATION_FILE,
|
|
1744
1764
|
method: 'handle429Retry'
|
|
1745
1765
|
});
|
|
1746
1766
|
expect(reg.webWorker).toBeDefined();
|
|
1747
1767
|
expect(postMessageSpy).toHaveBeenCalledWith(expect.objectContaining({
|
|
1748
1768
|
type: 'START_KEEPALIVE',
|
|
1749
|
-
accessToken: expect.any(String),
|
|
1750
|
-
deviceUrl: expect.any(String),
|
|
1751
1769
|
interval: expect.any(Number),
|
|
1752
|
-
retryCountThreshold: expect.any(Number)
|
|
1753
|
-
url: expect.any(String)
|
|
1770
|
+
retryCountThreshold: expect.any(Number)
|
|
1754
1771
|
}));
|
|
1755
|
-
case
|
|
1772
|
+
case 5:
|
|
1756
1773
|
case "end":
|
|
1757
1774
|
return _context35.stop();
|
|
1758
1775
|
}
|
|
1759
1776
|
}, _callee35);
|
|
1760
1777
|
})));
|
|
1761
|
-
it
|
|
1778
|
+
it.each([{
|
|
1779
|
+
description: 'retryAfter less than keepaliveInterval -> negative delay fires immediately',
|
|
1780
|
+
retryAfterDelta: -10
|
|
1781
|
+
}, {
|
|
1782
|
+
description: 'retryAfter equal to keepaliveInterval -> zero delay fires immediately',
|
|
1783
|
+
retryAfterDelta: 0
|
|
1784
|
+
}])('adjusts retry-after with keepaliveInterval on 429 keepalive failure ($description)', /*#__PURE__*/function () {
|
|
1785
|
+
var _ref37 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee36(_ref36) {
|
|
1786
|
+
var _reg$deviceInfo$devic2;
|
|
1787
|
+
var retryAfterDelta, keepaliveSpy, keepaliveInterval, retryAfter;
|
|
1788
|
+
return _regenerator.default.wrap(function (_context36) {
|
|
1789
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
1790
|
+
case 0:
|
|
1791
|
+
retryAfterDelta = _ref36.retryAfterDelta;
|
|
1792
|
+
_context36.next = 1;
|
|
1793
|
+
return beforeEachSetupForKeepalive();
|
|
1794
|
+
case 1:
|
|
1795
|
+
keepaliveSpy = jest.spyOn(reg, 'startKeepaliveTimer');
|
|
1796
|
+
keepaliveInterval = reg.deviceInfo.keepaliveInterval;
|
|
1797
|
+
retryAfter = keepaliveInterval + retryAfterDelta;
|
|
1798
|
+
reg.webWorker.onmessage({
|
|
1799
|
+
data: {
|
|
1800
|
+
type: _types.WorkerMessageType.KEEPALIVE_FAILURE,
|
|
1801
|
+
err: {
|
|
1802
|
+
statusCode: 429,
|
|
1803
|
+
headers: {
|
|
1804
|
+
'retry-after': retryAfter
|
|
1805
|
+
}
|
|
1806
|
+
},
|
|
1807
|
+
keepAliveRetryCount: 1
|
|
1808
|
+
}
|
|
1809
|
+
});
|
|
1810
|
+
_context36.next = 2;
|
|
1811
|
+
return flushPromises();
|
|
1812
|
+
case 2:
|
|
1813
|
+
expect(reg.webWorker).toBeUndefined();
|
|
1814
|
+
expect(keepaliveSpy).not.toBeCalled();
|
|
1815
|
+
|
|
1816
|
+
// With a non-positive adjusted delay, the timer should fire on the next tick.
|
|
1817
|
+
jest.advanceTimersByTime(0);
|
|
1818
|
+
_context36.next = 3;
|
|
1819
|
+
return flushPromises();
|
|
1820
|
+
case 3:
|
|
1821
|
+
expect(keepaliveSpy).toBeCalledOnceWith((_reg$deviceInfo$devic2 = reg.deviceInfo.device) === null || _reg$deviceInfo$devic2 === void 0 ? void 0 : _reg$deviceInfo$devic2.uri, keepaliveInterval, 'UNKNOWN');
|
|
1822
|
+
expect(logSpy).toBeCalledWith("Resuming keepalive after ".concat(retryAfter, " seconds"), {
|
|
1823
|
+
file: _constants.REGISTRATION_FILE,
|
|
1824
|
+
method: 'handle429Retry'
|
|
1825
|
+
});
|
|
1826
|
+
case 4:
|
|
1827
|
+
case "end":
|
|
1828
|
+
return _context36.stop();
|
|
1829
|
+
}
|
|
1830
|
+
}, _callee36);
|
|
1831
|
+
}));
|
|
1832
|
+
return function (_x) {
|
|
1833
|
+
return _ref37.apply(this, arguments);
|
|
1834
|
+
};
|
|
1835
|
+
}());
|
|
1836
|
+
it('ensure retryAfter is set when 429 occurs during failover retry', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee37() {
|
|
1762
1837
|
var retry429Spy;
|
|
1763
|
-
return _regenerator.default.wrap(function (
|
|
1764
|
-
while (1) switch (
|
|
1838
|
+
return _regenerator.default.wrap(function (_context37) {
|
|
1839
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
1765
1840
|
case 0:
|
|
1766
|
-
|
|
1841
|
+
_context37.next = 1;
|
|
1767
1842
|
return beforeEachSetupForKeepalive();
|
|
1768
1843
|
case 1:
|
|
1769
1844
|
// Simulate loss of registration so failover path attempts a new registration
|
|
@@ -1774,11 +1849,11 @@ describe('Registration Tests', function () {
|
|
|
1774
1849
|
webex.request.mockRejectedValueOnce(failurePayload429One);
|
|
1775
1850
|
|
|
1776
1851
|
// Directly schedule the failover attempt
|
|
1777
|
-
|
|
1852
|
+
_context37.next = 2;
|
|
1778
1853
|
return reg.startFailoverTimer();
|
|
1779
1854
|
case 2:
|
|
1780
1855
|
jest.advanceTimersByTime(33 * _constants.SEC_TO_MSEC_MFACTOR);
|
|
1781
|
-
|
|
1856
|
+
_context37.next = 3;
|
|
1782
1857
|
return flushPromises();
|
|
1783
1858
|
case 3:
|
|
1784
1859
|
expect(retry429Spy).toBeCalledWith(failurePayload429One.headers['retry-after'], 'startFailoverTimer');
|
|
@@ -1786,16 +1861,16 @@ describe('Registration Tests', function () {
|
|
|
1786
1861
|
jest.useRealTimers();
|
|
1787
1862
|
case 4:
|
|
1788
1863
|
case "end":
|
|
1789
|
-
return
|
|
1864
|
+
return _context37.stop();
|
|
1790
1865
|
}
|
|
1791
|
-
},
|
|
1866
|
+
}, _callee37);
|
|
1792
1867
|
})));
|
|
1793
|
-
it('sets retryAfter when reconnectOnFailure caller receives 429 after keepalive threshold miss', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
1868
|
+
it('sets retryAfter when reconnectOnFailure caller receives 429 after keepalive threshold miss', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee38() {
|
|
1794
1869
|
var retry429Spy, threshold;
|
|
1795
|
-
return _regenerator.default.wrap(function (
|
|
1796
|
-
while (1) switch (
|
|
1870
|
+
return _regenerator.default.wrap(function (_context38) {
|
|
1871
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
1797
1872
|
case 0:
|
|
1798
|
-
|
|
1873
|
+
_context38.next = 1;
|
|
1799
1874
|
return beforeEachSetupForKeepalive();
|
|
1800
1875
|
case 1:
|
|
1801
1876
|
retry429Spy = jest.spyOn(reg, 'handle429Retry'); // On reconnectOnFailure(RECONNECT_ON_FAILURE_UTIL) first restore attempt, make registration respond with 429 (retry-after: 20)
|
|
@@ -1818,7 +1893,7 @@ describe('Registration Tests', function () {
|
|
|
1818
1893
|
keepAliveRetryCount: threshold
|
|
1819
1894
|
}
|
|
1820
1895
|
});
|
|
1821
|
-
|
|
1896
|
+
_context38.next = 2;
|
|
1822
1897
|
return flushPromises();
|
|
1823
1898
|
case 2:
|
|
1824
1899
|
// handle429Retry is called with caller 'reconnectOnFailure' → else branch executes and sets retryAfter
|
|
@@ -1826,25 +1901,293 @@ describe('Registration Tests', function () {
|
|
|
1826
1901
|
expect(reg.retryAfter).toEqual(undefined); // Clear retryAfter after 429 retry
|
|
1827
1902
|
case 3:
|
|
1828
1903
|
case "end":
|
|
1829
|
-
return
|
|
1904
|
+
return _context38.stop();
|
|
1830
1905
|
}
|
|
1831
|
-
},
|
|
1906
|
+
}, _callee38);
|
|
1832
1907
|
})));
|
|
1908
|
+
describe('409 Conflict on keepalive (session superseded)', function () {
|
|
1909
|
+
var conflictError = {
|
|
1910
|
+
statusCode: 409,
|
|
1911
|
+
headers: {
|
|
1912
|
+
trackingid: 'tid-409'
|
|
1913
|
+
}
|
|
1914
|
+
};
|
|
1915
|
+
var sendKeepaliveFailure = /*#__PURE__*/function () {
|
|
1916
|
+
var _ref40 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee39(err, keepAliveRetryCount) {
|
|
1917
|
+
return _regenerator.default.wrap(function (_context39) {
|
|
1918
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
1919
|
+
case 0:
|
|
1920
|
+
reg.webWorker.onmessage({
|
|
1921
|
+
data: {
|
|
1922
|
+
type: _types.WorkerMessageType.KEEPALIVE_FAILURE,
|
|
1923
|
+
err: err,
|
|
1924
|
+
keepAliveRetryCount: keepAliveRetryCount
|
|
1925
|
+
}
|
|
1926
|
+
});
|
|
1927
|
+
_context39.next = 1;
|
|
1928
|
+
return flushPromises();
|
|
1929
|
+
case 1:
|
|
1930
|
+
case "end":
|
|
1931
|
+
return _context39.stop();
|
|
1932
|
+
}
|
|
1933
|
+
}, _callee39);
|
|
1934
|
+
}));
|
|
1935
|
+
return function sendKeepaliveFailure(_x2, _x3) {
|
|
1936
|
+
return _ref40.apply(this, arguments);
|
|
1937
|
+
};
|
|
1938
|
+
}();
|
|
1939
|
+
var getSupersededError = function getSupersededError() {
|
|
1940
|
+
var unregisteredCall = lineEmitter.mock.calls.find(function (_ref41) {
|
|
1941
|
+
var _ref42 = (0, _slicedToArray2.default)(_ref41, 1),
|
|
1942
|
+
event = _ref42[0];
|
|
1943
|
+
return event === _types4.LINE_EVENTS.UNREGISTERED;
|
|
1944
|
+
});
|
|
1945
|
+
return unregisteredCall === null || unregisteredCall === void 0 ? void 0 : unregisteredCall[2];
|
|
1946
|
+
};
|
|
1947
|
+
it.each([{
|
|
1948
|
+
description: 'on the very first keepalive failure',
|
|
1949
|
+
keepAliveRetryCount: 1
|
|
1950
|
+
}, {
|
|
1951
|
+
description: 'when the retry count already reached the threshold',
|
|
1952
|
+
keepAliveRetryCount: 5
|
|
1953
|
+
}])('stops keepalive without re-registration $description', /*#__PURE__*/function () {
|
|
1954
|
+
var _ref44 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee40(_ref43) {
|
|
1955
|
+
var keepAliveRetryCount, clearTimerSpy, reconnectSpy, registerSpy, handle404Spy;
|
|
1956
|
+
return _regenerator.default.wrap(function (_context40) {
|
|
1957
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
1958
|
+
case 0:
|
|
1959
|
+
keepAliveRetryCount = _ref43.keepAliveRetryCount;
|
|
1960
|
+
_context40.next = 1;
|
|
1961
|
+
return beforeEachSetupForKeepalive();
|
|
1962
|
+
case 1:
|
|
1963
|
+
clearTimerSpy = jest.spyOn(reg, 'clearKeepaliveTimer');
|
|
1964
|
+
reconnectSpy = jest.spyOn(reg, 'reconnectOnFailure');
|
|
1965
|
+
registerSpy = jest.spyOn(reg, 'attemptRegistrationWithServers');
|
|
1966
|
+
handle404Spy = jest.spyOn(reg, 'handle404KeepaliveFailure');
|
|
1967
|
+
lineEmitter.mockClear();
|
|
1968
|
+
_context40.next = 2;
|
|
1969
|
+
return sendKeepaliveFailure(conflictError, keepAliveRetryCount);
|
|
1970
|
+
case 2:
|
|
1971
|
+
// The 409 is classified by the common registration error handler.
|
|
1972
|
+
expect(handleErrorSpy).toHaveBeenCalledWith(conflictError, expect.anything(), {
|
|
1973
|
+
file: _constants.REGISTRATION_FILE,
|
|
1974
|
+
method: _constants.KEEPALIVE_UTIL
|
|
1975
|
+
}, expect.objectContaining({
|
|
1976
|
+
sessionSupersededCb: expect.any(Function)
|
|
1977
|
+
}));
|
|
1978
|
+
expect(warnSpy).toBeCalledWith('409 Conflict: session superseded by another device for this user', {
|
|
1979
|
+
file: _constants.REGISTRATION_FILE,
|
|
1980
|
+
method: _constants.KEEPALIVE_UTIL
|
|
1981
|
+
});
|
|
1982
|
+
expect(warnSpy).toBeCalledWith("Stopping keepalive without re-registration, session superseded by another device for this user - keepaliveRetryCount: ".concat(keepAliveRetryCount), {
|
|
1983
|
+
file: _constants.REGISTRATION_FILE,
|
|
1984
|
+
method: _constants.METHODS.HANDLE_409_KEEPALIVE_FAILURE
|
|
1985
|
+
});
|
|
1986
|
+
|
|
1987
|
+
// Keepalive is stopped and no further keepalive can be sent.
|
|
1988
|
+
expect(clearTimerSpy).toHaveBeenCalled();
|
|
1989
|
+
expect(reg.webWorker).toBeUndefined();
|
|
1990
|
+
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
|
|
1991
|
+
expect(reg.failbackTimer).toStrictEqual(undefined);
|
|
1992
|
+
|
|
1993
|
+
// No re-registration of any kind is attempted.
|
|
1994
|
+
expect(reconnectSpy).not.toHaveBeenCalled();
|
|
1995
|
+
expect(restoreSpy).not.toHaveBeenCalled();
|
|
1996
|
+
expect(restartSpy).not.toHaveBeenCalled();
|
|
1997
|
+
expect(failoverSpy).not.toHaveBeenCalled();
|
|
1998
|
+
expect(registerSpy).not.toHaveBeenCalled();
|
|
1999
|
+
expect(handle404Spy).not.toHaveBeenCalled();
|
|
2000
|
+
expect(reg.reconnectPending).toStrictEqual(false);
|
|
2001
|
+
case 3:
|
|
2002
|
+
case "end":
|
|
2003
|
+
return _context40.stop();
|
|
2004
|
+
}
|
|
2005
|
+
}, _callee40);
|
|
2006
|
+
}));
|
|
2007
|
+
return function (_x4) {
|
|
2008
|
+
return _ref44.apply(this, arguments);
|
|
2009
|
+
};
|
|
2010
|
+
}());
|
|
2011
|
+
it('notifies the consumer with a single UNREGISTERED carrying the superseded reason', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee41() {
|
|
2012
|
+
var supersededError;
|
|
2013
|
+
return _regenerator.default.wrap(function (_context41) {
|
|
2014
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
2015
|
+
case 0:
|
|
2016
|
+
_context41.next = 1;
|
|
2017
|
+
return beforeEachSetupForKeepalive();
|
|
2018
|
+
case 1:
|
|
2019
|
+
lineEmitter.mockClear();
|
|
2020
|
+
_context41.next = 2;
|
|
2021
|
+
return sendKeepaliveFailure(conflictError, 1);
|
|
2022
|
+
case 2:
|
|
2023
|
+
expect(lineEmitter.mock.calls.filter(function (_ref46) {
|
|
2024
|
+
var _ref47 = (0, _slicedToArray2.default)(_ref46, 1),
|
|
2025
|
+
event = _ref47[0];
|
|
2026
|
+
return event === _types4.LINE_EVENTS.UNREGISTERED;
|
|
2027
|
+
})).toHaveLength(1);
|
|
2028
|
+
expect(lineEmitter).not.toHaveBeenCalledWith(_types4.LINE_EVENTS.RECONNECTING);
|
|
2029
|
+
expect(lineEmitter).toHaveBeenLastCalledWith(_types4.LINE_EVENTS.UNREGISTERED, undefined, expect.any(_LineError.LineError));
|
|
2030
|
+
supersededError = getSupersededError();
|
|
2031
|
+
expect(supersededError.getError()).toStrictEqual({
|
|
2032
|
+
message: _constants.SESSION_SUPERSEDED_MESSAGE,
|
|
2033
|
+
type: _types3.ERROR_TYPE.SESSION_SUPERSEDED,
|
|
2034
|
+
status: _types.RegistrationStatus.INACTIVE,
|
|
2035
|
+
context: {
|
|
2036
|
+
file: _constants.REGISTRATION_FILE,
|
|
2037
|
+
method: _constants.KEEPALIVE_UTIL
|
|
2038
|
+
}
|
|
2039
|
+
});
|
|
2040
|
+
case 3:
|
|
2041
|
+
case "end":
|
|
2042
|
+
return _context41.stop();
|
|
2043
|
+
}
|
|
2044
|
+
}, _callee41);
|
|
2045
|
+
})));
|
|
2046
|
+
it('submits the keepalive failure metric and uploads logs', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee42() {
|
|
2047
|
+
var uploadLogsSpy;
|
|
2048
|
+
return _regenerator.default.wrap(function (_context42) {
|
|
2049
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
2050
|
+
case 0:
|
|
2051
|
+
_context42.next = 1;
|
|
2052
|
+
return beforeEachSetupForKeepalive();
|
|
2053
|
+
case 1:
|
|
2054
|
+
uploadLogsSpy = jest.spyOn(utils, 'uploadLogs');
|
|
2055
|
+
lineEmitter.mockClear();
|
|
2056
|
+
metricSpy.mockClear();
|
|
2057
|
+
_context42.next = 2;
|
|
2058
|
+
return sendKeepaliveFailure(conflictError, 2);
|
|
2059
|
+
case 2:
|
|
2060
|
+
expect(metricSpy).toBeCalledOnceWith(_types5.METRIC_EVENT.KEEPALIVE_ERROR, _types5.REG_ACTION.KEEPALIVE_FAILURE, _types5.METRIC_TYPE.BEHAVIORAL, _constants.METHODS.HANDLE_409_KEEPALIVE_FAILURE, 'PRIMARY', conflictError.headers.trackingid, 2, getSupersededError());
|
|
2061
|
+
expect(uploadLogsSpy).toHaveBeenCalled();
|
|
2062
|
+
case 3:
|
|
2063
|
+
case "end":
|
|
2064
|
+
return _context42.stop();
|
|
2065
|
+
}
|
|
2066
|
+
}, _callee42);
|
|
2067
|
+
})));
|
|
2068
|
+
it('closes the Mobius WebSocket when the socket transport is enabled', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee43() {
|
|
2069
|
+
var apiRequest, disconnectSocketSpy;
|
|
2070
|
+
return _regenerator.default.wrap(function (_context43) {
|
|
2071
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
2072
|
+
case 0:
|
|
2073
|
+
_context43.next = 1;
|
|
2074
|
+
return beforeEachSetupForKeepalive();
|
|
2075
|
+
case 1:
|
|
2076
|
+
apiRequest = _request.APIRequest.getInstance({
|
|
2077
|
+
webex: webex
|
|
2078
|
+
});
|
|
2079
|
+
jest.spyOn(apiRequest, 'isSocketEnabled').mockReturnValue(true);
|
|
2080
|
+
disconnectSocketSpy = jest.spyOn(apiRequest, 'disconnectFromMobiusSocket').mockResolvedValue();
|
|
2081
|
+
lineEmitter.mockClear();
|
|
2082
|
+
_context43.next = 2;
|
|
2083
|
+
return sendKeepaliveFailure(conflictError, 1);
|
|
2084
|
+
case 2:
|
|
2085
|
+
expect(disconnectSocketSpy).toBeCalledOnceWith({
|
|
2086
|
+
code: 3050,
|
|
2087
|
+
reason: 'done (permanent)'
|
|
2088
|
+
});
|
|
2089
|
+
expect(lineEmitter).toHaveBeenLastCalledWith(_types4.LINE_EVENTS.UNREGISTERED, undefined, expect.any(_LineError.LineError));
|
|
2090
|
+
case 3:
|
|
2091
|
+
case "end":
|
|
2092
|
+
return _context43.stop();
|
|
2093
|
+
}
|
|
2094
|
+
}, _callee43);
|
|
2095
|
+
})));
|
|
2096
|
+
it('still notifies the consumer when the Mobius WebSocket teardown fails', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee44() {
|
|
2097
|
+
var apiRequest;
|
|
2098
|
+
return _regenerator.default.wrap(function (_context44) {
|
|
2099
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
2100
|
+
case 0:
|
|
2101
|
+
_context44.next = 1;
|
|
2102
|
+
return beforeEachSetupForKeepalive();
|
|
2103
|
+
case 1:
|
|
2104
|
+
apiRequest = _request.APIRequest.getInstance({
|
|
2105
|
+
webex: webex
|
|
2106
|
+
});
|
|
2107
|
+
jest.spyOn(apiRequest, 'isSocketEnabled').mockReturnValue(true);
|
|
2108
|
+
jest.spyOn(apiRequest, 'disconnectFromMobiusSocket').mockRejectedValue(new Error('socket teardown failed'));
|
|
2109
|
+
lineEmitter.mockClear();
|
|
2110
|
+
_context44.next = 2;
|
|
2111
|
+
return sendKeepaliveFailure(conflictError, 1);
|
|
2112
|
+
case 2:
|
|
2113
|
+
expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining('Mobius socket disconnect failed after session-superseded'), {
|
|
2114
|
+
file: _constants.REGISTRATION_FILE,
|
|
2115
|
+
method: _constants.METHODS.HANDLE_409_KEEPALIVE_FAILURE
|
|
2116
|
+
});
|
|
2117
|
+
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
|
|
2118
|
+
expect(lineEmitter).toHaveBeenLastCalledWith(_types4.LINE_EVENTS.UNREGISTERED, undefined, expect.any(_LineError.LineError));
|
|
2119
|
+
case 3:
|
|
2120
|
+
case "end":
|
|
2121
|
+
return _context44.stop();
|
|
2122
|
+
}
|
|
2123
|
+
}, _callee44);
|
|
2124
|
+
})));
|
|
2125
|
+
it.each([{
|
|
2126
|
+
description: '404 device not found',
|
|
2127
|
+
err: {
|
|
2128
|
+
statusCode: 404
|
|
2129
|
+
}
|
|
2130
|
+
}, {
|
|
2131
|
+
description: '429 too many requests',
|
|
2132
|
+
err: {
|
|
2133
|
+
statusCode: 429,
|
|
2134
|
+
headers: {
|
|
2135
|
+
'retry-after': 5
|
|
2136
|
+
}
|
|
2137
|
+
}
|
|
2138
|
+
}, {
|
|
2139
|
+
description: '503 service unavailable',
|
|
2140
|
+
err: {
|
|
2141
|
+
statusCode: 503
|
|
2142
|
+
}
|
|
2143
|
+
}])('leaves the existing handling of $description untouched', /*#__PURE__*/function () {
|
|
2144
|
+
var _ref52 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee45(_ref51) {
|
|
2145
|
+
var err, handle409Spy;
|
|
2146
|
+
return _regenerator.default.wrap(function (_context45) {
|
|
2147
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
2148
|
+
case 0:
|
|
2149
|
+
err = _ref51.err;
|
|
2150
|
+
_context45.next = 1;
|
|
2151
|
+
return beforeEachSetupForKeepalive();
|
|
2152
|
+
case 1:
|
|
2153
|
+
handle409Spy = jest.spyOn(reg, 'handle409KeepaliveFailure');
|
|
2154
|
+
lineEmitter.mockClear();
|
|
2155
|
+
handleErrorSpy.mockClear();
|
|
2156
|
+
_context45.next = 2;
|
|
2157
|
+
return sendKeepaliveFailure(err, 1);
|
|
2158
|
+
case 2:
|
|
2159
|
+
expect(handle409Spy).not.toHaveBeenCalled();
|
|
2160
|
+
expect(handleErrorSpy).toHaveBeenCalledWith(err, expect.anything(), {
|
|
2161
|
+
file: _constants.REGISTRATION_FILE,
|
|
2162
|
+
method: _constants.KEEPALIVE_UTIL
|
|
2163
|
+
}, expect.anything());
|
|
2164
|
+
expect(lineEmitter).not.toHaveBeenCalledWith(_types4.LINE_EVENTS.UNREGISTERED, undefined, expect.anything());
|
|
2165
|
+
case 3:
|
|
2166
|
+
case "end":
|
|
2167
|
+
return _context45.stop();
|
|
2168
|
+
}
|
|
2169
|
+
}, _callee45);
|
|
2170
|
+
}));
|
|
2171
|
+
return function (_x5) {
|
|
2172
|
+
return _ref52.apply(this, arguments);
|
|
2173
|
+
};
|
|
2174
|
+
}());
|
|
2175
|
+
});
|
|
1833
2176
|
});
|
|
1834
2177
|
describe('Primary server status checks', function () {
|
|
1835
|
-
it('success: primary server status to be up', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
2178
|
+
it('success: primary server status to be up', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee46() {
|
|
1836
2179
|
var pingSuccessPayload, status;
|
|
1837
|
-
return _regenerator.default.wrap(function (
|
|
1838
|
-
while (1) switch (
|
|
2180
|
+
return _regenerator.default.wrap(function (_context46) {
|
|
2181
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
1839
2182
|
case 0:
|
|
1840
2183
|
pingSuccessPayload = {
|
|
1841
2184
|
statusCode: 200
|
|
1842
2185
|
};
|
|
1843
2186
|
webex.request.mockResolvedValue(pingSuccessPayload);
|
|
1844
|
-
|
|
2187
|
+
_context46.next = 1;
|
|
1845
2188
|
return reg.isPrimaryActive();
|
|
1846
2189
|
case 1:
|
|
1847
|
-
status =
|
|
2190
|
+
status = _context46.sent;
|
|
1848
2191
|
expect(webex.request).toBeCalledWith(_objectSpread({
|
|
1849
2192
|
method: 'GET',
|
|
1850
2193
|
uri: "https://mobius-dfw.webex.com/api/v1/ping"
|
|
@@ -1852,23 +2195,23 @@ describe('Registration Tests', function () {
|
|
|
1852
2195
|
expect(status).toEqual(true);
|
|
1853
2196
|
case 2:
|
|
1854
2197
|
case "end":
|
|
1855
|
-
return
|
|
2198
|
+
return _context46.stop();
|
|
1856
2199
|
}
|
|
1857
|
-
},
|
|
2200
|
+
}, _callee46);
|
|
1858
2201
|
})));
|
|
1859
|
-
it('failed: primary server status to be down', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
2202
|
+
it('failed: primary server status to be down', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee47() {
|
|
1860
2203
|
var pingFailurePayload, status;
|
|
1861
|
-
return _regenerator.default.wrap(function (
|
|
1862
|
-
while (1) switch (
|
|
2204
|
+
return _regenerator.default.wrap(function (_context47) {
|
|
2205
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
1863
2206
|
case 0:
|
|
1864
2207
|
pingFailurePayload = {
|
|
1865
2208
|
statusCode: 500
|
|
1866
2209
|
};
|
|
1867
2210
|
webex.request.mockResolvedValue(pingFailurePayload);
|
|
1868
|
-
|
|
2211
|
+
_context47.next = 1;
|
|
1869
2212
|
return reg.isPrimaryActive();
|
|
1870
2213
|
case 1:
|
|
1871
|
-
status =
|
|
2214
|
+
status = _context47.sent;
|
|
1872
2215
|
expect(webex.request).toBeCalledWith(_objectSpread({
|
|
1873
2216
|
method: 'GET',
|
|
1874
2217
|
uri: "https://mobius-dfw.webex.com/api/v1/ping"
|
|
@@ -1876,9 +2219,257 @@ describe('Registration Tests', function () {
|
|
|
1876
2219
|
expect(status).toEqual(false);
|
|
1877
2220
|
case 2:
|
|
1878
2221
|
case "end":
|
|
1879
|
-
return
|
|
2222
|
+
return _context47.stop();
|
|
2223
|
+
}
|
|
2224
|
+
}, _callee47);
|
|
2225
|
+
})));
|
|
2226
|
+
});
|
|
2227
|
+
describe('handleRegistrationDownEvent tests', function () {
|
|
2228
|
+
var registrationDownEvent = {
|
|
2229
|
+
type: 'async_event',
|
|
2230
|
+
eventId: 'evt-1',
|
|
2231
|
+
trackingId: 'tid-1',
|
|
2232
|
+
data: {
|
|
2233
|
+
eventType: 'registration.down',
|
|
2234
|
+
deviceInfo: {
|
|
2235
|
+
userId: 'u1',
|
|
2236
|
+
device: {
|
|
2237
|
+
deviceId: 'd1',
|
|
2238
|
+
uri: 'https://mobius/device/d1',
|
|
2239
|
+
status: 'ACTIVE'
|
|
2240
|
+
}
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2243
|
+
};
|
|
2244
|
+
beforeEach(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee48() {
|
|
2245
|
+
return _regenerator.default.wrap(function (_context48) {
|
|
2246
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
2247
|
+
case 0:
|
|
2248
|
+
postRegistrationSpy.mockResolvedValueOnce(successPayload);
|
|
2249
|
+
_context48.next = 1;
|
|
2250
|
+
return reg.triggerRegistration();
|
|
2251
|
+
case 1:
|
|
2252
|
+
expect(reg.getStatus()).toBe(_types.RegistrationStatus.ACTIVE);
|
|
2253
|
+
case 2:
|
|
2254
|
+
case "end":
|
|
2255
|
+
return _context48.stop();
|
|
2256
|
+
}
|
|
2257
|
+
}, _callee48);
|
|
2258
|
+
})));
|
|
2259
|
+
afterEach(function () {
|
|
2260
|
+
var calls = (0, _values.default)(reg.callManager.getActiveCalls());
|
|
2261
|
+
calls.forEach(function (call) {
|
|
2262
|
+
call.end();
|
|
2263
|
+
});
|
|
2264
|
+
reg.callManager.callCollection = {};
|
|
2265
|
+
});
|
|
2266
|
+
it('runs cleanup immediately when no active calls are present (socket disabled)', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee49() {
|
|
2267
|
+
var clearKeepaliveSpy, setStatusSpy, disconnectSocketSpy;
|
|
2268
|
+
return _regenerator.default.wrap(function (_context49) {
|
|
2269
|
+
while (1) switch (_context49.prev = _context49.next) {
|
|
2270
|
+
case 0:
|
|
2271
|
+
clearKeepaliveSpy = jest.spyOn(reg, 'clearKeepaliveTimer');
|
|
2272
|
+
setStatusSpy = jest.spyOn(reg, 'setStatus');
|
|
2273
|
+
disconnectSocketSpy = jest.spyOn(_request.APIRequest.getInstance({
|
|
2274
|
+
webex: webex
|
|
2275
|
+
}), 'disconnectFromMobiusSocket');
|
|
2276
|
+
lineEmitter.mockClear();
|
|
2277
|
+
expect((0, _keys.default)(reg.callManager.getActiveCalls()).length).toBe(0);
|
|
2278
|
+
_context49.next = 1;
|
|
2279
|
+
return reg.handleRegistrationDownEvent(registrationDownEvent);
|
|
2280
|
+
case 1:
|
|
2281
|
+
expect(clearKeepaliveSpy).toHaveBeenCalled();
|
|
2282
|
+
expect(setStatusSpy).toHaveBeenCalledWith(_types.RegistrationStatus.INACTIVE);
|
|
2283
|
+
expect(reg.getStatus()).toBe(_types.RegistrationStatus.INACTIVE);
|
|
2284
|
+
expect(reg.reconnectPending).toBe(false);
|
|
2285
|
+
expect(reg.scheduled429Retry).toBe(false);
|
|
2286
|
+
expect(reg.failoverImmediately).toBe(false);
|
|
2287
|
+
expect(reg.retryAfter).toBeUndefined();
|
|
2288
|
+
expect(reg.registerRetry).toBe(false);
|
|
2289
|
+
expect(disconnectSocketSpy).not.toHaveBeenCalled();
|
|
2290
|
+
/* A registration-down stop has no reason to report to the consumer. */
|
|
2291
|
+
expect(lineEmitter).toHaveBeenCalledWith(_types4.LINE_EVENTS.UNREGISTERED, undefined, undefined);
|
|
2292
|
+
case 2:
|
|
2293
|
+
case "end":
|
|
2294
|
+
return _context49.stop();
|
|
2295
|
+
}
|
|
2296
|
+
}, _callee49);
|
|
2297
|
+
})));
|
|
2298
|
+
it('ends the active call and still runs cleanup when an active call is present', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee50() {
|
|
2299
|
+
var clearKeepaliveSpy, setStatusSpy, activeCall, endSpy;
|
|
2300
|
+
return _regenerator.default.wrap(function (_context50) {
|
|
2301
|
+
while (1) switch (_context50.prev = _context50.next) {
|
|
2302
|
+
case 0:
|
|
2303
|
+
clearKeepaliveSpy = jest.spyOn(reg, 'clearKeepaliveTimer');
|
|
2304
|
+
setStatusSpy = jest.spyOn(reg, 'setStatus');
|
|
2305
|
+
activeCall = reg.callManager.createCall();
|
|
2306
|
+
endSpy = jest.spyOn(activeCall, 'end');
|
|
2307
|
+
expect((0, _keys.default)(reg.callManager.getActiveCalls()).length).toBe(1);
|
|
2308
|
+
lineEmitter.mockClear();
|
|
2309
|
+
_context50.next = 1;
|
|
2310
|
+
return reg.handleRegistrationDownEvent(registrationDownEvent);
|
|
2311
|
+
case 1:
|
|
2312
|
+
expect(endSpy).toHaveBeenCalledTimes(1);
|
|
2313
|
+
expect(clearKeepaliveSpy).toHaveBeenCalled();
|
|
2314
|
+
expect(setStatusSpy).toHaveBeenCalledWith(_types.RegistrationStatus.INACTIVE);
|
|
2315
|
+
expect(reg.getStatus()).toBe(_types.RegistrationStatus.INACTIVE);
|
|
2316
|
+
expect(lineEmitter).toHaveBeenCalledWith(_types4.LINE_EVENTS.UNREGISTERED, undefined, undefined);
|
|
2317
|
+
case 2:
|
|
2318
|
+
case "end":
|
|
2319
|
+
return _context50.stop();
|
|
2320
|
+
}
|
|
2321
|
+
}, _callee50);
|
|
2322
|
+
})));
|
|
2323
|
+
it('runs cleanup without calling end when no active call is present on re-invocation', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee51() {
|
|
2324
|
+
var clearKeepaliveSpy, setStatusSpy;
|
|
2325
|
+
return _regenerator.default.wrap(function (_context51) {
|
|
2326
|
+
while (1) switch (_context51.prev = _context51.next) {
|
|
2327
|
+
case 0:
|
|
2328
|
+
clearKeepaliveSpy = jest.spyOn(reg, 'clearKeepaliveTimer');
|
|
2329
|
+
setStatusSpy = jest.spyOn(reg, 'setStatus');
|
|
2330
|
+
_context51.next = 1;
|
|
2331
|
+
return reg.handleRegistrationDownEvent(registrationDownEvent);
|
|
2332
|
+
case 1:
|
|
2333
|
+
expect(reg.getStatus()).toBe(_types.RegistrationStatus.INACTIVE);
|
|
2334
|
+
clearKeepaliveSpy.mockClear();
|
|
2335
|
+
setStatusSpy.mockClear();
|
|
2336
|
+
lineEmitter.mockClear();
|
|
2337
|
+
expect((0, _keys.default)(reg.callManager.getActiveCalls()).length).toBe(0);
|
|
2338
|
+
_context51.next = 2;
|
|
2339
|
+
return reg.handleRegistrationDownEvent(registrationDownEvent);
|
|
2340
|
+
case 2:
|
|
2341
|
+
expect(clearKeepaliveSpy).toHaveBeenCalled();
|
|
2342
|
+
expect(setStatusSpy).toHaveBeenCalledWith(_types.RegistrationStatus.INACTIVE);
|
|
2343
|
+
expect(reg.getStatus()).toBe(_types.RegistrationStatus.INACTIVE);
|
|
2344
|
+
expect(lineEmitter).toHaveBeenCalledWith(_types4.LINE_EVENTS.UNREGISTERED, undefined, undefined);
|
|
2345
|
+
case 3:
|
|
2346
|
+
case "end":
|
|
2347
|
+
return _context51.stop();
|
|
2348
|
+
}
|
|
2349
|
+
}, _callee51);
|
|
2350
|
+
})));
|
|
2351
|
+
it('disconnects the Mobius WebSocket when socket is enabled', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee52() {
|
|
2352
|
+
var apiRequest, disconnectSocketSpy;
|
|
2353
|
+
return _regenerator.default.wrap(function (_context52) {
|
|
2354
|
+
while (1) switch (_context52.prev = _context52.next) {
|
|
2355
|
+
case 0:
|
|
2356
|
+
apiRequest = _request.APIRequest.getInstance({
|
|
2357
|
+
webex: webex
|
|
2358
|
+
});
|
|
2359
|
+
jest.spyOn(apiRequest, 'isSocketEnabled').mockReturnValue(true);
|
|
2360
|
+
disconnectSocketSpy = jest.spyOn(apiRequest, 'disconnectFromMobiusSocket').mockResolvedValue();
|
|
2361
|
+
lineEmitter.mockClear();
|
|
2362
|
+
expect((0, _keys.default)(reg.callManager.getActiveCalls()).length).toBe(0);
|
|
2363
|
+
_context52.next = 1;
|
|
2364
|
+
return reg.handleRegistrationDownEvent(registrationDownEvent);
|
|
2365
|
+
case 1:
|
|
2366
|
+
expect(disconnectSocketSpy).toHaveBeenCalledWith({
|
|
2367
|
+
code: 3050,
|
|
2368
|
+
reason: 'done (permanent)'
|
|
2369
|
+
});
|
|
2370
|
+
expect(reg.getStatus()).toBe(_types.RegistrationStatus.INACTIVE);
|
|
2371
|
+
expect(lineEmitter).toHaveBeenCalledWith(_types4.LINE_EVENTS.UNREGISTERED, undefined, undefined);
|
|
2372
|
+
case 2:
|
|
2373
|
+
case "end":
|
|
2374
|
+
return _context52.stop();
|
|
2375
|
+
}
|
|
2376
|
+
}, _callee52);
|
|
2377
|
+
})));
|
|
2378
|
+
it('still emits UNREGISTERED when socket disconnect fails', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee53() {
|
|
2379
|
+
var apiRequest, disconnectSocketSpy;
|
|
2380
|
+
return _regenerator.default.wrap(function (_context53) {
|
|
2381
|
+
while (1) switch (_context53.prev = _context53.next) {
|
|
2382
|
+
case 0:
|
|
2383
|
+
apiRequest = _request.APIRequest.getInstance({
|
|
2384
|
+
webex: webex
|
|
2385
|
+
});
|
|
2386
|
+
jest.spyOn(apiRequest, 'isSocketEnabled').mockReturnValue(true);
|
|
2387
|
+
disconnectSocketSpy = jest.spyOn(apiRequest, 'disconnectFromMobiusSocket').mockRejectedValue(new Error('socket teardown failed'));
|
|
2388
|
+
lineEmitter.mockClear();
|
|
2389
|
+
_context53.next = 1;
|
|
2390
|
+
return reg.handleRegistrationDownEvent(registrationDownEvent);
|
|
2391
|
+
case 1:
|
|
2392
|
+
expect(disconnectSocketSpy).toHaveBeenCalled();
|
|
2393
|
+
expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining('Mobius socket disconnect failed after registration-down'), {
|
|
2394
|
+
file: _constants.REGISTRATION_FILE,
|
|
2395
|
+
method: _constants.METHODS.HANDLE_REGISTRATION_DOWN_EVENT
|
|
2396
|
+
});
|
|
2397
|
+
expect(reg.getStatus()).toBe(_types.RegistrationStatus.INACTIVE);
|
|
2398
|
+
expect(lineEmitter).toHaveBeenCalledWith(_types4.LINE_EVENTS.UNREGISTERED, undefined, undefined);
|
|
2399
|
+
case 2:
|
|
2400
|
+
case "end":
|
|
2401
|
+
return _context53.stop();
|
|
2402
|
+
}
|
|
2403
|
+
}, _callee53);
|
|
2404
|
+
})));
|
|
2405
|
+
});
|
|
2406
|
+
describe('attemptRegistrationWithServers transport alignment', function () {
|
|
2407
|
+
var apiRequest;
|
|
2408
|
+
var setSocketEnabledSpy;
|
|
2409
|
+
beforeEach(function () {
|
|
2410
|
+
apiRequest = _request.APIRequest.getInstance({
|
|
2411
|
+
webex: webex
|
|
2412
|
+
});
|
|
2413
|
+
// Keep the actual transport on HTTP (no-op) so the registration flow stays simple;
|
|
2414
|
+
// we only assert which boolean the method derives from the server group's URL scheme.
|
|
2415
|
+
setSocketEnabledSpy = jest.spyOn(apiRequest, 'setSocketEnabled').mockImplementation(function () {});
|
|
2416
|
+
webex.request.mockResolvedValue(successPayload);
|
|
2417
|
+
});
|
|
2418
|
+
it('enables the WebSocket transport when the server group uses the wss:// scheme', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee54() {
|
|
2419
|
+
return _regenerator.default.wrap(function (_context54) {
|
|
2420
|
+
while (1) switch (_context54.prev = _context54.next) {
|
|
2421
|
+
case 0:
|
|
2422
|
+
_context54.next = 1;
|
|
2423
|
+
return reg.attemptRegistrationWithServers(_constants.REGISTRATION_UTIL, ['wss://mobius.example.com/api/v1/calling/web/']);
|
|
2424
|
+
case 1:
|
|
2425
|
+
expect(setSocketEnabledSpy).toHaveBeenCalledWith(true);
|
|
2426
|
+
case 2:
|
|
2427
|
+
case "end":
|
|
2428
|
+
return _context54.stop();
|
|
2429
|
+
}
|
|
2430
|
+
}, _callee54);
|
|
2431
|
+
})));
|
|
2432
|
+
it('falls back to the HTTP transport when the server group uses the https:// scheme', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee55() {
|
|
2433
|
+
return _regenerator.default.wrap(function (_context55) {
|
|
2434
|
+
while (1) switch (_context55.prev = _context55.next) {
|
|
2435
|
+
case 0:
|
|
2436
|
+
_context55.next = 1;
|
|
2437
|
+
return reg.attemptRegistrationWithServers(_constants.REGISTRATION_UTIL, ['https://mobius.example.com/api/v1/calling/web/']);
|
|
2438
|
+
case 1:
|
|
2439
|
+
expect(setSocketEnabledSpy).toHaveBeenCalledWith(false);
|
|
2440
|
+
case 2:
|
|
2441
|
+
case "end":
|
|
2442
|
+
return _context55.stop();
|
|
2443
|
+
}
|
|
2444
|
+
}, _callee55);
|
|
2445
|
+
})));
|
|
2446
|
+
it('does not change the transport when the server group is empty', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee56() {
|
|
2447
|
+
return _regenerator.default.wrap(function (_context56) {
|
|
2448
|
+
while (1) switch (_context56.prev = _context56.next) {
|
|
2449
|
+
case 0:
|
|
2450
|
+
_context56.next = 1;
|
|
2451
|
+
return reg.attemptRegistrationWithServers(_constants.REGISTRATION_UTIL, []);
|
|
2452
|
+
case 1:
|
|
2453
|
+
expect(setSocketEnabledSpy).not.toHaveBeenCalled();
|
|
2454
|
+
case 2:
|
|
2455
|
+
case "end":
|
|
2456
|
+
return _context56.stop();
|
|
2457
|
+
}
|
|
2458
|
+
}, _callee56);
|
|
2459
|
+
})));
|
|
2460
|
+
it('derives the transport from the first server in the group', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee57() {
|
|
2461
|
+
return _regenerator.default.wrap(function (_context57) {
|
|
2462
|
+
while (1) switch (_context57.prev = _context57.next) {
|
|
2463
|
+
case 0:
|
|
2464
|
+
_context57.next = 1;
|
|
2465
|
+
return reg.attemptRegistrationWithServers(_constants.REGISTRATION_UTIL, ['wss://primary.example.com/api/v1/calling/web/', 'https://backup.example.com/api/v1/calling/web/']);
|
|
2466
|
+
case 1:
|
|
2467
|
+
expect(setSocketEnabledSpy).toHaveBeenCalledWith(true);
|
|
2468
|
+
case 2:
|
|
2469
|
+
case "end":
|
|
2470
|
+
return _context57.stop();
|
|
1880
2471
|
}
|
|
1881
|
-
},
|
|
2472
|
+
}, _callee57);
|
|
1882
2473
|
})));
|
|
1883
2474
|
});
|
|
1884
2475
|
});
|