@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,916 @@
|
|
|
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 _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
|
|
13
|
+
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
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 _t41 in e) "default" !== _t41 && {}.hasOwnProperty.call(e, _t41) && ((i = (o = _Object$defineProperty) && _Object$getOwnPropertyDescriptor(e, _t41)) && (i.get || i.set) ? o(f, _t41, i) : f[_t41] = e[_t41]); 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 (_context) {
|
|
47
|
+
while (1) switch (_context.prev = _context.next) {
|
|
48
|
+
case 0:
|
|
49
|
+
callHistoryPayload = _callHistoryFixtures.mockCallHistoryBody;
|
|
50
|
+
webex.request.mockResolvedValue(callHistoryPayload);
|
|
51
|
+
_context.next = 1;
|
|
52
|
+
return callHistory.getCallHistoryData(7, 10, _types2.SORT.DEFAULT, _types2.SORT_BY.DEFAULT);
|
|
53
|
+
case 1:
|
|
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 2:
|
|
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 (_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 = 1;
|
|
91
|
+
return callHistory.getCallHistoryData(7, 2000, _types2.SORT.ASC, _types2.SORT_BY.START_TIME);
|
|
92
|
+
case 1:
|
|
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).toHaveBeenCalledWith("Failed to get call history: ".concat((0, _stringify.default)(failurePayload)), {
|
|
103
|
+
file: _constants.CALL_HISTORY_FILE,
|
|
104
|
+
method: _constants.METHODS.GET_CALL_HISTORY_DATA
|
|
105
|
+
});
|
|
106
|
+
expect(uploadLogsSpy).toHaveBeenCalledTimes(1);
|
|
107
|
+
case 2:
|
|
108
|
+
case "end":
|
|
109
|
+
return _context2.stop();
|
|
110
|
+
}
|
|
111
|
+
}, _callee2);
|
|
112
|
+
})));
|
|
113
|
+
it('verify device not found call history case', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
114
|
+
var failurePayload, callHistoryPayload, response;
|
|
115
|
+
return _regenerator.default.wrap(function (_context3) {
|
|
116
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
117
|
+
case 0:
|
|
118
|
+
failurePayload = {
|
|
119
|
+
statusCode: 404
|
|
120
|
+
};
|
|
121
|
+
callHistoryPayload = failurePayload;
|
|
122
|
+
webex.request.mockRejectedValue(callHistoryPayload);
|
|
123
|
+
_context3.next = 1;
|
|
124
|
+
return callHistory.getCallHistoryData(0, 0, _types2.SORT.ASC, _types2.SORT_BY.START_TIME);
|
|
125
|
+
case 1:
|
|
126
|
+
response = _context3.sent;
|
|
127
|
+
expect(response.statusCode).toBe(404);
|
|
128
|
+
expect(response.message).toBe('FAILURE');
|
|
129
|
+
|
|
130
|
+
// Verify logs were called with correct information
|
|
131
|
+
expect(infoSpy).toHaveBeenCalledWith('invoking with days=0, limit=0, sort=ASC, sortBy=startTime', {
|
|
132
|
+
file: _constants.CALL_HISTORY_FILE,
|
|
133
|
+
method: _constants.METHODS.GET_CALL_HISTORY_DATA
|
|
134
|
+
});
|
|
135
|
+
expect(errorSpy).toHaveBeenCalledWith("Failed to get call history: ".concat((0, _stringify.default)(failurePayload)), {
|
|
136
|
+
file: _constants.CALL_HISTORY_FILE,
|
|
137
|
+
method: _constants.METHODS.GET_CALL_HISTORY_DATA
|
|
138
|
+
});
|
|
139
|
+
expect(uploadLogsSpy).toHaveBeenCalledTimes(1);
|
|
140
|
+
case 2:
|
|
141
|
+
case "end":
|
|
142
|
+
return _context3.stop();
|
|
143
|
+
}
|
|
144
|
+
}, _callee3);
|
|
145
|
+
})));
|
|
146
|
+
describe('sorting user session response data by sortby', function () {
|
|
147
|
+
it('Array should be sort.ASC by START TIME ', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee4() {
|
|
148
|
+
var callHistoryPayload, response, responseDetails;
|
|
149
|
+
return _regenerator.default.wrap(function (_context4) {
|
|
150
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
151
|
+
case 0:
|
|
152
|
+
callHistoryPayload = _callHistoryFixtures.mockCallHistoryBody;
|
|
153
|
+
webex.request.mockResolvedValue(callHistoryPayload);
|
|
154
|
+
_context4.next = 1;
|
|
155
|
+
return callHistory.getCallHistoryData(10, 20, _types2.SORT.ASC, _types2.SORT_BY.START_TIME);
|
|
156
|
+
case 1:
|
|
157
|
+
response = _context4.sent;
|
|
158
|
+
responseDetails = {
|
|
159
|
+
statusCode: _callHistoryFixtures.sortedCallHistory.body.statusCode,
|
|
160
|
+
data: {
|
|
161
|
+
userSessions: _callHistoryFixtures.sortedCallHistory.body.userSessions
|
|
162
|
+
},
|
|
163
|
+
message: 'SUCCESS'
|
|
164
|
+
};
|
|
165
|
+
expect(response).toEqual(responseDetails);
|
|
166
|
+
|
|
167
|
+
// Verify logs were called with correct information
|
|
168
|
+
expect(infoSpy).toHaveBeenCalledWith('invoking with days=10, limit=20, sort=ASC, sortBy=startTime', {
|
|
169
|
+
file: _constants.CALL_HISTORY_FILE,
|
|
170
|
+
method: _constants.METHODS.GET_CALL_HISTORY_DATA
|
|
171
|
+
});
|
|
172
|
+
case 2:
|
|
173
|
+
case "end":
|
|
174
|
+
return _context4.stop();
|
|
175
|
+
}
|
|
176
|
+
}, _callee4);
|
|
177
|
+
})));
|
|
178
|
+
});
|
|
179
|
+
describe('Call History Session Event test', function () {
|
|
180
|
+
var mockOn = webex.internal.mercury.on;
|
|
181
|
+
var callHistory;
|
|
182
|
+
beforeEach(function () {
|
|
183
|
+
callHistory = (0, _CallHistory.createCallHistoryClient)(webex, {
|
|
184
|
+
level: _types.LOGGER.INFO
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
it('verify the recent user session event ', function (done) {
|
|
188
|
+
callHistory.on(_types3.COMMON_EVENT_KEYS.CALL_HISTORY_USER_SESSION_INFO, function (event) {
|
|
189
|
+
expect(event.data).toEqual(_callHistoryFixtures.MOCK_SESSION_EVENT.data);
|
|
190
|
+
done();
|
|
191
|
+
});
|
|
192
|
+
expect(mockOn.mock.calls[0][0]).toEqual(_types3.MOBIUS_EVENT_KEYS.CALL_SESSION_EVENT_INCLUSIVE);
|
|
193
|
+
var callSessionCallback = mockOn.mock.calls[0][1];
|
|
194
|
+
callSessionCallback(_callHistoryFixtures.MOCK_SESSION_EVENT);
|
|
195
|
+
});
|
|
196
|
+
it('verify the user session event received for locus calls', function (done) {
|
|
197
|
+
callHistory.on(_types3.COMMON_EVENT_KEYS.CALL_HISTORY_USER_SESSION_INFO, function (event) {
|
|
198
|
+
expect(event.data).toEqual(_callHistoryFixtures.MOCK_SESSION_EVENT_LEGACY.data);
|
|
199
|
+
done();
|
|
200
|
+
});
|
|
201
|
+
expect(mockOn.mock.calls[1][0]).toEqual(_types3.MOBIUS_EVENT_KEYS.CALL_SESSION_EVENT_LEGACY);
|
|
202
|
+
var callSessionCallback = mockOn.mock.calls[1][1];
|
|
203
|
+
callSessionCallback(_callHistoryFixtures.MOCK_SESSION_EVENT_LEGACY);
|
|
204
|
+
});
|
|
205
|
+
it('verify the user viewed session event for missed calls update', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee5() {
|
|
206
|
+
return _regenerator.default.wrap(function (_context5) {
|
|
207
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
208
|
+
case 0:
|
|
209
|
+
_context5.next = 1;
|
|
210
|
+
return new _promise.default(function (resolve) {
|
|
211
|
+
callHistory.on(_types3.COMMON_EVENT_KEYS.CALL_HISTORY_USER_VIEWED_SESSIONS, function (event) {
|
|
212
|
+
expect(event.data).toEqual(_callHistoryFixtures.MOCK_SESSION_EVENT_VIEWED.data);
|
|
213
|
+
resolve();
|
|
214
|
+
});
|
|
215
|
+
expect(mockOn.mock.calls[2][0]).toEqual(_types3.MOBIUS_EVENT_KEYS.CALL_SESSION_EVENT_VIEWED);
|
|
216
|
+
var callSessionCallback = mockOn.mock.calls[2][1];
|
|
217
|
+
callSessionCallback(_callHistoryFixtures.MOCK_SESSION_EVENT_VIEWED);
|
|
218
|
+
});
|
|
219
|
+
case 1:
|
|
220
|
+
case "end":
|
|
221
|
+
return _context5.stop();
|
|
222
|
+
}
|
|
223
|
+
}, _callee5);
|
|
224
|
+
})));
|
|
225
|
+
it('verify the user sessions deleted event for deleting the call history records', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee6() {
|
|
226
|
+
return _regenerator.default.wrap(function (_context6) {
|
|
227
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
228
|
+
case 0:
|
|
229
|
+
_context6.next = 1;
|
|
230
|
+
return new _promise.default(function (resolve) {
|
|
231
|
+
callHistory.on(_types3.COMMON_EVENT_KEYS.CALL_HISTORY_USER_SESSIONS_DELETED, function (event) {
|
|
232
|
+
expect(event.data).toEqual(_callHistoryFixtures.MOCK_SESSION_EVENT_DELETED.data);
|
|
233
|
+
resolve();
|
|
234
|
+
});
|
|
235
|
+
expect(mockOn.mock.calls[3][0]).toEqual(_types3.MOBIUS_EVENT_KEYS.CALL_SESSION_EVENT_DELETED);
|
|
236
|
+
var callSessionCallback = mockOn.mock.calls[3][1];
|
|
237
|
+
callSessionCallback(_callHistoryFixtures.MOCK_SESSION_EVENT_DELETED);
|
|
238
|
+
});
|
|
239
|
+
case 1:
|
|
240
|
+
case "end":
|
|
241
|
+
return _context6.stop();
|
|
242
|
+
}
|
|
243
|
+
}, _callee6);
|
|
244
|
+
})));
|
|
245
|
+
});
|
|
246
|
+
describe('Update missed calls test', function () {
|
|
247
|
+
var methodDetails = {
|
|
248
|
+
file: _constants.CALL_HISTORY_FILE,
|
|
249
|
+
method: _constants.METHODS.UPDATE_MISSED_CALLS
|
|
250
|
+
};
|
|
251
|
+
afterEach(function () {
|
|
252
|
+
jest.clearAllMocks();
|
|
253
|
+
});
|
|
254
|
+
beforeEach(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee7() {
|
|
255
|
+
return _regenerator.default.wrap(function (_context7) {
|
|
256
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
257
|
+
case 0:
|
|
258
|
+
serviceErrorCodeHandlerSpy = jest.spyOn(utils, 'serviceErrorCodeHandler');
|
|
259
|
+
uploadLogsSpy = jest.spyOn(utils, 'uploadLogs').mockResolvedValue();
|
|
260
|
+
global.fetch = jest.fn(function () {
|
|
261
|
+
return _promise.default.resolve({
|
|
262
|
+
status: 200,
|
|
263
|
+
ok: true,
|
|
264
|
+
json: function json() {
|
|
265
|
+
return _promise.default.resolve(_callHistoryFixtures.MOCK_UPDATE_MISSED_CALL_RESPONSE);
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
case 1:
|
|
270
|
+
case "end":
|
|
271
|
+
return _context7.stop();
|
|
272
|
+
}
|
|
273
|
+
}, _callee7);
|
|
274
|
+
})));
|
|
275
|
+
it('successfully updates missed calls', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee8() {
|
|
276
|
+
var endTimeSessionIds, response, convertedEndTimeSessionIds, _t, _t2, _t3, _t4, _t5, _t6, _t7;
|
|
277
|
+
return _regenerator.default.wrap(function (_context8) {
|
|
278
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
279
|
+
case 0:
|
|
280
|
+
endTimeSessionIds = [{
|
|
281
|
+
endTime: '1234568',
|
|
282
|
+
sessionId: '123'
|
|
283
|
+
}];
|
|
284
|
+
_context8.next = 1;
|
|
285
|
+
return callHistory.updateMissedCalls(endTimeSessionIds);
|
|
286
|
+
case 1:
|
|
287
|
+
response = _context8.sent;
|
|
288
|
+
convertedEndTimeSessionIds = endTimeSessionIds.map(function (session) {
|
|
289
|
+
return _objectSpread(_objectSpread({}, session), {}, {
|
|
290
|
+
endTime: new Date(session.endTime).getTime()
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
expect(response.statusCode).toEqual(200);
|
|
294
|
+
expect(response).toEqual(_callHistoryFixtures.MOCK_UPDATE_MISSED_CALL_RESPONSE);
|
|
295
|
+
_t = expect(global.fetch);
|
|
296
|
+
_t2 = _callHistoryFixtures.janusSetReadStateUrl;
|
|
297
|
+
_t3 = _types2.HTTP_METHODS.POST;
|
|
298
|
+
_t4 = _defineProperty2.default;
|
|
299
|
+
_t5 = (0, _defineProperty2.default)({}, _constants.CONTENT_TYPE, _constants.APPLICATION_JSON);
|
|
300
|
+
_context8.next = 2;
|
|
301
|
+
return webex.credentials.getUserToken();
|
|
302
|
+
case 2:
|
|
303
|
+
_t6 = _t4(_t5, "Authorization", _context8.sent);
|
|
304
|
+
_t7 = (0, _stringify.default)({
|
|
305
|
+
endTimeSessionIds: convertedEndTimeSessionIds
|
|
306
|
+
});
|
|
307
|
+
_t.toBeCalledOnceWith.call(_t, _t2, {
|
|
308
|
+
method: _t3,
|
|
309
|
+
headers: _t6,
|
|
310
|
+
body: _t7
|
|
311
|
+
});
|
|
312
|
+
// Verify logs were called with correct information
|
|
313
|
+
expect(infoSpy).toHaveBeenCalledWith("".concat(_constants2.METHOD_START_MESSAGE, " with sessions: ").concat((0, _stringify.default)(convertedEndTimeSessionIds)), methodDetails);
|
|
314
|
+
expect(logSpy).toHaveBeenCalledWith('Missed calls are successfully read by the user', methodDetails);
|
|
315
|
+
expect(errorSpy).not.toHaveBeenCalled();
|
|
316
|
+
expect(uploadLogsSpy).not.toHaveBeenCalled();
|
|
317
|
+
case 3:
|
|
318
|
+
case "end":
|
|
319
|
+
return _context8.stop();
|
|
320
|
+
}
|
|
321
|
+
}, _callee8);
|
|
322
|
+
})));
|
|
323
|
+
it('Error: updateMissedCalls throw 400 error', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee9() {
|
|
324
|
+
var endTimeSessionIds, response, convertedEndTimeSessionIds, _t8, _t9, _t0, _t1, _t10, _t11, _t12;
|
|
325
|
+
return _regenerator.default.wrap(function (_context9) {
|
|
326
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
327
|
+
case 0:
|
|
328
|
+
endTimeSessionIds = [];
|
|
329
|
+
global.fetch = jest.fn(function () {
|
|
330
|
+
return _promise.default.resolve({
|
|
331
|
+
status: 400,
|
|
332
|
+
ok: false
|
|
333
|
+
});
|
|
334
|
+
});
|
|
335
|
+
_context9.next = 1;
|
|
336
|
+
return callHistory.updateMissedCalls(endTimeSessionIds);
|
|
337
|
+
case 1:
|
|
338
|
+
response = _context9.sent;
|
|
339
|
+
convertedEndTimeSessionIds = endTimeSessionIds.map(function (session) {
|
|
340
|
+
return _objectSpread(_objectSpread({}, session), {}, {
|
|
341
|
+
endTime: new Date(session.endTime).getTime()
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
expect(response).toStrictEqual(_callHistoryFixtures.ERROR_DETAILS_400);
|
|
345
|
+
expect(response.statusCode).toBe(400);
|
|
346
|
+
_t8 = expect(global.fetch);
|
|
347
|
+
_t9 = _callHistoryFixtures.janusSetReadStateUrl;
|
|
348
|
+
_t0 = _types2.HTTP_METHODS.POST;
|
|
349
|
+
_t1 = _defineProperty2.default;
|
|
350
|
+
_t10 = (0, _defineProperty2.default)({}, _constants.CONTENT_TYPE, _constants.APPLICATION_JSON);
|
|
351
|
+
_context9.next = 2;
|
|
352
|
+
return webex.credentials.getUserToken();
|
|
353
|
+
case 2:
|
|
354
|
+
_t11 = _t1(_t10, "Authorization", _context9.sent);
|
|
355
|
+
_t12 = (0, _stringify.default)({
|
|
356
|
+
endTimeSessionIds: convertedEndTimeSessionIds
|
|
357
|
+
});
|
|
358
|
+
_t8.toBeCalledOnceWith.call(_t8, _t9, {
|
|
359
|
+
method: _t0,
|
|
360
|
+
headers: _t11,
|
|
361
|
+
body: _t12
|
|
362
|
+
});
|
|
363
|
+
expect(serviceErrorCodeHandlerSpy).toBeCalledOnceWith({
|
|
364
|
+
statusCode: 400
|
|
365
|
+
}, methodDetails);
|
|
366
|
+
expect(errorSpy).toBeCalledWith(expect.stringContaining('Failed to update missed calls'), methodDetails);
|
|
367
|
+
expect(uploadLogsSpy).toHaveBeenCalledTimes(1);
|
|
368
|
+
case 3:
|
|
369
|
+
case "end":
|
|
370
|
+
return _context9.stop();
|
|
371
|
+
}
|
|
372
|
+
}, _callee9);
|
|
373
|
+
})));
|
|
374
|
+
it('Error: updateMissedCalls throw 401 error', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee0() {
|
|
375
|
+
var endTimeSessionIds, response, convertedEndTimeSessionIds, _t13, _t14, _t15, _t16, _t17, _t18, _t19;
|
|
376
|
+
return _regenerator.default.wrap(function (_context0) {
|
|
377
|
+
while (1) switch (_context0.prev = _context0.next) {
|
|
378
|
+
case 0:
|
|
379
|
+
endTimeSessionIds = [];
|
|
380
|
+
global.fetch = jest.fn(function () {
|
|
381
|
+
return _promise.default.resolve({
|
|
382
|
+
status: 401,
|
|
383
|
+
ok: false
|
|
384
|
+
});
|
|
385
|
+
});
|
|
386
|
+
_context0.next = 1;
|
|
387
|
+
return callHistory.updateMissedCalls(endTimeSessionIds);
|
|
388
|
+
case 1:
|
|
389
|
+
response = _context0.sent;
|
|
390
|
+
convertedEndTimeSessionIds = endTimeSessionIds.map(function (session) {
|
|
391
|
+
return _objectSpread(_objectSpread({}, session), {}, {
|
|
392
|
+
endTime: new Date(session.endTime).getTime()
|
|
393
|
+
});
|
|
394
|
+
});
|
|
395
|
+
expect(response).toStrictEqual(_callHistoryFixtures.ERROR_DETAILS_401);
|
|
396
|
+
expect(response.statusCode).toBe(401);
|
|
397
|
+
_t13 = expect(global.fetch);
|
|
398
|
+
_t14 = _callHistoryFixtures.janusSetReadStateUrl;
|
|
399
|
+
_t15 = _types2.HTTP_METHODS.POST;
|
|
400
|
+
_t16 = _defineProperty2.default;
|
|
401
|
+
_t17 = (0, _defineProperty2.default)({}, _constants.CONTENT_TYPE, _constants.APPLICATION_JSON);
|
|
402
|
+
_context0.next = 2;
|
|
403
|
+
return webex.credentials.getUserToken();
|
|
404
|
+
case 2:
|
|
405
|
+
_t18 = _t16(_t17, "Authorization", _context0.sent);
|
|
406
|
+
_t19 = (0, _stringify.default)({
|
|
407
|
+
endTimeSessionIds: convertedEndTimeSessionIds
|
|
408
|
+
});
|
|
409
|
+
_t13.toBeCalledOnceWith.call(_t13, _t14, {
|
|
410
|
+
method: _t15,
|
|
411
|
+
headers: _t18,
|
|
412
|
+
body: _t19
|
|
413
|
+
});
|
|
414
|
+
expect(serviceErrorCodeHandlerSpy).toBeCalledOnceWith({
|
|
415
|
+
statusCode: 401
|
|
416
|
+
}, methodDetails);
|
|
417
|
+
expect(errorSpy).toHaveBeenCalled();
|
|
418
|
+
expect(uploadLogsSpy).toHaveBeenCalledTimes(1);
|
|
419
|
+
case 3:
|
|
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 (_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 = 1;
|
|
438
|
+
return callHistory['fetchUCMLinesData']();
|
|
439
|
+
case 1:
|
|
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 2:
|
|
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 (_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 = 1;
|
|
472
|
+
return callHistory['fetchUCMLinesData']();
|
|
473
|
+
case 1:
|
|
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 2:
|
|
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 (_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 = 1;
|
|
511
|
+
return callHistory.getCallHistoryData(7, 10, _types2.SORT.DEFAULT, _types2.SORT_BY.DEFAULT);
|
|
512
|
+
case 1:
|
|
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 2:
|
|
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 (_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 = 1;
|
|
536
|
+
return callHistory.getCallHistoryData(7, 10, _types2.SORT.DEFAULT, _types2.SORT_BY.DEFAULT);
|
|
537
|
+
case 1:
|
|
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 2:
|
|
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 (_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 = 1;
|
|
561
|
+
return callHistory.getCallHistoryData(7, 10, _types2.SORT.DEFAULT, _types2.SORT_BY.DEFAULT);
|
|
562
|
+
case 1:
|
|
563
|
+
expect(fetchUCMLinesDataSpy).not.toHaveBeenCalled();
|
|
564
|
+
case 2:
|
|
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 (_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 = 1;
|
|
582
|
+
return callHistory.getCallHistoryData(7, 10, _types2.SORT.DEFAULT, _types2.SORT_BY.DEFAULT);
|
|
583
|
+
case 1:
|
|
584
|
+
expect(fetchUCMLinesDataSpy).not.toHaveBeenCalled(); // Check that fetchUCMLinesData was not called
|
|
585
|
+
case 2:
|
|
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 (_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 1:
|
|
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, _t20, _t21, _t22, _t23, _t24, _t25, _t26;
|
|
623
|
+
return _regenerator.default.wrap(function (_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 = 1;
|
|
631
|
+
return callHistory.deleteCallHistoryRecords(deleteSessionIds);
|
|
632
|
+
case 1:
|
|
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
|
+
_t20 = expect(global.fetch);
|
|
642
|
+
_t21 = _callHistoryFixtures.janusMarkAsDeletedUrl;
|
|
643
|
+
_t22 = _types2.HTTP_METHODS.POST;
|
|
644
|
+
_t23 = _defineProperty2.default;
|
|
645
|
+
_t24 = (0, _defineProperty2.default)({}, _constants.CONTENT_TYPE, _constants.APPLICATION_JSON);
|
|
646
|
+
_context16.next = 2;
|
|
647
|
+
return webex.credentials.getUserToken();
|
|
648
|
+
case 2:
|
|
649
|
+
_t25 = _t23(_t24, "Authorization", _context16.sent);
|
|
650
|
+
_t26 = (0, _stringify.default)({
|
|
651
|
+
deleteSessionIds: convertedEndTimeSessionIds
|
|
652
|
+
});
|
|
653
|
+
_t20.toBeCalledOnceWith.call(_t20, _t21, {
|
|
654
|
+
method: _t22,
|
|
655
|
+
headers: _t25,
|
|
656
|
+
body: _t26
|
|
657
|
+
});
|
|
658
|
+
// Verify logs were called with correct information
|
|
659
|
+
expect(infoSpy).toHaveBeenCalledWith("".concat(_constants2.METHOD_START_MESSAGE, " with sessions: ").concat((0, _stringify.default)(deleteSessionIds)), methodDetails);
|
|
660
|
+
expect(logSpy).toHaveBeenCalledWith("Successfully deleted ".concat(deleteSessionIds.length, " call history records"), methodDetails);
|
|
661
|
+
expect(errorSpy).not.toHaveBeenCalled();
|
|
662
|
+
expect(uploadLogsSpy).not.toHaveBeenCalled();
|
|
663
|
+
case 3:
|
|
664
|
+
case "end":
|
|
665
|
+
return _context16.stop();
|
|
666
|
+
}
|
|
667
|
+
}, _callee16);
|
|
668
|
+
})));
|
|
669
|
+
it('Error: deleteCallHistoryRecords throw 400 error', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee17() {
|
|
670
|
+
var deleteSessionIds, response, convertedEndTimeSessionIds, _t27, _t28, _t29, _t30, _t31, _t32, _t33;
|
|
671
|
+
return _regenerator.default.wrap(function (_context17) {
|
|
672
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
673
|
+
case 0:
|
|
674
|
+
deleteSessionIds = [];
|
|
675
|
+
global.fetch = jest.fn(function () {
|
|
676
|
+
return _promise.default.resolve({
|
|
677
|
+
status: 400,
|
|
678
|
+
ok: false
|
|
679
|
+
});
|
|
680
|
+
});
|
|
681
|
+
_context17.next = 1;
|
|
682
|
+
return callHistory.deleteCallHistoryRecords(deleteSessionIds);
|
|
683
|
+
case 1:
|
|
684
|
+
response = _context17.sent;
|
|
685
|
+
convertedEndTimeSessionIds = deleteSessionIds.map(function (session) {
|
|
686
|
+
return _objectSpread(_objectSpread({}, session), {}, {
|
|
687
|
+
endTime: new Date(session.endTime).getTime()
|
|
688
|
+
});
|
|
689
|
+
});
|
|
690
|
+
expect(response).toStrictEqual(_callHistoryFixtures.ERROR_DETAILS_400);
|
|
691
|
+
expect(response.statusCode).toBe(400);
|
|
692
|
+
_t27 = expect(global.fetch);
|
|
693
|
+
_t28 = _callHistoryFixtures.janusMarkAsDeletedUrl;
|
|
694
|
+
_t29 = _types2.HTTP_METHODS.POST;
|
|
695
|
+
_t30 = _defineProperty2.default;
|
|
696
|
+
_t31 = (0, _defineProperty2.default)({}, _constants.CONTENT_TYPE, _constants.APPLICATION_JSON);
|
|
697
|
+
_context17.next = 2;
|
|
698
|
+
return webex.credentials.getUserToken();
|
|
699
|
+
case 2:
|
|
700
|
+
_t32 = _t30(_t31, "Authorization", _context17.sent);
|
|
701
|
+
_t33 = (0, _stringify.default)({
|
|
702
|
+
deleteSessionIds: convertedEndTimeSessionIds
|
|
703
|
+
});
|
|
704
|
+
_t27.toBeCalledOnceWith.call(_t27, _t28, {
|
|
705
|
+
method: _t29,
|
|
706
|
+
headers: _t32,
|
|
707
|
+
body: _t33
|
|
708
|
+
});
|
|
709
|
+
expect(serviceErrorCodeHandlerSpy).toBeCalledOnceWith({
|
|
710
|
+
statusCode: 400
|
|
711
|
+
}, methodDetails);
|
|
712
|
+
expect(errorSpy).toHaveBeenCalled();
|
|
713
|
+
expect(uploadLogsSpy).toHaveBeenCalledTimes(1);
|
|
714
|
+
case 3:
|
|
715
|
+
case "end":
|
|
716
|
+
return _context17.stop();
|
|
717
|
+
}
|
|
718
|
+
}, _callee17);
|
|
719
|
+
})));
|
|
720
|
+
it('Error: deleteCallHistoryRecords throw 401 error', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee18() {
|
|
721
|
+
var deleteSessionIds, response, convertedEndTimeSessionIds, _t34, _t35, _t36, _t37, _t38, _t39, _t40;
|
|
722
|
+
return _regenerator.default.wrap(function (_context18) {
|
|
723
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
724
|
+
case 0:
|
|
725
|
+
deleteSessionIds = [];
|
|
726
|
+
global.fetch = jest.fn(function () {
|
|
727
|
+
return _promise.default.resolve({
|
|
728
|
+
status: 401,
|
|
729
|
+
ok: false
|
|
730
|
+
});
|
|
731
|
+
});
|
|
732
|
+
_context18.next = 1;
|
|
733
|
+
return callHistory.deleteCallHistoryRecords(deleteSessionIds);
|
|
734
|
+
case 1:
|
|
735
|
+
response = _context18.sent;
|
|
736
|
+
convertedEndTimeSessionIds = deleteSessionIds.map(function (session) {
|
|
737
|
+
return _objectSpread(_objectSpread({}, session), {}, {
|
|
738
|
+
endTime: new Date(session.endTime).getTime()
|
|
739
|
+
});
|
|
740
|
+
});
|
|
741
|
+
expect(response).toStrictEqual(_callHistoryFixtures.ERROR_DETAILS_401);
|
|
742
|
+
expect(response.statusCode).toBe(401);
|
|
743
|
+
_t34 = expect(global.fetch);
|
|
744
|
+
_t35 = _callHistoryFixtures.janusMarkAsDeletedUrl;
|
|
745
|
+
_t36 = _types2.HTTP_METHODS.POST;
|
|
746
|
+
_t37 = _defineProperty2.default;
|
|
747
|
+
_t38 = (0, _defineProperty2.default)({}, _constants.CONTENT_TYPE, _constants.APPLICATION_JSON);
|
|
748
|
+
_context18.next = 2;
|
|
749
|
+
return webex.credentials.getUserToken();
|
|
750
|
+
case 2:
|
|
751
|
+
_t39 = _t37(_t38, "Authorization", _context18.sent);
|
|
752
|
+
_t40 = (0, _stringify.default)({
|
|
753
|
+
deleteSessionIds: convertedEndTimeSessionIds
|
|
754
|
+
});
|
|
755
|
+
_t34.toBeCalledOnceWith.call(_t34, _t35, {
|
|
756
|
+
method: _t36,
|
|
757
|
+
headers: _t39,
|
|
758
|
+
body: _t40
|
|
759
|
+
});
|
|
760
|
+
expect(serviceErrorCodeHandlerSpy).toBeCalledOnceWith({
|
|
761
|
+
statusCode: 401
|
|
762
|
+
}, methodDetails);
|
|
763
|
+
expect(errorSpy).toBeCalledWith(expect.stringContaining('Failed to delete call history records'), {
|
|
764
|
+
file: _constants.CALL_HISTORY_FILE,
|
|
765
|
+
method: _constants.METHODS.DELETE_CALL_HISTORY_RECORDS
|
|
766
|
+
});
|
|
767
|
+
expect(uploadLogsSpy).toHaveBeenCalledTimes(1);
|
|
768
|
+
case 3:
|
|
769
|
+
case "end":
|
|
770
|
+
return _context18.stop();
|
|
771
|
+
}
|
|
772
|
+
}, _callee18);
|
|
773
|
+
})));
|
|
774
|
+
it('handles invalid date formats gracefully', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee19() {
|
|
775
|
+
var deleteSessionIds, response;
|
|
776
|
+
return _regenerator.default.wrap(function (_context19) {
|
|
777
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
778
|
+
case 0:
|
|
779
|
+
deleteSessionIds = [{
|
|
780
|
+
endTime: 'invalid-date',
|
|
781
|
+
sessionId: '123'
|
|
782
|
+
}]; // Mock the response to be 400 and trigger an error in your function
|
|
783
|
+
global.fetch = jest.fn(function () {
|
|
784
|
+
return _promise.default.resolve({
|
|
785
|
+
status: 400,
|
|
786
|
+
ok: false
|
|
787
|
+
});
|
|
788
|
+
});
|
|
789
|
+
_context19.next = 1;
|
|
790
|
+
return callHistory.deleteCallHistoryRecords(deleteSessionIds);
|
|
791
|
+
case 1:
|
|
792
|
+
response = _context19.sent;
|
|
793
|
+
expect(response.statusCode).toBe(400);
|
|
794
|
+
expect(response).toEqual(_callHistoryFixtures.MOCK_DELETE_CALL_HISTORY_INVALID_DATE_RESPONSE);
|
|
795
|
+
|
|
796
|
+
// Verify logs were called with correct information
|
|
797
|
+
expect(infoSpy).toHaveBeenCalledWith(expect.stringContaining('The provided date is malformed or invalid'), methodDetails);
|
|
798
|
+
expect(uploadLogsSpy).not.toHaveBeenCalled();
|
|
799
|
+
case 2:
|
|
800
|
+
case "end":
|
|
801
|
+
return _context19.stop();
|
|
802
|
+
}
|
|
803
|
+
}, _callee19);
|
|
804
|
+
})));
|
|
805
|
+
});
|
|
806
|
+
describe('URL construction for shared sessions based on calling backend', function () {
|
|
807
|
+
var webexRequestSpy;
|
|
808
|
+
beforeEach(function () {
|
|
809
|
+
webexRequestSpy = jest.spyOn(webex, 'request').mockResolvedValue({
|
|
810
|
+
statusCode: 200,
|
|
811
|
+
body: {
|
|
812
|
+
statusCode: 200,
|
|
813
|
+
userSessions: []
|
|
814
|
+
}
|
|
815
|
+
});
|
|
816
|
+
});
|
|
817
|
+
afterEach(function () {
|
|
818
|
+
jest.restoreAllMocks();
|
|
819
|
+
});
|
|
820
|
+
it('should include includeSharedSessions=true for WXC backend', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee20() {
|
|
821
|
+
var callArgs;
|
|
822
|
+
return _regenerator.default.wrap(function (_context20) {
|
|
823
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
824
|
+
case 0:
|
|
825
|
+
jest.spyOn(utils, 'getCallingBackEnd').mockReturnValue(_types2.CALLING_BACKEND.WXC);
|
|
826
|
+
_context20.next = 1;
|
|
827
|
+
return callHistory.getCallHistoryData(7, 10, _types2.SORT.DEFAULT, _types2.SORT_BY.DEFAULT);
|
|
828
|
+
case 1:
|
|
829
|
+
callArgs = webexRequestSpy.mock.calls[0][0];
|
|
830
|
+
expect(callArgs.uri).toContain('&includeSharedSessions=true');
|
|
831
|
+
expect(callArgs.method).toBe(_types2.HTTP_METHODS.GET);
|
|
832
|
+
expect(callArgs.service).toBe('janus');
|
|
833
|
+
case 2:
|
|
834
|
+
case "end":
|
|
835
|
+
return _context20.stop();
|
|
836
|
+
}
|
|
837
|
+
}, _callee20);
|
|
838
|
+
})));
|
|
839
|
+
it('should NOT include includeSharedSessions for UCM backend', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee21() {
|
|
840
|
+
var callArgs;
|
|
841
|
+
return _regenerator.default.wrap(function (_context21) {
|
|
842
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
843
|
+
case 0:
|
|
844
|
+
jest.spyOn(utils, 'getCallingBackEnd').mockReturnValue(_types2.CALLING_BACKEND.UCM);
|
|
845
|
+
_context21.next = 1;
|
|
846
|
+
return callHistory.getCallHistoryData(7, 10, _types2.SORT.DEFAULT, _types2.SORT_BY.DEFAULT);
|
|
847
|
+
case 1:
|
|
848
|
+
callArgs = webexRequestSpy.mock.calls[0][0];
|
|
849
|
+
expect(callArgs.uri).not.toContain('includeSharedSessions');
|
|
850
|
+
expect(callArgs.method).toBe(_types2.HTTP_METHODS.GET);
|
|
851
|
+
expect(callArgs.service).toBe('janus');
|
|
852
|
+
case 2:
|
|
853
|
+
case "end":
|
|
854
|
+
return _context21.stop();
|
|
855
|
+
}
|
|
856
|
+
}, _callee21);
|
|
857
|
+
})));
|
|
858
|
+
it('should NOT include includeSharedSessions for BWRKS backend', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee22() {
|
|
859
|
+
var callArgs;
|
|
860
|
+
return _regenerator.default.wrap(function (_context22) {
|
|
861
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
862
|
+
case 0:
|
|
863
|
+
jest.spyOn(utils, 'getCallingBackEnd').mockReturnValue(_types2.CALLING_BACKEND.BWRKS);
|
|
864
|
+
_context22.next = 1;
|
|
865
|
+
return callHistory.getCallHistoryData(7, 10, _types2.SORT.DEFAULT, _types2.SORT_BY.DEFAULT);
|
|
866
|
+
case 1:
|
|
867
|
+
callArgs = webexRequestSpy.mock.calls[0][0];
|
|
868
|
+
expect(callArgs.uri).not.toContain('includeSharedSessions');
|
|
869
|
+
expect(callArgs.method).toBe(_types2.HTTP_METHODS.GET);
|
|
870
|
+
expect(callArgs.service).toBe('janus');
|
|
871
|
+
case 2:
|
|
872
|
+
case "end":
|
|
873
|
+
return _context22.stop();
|
|
874
|
+
}
|
|
875
|
+
}, _callee22);
|
|
876
|
+
})));
|
|
877
|
+
it('should NOT include includeSharedSessions for unknown/other backends', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee23() {
|
|
878
|
+
var callArgs;
|
|
879
|
+
return _regenerator.default.wrap(function (_context23) {
|
|
880
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
881
|
+
case 0:
|
|
882
|
+
jest.spyOn(utils, 'getCallingBackEnd').mockReturnValue('OTHER_BACKEND');
|
|
883
|
+
_context23.next = 1;
|
|
884
|
+
return callHistory.getCallHistoryData(7, 10, _types2.SORT.DEFAULT, _types2.SORT_BY.DEFAULT);
|
|
885
|
+
case 1:
|
|
886
|
+
callArgs = webexRequestSpy.mock.calls[0][0];
|
|
887
|
+
expect(callArgs.uri).not.toContain('includeSharedSessions');
|
|
888
|
+
expect(callArgs.method).toBe(_types2.HTTP_METHODS.GET);
|
|
889
|
+
expect(callArgs.service).toBe('janus');
|
|
890
|
+
case 2:
|
|
891
|
+
case "end":
|
|
892
|
+
return _context23.stop();
|
|
893
|
+
}
|
|
894
|
+
}, _callee23);
|
|
895
|
+
})));
|
|
896
|
+
it('should construct URL correctly with base parameters for all backends', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee24() {
|
|
897
|
+
var callArgs;
|
|
898
|
+
return _regenerator.default.wrap(function (_context24) {
|
|
899
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
900
|
+
case 0:
|
|
901
|
+
jest.spyOn(utils, 'getCallingBackEnd').mockReturnValue(_types2.CALLING_BACKEND.WXC);
|
|
902
|
+
_context24.next = 1;
|
|
903
|
+
return callHistory.getCallHistoryData(7, 10, _types2.SORT.DEFAULT, _types2.SORT_BY.DEFAULT);
|
|
904
|
+
case 1:
|
|
905
|
+
callArgs = webexRequestSpy.mock.calls[0][0];
|
|
906
|
+
expect(callArgs.uri).toMatch(/.*\/history\/userSessions.*limit=10.*includeNewSessionTypes=true.*sort=DESC.*/);
|
|
907
|
+
expect(callArgs.uri).toContain('&includeSharedSessions=true');
|
|
908
|
+
case 2:
|
|
909
|
+
case "end":
|
|
910
|
+
return _context24.stop();
|
|
911
|
+
}
|
|
912
|
+
}, _callee24);
|
|
913
|
+
})));
|
|
914
|
+
});
|
|
915
|
+
});
|
|
916
|
+
//# sourceMappingURL=CallHistory.test.js.map
|