@webex/calling 3.10.0 → 3.11.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/module/CallHistory/CallHistory.js +20 -11
- package/dist/module/CallSettings/UcmBackendConnector.js +21 -8
- package/dist/module/CallSettings/WxCallBackendConnector.js +10 -15
- package/dist/module/CallingClient/CallingClient.js +83 -123
- package/dist/module/CallingClient/calling/call.js +73 -58
- package/dist/module/CallingClient/calling/callManager.js +7 -0
- package/dist/module/CallingClient/constants.js +3 -0
- package/dist/module/CallingClient/registration/register.js +85 -5
- package/dist/module/CallingClient/registration/webWorker.js +2 -2
- package/dist/module/CallingClient/registration/webWorkerStr.js +2 -2
- package/dist/module/Contacts/ContactsClient.js +19 -25
- package/dist/module/Events/impl/index.js +1 -1
- package/dist/module/Logger/index.js +2 -2
- package/dist/module/Voicemail/BroadworksBackendConnector.js +10 -18
- package/dist/module/Voicemail/UcmBackendConnector.js +7 -11
- package/dist/module/Voicemail/Voicemail.js +42 -68
- package/dist/module/Voicemail/WxCallBackendConnector.js +14 -28
- package/dist/module/common/Utils.js +31 -5
- package/dist/module/common/constants.js +2 -0
- package/dist/module/common/testUtil.js +1 -0
- package/dist/types/CallHistory/CallHistory.d.ts.map +1 -1
- package/dist/types/CallSettings/UcmBackendConnector.d.ts +1 -0
- package/dist/types/CallSettings/UcmBackendConnector.d.ts.map +1 -1
- package/dist/types/CallSettings/WxCallBackendConnector.d.ts.map +1 -1
- package/dist/types/CallingClient/CallingClient.d.ts.map +1 -1
- package/dist/types/CallingClient/calling/call.d.ts +4 -0
- package/dist/types/CallingClient/calling/call.d.ts.map +1 -1
- package/dist/types/CallingClient/calling/callManager.d.ts.map +1 -1
- package/dist/types/CallingClient/constants.d.ts +3 -0
- package/dist/types/CallingClient/constants.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/register.d.ts +4 -0
- package/dist/types/CallingClient/registration/register.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/types.d.ts +6 -0
- package/dist/types/CallingClient/registration/types.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/webWorkerStr.d.ts +1 -1
- package/dist/types/CallingClient/registration/webWorkerStr.d.ts.map +1 -1
- package/dist/types/Contacts/ContactsClient.d.ts +1 -0
- package/dist/types/Contacts/ContactsClient.d.ts.map +1 -1
- package/dist/types/Logger/index.d.ts +1 -2
- package/dist/types/Logger/index.d.ts.map +1 -1
- package/dist/types/SDKConnector/types.d.ts +16 -0
- package/dist/types/SDKConnector/types.d.ts.map +1 -1
- package/dist/types/Voicemail/BroadworksBackendConnector.d.ts.map +1 -1
- package/dist/types/Voicemail/UcmBackendConnector.d.ts.map +1 -1
- package/dist/types/Voicemail/Voicemail.d.ts.map +1 -1
- package/dist/types/Voicemail/WxCallBackendConnector.d.ts.map +1 -1
- package/dist/types/common/Utils.d.ts +1 -1
- package/dist/types/common/Utils.d.ts.map +1 -1
- package/dist/types/common/constants.d.ts +2 -0
- package/dist/types/common/constants.d.ts.map +1 -1
- package/dist/types/common/testUtil.d.ts +1 -0
- package/dist/types/common/testUtil.d.ts.map +1 -1
- package/package.json +4 -4
- package/dist/CallHistory/CallHistory.js +0 -584
- package/dist/CallHistory/CallHistory.js.map +0 -1
- package/dist/CallHistory/CallHistory.test.js +0 -813
- package/dist/CallHistory/CallHistory.test.js.map +0 -1
- package/dist/CallHistory/callHistoryFixtures.js +0 -650
- package/dist/CallHistory/callHistoryFixtures.js.map +0 -1
- package/dist/CallHistory/constants.js +0 -38
- package/dist/CallHistory/constants.js.map +0 -1
- package/dist/CallHistory/types.js +0 -7
- package/dist/CallHistory/types.js.map +0 -1
- package/dist/CallSettings/CallSettings.js +0 -312
- package/dist/CallSettings/CallSettings.js.map +0 -1
- package/dist/CallSettings/CallSettings.test.js +0 -122
- package/dist/CallSettings/CallSettings.test.js.map +0 -1
- package/dist/CallSettings/UcmBackendConnector.js +0 -261
- package/dist/CallSettings/UcmBackendConnector.js.map +0 -1
- package/dist/CallSettings/UcmBackendConnector.test.js +0 -321
- package/dist/CallSettings/UcmBackendConnector.test.js.map +0 -1
- package/dist/CallSettings/WxCallBackendConnector.js +0 -604
- package/dist/CallSettings/WxCallBackendConnector.js.map +0 -1
- package/dist/CallSettings/WxCallBackendConnector.test.js +0 -905
- package/dist/CallSettings/WxCallBackendConnector.test.js.map +0 -1
- package/dist/CallSettings/constants.js +0 -31
- package/dist/CallSettings/constants.js.map +0 -1
- package/dist/CallSettings/testFixtures.js +0 -68
- package/dist/CallSettings/testFixtures.js.map +0 -1
- package/dist/CallSettings/types.js +0 -7
- package/dist/CallSettings/types.js.map +0 -1
- package/dist/CallingClient/CallingClient.js +0 -1071
- package/dist/CallingClient/CallingClient.js.map +0 -1
- package/dist/CallingClient/CallingClient.test.js +0 -1289
- package/dist/CallingClient/CallingClient.test.js.map +0 -1
- package/dist/CallingClient/callRecordFixtures.js +0 -101
- package/dist/CallingClient/callRecordFixtures.js.map +0 -1
- package/dist/CallingClient/calling/CallerId/index.js +0 -276
- package/dist/CallingClient/calling/CallerId/index.js.map +0 -1
- package/dist/CallingClient/calling/CallerId/index.test.js +0 -275
- package/dist/CallingClient/calling/CallerId/index.test.js.map +0 -1
- package/dist/CallingClient/calling/CallerId/types.js +0 -7
- package/dist/CallingClient/calling/CallerId/types.js.map +0 -1
- package/dist/CallingClient/calling/call.js +0 -3444
- package/dist/CallingClient/calling/call.js.map +0 -1
- package/dist/CallingClient/calling/call.test.js +0 -3260
- package/dist/CallingClient/calling/call.test.js.map +0 -1
- package/dist/CallingClient/calling/callManager.js +0 -456
- package/dist/CallingClient/calling/callManager.js.map +0 -1
- package/dist/CallingClient/calling/callManager.test.js +0 -741
- package/dist/CallingClient/calling/callManager.test.js.map +0 -1
- package/dist/CallingClient/calling/index.js +0 -30
- package/dist/CallingClient/calling/index.js.map +0 -1
- package/dist/CallingClient/calling/types.js +0 -74
- package/dist/CallingClient/calling/types.js.map +0 -1
- package/dist/CallingClient/callingClientFixtures.js +0 -143
- package/dist/CallingClient/callingClientFixtures.js.map +0 -1
- package/dist/CallingClient/constants.js +0 -237
- package/dist/CallingClient/constants.js.map +0 -1
- package/dist/CallingClient/line/index.js +0 -349
- package/dist/CallingClient/line/index.js.map +0 -1
- package/dist/CallingClient/line/line.test.js +0 -327
- package/dist/CallingClient/line/line.test.js.map +0 -1
- package/dist/CallingClient/line/types.js +0 -21
- package/dist/CallingClient/line/types.js.map +0 -1
- package/dist/CallingClient/registration/index.js +0 -19
- package/dist/CallingClient/registration/index.js.map +0 -1
- package/dist/CallingClient/registration/register.js +0 -1538
- package/dist/CallingClient/registration/register.js.map +0 -1
- package/dist/CallingClient/registration/register.test.js +0 -1537
- package/dist/CallingClient/registration/register.test.js.map +0 -1
- package/dist/CallingClient/registration/registerFixtures.js +0 -36
- package/dist/CallingClient/registration/registerFixtures.js.map +0 -1
- package/dist/CallingClient/registration/types.js +0 -7
- package/dist/CallingClient/registration/types.js.map +0 -1
- package/dist/CallingClient/registration/webWorker.js +0 -130
- package/dist/CallingClient/registration/webWorker.js.map +0 -1
- package/dist/CallingClient/registration/webWorker.test.js +0 -303
- package/dist/CallingClient/registration/webWorker.test.js.map +0 -1
- package/dist/CallingClient/registration/webWorkerStr.js +0 -15
- package/dist/CallingClient/registration/webWorkerStr.js.map +0 -1
- package/dist/CallingClient/types.js +0 -7
- package/dist/CallingClient/types.js.map +0 -1
- package/dist/CallingClient/windowsChromiumIceWarmupUtils.js +0 -142
- package/dist/CallingClient/windowsChromiumIceWarmupUtils.js.map +0 -1
- package/dist/Contacts/ContactsClient.js +0 -1215
- package/dist/Contacts/ContactsClient.js.map +0 -1
- package/dist/Contacts/ContactsClient.test.js +0 -1003
- package/dist/Contacts/ContactsClient.test.js.map +0 -1
- package/dist/Contacts/constants.js +0 -40
- package/dist/Contacts/constants.js.map +0 -1
- package/dist/Contacts/contactFixtures.js +0 -430
- package/dist/Contacts/contactFixtures.js.map +0 -1
- package/dist/Contacts/types.js +0 -43
- package/dist/Contacts/types.js.map +0 -1
- package/dist/Errors/catalog/CallError.js +0 -92
- package/dist/Errors/catalog/CallError.js.map +0 -1
- package/dist/Errors/catalog/CallingDeviceError.js +0 -86
- package/dist/Errors/catalog/CallingDeviceError.js.map +0 -1
- package/dist/Errors/catalog/ExtendedError.js +0 -44
- package/dist/Errors/catalog/ExtendedError.js.map +0 -1
- package/dist/Errors/catalog/LineError.js +0 -88
- package/dist/Errors/catalog/LineError.js.map +0 -1
- package/dist/Errors/index.js +0 -28
- package/dist/Errors/index.js.map +0 -1
- package/dist/Errors/types.js +0 -59
- package/dist/Errors/types.js.map +0 -1
- package/dist/Events/impl/index.js +0 -81
- package/dist/Events/impl/index.js.map +0 -1
- package/dist/Events/types.js +0 -107
- package/dist/Events/types.js.map +0 -1
- package/dist/Logger/index.js +0 -228
- package/dist/Logger/index.js.map +0 -1
- package/dist/Logger/index.test.js +0 -87
- package/dist/Logger/index.test.js.map +0 -1
- package/dist/Logger/types.js +0 -34
- package/dist/Logger/types.js.map +0 -1
- package/dist/Metrics/index.js +0 -535
- package/dist/Metrics/index.js.map +0 -1
- package/dist/Metrics/index.test.js +0 -463
- package/dist/Metrics/index.test.js.map +0 -1
- package/dist/Metrics/types.js +0 -64
- package/dist/Metrics/types.js.map +0 -1
- package/dist/SDKConnector/index.js +0 -103
- package/dist/SDKConnector/index.js.map +0 -1
- package/dist/SDKConnector/index.test.js +0 -9
- package/dist/SDKConnector/index.test.js.map +0 -1
- package/dist/SDKConnector/types.js +0 -7
- package/dist/SDKConnector/types.js.map +0 -1
- package/dist/SDKConnector/utils.js +0 -39
- package/dist/SDKConnector/utils.js.map +0 -1
- package/dist/SDKConnector/utils.test.js +0 -9
- package/dist/SDKConnector/utils.test.js.map +0 -1
- package/dist/Voicemail/BroadworksBackendConnector.js +0 -707
- package/dist/Voicemail/BroadworksBackendConnector.js.map +0 -1
- package/dist/Voicemail/BroadworksBackendConnector.test.js +0 -812
- package/dist/Voicemail/BroadworksBackendConnector.test.js.map +0 -1
- package/dist/Voicemail/UcmBackendConnector.js +0 -632
- package/dist/Voicemail/UcmBackendConnector.js.map +0 -1
- package/dist/Voicemail/UcmBackendConnector.test.js +0 -738
- package/dist/Voicemail/UcmBackendConnector.test.js.map +0 -1
- package/dist/Voicemail/Voicemail.js +0 -500
- package/dist/Voicemail/Voicemail.js.map +0 -1
- package/dist/Voicemail/Voicemail.test.js +0 -391
- package/dist/Voicemail/Voicemail.test.js.map +0 -1
- package/dist/Voicemail/WxCallBackendConnector.js +0 -671
- package/dist/Voicemail/WxCallBackendConnector.js.map +0 -1
- package/dist/Voicemail/WxCallBackendConnector.test.js +0 -1199
- package/dist/Voicemail/WxCallBackendConnector.test.js.map +0 -1
- package/dist/Voicemail/constants.js +0 -61
- package/dist/Voicemail/constants.js.map +0 -1
- package/dist/Voicemail/types.js +0 -7
- package/dist/Voicemail/types.js.map +0 -1
- package/dist/Voicemail/voicemailFixture.js +0 -524
- package/dist/Voicemail/voicemailFixture.js.map +0 -1
- package/dist/api.js +0 -157
- package/dist/api.js.map +0 -1
- package/dist/common/Utils.js +0 -1451
- package/dist/common/Utils.js.map +0 -1
- package/dist/common/Utils.test.js +0 -1744
- package/dist/common/Utils.test.js.map +0 -1
- package/dist/common/constants.js +0 -60
- package/dist/common/constants.js.map +0 -1
- package/dist/common/index.js +0 -19
- package/dist/common/index.js.map +0 -1
- package/dist/common/testUtil.js +0 -982
- package/dist/common/testUtil.js.map +0 -1
- package/dist/common/types.js +0 -75
- package/dist/common/types.js.map +0 -1
- package/dist/index.js +0 -321
- package/dist/index.js.map +0 -1
|
@@ -1,813 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _typeof = require("@babel/runtime-corejs2/helpers/typeof");
|
|
4
|
-
var _Object$keys = 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 _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
13
|
-
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
|
|
14
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
|
|
15
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
16
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
|
|
17
|
-
var _types = require("../Logger/types");
|
|
18
|
-
var _testUtil = require("../common/testUtil");
|
|
19
|
-
var _types2 = require("../common/types");
|
|
20
|
-
var _CallHistory = require("./CallHistory");
|
|
21
|
-
var _callHistoryFixtures = require("./callHistoryFixtures");
|
|
22
|
-
var _types3 = require("../Events/types");
|
|
23
|
-
var _constants = require("./constants");
|
|
24
|
-
var utils = _interopRequireWildcard(require("../common/Utils"));
|
|
25
|
-
var _Logger = _interopRequireDefault(require("../Logger"));
|
|
26
|
-
var _constants2 = require("../common/constants");
|
|
27
|
-
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); }
|
|
28
|
-
function ownKeys(e, r) { var t = _Object$keys(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; }
|
|
29
|
-
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-unused-vars */ /* eslint-disable dot-notation */ /* eslint-disable @typescript-eslint/no-shadow */
|
|
30
|
-
var webex = (0, _testUtil.getTestUtilsWebex)();
|
|
31
|
-
var serviceErrorCodeHandlerSpy;
|
|
32
|
-
var uploadLogsSpy;
|
|
33
|
-
describe('Call history tests', function () {
|
|
34
|
-
var callHistory;
|
|
35
|
-
var infoSpy = jest.spyOn(_Logger.default, 'info').mockImplementation();
|
|
36
|
-
var logSpy = jest.spyOn(_Logger.default, 'log').mockImplementation();
|
|
37
|
-
var errorSpy = jest.spyOn(_Logger.default, 'error').mockImplementation();
|
|
38
|
-
beforeAll(function () {
|
|
39
|
-
callHistory = new _CallHistory.CallHistory(webex, {
|
|
40
|
-
level: _types.LOGGER.INFO
|
|
41
|
-
});
|
|
42
|
-
uploadLogsSpy = jest.spyOn(utils, 'uploadLogs').mockResolvedValue();
|
|
43
|
-
});
|
|
44
|
-
it('verify successful call history case', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
45
|
-
var callHistoryPayload, response;
|
|
46
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
47
|
-
while (1) switch (_context.prev = _context.next) {
|
|
48
|
-
case 0:
|
|
49
|
-
callHistoryPayload = _callHistoryFixtures.mockCallHistoryBody;
|
|
50
|
-
webex.request.mockResolvedValue(callHistoryPayload);
|
|
51
|
-
_context.next = 4;
|
|
52
|
-
return callHistory.getCallHistoryData(7, 10, _types2.SORT.DEFAULT, _types2.SORT_BY.DEFAULT);
|
|
53
|
-
case 4:
|
|
54
|
-
response = _context.sent;
|
|
55
|
-
expect(response.statusCode).toBe(200);
|
|
56
|
-
expect(response.message).toBe('SUCCESS');
|
|
57
|
-
|
|
58
|
-
// Verify logging behavior
|
|
59
|
-
expect(infoSpy).toHaveBeenCalled();
|
|
60
|
-
expect(logSpy).toHaveBeenCalled();
|
|
61
|
-
expect(errorSpy).not.toHaveBeenCalled();
|
|
62
|
-
|
|
63
|
-
// Verify logs were called with correct information
|
|
64
|
-
expect(infoSpy).toHaveBeenCalledWith('invoking with days=7, limit=10, sort=DESC, sortBy=endTime', {
|
|
65
|
-
file: _constants.CALL_HISTORY_FILE,
|
|
66
|
-
method: _constants.METHODS.GET_CALL_HISTORY_DATA
|
|
67
|
-
});
|
|
68
|
-
expect(logSpy).toHaveBeenCalledWith(expect.stringContaining('Successfully retrieved call history data'), {
|
|
69
|
-
file: _constants.CALL_HISTORY_FILE,
|
|
70
|
-
method: _constants.METHODS.GET_CALL_HISTORY_DATA
|
|
71
|
-
});
|
|
72
|
-
expect(errorSpy).not.toHaveBeenCalled();
|
|
73
|
-
expect(uploadLogsSpy).not.toHaveBeenCalled();
|
|
74
|
-
case 14:
|
|
75
|
-
case "end":
|
|
76
|
-
return _context.stop();
|
|
77
|
-
}
|
|
78
|
-
}, _callee);
|
|
79
|
-
})));
|
|
80
|
-
it('verify bad request failed call history case', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
81
|
-
var failurePayload, callHistoryPayload, response;
|
|
82
|
-
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
83
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
84
|
-
case 0:
|
|
85
|
-
failurePayload = {
|
|
86
|
-
statusCode: 400
|
|
87
|
-
};
|
|
88
|
-
callHistoryPayload = failurePayload;
|
|
89
|
-
webex.request.mockRejectedValue(callHistoryPayload);
|
|
90
|
-
_context2.next = 5;
|
|
91
|
-
return callHistory.getCallHistoryData(7, 2000, _types2.SORT.ASC, _types2.SORT_BY.START_TIME);
|
|
92
|
-
case 5:
|
|
93
|
-
response = _context2.sent;
|
|
94
|
-
expect(response.statusCode).toBe(400);
|
|
95
|
-
expect(response.message).toBe('FAILURE');
|
|
96
|
-
|
|
97
|
-
// Verify logs were called with correct information
|
|
98
|
-
expect(infoSpy).toHaveBeenCalledWith('invoking with days=7, limit=2000, sort=ASC, sortBy=startTime', {
|
|
99
|
-
file: _constants.CALL_HISTORY_FILE,
|
|
100
|
-
method: _constants.METHODS.GET_CALL_HISTORY_DATA
|
|
101
|
-
});
|
|
102
|
-
expect(errorSpy).toHaveBeenCalled();
|
|
103
|
-
expect(uploadLogsSpy).toHaveBeenCalledTimes(1);
|
|
104
|
-
case 11:
|
|
105
|
-
case "end":
|
|
106
|
-
return _context2.stop();
|
|
107
|
-
}
|
|
108
|
-
}, _callee2);
|
|
109
|
-
})));
|
|
110
|
-
it('verify device not found call history case', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
111
|
-
var failurePayload, callHistoryPayload, response;
|
|
112
|
-
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
113
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
114
|
-
case 0:
|
|
115
|
-
failurePayload = {
|
|
116
|
-
statusCode: 404
|
|
117
|
-
};
|
|
118
|
-
callHistoryPayload = failurePayload;
|
|
119
|
-
webex.request.mockRejectedValue(callHistoryPayload);
|
|
120
|
-
_context3.next = 5;
|
|
121
|
-
return callHistory.getCallHistoryData(0, 0, _types2.SORT.ASC, _types2.SORT_BY.START_TIME);
|
|
122
|
-
case 5:
|
|
123
|
-
response = _context3.sent;
|
|
124
|
-
expect(response.statusCode).toBe(404);
|
|
125
|
-
expect(response.message).toBe('FAILURE');
|
|
126
|
-
|
|
127
|
-
// Verify logs were called with correct information
|
|
128
|
-
expect(infoSpy).toHaveBeenCalledWith('invoking with days=0, limit=0, sort=ASC, sortBy=startTime', {
|
|
129
|
-
file: _constants.CALL_HISTORY_FILE,
|
|
130
|
-
method: _constants.METHODS.GET_CALL_HISTORY_DATA
|
|
131
|
-
});
|
|
132
|
-
expect(errorSpy).toHaveBeenCalled();
|
|
133
|
-
expect(uploadLogsSpy).toHaveBeenCalledTimes(1);
|
|
134
|
-
case 11:
|
|
135
|
-
case "end":
|
|
136
|
-
return _context3.stop();
|
|
137
|
-
}
|
|
138
|
-
}, _callee3);
|
|
139
|
-
})));
|
|
140
|
-
describe('sorting user session response data by sortby', function () {
|
|
141
|
-
it('Array should be sort.ASC by START TIME ', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee4() {
|
|
142
|
-
var callHistoryPayload, response, responseDetails;
|
|
143
|
-
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
144
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
145
|
-
case 0:
|
|
146
|
-
callHistoryPayload = _callHistoryFixtures.mockCallHistoryBody;
|
|
147
|
-
webex.request.mockResolvedValue(callHistoryPayload);
|
|
148
|
-
_context4.next = 4;
|
|
149
|
-
return callHistory.getCallHistoryData(10, 20, _types2.SORT.ASC, _types2.SORT_BY.START_TIME);
|
|
150
|
-
case 4:
|
|
151
|
-
response = _context4.sent;
|
|
152
|
-
responseDetails = {
|
|
153
|
-
statusCode: _callHistoryFixtures.sortedCallHistory.body.statusCode,
|
|
154
|
-
data: {
|
|
155
|
-
userSessions: _callHistoryFixtures.sortedCallHistory.body.userSessions
|
|
156
|
-
},
|
|
157
|
-
message: 'SUCCESS'
|
|
158
|
-
};
|
|
159
|
-
expect(response).toEqual(responseDetails);
|
|
160
|
-
|
|
161
|
-
// Verify logs were called with correct information
|
|
162
|
-
expect(infoSpy).toHaveBeenCalledWith('invoking with days=10, limit=20, sort=ASC, sortBy=startTime', {
|
|
163
|
-
file: _constants.CALL_HISTORY_FILE,
|
|
164
|
-
method: _constants.METHODS.GET_CALL_HISTORY_DATA
|
|
165
|
-
});
|
|
166
|
-
case 8:
|
|
167
|
-
case "end":
|
|
168
|
-
return _context4.stop();
|
|
169
|
-
}
|
|
170
|
-
}, _callee4);
|
|
171
|
-
})));
|
|
172
|
-
});
|
|
173
|
-
describe('Call History Session Event test', function () {
|
|
174
|
-
var mockOn = webex.internal.mercury.on;
|
|
175
|
-
var callHistory;
|
|
176
|
-
beforeEach(function () {
|
|
177
|
-
callHistory = (0, _CallHistory.createCallHistoryClient)(webex, {
|
|
178
|
-
level: _types.LOGGER.INFO
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
it('verify the recent user session event ', function (done) {
|
|
182
|
-
callHistory.on(_types3.COMMON_EVENT_KEYS.CALL_HISTORY_USER_SESSION_INFO, function (event) {
|
|
183
|
-
expect(event.data).toEqual(_callHistoryFixtures.MOCK_SESSION_EVENT.data);
|
|
184
|
-
done();
|
|
185
|
-
});
|
|
186
|
-
expect(mockOn.mock.calls[0][0]).toEqual(_types3.MOBIUS_EVENT_KEYS.CALL_SESSION_EVENT_INCLUSIVE);
|
|
187
|
-
var callSessionCallback = mockOn.mock.calls[0][1];
|
|
188
|
-
callSessionCallback(_callHistoryFixtures.MOCK_SESSION_EVENT);
|
|
189
|
-
});
|
|
190
|
-
it('verify the user session event received for locus calls', function (done) {
|
|
191
|
-
callHistory.on(_types3.COMMON_EVENT_KEYS.CALL_HISTORY_USER_SESSION_INFO, function (event) {
|
|
192
|
-
expect(event.data).toEqual(_callHistoryFixtures.MOCK_SESSION_EVENT_LEGACY.data);
|
|
193
|
-
done();
|
|
194
|
-
});
|
|
195
|
-
expect(mockOn.mock.calls[1][0]).toEqual(_types3.MOBIUS_EVENT_KEYS.CALL_SESSION_EVENT_LEGACY);
|
|
196
|
-
var callSessionCallback = mockOn.mock.calls[1][1];
|
|
197
|
-
callSessionCallback(_callHistoryFixtures.MOCK_SESSION_EVENT_LEGACY);
|
|
198
|
-
});
|
|
199
|
-
it('verify the user viewed session event for missed calls update', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee5() {
|
|
200
|
-
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
201
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
202
|
-
case 0:
|
|
203
|
-
_context5.next = 2;
|
|
204
|
-
return new _promise.default(function (resolve) {
|
|
205
|
-
callHistory.on(_types3.COMMON_EVENT_KEYS.CALL_HISTORY_USER_VIEWED_SESSIONS, function (event) {
|
|
206
|
-
expect(event.data).toEqual(_callHistoryFixtures.MOCK_SESSION_EVENT_VIEWED.data);
|
|
207
|
-
resolve();
|
|
208
|
-
});
|
|
209
|
-
expect(mockOn.mock.calls[2][0]).toEqual(_types3.MOBIUS_EVENT_KEYS.CALL_SESSION_EVENT_VIEWED);
|
|
210
|
-
var callSessionCallback = mockOn.mock.calls[2][1];
|
|
211
|
-
callSessionCallback(_callHistoryFixtures.MOCK_SESSION_EVENT_VIEWED);
|
|
212
|
-
});
|
|
213
|
-
case 2:
|
|
214
|
-
case "end":
|
|
215
|
-
return _context5.stop();
|
|
216
|
-
}
|
|
217
|
-
}, _callee5);
|
|
218
|
-
})));
|
|
219
|
-
it('verify the user sessions deleted event for deleting the call history records', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee6() {
|
|
220
|
-
return _regenerator.default.wrap(function _callee6$(_context6) {
|
|
221
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
222
|
-
case 0:
|
|
223
|
-
_context6.next = 2;
|
|
224
|
-
return new _promise.default(function (resolve) {
|
|
225
|
-
callHistory.on(_types3.COMMON_EVENT_KEYS.CALL_HISTORY_USER_SESSIONS_DELETED, function (event) {
|
|
226
|
-
expect(event.data).toEqual(_callHistoryFixtures.MOCK_SESSION_EVENT_DELETED.data);
|
|
227
|
-
resolve();
|
|
228
|
-
});
|
|
229
|
-
expect(mockOn.mock.calls[3][0]).toEqual(_types3.MOBIUS_EVENT_KEYS.CALL_SESSION_EVENT_DELETED);
|
|
230
|
-
var callSessionCallback = mockOn.mock.calls[3][1];
|
|
231
|
-
callSessionCallback(_callHistoryFixtures.MOCK_SESSION_EVENT_DELETED);
|
|
232
|
-
});
|
|
233
|
-
case 2:
|
|
234
|
-
case "end":
|
|
235
|
-
return _context6.stop();
|
|
236
|
-
}
|
|
237
|
-
}, _callee6);
|
|
238
|
-
})));
|
|
239
|
-
});
|
|
240
|
-
describe('Update missed calls test', function () {
|
|
241
|
-
var methodDetails = {
|
|
242
|
-
file: _constants.CALL_HISTORY_FILE,
|
|
243
|
-
method: _constants.METHODS.UPDATE_MISSED_CALLS
|
|
244
|
-
};
|
|
245
|
-
afterEach(function () {
|
|
246
|
-
jest.clearAllMocks();
|
|
247
|
-
});
|
|
248
|
-
beforeEach(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee7() {
|
|
249
|
-
return _regenerator.default.wrap(function _callee7$(_context7) {
|
|
250
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
251
|
-
case 0:
|
|
252
|
-
serviceErrorCodeHandlerSpy = jest.spyOn(utils, 'serviceErrorCodeHandler');
|
|
253
|
-
uploadLogsSpy = jest.spyOn(utils, 'uploadLogs').mockResolvedValue();
|
|
254
|
-
global.fetch = jest.fn(function () {
|
|
255
|
-
return _promise.default.resolve({
|
|
256
|
-
status: 200,
|
|
257
|
-
ok: true,
|
|
258
|
-
json: function json() {
|
|
259
|
-
return _promise.default.resolve(_callHistoryFixtures.MOCK_UPDATE_MISSED_CALL_RESPONSE);
|
|
260
|
-
}
|
|
261
|
-
});
|
|
262
|
-
});
|
|
263
|
-
case 3:
|
|
264
|
-
case "end":
|
|
265
|
-
return _context7.stop();
|
|
266
|
-
}
|
|
267
|
-
}, _callee7);
|
|
268
|
-
})));
|
|
269
|
-
it('successfully updates missed calls', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee8() {
|
|
270
|
-
var endTimeSessionIds, response, convertedEndTimeSessionIds;
|
|
271
|
-
return _regenerator.default.wrap(function _callee8$(_context8) {
|
|
272
|
-
while (1) switch (_context8.prev = _context8.next) {
|
|
273
|
-
case 0:
|
|
274
|
-
endTimeSessionIds = [{
|
|
275
|
-
endTime: '1234568',
|
|
276
|
-
sessionId: '123'
|
|
277
|
-
}];
|
|
278
|
-
_context8.next = 3;
|
|
279
|
-
return callHistory.updateMissedCalls(endTimeSessionIds);
|
|
280
|
-
case 3:
|
|
281
|
-
response = _context8.sent;
|
|
282
|
-
convertedEndTimeSessionIds = endTimeSessionIds.map(function (session) {
|
|
283
|
-
return _objectSpread(_objectSpread({}, session), {}, {
|
|
284
|
-
endTime: new Date(session.endTime).getTime()
|
|
285
|
-
});
|
|
286
|
-
});
|
|
287
|
-
expect(response.statusCode).toEqual(200);
|
|
288
|
-
expect(response).toEqual(_callHistoryFixtures.MOCK_UPDATE_MISSED_CALL_RESPONSE);
|
|
289
|
-
_context8.t0 = expect(global.fetch);
|
|
290
|
-
_context8.t1 = _callHistoryFixtures.janusSetReadStateUrl;
|
|
291
|
-
_context8.t2 = _types2.HTTP_METHODS.POST;
|
|
292
|
-
_context8.t3 = _defineProperty2.default;
|
|
293
|
-
_context8.t4 = (0, _defineProperty2.default)({}, _constants.CONTENT_TYPE, _constants.APPLICATION_JSON);
|
|
294
|
-
_context8.next = 14;
|
|
295
|
-
return webex.credentials.getUserToken();
|
|
296
|
-
case 14:
|
|
297
|
-
_context8.t5 = _context8.sent;
|
|
298
|
-
_context8.t6 = (0, _context8.t3)(_context8.t4, "Authorization", _context8.t5);
|
|
299
|
-
_context8.t7 = (0, _stringify.default)({
|
|
300
|
-
endTimeSessionIds: convertedEndTimeSessionIds
|
|
301
|
-
});
|
|
302
|
-
_context8.t8 = {
|
|
303
|
-
method: _context8.t2,
|
|
304
|
-
headers: _context8.t6,
|
|
305
|
-
body: _context8.t7
|
|
306
|
-
};
|
|
307
|
-
_context8.t0.toBeCalledOnceWith.call(_context8.t0, _context8.t1, _context8.t8);
|
|
308
|
-
// Verify logs were called with correct information
|
|
309
|
-
expect(infoSpy).toHaveBeenCalledWith("".concat(_constants2.METHOD_START_MESSAGE, " with sessions: ").concat((0, _stringify.default)(convertedEndTimeSessionIds)), methodDetails);
|
|
310
|
-
expect(logSpy).toHaveBeenCalledWith('Missed calls are successfully read by the user', methodDetails);
|
|
311
|
-
expect(errorSpy).not.toHaveBeenCalled();
|
|
312
|
-
expect(uploadLogsSpy).not.toHaveBeenCalled();
|
|
313
|
-
case 23:
|
|
314
|
-
case "end":
|
|
315
|
-
return _context8.stop();
|
|
316
|
-
}
|
|
317
|
-
}, _callee8);
|
|
318
|
-
})));
|
|
319
|
-
it('Error: updateMissedCalls throw 400 error', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee9() {
|
|
320
|
-
var endTimeSessionIds, response, convertedEndTimeSessionIds;
|
|
321
|
-
return _regenerator.default.wrap(function _callee9$(_context9) {
|
|
322
|
-
while (1) switch (_context9.prev = _context9.next) {
|
|
323
|
-
case 0:
|
|
324
|
-
endTimeSessionIds = [];
|
|
325
|
-
global.fetch = jest.fn(function () {
|
|
326
|
-
return _promise.default.resolve({
|
|
327
|
-
status: 400,
|
|
328
|
-
ok: false
|
|
329
|
-
});
|
|
330
|
-
});
|
|
331
|
-
_context9.next = 4;
|
|
332
|
-
return callHistory.updateMissedCalls(endTimeSessionIds);
|
|
333
|
-
case 4:
|
|
334
|
-
response = _context9.sent;
|
|
335
|
-
convertedEndTimeSessionIds = endTimeSessionIds.map(function (session) {
|
|
336
|
-
return _objectSpread(_objectSpread({}, session), {}, {
|
|
337
|
-
endTime: new Date(session.endTime).getTime()
|
|
338
|
-
});
|
|
339
|
-
});
|
|
340
|
-
expect(response).toStrictEqual(_callHistoryFixtures.ERROR_DETAILS_400);
|
|
341
|
-
expect(response.statusCode).toBe(400);
|
|
342
|
-
_context9.t0 = expect(global.fetch);
|
|
343
|
-
_context9.t1 = _callHistoryFixtures.janusSetReadStateUrl;
|
|
344
|
-
_context9.t2 = _types2.HTTP_METHODS.POST;
|
|
345
|
-
_context9.t3 = _defineProperty2.default;
|
|
346
|
-
_context9.t4 = (0, _defineProperty2.default)({}, _constants.CONTENT_TYPE, _constants.APPLICATION_JSON);
|
|
347
|
-
_context9.next = 15;
|
|
348
|
-
return webex.credentials.getUserToken();
|
|
349
|
-
case 15:
|
|
350
|
-
_context9.t5 = _context9.sent;
|
|
351
|
-
_context9.t6 = (0, _context9.t3)(_context9.t4, "Authorization", _context9.t5);
|
|
352
|
-
_context9.t7 = (0, _stringify.default)({
|
|
353
|
-
endTimeSessionIds: convertedEndTimeSessionIds
|
|
354
|
-
});
|
|
355
|
-
_context9.t8 = {
|
|
356
|
-
method: _context9.t2,
|
|
357
|
-
headers: _context9.t6,
|
|
358
|
-
body: _context9.t7
|
|
359
|
-
};
|
|
360
|
-
_context9.t0.toBeCalledOnceWith.call(_context9.t0, _context9.t1, _context9.t8);
|
|
361
|
-
expect(serviceErrorCodeHandlerSpy).toBeCalledOnceWith({
|
|
362
|
-
statusCode: 400
|
|
363
|
-
}, methodDetails);
|
|
364
|
-
expect(errorSpy).toHaveBeenCalled();
|
|
365
|
-
expect(uploadLogsSpy).toHaveBeenCalledTimes(1);
|
|
366
|
-
case 23:
|
|
367
|
-
case "end":
|
|
368
|
-
return _context9.stop();
|
|
369
|
-
}
|
|
370
|
-
}, _callee9);
|
|
371
|
-
})));
|
|
372
|
-
it('Error: updateMissedCalls throw 401 error', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee0() {
|
|
373
|
-
var endTimeSessionIds, response, convertedEndTimeSessionIds;
|
|
374
|
-
return _regenerator.default.wrap(function _callee0$(_context0) {
|
|
375
|
-
while (1) switch (_context0.prev = _context0.next) {
|
|
376
|
-
case 0:
|
|
377
|
-
endTimeSessionIds = [];
|
|
378
|
-
global.fetch = jest.fn(function () {
|
|
379
|
-
return _promise.default.resolve({
|
|
380
|
-
status: 401,
|
|
381
|
-
ok: false
|
|
382
|
-
});
|
|
383
|
-
});
|
|
384
|
-
_context0.next = 4;
|
|
385
|
-
return callHistory.updateMissedCalls(endTimeSessionIds);
|
|
386
|
-
case 4:
|
|
387
|
-
response = _context0.sent;
|
|
388
|
-
convertedEndTimeSessionIds = endTimeSessionIds.map(function (session) {
|
|
389
|
-
return _objectSpread(_objectSpread({}, session), {}, {
|
|
390
|
-
endTime: new Date(session.endTime).getTime()
|
|
391
|
-
});
|
|
392
|
-
});
|
|
393
|
-
expect(response).toStrictEqual(_callHistoryFixtures.ERROR_DETAILS_401);
|
|
394
|
-
expect(response.statusCode).toBe(401);
|
|
395
|
-
_context0.t0 = expect(global.fetch);
|
|
396
|
-
_context0.t1 = _callHistoryFixtures.janusSetReadStateUrl;
|
|
397
|
-
_context0.t2 = _types2.HTTP_METHODS.POST;
|
|
398
|
-
_context0.t3 = _defineProperty2.default;
|
|
399
|
-
_context0.t4 = (0, _defineProperty2.default)({}, _constants.CONTENT_TYPE, _constants.APPLICATION_JSON);
|
|
400
|
-
_context0.next = 15;
|
|
401
|
-
return webex.credentials.getUserToken();
|
|
402
|
-
case 15:
|
|
403
|
-
_context0.t5 = _context0.sent;
|
|
404
|
-
_context0.t6 = (0, _context0.t3)(_context0.t4, "Authorization", _context0.t5);
|
|
405
|
-
_context0.t7 = (0, _stringify.default)({
|
|
406
|
-
endTimeSessionIds: convertedEndTimeSessionIds
|
|
407
|
-
});
|
|
408
|
-
_context0.t8 = {
|
|
409
|
-
method: _context0.t2,
|
|
410
|
-
headers: _context0.t6,
|
|
411
|
-
body: _context0.t7
|
|
412
|
-
};
|
|
413
|
-
_context0.t0.toBeCalledOnceWith.call(_context0.t0, _context0.t1, _context0.t8);
|
|
414
|
-
expect(serviceErrorCodeHandlerSpy).toBeCalledOnceWith({
|
|
415
|
-
statusCode: 401
|
|
416
|
-
}, methodDetails);
|
|
417
|
-
expect(errorSpy).toHaveBeenCalled();
|
|
418
|
-
expect(uploadLogsSpy).toHaveBeenCalledTimes(1);
|
|
419
|
-
case 23:
|
|
420
|
-
case "end":
|
|
421
|
-
return _context0.stop();
|
|
422
|
-
}
|
|
423
|
-
}, _callee0);
|
|
424
|
-
})));
|
|
425
|
-
});
|
|
426
|
-
describe('fetchUCMLinesData test', function () {
|
|
427
|
-
beforeEach(function () {
|
|
428
|
-
uploadLogsSpy = jest.spyOn(utils, 'uploadLogs').mockResolvedValue();
|
|
429
|
-
});
|
|
430
|
-
it('verify successful UCM lines API case', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee1() {
|
|
431
|
-
var ucmLinesAPIPayload, response;
|
|
432
|
-
return _regenerator.default.wrap(function _callee1$(_context1) {
|
|
433
|
-
while (1) switch (_context1.prev = _context1.next) {
|
|
434
|
-
case 0:
|
|
435
|
-
ucmLinesAPIPayload = _callHistoryFixtures.MOCK_LINES_API_CALL_RESPONSE;
|
|
436
|
-
webex.request.mockResolvedValue(ucmLinesAPIPayload);
|
|
437
|
-
_context1.next = 4;
|
|
438
|
-
return callHistory['fetchUCMLinesData']();
|
|
439
|
-
case 4:
|
|
440
|
-
response = _context1.sent;
|
|
441
|
-
expect(response.statusCode).toBe(200);
|
|
442
|
-
expect(response.message).toBe('SUCCESS');
|
|
443
|
-
|
|
444
|
-
// Verify logs were called with correct information
|
|
445
|
-
expect(infoSpy).toHaveBeenCalledWith('invoking with URL: https://gw.telemetry.int-ucmgmt.cisco.com/v1/uc/config/people/8a67806f-fc4d-446b-a131-31e71ea5b0e9/lines?orgId=1704d30d-a131-4bc7-9449-948487643793', {
|
|
446
|
-
file: _constants.CALL_HISTORY_FILE,
|
|
447
|
-
method: _constants.METHODS.FETCH_UCM_LINES_DATA
|
|
448
|
-
});
|
|
449
|
-
expect(logSpy).toHaveBeenCalledWith('Line details fetched successfully', {
|
|
450
|
-
file: _constants.CALL_HISTORY_FILE,
|
|
451
|
-
method: _constants.METHODS.FETCH_UCM_LINES_DATA
|
|
452
|
-
});
|
|
453
|
-
expect(errorSpy).not.toHaveBeenCalled();
|
|
454
|
-
expect(uploadLogsSpy).not.toHaveBeenCalled();
|
|
455
|
-
case 11:
|
|
456
|
-
case "end":
|
|
457
|
-
return _context1.stop();
|
|
458
|
-
}
|
|
459
|
-
}, _callee1);
|
|
460
|
-
})));
|
|
461
|
-
it('verify bad request failed UCM lines API case', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee10() {
|
|
462
|
-
var failurePayload, ucmLinesAPIPayload, response;
|
|
463
|
-
return _regenerator.default.wrap(function _callee10$(_context10) {
|
|
464
|
-
while (1) switch (_context10.prev = _context10.next) {
|
|
465
|
-
case 0:
|
|
466
|
-
failurePayload = {
|
|
467
|
-
statusCode: 400
|
|
468
|
-
};
|
|
469
|
-
ucmLinesAPIPayload = failurePayload;
|
|
470
|
-
webex.request.mockRejectedValue(ucmLinesAPIPayload);
|
|
471
|
-
_context10.next = 5;
|
|
472
|
-
return callHistory['fetchUCMLinesData']();
|
|
473
|
-
case 5:
|
|
474
|
-
response = _context10.sent;
|
|
475
|
-
expect(response).toStrictEqual(_callHistoryFixtures.ERROR_DETAILS_400);
|
|
476
|
-
expect(response.data.error).toEqual(_callHistoryFixtures.ERROR_DETAILS_400.data.error);
|
|
477
|
-
expect(response.statusCode).toBe(400);
|
|
478
|
-
expect(response.message).toBe('FAILURE');
|
|
479
|
-
expect(serviceErrorCodeHandlerSpy).toHaveBeenCalledWith({
|
|
480
|
-
statusCode: 400
|
|
481
|
-
}, {
|
|
482
|
-
file: _constants.CALL_HISTORY_FILE,
|
|
483
|
-
method: _constants.METHODS.FETCH_UCM_LINES_DATA
|
|
484
|
-
});
|
|
485
|
-
|
|
486
|
-
// Verify logs were called with correct information
|
|
487
|
-
expect(infoSpy).toHaveBeenCalledWith("".concat(_constants2.METHOD_START_MESSAGE, " with URL: https://gw.telemetry.int-ucmgmt.cisco.com/v1/uc/config/people/8a67806f-fc4d-446b-a131-31e71ea5b0e9/lines?orgId=1704d30d-a131-4bc7-9449-948487643793"), {
|
|
488
|
-
file: _constants.CALL_HISTORY_FILE,
|
|
489
|
-
method: _constants.METHODS.FETCH_UCM_LINES_DATA
|
|
490
|
-
});
|
|
491
|
-
expect(errorSpy).toHaveBeenCalled();
|
|
492
|
-
expect(uploadLogsSpy).toHaveBeenCalledTimes(1);
|
|
493
|
-
case 14:
|
|
494
|
-
case "end":
|
|
495
|
-
return _context10.stop();
|
|
496
|
-
}
|
|
497
|
-
}, _callee10);
|
|
498
|
-
})));
|
|
499
|
-
it('should call fetchUCMLinesData when calling backend is UCM and userSessions contain valid cucmDN', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee11() {
|
|
500
|
-
var fetchUCMLinesDataSpy, mockCallHistoryPayload, response;
|
|
501
|
-
return _regenerator.default.wrap(function _callee11$(_context11) {
|
|
502
|
-
while (1) switch (_context11.prev = _context11.next) {
|
|
503
|
-
case 0:
|
|
504
|
-
jest.spyOn(utils, 'getCallingBackEnd').mockReturnValue(_types2.CALLING_BACKEND.UCM);
|
|
505
|
-
// Since fetchUCMLinesData is a private method, TypeScript restricts direct access to it.
|
|
506
|
-
// To bypass this restriction, we are using 'as any' to access and invoke the method for testing purposes.
|
|
507
|
-
fetchUCMLinesDataSpy = jest.spyOn(callHistory, 'fetchUCMLinesData').mockResolvedValue(_callHistoryFixtures.MOCK_LINES_API_CALL_RESPONSE);
|
|
508
|
-
mockCallHistoryPayload = _callHistoryFixtures.MOCK_CALL_HISTORY_WITH_UCM_LINE_NUMBER;
|
|
509
|
-
webex.request.mockResolvedValue(mockCallHistoryPayload);
|
|
510
|
-
_context11.next = 6;
|
|
511
|
-
return callHistory.getCallHistoryData(7, 10, _types2.SORT.DEFAULT, _types2.SORT_BY.DEFAULT);
|
|
512
|
-
case 6:
|
|
513
|
-
response = _context11.sent;
|
|
514
|
-
expect(fetchUCMLinesDataSpy).toHaveBeenCalledTimes(1);
|
|
515
|
-
expect(response.statusCode).toBe(200);
|
|
516
|
-
expect(response.data.userSessions && response.data.userSessions[0].self.ucmLineNumber).toEqual(1);
|
|
517
|
-
case 10:
|
|
518
|
-
case "end":
|
|
519
|
-
return _context11.stop();
|
|
520
|
-
}
|
|
521
|
-
}, _callee11);
|
|
522
|
-
})));
|
|
523
|
-
it('should fetchUCMLinesData but not assign ucmLineNumber when UCM backend has no line data', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee12() {
|
|
524
|
-
var fetchUCMLinesDataSpy, mockCallHistoryPayload, response;
|
|
525
|
-
return _regenerator.default.wrap(function _callee12$(_context12) {
|
|
526
|
-
while (1) switch (_context12.prev = _context12.next) {
|
|
527
|
-
case 0:
|
|
528
|
-
jest.spyOn(utils, 'getCallingBackEnd').mockReturnValue(_types2.CALLING_BACKEND.UCM);
|
|
529
|
-
|
|
530
|
-
// Since fetchUCMLinesData is a private method, TypeScript restricts direct access to it.
|
|
531
|
-
// To bypass this restriction, we are using 'as any' to access and invoke the method for testing purposes.
|
|
532
|
-
fetchUCMLinesDataSpy = jest.spyOn(callHistory, 'fetchUCMLinesData').mockResolvedValue(_callHistoryFixtures.MOCK_LINES_API_CALL_RESPONSE_WITH_NO_LINEDATA);
|
|
533
|
-
mockCallHistoryPayload = _callHistoryFixtures.MOCK_CALL_HISTORY_WITHOUT_UCM_LINE_NUMBER;
|
|
534
|
-
webex.request.mockResolvedValue(mockCallHistoryPayload);
|
|
535
|
-
_context12.next = 6;
|
|
536
|
-
return callHistory.getCallHistoryData(7, 10, _types2.SORT.DEFAULT, _types2.SORT_BY.DEFAULT);
|
|
537
|
-
case 6:
|
|
538
|
-
response = _context12.sent;
|
|
539
|
-
expect(fetchUCMLinesDataSpy).toHaveBeenCalledTimes(1);
|
|
540
|
-
expect(response.statusCode).toBe(200);
|
|
541
|
-
expect(response.data.userSessions && response.data.userSessions[0].self.cucmDN).toBeDefined();
|
|
542
|
-
expect(response.data.userSessions && response.data.userSessions[0].self.ucmLineNumber).toEqual(undefined);
|
|
543
|
-
case 11:
|
|
544
|
-
case "end":
|
|
545
|
-
return _context12.stop();
|
|
546
|
-
}
|
|
547
|
-
}, _callee12);
|
|
548
|
-
})));
|
|
549
|
-
it('should not call fetchUCMLinesData when calling backend is UCM but no valid cucmDN is present', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee13() {
|
|
550
|
-
var fetchUCMLinesDataSpy, callHistoryPayload;
|
|
551
|
-
return _regenerator.default.wrap(function _callee13$(_context13) {
|
|
552
|
-
while (1) switch (_context13.prev = _context13.next) {
|
|
553
|
-
case 0:
|
|
554
|
-
jest.spyOn(utils, 'getCallingBackEnd').mockReturnValue(_types2.CALLING_BACKEND.UCM);
|
|
555
|
-
// Since fetchUCMLinesData is a private method, TypeScript restricts direct access to it.
|
|
556
|
-
// To bypass this restriction, we are using 'as any' to access and invoke the method for testing purposes.
|
|
557
|
-
fetchUCMLinesDataSpy = jest.spyOn(callHistory, 'fetchUCMLinesData').mockResolvedValue({});
|
|
558
|
-
callHistoryPayload = _callHistoryFixtures.mockCallHistoryBody;
|
|
559
|
-
webex.request.mockResolvedValue(callHistoryPayload);
|
|
560
|
-
_context13.next = 6;
|
|
561
|
-
return callHistory.getCallHistoryData(7, 10, _types2.SORT.DEFAULT, _types2.SORT_BY.DEFAULT);
|
|
562
|
-
case 6:
|
|
563
|
-
expect(fetchUCMLinesDataSpy).not.toHaveBeenCalled();
|
|
564
|
-
case 7:
|
|
565
|
-
case "end":
|
|
566
|
-
return _context13.stop();
|
|
567
|
-
}
|
|
568
|
-
}, _callee13);
|
|
569
|
-
})));
|
|
570
|
-
it('should not call fetchUCMLinesData when calling backend is not UCM', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee14() {
|
|
571
|
-
var fetchUCMLinesDataSpy, callHistoryPayload;
|
|
572
|
-
return _regenerator.default.wrap(function _callee14$(_context14) {
|
|
573
|
-
while (1) switch (_context14.prev = _context14.next) {
|
|
574
|
-
case 0:
|
|
575
|
-
jest.spyOn(utils, 'getCallingBackEnd').mockReturnValue(_types2.CALLING_BACKEND.WXC);
|
|
576
|
-
// Since fetchUCMLinesData is a private method, TypeScript restricts direct access to it.
|
|
577
|
-
// To bypass this restriction, we are using 'as any' to access and invoke the method for testing purposes.
|
|
578
|
-
fetchUCMLinesDataSpy = jest.spyOn(callHistory, 'fetchUCMLinesData').mockResolvedValue({});
|
|
579
|
-
callHistoryPayload = _callHistoryFixtures.mockCallHistoryBody;
|
|
580
|
-
webex.request.mockResolvedValue(callHistoryPayload);
|
|
581
|
-
_context14.next = 6;
|
|
582
|
-
return callHistory.getCallHistoryData(7, 10, _types2.SORT.DEFAULT, _types2.SORT_BY.DEFAULT);
|
|
583
|
-
case 6:
|
|
584
|
-
expect(fetchUCMLinesDataSpy).not.toHaveBeenCalled(); // Check that fetchUCMLinesData was not called
|
|
585
|
-
case 7:
|
|
586
|
-
case "end":
|
|
587
|
-
return _context14.stop();
|
|
588
|
-
}
|
|
589
|
-
}, _callee14);
|
|
590
|
-
})));
|
|
591
|
-
});
|
|
592
|
-
describe('Delete call history records test', function () {
|
|
593
|
-
var methodDetails = {
|
|
594
|
-
file: _constants.CALL_HISTORY_FILE,
|
|
595
|
-
method: _constants.METHODS.DELETE_CALL_HISTORY_RECORDS
|
|
596
|
-
};
|
|
597
|
-
afterEach(function () {
|
|
598
|
-
jest.clearAllMocks();
|
|
599
|
-
});
|
|
600
|
-
beforeEach(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee15() {
|
|
601
|
-
return _regenerator.default.wrap(function _callee15$(_context15) {
|
|
602
|
-
while (1) switch (_context15.prev = _context15.next) {
|
|
603
|
-
case 0:
|
|
604
|
-
serviceErrorCodeHandlerSpy = jest.spyOn(utils, 'serviceErrorCodeHandler');
|
|
605
|
-
uploadLogsSpy = jest.spyOn(utils, 'uploadLogs').mockResolvedValue();
|
|
606
|
-
global.fetch = jest.fn(function () {
|
|
607
|
-
return _promise.default.resolve({
|
|
608
|
-
status: 200,
|
|
609
|
-
ok: true,
|
|
610
|
-
json: function json() {
|
|
611
|
-
return _promise.default.resolve(_callHistoryFixtures.MOCK_DELETE_CALL_HISTORY_RECORDS_RESPONSE);
|
|
612
|
-
}
|
|
613
|
-
});
|
|
614
|
-
});
|
|
615
|
-
case 3:
|
|
616
|
-
case "end":
|
|
617
|
-
return _context15.stop();
|
|
618
|
-
}
|
|
619
|
-
}, _callee15);
|
|
620
|
-
})));
|
|
621
|
-
it('successfully deletes the call history records', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee16() {
|
|
622
|
-
var deleteSessionIds, response, convertedEndTimeSessionIds;
|
|
623
|
-
return _regenerator.default.wrap(function _callee16$(_context16) {
|
|
624
|
-
while (1) switch (_context16.prev = _context16.next) {
|
|
625
|
-
case 0:
|
|
626
|
-
deleteSessionIds = [{
|
|
627
|
-
endTime: '2024-10-22T08:50:48.603Z',
|
|
628
|
-
sessionId: '123'
|
|
629
|
-
}];
|
|
630
|
-
_context16.next = 3;
|
|
631
|
-
return callHistory.deleteCallHistoryRecords(deleteSessionIds);
|
|
632
|
-
case 3:
|
|
633
|
-
response = _context16.sent;
|
|
634
|
-
convertedEndTimeSessionIds = deleteSessionIds.map(function (session) {
|
|
635
|
-
return _objectSpread(_objectSpread({}, session), {}, {
|
|
636
|
-
endTime: new Date(session.endTime).getTime()
|
|
637
|
-
});
|
|
638
|
-
});
|
|
639
|
-
expect(response.statusCode).toEqual(200);
|
|
640
|
-
expect(response).toEqual(_callHistoryFixtures.MOCK_DELETE_CALL_HISTORY_RECORDS_RESPONSE);
|
|
641
|
-
_context16.t0 = expect(global.fetch);
|
|
642
|
-
_context16.t1 = _callHistoryFixtures.janusMarkAsDeletedUrl;
|
|
643
|
-
_context16.t2 = _types2.HTTP_METHODS.POST;
|
|
644
|
-
_context16.t3 = _defineProperty2.default;
|
|
645
|
-
_context16.t4 = (0, _defineProperty2.default)({}, _constants.CONTENT_TYPE, _constants.APPLICATION_JSON);
|
|
646
|
-
_context16.next = 14;
|
|
647
|
-
return webex.credentials.getUserToken();
|
|
648
|
-
case 14:
|
|
649
|
-
_context16.t5 = _context16.sent;
|
|
650
|
-
_context16.t6 = (0, _context16.t3)(_context16.t4, "Authorization", _context16.t5);
|
|
651
|
-
_context16.t7 = (0, _stringify.default)({
|
|
652
|
-
deleteSessionIds: convertedEndTimeSessionIds
|
|
653
|
-
});
|
|
654
|
-
_context16.t8 = {
|
|
655
|
-
method: _context16.t2,
|
|
656
|
-
headers: _context16.t6,
|
|
657
|
-
body: _context16.t7
|
|
658
|
-
};
|
|
659
|
-
_context16.t0.toBeCalledOnceWith.call(_context16.t0, _context16.t1, _context16.t8);
|
|
660
|
-
// Verify logs were called with correct information
|
|
661
|
-
expect(infoSpy).toHaveBeenCalledWith("".concat(_constants2.METHOD_START_MESSAGE, " with sessions: ").concat((0, _stringify.default)(deleteSessionIds)), methodDetails);
|
|
662
|
-
expect(logSpy).toHaveBeenCalledWith("Successfully deleted ".concat(deleteSessionIds.length, " call history records"), methodDetails);
|
|
663
|
-
expect(errorSpy).not.toHaveBeenCalled();
|
|
664
|
-
expect(uploadLogsSpy).not.toHaveBeenCalled();
|
|
665
|
-
case 23:
|
|
666
|
-
case "end":
|
|
667
|
-
return _context16.stop();
|
|
668
|
-
}
|
|
669
|
-
}, _callee16);
|
|
670
|
-
})));
|
|
671
|
-
it('Error: deleteCallHistoryRecords throw 400 error', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee17() {
|
|
672
|
-
var deleteSessionIds, response, convertedEndTimeSessionIds;
|
|
673
|
-
return _regenerator.default.wrap(function _callee17$(_context17) {
|
|
674
|
-
while (1) switch (_context17.prev = _context17.next) {
|
|
675
|
-
case 0:
|
|
676
|
-
deleteSessionIds = [];
|
|
677
|
-
global.fetch = jest.fn(function () {
|
|
678
|
-
return _promise.default.resolve({
|
|
679
|
-
status: 400,
|
|
680
|
-
ok: false
|
|
681
|
-
});
|
|
682
|
-
});
|
|
683
|
-
_context17.next = 4;
|
|
684
|
-
return callHistory.deleteCallHistoryRecords(deleteSessionIds);
|
|
685
|
-
case 4:
|
|
686
|
-
response = _context17.sent;
|
|
687
|
-
convertedEndTimeSessionIds = deleteSessionIds.map(function (session) {
|
|
688
|
-
return _objectSpread(_objectSpread({}, session), {}, {
|
|
689
|
-
endTime: new Date(session.endTime).getTime()
|
|
690
|
-
});
|
|
691
|
-
});
|
|
692
|
-
expect(response).toStrictEqual(_callHistoryFixtures.ERROR_DETAILS_400);
|
|
693
|
-
expect(response.statusCode).toBe(400);
|
|
694
|
-
_context17.t0 = expect(global.fetch);
|
|
695
|
-
_context17.t1 = _callHistoryFixtures.janusMarkAsDeletedUrl;
|
|
696
|
-
_context17.t2 = _types2.HTTP_METHODS.POST;
|
|
697
|
-
_context17.t3 = _defineProperty2.default;
|
|
698
|
-
_context17.t4 = (0, _defineProperty2.default)({}, _constants.CONTENT_TYPE, _constants.APPLICATION_JSON);
|
|
699
|
-
_context17.next = 15;
|
|
700
|
-
return webex.credentials.getUserToken();
|
|
701
|
-
case 15:
|
|
702
|
-
_context17.t5 = _context17.sent;
|
|
703
|
-
_context17.t6 = (0, _context17.t3)(_context17.t4, "Authorization", _context17.t5);
|
|
704
|
-
_context17.t7 = (0, _stringify.default)({
|
|
705
|
-
deleteSessionIds: convertedEndTimeSessionIds
|
|
706
|
-
});
|
|
707
|
-
_context17.t8 = {
|
|
708
|
-
method: _context17.t2,
|
|
709
|
-
headers: _context17.t6,
|
|
710
|
-
body: _context17.t7
|
|
711
|
-
};
|
|
712
|
-
_context17.t0.toBeCalledOnceWith.call(_context17.t0, _context17.t1, _context17.t8);
|
|
713
|
-
expect(serviceErrorCodeHandlerSpy).toBeCalledOnceWith({
|
|
714
|
-
statusCode: 400
|
|
715
|
-
}, methodDetails);
|
|
716
|
-
expect(errorSpy).toHaveBeenCalled();
|
|
717
|
-
expect(uploadLogsSpy).toHaveBeenCalledTimes(1);
|
|
718
|
-
case 23:
|
|
719
|
-
case "end":
|
|
720
|
-
return _context17.stop();
|
|
721
|
-
}
|
|
722
|
-
}, _callee17);
|
|
723
|
-
})));
|
|
724
|
-
it('Error: deleteCallHistoryRecords throw 401 error', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee18() {
|
|
725
|
-
var deleteSessionIds, response, convertedEndTimeSessionIds;
|
|
726
|
-
return _regenerator.default.wrap(function _callee18$(_context18) {
|
|
727
|
-
while (1) switch (_context18.prev = _context18.next) {
|
|
728
|
-
case 0:
|
|
729
|
-
deleteSessionIds = [];
|
|
730
|
-
global.fetch = jest.fn(function () {
|
|
731
|
-
return _promise.default.resolve({
|
|
732
|
-
status: 401,
|
|
733
|
-
ok: false
|
|
734
|
-
});
|
|
735
|
-
});
|
|
736
|
-
_context18.next = 4;
|
|
737
|
-
return callHistory.deleteCallHistoryRecords(deleteSessionIds);
|
|
738
|
-
case 4:
|
|
739
|
-
response = _context18.sent;
|
|
740
|
-
convertedEndTimeSessionIds = deleteSessionIds.map(function (session) {
|
|
741
|
-
return _objectSpread(_objectSpread({}, session), {}, {
|
|
742
|
-
endTime: new Date(session.endTime).getTime()
|
|
743
|
-
});
|
|
744
|
-
});
|
|
745
|
-
expect(response).toStrictEqual(_callHistoryFixtures.ERROR_DETAILS_401);
|
|
746
|
-
expect(response.statusCode).toBe(401);
|
|
747
|
-
_context18.t0 = expect(global.fetch);
|
|
748
|
-
_context18.t1 = _callHistoryFixtures.janusMarkAsDeletedUrl;
|
|
749
|
-
_context18.t2 = _types2.HTTP_METHODS.POST;
|
|
750
|
-
_context18.t3 = _defineProperty2.default;
|
|
751
|
-
_context18.t4 = (0, _defineProperty2.default)({}, _constants.CONTENT_TYPE, _constants.APPLICATION_JSON);
|
|
752
|
-
_context18.next = 15;
|
|
753
|
-
return webex.credentials.getUserToken();
|
|
754
|
-
case 15:
|
|
755
|
-
_context18.t5 = _context18.sent;
|
|
756
|
-
_context18.t6 = (0, _context18.t3)(_context18.t4, "Authorization", _context18.t5);
|
|
757
|
-
_context18.t7 = (0, _stringify.default)({
|
|
758
|
-
deleteSessionIds: convertedEndTimeSessionIds
|
|
759
|
-
});
|
|
760
|
-
_context18.t8 = {
|
|
761
|
-
method: _context18.t2,
|
|
762
|
-
headers: _context18.t6,
|
|
763
|
-
body: _context18.t7
|
|
764
|
-
};
|
|
765
|
-
_context18.t0.toBeCalledOnceWith.call(_context18.t0, _context18.t1, _context18.t8);
|
|
766
|
-
expect(serviceErrorCodeHandlerSpy).toBeCalledOnceWith({
|
|
767
|
-
statusCode: 401
|
|
768
|
-
}, methodDetails);
|
|
769
|
-
expect(errorSpy).toHaveBeenCalledWith(expect.any(Error), {
|
|
770
|
-
file: _constants.CALL_HISTORY_FILE,
|
|
771
|
-
method: _constants.METHODS.DELETE_CALL_HISTORY_RECORDS
|
|
772
|
-
});
|
|
773
|
-
expect(uploadLogsSpy).toHaveBeenCalledTimes(1);
|
|
774
|
-
case 23:
|
|
775
|
-
case "end":
|
|
776
|
-
return _context18.stop();
|
|
777
|
-
}
|
|
778
|
-
}, _callee18);
|
|
779
|
-
})));
|
|
780
|
-
it('handles invalid date formats gracefully', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee19() {
|
|
781
|
-
var deleteSessionIds, response;
|
|
782
|
-
return _regenerator.default.wrap(function _callee19$(_context19) {
|
|
783
|
-
while (1) switch (_context19.prev = _context19.next) {
|
|
784
|
-
case 0:
|
|
785
|
-
deleteSessionIds = [{
|
|
786
|
-
endTime: 'invalid-date',
|
|
787
|
-
sessionId: '123'
|
|
788
|
-
}]; // Mock the response to be 400 and trigger an error in your function
|
|
789
|
-
global.fetch = jest.fn(function () {
|
|
790
|
-
return _promise.default.resolve({
|
|
791
|
-
status: 400,
|
|
792
|
-
ok: false
|
|
793
|
-
});
|
|
794
|
-
});
|
|
795
|
-
_context19.next = 4;
|
|
796
|
-
return callHistory.deleteCallHistoryRecords(deleteSessionIds);
|
|
797
|
-
case 4:
|
|
798
|
-
response = _context19.sent;
|
|
799
|
-
expect(response.statusCode).toBe(400);
|
|
800
|
-
expect(response).toEqual(_callHistoryFixtures.MOCK_DELETE_CALL_HISTORY_INVALID_DATE_RESPONSE);
|
|
801
|
-
|
|
802
|
-
// Verify logs were called with correct information
|
|
803
|
-
expect(infoSpy).toHaveBeenCalledWith(expect.stringContaining('The provided date is malformed or invalid'), methodDetails);
|
|
804
|
-
expect(uploadLogsSpy).not.toHaveBeenCalled();
|
|
805
|
-
case 9:
|
|
806
|
-
case "end":
|
|
807
|
-
return _context19.stop();
|
|
808
|
-
}
|
|
809
|
-
}, _callee19);
|
|
810
|
-
})));
|
|
811
|
-
});
|
|
812
|
-
});
|
|
813
|
-
//# sourceMappingURL=CallHistory.test.js.map
|