@webex/calling 3.11.0 → 3.12.0
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 +596 -0
- package/dist/CallHistory/CallHistory.js.map +1 -0
- package/dist/CallHistory/CallHistory.test.js +916 -0
- package/dist/CallHistory/CallHistory.test.js.map +1 -0
- package/dist/CallHistory/callHistoryFixtures.js +650 -0
- package/dist/CallHistory/callHistoryFixtures.js.map +1 -0
- package/dist/CallHistory/constants.js +38 -0
- package/dist/CallHistory/constants.js.map +1 -0
- package/dist/CallHistory/types.js +7 -0
- package/dist/CallHistory/types.js.map +1 -0
- package/dist/CallSettings/CallSettings.js +311 -0
- package/dist/CallSettings/CallSettings.js.map +1 -0
- package/dist/CallSettings/CallSettings.test.js +122 -0
- package/dist/CallSettings/CallSettings.test.js.map +1 -0
- package/dist/CallSettings/UcmBackendConnector.js +308 -0
- package/dist/CallSettings/UcmBackendConnector.js.map +1 -0
- package/dist/CallSettings/UcmBackendConnector.test.js +411 -0
- package/dist/CallSettings/UcmBackendConnector.test.js.map +1 -0
- package/dist/CallSettings/WxCallBackendConnector.js +597 -0
- package/dist/CallSettings/WxCallBackendConnector.js.map +1 -0
- package/dist/CallSettings/WxCallBackendConnector.test.js +904 -0
- package/dist/CallSettings/WxCallBackendConnector.test.js.map +1 -0
- package/dist/CallSettings/constants.js +31 -0
- package/dist/CallSettings/constants.js.map +1 -0
- package/dist/CallSettings/testFixtures.js +68 -0
- package/dist/CallSettings/testFixtures.js.map +1 -0
- package/dist/CallSettings/types.js +7 -0
- package/dist/CallSettings/types.js.map +1 -0
- package/dist/CallingClient/CallingClient.js +1119 -0
- package/dist/CallingClient/CallingClient.js.map +1 -0
- package/dist/CallingClient/CallingClient.test.js +1266 -0
- package/dist/CallingClient/CallingClient.test.js.map +1 -0
- package/dist/CallingClient/callRecordFixtures.js +101 -0
- package/dist/CallingClient/callRecordFixtures.js.map +1 -0
- package/dist/CallingClient/calling/CallerId/index.js +275 -0
- package/dist/CallingClient/calling/CallerId/index.js.map +1 -0
- package/dist/CallingClient/calling/CallerId/index.test.js +275 -0
- package/dist/CallingClient/calling/CallerId/index.test.js.map +1 -0
- package/dist/CallingClient/calling/CallerId/types.js +7 -0
- package/dist/CallingClient/calling/CallerId/types.js.map +1 -0
- package/dist/CallingClient/calling/call.js +3486 -0
- package/dist/CallingClient/calling/call.js.map +1 -0
- package/dist/CallingClient/calling/call.test.js +3612 -0
- package/dist/CallingClient/calling/call.test.js.map +1 -0
- package/dist/CallingClient/calling/callManager.js +460 -0
- package/dist/CallingClient/calling/callManager.js.map +1 -0
- package/dist/CallingClient/calling/callManager.test.js +741 -0
- package/dist/CallingClient/calling/callManager.test.js.map +1 -0
- package/dist/CallingClient/calling/index.js +30 -0
- package/dist/CallingClient/calling/index.js.map +1 -0
- package/dist/CallingClient/calling/types.js +74 -0
- package/dist/CallingClient/calling/types.js.map +1 -0
- package/dist/CallingClient/callingClientFixtures.js +143 -0
- package/dist/CallingClient/callingClientFixtures.js.map +1 -0
- package/dist/CallingClient/constants.js +243 -0
- package/dist/CallingClient/constants.js.map +1 -0
- package/dist/CallingClient/line/index.js +332 -0
- package/dist/CallingClient/line/index.js.map +1 -0
- package/dist/CallingClient/line/line.test.js +327 -0
- package/dist/CallingClient/line/line.test.js.map +1 -0
- package/dist/CallingClient/line/types.js +21 -0
- package/dist/CallingClient/line/types.js.map +1 -0
- package/dist/CallingClient/registration/index.js +19 -0
- package/dist/CallingClient/registration/index.js.map +1 -0
- package/dist/CallingClient/registration/register.js +1686 -0
- package/dist/CallingClient/registration/register.js.map +1 -0
- package/dist/CallingClient/registration/register.test.js +1885 -0
- package/dist/CallingClient/registration/register.test.js.map +1 -0
- package/dist/CallingClient/registration/registerFixtures.js +36 -0
- package/dist/CallingClient/registration/registerFixtures.js.map +1 -0
- package/dist/CallingClient/registration/types.js +7 -0
- package/dist/CallingClient/registration/types.js.map +1 -0
- package/dist/CallingClient/registration/webWorker.js +130 -0
- package/dist/CallingClient/registration/webWorker.js.map +1 -0
- package/dist/CallingClient/registration/webWorker.test.js +303 -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 +7 -0
- package/dist/CallingClient/types.js.map +1 -0
- package/dist/CallingClient/windowsChromiumIceWarmupUtils.js +142 -0
- package/dist/CallingClient/windowsChromiumIceWarmupUtils.js.map +1 -0
- package/dist/Contacts/ContactsClient.js +1206 -0
- package/dist/Contacts/ContactsClient.js.map +1 -0
- package/dist/Contacts/ContactsClient.test.js +1004 -0
- package/dist/Contacts/ContactsClient.test.js.map +1 -0
- package/dist/Contacts/constants.js +40 -0
- package/dist/Contacts/constants.js.map +1 -0
- package/dist/Contacts/contactFixtures.js +430 -0
- package/dist/Contacts/contactFixtures.js.map +1 -0
- package/dist/Contacts/types.js +43 -0
- package/dist/Contacts/types.js.map +1 -0
- package/dist/Errors/catalog/CallError.js +89 -0
- package/dist/Errors/catalog/CallError.js.map +1 -0
- package/dist/Errors/catalog/CallingDeviceError.js +83 -0
- package/dist/Errors/catalog/CallingDeviceError.js.map +1 -0
- package/dist/Errors/catalog/ExtendedError.js +42 -0
- package/dist/Errors/catalog/ExtendedError.js.map +1 -0
- package/dist/Errors/catalog/LineError.js +85 -0
- package/dist/Errors/catalog/LineError.js.map +1 -0
- package/dist/Errors/index.js +28 -0
- package/dist/Errors/index.js.map +1 -0
- package/dist/Errors/types.js +59 -0
- package/dist/Errors/types.js.map +1 -0
- package/dist/Events/impl/index.js +79 -0
- package/dist/Events/impl/index.js.map +1 -0
- package/dist/Events/types.js +107 -0
- package/dist/Events/types.js.map +1 -0
- package/dist/Logger/index.js +228 -0
- package/dist/Logger/index.js.map +1 -0
- package/dist/Logger/index.test.js +87 -0
- package/dist/Logger/index.test.js.map +1 -0
- package/dist/Logger/types.js +34 -0
- package/dist/Logger/types.js.map +1 -0
- package/dist/Metrics/index.js +534 -0
- package/dist/Metrics/index.js.map +1 -0
- package/dist/Metrics/index.test.js +463 -0
- package/dist/Metrics/index.test.js.map +1 -0
- package/dist/Metrics/types.js +64 -0
- package/dist/Metrics/types.js.map +1 -0
- package/dist/SDKConnector/index.js +102 -0
- package/dist/SDKConnector/index.js.map +1 -0
- package/dist/SDKConnector/index.test.js +9 -0
- package/dist/SDKConnector/index.test.js.map +1 -0
- package/dist/SDKConnector/types.js +7 -0
- package/dist/SDKConnector/types.js.map +1 -0
- package/dist/SDKConnector/utils.js +39 -0
- package/dist/SDKConnector/utils.js.map +1 -0
- package/dist/SDKConnector/utils.test.js +9 -0
- package/dist/SDKConnector/utils.test.js.map +1 -0
- package/dist/Voicemail/BroadworksBackendConnector.js +699 -0
- package/dist/Voicemail/BroadworksBackendConnector.js.map +1 -0
- package/dist/Voicemail/BroadworksBackendConnector.test.js +820 -0
- package/dist/Voicemail/BroadworksBackendConnector.test.js.map +1 -0
- package/dist/Voicemail/UcmBackendConnector.js +628 -0
- package/dist/Voicemail/UcmBackendConnector.js.map +1 -0
- package/dist/Voicemail/UcmBackendConnector.test.js +738 -0
- package/dist/Voicemail/UcmBackendConnector.test.js.map +1 -0
- package/dist/Voicemail/Voicemail.js +472 -0
- package/dist/Voicemail/Voicemail.js.map +1 -0
- package/dist/Voicemail/Voicemail.test.js +391 -0
- package/dist/Voicemail/Voicemail.test.js.map +1 -0
- package/dist/Voicemail/WxCallBackendConnector.js +657 -0
- package/dist/Voicemail/WxCallBackendConnector.js.map +1 -0
- package/dist/Voicemail/WxCallBackendConnector.test.js +1225 -0
- package/dist/Voicemail/WxCallBackendConnector.test.js.map +1 -0
- package/dist/Voicemail/constants.js +61 -0
- package/dist/Voicemail/constants.js.map +1 -0
- package/dist/Voicemail/types.js +7 -0
- package/dist/Voicemail/types.js.map +1 -0
- package/dist/Voicemail/voicemailFixture.js +524 -0
- package/dist/Voicemail/voicemailFixture.js.map +1 -0
- package/dist/api.js +157 -0
- package/dist/api.js.map +1 -0
- package/dist/common/Utils.js +1483 -0
- package/dist/common/Utils.js.map +1 -0
- package/dist/common/Utils.test.js +1989 -0
- package/dist/common/Utils.test.js.map +1 -0
- package/dist/common/constants.js +62 -0
- package/dist/common/constants.js.map +1 -0
- package/dist/common/index.js +19 -0
- package/dist/common/index.js.map +1 -0
- package/dist/common/testUtil.js +983 -0
- package/dist/common/testUtil.js.map +1 -0
- package/dist/common/types.js +75 -0
- package/dist/common/types.js.map +1 -0
- package/dist/index.js +321 -0
- package/dist/index.js.map +1 -0
- package/dist/module/CallHistory/CallHistory.js +28 -17
- package/dist/module/CallingClient/CallingClient.js +43 -1
- package/dist/module/CallingClient/calling/call.js +3 -2
- package/dist/module/CallingClient/constants.js +2 -0
- package/dist/module/CallingClient/registration/register.js +8 -0
- package/dist/types/CallHistory/CallHistory.d.ts.map +1 -1
- package/dist/types/CallingClient/CallingClient.d.ts +2 -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/constants.d.ts +2 -0
- package/dist/types/CallingClient/constants.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/register.d.ts +2 -1
- package/dist/types/CallingClient/registration/register.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/types.d.ts +2 -1
- package/dist/types/CallingClient/registration/types.d.ts.map +1 -1
- package/dist/types/CallingClient/types.d.ts +2 -1
- package/dist/types/CallingClient/types.d.ts.map +1 -1
- package/dist/types/common/types.d.ts +4 -0
- package/dist/types/common/types.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,1266 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _typeof = require("@babel/runtime-corejs2/helpers/typeof");
|
|
4
|
+
var _Object$keys2 = require("@babel/runtime-corejs2/core-js/object/keys");
|
|
5
|
+
var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs2/core-js/object/get-own-property-symbols");
|
|
6
|
+
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
|
|
7
|
+
var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptors");
|
|
8
|
+
var _Object$defineProperties = require("@babel/runtime-corejs2/core-js/object/define-properties");
|
|
9
|
+
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
10
|
+
var _WeakMap = require("@babel/runtime-corejs2/core-js/weak-map");
|
|
11
|
+
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
12
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
|
|
13
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
|
|
14
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
|
|
15
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
16
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
|
|
17
|
+
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
18
|
+
var _values = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/values"));
|
|
19
|
+
var _keys = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/keys"));
|
|
20
|
+
var _asyncMutex = require("async-mutex");
|
|
21
|
+
var Media = _interopRequireWildcard(require("@webex/internal-media-core"));
|
|
22
|
+
var _types = require("../Logger/types");
|
|
23
|
+
var _testUtil = require("../common/testUtil");
|
|
24
|
+
var _types2 = require("../common/types");
|
|
25
|
+
var _types3 = require("../Events/types");
|
|
26
|
+
var _Logger = _interopRequireDefault(require("../Logger"));
|
|
27
|
+
var _CallingClient = require("./CallingClient");
|
|
28
|
+
var _Utils = _interopRequireWildcard(require("../common/Utils"));
|
|
29
|
+
var utils = _Utils;
|
|
30
|
+
var _callManager = require("./calling/callManager");
|
|
31
|
+
var _constants = require("./constants");
|
|
32
|
+
var _callRecordFixtures = require("./callRecordFixtures");
|
|
33
|
+
var _callingClientFixtures = require("./callingClientFixtures");
|
|
34
|
+
var _line = _interopRequireDefault(require("./line"));
|
|
35
|
+
var _registerFixtures = require("./registration/registerFixtures");
|
|
36
|
+
var _constants2 = require("../common/constants");
|
|
37
|
+
var _types4 = require("../Metrics/types");
|
|
38
|
+
var _windowsChromiumIceWarmupUtils = _interopRequireDefault(require("./windowsChromiumIceWarmupUtils"));
|
|
39
|
+
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 _t5 in e) "default" !== _t5 && {}.hasOwnProperty.call(e, _t5) && ((i = (o = _Object$defineProperty) && _Object$getOwnPropertyDescriptor(e, _t5)) && (i.get || i.set) ? o(f, _t5, i) : f[_t5] = e[_t5]); return f; })(e, t); }
|
|
40
|
+
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; }
|
|
41
|
+
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 dot-notation */
|
|
42
|
+
global.crypto = {
|
|
43
|
+
randomUUID: function randomUUID() {
|
|
44
|
+
return '12345678-1234-5678-1234-567812345678';
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
jest.spyOn(utils, 'uploadLogs').mockResolvedValue(undefined);
|
|
48
|
+
describe('CallingClient Tests', function () {
|
|
49
|
+
// Common initializers
|
|
50
|
+
|
|
51
|
+
var handleErrorSpy = jest.spyOn(utils, 'handleCallingClientErrors');
|
|
52
|
+
var setLoggerSpy = jest.spyOn(Media, 'setLogger');
|
|
53
|
+
var webex = (0, _testUtil.getTestUtilsWebex)();
|
|
54
|
+
webex.internal.services['_hostCatalog'] = _callingClientFixtures.mockCatalogUS;
|
|
55
|
+
webex.internal.services.getMobiusClusters = jest.fn().mockReturnValue(_callingClientFixtures.mockUSServiceHosts);
|
|
56
|
+
var defaultServiceIndicator = _types2.ServiceIndicator.CALLING;
|
|
57
|
+
var callManager = (0, _callManager.getCallManager)(webex, defaultServiceIndicator);
|
|
58
|
+
var infoSpy = jest.spyOn(_Logger.default, 'info');
|
|
59
|
+
var logSpy = jest.spyOn(_Logger.default, 'log');
|
|
60
|
+
var warnSpy = jest.spyOn(_Logger.default, 'warn');
|
|
61
|
+
var originalProcessNextTick = process.nextTick;
|
|
62
|
+
function flushPromises() {
|
|
63
|
+
return new _promise.default(function (resolve) {
|
|
64
|
+
originalProcessNextTick(resolve);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
describe('CallingClient pick Mobius cluster using Service Host Tests', function () {
|
|
68
|
+
afterAll(function () {
|
|
69
|
+
callManager.removeAllListeners();
|
|
70
|
+
webex.internal.services['_serviceUrls']['mobius'] = 'https://mobius.aintgen-a-1.int.infra.webex.com/api/v1';
|
|
71
|
+
webex.internal.services['_hostCatalog'] = _callingClientFixtures.mockCatalogUS;
|
|
72
|
+
});
|
|
73
|
+
it('should use default mobius service host when Service URL is invalid', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
74
|
+
var callingClient;
|
|
75
|
+
return _regenerator.default.wrap(function (_context) {
|
|
76
|
+
while (1) switch (_context.prev = _context.next) {
|
|
77
|
+
case 0:
|
|
78
|
+
webex.internal.services._hostCatalog = _callingClientFixtures.mockCatalogUS;
|
|
79
|
+
webex.internal.services._serviceUrls.mobius = 'invalid-url';
|
|
80
|
+
_context.next = 1;
|
|
81
|
+
return (0, _CallingClient.createClient)(webex, {
|
|
82
|
+
logger: {
|
|
83
|
+
level: _types.LOGGER.INFO
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
case 1:
|
|
87
|
+
callingClient = _context.sent;
|
|
88
|
+
expect(setLoggerSpy).toHaveBeenCalledTimes(1);
|
|
89
|
+
expect(callingClient['mobiusClusters']).toStrictEqual(_callingClientFixtures.mockUSServiceHosts);
|
|
90
|
+
case 2:
|
|
91
|
+
case "end":
|
|
92
|
+
return _context.stop();
|
|
93
|
+
}
|
|
94
|
+
}, _callee);
|
|
95
|
+
})));
|
|
96
|
+
it('should set mobiusServiceHost correctly when URL is valid', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
97
|
+
var callingClient;
|
|
98
|
+
return _regenerator.default.wrap(function (_context2) {
|
|
99
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
100
|
+
case 0:
|
|
101
|
+
webex.internal.services._hostCatalog = _callingClientFixtures.mockCatalogEU;
|
|
102
|
+
webex.internal.services.getMobiusClusters = jest.fn().mockReturnValue(_callingClientFixtures.mockEUServiceHosts);
|
|
103
|
+
webex.internal.services['_serviceUrls']['mobius'] = 'https://mobius-eu-central-1.prod.infra.webex.com/api/v1';
|
|
104
|
+
_context2.next = 1;
|
|
105
|
+
return (0, _CallingClient.createClient)(webex, {
|
|
106
|
+
logger: {
|
|
107
|
+
level: _types.LOGGER.INFO
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
case 1:
|
|
111
|
+
callingClient = _context2.sent;
|
|
112
|
+
expect(callingClient['mobiusHost']).toBe('https://mobius-eu-central-1.prod.infra.webex.com/api/v1');
|
|
113
|
+
expect(callingClient['mobiusClusters']).toStrictEqual(_callingClientFixtures.mockEUServiceHosts);
|
|
114
|
+
case 2:
|
|
115
|
+
case "end":
|
|
116
|
+
return _context2.stop();
|
|
117
|
+
}
|
|
118
|
+
}, _callee2);
|
|
119
|
+
})));
|
|
120
|
+
});
|
|
121
|
+
describe('ServiceData tests', function () {
|
|
122
|
+
var callingClient;
|
|
123
|
+
afterEach(function () {
|
|
124
|
+
callManager.removeAllListeners();
|
|
125
|
+
callingClient = undefined;
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* No input sdk config to callingClient, it should default to service type
|
|
130
|
+
* calling and empty domain value.
|
|
131
|
+
*/
|
|
132
|
+
it('Verify valid calling serviceData with no input sdk config', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee4() {
|
|
133
|
+
return _regenerator.default.wrap(function (_context4) {
|
|
134
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
135
|
+
case 0:
|
|
136
|
+
expect(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
137
|
+
return _regenerator.default.wrap(function (_context3) {
|
|
138
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
139
|
+
case 0:
|
|
140
|
+
_context3.next = 1;
|
|
141
|
+
return (0, _CallingClient.createClient)(webex);
|
|
142
|
+
case 1:
|
|
143
|
+
callingClient = _context3.sent;
|
|
144
|
+
expect(callingClient).toBeTruthy();
|
|
145
|
+
case 2:
|
|
146
|
+
case "end":
|
|
147
|
+
return _context3.stop();
|
|
148
|
+
}
|
|
149
|
+
}, _callee3);
|
|
150
|
+
}))).not.toThrow(Error);
|
|
151
|
+
case 1:
|
|
152
|
+
case "end":
|
|
153
|
+
return _context4.stop();
|
|
154
|
+
}
|
|
155
|
+
}, _callee4);
|
|
156
|
+
})));
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Input sdk config to callingClient with serviceData carrying empty string for
|
|
160
|
+
* both indicator and domain in it.
|
|
161
|
+
*
|
|
162
|
+
* It should default to service type calling and empty domain value.
|
|
163
|
+
*
|
|
164
|
+
*/
|
|
165
|
+
it('Verify invalid empty service indicator, empty domain', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee6() {
|
|
166
|
+
var serviceDataObj;
|
|
167
|
+
return _regenerator.default.wrap(function (_context6) {
|
|
168
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
169
|
+
case 0:
|
|
170
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
171
|
+
serviceDataObj = {
|
|
172
|
+
indicator: '',
|
|
173
|
+
domain: ''
|
|
174
|
+
};
|
|
175
|
+
expect(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee5() {
|
|
176
|
+
return _regenerator.default.wrap(function (_context5) {
|
|
177
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
178
|
+
case 0:
|
|
179
|
+
_context5.next = 1;
|
|
180
|
+
return (0, _CallingClient.createClient)(webex, {
|
|
181
|
+
serviceData: serviceDataObj
|
|
182
|
+
});
|
|
183
|
+
case 1:
|
|
184
|
+
callingClient = _context5.sent;
|
|
185
|
+
expect(callingClient).toBeTruthy();
|
|
186
|
+
case 2:
|
|
187
|
+
case "end":
|
|
188
|
+
return _context5.stop();
|
|
189
|
+
}
|
|
190
|
+
}, _callee5);
|
|
191
|
+
}))).not.toThrow(Error);
|
|
192
|
+
case 1:
|
|
193
|
+
case "end":
|
|
194
|
+
return _context6.stop();
|
|
195
|
+
}
|
|
196
|
+
}, _callee6);
|
|
197
|
+
})));
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Input sdk config to callingClient with serviceData carrying invalid value for indicator
|
|
201
|
+
* and valid domain type string for domain field in it.
|
|
202
|
+
*
|
|
203
|
+
* It should throw error and abort execution as indicator value is invalid.
|
|
204
|
+
*
|
|
205
|
+
* INDICATOR value MUST MATCH with one of the values in ServiceIndicator enum.
|
|
206
|
+
*/
|
|
207
|
+
it('Verify invalid service indicator, valid domain', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee7() {
|
|
208
|
+
var serviceDataObj, _t;
|
|
209
|
+
return _regenerator.default.wrap(function (_context7) {
|
|
210
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
211
|
+
case 0:
|
|
212
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
213
|
+
serviceDataObj = {
|
|
214
|
+
indicator: 'test',
|
|
215
|
+
domain: 'test.example.com'
|
|
216
|
+
};
|
|
217
|
+
_context7.prev = 1;
|
|
218
|
+
_context7.next = 2;
|
|
219
|
+
return (0, _CallingClient.createClient)(webex, {
|
|
220
|
+
serviceData: serviceDataObj
|
|
221
|
+
});
|
|
222
|
+
case 2:
|
|
223
|
+
callingClient = _context7.sent;
|
|
224
|
+
_context7.next = 4;
|
|
225
|
+
break;
|
|
226
|
+
case 3:
|
|
227
|
+
_context7.prev = 3;
|
|
228
|
+
_t = _context7["catch"](1);
|
|
229
|
+
expect(_t.message).toEqual('Invalid service indicator, Allowed values are: calling, contactcenter and guestcalling');
|
|
230
|
+
case 4:
|
|
231
|
+
expect.assertions(1);
|
|
232
|
+
case 5:
|
|
233
|
+
case "end":
|
|
234
|
+
return _context7.stop();
|
|
235
|
+
}
|
|
236
|
+
}, _callee7, null, [[1, 3]]);
|
|
237
|
+
})));
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Input sdk config to callingClient with serviceData carrying valid value for indicator
|
|
241
|
+
* 'calling', but an invalid domain type string for domain field in it.
|
|
242
|
+
*
|
|
243
|
+
* It should throw error and abort execution as domain value is invalid.
|
|
244
|
+
*
|
|
245
|
+
* DOMAIN field for service type calling is allowed to be empty but if it carries a non-empty
|
|
246
|
+
* string then it must be of valid domain type.
|
|
247
|
+
*/
|
|
248
|
+
it('CALLING: verify invalid service domain', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee8() {
|
|
249
|
+
var serviceDataObj, _t2;
|
|
250
|
+
return _regenerator.default.wrap(function (_context8) {
|
|
251
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
252
|
+
case 0:
|
|
253
|
+
serviceDataObj = {
|
|
254
|
+
indicator: _types2.ServiceIndicator.CALLING,
|
|
255
|
+
domain: 'test'
|
|
256
|
+
};
|
|
257
|
+
_context8.prev = 1;
|
|
258
|
+
_context8.next = 2;
|
|
259
|
+
return (0, _CallingClient.createClient)(webex, {
|
|
260
|
+
serviceData: serviceDataObj
|
|
261
|
+
});
|
|
262
|
+
case 2:
|
|
263
|
+
callingClient = _context8.sent;
|
|
264
|
+
_context8.next = 4;
|
|
265
|
+
break;
|
|
266
|
+
case 3:
|
|
267
|
+
_context8.prev = 3;
|
|
268
|
+
_t2 = _context8["catch"](1);
|
|
269
|
+
expect(_t2.message).toEqual('Invalid service domain.');
|
|
270
|
+
case 4:
|
|
271
|
+
expect.assertions(1);
|
|
272
|
+
case 5:
|
|
273
|
+
case "end":
|
|
274
|
+
return _context8.stop();
|
|
275
|
+
}
|
|
276
|
+
}, _callee8, null, [[1, 3]]);
|
|
277
|
+
})));
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Input sdk config to callingClient with serviceData carrying valid value for indicator
|
|
281
|
+
* 'calling', and an empty string for domain field in it.
|
|
282
|
+
*
|
|
283
|
+
* Execution should proceed properly and createRegistration should be called with same serviceData.
|
|
284
|
+
*
|
|
285
|
+
* DOMAIN field for service type 'calling' is allowed to be empty.
|
|
286
|
+
*/
|
|
287
|
+
it('CALLING: verify valid empty service domain', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee0() {
|
|
288
|
+
var serviceDataObj;
|
|
289
|
+
return _regenerator.default.wrap(function (_context0) {
|
|
290
|
+
while (1) switch (_context0.prev = _context0.next) {
|
|
291
|
+
case 0:
|
|
292
|
+
serviceDataObj = {
|
|
293
|
+
indicator: _types2.ServiceIndicator.CALLING,
|
|
294
|
+
domain: ''
|
|
295
|
+
};
|
|
296
|
+
expect(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee9() {
|
|
297
|
+
return _regenerator.default.wrap(function (_context9) {
|
|
298
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
299
|
+
case 0:
|
|
300
|
+
_context9.next = 1;
|
|
301
|
+
return (0, _CallingClient.createClient)(webex, {
|
|
302
|
+
serviceData: serviceDataObj
|
|
303
|
+
});
|
|
304
|
+
case 1:
|
|
305
|
+
callingClient = _context9.sent;
|
|
306
|
+
expect(callingClient).toBeTruthy();
|
|
307
|
+
case 2:
|
|
308
|
+
case "end":
|
|
309
|
+
return _context9.stop();
|
|
310
|
+
}
|
|
311
|
+
}, _callee9);
|
|
312
|
+
}))).not.toThrow(Error);
|
|
313
|
+
case 1:
|
|
314
|
+
case "end":
|
|
315
|
+
return _context0.stop();
|
|
316
|
+
}
|
|
317
|
+
}, _callee0);
|
|
318
|
+
})));
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Input sdk config to callingClient with serviceData carrying valid value for indicator
|
|
322
|
+
* 'contactcenter', but an empty string for domain field in it.
|
|
323
|
+
*
|
|
324
|
+
* It should throw error and abort execution as domain value is invalid.
|
|
325
|
+
*
|
|
326
|
+
* DOMAIN field for service type 'contactcenter' must carry a non-empty valid domain type string.
|
|
327
|
+
*/
|
|
328
|
+
it('ContactCenter: verify empty invalid service domain', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee1() {
|
|
329
|
+
var serviceDataObj, _t3;
|
|
330
|
+
return _regenerator.default.wrap(function (_context1) {
|
|
331
|
+
while (1) switch (_context1.prev = _context1.next) {
|
|
332
|
+
case 0:
|
|
333
|
+
serviceDataObj = {
|
|
334
|
+
indicator: _types2.ServiceIndicator.CONTACT_CENTER,
|
|
335
|
+
domain: ''
|
|
336
|
+
};
|
|
337
|
+
_context1.prev = 1;
|
|
338
|
+
_context1.next = 2;
|
|
339
|
+
return (0, _CallingClient.createClient)(webex, {
|
|
340
|
+
serviceData: serviceDataObj
|
|
341
|
+
});
|
|
342
|
+
case 2:
|
|
343
|
+
callingClient = _context1.sent;
|
|
344
|
+
_context1.next = 4;
|
|
345
|
+
break;
|
|
346
|
+
case 3:
|
|
347
|
+
_context1.prev = 3;
|
|
348
|
+
_t3 = _context1["catch"](1);
|
|
349
|
+
expect(_t3.message).toEqual('Invalid service domain.');
|
|
350
|
+
case 4:
|
|
351
|
+
expect.assertions(1);
|
|
352
|
+
case 5:
|
|
353
|
+
case "end":
|
|
354
|
+
return _context1.stop();
|
|
355
|
+
}
|
|
356
|
+
}, _callee1, null, [[1, 3]]);
|
|
357
|
+
})));
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Input sdk config to callingClient with serviceData carrying valid value for indicator
|
|
361
|
+
* 'contactcenter' , and a valid domain type string for domain field in it.
|
|
362
|
+
*
|
|
363
|
+
* Execution should proceed properly and createRegistration should be called with same serviceData.
|
|
364
|
+
*
|
|
365
|
+
* DOMAIN field for service type 'contactcenter' must carry a non-empty valid domain type string.
|
|
366
|
+
*/
|
|
367
|
+
it('ContactCenter: verify valid service domain', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee11() {
|
|
368
|
+
var serviceDataObj;
|
|
369
|
+
return _regenerator.default.wrap(function (_context11) {
|
|
370
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
371
|
+
case 0:
|
|
372
|
+
serviceDataObj = {
|
|
373
|
+
indicator: _types2.ServiceIndicator.CONTACT_CENTER,
|
|
374
|
+
domain: 'test.example.com'
|
|
375
|
+
};
|
|
376
|
+
expect(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee10() {
|
|
377
|
+
return _regenerator.default.wrap(function (_context10) {
|
|
378
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
379
|
+
case 0:
|
|
380
|
+
_context10.next = 1;
|
|
381
|
+
return (0, _CallingClient.createClient)(webex, {
|
|
382
|
+
serviceData: serviceDataObj
|
|
383
|
+
});
|
|
384
|
+
case 1:
|
|
385
|
+
callingClient = _context10.sent;
|
|
386
|
+
expect(callingClient).toBeTruthy();
|
|
387
|
+
case 2:
|
|
388
|
+
case "end":
|
|
389
|
+
return _context10.stop();
|
|
390
|
+
}
|
|
391
|
+
}, _callee10);
|
|
392
|
+
}))).not.toThrow(Error);
|
|
393
|
+
case 1:
|
|
394
|
+
case "end":
|
|
395
|
+
return _context11.stop();
|
|
396
|
+
}
|
|
397
|
+
}, _callee11);
|
|
398
|
+
})));
|
|
399
|
+
it('Get current log level', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee12() {
|
|
400
|
+
return _regenerator.default.wrap(function (_context12) {
|
|
401
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
402
|
+
case 0:
|
|
403
|
+
_context12.next = 1;
|
|
404
|
+
return (0, _CallingClient.createClient)(webex, {
|
|
405
|
+
logger: {
|
|
406
|
+
level: _types.LOGGER.INFO
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
case 1:
|
|
410
|
+
callingClient = _context12.sent;
|
|
411
|
+
expect(callingClient).toBeTruthy();
|
|
412
|
+
expect(callingClient.getLoggingLevel).toBeTruthy();
|
|
413
|
+
expect(callingClient.getLoggingLevel()).toEqual(_types.LOGGER.INFO);
|
|
414
|
+
case 2:
|
|
415
|
+
case "end":
|
|
416
|
+
return _context12.stop();
|
|
417
|
+
}
|
|
418
|
+
}, _callee12);
|
|
419
|
+
})));
|
|
420
|
+
});
|
|
421
|
+
describe('Mobius Server discovery tests', function () {
|
|
422
|
+
var callingClient;
|
|
423
|
+
afterEach(function () {
|
|
424
|
+
jest.clearAllTimers();
|
|
425
|
+
jest.clearAllMocks();
|
|
426
|
+
callingClient.removeAllListeners();
|
|
427
|
+
callManager.removeAllListeners();
|
|
428
|
+
callingClient = undefined;
|
|
429
|
+
jest.useRealTimers();
|
|
430
|
+
});
|
|
431
|
+
it('verify successful mobius server url discovery', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee13() {
|
|
432
|
+
return _regenerator.default.wrap(function (_context13) {
|
|
433
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
434
|
+
case 0:
|
|
435
|
+
webex.request.mockResolvedValueOnce(_callingClientFixtures.regionPayload).mockResolvedValueOnce(_callingClientFixtures.discoveryPayload);
|
|
436
|
+
_context13.next = 1;
|
|
437
|
+
return (0, _CallingClient.createClient)(webex, {
|
|
438
|
+
logger: {
|
|
439
|
+
level: _types.LOGGER.INFO
|
|
440
|
+
}
|
|
441
|
+
});
|
|
442
|
+
case 1:
|
|
443
|
+
callingClient = _context13.sent;
|
|
444
|
+
expect(webex.request).toBeCalledTimes(2);
|
|
445
|
+
expect(callingClient.primaryMobiusUris).toEqual([_callingClientFixtures.primaryUrl]);
|
|
446
|
+
expect(handleErrorSpy).not.toBeCalled();
|
|
447
|
+
expect(webex.request).nthCalledWith(1, {
|
|
448
|
+
method: 'GET',
|
|
449
|
+
uri: "".concat(_constants.DISCOVERY_URL),
|
|
450
|
+
addAuthHeader: false,
|
|
451
|
+
headers: (0, _defineProperty2.default)({}, _constants.SPARK_USER_AGENT, null)
|
|
452
|
+
});
|
|
453
|
+
expect(webex.request).nthCalledWith(2, _objectSpread(_objectSpread({
|
|
454
|
+
method: 'GET'
|
|
455
|
+
}, (0, _testUtil.getMockRequestTemplate)()), {}, {
|
|
456
|
+
uri: "".concat(callingClient['mobiusHost']).concat(_constants.URL_ENDPOINT, "?regionCode=").concat(_callingClientFixtures.regionBody.clientRegion, "&countryCode=").concat(_callingClientFixtures.regionBody.countryCode)
|
|
457
|
+
}));
|
|
458
|
+
case 2:
|
|
459
|
+
case "end":
|
|
460
|
+
return _context13.stop();
|
|
461
|
+
}
|
|
462
|
+
}, _callee13);
|
|
463
|
+
})));
|
|
464
|
+
it('when region discovery succeeds but region based mobius url discovery fails with final error', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee14() {
|
|
465
|
+
var failurePayload;
|
|
466
|
+
return _regenerator.default.wrap(function (_context14) {
|
|
467
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
468
|
+
case 0:
|
|
469
|
+
failurePayload = {
|
|
470
|
+
statusCode: 401
|
|
471
|
+
};
|
|
472
|
+
webex.request.mockResolvedValueOnce(_callingClientFixtures.regionPayload).mockRejectedValueOnce(failurePayload);
|
|
473
|
+
_context14.next = 1;
|
|
474
|
+
return (0, _CallingClient.createClient)(webex, {
|
|
475
|
+
logger: {
|
|
476
|
+
level: _types.LOGGER.INFO
|
|
477
|
+
}
|
|
478
|
+
});
|
|
479
|
+
case 1:
|
|
480
|
+
callingClient = _context14.sent;
|
|
481
|
+
expect(handleErrorSpy).toBeCalledWith(failurePayload, expect.anything(), {
|
|
482
|
+
file: _constants.CALLING_CLIENT_FILE,
|
|
483
|
+
method: 'getMobiusServers'
|
|
484
|
+
});
|
|
485
|
+
expect(webex.request).toBeCalledTimes(2);
|
|
486
|
+
expect(callingClient.primaryMobiusUris).toEqual(["".concat(callingClient['mobiusHost']).concat(_constants.URL_ENDPOINT)]);
|
|
487
|
+
expect(webex.request).nthCalledWith(1, {
|
|
488
|
+
method: 'GET',
|
|
489
|
+
uri: "".concat(_constants.DISCOVERY_URL),
|
|
490
|
+
addAuthHeader: false,
|
|
491
|
+
headers: (0, _defineProperty2.default)({}, _constants.SPARK_USER_AGENT, null)
|
|
492
|
+
});
|
|
493
|
+
expect(warnSpy).toBeCalledWith("Couldn't resolve the region and country code. Defaulting to the catalog entries to discover mobius servers", expect.objectContaining({
|
|
494
|
+
file: _constants.CALLING_CLIENT_FILE,
|
|
495
|
+
method: 'getMobiusServers'
|
|
496
|
+
}));
|
|
497
|
+
case 2:
|
|
498
|
+
case "end":
|
|
499
|
+
return _context14.stop();
|
|
500
|
+
}
|
|
501
|
+
}, _callee14);
|
|
502
|
+
})));
|
|
503
|
+
it('Verify successful mobius server url discovery after initializing callingClient through a config', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee15() {
|
|
504
|
+
return _regenerator.default.wrap(function (_context15) {
|
|
505
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
506
|
+
case 0:
|
|
507
|
+
infoSpy.mockReset();
|
|
508
|
+
webex.request.mockResolvedValueOnce(_callingClientFixtures.discoveryPayload);
|
|
509
|
+
_context15.next = 1;
|
|
510
|
+
return (0, _CallingClient.createClient)(webex, {
|
|
511
|
+
discovery: {
|
|
512
|
+
region: 'AP-SOUTHEAST',
|
|
513
|
+
country: 'IN'
|
|
514
|
+
},
|
|
515
|
+
logger: {
|
|
516
|
+
level: _types.LOGGER.INFO
|
|
517
|
+
}
|
|
518
|
+
});
|
|
519
|
+
case 1:
|
|
520
|
+
callingClient = _context15.sent;
|
|
521
|
+
expect(callingClient.primaryMobiusUris).toEqual([_callingClientFixtures.primaryUrl]);
|
|
522
|
+
expect(infoSpy).toHaveBeenCalledWith(_constants2.METHOD_START_MESSAGE, {
|
|
523
|
+
file: 'CallingClient',
|
|
524
|
+
method: 'getMobiusServers'
|
|
525
|
+
});
|
|
526
|
+
expect(webex.request).toBeCalledOnceWith(_objectSpread(_objectSpread({}, (0, _testUtil.getMockRequestTemplate)()), {}, {
|
|
527
|
+
uri: "".concat(callingClient['mobiusHost']).concat(_constants.URL_ENDPOINT, "?regionCode=").concat(_callingClientFixtures.regionBody.clientRegion, "&countryCode=").concat(_callingClientFixtures.regionBody.countryCode),
|
|
528
|
+
method: 'GET'
|
|
529
|
+
}));
|
|
530
|
+
expect(handleErrorSpy).not.toHaveBeenCalled();
|
|
531
|
+
case 2:
|
|
532
|
+
case "end":
|
|
533
|
+
return _context15.stop();
|
|
534
|
+
}
|
|
535
|
+
}, _callee15);
|
|
536
|
+
})));
|
|
537
|
+
});
|
|
538
|
+
describe('Testing each cluster present withing host catalog', function () {
|
|
539
|
+
var mobiusCluster = ['mobius-eu-central-1.prod.infra.webex.com', 'mobius-us-east-1.int.infra.webex.com', 'mobius-eu-central-1.int.infra.webex.com'];
|
|
540
|
+
var checkCluster = /*#__PURE__*/function () {
|
|
541
|
+
var _ref16 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee16(mockServiceHosts, mockCatalog) {
|
|
542
|
+
var callingClient;
|
|
543
|
+
return _regenerator.default.wrap(function (_context16) {
|
|
544
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
545
|
+
case 0:
|
|
546
|
+
webex.internal.services._hostCatalog = mockCatalog;
|
|
547
|
+
webex.internal.services.getMobiusClusters = jest.fn().mockReturnValue(mockServiceHosts);
|
|
548
|
+
_context16.next = 1;
|
|
549
|
+
return (0, _CallingClient.createClient)(webex, {
|
|
550
|
+
logger: {
|
|
551
|
+
level: _types.LOGGER.INFO
|
|
552
|
+
}
|
|
553
|
+
});
|
|
554
|
+
case 1:
|
|
555
|
+
callingClient = _context16.sent;
|
|
556
|
+
expect(callingClient['mobiusClusters']).toStrictEqual(mockServiceHosts);
|
|
557
|
+
case 2:
|
|
558
|
+
case "end":
|
|
559
|
+
return _context16.stop();
|
|
560
|
+
}
|
|
561
|
+
}, _callee16);
|
|
562
|
+
}));
|
|
563
|
+
return function checkCluster(_x, _x2) {
|
|
564
|
+
return _ref16.apply(this, arguments);
|
|
565
|
+
};
|
|
566
|
+
}();
|
|
567
|
+
it.each(mobiusCluster)('%s', /*#__PURE__*/function () {
|
|
568
|
+
var _ref17 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee17(clusterName) {
|
|
569
|
+
var _t4;
|
|
570
|
+
return _regenerator.default.wrap(function (_context17) {
|
|
571
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
572
|
+
case 0:
|
|
573
|
+
_t4 = clusterName;
|
|
574
|
+
_context17.next = _t4 === 'mobius-eu-central-1.prod.infra.webex.com' ? 1 : _t4 === 'mobius-us-east-1.int.infra.webex.com' ? 2 : _t4 === 'mobius-eu-central-1.int.infra.webex.com' ? 3 : 4;
|
|
575
|
+
break;
|
|
576
|
+
case 1:
|
|
577
|
+
checkCluster(_callingClientFixtures.mockEUServiceHosts, _callingClientFixtures.mockCatalogEU);
|
|
578
|
+
return _context17.abrupt("continue", 5);
|
|
579
|
+
case 2:
|
|
580
|
+
checkCluster(_callingClientFixtures.mockIntServiceHosts, _callingClientFixtures.mockCatalogUSInt);
|
|
581
|
+
return _context17.abrupt("continue", 5);
|
|
582
|
+
case 3:
|
|
583
|
+
checkCluster(_callingClientFixtures.mockEUIntServiceHosts, _callingClientFixtures.mockCatalogEUInt);
|
|
584
|
+
return _context17.abrupt("continue", 5);
|
|
585
|
+
case 4:
|
|
586
|
+
return _context17.abrupt("continue", 5);
|
|
587
|
+
case 5:
|
|
588
|
+
case "end":
|
|
589
|
+
return _context17.stop();
|
|
590
|
+
}
|
|
591
|
+
}, _callee17);
|
|
592
|
+
}));
|
|
593
|
+
return function (_x3) {
|
|
594
|
+
return _ref17.apply(this, arguments);
|
|
595
|
+
};
|
|
596
|
+
}());
|
|
597
|
+
});
|
|
598
|
+
describe('Line creation tests', function () {
|
|
599
|
+
var callingClient;
|
|
600
|
+
var line;
|
|
601
|
+
beforeEach(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee18() {
|
|
602
|
+
return _regenerator.default.wrap(function (_context18) {
|
|
603
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
604
|
+
case 0:
|
|
605
|
+
_context18.next = 1;
|
|
606
|
+
return (0, _CallingClient.createClient)(webex);
|
|
607
|
+
case 1:
|
|
608
|
+
callingClient = _context18.sent;
|
|
609
|
+
line = (0, _values.default)(callingClient.lineDict)[0];
|
|
610
|
+
case 2:
|
|
611
|
+
case "end":
|
|
612
|
+
return _context18.stop();
|
|
613
|
+
}
|
|
614
|
+
}, _callee18);
|
|
615
|
+
})));
|
|
616
|
+
afterEach(function () {
|
|
617
|
+
jest.clearAllTimers();
|
|
618
|
+
jest.clearAllMocks();
|
|
619
|
+
callingClient.removeAllListeners();
|
|
620
|
+
callManager.removeAllListeners();
|
|
621
|
+
callingClient = undefined;
|
|
622
|
+
jest.useRealTimers();
|
|
623
|
+
});
|
|
624
|
+
it('verify line dict successfully created', function () {
|
|
625
|
+
expect(callingClient.lineDict).toBeTruthy();
|
|
626
|
+
expect(line).toBeTruthy();
|
|
627
|
+
expect((0, _keys.default)(callingClient.lineDict).length).toEqual(1);
|
|
628
|
+
});
|
|
629
|
+
it('verify getLines response', function () {
|
|
630
|
+
expect(callingClient.getLines).toBeTruthy();
|
|
631
|
+
expect(callingClient.getLines()).toEqual(callingClient.lineDict);
|
|
632
|
+
});
|
|
633
|
+
});
|
|
634
|
+
describe('Connectivity and Mercury event handlers', function () {
|
|
635
|
+
var callingClient;
|
|
636
|
+
var line;
|
|
637
|
+
var reg;
|
|
638
|
+
var windowEventSpy;
|
|
639
|
+
var deRegSpy;
|
|
640
|
+
var restoreSpy;
|
|
641
|
+
var restartRegisterSpy;
|
|
642
|
+
var registerSpy;
|
|
643
|
+
var metricSpy;
|
|
644
|
+
beforeEach(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee19() {
|
|
645
|
+
return _regenerator.default.wrap(function (_context19) {
|
|
646
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
647
|
+
case 0:
|
|
648
|
+
jest.useFakeTimers();
|
|
649
|
+
webex.request.mockResolvedValueOnce(_callingClientFixtures.regionPayload).mockResolvedValueOnce(_callingClientFixtures.discoveryPayload).mockResolvedValueOnce(_callingClientFixtures.registrationPayload);
|
|
650
|
+
windowEventSpy = jest.spyOn(window, 'addEventListener');
|
|
651
|
+
_context19.next = 1;
|
|
652
|
+
return (0, _CallingClient.createClient)(webex, {
|
|
653
|
+
logger: {
|
|
654
|
+
level: _types.LOGGER.INFO
|
|
655
|
+
}
|
|
656
|
+
});
|
|
657
|
+
case 1:
|
|
658
|
+
callingClient = _context19.sent;
|
|
659
|
+
line = (0, _values.default)(callingClient.lineDict)[0];
|
|
660
|
+
reg = line.registration;
|
|
661
|
+
_context19.next = 2;
|
|
662
|
+
return line.register();
|
|
663
|
+
case 2:
|
|
664
|
+
deRegSpy = jest.spyOn(reg, 'deregister');
|
|
665
|
+
restoreSpy = jest.spyOn(reg, 'restorePreviousRegistration');
|
|
666
|
+
restartRegisterSpy = jest.spyOn(reg, 'restartRegistration');
|
|
667
|
+
registerSpy = jest.spyOn(reg, 'attemptRegistrationWithServers');
|
|
668
|
+
metricSpy = jest.spyOn(callingClient['metricManager'], 'submitConnectionMetrics');
|
|
669
|
+
case 3:
|
|
670
|
+
case "end":
|
|
671
|
+
return _context19.stop();
|
|
672
|
+
}
|
|
673
|
+
}, _callee19);
|
|
674
|
+
})));
|
|
675
|
+
afterEach(function () {
|
|
676
|
+
jest.clearAllTimers();
|
|
677
|
+
jest.clearAllMocks();
|
|
678
|
+
callingClient.removeAllListeners();
|
|
679
|
+
callingClient['callManager'].callCollection = {};
|
|
680
|
+
callManager.removeAllListeners();
|
|
681
|
+
callingClient = undefined;
|
|
682
|
+
jest.useRealTimers();
|
|
683
|
+
});
|
|
684
|
+
it('window offline handler sets networkDown and clears keepalive when network is unreachable', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee20() {
|
|
685
|
+
var g, clearKeepaliveSpy, offlineCb;
|
|
686
|
+
return _regenerator.default.wrap(function (_context20) {
|
|
687
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
688
|
+
case 0:
|
|
689
|
+
g = global;
|
|
690
|
+
g.fetch = jest.fn().mockRejectedValueOnce(new Error('network fail'));
|
|
691
|
+
clearKeepaliveSpy = jest.spyOn(reg, 'clearKeepaliveTimer');
|
|
692
|
+
offlineCb = windowEventSpy.mock.calls[1][1];
|
|
693
|
+
_context20.next = 1;
|
|
694
|
+
return offlineCb();
|
|
695
|
+
case 1:
|
|
696
|
+
expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining('Network connectivity probe failed'), {
|
|
697
|
+
file: _constants.CALLING_CLIENT_FILE,
|
|
698
|
+
method: 'pingExternal'
|
|
699
|
+
});
|
|
700
|
+
expect(callingClient['isNetworkDown']).toBe(true);
|
|
701
|
+
expect(clearKeepaliveSpy).toHaveBeenCalled();
|
|
702
|
+
case 2:
|
|
703
|
+
case "end":
|
|
704
|
+
return _context20.stop();
|
|
705
|
+
}
|
|
706
|
+
}, _callee20);
|
|
707
|
+
})));
|
|
708
|
+
it('window offline handler does not clear keepalive when network is reachable', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee21() {
|
|
709
|
+
var g, clearKeepaliveSpy, offlineCb;
|
|
710
|
+
return _regenerator.default.wrap(function (_context21) {
|
|
711
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
712
|
+
case 0:
|
|
713
|
+
g = global;
|
|
714
|
+
g.fetch = jest.fn().mockResolvedValueOnce({});
|
|
715
|
+
clearKeepaliveSpy = jest.spyOn(reg, 'clearKeepaliveTimer');
|
|
716
|
+
offlineCb = windowEventSpy.mock.calls[1][1];
|
|
717
|
+
_context21.next = 1;
|
|
718
|
+
return offlineCb();
|
|
719
|
+
case 1:
|
|
720
|
+
expect(g.fetch).toHaveBeenCalledWith('https://www.google.com/generate_204', expect.any(Object));
|
|
721
|
+
expect(callingClient['isNetworkDown']).toBe(false);
|
|
722
|
+
expect(clearKeepaliveSpy).not.toHaveBeenCalled();
|
|
723
|
+
case 2:
|
|
724
|
+
case "end":
|
|
725
|
+
return _context21.stop();
|
|
726
|
+
}
|
|
727
|
+
}, _callee21);
|
|
728
|
+
})));
|
|
729
|
+
it('window online handler sets networkUpTimestamp and logs', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee22() {
|
|
730
|
+
var onlineCb;
|
|
731
|
+
return _regenerator.default.wrap(function (_context22) {
|
|
732
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
733
|
+
case 0:
|
|
734
|
+
onlineCb = windowEventSpy.mock.calls[0][1];
|
|
735
|
+
_context22.next = 1;
|
|
736
|
+
return onlineCb();
|
|
737
|
+
case 1:
|
|
738
|
+
expect(callingClient['networkUpTimestamp']).toEqual(expect.any(String));
|
|
739
|
+
expect(infoSpy).toHaveBeenCalledWith(_constants2.METHOD_START_MESSAGE, {
|
|
740
|
+
file: _constants.CALLING_CLIENT_FILE,
|
|
741
|
+
method: 'handleNetworkOnline'
|
|
742
|
+
});
|
|
743
|
+
case 2:
|
|
744
|
+
case "end":
|
|
745
|
+
return _context22.stop();
|
|
746
|
+
}
|
|
747
|
+
}, _callee22);
|
|
748
|
+
})));
|
|
749
|
+
it('mercury offline submits metrics and sets timestamp', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee23() {
|
|
750
|
+
var mercuryOfflineCb;
|
|
751
|
+
return _regenerator.default.wrap(function (_context23) {
|
|
752
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
753
|
+
case 0:
|
|
754
|
+
mercuryOfflineCb = webex.internal.mercury.on.mock.calls[1][1];
|
|
755
|
+
_context23.next = 1;
|
|
756
|
+
return mercuryOfflineCb();
|
|
757
|
+
case 1:
|
|
758
|
+
expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining('Mercury down, waiting for connection to be up'), {
|
|
759
|
+
file: _constants.CALLING_CLIENT_FILE,
|
|
760
|
+
method: 'handleMercuryOffline'
|
|
761
|
+
});
|
|
762
|
+
expect(callingClient['mercuryDownTimestamp']).toEqual(expect.any(String));
|
|
763
|
+
expect(metricSpy).toHaveBeenCalledWith(_types4.METRIC_EVENT.CONNECTION_ERROR, _types4.CONNECTION_ACTION.MERCURY_DOWN, _types4.METRIC_TYPE.BEHAVIORAL, expect.any(String), '');
|
|
764
|
+
case 2:
|
|
765
|
+
case "end":
|
|
766
|
+
return _context23.stop();
|
|
767
|
+
}
|
|
768
|
+
}, _callee23);
|
|
769
|
+
})));
|
|
770
|
+
it('handles reconnection with no active calls after network flap, once mercury comes back up', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee24() {
|
|
771
|
+
var handleConnectionRestoreSpy, mercuryOnlineCb;
|
|
772
|
+
return _regenerator.default.wrap(function (_context24) {
|
|
773
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
774
|
+
case 0:
|
|
775
|
+
handleConnectionRestoreSpy = jest.spyOn(reg, 'handleConnectionRestoration');
|
|
776
|
+
callingClient['isNetworkDown'] = true;
|
|
777
|
+
callingClient['networkDownTimestamp'] = '2023-01-01T00:00:00.000Z';
|
|
778
|
+
callingClient['networkUpTimestamp'] = '2023-01-01T00:01:00.000Z';
|
|
779
|
+
mercuryOnlineCb = webex.internal.mercury.on.mock.calls[2][1];
|
|
780
|
+
_context24.next = 1;
|
|
781
|
+
return mercuryOnlineCb();
|
|
782
|
+
case 1:
|
|
783
|
+
// Run the interval once
|
|
784
|
+
jest.advanceTimersByTime(_constants.NETWORK_FLAP_TIMEOUT + 100);
|
|
785
|
+
_context24.next = 2;
|
|
786
|
+
return flushPromises();
|
|
787
|
+
case 2:
|
|
788
|
+
expect(handleConnectionRestoreSpy).toHaveBeenCalledWith(true);
|
|
789
|
+
expect(logSpy).toHaveBeenCalledWith('Network is up again, re-registering with Webex Calling if needed', {
|
|
790
|
+
file: _constants.REGISTRATION_FILE,
|
|
791
|
+
method: 'handleConnectionRestoration'
|
|
792
|
+
});
|
|
793
|
+
expect(deRegSpy).toHaveBeenCalledWith();
|
|
794
|
+
expect(restoreSpy).toHaveBeenCalledWith('handleConnectionRestoration');
|
|
795
|
+
expect(restartRegisterSpy).toHaveBeenCalledWith('handleConnectionRestoration');
|
|
796
|
+
expect(registerSpy).toHaveBeenCalledWith('handleConnectionRestoration', [reg.getActiveMobiusUrl()]);
|
|
797
|
+
expect(registerSpy).toHaveBeenCalledWith('handleConnectionRestoration', [_callingClientFixtures.primaryUrl]);
|
|
798
|
+
expect(metricSpy).toHaveBeenCalledWith(_types4.METRIC_EVENT.CONNECTION_ERROR, _types4.CONNECTION_ACTION.NETWORK_FLAP, _types4.METRIC_TYPE.BEHAVIORAL, '2023-01-01T00:00:00.000Z', '2023-01-01T00:01:00.000Z');
|
|
799
|
+
case 3:
|
|
800
|
+
case "end":
|
|
801
|
+
return _context24.stop();
|
|
802
|
+
}
|
|
803
|
+
}, _callee24);
|
|
804
|
+
})));
|
|
805
|
+
it('no reconnection for idle registration with no active calls after network flap, once mercury comes back up', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee25() {
|
|
806
|
+
var handleConnectionRestoreSpy, mercuryOnlineCb;
|
|
807
|
+
return _regenerator.default.wrap(function (_context25) {
|
|
808
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
809
|
+
case 0:
|
|
810
|
+
handleConnectionRestoreSpy = jest.spyOn(reg, 'handleConnectionRestoration');
|
|
811
|
+
callingClient['isNetworkDown'] = true;
|
|
812
|
+
callingClient['networkDownTimestamp'] = '2023-01-01T00:00:00.000Z';
|
|
813
|
+
callingClient['networkUpTimestamp'] = '2023-01-01T00:01:00.000Z';
|
|
814
|
+
reg.setStatus(_types2.RegistrationStatus.IDLE);
|
|
815
|
+
mercuryOnlineCb = webex.internal.mercury.on.mock.calls[2][1];
|
|
816
|
+
_context25.next = 1;
|
|
817
|
+
return mercuryOnlineCb();
|
|
818
|
+
case 1:
|
|
819
|
+
// Run the interval once
|
|
820
|
+
jest.advanceTimersByTime(_constants.NETWORK_FLAP_TIMEOUT + 100);
|
|
821
|
+
_context25.next = 2;
|
|
822
|
+
return flushPromises();
|
|
823
|
+
case 2:
|
|
824
|
+
expect(handleConnectionRestoreSpy).not.toHaveBeenCalledWith(true);
|
|
825
|
+
expect(logSpy).not.toHaveBeenCalledWith('Network is up again, re-registering with Webex Calling if needed', {
|
|
826
|
+
file: _constants.REGISTRATION_FILE,
|
|
827
|
+
method: 'handleConnectionRestoration'
|
|
828
|
+
});
|
|
829
|
+
expect(deRegSpy).not.toHaveBeenCalledWith();
|
|
830
|
+
expect(restoreSpy).not.toHaveBeenCalledWith('handleConnectionRestoration');
|
|
831
|
+
expect(restartRegisterSpy).not.toHaveBeenCalledWith('handleConnectionRestoration');
|
|
832
|
+
expect(registerSpy).not.toHaveBeenCalledWith('handleConnectionRestoration', [reg.getActiveMobiusUrl()]);
|
|
833
|
+
expect(registerSpy).not.toHaveBeenCalledWith('handleConnectionRestoration', [_callingClientFixtures.primaryUrl]);
|
|
834
|
+
expect(metricSpy).toHaveBeenCalledWith(_types4.METRIC_EVENT.CONNECTION_ERROR, _types4.CONNECTION_ACTION.NETWORK_FLAP, _types4.METRIC_TYPE.BEHAVIORAL, '2023-01-01T00:00:00.000Z', '2023-01-01T00:01:00.000Z');
|
|
835
|
+
case 3:
|
|
836
|
+
case "end":
|
|
837
|
+
return _context25.stop();
|
|
838
|
+
}
|
|
839
|
+
}, _callee25);
|
|
840
|
+
})));
|
|
841
|
+
it('handle calls status check once mercury comes back up after a network flap', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee26() {
|
|
842
|
+
var call, callKeepaliveSpy, deleteSpy, mercuryOnlineCb;
|
|
843
|
+
return _regenerator.default.wrap(function (_context26) {
|
|
844
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
845
|
+
case 0:
|
|
846
|
+
callingClient['isNetworkDown'] = true;
|
|
847
|
+
call = callingClient['callManager'].createCall();
|
|
848
|
+
callKeepaliveSpy = jest.spyOn(call, 'postStatus').mockRejectedValueOnce(new Error('keepalive fail'));
|
|
849
|
+
deleteSpy = jest.spyOn(call, 'delete');
|
|
850
|
+
expect((0, _keys.default)(callingClient['callManager'].getActiveCalls()).length).toBe(1);
|
|
851
|
+
mercuryOnlineCb = webex.internal.mercury.on.mock.calls[2][1];
|
|
852
|
+
_context26.next = 1;
|
|
853
|
+
return mercuryOnlineCb();
|
|
854
|
+
case 1:
|
|
855
|
+
expect(callKeepaliveSpy).toHaveBeenCalled();
|
|
856
|
+
_context26.next = 2;
|
|
857
|
+
return flushPromises();
|
|
858
|
+
case 2:
|
|
859
|
+
expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining('Call Keepalive failed'), {
|
|
860
|
+
file: _constants.CALLING_CLIENT_FILE,
|
|
861
|
+
method: 'checkCallStatus'
|
|
862
|
+
});
|
|
863
|
+
expect(call['callStateMachine'].state.value).toBe('S_CALL_CLEARED');
|
|
864
|
+
expect(deleteSpy).toHaveBeenCalled();
|
|
865
|
+
expect((0, _keys.default)(reg.callManager.getActiveCalls()).length).toBe(0);
|
|
866
|
+
expect(metricSpy).toHaveBeenCalledWith(_types4.METRIC_EVENT.CONNECTION_ERROR, _types4.CONNECTION_ACTION.NETWORK_FLAP, _types4.METRIC_TYPE.BEHAVIORAL, expect.any(String), expect.any(String));
|
|
867
|
+
case 3:
|
|
868
|
+
case "end":
|
|
869
|
+
return _context26.stop();
|
|
870
|
+
}
|
|
871
|
+
}, _callee26);
|
|
872
|
+
})));
|
|
873
|
+
it('handle calls status check once mercury comes back up with stable network', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee27() {
|
|
874
|
+
var call, callKeepaliveSpy, deleteSpy, mercuryOnlineCb;
|
|
875
|
+
return _regenerator.default.wrap(function (_context27) {
|
|
876
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
877
|
+
case 0:
|
|
878
|
+
call = callingClient['callManager'].createCall();
|
|
879
|
+
callKeepaliveSpy = jest.spyOn(call, 'postStatus').mockRejectedValueOnce(new Error('keepalive fail'));
|
|
880
|
+
deleteSpy = jest.spyOn(call, 'delete');
|
|
881
|
+
expect((0, _keys.default)(callingClient['callManager'].getActiveCalls()).length).toBe(1);
|
|
882
|
+
mercuryOnlineCb = webex.internal.mercury.on.mock.calls[2][1];
|
|
883
|
+
_context27.next = 1;
|
|
884
|
+
return mercuryOnlineCb();
|
|
885
|
+
case 1:
|
|
886
|
+
expect(callKeepaliveSpy).toHaveBeenCalled();
|
|
887
|
+
_context27.next = 2;
|
|
888
|
+
return flushPromises();
|
|
889
|
+
case 2:
|
|
890
|
+
expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining('Call Keepalive failed'), {
|
|
891
|
+
file: _constants.CALLING_CLIENT_FILE,
|
|
892
|
+
method: 'checkCallStatus'
|
|
893
|
+
});
|
|
894
|
+
expect(call['callStateMachine'].state.value).toBe('S_CALL_CLEARED');
|
|
895
|
+
expect(deleteSpy).toHaveBeenCalled();
|
|
896
|
+
expect((0, _keys.default)(reg.callManager.getActiveCalls()).length).toBe(0);
|
|
897
|
+
expect(metricSpy).toHaveBeenCalledWith(_types4.METRIC_EVENT.CONNECTION_ERROR, _types4.CONNECTION_ACTION.MERCURY_UP, _types4.METRIC_TYPE.BEHAVIORAL, expect.any(String), expect.any(String));
|
|
898
|
+
case 3:
|
|
899
|
+
case "end":
|
|
900
|
+
return _context27.stop();
|
|
901
|
+
}
|
|
902
|
+
}, _callee27);
|
|
903
|
+
})));
|
|
904
|
+
});
|
|
905
|
+
|
|
906
|
+
// Calling related test cases
|
|
907
|
+
describe('Calling tests', function () {
|
|
908
|
+
var mutex = new _asyncMutex.Mutex();
|
|
909
|
+
var userId = webex.internal.device.userId;
|
|
910
|
+
var clientDeviceUri = webex.internal.device.url;
|
|
911
|
+
var mobiusUris = (0, _Utils.filterMobiusUris)((0, _testUtil.getMobiusDiscoveryResponse)(), _registerFixtures.URL);
|
|
912
|
+
var primaryMobiusUris = jest.fn(function () {
|
|
913
|
+
return mobiusUris.primary;
|
|
914
|
+
});
|
|
915
|
+
var backupMobiusUris = jest.fn(function () {
|
|
916
|
+
return mobiusUris.backup;
|
|
917
|
+
});
|
|
918
|
+
var callingClient;
|
|
919
|
+
var line;
|
|
920
|
+
beforeAll(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee28() {
|
|
921
|
+
var calls;
|
|
922
|
+
return _regenerator.default.wrap(function (_context28) {
|
|
923
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
924
|
+
case 0:
|
|
925
|
+
_context28.next = 1;
|
|
926
|
+
return (0, _CallingClient.createClient)(webex);
|
|
927
|
+
case 1:
|
|
928
|
+
callingClient = _context28.sent;
|
|
929
|
+
line = new _line.default(userId, clientDeviceUri, mutex, primaryMobiusUris(), backupMobiusUris(), _types.LOGGER.INFO);
|
|
930
|
+
calls = (0, _values.default)(callManager.getActiveCalls());
|
|
931
|
+
calls.forEach(function (call) {
|
|
932
|
+
call.end();
|
|
933
|
+
});
|
|
934
|
+
case 2:
|
|
935
|
+
case "end":
|
|
936
|
+
return _context28.stop();
|
|
937
|
+
}
|
|
938
|
+
}, _callee28);
|
|
939
|
+
})));
|
|
940
|
+
afterAll(function () {
|
|
941
|
+
callingClient.removeAllListeners();
|
|
942
|
+
callManager.removeAllListeners();
|
|
943
|
+
});
|
|
944
|
+
it('verify calling client object', function () {
|
|
945
|
+
expect(callingClient.getSDKConnector().getWebex().internal.device.userId).toBe('8a67806f-fc4d-446b-a131-31e71ea5b0e9');
|
|
946
|
+
});
|
|
947
|
+
it('returns undefined when there is no connected call', function () {
|
|
948
|
+
line.register();
|
|
949
|
+
line.makeCall({
|
|
950
|
+
address: '123456',
|
|
951
|
+
type: _types2.CallType.URI
|
|
952
|
+
});
|
|
953
|
+
expect(callingClient.getConnectedCall()).toEqual(undefined);
|
|
954
|
+
});
|
|
955
|
+
it('returns the connected call', function () {
|
|
956
|
+
line.register();
|
|
957
|
+
var mockCall = line.makeCall({
|
|
958
|
+
address: '1234',
|
|
959
|
+
type: _types2.CallType.URI
|
|
960
|
+
});
|
|
961
|
+
var mockCall2 = line.makeCall({
|
|
962
|
+
address: '5678',
|
|
963
|
+
type: _types2.CallType.URI
|
|
964
|
+
});
|
|
965
|
+
// Connected call
|
|
966
|
+
mockCall['connected'] = true;
|
|
967
|
+
mockCall['earlyMedia'] = false;
|
|
968
|
+
mockCall['callStateMachine'].state.value = 'S_CALL_ESTABLISHED';
|
|
969
|
+
|
|
970
|
+
// Held call
|
|
971
|
+
mockCall2['connected'] = true;
|
|
972
|
+
mockCall2['held'] = true;
|
|
973
|
+
mockCall2['earlyMedia'] = false;
|
|
974
|
+
mockCall2['callStateMachine'].state.value = 'S_CALL_HOLD';
|
|
975
|
+
var mockActiveCalls = {
|
|
976
|
+
mockCorrelationId: mockCall,
|
|
977
|
+
mockCorrelationId2: mockCall2
|
|
978
|
+
};
|
|
979
|
+
jest.spyOn(callManager, 'getActiveCalls').mockReturnValue(mockActiveCalls);
|
|
980
|
+
expect(callingClient.getConnectedCall()).toEqual(mockCall);
|
|
981
|
+
});
|
|
982
|
+
it('returns all active calls', function () {
|
|
983
|
+
callingClient.lineDict = {
|
|
984
|
+
mockDeviceId: {
|
|
985
|
+
lineId: 'mockLineId'
|
|
986
|
+
},
|
|
987
|
+
mockDeviceId2: {
|
|
988
|
+
lineId: 'mockLineId2'
|
|
989
|
+
}
|
|
990
|
+
};
|
|
991
|
+
var mockCall = line.makeCall({
|
|
992
|
+
address: '1234',
|
|
993
|
+
type: _types2.CallType.URI
|
|
994
|
+
});
|
|
995
|
+
var mockCall2 = line.makeCall({
|
|
996
|
+
address: '5678',
|
|
997
|
+
type: _types2.CallType.URI
|
|
998
|
+
});
|
|
999
|
+
var mockCall3 = line.makeCall({
|
|
1000
|
+
address: '9101',
|
|
1001
|
+
type: _types2.CallType.URI
|
|
1002
|
+
});
|
|
1003
|
+
mockCall.lineId = 'mockLineId';
|
|
1004
|
+
mockCall2.lineId = 'mockLineId2';
|
|
1005
|
+
mockCall3.lineId = 'mockLineId2';
|
|
1006
|
+
var mockActiveCalls = {
|
|
1007
|
+
mockCorrelationId: mockCall,
|
|
1008
|
+
mockCorrelationId2: mockCall2,
|
|
1009
|
+
mockCorrelationId3: mockCall3
|
|
1010
|
+
};
|
|
1011
|
+
jest.spyOn(callManager, 'getActiveCalls').mockReturnValue(mockActiveCalls);
|
|
1012
|
+
expect(callingClient.getActiveCalls()).toEqual({
|
|
1013
|
+
mockLineId: [mockCall],
|
|
1014
|
+
mockLineId2: [mockCall2, mockCall3]
|
|
1015
|
+
});
|
|
1016
|
+
});
|
|
1017
|
+
});
|
|
1018
|
+
describe('Call Session Event test', function () {
|
|
1019
|
+
var mockOn = webex.internal.mercury.on;
|
|
1020
|
+
var callingClient;
|
|
1021
|
+
beforeEach(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee29() {
|
|
1022
|
+
return _regenerator.default.wrap(function (_context29) {
|
|
1023
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
1024
|
+
case 0:
|
|
1025
|
+
_context29.next = 1;
|
|
1026
|
+
return (0, _CallingClient.createClient)(webex, {
|
|
1027
|
+
logger: {
|
|
1028
|
+
level: _types.LOGGER.INFO
|
|
1029
|
+
}
|
|
1030
|
+
});
|
|
1031
|
+
case 1:
|
|
1032
|
+
callingClient = _context29.sent;
|
|
1033
|
+
case 2:
|
|
1034
|
+
case "end":
|
|
1035
|
+
return _context29.stop();
|
|
1036
|
+
}
|
|
1037
|
+
}, _callee29);
|
|
1038
|
+
})));
|
|
1039
|
+
afterEach(function () {
|
|
1040
|
+
callingClient.removeAllListeners();
|
|
1041
|
+
callManager.removeAllListeners();
|
|
1042
|
+
});
|
|
1043
|
+
it('verify the recent user session event ', function (done) {
|
|
1044
|
+
expect.assertions(2);
|
|
1045
|
+
callingClient.on(_types3.CALLING_CLIENT_EVENT_KEYS.USER_SESSION_INFO, function (event) {
|
|
1046
|
+
expect(event.data).toEqual(_callRecordFixtures.MOCK_SESSION_EVENT.data);
|
|
1047
|
+
done();
|
|
1048
|
+
});
|
|
1049
|
+
expect(mockOn.mock.calls[0][0]).toEqual(_types3.MOBIUS_EVENT_KEYS.CALL_SESSION_EVENT_INCLUSIVE);
|
|
1050
|
+
var callSessionCallback = mockOn.mock.calls[0][1];
|
|
1051
|
+
callSessionCallback(_callRecordFixtures.MOCK_SESSION_EVENT);
|
|
1052
|
+
});
|
|
1053
|
+
it('drop the recent user session if there is no webex calling type', function (done) {
|
|
1054
|
+
expect.assertions(2);
|
|
1055
|
+
callingClient.on(_types3.CALLING_CLIENT_EVENT_KEYS.USER_SESSION_INFO, function (event) {
|
|
1056
|
+
expect(event.data.userSessions.userSessions.length).toEqual(1);
|
|
1057
|
+
done();
|
|
1058
|
+
});
|
|
1059
|
+
expect(mockOn.mock.calls[0][0]).toEqual(_types3.MOBIUS_EVENT_KEYS.CALL_SESSION_EVENT_INCLUSIVE);
|
|
1060
|
+
var callSessionCallback = mockOn.mock.calls[0][1];
|
|
1061
|
+
callSessionCallback(_callRecordFixtures.MOCK_MULTIPLE_SESSIONS_EVENT);
|
|
1062
|
+
});
|
|
1063
|
+
});
|
|
1064
|
+
describe('getDevices', function () {
|
|
1065
|
+
var callingClient;
|
|
1066
|
+
var primaryMobius = 'https://mobius.primary/api/v1/calling/web/';
|
|
1067
|
+
var backupMobius = 'https://mobius.backup/api/v1/calling/web/';
|
|
1068
|
+
beforeEach(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee30() {
|
|
1069
|
+
return _regenerator.default.wrap(function (_context30) {
|
|
1070
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
1071
|
+
case 0:
|
|
1072
|
+
_context30.next = 1;
|
|
1073
|
+
return (0, _CallingClient.createClient)(webex, {
|
|
1074
|
+
logger: {
|
|
1075
|
+
level: _types.LOGGER.INFO
|
|
1076
|
+
}
|
|
1077
|
+
});
|
|
1078
|
+
case 1:
|
|
1079
|
+
callingClient = _context30.sent;
|
|
1080
|
+
callingClient.primaryMobiusUris = [primaryMobius];
|
|
1081
|
+
callingClient.backupMobiusUris = [backupMobius];
|
|
1082
|
+
webex.request.mockClear();
|
|
1083
|
+
case 2:
|
|
1084
|
+
case "end":
|
|
1085
|
+
return _context30.stop();
|
|
1086
|
+
}
|
|
1087
|
+
}, _callee30);
|
|
1088
|
+
})));
|
|
1089
|
+
afterEach(function () {
|
|
1090
|
+
callingClient.removeAllListeners();
|
|
1091
|
+
});
|
|
1092
|
+
it('fetches devices for the provided userId', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee31() {
|
|
1093
|
+
var devices, responsePayload, response;
|
|
1094
|
+
return _regenerator.default.wrap(function (_context31) {
|
|
1095
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
1096
|
+
case 0:
|
|
1097
|
+
devices = [{
|
|
1098
|
+
deviceId: 'device-1',
|
|
1099
|
+
uri: 'https://mobius.test/api/v1/calling/web/devices/device-1',
|
|
1100
|
+
status: 'ACTIVE',
|
|
1101
|
+
lastSeen: '2024-01-01T00:00:00Z',
|
|
1102
|
+
addresses: [],
|
|
1103
|
+
clientDeviceUri: 'client-device-uri'
|
|
1104
|
+
}];
|
|
1105
|
+
responsePayload = {
|
|
1106
|
+
statusCode: 200,
|
|
1107
|
+
body: {
|
|
1108
|
+
userId: 'user-123',
|
|
1109
|
+
devices: devices
|
|
1110
|
+
}
|
|
1111
|
+
};
|
|
1112
|
+
webex.request.mockResolvedValue(responsePayload);
|
|
1113
|
+
_context31.next = 1;
|
|
1114
|
+
return callingClient.getDevices('user-123');
|
|
1115
|
+
case 1:
|
|
1116
|
+
response = _context31.sent;
|
|
1117
|
+
expect(webex.request).toHaveBeenCalledWith({
|
|
1118
|
+
uri: 'https://mobius.primary/api/v1/calling/web/devices?userid=user-123',
|
|
1119
|
+
method: _types2.HTTP_METHODS.GET,
|
|
1120
|
+
service: _types2.ALLOWED_SERVICES.MOBIUS,
|
|
1121
|
+
headers: (0, _defineProperty2.default)((0, _defineProperty2.default)({}, _constants.CISCO_DEVICE_URL, webex.internal.device.url), _constants.SPARK_USER_AGENT, _constants.CALLING_USER_AGENT)
|
|
1122
|
+
});
|
|
1123
|
+
expect(response).toEqual(devices);
|
|
1124
|
+
case 2:
|
|
1125
|
+
case "end":
|
|
1126
|
+
return _context31.stop();
|
|
1127
|
+
}
|
|
1128
|
+
}, _callee31);
|
|
1129
|
+
})));
|
|
1130
|
+
it('falls back to backup Mobius when primary fails', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee32() {
|
|
1131
|
+
var devices, failurePayload, responsePayload, response, requestCalls;
|
|
1132
|
+
return _regenerator.default.wrap(function (_context32) {
|
|
1133
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
1134
|
+
case 0:
|
|
1135
|
+
devices = [{
|
|
1136
|
+
deviceId: 'device-2',
|
|
1137
|
+
uri: 'https://mobius.backup/api/v1/calling/web/devices/device-2',
|
|
1138
|
+
status: 'ACTIVE',
|
|
1139
|
+
lastSeen: '2024-01-01T00:00:00Z',
|
|
1140
|
+
addresses: [],
|
|
1141
|
+
clientDeviceUri: 'client-device-uri'
|
|
1142
|
+
}];
|
|
1143
|
+
failurePayload = {
|
|
1144
|
+
statusCode: 404
|
|
1145
|
+
};
|
|
1146
|
+
responsePayload = {
|
|
1147
|
+
statusCode: 200,
|
|
1148
|
+
body: {
|
|
1149
|
+
userId: 'user-123',
|
|
1150
|
+
devices: devices
|
|
1151
|
+
}
|
|
1152
|
+
};
|
|
1153
|
+
webex.request.mockRejectedValueOnce(failurePayload).mockResolvedValueOnce(responsePayload);
|
|
1154
|
+
_context32.next = 1;
|
|
1155
|
+
return callingClient.getDevices('user-123');
|
|
1156
|
+
case 1:
|
|
1157
|
+
response = _context32.sent;
|
|
1158
|
+
requestCalls = webex.request.mock.calls;
|
|
1159
|
+
expect(requestCalls[0][0]).toEqual({
|
|
1160
|
+
uri: 'https://mobius.primary/api/v1/calling/web/devices?userid=user-123',
|
|
1161
|
+
method: _types2.HTTP_METHODS.GET,
|
|
1162
|
+
service: _types2.ALLOWED_SERVICES.MOBIUS,
|
|
1163
|
+
headers: (0, _defineProperty2.default)((0, _defineProperty2.default)({}, _constants.CISCO_DEVICE_URL, webex.internal.device.url), _constants.SPARK_USER_AGENT, _constants.CALLING_USER_AGENT)
|
|
1164
|
+
});
|
|
1165
|
+
expect(requestCalls[1][0]).toEqual({
|
|
1166
|
+
uri: 'https://mobius.backup/api/v1/calling/web/devices?userid=user-123',
|
|
1167
|
+
method: _types2.HTTP_METHODS.GET,
|
|
1168
|
+
service: _types2.ALLOWED_SERVICES.MOBIUS,
|
|
1169
|
+
headers: (0, _defineProperty2.default)((0, _defineProperty2.default)({}, _constants.CISCO_DEVICE_URL, webex.internal.device.url), _constants.SPARK_USER_AGENT, _constants.CALLING_USER_AGENT)
|
|
1170
|
+
});
|
|
1171
|
+
expect(response).toEqual(devices);
|
|
1172
|
+
case 2:
|
|
1173
|
+
case "end":
|
|
1174
|
+
return _context32.stop();
|
|
1175
|
+
}
|
|
1176
|
+
}, _callee32);
|
|
1177
|
+
})));
|
|
1178
|
+
});
|
|
1179
|
+
describe('windowsChromiumIceWarmup', function () {
|
|
1180
|
+
var origRTCPeerConnection;
|
|
1181
|
+
beforeAll(function () {
|
|
1182
|
+
var _Class;
|
|
1183
|
+
origRTCPeerConnection = global.RTCPeerConnection;
|
|
1184
|
+
// Minimal mock for RTCPeerConnection
|
|
1185
|
+
global.RTCPeerConnection = (_Class = /*#__PURE__*/function () {
|
|
1186
|
+
function _Class() {
|
|
1187
|
+
(0, _classCallCheck2.default)(this, _Class);
|
|
1188
|
+
(0, _defineProperty2.default)(this, "iceGatheringState", 'complete');
|
|
1189
|
+
(0, _defineProperty2.default)(this, "localDescription", null);
|
|
1190
|
+
(0, _defineProperty2.default)(this, "remoteDescription", null);
|
|
1191
|
+
(0, _defineProperty2.default)(this, "onicecandidate", null);
|
|
1192
|
+
this.constructor.instances.push(this);
|
|
1193
|
+
}
|
|
1194
|
+
return (0, _createClass2.default)(_Class, [{
|
|
1195
|
+
key: "createDataChannel",
|
|
1196
|
+
value: function createDataChannel() {
|
|
1197
|
+
return {};
|
|
1198
|
+
}
|
|
1199
|
+
}, {
|
|
1200
|
+
key: "addTransceiver",
|
|
1201
|
+
value: function addTransceiver() {
|
|
1202
|
+
return {};
|
|
1203
|
+
}
|
|
1204
|
+
}, {
|
|
1205
|
+
key: "createOffer",
|
|
1206
|
+
value: function createOffer() {
|
|
1207
|
+
return _promise.default.resolve({
|
|
1208
|
+
sdp: 'offer',
|
|
1209
|
+
type: 'offer'
|
|
1210
|
+
});
|
|
1211
|
+
}
|
|
1212
|
+
}, {
|
|
1213
|
+
key: "setLocalDescription",
|
|
1214
|
+
value: function setLocalDescription(desc) {
|
|
1215
|
+
this.localDescription = desc;
|
|
1216
|
+
return _promise.default.resolve();
|
|
1217
|
+
}
|
|
1218
|
+
}, {
|
|
1219
|
+
key: "setRemoteDescription",
|
|
1220
|
+
value: function setRemoteDescription(desc) {
|
|
1221
|
+
this.remoteDescription = desc;
|
|
1222
|
+
return _promise.default.resolve();
|
|
1223
|
+
}
|
|
1224
|
+
}, {
|
|
1225
|
+
key: "createAnswer",
|
|
1226
|
+
value: function createAnswer() {
|
|
1227
|
+
return _promise.default.resolve({
|
|
1228
|
+
sdp: 'answer',
|
|
1229
|
+
type: 'answer'
|
|
1230
|
+
});
|
|
1231
|
+
}
|
|
1232
|
+
}, {
|
|
1233
|
+
key: "addIceCandidate",
|
|
1234
|
+
value: function addIceCandidate() {
|
|
1235
|
+
return _promise.default.resolve();
|
|
1236
|
+
}
|
|
1237
|
+
}, {
|
|
1238
|
+
key: "close",
|
|
1239
|
+
value: function close() {}
|
|
1240
|
+
}, {
|
|
1241
|
+
key: "addEventListener",
|
|
1242
|
+
value: function addEventListener() {}
|
|
1243
|
+
}, {
|
|
1244
|
+
key: "removeEventListener",
|
|
1245
|
+
value: function removeEventListener() {}
|
|
1246
|
+
}]);
|
|
1247
|
+
}(), (0, _defineProperty2.default)(_Class, "instances", []), _Class);
|
|
1248
|
+
});
|
|
1249
|
+
afterAll(function () {
|
|
1250
|
+
global.RTCPeerConnection = origRTCPeerConnection;
|
|
1251
|
+
});
|
|
1252
|
+
it('should complete without throwing', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee33() {
|
|
1253
|
+
return _regenerator.default.wrap(function (_context33) {
|
|
1254
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
1255
|
+
case 0:
|
|
1256
|
+
_context33.next = 1;
|
|
1257
|
+
return expect((0, _windowsChromiumIceWarmupUtils.default)({})).resolves.not.toThrow();
|
|
1258
|
+
case 1:
|
|
1259
|
+
case "end":
|
|
1260
|
+
return _context33.stop();
|
|
1261
|
+
}
|
|
1262
|
+
}, _callee33);
|
|
1263
|
+
})));
|
|
1264
|
+
});
|
|
1265
|
+
});
|
|
1266
|
+
//# sourceMappingURL=CallingClient.test.js.map
|