@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,3260 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _typeof = require("@babel/runtime-corejs2/helpers/typeof");
|
|
4
|
-
var _WeakMap = require("@babel/runtime-corejs2/core-js/weak-map");
|
|
5
|
-
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
6
|
-
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
|
|
7
|
-
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
8
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
|
|
9
|
-
var _keys = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/keys"));
|
|
10
|
-
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
11
|
-
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
|
|
12
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
|
|
13
|
-
var InternalMediaCoreModule = _interopRequireWildcard(require("@webex/internal-media-core"));
|
|
14
|
-
var _webMediaEffects = require("@webex/web-media-effects");
|
|
15
|
-
var _types = require("../../Errors/types");
|
|
16
|
-
var _Utils = _interopRequireWildcard(require("../../common/Utils"));
|
|
17
|
-
var Utils = _Utils;
|
|
18
|
-
var _types2 = require("../../Events/types");
|
|
19
|
-
var _constants = require("../constants");
|
|
20
|
-
var _types3 = require("../../common/types");
|
|
21
|
-
var _types4 = require("../../Metrics/types");
|
|
22
|
-
var _call = require("./call");
|
|
23
|
-
var _types5 = require("./types");
|
|
24
|
-
var _testUtil = require("../../common/testUtil");
|
|
25
|
-
var _callManager = require("./callManager");
|
|
26
|
-
var _Logger = _interopRequireDefault(require("../../Logger"));
|
|
27
|
-
var _Errors = require("../../Errors");
|
|
28
|
-
var _constants2 = require("../../common/constants");
|
|
29
|
-
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); }
|
|
30
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
31
|
-
/* eslint-disable dot-notation */
|
|
32
|
-
/* eslint-disable @typescript-eslint/no-shadow */
|
|
33
|
-
|
|
34
|
-
jest.mock('@webex/internal-media-core');
|
|
35
|
-
var uploadLogsSpy = jest.spyOn(Utils, 'uploadLogs').mockResolvedValue(undefined);
|
|
36
|
-
var webex = (0, _testUtil.getTestUtilsWebex)();
|
|
37
|
-
var mockInternalMediaCoreModule = InternalMediaCoreModule;
|
|
38
|
-
var defaultServiceIndicator = _types3.ServiceIndicator.CALLING;
|
|
39
|
-
var activeUrl = 'FakeActiveUrl';
|
|
40
|
-
var mockLineId = 'e4e8ee2a-a154-4e52-8f11-ef4cde2dce72';
|
|
41
|
-
describe('Call Tests', function () {
|
|
42
|
-
var deviceId = '55dfb53f-bed2-36da-8e85-cee7f02aa68e';
|
|
43
|
-
var dest = {
|
|
44
|
-
type: _types3.CallType.URI,
|
|
45
|
-
address: 'tel:5003'
|
|
46
|
-
};
|
|
47
|
-
var dummyMidCallEvent = {
|
|
48
|
-
eventType: 'callInfo',
|
|
49
|
-
eventData: {
|
|
50
|
-
callerId: {
|
|
51
|
-
from: '"Bob Marley" <sip:5010@207.182.171.130;user=phone>;tag=888068389-1654853820619-'
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
var callManager;
|
|
56
|
-
var deleteCallFromCollection = jest.fn();
|
|
57
|
-
var disconnectStats = {
|
|
58
|
-
'rtp-rxstat': {
|
|
59
|
-
Dur: 53.77999999999787,
|
|
60
|
-
LostPkt: 11,
|
|
61
|
-
LatePkt: 0,
|
|
62
|
-
Oct: 41156,
|
|
63
|
-
Pkt: 2379,
|
|
64
|
-
AvgJit: 0.041720656289440466,
|
|
65
|
-
VQMetrics: {
|
|
66
|
-
maxJitter: 0,
|
|
67
|
-
VoPktSizeMs: 20,
|
|
68
|
-
VoOneWayDelayMs: 0.26116666666666666,
|
|
69
|
-
hwType: 'OS X 10.15.7 64-bit/Chrome-105.0.0.0',
|
|
70
|
-
networkType: 'wifi',
|
|
71
|
-
VoRxCodec: 'opus'
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
'rtp-txstat': {
|
|
75
|
-
Dur: 53.77999999999787,
|
|
76
|
-
Pkt: 2410,
|
|
77
|
-
Oct: 41156,
|
|
78
|
-
VQMetrics: {
|
|
79
|
-
VoTxCodec: 'opus',
|
|
80
|
-
rtpBitRate: 32000
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
var parseMediaQualityStatisticsMock = jest.spyOn(Utils, 'parseMediaQualityStatistics').mockReturnValue(disconnectStats);
|
|
85
|
-
var mockTrack = {
|
|
86
|
-
enabled: false
|
|
87
|
-
};
|
|
88
|
-
var mockEffect = {
|
|
89
|
-
isEnabled: true,
|
|
90
|
-
effectTrack: mockTrack,
|
|
91
|
-
on: jest.fn(),
|
|
92
|
-
off: jest.fn()
|
|
93
|
-
};
|
|
94
|
-
var roapMediaConnectionConfig = {
|
|
95
|
-
skipInactiveTransceivers: true,
|
|
96
|
-
iceServers: [],
|
|
97
|
-
iceCandidatesTimeout: _constants.ICE_CANDIDATES_TIMEOUT,
|
|
98
|
-
sdpMunging: {
|
|
99
|
-
convertPort9to0: true,
|
|
100
|
-
addContentSlides: false,
|
|
101
|
-
copyClineToSessionLevel: true
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
var roapMediaConnectionOptions = {
|
|
105
|
-
localTracks: {
|
|
106
|
-
audio: mockTrack
|
|
107
|
-
},
|
|
108
|
-
direction: {
|
|
109
|
-
audio: 'sendrecv',
|
|
110
|
-
video: 'inactive',
|
|
111
|
-
screenShareVideo: 'inactive'
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
afterEach(function () {
|
|
115
|
-
webex.request = jest.fn();
|
|
116
|
-
});
|
|
117
|
-
beforeEach(function () {
|
|
118
|
-
callManager = (0, _callManager.getCallManager)(webex, defaultServiceIndicator);
|
|
119
|
-
});
|
|
120
|
-
it('create call object', function () {
|
|
121
|
-
webex.request.mockReturnValueOnce({
|
|
122
|
-
statusCode: 200,
|
|
123
|
-
body: {
|
|
124
|
-
device: {
|
|
125
|
-
deviceId: '8a67806f-fc4d-446b-a131-31e71ea5b010',
|
|
126
|
-
correlationId: '8a67806f-fc4d-446b-a131-31e71ea5b011'
|
|
127
|
-
},
|
|
128
|
-
callId: '8a67806f-fc4d-446b-a131-31e71ea5b020',
|
|
129
|
-
callData: {
|
|
130
|
-
callState: _types5.MobiusCallState.PROCEEDING
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
var call = (0, _call.createCall)(activeUrl, webex, _types3.CallDirection.OUTBOUND, deviceId, mockLineId, deleteCallFromCollection, defaultServiceIndicator, dest);
|
|
135
|
-
expect(call).toBeTruthy();
|
|
136
|
-
});
|
|
137
|
-
it('should log a warning when sending a digit fails', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
138
|
-
var tone, errorMessage, mockMediaConnection, callManager, call, realMediaConnection, warnSpy, infoSpy;
|
|
139
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
140
|
-
while (1) switch (_context.prev = _context.next) {
|
|
141
|
-
case 0:
|
|
142
|
-
tone = '1';
|
|
143
|
-
errorMessage = 'Failed to send digit'; // Mock the mediaConnection object
|
|
144
|
-
mockMediaConnection = {
|
|
145
|
-
insertDTMF: jest.fn(function () {
|
|
146
|
-
throw new Error(errorMessage);
|
|
147
|
-
})
|
|
148
|
-
};
|
|
149
|
-
callManager = (0, _callManager.getCallManager)(webex, defaultServiceIndicator);
|
|
150
|
-
call = callManager.createCall(_types3.CallDirection.OUTBOUND, deviceId, mockLineId, dest);
|
|
151
|
-
realMediaConnection = call.mediaConnection; // Set the mock mediaConnection object
|
|
152
|
-
call.mediaConnection = mockMediaConnection;
|
|
153
|
-
|
|
154
|
-
// Spy on the log methods
|
|
155
|
-
warnSpy = jest.spyOn(_Logger.default, 'warn');
|
|
156
|
-
infoSpy = jest.spyOn(_Logger.default, 'info'); // Call the sendDigit method
|
|
157
|
-
call.sendDigit(tone);
|
|
158
|
-
|
|
159
|
-
// Expect log.info to be called with the digit being sent
|
|
160
|
-
expect(infoSpy).toHaveBeenCalledWith("".concat(_constants2.METHOD_START_MESSAGE, " with: ").concat(tone), {
|
|
161
|
-
file: 'call',
|
|
162
|
-
method: 'sendDigit'
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
// Expect the log.warn method to be called with the error message
|
|
166
|
-
expect(warnSpy).toHaveBeenCalledWith("Unable to send digit on call: ".concat(errorMessage), {
|
|
167
|
-
file: 'call',
|
|
168
|
-
method: 'sendDigit'
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
// Restore the real mediaConnection object
|
|
172
|
-
call.mediaConnection = realMediaConnection;
|
|
173
|
-
call.end();
|
|
174
|
-
_context.next = 16;
|
|
175
|
-
return (0, _Utils.waitForMsecs)(50);
|
|
176
|
-
case 16:
|
|
177
|
-
// Need to add a small delay for Promise and callback to finish.
|
|
178
|
-
|
|
179
|
-
/* After call ends, call manager should have 0 record */
|
|
180
|
-
expect((0, _keys.default)(callManager.getActiveCalls()).length).toBe(0);
|
|
181
|
-
case 17:
|
|
182
|
-
case "end":
|
|
183
|
-
return _context.stop();
|
|
184
|
-
}
|
|
185
|
-
}, _callee);
|
|
186
|
-
})));
|
|
187
|
-
it('delete call object when ending the call', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
188
|
-
var callManager, mockStream, localAudioStream, call, infoSpy;
|
|
189
|
-
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
190
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
191
|
-
case 0:
|
|
192
|
-
webex.request.mockReturnValue({
|
|
193
|
-
statusCode: 200,
|
|
194
|
-
body: {
|
|
195
|
-
device: {
|
|
196
|
-
deviceId: '8a67806f-fc4d-446b-a131-31e71ea5b010',
|
|
197
|
-
correlationId: '8a67806f-fc4d-446b-a131-31e71ea5b011'
|
|
198
|
-
},
|
|
199
|
-
callId: '8a67806f-fc4d-446b-a131-31e71ea5b020'
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
callManager = (0, _callManager.getCallManager)(webex, defaultServiceIndicator);
|
|
203
|
-
mockStream = {
|
|
204
|
-
on: jest.fn(),
|
|
205
|
-
setUserMuted: jest.fn()
|
|
206
|
-
};
|
|
207
|
-
localAudioStream = mockStream;
|
|
208
|
-
call = callManager.createCall(_types3.CallDirection.OUTBOUND, deviceId, mockLineId, dest);
|
|
209
|
-
infoSpy = jest.spyOn(_Logger.default, 'info');
|
|
210
|
-
expect(call).toBeTruthy();
|
|
211
|
-
/* After creation , call manager should have 1 record */
|
|
212
|
-
expect((0, _keys.default)(callManager.getActiveCalls()).length).toBe(1);
|
|
213
|
-
call.mute(localAudioStream);
|
|
214
|
-
expect(call.isMuted()).toEqual(true);
|
|
215
|
-
expect(mockStream.setUserMuted).toBeCalledOnceWith(true);
|
|
216
|
-
expect(infoSpy).toHaveBeenCalledWith('invoking with: user mute', {
|
|
217
|
-
file: 'call',
|
|
218
|
-
method: 'mute'
|
|
219
|
-
});
|
|
220
|
-
call.mute(localAudioStream);
|
|
221
|
-
expect(mockStream.setUserMuted).toBeCalledWith(false);
|
|
222
|
-
expect(call.isMuted()).toEqual(false);
|
|
223
|
-
call.end();
|
|
224
|
-
expect(infoSpy).toHaveBeenCalledWith(_constants2.METHOD_START_MESSAGE, {
|
|
225
|
-
file: 'call',
|
|
226
|
-
method: 'end'
|
|
227
|
-
});
|
|
228
|
-
_context2.next = 19;
|
|
229
|
-
return (0, _Utils.waitForMsecs)(50);
|
|
230
|
-
case 19:
|
|
231
|
-
// Need to add a small delay for Promise and callback to finish.
|
|
232
|
-
expect(parseMediaQualityStatisticsMock).toHaveBeenCalledTimes(1);
|
|
233
|
-
expect(webex.request.mock.calls[0][0].body.metrics).toStrictEqual(disconnectStats);
|
|
234
|
-
expect(call.getDisconnectReason().code).toBe(_types5.DisconnectCode.NORMAL);
|
|
235
|
-
expect(call.getDisconnectReason().cause).toBe(_types5.DisconnectCause.NORMAL);
|
|
236
|
-
|
|
237
|
-
/* After call ends, call manager should have 0 record */
|
|
238
|
-
expect((0, _keys.default)(callManager.getActiveCalls()).length).toBe(0);
|
|
239
|
-
case 24:
|
|
240
|
-
case "end":
|
|
241
|
-
return _context2.stop();
|
|
242
|
-
}
|
|
243
|
-
}, _callee2);
|
|
244
|
-
})));
|
|
245
|
-
it('Check whether media requests succeed or not', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
246
|
-
var mediaResponse, call, response;
|
|
247
|
-
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
248
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
249
|
-
case 0:
|
|
250
|
-
webex.request.mockReturnValue({
|
|
251
|
-
statusCode: 200,
|
|
252
|
-
body: {
|
|
253
|
-
device: {
|
|
254
|
-
deviceId: '8a67806f-fc4d-446b-a131-31e71ea5b010',
|
|
255
|
-
correlationId: '8a67806f-fc4d-446b-a131-31e71ea5b011'
|
|
256
|
-
},
|
|
257
|
-
callId: '8a67806f-fc4d-446b-a131-31e71ea5b020'
|
|
258
|
-
}
|
|
259
|
-
});
|
|
260
|
-
mediaResponse = {
|
|
261
|
-
statusCode: 200,
|
|
262
|
-
body: {
|
|
263
|
-
device: {
|
|
264
|
-
deviceId: '8a67806f-fc4d-446b-a131-31e71ea5b010',
|
|
265
|
-
correlationId: '8a67806f-fc4d-446b-a131-31e71ea5b011'
|
|
266
|
-
},
|
|
267
|
-
callId: '8a67806f-fc4d-446b-a131-31e71ea5b020'
|
|
268
|
-
}
|
|
269
|
-
};
|
|
270
|
-
call = callManager.createCall(_types3.CallDirection.INBOUND, deviceId, mockLineId, dest);
|
|
271
|
-
_context3.next = 5;
|
|
272
|
-
return call['postMedia']({});
|
|
273
|
-
case 5:
|
|
274
|
-
response = _context3.sent;
|
|
275
|
-
expect(response.body).toStrictEqual(mediaResponse.body);
|
|
276
|
-
case 7:
|
|
277
|
-
case "end":
|
|
278
|
-
return _context3.stop();
|
|
279
|
-
}
|
|
280
|
-
}, _callee3);
|
|
281
|
-
})));
|
|
282
|
-
it('check whether callerId midcall event is serviced or not', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee4() {
|
|
283
|
-
var call;
|
|
284
|
-
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
285
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
286
|
-
case 0:
|
|
287
|
-
call = callManager.createCall(_types3.CallDirection.OUTBOUND, deviceId, mockLineId, dest);
|
|
288
|
-
call.handleMidCallEvent(dummyMidCallEvent);
|
|
289
|
-
_context4.next = 4;
|
|
290
|
-
return (0, _Utils.waitForMsecs)(50);
|
|
291
|
-
case 4:
|
|
292
|
-
expect(call.getCallerInfo().name).toStrictEqual('Bob Marley');
|
|
293
|
-
expect(call.getCallerInfo().num).toStrictEqual('5010');
|
|
294
|
-
expect(call.getCallerInfo().avatarSrc).toBeFalsy();
|
|
295
|
-
case 7:
|
|
296
|
-
case "end":
|
|
297
|
-
return _context4.stop();
|
|
298
|
-
}
|
|
299
|
-
}, _callee4);
|
|
300
|
-
})));
|
|
301
|
-
it('check whether call midcall event is serviced or not', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee5() {
|
|
302
|
-
var call, logSpy, corelationId;
|
|
303
|
-
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
304
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
305
|
-
case 0:
|
|
306
|
-
call = callManager.createCall(_types3.CallDirection.OUTBOUND, deviceId, mockLineId, dest);
|
|
307
|
-
dummyMidCallEvent.eventType = 'callState';
|
|
308
|
-
logSpy = jest.spyOn(_Logger.default, 'log');
|
|
309
|
-
call.handleMidCallEvent(dummyMidCallEvent);
|
|
310
|
-
_context5.next = 6;
|
|
311
|
-
return (0, _Utils.waitForMsecs)(50);
|
|
312
|
-
case 6:
|
|
313
|
-
corelationId = call.getCorrelationId();
|
|
314
|
-
expect(logSpy).toHaveBeenLastCalledWith("Received Midcall call event for correlationId : ".concat(corelationId), {
|
|
315
|
-
file: 'call',
|
|
316
|
-
method: 'handleMidCallEvent'
|
|
317
|
-
});
|
|
318
|
-
case 8:
|
|
319
|
-
case "end":
|
|
320
|
-
return _context5.stop();
|
|
321
|
-
}
|
|
322
|
-
}, _callee5);
|
|
323
|
-
})));
|
|
324
|
-
it('check call stats for active call', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee6() {
|
|
325
|
-
var call, callRtpStats;
|
|
326
|
-
return _regenerator.default.wrap(function _callee6$(_context6) {
|
|
327
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
328
|
-
case 0:
|
|
329
|
-
call = callManager.createCall(_types3.CallDirection.OUTBOUND, deviceId, mockLineId, dest);
|
|
330
|
-
_context6.prev = 1;
|
|
331
|
-
_context6.next = 4;
|
|
332
|
-
return call.getCallRtpStats();
|
|
333
|
-
case 4:
|
|
334
|
-
callRtpStats = _context6.sent;
|
|
335
|
-
_context6.next = 10;
|
|
336
|
-
break;
|
|
337
|
-
case 7:
|
|
338
|
-
_context6.prev = 7;
|
|
339
|
-
_context6.t0 = _context6["catch"](1);
|
|
340
|
-
console.error(_context6.t0);
|
|
341
|
-
case 10:
|
|
342
|
-
expect(callRtpStats).toStrictEqual(disconnectStats);
|
|
343
|
-
case 11:
|
|
344
|
-
case "end":
|
|
345
|
-
return _context6.stop();
|
|
346
|
-
}
|
|
347
|
-
}, _callee6, null, [[1, 7]]);
|
|
348
|
-
})));
|
|
349
|
-
it('dial functionality tests for coverage', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee7() {
|
|
350
|
-
var mockStream, localAudioStream, warnSpy, call, bnrMetricSpy, logSpy;
|
|
351
|
-
return _regenerator.default.wrap(function _callee7$(_context7) {
|
|
352
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
353
|
-
case 0:
|
|
354
|
-
mockStream = {
|
|
355
|
-
outputStream: {
|
|
356
|
-
getAudioTracks: jest.fn().mockReturnValue([mockTrack])
|
|
357
|
-
},
|
|
358
|
-
on: jest.fn(),
|
|
359
|
-
getEffectByKind: jest.fn().mockImplementation(function () {
|
|
360
|
-
return mockEffect;
|
|
361
|
-
})
|
|
362
|
-
};
|
|
363
|
-
localAudioStream = mockStream;
|
|
364
|
-
warnSpy = jest.spyOn(_Logger.default, 'warn');
|
|
365
|
-
call = (0, _call.createCall)(activeUrl, webex, _types3.CallDirection.OUTBOUND, deviceId, mockLineId, deleteCallFromCollection, defaultServiceIndicator, dest);
|
|
366
|
-
bnrMetricSpy = jest.spyOn(call['metricManager'], 'submitBNRMetric');
|
|
367
|
-
logSpy = jest.spyOn(_Logger.default, 'log');
|
|
368
|
-
call.dial(localAudioStream);
|
|
369
|
-
expect(mockTrack.enabled).toEqual(true);
|
|
370
|
-
expect(mockInternalMediaCoreModule.RoapMediaConnection).toBeCalledOnceWith(roapMediaConnectionConfig, roapMediaConnectionOptions, expect.any(String), expect.any(Function), expect.any(Function), expect.any(Function));
|
|
371
|
-
expect(call['mediaStateMachine'].state.value).toBe('S_SEND_ROAP_OFFER');
|
|
372
|
-
expect(logSpy).toHaveBeenCalled();
|
|
373
|
-
expect(bnrMetricSpy).toBeCalledOnceWith(_types4.METRIC_EVENT.BNR_ENABLED, _types4.METRIC_TYPE.BEHAVIORAL, call.getCallId(), call.getCorrelationId());
|
|
374
|
-
|
|
375
|
-
/* Now change the state and recall to check for error */
|
|
376
|
-
call['mediaStateMachine'].state.value = 'S_SEND_ROAP_OFFER';
|
|
377
|
-
call.dial(localAudioStream);
|
|
378
|
-
expect(call['mediaStateMachine'].state.value).toBe('S_SEND_ROAP_OFFER');
|
|
379
|
-
expect(warnSpy).toBeCalledOnceWith("Call cannot be dialed because the state is already : S_SEND_ROAP_OFFER", {
|
|
380
|
-
file: 'call',
|
|
381
|
-
method: 'dial'
|
|
382
|
-
});
|
|
383
|
-
case 16:
|
|
384
|
-
case "end":
|
|
385
|
-
return _context7.stop();
|
|
386
|
-
}
|
|
387
|
-
}, _callee7);
|
|
388
|
-
})));
|
|
389
|
-
it('answer functionality tests for coverage', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee8() {
|
|
390
|
-
var mockStream, localAudioStream, warnSpy, call, bnrMetricSpy, infoSpy;
|
|
391
|
-
return _regenerator.default.wrap(function _callee8$(_context8) {
|
|
392
|
-
while (1) switch (_context8.prev = _context8.next) {
|
|
393
|
-
case 0:
|
|
394
|
-
mockStream = {
|
|
395
|
-
outputStream: {
|
|
396
|
-
getAudioTracks: jest.fn().mockReturnValue([mockTrack])
|
|
397
|
-
},
|
|
398
|
-
on: jest.fn(),
|
|
399
|
-
getEffectByKind: jest.fn().mockImplementation(function () {
|
|
400
|
-
return mockEffect;
|
|
401
|
-
})
|
|
402
|
-
};
|
|
403
|
-
localAudioStream = mockStream;
|
|
404
|
-
warnSpy = jest.spyOn(_Logger.default, 'warn');
|
|
405
|
-
call = (0, _call.createCall)(activeUrl, webex, _types3.CallDirection.OUTBOUND, deviceId, mockLineId, deleteCallFromCollection, defaultServiceIndicator, dest);
|
|
406
|
-
/** Cannot answer in idle state */
|
|
407
|
-
bnrMetricSpy = jest.spyOn(call['metricManager'], 'submitBNRMetric');
|
|
408
|
-
infoSpy = jest.spyOn(_Logger.default, 'info');
|
|
409
|
-
call.answer(localAudioStream);
|
|
410
|
-
expect(mockTrack.enabled).toEqual(true);
|
|
411
|
-
expect(mockInternalMediaCoreModule.RoapMediaConnection).toBeCalledOnceWith(roapMediaConnectionConfig, roapMediaConnectionOptions, expect.any(String), expect.any(Function), expect.any(Function), expect.any(Function));
|
|
412
|
-
expect(call['callStateMachine'].state.value).toBe('S_IDLE');
|
|
413
|
-
expect(warnSpy).toBeCalledOnceWith("Call cannot be answered because the state is : S_IDLE", {
|
|
414
|
-
file: 'call',
|
|
415
|
-
method: 'answer'
|
|
416
|
-
});
|
|
417
|
-
expect(infoSpy).toHaveBeenCalled();
|
|
418
|
-
|
|
419
|
-
/* Now change the state and recall to check for correct flow */
|
|
420
|
-
call['callStateMachine'].state.value = 'S_SEND_CALL_PROGRESS';
|
|
421
|
-
call.answer(localAudioStream);
|
|
422
|
-
expect(call['callStateMachine'].state.value).toBe('S_SEND_CALL_CONNECT');
|
|
423
|
-
expect(bnrMetricSpy).toBeCalledOnceWith(_types4.METRIC_EVENT.BNR_ENABLED, _types4.METRIC_TYPE.BEHAVIORAL, call.getCallId(), call.getCorrelationId());
|
|
424
|
-
case 16:
|
|
425
|
-
case "end":
|
|
426
|
-
return _context8.stop();
|
|
427
|
-
}
|
|
428
|
-
}, _callee8);
|
|
429
|
-
})));
|
|
430
|
-
it('testing enabling/disabling the BNR on an active call', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee9() {
|
|
431
|
-
var mockStream, localAudioStream, onStreamSpy, onEffectSpy, offStreamSpy, offEffectSpy, call, updateLocalTracksSpy, bnrMetricSpy;
|
|
432
|
-
return _regenerator.default.wrap(function _callee9$(_context9) {
|
|
433
|
-
while (1) switch (_context9.prev = _context9.next) {
|
|
434
|
-
case 0:
|
|
435
|
-
mockStream = {
|
|
436
|
-
outputStream: {
|
|
437
|
-
getAudioTracks: jest.fn().mockReturnValue([mockTrack])
|
|
438
|
-
},
|
|
439
|
-
on: jest.fn(),
|
|
440
|
-
off: jest.fn(),
|
|
441
|
-
getEffectByKind: jest.fn()
|
|
442
|
-
};
|
|
443
|
-
localAudioStream = mockStream;
|
|
444
|
-
onStreamSpy = jest.spyOn(localAudioStream, 'on');
|
|
445
|
-
onEffectSpy = jest.spyOn(mockEffect, 'on');
|
|
446
|
-
offStreamSpy = jest.spyOn(localAudioStream, 'off');
|
|
447
|
-
offEffectSpy = jest.spyOn(mockEffect, 'off');
|
|
448
|
-
call = (0, _call.createCall)(activeUrl, webex, _types3.CallDirection.OUTBOUND, deviceId, mockLineId, deleteCallFromCollection, defaultServiceIndicator, dest);
|
|
449
|
-
call.dial(localAudioStream);
|
|
450
|
-
expect(mockTrack.enabled).toEqual(true);
|
|
451
|
-
expect(mockInternalMediaCoreModule.RoapMediaConnection).toBeCalledOnceWith(roapMediaConnectionConfig, roapMediaConnectionOptions, expect.any(String), expect.any(Function), expect.any(Function), expect.any(Function));
|
|
452
|
-
expect(call['mediaStateMachine'].state.value).toBe('S_SEND_ROAP_OFFER');
|
|
453
|
-
updateLocalTracksSpy = jest.spyOn(call['mediaConnection'], 'updateLocalTracks');
|
|
454
|
-
bnrMetricSpy = jest.spyOn(call['metricManager'], 'submitBNRMetric');
|
|
455
|
-
/* Update the stream with the effect */
|
|
456
|
-
jest.spyOn(localAudioStream, 'getEffectByKind').mockReturnValue(mockEffect);
|
|
457
|
-
|
|
458
|
-
/* Checking if listeners on the localAudioStream have been registered */
|
|
459
|
-
expect(onStreamSpy).toBeCalledTimes(2);
|
|
460
|
-
expect(onStreamSpy).toBeCalledWith(InternalMediaCoreModule.LocalStreamEventNames.OutputTrackChange, expect.any(Function));
|
|
461
|
-
expect(onStreamSpy).toBeCalledWith(InternalMediaCoreModule.LocalStreamEventNames.EffectAdded, expect.any(Function));
|
|
462
|
-
bnrMetricSpy.mockClear();
|
|
463
|
-
/* Invoking the callback function to trigger EffectAdded event to simulate adding effect to the stream */
|
|
464
|
-
onStreamSpy.mock.calls[1][1](mockEffect);
|
|
465
|
-
expect(onEffectSpy).toBeCalledWith(_webMediaEffects.EffectEvent.Enabled, expect.any(Function));
|
|
466
|
-
expect(onEffectSpy).toBeCalledWith(_webMediaEffects.EffectEvent.Disabled, expect.any(Function));
|
|
467
|
-
|
|
468
|
-
/* Send Enabled event on the effect, update track and send metrics for BNR disabled */
|
|
469
|
-
onStreamSpy.mock.calls[0][1](mockTrack);
|
|
470
|
-
onEffectSpy.mock.calls[0][1]();
|
|
471
|
-
expect(updateLocalTracksSpy).toBeCalledOnceWith({
|
|
472
|
-
audio: mockTrack
|
|
473
|
-
});
|
|
474
|
-
expect(bnrMetricSpy).toBeCalledOnceWith(_types4.METRIC_EVENT.BNR_ENABLED, _types4.METRIC_TYPE.BEHAVIORAL, call.getCallId(), call.getCorrelationId());
|
|
475
|
-
|
|
476
|
-
/* Clear the mocks */
|
|
477
|
-
updateLocalTracksSpy.mockClear();
|
|
478
|
-
bnrMetricSpy.mockClear();
|
|
479
|
-
|
|
480
|
-
/* Send Disabled event on the effect, update track and send metrics for BNR disabled */
|
|
481
|
-
mockEffect.isEnabled = false;
|
|
482
|
-
onStreamSpy.mock.calls[0][1](mockTrack);
|
|
483
|
-
onEffectSpy.mock.calls[1][1]();
|
|
484
|
-
expect(updateLocalTracksSpy).toBeCalledOnceWith({
|
|
485
|
-
audio: mockTrack
|
|
486
|
-
});
|
|
487
|
-
expect(bnrMetricSpy).toBeCalledOnceWith(_types4.METRIC_EVENT.BNR_DISABLED, _types4.METRIC_TYPE.BEHAVIORAL, call.getCallId(), call.getCorrelationId());
|
|
488
|
-
call.end();
|
|
489
|
-
_context9.next = 35;
|
|
490
|
-
return (0, _Utils.waitForMsecs)(50);
|
|
491
|
-
case 35:
|
|
492
|
-
/* Checks for switching off the listeners on call disconnect */
|
|
493
|
-
expect(offStreamSpy).toBeCalledTimes(2);
|
|
494
|
-
expect(offStreamSpy).toBeCalledWith(InternalMediaCoreModule.LocalStreamEventNames.OutputTrackChange, expect.any(Function));
|
|
495
|
-
expect(offStreamSpy).toBeCalledWith(InternalMediaCoreModule.LocalStreamEventNames.EffectAdded, expect.any(Function));
|
|
496
|
-
expect(offEffectSpy).toBeCalledWith(_webMediaEffects.EffectEvent.Enabled, expect.any(Function));
|
|
497
|
-
expect(offEffectSpy).toBeCalledWith(_webMediaEffects.EffectEvent.Disabled, expect.any(Function));
|
|
498
|
-
case 40:
|
|
499
|
-
case "end":
|
|
500
|
-
return _context9.stop();
|
|
501
|
-
}
|
|
502
|
-
}, _callee9);
|
|
503
|
-
})));
|
|
504
|
-
it('answer fails if localAudioTrack is empty', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee0() {
|
|
505
|
-
var mockStream, localAudioStream, warnSpy, call;
|
|
506
|
-
return _regenerator.default.wrap(function _callee0$(_context0) {
|
|
507
|
-
while (1) switch (_context0.prev = _context0.next) {
|
|
508
|
-
case 0:
|
|
509
|
-
mockStream = {
|
|
510
|
-
outputStream: {
|
|
511
|
-
getAudioTracks: jest.fn().mockReturnValue([])
|
|
512
|
-
},
|
|
513
|
-
on: jest.fn(),
|
|
514
|
-
off: jest.fn(),
|
|
515
|
-
getEffectByKind: jest.fn()
|
|
516
|
-
};
|
|
517
|
-
localAudioStream = mockStream;
|
|
518
|
-
webex.request.mockReturnValue({
|
|
519
|
-
statusCode: 200,
|
|
520
|
-
body: {
|
|
521
|
-
device: {
|
|
522
|
-
deviceId: '8a67806f-fc4d-446b-a131-31e71ea5b010',
|
|
523
|
-
correlationId: '8a67806f-fc4d-446b-a131-31e71ea5b011'
|
|
524
|
-
},
|
|
525
|
-
callId: '8a67806f-fc4d-446b-a131-31e71ea5b020'
|
|
526
|
-
}
|
|
527
|
-
});
|
|
528
|
-
warnSpy = jest.spyOn(_Logger.default, 'warn');
|
|
529
|
-
call = (0, _call.createCall)(activeUrl, webex, _types3.CallDirection.OUTBOUND, deviceId, mockLineId, deleteCallFromCollection, defaultServiceIndicator, dest);
|
|
530
|
-
call.answer(localAudioStream);
|
|
531
|
-
_context0.next = 8;
|
|
532
|
-
return (0, _Utils.waitForMsecs)(50);
|
|
533
|
-
case 8:
|
|
534
|
-
expect(warnSpy).toBeCalledTimes(2);
|
|
535
|
-
expect(warnSpy).toBeCalledWith("Did not find a local track while answering the call ".concat(call.getCorrelationId()), {
|
|
536
|
-
file: 'call',
|
|
537
|
-
method: 'answer'
|
|
538
|
-
});
|
|
539
|
-
expect(call['callStateMachine'].state.value).toBe('S_CALL_CLEARED');
|
|
540
|
-
expect(call['mediaStateMachine'].state.value).toBe('S_ROAP_IDLE');
|
|
541
|
-
expect(call.getDisconnectReason().code).toBe(_types5.DisconnectCode.MEDIA_INACTIVITY);
|
|
542
|
-
expect(call.getDisconnectReason().cause).toBe(_types5.DisconnectCause.MEDIA_INACTIVITY);
|
|
543
|
-
expect(webex.request.mock.calls[0][0].body.metrics).toStrictEqual(disconnectStats);
|
|
544
|
-
case 15:
|
|
545
|
-
case "end":
|
|
546
|
-
return _context0.stop();
|
|
547
|
-
}
|
|
548
|
-
}, _callee0);
|
|
549
|
-
})));
|
|
550
|
-
it('dial fails if localAudioTrack is empty', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee1() {
|
|
551
|
-
var mockStream, localAudioStream, warnSpy, call;
|
|
552
|
-
return _regenerator.default.wrap(function _callee1$(_context1) {
|
|
553
|
-
while (1) switch (_context1.prev = _context1.next) {
|
|
554
|
-
case 0:
|
|
555
|
-
mockStream = {
|
|
556
|
-
outputStream: {
|
|
557
|
-
getAudioTracks: jest.fn().mockReturnValue([])
|
|
558
|
-
},
|
|
559
|
-
on: jest.fn()
|
|
560
|
-
};
|
|
561
|
-
localAudioStream = mockStream;
|
|
562
|
-
warnSpy = jest.spyOn(_Logger.default, 'warn');
|
|
563
|
-
call = (0, _call.createCall)(activeUrl, webex, _types3.CallDirection.OUTBOUND, deviceId, mockLineId, deleteCallFromCollection, defaultServiceIndicator, dest);
|
|
564
|
-
call.dial(localAudioStream);
|
|
565
|
-
_context1.next = 7;
|
|
566
|
-
return (0, _Utils.waitForMsecs)(50);
|
|
567
|
-
case 7:
|
|
568
|
-
expect(warnSpy).toBeCalledTimes(1);
|
|
569
|
-
expect(warnSpy).toBeCalledWith("Did not find a local track while dialing the call ".concat(call.getCorrelationId()), {
|
|
570
|
-
file: 'call',
|
|
571
|
-
method: 'dial'
|
|
572
|
-
});
|
|
573
|
-
expect(call['callStateMachine'].state.value).toBe('S_IDLE');
|
|
574
|
-
expect(call['mediaStateMachine'].state.value).toBe('S_ROAP_IDLE');
|
|
575
|
-
expect(webex.request).not.toBeCalledOnceWith();
|
|
576
|
-
case 12:
|
|
577
|
-
case "end":
|
|
578
|
-
return _context1.stop();
|
|
579
|
-
}
|
|
580
|
-
}, _callee1);
|
|
581
|
-
})));
|
|
582
|
-
it('update media after call creation with valid stream', function () {
|
|
583
|
-
var callManager = (0, _callManager.getCallManager)(webex, defaultServiceIndicator);
|
|
584
|
-
var mockStream = {
|
|
585
|
-
outputStream: {
|
|
586
|
-
getAudioTracks: jest.fn().mockReturnValue([mockTrack])
|
|
587
|
-
},
|
|
588
|
-
on: jest.fn(),
|
|
589
|
-
off: jest.fn(),
|
|
590
|
-
getEffectByKind: jest.fn()
|
|
591
|
-
};
|
|
592
|
-
var localAudioStream = mockStream;
|
|
593
|
-
var onStream1Spy = jest.spyOn(localAudioStream, 'on');
|
|
594
|
-
var offStream1Spy = jest.spyOn(localAudioStream, 'off');
|
|
595
|
-
var call = callManager.createCall(_types3.CallDirection.OUTBOUND, deviceId, mockLineId, dest);
|
|
596
|
-
call.dial(localAudioStream);
|
|
597
|
-
expect(mockTrack.enabled).toEqual(true);
|
|
598
|
-
expect(onStream1Spy).toBeCalledTimes(2);
|
|
599
|
-
expect(onStream1Spy).toBeCalledWith(InternalMediaCoreModule.LocalStreamEventNames.OutputTrackChange, expect.any(Function));
|
|
600
|
-
expect(onStream1Spy).toBeCalledWith(InternalMediaCoreModule.LocalStreamEventNames.EffectAdded, expect.any(Function));
|
|
601
|
-
var mockTrack2 = {
|
|
602
|
-
enabled: true
|
|
603
|
-
};
|
|
604
|
-
var mockStream2 = {
|
|
605
|
-
outputStream: {
|
|
606
|
-
getAudioTracks: jest.fn().mockReturnValue([mockTrack2])
|
|
607
|
-
},
|
|
608
|
-
on: jest.fn(),
|
|
609
|
-
getEffectByKind: jest.fn()
|
|
610
|
-
};
|
|
611
|
-
var localAudioStream2 = mockStream2;
|
|
612
|
-
var onStream2Spy = jest.spyOn(localAudioStream2, 'on');
|
|
613
|
-
call.updateMedia(localAudioStream2);
|
|
614
|
-
expect(call['mediaConnection'].updateLocalTracks).toBeCalledOnceWith({
|
|
615
|
-
audio: mockTrack2
|
|
616
|
-
});
|
|
617
|
-
expect(call['localAudioStream']).toEqual(localAudioStream2);
|
|
618
|
-
expect(offStream1Spy).toBeCalledWith(InternalMediaCoreModule.LocalStreamEventNames.EffectAdded, expect.any(Function));
|
|
619
|
-
expect(onStream2Spy).toBeCalledWith(InternalMediaCoreModule.LocalStreamEventNames.OutputTrackChange, expect.any(Function));
|
|
620
|
-
expect(onStream2Spy).toBeCalledWith(InternalMediaCoreModule.LocalStreamEventNames.EffectAdded, expect.any(Function));
|
|
621
|
-
});
|
|
622
|
-
it('update media with invalid stream', function () {
|
|
623
|
-
var callManager = (0, _callManager.getCallManager)(webex, defaultServiceIndicator);
|
|
624
|
-
var warnSpy = jest.spyOn(_Logger.default, 'warn');
|
|
625
|
-
var infoSpy = jest.spyOn(_Logger.default, 'info');
|
|
626
|
-
var mockStream = {
|
|
627
|
-
outputStream: {
|
|
628
|
-
getAudioTracks: jest.fn().mockReturnValue([mockTrack])
|
|
629
|
-
},
|
|
630
|
-
on: jest.fn(),
|
|
631
|
-
getEffectByKind: jest.fn()
|
|
632
|
-
};
|
|
633
|
-
var localAudioStream = mockStream;
|
|
634
|
-
var call = callManager.createCall(_types3.CallDirection.OUTBOUND, deviceId, mockLineId, dest);
|
|
635
|
-
call.dial(localAudioStream);
|
|
636
|
-
expect(mockTrack.enabled).toEqual(true);
|
|
637
|
-
var errorStream = {
|
|
638
|
-
outputStream: {
|
|
639
|
-
getAudioTracks: jest.fn().mockReturnValue([])
|
|
640
|
-
}
|
|
641
|
-
};
|
|
642
|
-
var localAudioStream2 = errorStream;
|
|
643
|
-
call.updateMedia(localAudioStream2);
|
|
644
|
-
expect(call['mediaConnection'].updateLocalTracks).not.toBeCalled();
|
|
645
|
-
expect(warnSpy).toHaveBeenCalledWith("Did not find a local track while updating media for call ".concat(call.getCorrelationId(), ". Will not update media"), {
|
|
646
|
-
file: 'call',
|
|
647
|
-
method: 'updateMedia'
|
|
648
|
-
});
|
|
649
|
-
expect(infoSpy).toHaveBeenCalledWith('invoking with stream', {
|
|
650
|
-
file: 'call',
|
|
651
|
-
method: 'dial'
|
|
652
|
-
});
|
|
653
|
-
});
|
|
654
|
-
it('test system mute and user mute different scnearios', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee10() {
|
|
655
|
-
var logSpy, callManager, mockStream, localAudioStream, call;
|
|
656
|
-
return _regenerator.default.wrap(function _callee10$(_context10) {
|
|
657
|
-
while (1) switch (_context10.prev = _context10.next) {
|
|
658
|
-
case 0:
|
|
659
|
-
logSpy = jest.spyOn(_Logger.default, 'info');
|
|
660
|
-
webex.request.mockReturnValue({
|
|
661
|
-
statusCode: 200,
|
|
662
|
-
body: {
|
|
663
|
-
device: {
|
|
664
|
-
deviceId: '8a67806f-fc4d-446b-a131-31e71ea5b010',
|
|
665
|
-
correlationId: '8a67806f-fc4d-446b-a131-31e71ea5b011'
|
|
666
|
-
},
|
|
667
|
-
callId: '8a67806f-fc4d-446b-a131-31e71ea5b020'
|
|
668
|
-
}
|
|
669
|
-
});
|
|
670
|
-
callManager = (0, _callManager.getCallManager)(webex, defaultServiceIndicator);
|
|
671
|
-
mockStream = {
|
|
672
|
-
on: jest.fn(),
|
|
673
|
-
setUserMuted: jest.fn(),
|
|
674
|
-
systemMuted: false,
|
|
675
|
-
userMuted: false
|
|
676
|
-
};
|
|
677
|
-
localAudioStream = mockStream;
|
|
678
|
-
call = callManager.createCall(dest, _types3.CallDirection.OUTBOUND, deviceId, mockLineId);
|
|
679
|
-
expect(call).toBeTruthy();
|
|
680
|
-
/* System mute is being triggered, mute state within call object should update to true */
|
|
681
|
-
mockStream.systemMuted = true;
|
|
682
|
-
call.mute(localAudioStream, _types5.MUTE_TYPE.SYSTEM);
|
|
683
|
-
expect(call.isMuted()).toEqual(true);
|
|
684
|
-
|
|
685
|
-
/* User mute is triggered, but no change will happen to the call object mute state since it is system muted */
|
|
686
|
-
logSpy.mockClear();
|
|
687
|
-
call.mute(localAudioStream, _types5.MUTE_TYPE.USER);
|
|
688
|
-
expect(call.isMuted()).toEqual(true);
|
|
689
|
-
expect(mockStream.setUserMuted).not.toBeCalledOnceWith(true);
|
|
690
|
-
expect(logSpy).toHaveBeenCalledWith("Call is muted on the system - ".concat(call.getCorrelationId(), "."), {
|
|
691
|
-
file: 'call',
|
|
692
|
-
method: 'mute'
|
|
693
|
-
});
|
|
694
|
-
|
|
695
|
-
/* System mute is being triggered, mute state within call object should update to false */
|
|
696
|
-
mockStream.systemMuted = false;
|
|
697
|
-
call.mute(localAudioStream, _types5.MUTE_TYPE.SYSTEM);
|
|
698
|
-
expect(call.isMuted()).toEqual(false);
|
|
699
|
-
|
|
700
|
-
/* User mute can be triggered now updating call object mute state as well */
|
|
701
|
-
call.mute(localAudioStream, _types5.MUTE_TYPE.USER);
|
|
702
|
-
expect(call.isMuted()).toEqual(true);
|
|
703
|
-
expect(mockStream.setUserMuted).toBeCalledOnceWith(true);
|
|
704
|
-
mockStream.userMuted = true;
|
|
705
|
-
|
|
706
|
-
/* System mute being triggered now won't update the mute state within call object but will block the user unmute */
|
|
707
|
-
logSpy.mockClear();
|
|
708
|
-
mockStream.systemMuted = true;
|
|
709
|
-
call.mute(localAudioStream, _types5.MUTE_TYPE.SYSTEM);
|
|
710
|
-
expect(call.isMuted()).toEqual(true);
|
|
711
|
-
expect(logSpy).toHaveBeenCalledWith("Call is muted by the user already - ".concat(call.getCorrelationId(), "."), {
|
|
712
|
-
file: 'call',
|
|
713
|
-
method: 'mute'
|
|
714
|
-
});
|
|
715
|
-
|
|
716
|
-
/* User mute now won't be able to update mute state back to false as system mute is also set */
|
|
717
|
-
call.mute(localAudioStream, _types5.MUTE_TYPE.USER);
|
|
718
|
-
expect(call.isMuted()).toEqual(true);
|
|
719
|
-
expect(mockStream.setUserMuted).not.toBeCalledOnceWith(false);
|
|
720
|
-
|
|
721
|
-
/* Revert the system mute but call mute state remains same */
|
|
722
|
-
mockStream.systemMuted = false;
|
|
723
|
-
call.mute(localAudioStream, _types5.MUTE_TYPE.SYSTEM);
|
|
724
|
-
expect(call.isMuted()).toEqual(true);
|
|
725
|
-
|
|
726
|
-
/* User mute will be able update the mute state now */
|
|
727
|
-
mockStream.setUserMuted.mockClear();
|
|
728
|
-
call.mute(localAudioStream, _types5.MUTE_TYPE.USER);
|
|
729
|
-
expect(call.isMuted()).toEqual(false);
|
|
730
|
-
expect(mockStream.setUserMuted).toBeCalledOnceWith(false);
|
|
731
|
-
case 37:
|
|
732
|
-
case "end":
|
|
733
|
-
return _context10.stop();
|
|
734
|
-
}
|
|
735
|
-
}, _callee10);
|
|
736
|
-
})));
|
|
737
|
-
describe('Guest Calling Flow Tests', function () {
|
|
738
|
-
var dummyEvent = {
|
|
739
|
-
type: 'E_SEND_CALL_SETUP',
|
|
740
|
-
data: undefined
|
|
741
|
-
};
|
|
742
|
-
var call;
|
|
743
|
-
it('outgoing call without guest calling must have callee', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee11() {
|
|
744
|
-
var requestSpy, requestArgs;
|
|
745
|
-
return _regenerator.default.wrap(function _callee11$(_context11) {
|
|
746
|
-
while (1) switch (_context11.prev = _context11.next) {
|
|
747
|
-
case 0:
|
|
748
|
-
call = new _call.Call(activeUrl, webex, _types3.CallDirection.OUTBOUND, deviceId, mockLineId, function () {
|
|
749
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
750
|
-
var dummy = 10;
|
|
751
|
-
}, defaultServiceIndicator, dest);
|
|
752
|
-
call['callStateMachine'].state.value = 'S_IDLE';
|
|
753
|
-
requestSpy = jest.spyOn(webex, 'request');
|
|
754
|
-
call.sendCallStateMachineEvt(dummyEvent);
|
|
755
|
-
requestArgs = requestSpy.mock.calls[0][0];
|
|
756
|
-
expect('callee' in requestArgs.body).toBe(true);
|
|
757
|
-
case 6:
|
|
758
|
-
case "end":
|
|
759
|
-
return _context11.stop();
|
|
760
|
-
}
|
|
761
|
-
}, _callee11);
|
|
762
|
-
})));
|
|
763
|
-
it('outgoing call for guest calling must not have callee', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee12() {
|
|
764
|
-
var requestSpy, requestArgs;
|
|
765
|
-
return _regenerator.default.wrap(function _callee12$(_context12) {
|
|
766
|
-
while (1) switch (_context12.prev = _context12.next) {
|
|
767
|
-
case 0:
|
|
768
|
-
call = new _call.Call(activeUrl, webex, _types3.CallDirection.OUTBOUND, deviceId, mockLineId, function () {
|
|
769
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
770
|
-
var dummy = 10;
|
|
771
|
-
}, defaultServiceIndicator);
|
|
772
|
-
call['callStateMachine'].state.value = 'S_IDLE';
|
|
773
|
-
requestSpy = jest.spyOn(webex, 'request');
|
|
774
|
-
call.sendCallStateMachineEvt(dummyEvent);
|
|
775
|
-
requestArgs = requestSpy.mock.calls[0][0];
|
|
776
|
-
expect('callee' in requestArgs.body).toBe(false);
|
|
777
|
-
case 6:
|
|
778
|
-
case "end":
|
|
779
|
-
return _context12.stop();
|
|
780
|
-
}
|
|
781
|
-
}, _callee12);
|
|
782
|
-
})));
|
|
783
|
-
});
|
|
784
|
-
});
|
|
785
|
-
describe('State Machine handler tests', function () {
|
|
786
|
-
var deviceId = '55dfb53f-bed2-36da-8e85-cee7f02aa68e';
|
|
787
|
-
var dest = {
|
|
788
|
-
type: _types3.CallType.URI,
|
|
789
|
-
address: 'tel:5003'
|
|
790
|
-
};
|
|
791
|
-
var mockStatusBody = {
|
|
792
|
-
device: {
|
|
793
|
-
deviceId: '123e4567-e89b-12d3-a456-426614174000',
|
|
794
|
-
correlationId: 'b5476d4c-f48b-475e-b4e2-994e24d14ca2'
|
|
795
|
-
},
|
|
796
|
-
callId: 'fcf86aa5-5539-4c9f-8b72-667786ae9b6c'
|
|
797
|
-
};
|
|
798
|
-
var call;
|
|
799
|
-
var dtmfMock;
|
|
800
|
-
beforeEach(function () {
|
|
801
|
-
call = new _call.Call(activeUrl, webex, _types3.CallDirection.OUTBOUND, deviceId, mockLineId, function () {
|
|
802
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
803
|
-
var dummy = 10;
|
|
804
|
-
}, defaultServiceIndicator, dest);
|
|
805
|
-
jest.clearAllTimers();
|
|
806
|
-
jest.useFakeTimers();
|
|
807
|
-
call['callStateMachine'].state.value = 'S_IDLE';
|
|
808
|
-
call.mediaConnection = _testUtil.mediaConnection;
|
|
809
|
-
dtmfMock = jest.spyOn(call['mediaConnection'], 'insertDTMF');
|
|
810
|
-
});
|
|
811
|
-
|
|
812
|
-
// afterEach(() => call.removeAllListeners());
|
|
813
|
-
|
|
814
|
-
it('successful session refresh', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee13() {
|
|
815
|
-
var statusPayload, dummyEvent, funcSpy, logSpy;
|
|
816
|
-
return _regenerator.default.wrap(function _callee13$(_context13) {
|
|
817
|
-
while (1) switch (_context13.prev = _context13.next) {
|
|
818
|
-
case 0:
|
|
819
|
-
statusPayload = {
|
|
820
|
-
statusCode: 200,
|
|
821
|
-
body: mockStatusBody
|
|
822
|
-
};
|
|
823
|
-
dummyEvent = {
|
|
824
|
-
type: 'E_CALL_ESTABLISHED'
|
|
825
|
-
};
|
|
826
|
-
call['callStateMachine'].state.value = 'S_SEND_CALL_CONNECT';
|
|
827
|
-
webex.request.mockReturnValue(statusPayload);
|
|
828
|
-
jest.spyOn(global, 'setInterval');
|
|
829
|
-
funcSpy = jest.spyOn(call, 'postStatus').mockResolvedValue(statusPayload);
|
|
830
|
-
logSpy = jest.spyOn(_Logger.default, 'info');
|
|
831
|
-
call.sendCallStateMachineEvt(dummyEvent);
|
|
832
|
-
jest.advanceTimersByTime(_constants.DEFAULT_SESSION_TIMER);
|
|
833
|
-
|
|
834
|
-
/* This is to flush all the promises from the Promise queue so that
|
|
835
|
-
* Jest.fakeTimers can advance time and also clear the promise Queue
|
|
836
|
-
*/
|
|
837
|
-
_context13.next = 11;
|
|
838
|
-
return (0, _testUtil.flushPromises)(3);
|
|
839
|
-
case 11:
|
|
840
|
-
expect(setInterval).toHaveBeenCalledTimes(1);
|
|
841
|
-
expect(funcSpy).toBeCalledTimes(1);
|
|
842
|
-
expect(logSpy).toBeCalledWith('Session refresh successful', {
|
|
843
|
-
file: 'call',
|
|
844
|
-
method: 'handleCallEstablished'
|
|
845
|
-
});
|
|
846
|
-
expect(logSpy).toHaveBeenCalledWith("".concat(_constants2.METHOD_START_MESSAGE, " with: ").concat(call.getCorrelationId()), {
|
|
847
|
-
file: 'call',
|
|
848
|
-
method: 'handleCallEstablished'
|
|
849
|
-
});
|
|
850
|
-
case 15:
|
|
851
|
-
case "end":
|
|
852
|
-
return _context13.stop();
|
|
853
|
-
}
|
|
854
|
-
}, _callee13);
|
|
855
|
-
})));
|
|
856
|
-
it('session refresh failure', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee14() {
|
|
857
|
-
var statusPayload, funcSpy;
|
|
858
|
-
return _regenerator.default.wrap(function _callee14$(_context14) {
|
|
859
|
-
while (1) switch (_context14.prev = _context14.next) {
|
|
860
|
-
case 0:
|
|
861
|
-
expect.assertions(4);
|
|
862
|
-
statusPayload = {
|
|
863
|
-
statusCode: 403
|
|
864
|
-
};
|
|
865
|
-
webex.request.mockReturnValue(statusPayload);
|
|
866
|
-
jest.spyOn(global, 'clearInterval');
|
|
867
|
-
call.on(_types2.CALL_EVENT_KEYS.CALL_ERROR, function (errObj) {
|
|
868
|
-
expect(errObj.type).toStrictEqual(_types.ERROR_TYPE.FORBIDDEN_ERROR);
|
|
869
|
-
expect(errObj.message).toStrictEqual('An unauthorized action has been received. This action has been blocked. Please contact the administrator if this persists.');
|
|
870
|
-
});
|
|
871
|
-
funcSpy = jest.spyOn(call, 'postStatus').mockRejectedValue(statusPayload);
|
|
872
|
-
if (call['sessionTimer'] === undefined) {
|
|
873
|
-
/* In cases where this test is run independently/alone, there is no sessionTimer initiated
|
|
874
|
-
Thus we will check and initialize the timer when not present by calling handleCallEstablish() */
|
|
875
|
-
call['handleCallEstablished']({});
|
|
876
|
-
}
|
|
877
|
-
call['handleCallEstablished']({});
|
|
878
|
-
jest.advanceTimersByTime(_constants.DEFAULT_SESSION_TIMER);
|
|
879
|
-
|
|
880
|
-
/* This is to flush all the promises from the Promise queue so that
|
|
881
|
-
* Jest.fakeTimers can advance time and also clear the promise Queue
|
|
882
|
-
*/
|
|
883
|
-
_context14.next = 11;
|
|
884
|
-
return _promise.default.resolve();
|
|
885
|
-
case 11:
|
|
886
|
-
_context14.next = 13;
|
|
887
|
-
return _promise.default.resolve();
|
|
888
|
-
case 13:
|
|
889
|
-
expect(clearInterval).toHaveBeenCalledTimes(2); // check this
|
|
890
|
-
expect(funcSpy).toBeCalledTimes(1);
|
|
891
|
-
case 15:
|
|
892
|
-
case "end":
|
|
893
|
-
return _context14.stop();
|
|
894
|
-
}
|
|
895
|
-
}, _callee14);
|
|
896
|
-
})));
|
|
897
|
-
it('state changes during successful incoming call', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee15() {
|
|
898
|
-
var statusPayload, dummyEvent, postMediaSpy, deleteSpy, dummyOkEvent;
|
|
899
|
-
return _regenerator.default.wrap(function _callee15$(_context15) {
|
|
900
|
-
while (1) switch (_context15.prev = _context15.next) {
|
|
901
|
-
case 0:
|
|
902
|
-
statusPayload = {
|
|
903
|
-
statusCode: 200,
|
|
904
|
-
body: mockStatusBody
|
|
905
|
-
};
|
|
906
|
-
dummyEvent = {
|
|
907
|
-
type: 'E_RECV_CALL_SETUP',
|
|
908
|
-
data: {
|
|
909
|
-
seq: 1,
|
|
910
|
-
messageType: 'OFFER'
|
|
911
|
-
}
|
|
912
|
-
};
|
|
913
|
-
postMediaSpy = jest.spyOn(call, 'postMedia');
|
|
914
|
-
deleteSpy = jest.spyOn(call, 'delete');
|
|
915
|
-
webex.request.mockReturnValue(statusPayload);
|
|
916
|
-
call['direction'] = _types3.CallDirection.INBOUND;
|
|
917
|
-
call.sendCallStateMachineEvt(dummyEvent);
|
|
918
|
-
expect(call['callStateMachine'].state.value).toBe('S_SEND_CALL_PROGRESS');
|
|
919
|
-
dummyEvent.type = 'E_SEND_CALL_CONNECT';
|
|
920
|
-
call.sendCallStateMachineEvt(dummyEvent);
|
|
921
|
-
expect(call['callStateMachine'].state.value).toBe('S_SEND_CALL_CONNECT');
|
|
922
|
-
|
|
923
|
-
/* we should expect to forward the roap offer message to mediaSdk for further processing */
|
|
924
|
-
dummyEvent.type = 'E_RECV_ROAP_OFFER';
|
|
925
|
-
call.sendMediaStateMachineEvt(dummyEvent);
|
|
926
|
-
expect(_testUtil.mediaConnection.roapMessageReceived).toHaveBeenLastCalledWith(dummyEvent.data);
|
|
927
|
-
|
|
928
|
-
/* expect sending roap answer to mobius */
|
|
929
|
-
dummyEvent.type = 'E_SEND_ROAP_ANSWER';
|
|
930
|
-
call.sendMediaStateMachineEvt(dummyEvent);
|
|
931
|
-
expect(postMediaSpy).toBeCalledOnceWith(dummyEvent.data);
|
|
932
|
-
dummyOkEvent = {
|
|
933
|
-
type: 'E_ROAP_OK',
|
|
934
|
-
data: {
|
|
935
|
-
received: true,
|
|
936
|
-
message: {
|
|
937
|
-
seq: 1,
|
|
938
|
-
messageType: 'OFFER'
|
|
939
|
-
}
|
|
940
|
-
}
|
|
941
|
-
};
|
|
942
|
-
/* we receive roap Ok from mobius and expect mediaSdk to process it */
|
|
943
|
-
call.sendMediaStateMachineEvt(dummyOkEvent);
|
|
944
|
-
expect(_testUtil.mediaConnection.roapMessageReceived).toHaveBeenLastCalledWith(dummyOkEvent.data.message);
|
|
945
|
-
expect(call['callStateMachine'].state.value).toBe('S_CALL_ESTABLISHED');
|
|
946
|
-
expect(call.isConnected()).toBe(true);
|
|
947
|
-
call.sendDigit('1');
|
|
948
|
-
expect(dtmfMock).toBeCalledOnceWith('1');
|
|
949
|
-
call.sendCallStateMachineEvt({
|
|
950
|
-
type: 'E_RECV_CALL_DISCONNECT'
|
|
951
|
-
});
|
|
952
|
-
expect(deleteSpy).toBeCalledOnceWith();
|
|
953
|
-
expect(call['callStateMachine'].state.value).toBe('S_RECV_CALL_DISCONNECT');
|
|
954
|
-
case 27:
|
|
955
|
-
case "end":
|
|
956
|
-
return _context15.stop();
|
|
957
|
-
}
|
|
958
|
-
}, _callee15);
|
|
959
|
-
})));
|
|
960
|
-
it('state changes during unsuccessful incoming call due to no offer', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee16() {
|
|
961
|
-
var statusPayload, dummyEvent;
|
|
962
|
-
return _regenerator.default.wrap(function _callee16$(_context16) {
|
|
963
|
-
while (1) switch (_context16.prev = _context16.next) {
|
|
964
|
-
case 0:
|
|
965
|
-
call['direction'] = _types3.CallDirection.INBOUND;
|
|
966
|
-
statusPayload = {
|
|
967
|
-
statusCode: 200,
|
|
968
|
-
body: mockStatusBody
|
|
969
|
-
};
|
|
970
|
-
dummyEvent = {
|
|
971
|
-
type: 'E_RECV_CALL_SETUP',
|
|
972
|
-
data: {
|
|
973
|
-
seq: 1,
|
|
974
|
-
message: {},
|
|
975
|
-
type: 'OFFER'
|
|
976
|
-
}
|
|
977
|
-
};
|
|
978
|
-
webex.request.mockReturnValue(statusPayload);
|
|
979
|
-
call.sendCallStateMachineEvt(dummyEvent);
|
|
980
|
-
expect(call['callStateMachine'].state.value).toBe('S_SEND_CALL_PROGRESS');
|
|
981
|
-
_context16.next = 8;
|
|
982
|
-
return call['handleOutgoingCallConnect']({
|
|
983
|
-
type: 'E_SEND_CALL_CONNECT'
|
|
984
|
-
});
|
|
985
|
-
case 8:
|
|
986
|
-
/* state should not change since there is no offer received. */
|
|
987
|
-
expect(call['callStateMachine'].state.value).toBe('S_SEND_CALL_PROGRESS');
|
|
988
|
-
expect(call.isConnected()).toBeFalsy();
|
|
989
|
-
call.sendCallStateMachineEvt({
|
|
990
|
-
type: 'E_RECV_CALL_DISCONNECT'
|
|
991
|
-
});
|
|
992
|
-
expect(call['callStateMachine'].state.value).toBe('S_RECV_CALL_DISCONNECT');
|
|
993
|
-
case 12:
|
|
994
|
-
case "end":
|
|
995
|
-
return _context16.stop();
|
|
996
|
-
}
|
|
997
|
-
}, _callee16);
|
|
998
|
-
})));
|
|
999
|
-
it('state changes during unsuccessful incoming call due error in call connect', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee17() {
|
|
1000
|
-
var warnSpy, errorSpy, stateMachineSpy, statusPayload, roapMessage;
|
|
1001
|
-
return _regenerator.default.wrap(function _callee17$(_context17) {
|
|
1002
|
-
while (1) switch (_context17.prev = _context17.next) {
|
|
1003
|
-
case 0:
|
|
1004
|
-
warnSpy = jest.spyOn(_Logger.default, 'warn');
|
|
1005
|
-
errorSpy = jest.spyOn(_Logger.default, 'error');
|
|
1006
|
-
stateMachineSpy = jest.spyOn(call, 'sendCallStateMachineEvt');
|
|
1007
|
-
statusPayload = {
|
|
1008
|
-
statusCode: 200,
|
|
1009
|
-
body: mockStatusBody
|
|
1010
|
-
};
|
|
1011
|
-
roapMessage = {
|
|
1012
|
-
seq: 1,
|
|
1013
|
-
message: {},
|
|
1014
|
-
type: 'OFFER'
|
|
1015
|
-
};
|
|
1016
|
-
call['direction'] = _types3.CallDirection.INBOUND;
|
|
1017
|
-
webex.request.mockReturnValue(statusPayload);
|
|
1018
|
-
call.sendCallStateMachineEvt({
|
|
1019
|
-
type: 'E_RECV_CALL_SETUP'
|
|
1020
|
-
});
|
|
1021
|
-
expect(call['callStateMachine'].state.value).toBe('S_SEND_CALL_PROGRESS');
|
|
1022
|
-
call.sendMediaStateMachineEvt({
|
|
1023
|
-
type: 'E_RECV_ROAP_OFFER',
|
|
1024
|
-
data: roapMessage
|
|
1025
|
-
});
|
|
1026
|
-
webex.request.mockRejectedValueOnce({
|
|
1027
|
-
statusCode: 403
|
|
1028
|
-
}).mockResolvedValue(statusPayload);
|
|
1029
|
-
_context17.next = 13;
|
|
1030
|
-
return call['handleOutgoingCallConnect']({
|
|
1031
|
-
type: 'E_SEND_CALL_CONNECT'
|
|
1032
|
-
});
|
|
1033
|
-
case 13:
|
|
1034
|
-
expect(call['callStateMachine'].state.value).toBe('S_UNKNOWN');
|
|
1035
|
-
expect(stateMachineSpy).toBeCalledTimes(3);
|
|
1036
|
-
expect(warnSpy).toBeCalledTimes(3);
|
|
1037
|
-
expect(errorSpy).toBeCalledTimes(1);
|
|
1038
|
-
case 17:
|
|
1039
|
-
case "end":
|
|
1040
|
-
return _context17.stop();
|
|
1041
|
-
}
|
|
1042
|
-
}, _callee17);
|
|
1043
|
-
})));
|
|
1044
|
-
it('state changes during successful outgoing call', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee18() {
|
|
1045
|
-
var statusPayload, dummyEvent, postMediaSpy, logSpy, dummyOkEvent;
|
|
1046
|
-
return _regenerator.default.wrap(function _callee18$(_context18) {
|
|
1047
|
-
while (1) switch (_context18.prev = _context18.next) {
|
|
1048
|
-
case 0:
|
|
1049
|
-
statusPayload = {
|
|
1050
|
-
statusCode: 200,
|
|
1051
|
-
body: mockStatusBody
|
|
1052
|
-
};
|
|
1053
|
-
dummyEvent = {
|
|
1054
|
-
type: 'E_SEND_CALL_SETUP',
|
|
1055
|
-
data: undefined
|
|
1056
|
-
};
|
|
1057
|
-
postMediaSpy = jest.spyOn(call, 'postMedia');
|
|
1058
|
-
logSpy = jest.spyOn(_Logger.default, 'log');
|
|
1059
|
-
webex.request.mockReturnValue(statusPayload);
|
|
1060
|
-
call.sendCallStateMachineEvt(dummyEvent);
|
|
1061
|
-
expect(call['callStateMachine'].state.value).toBe('S_SEND_CALL_SETUP');
|
|
1062
|
-
expect(logSpy).toHaveBeenCalled();
|
|
1063
|
-
dummyEvent.type = 'E_RECV_CALL_PROGRESS';
|
|
1064
|
-
call.sendCallStateMachineEvt(dummyEvent);
|
|
1065
|
-
expect(call['callStateMachine'].state.value).toBe('S_RECV_CALL_PROGRESS');
|
|
1066
|
-
dummyEvent.type = 'E_SEND_ROAP_OFFER';
|
|
1067
|
-
call.sendMediaStateMachineEvt(dummyEvent);
|
|
1068
|
-
|
|
1069
|
-
/**
|
|
1070
|
-
* Since the event doesn't have any data above, we should request media sdk for an offer here.
|
|
1071
|
-
* The below event is expected to be called again my mediaSdk.
|
|
1072
|
-
*/
|
|
1073
|
-
dummyEvent.data = {
|
|
1074
|
-
seq: 1,
|
|
1075
|
-
messageType: 'OFFER',
|
|
1076
|
-
sdp: 'sdp'
|
|
1077
|
-
};
|
|
1078
|
-
call.sendMediaStateMachineEvt(dummyEvent);
|
|
1079
|
-
expect(_testUtil.mediaConnection.initiateOffer).toHaveBeenCalledTimes(1);
|
|
1080
|
-
expect(postMediaSpy).toHaveBeenLastCalledWith(dummyEvent.data);
|
|
1081
|
-
dummyEvent.type = 'E_RECV_ROAP_ANSWER';
|
|
1082
|
-
call.sendMediaStateMachineEvt(dummyEvent);
|
|
1083
|
-
expect(_testUtil.mediaConnection.roapMessageReceived).toHaveBeenLastCalledWith(dummyEvent.data);
|
|
1084
|
-
dummyOkEvent = {
|
|
1085
|
-
type: 'E_ROAP_OK',
|
|
1086
|
-
data: {
|
|
1087
|
-
received: false,
|
|
1088
|
-
message: {
|
|
1089
|
-
seq: 1,
|
|
1090
|
-
messageType: 'OK'
|
|
1091
|
-
}
|
|
1092
|
-
}
|
|
1093
|
-
};
|
|
1094
|
-
call.sendMediaStateMachineEvt(dummyOkEvent);
|
|
1095
|
-
expect(postMediaSpy).toHaveBeenLastCalledWith(dummyOkEvent.data.message);
|
|
1096
|
-
dummyEvent.type = 'E_RECV_ROAP_OFFER_REQUEST';
|
|
1097
|
-
call.sendMediaStateMachineEvt(dummyEvent);
|
|
1098
|
-
expect(_testUtil.mediaConnection.roapMessageReceived).toHaveBeenLastCalledWith(dummyEvent.data);
|
|
1099
|
-
dummyEvent.type = 'E_SEND_ROAP_OFFER';
|
|
1100
|
-
call.sendMediaStateMachineEvt(dummyEvent);
|
|
1101
|
-
expect(postMediaSpy).toHaveBeenLastCalledWith(dummyEvent.data);
|
|
1102
|
-
dummyEvent.type = 'E_RECV_ROAP_ANSWER';
|
|
1103
|
-
call.sendMediaStateMachineEvt(dummyEvent);
|
|
1104
|
-
expect(_testUtil.mediaConnection.roapMessageReceived).toHaveBeenLastCalledWith(dummyEvent.data);
|
|
1105
|
-
call.sendMediaStateMachineEvt(dummyOkEvent);
|
|
1106
|
-
expect(postMediaSpy).toHaveBeenLastCalledWith(dummyOkEvent.data.message);
|
|
1107
|
-
|
|
1108
|
-
/* With the two roap offer/answer transactions that we simulated earlier
|
|
1109
|
-
we get a total 4 outgoing and 3 incoming roap messages.
|
|
1110
|
-
*/
|
|
1111
|
-
expect(postMediaSpy).toBeCalledTimes(4);
|
|
1112
|
-
expect(_testUtil.mediaConnection.roapMessageReceived).toBeCalledTimes(3);
|
|
1113
|
-
dummyEvent.type = 'E_RECV_CALL_CONNECT';
|
|
1114
|
-
call.sendCallStateMachineEvt(dummyEvent);
|
|
1115
|
-
expect(call['callStateMachine'].state.value).toBe('S_CALL_ESTABLISHED');
|
|
1116
|
-
expect(call.isConnected()).toBe(true);
|
|
1117
|
-
call.sendCallStateMachineEvt({
|
|
1118
|
-
type: 'E_SEND_CALL_DISCONNECT'
|
|
1119
|
-
});
|
|
1120
|
-
expect(call['callStateMachine'].state.value).toBe('S_SEND_CALL_DISCONNECT');
|
|
1121
|
-
case 42:
|
|
1122
|
-
case "end":
|
|
1123
|
-
return _context18.stop();
|
|
1124
|
-
}
|
|
1125
|
-
}, _callee18);
|
|
1126
|
-
})));
|
|
1127
|
-
it('outgoing call where we receive connect directly after setup. Media established before connect. test call and media state changes', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee19() {
|
|
1128
|
-
var statusPayload, dummySetupEvent, dummyConnectEvent, dummyOfferEvent, dummyAnswerEvent, dummyOkEvent, postMediaSpy;
|
|
1129
|
-
return _regenerator.default.wrap(function _callee19$(_context19) {
|
|
1130
|
-
while (1) switch (_context19.prev = _context19.next) {
|
|
1131
|
-
case 0:
|
|
1132
|
-
statusPayload = {
|
|
1133
|
-
statusCode: 200,
|
|
1134
|
-
body: mockStatusBody
|
|
1135
|
-
};
|
|
1136
|
-
dummySetupEvent = {
|
|
1137
|
-
type: 'E_SEND_CALL_SETUP',
|
|
1138
|
-
data: undefined
|
|
1139
|
-
};
|
|
1140
|
-
dummyConnectEvent = {
|
|
1141
|
-
type: 'E_RECV_CALL_CONNECT',
|
|
1142
|
-
data: undefined
|
|
1143
|
-
};
|
|
1144
|
-
dummyOfferEvent = {
|
|
1145
|
-
type: 'E_SEND_ROAP_OFFER',
|
|
1146
|
-
data: undefined
|
|
1147
|
-
};
|
|
1148
|
-
dummyAnswerEvent = {
|
|
1149
|
-
type: 'E_RECV_ROAP_ANSWER',
|
|
1150
|
-
data: {
|
|
1151
|
-
seq: 1,
|
|
1152
|
-
messageType: 'ANSWER',
|
|
1153
|
-
sdp: 'sdp'
|
|
1154
|
-
}
|
|
1155
|
-
};
|
|
1156
|
-
dummyOkEvent = {
|
|
1157
|
-
type: 'E_ROAP_OK',
|
|
1158
|
-
data: {
|
|
1159
|
-
received: false,
|
|
1160
|
-
message: {
|
|
1161
|
-
seq: 1,
|
|
1162
|
-
messageType: 'OK'
|
|
1163
|
-
}
|
|
1164
|
-
}
|
|
1165
|
-
};
|
|
1166
|
-
postMediaSpy = jest.spyOn(call, 'postMedia');
|
|
1167
|
-
webex.request.mockReturnValue(statusPayload);
|
|
1168
|
-
call.sendCallStateMachineEvt(dummySetupEvent);
|
|
1169
|
-
expect(call['callStateMachine'].state.value).toBe('S_SEND_CALL_SETUP');
|
|
1170
|
-
call.sendMediaStateMachineEvt(dummyOfferEvent);
|
|
1171
|
-
|
|
1172
|
-
/**
|
|
1173
|
-
* Since the event doesn't have any data above, we should request media sdk for an offer here.
|
|
1174
|
-
* The below event is expected to be called again my mediaSdk.
|
|
1175
|
-
*/
|
|
1176
|
-
dummyOfferEvent.data = {
|
|
1177
|
-
seq: 1,
|
|
1178
|
-
messageType: 'OFFER',
|
|
1179
|
-
sdp: 'sdp'
|
|
1180
|
-
};
|
|
1181
|
-
call.sendMediaStateMachineEvt(dummyOfferEvent);
|
|
1182
|
-
expect(_testUtil.mediaConnection.initiateOffer).toHaveBeenCalledTimes(1);
|
|
1183
|
-
expect(postMediaSpy).toHaveBeenLastCalledWith(dummyOfferEvent.data);
|
|
1184
|
-
call.sendMediaStateMachineEvt(dummyAnswerEvent);
|
|
1185
|
-
expect(_testUtil.mediaConnection.roapMessageReceived).toHaveBeenLastCalledWith(dummyAnswerEvent.data);
|
|
1186
|
-
call.sendMediaStateMachineEvt(dummyOkEvent);
|
|
1187
|
-
expect(postMediaSpy).toHaveBeenLastCalledWith(dummyOkEvent.data.message);
|
|
1188
|
-
expect(call['mediaStateMachine'].state.value).toBe('S_ROAP_OK');
|
|
1189
|
-
call.sendCallStateMachineEvt(dummyConnectEvent);
|
|
1190
|
-
expect(call['callStateMachine'].state.value).toBe('S_CALL_ESTABLISHED');
|
|
1191
|
-
expect(call.isConnected()).toBe(true);
|
|
1192
|
-
call.sendCallStateMachineEvt({
|
|
1193
|
-
type: 'E_SEND_CALL_DISCONNECT'
|
|
1194
|
-
});
|
|
1195
|
-
expect(call['callStateMachine'].state.value).toBe('S_SEND_CALL_DISCONNECT');
|
|
1196
|
-
case 25:
|
|
1197
|
-
case "end":
|
|
1198
|
-
return _context19.stop();
|
|
1199
|
-
}
|
|
1200
|
-
}, _callee19);
|
|
1201
|
-
})));
|
|
1202
|
-
it('state changes during successful outgoing call with early media', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee20() {
|
|
1203
|
-
var statusPayload, dummyEvent;
|
|
1204
|
-
return _regenerator.default.wrap(function _callee20$(_context20) {
|
|
1205
|
-
while (1) switch (_context20.prev = _context20.next) {
|
|
1206
|
-
case 0:
|
|
1207
|
-
statusPayload = {
|
|
1208
|
-
statusCode: 200,
|
|
1209
|
-
body: mockStatusBody
|
|
1210
|
-
};
|
|
1211
|
-
dummyEvent = {
|
|
1212
|
-
type: 'E_SEND_CALL_SETUP',
|
|
1213
|
-
data: {
|
|
1214
|
-
seq: 1,
|
|
1215
|
-
message: {},
|
|
1216
|
-
type: 'OFFER'
|
|
1217
|
-
}
|
|
1218
|
-
};
|
|
1219
|
-
webex.request.mockReturnValue(statusPayload);
|
|
1220
|
-
call.sendCallStateMachineEvt(dummyEvent);
|
|
1221
|
-
expect(call['callStateMachine'].state.value).toBe('S_SEND_CALL_SETUP');
|
|
1222
|
-
dummyEvent.type = 'E_RECV_CALL_PROGRESS';
|
|
1223
|
-
call.sendCallStateMachineEvt(dummyEvent);
|
|
1224
|
-
expect(call['callStateMachine'].state.value).toBe('S_RECV_CALL_PROGRESS');
|
|
1225
|
-
|
|
1226
|
-
/* Send a second callProgress event with inband media and it should handle */
|
|
1227
|
-
dummyEvent.data['callProgressData'] = {
|
|
1228
|
-
inbandMedia: true
|
|
1229
|
-
};
|
|
1230
|
-
dummyEvent.data['callerId'] = {
|
|
1231
|
-
from: '"Bob Marley" <sip:5010@207.182.171.130;user=phone>;tag=888068389-1654853820619-'
|
|
1232
|
-
};
|
|
1233
|
-
call.sendCallStateMachineEvt(dummyEvent);
|
|
1234
|
-
expect(call['callStateMachine'].state.value).toBe('S_RECV_CALL_PROGRESS');
|
|
1235
|
-
dummyEvent.type = 'E_RECV_CALL_CONNECT';
|
|
1236
|
-
call.sendCallStateMachineEvt(dummyEvent);
|
|
1237
|
-
expect(call['callStateMachine'].state.value).toBe('S_CALL_ESTABLISHED');
|
|
1238
|
-
call.sendCallStateMachineEvt({
|
|
1239
|
-
type: 'E_RECV_CALL_DISCONNECT'
|
|
1240
|
-
});
|
|
1241
|
-
expect(call['callStateMachine'].state.value).toBe('S_RECV_CALL_DISCONNECT');
|
|
1242
|
-
case 17:
|
|
1243
|
-
case "end":
|
|
1244
|
-
return _context20.stop();
|
|
1245
|
-
}
|
|
1246
|
-
}, _callee20);
|
|
1247
|
-
})));
|
|
1248
|
-
it('state changes during unsuccessful outgoing call due to error in call setup', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee21() {
|
|
1249
|
-
var statusPayload, dummyEvent, errorSpy;
|
|
1250
|
-
return _regenerator.default.wrap(function _callee21$(_context21) {
|
|
1251
|
-
while (1) switch (_context21.prev = _context21.next) {
|
|
1252
|
-
case 0:
|
|
1253
|
-
statusPayload = {
|
|
1254
|
-
statusCode: 403,
|
|
1255
|
-
body: mockStatusBody
|
|
1256
|
-
};
|
|
1257
|
-
dummyEvent = {
|
|
1258
|
-
type: 'E_SEND_CALL_SETUP',
|
|
1259
|
-
data: {
|
|
1260
|
-
seq: 1,
|
|
1261
|
-
message: {},
|
|
1262
|
-
type: 'OFFER'
|
|
1263
|
-
}
|
|
1264
|
-
};
|
|
1265
|
-
webex.request.mockRejectedValueOnce(statusPayload);
|
|
1266
|
-
errorSpy = jest.spyOn(_Logger.default, 'error');
|
|
1267
|
-
call.sendCallStateMachineEvt(dummyEvent);
|
|
1268
|
-
_context21.next = 7;
|
|
1269
|
-
return (0, _testUtil.flushPromises)(3);
|
|
1270
|
-
case 7:
|
|
1271
|
-
expect(call['callStateMachine'].state.value).toBe('S_UNKNOWN');
|
|
1272
|
-
expect(errorSpy).toHaveBeenCalled();
|
|
1273
|
-
expect(uploadLogsSpy).toHaveBeenCalledWith({
|
|
1274
|
-
correlationId: call.getCorrelationId(),
|
|
1275
|
-
callId: call.getCallId()
|
|
1276
|
-
});
|
|
1277
|
-
case 10:
|
|
1278
|
-
case "end":
|
|
1279
|
-
return _context21.stop();
|
|
1280
|
-
}
|
|
1281
|
-
}, _callee21);
|
|
1282
|
-
})));
|
|
1283
|
-
it('state changes during unsuccessful outgoing call due to error in media ok', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee22() {
|
|
1284
|
-
var statusPayload, dummyEvent, warnSpy;
|
|
1285
|
-
return _regenerator.default.wrap(function _callee22$(_context22) {
|
|
1286
|
-
while (1) switch (_context22.prev = _context22.next) {
|
|
1287
|
-
case 0:
|
|
1288
|
-
statusPayload = {
|
|
1289
|
-
statusCode: 403,
|
|
1290
|
-
body: mockStatusBody
|
|
1291
|
-
};
|
|
1292
|
-
dummyEvent = {
|
|
1293
|
-
type: 'E_ROAP_OK',
|
|
1294
|
-
data: {
|
|
1295
|
-
received: false,
|
|
1296
|
-
message: {}
|
|
1297
|
-
}
|
|
1298
|
-
};
|
|
1299
|
-
call['callStateMachine'].state.value = 'S_RECV_CALL_PROGRESS';
|
|
1300
|
-
call['earlyMedia'] = true;
|
|
1301
|
-
call['mediaStateMachine'].state.value = 'S_RECV_ROAP_ANSWER';
|
|
1302
|
-
webex.request.mockRejectedValue(statusPayload);
|
|
1303
|
-
warnSpy = jest.spyOn(_Logger.default, 'warn');
|
|
1304
|
-
jest.spyOn(Utils, 'uploadLogs').mockResolvedValue(undefined);
|
|
1305
|
-
_context22.next = 10;
|
|
1306
|
-
return call['handleRoapEstablished']({}, dummyEvent);
|
|
1307
|
-
case 10:
|
|
1308
|
-
_context22.next = 12;
|
|
1309
|
-
return (0, _testUtil.flushPromises)(2);
|
|
1310
|
-
case 12:
|
|
1311
|
-
expect(call.isConnected()).toBe(false);
|
|
1312
|
-
expect(call['mediaStateMachine'].state.value).toBe('S_ROAP_ERROR');
|
|
1313
|
-
expect(call['callStateMachine'].state.value).toBe('S_UNKNOWN');
|
|
1314
|
-
expect(warnSpy).toHaveBeenCalledWith('Failed to process MediaOk request', {
|
|
1315
|
-
file: 'call',
|
|
1316
|
-
method: 'handleRoapEstablished'
|
|
1317
|
-
});
|
|
1318
|
-
expect(uploadLogsSpy).toHaveBeenCalledWith({
|
|
1319
|
-
correlationId: call.getCorrelationId(),
|
|
1320
|
-
callId: call.getCallId()
|
|
1321
|
-
});
|
|
1322
|
-
case 17:
|
|
1323
|
-
case "end":
|
|
1324
|
-
return _context22.stop();
|
|
1325
|
-
}
|
|
1326
|
-
}, _callee22);
|
|
1327
|
-
})));
|
|
1328
|
-
it('state changes during unsuccessful outgoing call since no sdp in offer', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee23() {
|
|
1329
|
-
var statusPayload, dummyEvent;
|
|
1330
|
-
return _regenerator.default.wrap(function _callee23$(_context23) {
|
|
1331
|
-
while (1) switch (_context23.prev = _context23.next) {
|
|
1332
|
-
case 0:
|
|
1333
|
-
statusPayload = {
|
|
1334
|
-
statusCode: 403,
|
|
1335
|
-
body: mockStatusBody
|
|
1336
|
-
};
|
|
1337
|
-
dummyEvent = {
|
|
1338
|
-
type: 'E_SEND_ROAP_OFFER',
|
|
1339
|
-
data: {
|
|
1340
|
-
seq: 1,
|
|
1341
|
-
type: 'OFFER'
|
|
1342
|
-
}
|
|
1343
|
-
};
|
|
1344
|
-
webex.request.mockReturnValue(statusPayload);
|
|
1345
|
-
call['callStateMachine'].state.value = 'S_RECV_CALL_PROGRESS';
|
|
1346
|
-
call['mediaStateMachine'].state.value = 'S_ROAP_IDLE';
|
|
1347
|
-
call.sendMediaStateMachineEvt(dummyEvent);
|
|
1348
|
-
/* since there is no sdp, mediaMachine should remain in same state
|
|
1349
|
-
and an initiateOffer request to be sent to SDK only once */
|
|
1350
|
-
expect(call['mediaStateMachine'].state.value).toBe('S_SEND_ROAP_OFFER');
|
|
1351
|
-
expect(_testUtil.mediaConnection.initiateOffer).toBeCalledOnceWith();
|
|
1352
|
-
case 8:
|
|
1353
|
-
case "end":
|
|
1354
|
-
return _context23.stop();
|
|
1355
|
-
}
|
|
1356
|
-
}, _callee23);
|
|
1357
|
-
})));
|
|
1358
|
-
it('Outgoing Roap offer retry-after error case during midcall', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee24() {
|
|
1359
|
-
var statusPayload, funcSpy, stateMachineSpy, dummyEvent;
|
|
1360
|
-
return _regenerator.default.wrap(function _callee24$(_context24) {
|
|
1361
|
-
while (1) switch (_context24.prev = _context24.next) {
|
|
1362
|
-
case 0:
|
|
1363
|
-
statusPayload = {
|
|
1364
|
-
statusCode: 503,
|
|
1365
|
-
headers: {
|
|
1366
|
-
'retry-after': 1
|
|
1367
|
-
},
|
|
1368
|
-
body: mockStatusBody
|
|
1369
|
-
};
|
|
1370
|
-
jest.spyOn(global, 'setTimeout');
|
|
1371
|
-
funcSpy = jest.spyOn(call, 'postMedia').mockRejectedValueOnce(statusPayload);
|
|
1372
|
-
stateMachineSpy = jest.spyOn(call, 'sendMediaStateMachineEvt');
|
|
1373
|
-
dummyEvent = {
|
|
1374
|
-
type: 'E_SEND_ROAP_OFFER',
|
|
1375
|
-
data: {
|
|
1376
|
-
seq: 1,
|
|
1377
|
-
message: {},
|
|
1378
|
-
type: 'OFFER',
|
|
1379
|
-
sdp: 'sdp'
|
|
1380
|
-
}
|
|
1381
|
-
};
|
|
1382
|
-
call['connected'] = true;
|
|
1383
|
-
_context24.next = 8;
|
|
1384
|
-
return call['handleOutgoingRoapOffer']({}, dummyEvent);
|
|
1385
|
-
case 8:
|
|
1386
|
-
jest.advanceTimersByTime(1005);
|
|
1387
|
-
expect(setTimeout).toHaveBeenCalledTimes(1);
|
|
1388
|
-
expect(funcSpy).toHaveBeenCalledWith(dummyEvent.data);
|
|
1389
|
-
|
|
1390
|
-
/* first failure , and second because of retry-after */
|
|
1391
|
-
expect(funcSpy).toHaveBeenCalledTimes(2);
|
|
1392
|
-
expect(stateMachineSpy).toBeCalledOnceWith(dummyEvent);
|
|
1393
|
-
case 13:
|
|
1394
|
-
case "end":
|
|
1395
|
-
return _context24.stop();
|
|
1396
|
-
}
|
|
1397
|
-
}, _callee24);
|
|
1398
|
-
})));
|
|
1399
|
-
it('Outgoing Roap offer retry-after error case during call establishment', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee25() {
|
|
1400
|
-
var statusPayload, funcSpy, stateMachineSpy, dummyEvent;
|
|
1401
|
-
return _regenerator.default.wrap(function _callee25$(_context25) {
|
|
1402
|
-
while (1) switch (_context25.prev = _context25.next) {
|
|
1403
|
-
case 0:
|
|
1404
|
-
statusPayload = {
|
|
1405
|
-
statusCode: 503,
|
|
1406
|
-
headers: {
|
|
1407
|
-
'retry-after': 1
|
|
1408
|
-
},
|
|
1409
|
-
body: mockStatusBody
|
|
1410
|
-
};
|
|
1411
|
-
jest.spyOn(global, 'setTimeout');
|
|
1412
|
-
funcSpy = jest.spyOn(call, 'postMedia').mockRejectedValueOnce(statusPayload);
|
|
1413
|
-
stateMachineSpy = jest.spyOn(call, 'sendMediaStateMachineEvt');
|
|
1414
|
-
dummyEvent = {
|
|
1415
|
-
type: 'E_SEND_ROAP_OFFER',
|
|
1416
|
-
data: {
|
|
1417
|
-
seq: 1,
|
|
1418
|
-
message: {},
|
|
1419
|
-
type: 'OFFER',
|
|
1420
|
-
sdp: 'sdp'
|
|
1421
|
-
}
|
|
1422
|
-
};
|
|
1423
|
-
call['connected'] = false;
|
|
1424
|
-
_context25.next = 8;
|
|
1425
|
-
return call['handleOutgoingRoapOffer']({}, dummyEvent);
|
|
1426
|
-
case 8:
|
|
1427
|
-
jest.advanceTimersByTime(1005);
|
|
1428
|
-
expect(funcSpy).toBeCalledOnceWith(dummyEvent.data);
|
|
1429
|
-
|
|
1430
|
-
/* These shouldn't be called as call is not connected yet */
|
|
1431
|
-
expect(setTimeout).not.toHaveBeenCalled();
|
|
1432
|
-
expect(stateMachineSpy).not.toBeCalled();
|
|
1433
|
-
case 12:
|
|
1434
|
-
case "end":
|
|
1435
|
-
return _context25.stop();
|
|
1436
|
-
}
|
|
1437
|
-
}, _callee25);
|
|
1438
|
-
})));
|
|
1439
|
-
it('Outgoing Roap Answer retry-after error case during midcall', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee26() {
|
|
1440
|
-
var statusPayload, funcSpy, stateMachineSpy, dummyEvent;
|
|
1441
|
-
return _regenerator.default.wrap(function _callee26$(_context26) {
|
|
1442
|
-
while (1) switch (_context26.prev = _context26.next) {
|
|
1443
|
-
case 0:
|
|
1444
|
-
statusPayload = {
|
|
1445
|
-
statusCode: 503,
|
|
1446
|
-
headers: {
|
|
1447
|
-
'retry-after': 1
|
|
1448
|
-
},
|
|
1449
|
-
body: mockStatusBody
|
|
1450
|
-
};
|
|
1451
|
-
jest.spyOn(global, 'setTimeout');
|
|
1452
|
-
funcSpy = jest.spyOn(call, 'postMedia').mockRejectedValueOnce(statusPayload);
|
|
1453
|
-
stateMachineSpy = jest.spyOn(call, 'sendMediaStateMachineEvt');
|
|
1454
|
-
dummyEvent = {
|
|
1455
|
-
type: 'E_SEND_ROAP_ANSWER',
|
|
1456
|
-
data: {
|
|
1457
|
-
seq: 1,
|
|
1458
|
-
message: {},
|
|
1459
|
-
type: 'OFFER'
|
|
1460
|
-
}
|
|
1461
|
-
};
|
|
1462
|
-
call['connected'] = true;
|
|
1463
|
-
call['mediaStateMachine'].state.value = 'S_RECV_ROAP_OFFER';
|
|
1464
|
-
_context26.next = 9;
|
|
1465
|
-
return call['handleOutgoingRoapAnswer']({}, dummyEvent);
|
|
1466
|
-
case 9:
|
|
1467
|
-
jest.advanceTimersByTime(1005);
|
|
1468
|
-
expect(setTimeout).toHaveBeenCalledTimes(1);
|
|
1469
|
-
expect(funcSpy).toHaveBeenCalledWith(dummyEvent.data);
|
|
1470
|
-
|
|
1471
|
-
/* first failure , and second because of retry-after */
|
|
1472
|
-
expect(funcSpy).toHaveBeenCalledTimes(2);
|
|
1473
|
-
expect(stateMachineSpy).toBeCalledOnceWith(dummyEvent);
|
|
1474
|
-
case 14:
|
|
1475
|
-
case "end":
|
|
1476
|
-
return _context26.stop();
|
|
1477
|
-
}
|
|
1478
|
-
}, _callee26);
|
|
1479
|
-
})));
|
|
1480
|
-
it('Outgoing Roap answer retry-after error case during call establishment', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee27() {
|
|
1481
|
-
var statusPayload, funcSpy, stateMachineSpy, dummyEvent;
|
|
1482
|
-
return _regenerator.default.wrap(function _callee27$(_context27) {
|
|
1483
|
-
while (1) switch (_context27.prev = _context27.next) {
|
|
1484
|
-
case 0:
|
|
1485
|
-
statusPayload = {
|
|
1486
|
-
statusCode: 503,
|
|
1487
|
-
headers: {
|
|
1488
|
-
'retry-after': 1
|
|
1489
|
-
},
|
|
1490
|
-
body: mockStatusBody
|
|
1491
|
-
};
|
|
1492
|
-
jest.spyOn(global, 'setTimeout');
|
|
1493
|
-
funcSpy = jest.spyOn(call, 'postMedia').mockRejectedValueOnce(statusPayload);
|
|
1494
|
-
stateMachineSpy = jest.spyOn(call, 'sendMediaStateMachineEvt');
|
|
1495
|
-
dummyEvent = {
|
|
1496
|
-
type: 'E_SEND_ROAP_ANSWER',
|
|
1497
|
-
data: {
|
|
1498
|
-
seq: 1,
|
|
1499
|
-
message: {},
|
|
1500
|
-
type: 'OFFER'
|
|
1501
|
-
}
|
|
1502
|
-
};
|
|
1503
|
-
call['connected'] = false;
|
|
1504
|
-
_context27.next = 8;
|
|
1505
|
-
return call['handleOutgoingRoapAnswer']({}, dummyEvent);
|
|
1506
|
-
case 8:
|
|
1507
|
-
jest.advanceTimersByTime(1005);
|
|
1508
|
-
expect(funcSpy).toBeCalledOnceWith(dummyEvent.data);
|
|
1509
|
-
expect(funcSpy).toHaveBeenCalledTimes(1);
|
|
1510
|
-
|
|
1511
|
-
/* These shouldn't be called as call is not connected yet */
|
|
1512
|
-
expect(setTimeout).not.toHaveBeenCalled();
|
|
1513
|
-
expect(stateMachineSpy).not.toBeCalled();
|
|
1514
|
-
case 13:
|
|
1515
|
-
case "end":
|
|
1516
|
-
return _context27.stop();
|
|
1517
|
-
}
|
|
1518
|
-
}, _callee27);
|
|
1519
|
-
})));
|
|
1520
|
-
it('ROAP error during mid call', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee28() {
|
|
1521
|
-
var statusPayload, warnSpy, stateMachineSpy, funcSpy, errorEvent;
|
|
1522
|
-
return _regenerator.default.wrap(function _callee28$(_context28) {
|
|
1523
|
-
while (1) switch (_context28.prev = _context28.next) {
|
|
1524
|
-
case 0:
|
|
1525
|
-
statusPayload = {
|
|
1526
|
-
statusCode: 200,
|
|
1527
|
-
body: mockStatusBody
|
|
1528
|
-
};
|
|
1529
|
-
warnSpy = jest.spyOn(_Logger.default, 'warn');
|
|
1530
|
-
stateMachineSpy = jest.spyOn(call, 'sendCallStateMachineEvt');
|
|
1531
|
-
funcSpy = jest.spyOn(call, 'postMedia').mockResolvedValue(statusPayload);
|
|
1532
|
-
errorEvent = {
|
|
1533
|
-
type: 'E_ROAP_ERROR',
|
|
1534
|
-
data: {
|
|
1535
|
-
seq: 2,
|
|
1536
|
-
messageType: 'ERROR',
|
|
1537
|
-
errorType: 'OUT_OF_ORDER'
|
|
1538
|
-
}
|
|
1539
|
-
};
|
|
1540
|
-
call['mediaStateMachine'].state.value = 'S_SEND_ROAP_ANSWER';
|
|
1541
|
-
call['connected'] = true;
|
|
1542
|
-
call.sendMediaStateMachineEvt(errorEvent);
|
|
1543
|
-
expect(funcSpy).toBeCalledOnceWith(errorEvent.data);
|
|
1544
|
-
expect(warnSpy).not.toHaveBeenCalled();
|
|
1545
|
-
expect(stateMachineSpy).not.toHaveBeenCalled();
|
|
1546
|
-
case 11:
|
|
1547
|
-
case "end":
|
|
1548
|
-
return _context28.stop();
|
|
1549
|
-
}
|
|
1550
|
-
}, _callee28);
|
|
1551
|
-
})));
|
|
1552
|
-
it('ROAP ok retry-after during mid call', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee29() {
|
|
1553
|
-
var statusPayload, funcSpy, stateMachineSpy, dummyEvent;
|
|
1554
|
-
return _regenerator.default.wrap(function _callee29$(_context29) {
|
|
1555
|
-
while (1) switch (_context29.prev = _context29.next) {
|
|
1556
|
-
case 0:
|
|
1557
|
-
statusPayload = {
|
|
1558
|
-
statusCode: 503,
|
|
1559
|
-
headers: {
|
|
1560
|
-
'retry-after': 1
|
|
1561
|
-
},
|
|
1562
|
-
body: mockStatusBody
|
|
1563
|
-
};
|
|
1564
|
-
jest.spyOn(global, 'setTimeout');
|
|
1565
|
-
funcSpy = jest.spyOn(call, 'postMedia').mockRejectedValueOnce(statusPayload);
|
|
1566
|
-
stateMachineSpy = jest.spyOn(call, 'sendMediaStateMachineEvt');
|
|
1567
|
-
dummyEvent = {
|
|
1568
|
-
type: 'E_ROAP_OK',
|
|
1569
|
-
data: {
|
|
1570
|
-
seq: 1,
|
|
1571
|
-
message: {},
|
|
1572
|
-
type: 'OK'
|
|
1573
|
-
}
|
|
1574
|
-
};
|
|
1575
|
-
call['connected'] = true;
|
|
1576
|
-
call['mediaStateMachine'].state.value = 'S_RECV_ROAP_ANSWER';
|
|
1577
|
-
_context29.next = 9;
|
|
1578
|
-
return call['handleRoapEstablished']({}, dummyEvent);
|
|
1579
|
-
case 9:
|
|
1580
|
-
jest.advanceTimersByTime(1005);
|
|
1581
|
-
expect(setTimeout).toHaveBeenCalledTimes(1);
|
|
1582
|
-
expect(funcSpy).toHaveBeenCalled();
|
|
1583
|
-
|
|
1584
|
-
/* first failure , and second because of retry-after */
|
|
1585
|
-
expect(funcSpy).toHaveBeenCalledTimes(2);
|
|
1586
|
-
expect(stateMachineSpy).toBeCalledOnceWith(dummyEvent);
|
|
1587
|
-
case 14:
|
|
1588
|
-
case "end":
|
|
1589
|
-
return _context29.stop();
|
|
1590
|
-
}
|
|
1591
|
-
}, _callee29);
|
|
1592
|
-
})));
|
|
1593
|
-
it('Unable to communicate roap error with mobius', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee30() {
|
|
1594
|
-
var statusPayload, stateMachineSpy, funcSpy, errorEvent;
|
|
1595
|
-
return _regenerator.default.wrap(function _callee30$(_context30) {
|
|
1596
|
-
while (1) switch (_context30.prev = _context30.next) {
|
|
1597
|
-
case 0:
|
|
1598
|
-
statusPayload = {
|
|
1599
|
-
statusCode: 403,
|
|
1600
|
-
body: mockStatusBody
|
|
1601
|
-
};
|
|
1602
|
-
stateMachineSpy = jest.spyOn(call, 'sendCallStateMachineEvt');
|
|
1603
|
-
funcSpy = jest.spyOn(call, 'postMedia').mockRejectedValue(statusPayload);
|
|
1604
|
-
errorEvent = {
|
|
1605
|
-
type: 'E_ROAP_ERROR',
|
|
1606
|
-
data: {
|
|
1607
|
-
seq: 2,
|
|
1608
|
-
messageType: 'ERROR',
|
|
1609
|
-
errorType: 'OUT_OF_ORDER'
|
|
1610
|
-
}
|
|
1611
|
-
};
|
|
1612
|
-
call['mediaStateMachine'].state.value = 'S_SEND_ROAP_ANSWER';
|
|
1613
|
-
call['connected'] = true;
|
|
1614
|
-
call.sendMediaStateMachineEvt(errorEvent);
|
|
1615
|
-
expect(funcSpy).toBeCalledOnceWith(errorEvent.data);
|
|
1616
|
-
expect(stateMachineSpy).not.toHaveBeenCalled();
|
|
1617
|
-
case 9:
|
|
1618
|
-
case "end":
|
|
1619
|
-
return _context30.stop();
|
|
1620
|
-
}
|
|
1621
|
-
}, _callee30);
|
|
1622
|
-
})));
|
|
1623
|
-
it('ROAP error during call establishment', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee31() {
|
|
1624
|
-
var statusPayload, warnSpy, stateMachineSpy, funcSpy, errorEvent;
|
|
1625
|
-
return _regenerator.default.wrap(function _callee31$(_context31) {
|
|
1626
|
-
while (1) switch (_context31.prev = _context31.next) {
|
|
1627
|
-
case 0:
|
|
1628
|
-
statusPayload = {
|
|
1629
|
-
statusCode: 200,
|
|
1630
|
-
body: mockStatusBody
|
|
1631
|
-
};
|
|
1632
|
-
warnSpy = jest.spyOn(_Logger.default, 'warn');
|
|
1633
|
-
stateMachineSpy = jest.spyOn(call, 'sendCallStateMachineEvt');
|
|
1634
|
-
funcSpy = jest.spyOn(call, 'postMedia').mockResolvedValue(statusPayload);
|
|
1635
|
-
errorEvent = {
|
|
1636
|
-
type: 'E_ROAP_ERROR',
|
|
1637
|
-
data: {
|
|
1638
|
-
seq: 2,
|
|
1639
|
-
messageType: 'ERROR',
|
|
1640
|
-
errorType: 'OUT_OF_ORDER'
|
|
1641
|
-
}
|
|
1642
|
-
};
|
|
1643
|
-
call['connected'] = false;
|
|
1644
|
-
_context31.next = 8;
|
|
1645
|
-
return call['handleRoapError']({}, errorEvent);
|
|
1646
|
-
case 8:
|
|
1647
|
-
expect(funcSpy).toBeCalledOnceWith(errorEvent.data);
|
|
1648
|
-
expect(warnSpy).toBeCalledOnceWith('Call failed due to media issue', {
|
|
1649
|
-
file: 'call',
|
|
1650
|
-
method: 'handleRoapError'
|
|
1651
|
-
});
|
|
1652
|
-
expect(stateMachineSpy).toBeCalledOnceWith({
|
|
1653
|
-
data: {
|
|
1654
|
-
media: true
|
|
1655
|
-
},
|
|
1656
|
-
type: 'E_UNKNOWN'
|
|
1657
|
-
});
|
|
1658
|
-
case 11:
|
|
1659
|
-
case "end":
|
|
1660
|
-
return _context31.stop();
|
|
1661
|
-
}
|
|
1662
|
-
}, _callee31);
|
|
1663
|
-
})));
|
|
1664
|
-
it('state changes during successful incoming call with out of order events', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee32() {
|
|
1665
|
-
var statusPayload, dummyEvent, postMediaSpy, dummyOkEvent, dummyOfferEvent;
|
|
1666
|
-
return _regenerator.default.wrap(function _callee32$(_context32) {
|
|
1667
|
-
while (1) switch (_context32.prev = _context32.next) {
|
|
1668
|
-
case 0:
|
|
1669
|
-
statusPayload = {
|
|
1670
|
-
statusCode: 200,
|
|
1671
|
-
body: mockStatusBody
|
|
1672
|
-
};
|
|
1673
|
-
dummyEvent = {
|
|
1674
|
-
type: 'E_RECV_CALL_SETUP',
|
|
1675
|
-
data: {
|
|
1676
|
-
seq: 1,
|
|
1677
|
-
messageType: 'OFFER'
|
|
1678
|
-
}
|
|
1679
|
-
};
|
|
1680
|
-
postMediaSpy = jest.spyOn(call, 'postMedia');
|
|
1681
|
-
webex.request.mockReturnValue(statusPayload);
|
|
1682
|
-
call['direction'] = _types3.CallDirection.INBOUND;
|
|
1683
|
-
call.sendCallStateMachineEvt(dummyEvent);
|
|
1684
|
-
expect(call['callStateMachine'].state.value).toBe('S_SEND_CALL_PROGRESS');
|
|
1685
|
-
dummyEvent.type = 'E_SEND_CALL_CONNECT';
|
|
1686
|
-
call.sendCallStateMachineEvt(dummyEvent);
|
|
1687
|
-
expect(call['callStateMachine'].state.value).toBe('S_SEND_CALL_CONNECT');
|
|
1688
|
-
|
|
1689
|
-
/* we should expect to forward the roap offer message to mediaSdk for further processing */
|
|
1690
|
-
dummyEvent.type = 'E_RECV_ROAP_OFFER';
|
|
1691
|
-
call.sendMediaStateMachineEvt(dummyEvent);
|
|
1692
|
-
expect(_testUtil.mediaConnection.roapMessageReceived).toHaveBeenLastCalledWith(dummyEvent.data);
|
|
1693
|
-
|
|
1694
|
-
/* expect sending roap answer to mobius */
|
|
1695
|
-
dummyEvent.type = 'E_SEND_ROAP_ANSWER';
|
|
1696
|
-
dummyEvent.data = {
|
|
1697
|
-
seq: 1,
|
|
1698
|
-
messageType: 'ANSWER'
|
|
1699
|
-
};
|
|
1700
|
-
_context32.next = 17;
|
|
1701
|
-
return call.sendMediaStateMachineEvt(dummyEvent);
|
|
1702
|
-
case 17:
|
|
1703
|
-
expect(postMediaSpy).toBeCalledOnceWith(dummyEvent.data);
|
|
1704
|
-
|
|
1705
|
-
/* we receive roap Offer Request followed by roap Ok from mobius and handle
|
|
1706
|
-
out of order events by buffering and processing them in sequence */
|
|
1707
|
-
dummyOkEvent = {
|
|
1708
|
-
type: 'E_ROAP_OK',
|
|
1709
|
-
data: {
|
|
1710
|
-
received: true,
|
|
1711
|
-
message: {
|
|
1712
|
-
seq: 1,
|
|
1713
|
-
messageType: 'OK'
|
|
1714
|
-
}
|
|
1715
|
-
}
|
|
1716
|
-
};
|
|
1717
|
-
dummyEvent.type = 'E_RECV_ROAP_OFFER_REQUEST';
|
|
1718
|
-
dummyEvent.data = {
|
|
1719
|
-
seq: 2,
|
|
1720
|
-
messageType: 'OFFER_REQUEST'
|
|
1721
|
-
};
|
|
1722
|
-
_context32.next = 23;
|
|
1723
|
-
return call.sendMediaStateMachineEvt(dummyEvent);
|
|
1724
|
-
case 23:
|
|
1725
|
-
expect(call['receivedRoapOKSeq']).toBe(0);
|
|
1726
|
-
expect(_testUtil.mediaConnection.roapMessageReceived).not.toHaveBeenLastCalledWith(dummyEvent.data);
|
|
1727
|
-
call.sendMediaStateMachineEvt(dummyOkEvent);
|
|
1728
|
-
expect(_testUtil.mediaConnection.roapMessageReceived).toHaveBeenNthCalledWith(2, dummyOkEvent.data.message);
|
|
1729
|
-
expect(_testUtil.mediaConnection.roapMessageReceived).toHaveBeenLastCalledWith(dummyEvent.data);
|
|
1730
|
-
dummyOfferEvent = {
|
|
1731
|
-
type: 'E_SEND_ROAP_OFFER',
|
|
1732
|
-
data: {
|
|
1733
|
-
seq: 2,
|
|
1734
|
-
messageType: 'OFFER',
|
|
1735
|
-
sdp: 'sdp'
|
|
1736
|
-
}
|
|
1737
|
-
};
|
|
1738
|
-
expect(call['mediaStateMachine'].state.value).toBe('S_RECV_ROAP_OFFER_REQUEST');
|
|
1739
|
-
call.sendMediaStateMachineEvt(dummyOfferEvent);
|
|
1740
|
-
expect(postMediaSpy).toHaveBeenLastCalledWith(dummyOfferEvent.data);
|
|
1741
|
-
dummyEvent.type = 'E_RECV_ROAP_ANSWER';
|
|
1742
|
-
dummyEvent.data = {
|
|
1743
|
-
seq: 2,
|
|
1744
|
-
messageType: 'ANSWER'
|
|
1745
|
-
};
|
|
1746
|
-
call.sendMediaStateMachineEvt(dummyEvent);
|
|
1747
|
-
expect(_testUtil.mediaConnection.roapMessageReceived).toHaveBeenLastCalledWith(dummyEvent.data);
|
|
1748
|
-
dummyOkEvent.data = {
|
|
1749
|
-
received: false,
|
|
1750
|
-
message: {
|
|
1751
|
-
seq: 2,
|
|
1752
|
-
messageType: 'OK'
|
|
1753
|
-
}
|
|
1754
|
-
};
|
|
1755
|
-
call.sendMediaStateMachineEvt(dummyOkEvent);
|
|
1756
|
-
expect(postMediaSpy).toHaveBeenLastCalledWith(dummyOkEvent.data.message);
|
|
1757
|
-
|
|
1758
|
-
/* With the two roap offer/answer transactions that we simulated earlier
|
|
1759
|
-
we get a total 4 outgoing and 3 incoming roap messages.
|
|
1760
|
-
*/
|
|
1761
|
-
expect(postMediaSpy).toBeCalledTimes(3);
|
|
1762
|
-
expect(_testUtil.mediaConnection.roapMessageReceived).toBeCalledTimes(4);
|
|
1763
|
-
expect(call['callStateMachine'].state.value).toBe('S_CALL_ESTABLISHED');
|
|
1764
|
-
expect(call.isConnected()).toBe(true);
|
|
1765
|
-
dummyEvent.type = 'E_CALL_HOLD';
|
|
1766
|
-
dummyEvent.data = {
|
|
1767
|
-
seq: 3,
|
|
1768
|
-
messageType: 'OFFER'
|
|
1769
|
-
};
|
|
1770
|
-
call.sendCallStateMachineEvt(dummyEvent);
|
|
1771
|
-
dummyEvent.type = 'E_RECV_ROAP_OFFER';
|
|
1772
|
-
_context32.next = 49;
|
|
1773
|
-
return call.sendMediaStateMachineEvt(dummyEvent);
|
|
1774
|
-
case 49:
|
|
1775
|
-
expect(_testUtil.mediaConnection.roapMessageReceived).toHaveBeenLastCalledWith(dummyEvent.data);
|
|
1776
|
-
dummyEvent.type = 'E_SEND_ROAP_ANSWER';
|
|
1777
|
-
dummyEvent.data = {
|
|
1778
|
-
seq: 3,
|
|
1779
|
-
messageType: 'ANSWER'
|
|
1780
|
-
};
|
|
1781
|
-
_context32.next = 54;
|
|
1782
|
-
return call.sendMediaStateMachineEvt(dummyEvent);
|
|
1783
|
-
case 54:
|
|
1784
|
-
expect(postMediaSpy).toHaveBeenLastCalledWith(dummyEvent.data);
|
|
1785
|
-
dummyEvent.type = 'E_RECV_ROAP_OFFER';
|
|
1786
|
-
dummyEvent.data = {
|
|
1787
|
-
seq: 4,
|
|
1788
|
-
messageType: 'OFFER'
|
|
1789
|
-
};
|
|
1790
|
-
call.sendMediaStateMachineEvt(dummyEvent);
|
|
1791
|
-
expect(call['receivedRoapOKSeq']).toBe(2);
|
|
1792
|
-
expect(_testUtil.mediaConnection.roapMessageReceived).not.toHaveBeenLastCalledWith(dummyEvent.data);
|
|
1793
|
-
dummyOkEvent.data = {
|
|
1794
|
-
received: true,
|
|
1795
|
-
message: {
|
|
1796
|
-
seq: 3,
|
|
1797
|
-
messageType: 'OK'
|
|
1798
|
-
}
|
|
1799
|
-
};
|
|
1800
|
-
_context32.next = 63;
|
|
1801
|
-
return call.sendMediaStateMachineEvt(dummyOkEvent);
|
|
1802
|
-
case 63:
|
|
1803
|
-
expect(_testUtil.mediaConnection.roapMessageReceived).toHaveBeenNthCalledWith(6, dummyOkEvent.data.message);
|
|
1804
|
-
expect(_testUtil.mediaConnection.roapMessageReceived).toHaveBeenLastCalledWith(dummyEvent.data);
|
|
1805
|
-
dummyEvent.type = 'E_SEND_ROAP_ANSWER';
|
|
1806
|
-
dummyEvent.data = {
|
|
1807
|
-
seq: 4,
|
|
1808
|
-
messageType: 'ANSWER'
|
|
1809
|
-
};
|
|
1810
|
-
expect(call['mediaStateMachine'].state.value).toBe('S_RECV_ROAP_OFFER');
|
|
1811
|
-
call.sendMediaStateMachineEvt(dummyEvent);
|
|
1812
|
-
expect(postMediaSpy).toHaveBeenLastCalledWith(dummyEvent.data);
|
|
1813
|
-
case 70:
|
|
1814
|
-
case "end":
|
|
1815
|
-
return _context32.stop();
|
|
1816
|
-
}
|
|
1817
|
-
}, _callee32);
|
|
1818
|
-
})));
|
|
1819
|
-
it('successfully handles out of order events when ROAP OK is received while executing outgoingRoapAnswer', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee33() {
|
|
1820
|
-
var mockStatusBody, statusPayload, dummyEvent, postMediaSpy, dummyOkEvent, dummyOfferEvent;
|
|
1821
|
-
return _regenerator.default.wrap(function _callee33$(_context33) {
|
|
1822
|
-
while (1) switch (_context33.prev = _context33.next) {
|
|
1823
|
-
case 0:
|
|
1824
|
-
mockStatusBody = {
|
|
1825
|
-
device: {
|
|
1826
|
-
deviceId: '123e4567-e89b-12d3-a456-426614174000',
|
|
1827
|
-
correlationId: 'b5476d4c-f48b-475e-b4e2-994e24d14ca2'
|
|
1828
|
-
},
|
|
1829
|
-
callId: 'fcf86aa5-5539-4c9f-8b72-667786ae9b6c'
|
|
1830
|
-
};
|
|
1831
|
-
statusPayload = {
|
|
1832
|
-
statusCode: 200,
|
|
1833
|
-
body: mockStatusBody
|
|
1834
|
-
};
|
|
1835
|
-
dummyEvent = {
|
|
1836
|
-
type: 'E_RECV_CALL_SETUP',
|
|
1837
|
-
data: {
|
|
1838
|
-
seq: 1,
|
|
1839
|
-
messageType: 'OFFER'
|
|
1840
|
-
}
|
|
1841
|
-
};
|
|
1842
|
-
postMediaSpy = jest.spyOn(call, 'postMedia');
|
|
1843
|
-
webex.request.mockReturnValue(statusPayload);
|
|
1844
|
-
call['direction'] = _types3.CallDirection.INBOUND;
|
|
1845
|
-
call.sendCallStateMachineEvt(dummyEvent);
|
|
1846
|
-
expect(call['callStateMachine'].state.value).toBe('S_SEND_CALL_PROGRESS');
|
|
1847
|
-
dummyEvent.type = 'E_SEND_CALL_CONNECT';
|
|
1848
|
-
call.sendCallStateMachineEvt(dummyEvent);
|
|
1849
|
-
expect(call['callStateMachine'].state.value).toBe('S_SEND_CALL_CONNECT');
|
|
1850
|
-
|
|
1851
|
-
/* we should expect to forward the roap offer message to mediaSdk for further processing */
|
|
1852
|
-
dummyEvent.type = 'E_RECV_ROAP_OFFER';
|
|
1853
|
-
call.sendMediaStateMachineEvt(dummyEvent);
|
|
1854
|
-
expect(_testUtil.mediaConnection.roapMessageReceived).toHaveBeenLastCalledWith(dummyEvent.data);
|
|
1855
|
-
|
|
1856
|
-
/* expect sending roap answer to mobius */
|
|
1857
|
-
dummyEvent.type = 'E_SEND_ROAP_ANSWER';
|
|
1858
|
-
dummyEvent.data = {
|
|
1859
|
-
seq: 1,
|
|
1860
|
-
messageType: 'ANSWER'
|
|
1861
|
-
};
|
|
1862
|
-
_context33.next = 18;
|
|
1863
|
-
return call.sendMediaStateMachineEvt(dummyEvent);
|
|
1864
|
-
case 18:
|
|
1865
|
-
expect(postMediaSpy).toBeCalledOnceWith(dummyEvent.data);
|
|
1866
|
-
|
|
1867
|
-
/* we receive roap Offer Request followed by roap Ok from mobius and handle
|
|
1868
|
-
out of order events by buffering and processing them in sequence */
|
|
1869
|
-
dummyOkEvent = {
|
|
1870
|
-
type: 'E_ROAP_OK',
|
|
1871
|
-
data: {
|
|
1872
|
-
received: true,
|
|
1873
|
-
message: {
|
|
1874
|
-
seq: 1,
|
|
1875
|
-
messageType: 'OK'
|
|
1876
|
-
}
|
|
1877
|
-
}
|
|
1878
|
-
};
|
|
1879
|
-
dummyEvent.type = 'E_RECV_ROAP_OFFER_REQUEST';
|
|
1880
|
-
dummyEvent.data = {
|
|
1881
|
-
seq: 2,
|
|
1882
|
-
messageType: 'OFFER_REQUEST'
|
|
1883
|
-
};
|
|
1884
|
-
_context33.next = 24;
|
|
1885
|
-
return call.sendMediaStateMachineEvt(dummyEvent);
|
|
1886
|
-
case 24:
|
|
1887
|
-
expect(call['receivedRoapOKSeq']).toBe(0);
|
|
1888
|
-
expect(_testUtil.mediaConnection.roapMessageReceived).not.toHaveBeenLastCalledWith(dummyEvent.data);
|
|
1889
|
-
call.sendMediaStateMachineEvt(dummyOkEvent);
|
|
1890
|
-
expect(_testUtil.mediaConnection.roapMessageReceived).toHaveBeenNthCalledWith(2, dummyOkEvent.data.message);
|
|
1891
|
-
expect(_testUtil.mediaConnection.roapMessageReceived).toHaveBeenLastCalledWith(dummyEvent.data);
|
|
1892
|
-
dummyOfferEvent = {
|
|
1893
|
-
type: 'E_SEND_ROAP_OFFER',
|
|
1894
|
-
data: {
|
|
1895
|
-
seq: 2,
|
|
1896
|
-
messageType: 'OFFER',
|
|
1897
|
-
sdp: 'sdp'
|
|
1898
|
-
}
|
|
1899
|
-
};
|
|
1900
|
-
expect(call['mediaStateMachine'].state.value).toBe('S_RECV_ROAP_OFFER_REQUEST');
|
|
1901
|
-
call.sendMediaStateMachineEvt(dummyOfferEvent);
|
|
1902
|
-
expect(postMediaSpy).toHaveBeenLastCalledWith(dummyOfferEvent.data);
|
|
1903
|
-
dummyEvent.type = 'E_RECV_ROAP_ANSWER';
|
|
1904
|
-
dummyEvent.data = {
|
|
1905
|
-
seq: 2,
|
|
1906
|
-
messageType: 'ANSWER'
|
|
1907
|
-
};
|
|
1908
|
-
call.sendMediaStateMachineEvt(dummyEvent);
|
|
1909
|
-
expect(_testUtil.mediaConnection.roapMessageReceived).toHaveBeenLastCalledWith(dummyEvent.data);
|
|
1910
|
-
dummyOkEvent.data = {
|
|
1911
|
-
received: false,
|
|
1912
|
-
message: {
|
|
1913
|
-
seq: 2,
|
|
1914
|
-
messageType: 'OK'
|
|
1915
|
-
}
|
|
1916
|
-
};
|
|
1917
|
-
call.sendMediaStateMachineEvt(dummyOkEvent);
|
|
1918
|
-
expect(postMediaSpy).toHaveBeenLastCalledWith(dummyOkEvent.data.message);
|
|
1919
|
-
|
|
1920
|
-
/* With the two roap offer/answer transactions that we simulated earlier
|
|
1921
|
-
we get a total 4 outgoing and 3 incoming roap messages.
|
|
1922
|
-
*/
|
|
1923
|
-
expect(postMediaSpy).toBeCalledTimes(3);
|
|
1924
|
-
expect(_testUtil.mediaConnection.roapMessageReceived).toBeCalledTimes(4);
|
|
1925
|
-
expect(call['callStateMachine'].state.value).toBe('S_CALL_ESTABLISHED');
|
|
1926
|
-
expect(call.isConnected()).toBe(true);
|
|
1927
|
-
dummyEvent.type = 'E_CALL_HOLD';
|
|
1928
|
-
dummyEvent.data = {
|
|
1929
|
-
seq: 3,
|
|
1930
|
-
messageType: 'OFFER'
|
|
1931
|
-
};
|
|
1932
|
-
call.sendCallStateMachineEvt(dummyEvent);
|
|
1933
|
-
dummyEvent.type = 'E_RECV_ROAP_OFFER';
|
|
1934
|
-
_context33.next = 50;
|
|
1935
|
-
return call.sendMediaStateMachineEvt(dummyEvent);
|
|
1936
|
-
case 50:
|
|
1937
|
-
expect(_testUtil.mediaConnection.roapMessageReceived).toHaveBeenLastCalledWith(dummyEvent.data);
|
|
1938
|
-
dummyEvent.type = 'E_SEND_ROAP_ANSWER';
|
|
1939
|
-
dummyEvent.data = {
|
|
1940
|
-
seq: 3,
|
|
1941
|
-
messageType: 'ANSWER'
|
|
1942
|
-
};
|
|
1943
|
-
_context33.next = 55;
|
|
1944
|
-
return call.sendMediaStateMachineEvt(dummyEvent);
|
|
1945
|
-
case 55:
|
|
1946
|
-
expect(postMediaSpy).toHaveBeenLastCalledWith(dummyEvent.data);
|
|
1947
|
-
dummyEvent.type = 'E_RECV_ROAP_OFFER';
|
|
1948
|
-
dummyEvent.data = {
|
|
1949
|
-
seq: 4,
|
|
1950
|
-
messageType: 'OFFER'
|
|
1951
|
-
};
|
|
1952
|
-
dummyOkEvent.data = {
|
|
1953
|
-
received: true,
|
|
1954
|
-
message: {
|
|
1955
|
-
seq: 3,
|
|
1956
|
-
messageType: 'OK'
|
|
1957
|
-
}
|
|
1958
|
-
};
|
|
1959
|
-
call.sendMediaStateMachineEvt(dummyEvent);
|
|
1960
|
-
_context33.next = 62;
|
|
1961
|
-
return call.sendMediaStateMachineEvt(dummyOkEvent);
|
|
1962
|
-
case 62:
|
|
1963
|
-
expect(call['receivedRoapOKSeq']).toBe(3);
|
|
1964
|
-
expect(_testUtil.mediaConnection.roapMessageReceived).toHaveBeenNthCalledWith(6, dummyOkEvent.data.message);
|
|
1965
|
-
expect(_testUtil.mediaConnection.roapMessageReceived).toHaveBeenLastCalledWith(dummyEvent.data);
|
|
1966
|
-
dummyEvent.type = 'E_SEND_ROAP_ANSWER';
|
|
1967
|
-
dummyEvent.data = {
|
|
1968
|
-
seq: 4,
|
|
1969
|
-
messageType: 'ANSWER'
|
|
1970
|
-
};
|
|
1971
|
-
expect(call['mediaStateMachine'].state.value).toBe('S_RECV_ROAP_OFFER');
|
|
1972
|
-
call.sendMediaStateMachineEvt(dummyEvent);
|
|
1973
|
-
expect(postMediaSpy).toHaveBeenLastCalledWith(dummyEvent.data);
|
|
1974
|
-
case 70:
|
|
1975
|
-
case "end":
|
|
1976
|
-
return _context33.stop();
|
|
1977
|
-
}
|
|
1978
|
-
}, _callee33);
|
|
1979
|
-
})));
|
|
1980
|
-
it('handle hold event successfully when media received after progress but before connect', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee34() {
|
|
1981
|
-
var statusPayload, dummyEvent, postMediaSpy, infoSpy, dummyOkEvent;
|
|
1982
|
-
return _regenerator.default.wrap(function _callee34$(_context34) {
|
|
1983
|
-
while (1) switch (_context34.prev = _context34.next) {
|
|
1984
|
-
case 0:
|
|
1985
|
-
statusPayload = {
|
|
1986
|
-
statusCode: 200,
|
|
1987
|
-
body: mockStatusBody
|
|
1988
|
-
};
|
|
1989
|
-
dummyEvent = {
|
|
1990
|
-
type: 'E_SEND_CALL_SETUP',
|
|
1991
|
-
data: {
|
|
1992
|
-
seq: 1,
|
|
1993
|
-
messageType: 'OFFER',
|
|
1994
|
-
sdp: 'sdp'
|
|
1995
|
-
}
|
|
1996
|
-
};
|
|
1997
|
-
postMediaSpy = jest.spyOn(call, 'postMedia');
|
|
1998
|
-
infoSpy = jest.spyOn(_Logger.default, 'info');
|
|
1999
|
-
webex.request.mockReturnValue(statusPayload);
|
|
2000
|
-
call.sendCallStateMachineEvt(dummyEvent);
|
|
2001
|
-
expect(call['callStateMachine'].state.value).toBe('S_SEND_CALL_SETUP');
|
|
2002
|
-
dummyEvent.type = 'E_SEND_ROAP_OFFER';
|
|
2003
|
-
call.sendMediaStateMachineEvt(dummyEvent);
|
|
2004
|
-
expect(postMediaSpy).toHaveBeenLastCalledWith(dummyEvent.data);
|
|
2005
|
-
dummyEvent.type = 'E_RECV_CALL_PROGRESS';
|
|
2006
|
-
dummyEvent.data = undefined;
|
|
2007
|
-
call.sendCallStateMachineEvt(dummyEvent);
|
|
2008
|
-
expect(call['callStateMachine'].state.value).toBe('S_RECV_CALL_PROGRESS');
|
|
2009
|
-
dummyEvent.type = 'E_RECV_ROAP_ANSWER';
|
|
2010
|
-
dummyEvent.data = {
|
|
2011
|
-
seq: 1,
|
|
2012
|
-
messageType: 'ANSWER',
|
|
2013
|
-
sdp: 'sdp'
|
|
2014
|
-
};
|
|
2015
|
-
call.sendMediaStateMachineEvt(dummyEvent);
|
|
2016
|
-
expect(_testUtil.mediaConnection.roapMessageReceived).toHaveBeenLastCalledWith(dummyEvent.data);
|
|
2017
|
-
expect(call['mediaNegotiationCompleted']).toBe(false);
|
|
2018
|
-
dummyOkEvent = {
|
|
2019
|
-
type: 'E_ROAP_OK',
|
|
2020
|
-
data: {
|
|
2021
|
-
received: false,
|
|
2022
|
-
message: {
|
|
2023
|
-
seq: 1,
|
|
2024
|
-
messageType: 'OK'
|
|
2025
|
-
}
|
|
2026
|
-
}
|
|
2027
|
-
};
|
|
2028
|
-
call.sendMediaStateMachineEvt(dummyOkEvent);
|
|
2029
|
-
expect(call['mediaNegotiationCompleted']).toBe(true);
|
|
2030
|
-
expect(postMediaSpy).toHaveBeenLastCalledWith(dummyOkEvent.data.message);
|
|
2031
|
-
dummyEvent.type = 'E_RECV_CALL_CONNECT';
|
|
2032
|
-
dummyEvent.data = undefined;
|
|
2033
|
-
call.sendCallStateMachineEvt(dummyEvent);
|
|
2034
|
-
|
|
2035
|
-
/* Call will move to connect state then immediately move to established state as
|
|
2036
|
-
media negotiation is already completed before connect was received
|
|
2037
|
-
*/
|
|
2038
|
-
expect(call['callStateMachine'].state.value).toBe('S_CALL_ESTABLISHED');
|
|
2039
|
-
expect(call.isConnected()).toBe(true);
|
|
2040
|
-
dummyEvent.type = 'E_CALL_HOLD';
|
|
2041
|
-
dummyEvent.data = undefined;
|
|
2042
|
-
call.sendCallStateMachineEvt(dummyEvent);
|
|
2043
|
-
expect(call['callStateMachine'].state.value).toBe('S_CALL_HOLD');
|
|
2044
|
-
expect(infoSpy).toHaveBeenLastCalledWith("".concat(_constants2.METHOD_START_MESSAGE, " with: ").concat(call.getCorrelationId()), {
|
|
2045
|
-
file: 'call',
|
|
2046
|
-
method: 'handleCallHold'
|
|
2047
|
-
});
|
|
2048
|
-
case 33:
|
|
2049
|
-
case "end":
|
|
2050
|
-
return _context34.stop();
|
|
2051
|
-
}
|
|
2052
|
-
}, _callee34);
|
|
2053
|
-
})));
|
|
2054
|
-
describe('Call event timers tests', function () {
|
|
2055
|
-
var callManager;
|
|
2056
|
-
beforeEach(function () {
|
|
2057
|
-
jest.useFakeTimers();
|
|
2058
|
-
callManager = (0, _callManager.getCallManager)(webex, defaultServiceIndicator);
|
|
2059
|
-
});
|
|
2060
|
-
afterEach(function () {
|
|
2061
|
-
jest.clearAllTimers();
|
|
2062
|
-
});
|
|
2063
|
-
it('times out if the next event is not received - 60 seconds timeout', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee35() {
|
|
2064
|
-
var statusPayload, dummyEvent, logSpy, emitSpy, deleteSpy, dummyOkEvent;
|
|
2065
|
-
return _regenerator.default.wrap(function _callee35$(_context35) {
|
|
2066
|
-
while (1) switch (_context35.prev = _context35.next) {
|
|
2067
|
-
case 0:
|
|
2068
|
-
statusPayload = {
|
|
2069
|
-
statusCode: 200,
|
|
2070
|
-
body: mockStatusBody
|
|
2071
|
-
};
|
|
2072
|
-
dummyEvent = {
|
|
2073
|
-
type: 'E_SEND_CALL_SETUP',
|
|
2074
|
-
data: undefined
|
|
2075
|
-
};
|
|
2076
|
-
logSpy = jest.spyOn(_Logger.default, 'warn');
|
|
2077
|
-
emitSpy = jest.spyOn(call, 'emit');
|
|
2078
|
-
deleteSpy = jest.spyOn(call, 'delete');
|
|
2079
|
-
callManager.callCollection = {};
|
|
2080
|
-
webex.request.mockReturnValue(statusPayload);
|
|
2081
|
-
|
|
2082
|
-
// handleOutgoingCallSetup is asynchronous
|
|
2083
|
-
_context35.next = 9;
|
|
2084
|
-
return call.sendCallStateMachineEvt(dummyEvent);
|
|
2085
|
-
case 9:
|
|
2086
|
-
expect(call['callStateMachine'].state.value).toBe('S_SEND_CALL_SETUP');
|
|
2087
|
-
dummyEvent.type = 'E_RECV_CALL_PROGRESS';
|
|
2088
|
-
call.sendCallStateMachineEvt(dummyEvent);
|
|
2089
|
-
expect(call['callStateMachine'].state.value).toBe('S_RECV_CALL_PROGRESS');
|
|
2090
|
-
|
|
2091
|
-
// Media setup for the call
|
|
2092
|
-
dummyEvent.type = 'E_SEND_ROAP_OFFER';
|
|
2093
|
-
call.sendMediaStateMachineEvt(dummyEvent);
|
|
2094
|
-
dummyEvent.data = {
|
|
2095
|
-
seq: 1,
|
|
2096
|
-
messageType: 'OFFER',
|
|
2097
|
-
sdp: 'sdp'
|
|
2098
|
-
};
|
|
2099
|
-
call.sendMediaStateMachineEvt(dummyEvent);
|
|
2100
|
-
dummyEvent.type = 'E_RECV_ROAP_ANSWER';
|
|
2101
|
-
call.sendMediaStateMachineEvt(dummyEvent);
|
|
2102
|
-
dummyOkEvent = {
|
|
2103
|
-
type: 'E_ROAP_OK',
|
|
2104
|
-
data: {
|
|
2105
|
-
received: false,
|
|
2106
|
-
message: {
|
|
2107
|
-
seq: 1,
|
|
2108
|
-
messageType: 'OK'
|
|
2109
|
-
}
|
|
2110
|
-
}
|
|
2111
|
-
};
|
|
2112
|
-
call.sendMediaStateMachineEvt(dummyOkEvent);
|
|
2113
|
-
dummyEvent.type = 'E_RECV_ROAP_OFFER_REQUEST';
|
|
2114
|
-
call.sendMediaStateMachineEvt(dummyEvent);
|
|
2115
|
-
dummyEvent.type = 'E_SEND_ROAP_OFFER';
|
|
2116
|
-
call.sendMediaStateMachineEvt(dummyEvent);
|
|
2117
|
-
dummyEvent.type = 'E_RECV_ROAP_ANSWER';
|
|
2118
|
-
logSpy.mockClear();
|
|
2119
|
-
jest.advanceTimersByTime(60000);
|
|
2120
|
-
expect(logSpy.mock.calls[0][0]).toBe('Call timed out');
|
|
2121
|
-
expect(emitSpy).toHaveBeenCalledWith(_types2.CALL_EVENT_KEYS.DISCONNECT, call.getCorrelationId());
|
|
2122
|
-
expect(deleteSpy).toHaveBeenCalledTimes(1);
|
|
2123
|
-
expect(callManager.callCollection).toStrictEqual({});
|
|
2124
|
-
case 32:
|
|
2125
|
-
case "end":
|
|
2126
|
-
return _context35.stop();
|
|
2127
|
-
}
|
|
2128
|
-
}, _callee35);
|
|
2129
|
-
})));
|
|
2130
|
-
it('times out if the next event is not received - 10 seconds timeout', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee36() {
|
|
2131
|
-
var statusPayload, dummyEvent, call, emitSpy, deleteSpy, logSpy;
|
|
2132
|
-
return _regenerator.default.wrap(function _callee36$(_context36) {
|
|
2133
|
-
while (1) switch (_context36.prev = _context36.next) {
|
|
2134
|
-
case 0:
|
|
2135
|
-
statusPayload = {
|
|
2136
|
-
statusCode: 200,
|
|
2137
|
-
body: mockStatusBody
|
|
2138
|
-
};
|
|
2139
|
-
dummyEvent = {
|
|
2140
|
-
type: 'E_SEND_CALL_SETUP',
|
|
2141
|
-
data: undefined
|
|
2142
|
-
};
|
|
2143
|
-
callManager.callCollection = {};
|
|
2144
|
-
call = callManager.createCall(dest, _types3.CallDirection.OUTBOUND, deviceId, mockLineId);
|
|
2145
|
-
emitSpy = jest.spyOn(call, 'emit');
|
|
2146
|
-
deleteSpy = jest.spyOn(call, 'delete');
|
|
2147
|
-
logSpy = jest.spyOn(_Logger.default, 'warn');
|
|
2148
|
-
webex.request.mockReturnValue(statusPayload);
|
|
2149
|
-
expect((0, _keys.default)(callManager.callCollection)[0]).toBe(call.getCorrelationId());
|
|
2150
|
-
|
|
2151
|
-
// handleOutgoingCallSetup is asynchronous
|
|
2152
|
-
_context36.next = 11;
|
|
2153
|
-
return call.sendCallStateMachineEvt(dummyEvent);
|
|
2154
|
-
case 11:
|
|
2155
|
-
expect(call['callStateMachine'].state.value).toBe('S_SEND_CALL_SETUP');
|
|
2156
|
-
logSpy.mockClear();
|
|
2157
|
-
jest.advanceTimersByTime(10000);
|
|
2158
|
-
expect(logSpy.mock.calls[0][0]).toBe('Call timed out');
|
|
2159
|
-
expect(emitSpy).toHaveBeenCalledWith(_types2.CALL_EVENT_KEYS.DISCONNECT, call.getCorrelationId());
|
|
2160
|
-
expect(deleteSpy).toHaveBeenCalledTimes(1);
|
|
2161
|
-
expect(callManager.callCollection).toStrictEqual({});
|
|
2162
|
-
case 18:
|
|
2163
|
-
case "end":
|
|
2164
|
-
return _context36.stop();
|
|
2165
|
-
}
|
|
2166
|
-
}, _callee36);
|
|
2167
|
-
})));
|
|
2168
|
-
});
|
|
2169
|
-
});
|
|
2170
|
-
describe('Supplementary Services tests', function () {
|
|
2171
|
-
var deviceId = '55dfb53f-bed2-36da-8e85-cee7f02aa68e';
|
|
2172
|
-
var dest = {
|
|
2173
|
-
type: _types3.CallType.URI,
|
|
2174
|
-
address: 'tel:5003'
|
|
2175
|
-
};
|
|
2176
|
-
var mockResponseBody = {
|
|
2177
|
-
device: {
|
|
2178
|
-
deviceId: '123e4567-e89b-12d3-a456-426614174000',
|
|
2179
|
-
correlationId: 'b5476d4c-f48b-475e-b4e2-994e24d14ca2'
|
|
2180
|
-
},
|
|
2181
|
-
callId: 'fcf86aa5-5539-4c9f-8b72-667786ae9b6c'
|
|
2182
|
-
};
|
|
2183
|
-
var call;
|
|
2184
|
-
beforeEach(function () {
|
|
2185
|
-
/* Since we are not actually testing from the start of a call , so it's good to set the below
|
|
2186
|
-
* parameters manually
|
|
2187
|
-
*/
|
|
2188
|
-
|
|
2189
|
-
call = new _call.Call(activeUrl, webex, _types3.CallDirection.OUTBOUND, deviceId, mockLineId, function () {
|
|
2190
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2191
|
-
var dummy = 10;
|
|
2192
|
-
}, defaultServiceIndicator, dest);
|
|
2193
|
-
call['connected'] = true;
|
|
2194
|
-
call['earlyMedia'] = false;
|
|
2195
|
-
|
|
2196
|
-
/* Also supplementary services will start always from Call_Established state */
|
|
2197
|
-
call['callStateMachine'].state.value = 'S_CALL_ESTABLISHED';
|
|
2198
|
-
call.removeAllListeners(_types2.CALL_EVENT_KEYS.CALL_ERROR);
|
|
2199
|
-
jest.clearAllTimers();
|
|
2200
|
-
jest.useFakeTimers();
|
|
2201
|
-
});
|
|
2202
|
-
describe('Call hold-resume tests', function () {
|
|
2203
|
-
var mockHeldEvent = {
|
|
2204
|
-
eventType: 'callState',
|
|
2205
|
-
eventData: {
|
|
2206
|
-
callState: 'HELD'
|
|
2207
|
-
}
|
|
2208
|
-
};
|
|
2209
|
-
var mockResumeEvent = {
|
|
2210
|
-
eventType: 'callState',
|
|
2211
|
-
eventData: {
|
|
2212
|
-
callState: 'CONNECTED'
|
|
2213
|
-
}
|
|
2214
|
-
};
|
|
2215
|
-
var dummyEvent = {
|
|
2216
|
-
type: 'E_SEND_ROAP_OFFER',
|
|
2217
|
-
data: {
|
|
2218
|
-
seq: 1,
|
|
2219
|
-
message: {},
|
|
2220
|
-
type: 'OFFER'
|
|
2221
|
-
}
|
|
2222
|
-
};
|
|
2223
|
-
beforeEach(function () {
|
|
2224
|
-
call.removeAllListeners();
|
|
2225
|
-
});
|
|
2226
|
-
it('Handle successful Call hold case without delayed http response', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee38() {
|
|
2227
|
-
var responsePayload, warnSpy, roapEvent;
|
|
2228
|
-
return _regenerator.default.wrap(function _callee38$(_context38) {
|
|
2229
|
-
while (1) switch (_context38.prev = _context38.next) {
|
|
2230
|
-
case 0:
|
|
2231
|
-
expect.assertions(7);
|
|
2232
|
-
responsePayload = {
|
|
2233
|
-
statusCode: 200,
|
|
2234
|
-
body: mockResponseBody
|
|
2235
|
-
};
|
|
2236
|
-
jest.spyOn(webex, 'request').mockResolvedValue(responsePayload);
|
|
2237
|
-
jest.spyOn(global, 'setTimeout');
|
|
2238
|
-
jest.spyOn(global, 'clearTimeout');
|
|
2239
|
-
warnSpy = jest.spyOn(_Logger.default, 'warn');
|
|
2240
|
-
call['held'] = false;
|
|
2241
|
-
call.on(_types2.CALL_EVENT_KEYS.HELD, /*#__PURE__*/function () {
|
|
2242
|
-
var _ref38 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee37(correlationId) {
|
|
2243
|
-
return _regenerator.default.wrap(function _callee37$(_context37) {
|
|
2244
|
-
while (1) switch (_context37.prev = _context37.next) {
|
|
2245
|
-
case 0:
|
|
2246
|
-
expect(correlationId).toStrictEqual(call.getCorrelationId());
|
|
2247
|
-
case 1:
|
|
2248
|
-
case "end":
|
|
2249
|
-
return _context37.stop();
|
|
2250
|
-
}
|
|
2251
|
-
}, _callee37);
|
|
2252
|
-
}));
|
|
2253
|
-
return function (_x) {
|
|
2254
|
-
return _ref38.apply(this, arguments);
|
|
2255
|
-
};
|
|
2256
|
-
}());
|
|
2257
|
-
_context38.next = 10;
|
|
2258
|
-
return call.doHoldResume();
|
|
2259
|
-
case 10:
|
|
2260
|
-
_context38.next = 12;
|
|
2261
|
-
return (0, _testUtil.flushPromises)(2);
|
|
2262
|
-
case 12:
|
|
2263
|
-
expect(setTimeout).toHaveBeenCalledTimes(1);
|
|
2264
|
-
call.handleMidCallEvent(mockHeldEvent);
|
|
2265
|
-
|
|
2266
|
-
/* At this point, the Call State should be S_CALL_HOLD
|
|
2267
|
-
*/
|
|
2268
|
-
expect(call['callStateMachine'].state.value).toStrictEqual('S_CALL_HOLD');
|
|
2269
|
-
|
|
2270
|
-
/* We simulate the media Connection events manually here as we are not really testing with actual
|
|
2271
|
-
* media.
|
|
2272
|
-
*/
|
|
2273
|
-
call['handleIncomingRoapOffer']({}, dummyEvent);
|
|
2274
|
-
roapEvent = JSON.parse((0, _stringify.default)(dummyEvent));
|
|
2275
|
-
roapEvent.data.type = 'ANSWER';
|
|
2276
|
-
_context38.next = 20;
|
|
2277
|
-
return call['handleOutgoingRoapAnswer']({}, dummyEvent);
|
|
2278
|
-
case 20:
|
|
2279
|
-
roapEvent.data.type = 'OK';
|
|
2280
|
-
_context38.next = 23;
|
|
2281
|
-
return call['handleRoapEstablished']({}, dummyEvent);
|
|
2282
|
-
case 23:
|
|
2283
|
-
expect(clearTimeout).toHaveBeenCalledTimes(1);
|
|
2284
|
-
/* isHeld flag should be set and an Hold event should be emitted */
|
|
2285
|
-
expect(call.isHeld()).toStrictEqual(true);
|
|
2286
|
-
/* We should return back to call established state */
|
|
2287
|
-
expect(call['callStateMachine'].state.value).toStrictEqual('S_CALL_ESTABLISHED');
|
|
2288
|
-
jest.advanceTimersByTime(12000);
|
|
2289
|
-
expect(warnSpy).not.toHaveBeenCalledWith('Hold response timed out', {
|
|
2290
|
-
file: 'call',
|
|
2291
|
-
method: 'handleCallHold'
|
|
2292
|
-
});
|
|
2293
|
-
case 28:
|
|
2294
|
-
case "end":
|
|
2295
|
-
return _context38.stop();
|
|
2296
|
-
}
|
|
2297
|
-
}, _callee38);
|
|
2298
|
-
})));
|
|
2299
|
-
it('Handle successful Call hold case with delayed http response', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee40() {
|
|
2300
|
-
var responsePayload, warnSpy, roapEvent;
|
|
2301
|
-
return _regenerator.default.wrap(function _callee40$(_context40) {
|
|
2302
|
-
while (1) switch (_context40.prev = _context40.next) {
|
|
2303
|
-
case 0:
|
|
2304
|
-
expect.assertions(8);
|
|
2305
|
-
responsePayload = {
|
|
2306
|
-
statusCode: 200,
|
|
2307
|
-
body: mockResponseBody
|
|
2308
|
-
};
|
|
2309
|
-
jest.spyOn(webex, 'request').mockResolvedValue(responsePayload);
|
|
2310
|
-
jest.spyOn(global, 'setTimeout');
|
|
2311
|
-
jest.spyOn(global, 'clearTimeout');
|
|
2312
|
-
warnSpy = jest.spyOn(_Logger.default, 'warn');
|
|
2313
|
-
call['held'] = false;
|
|
2314
|
-
call.on(_types2.CALL_EVENT_KEYS.HELD, /*#__PURE__*/function () {
|
|
2315
|
-
var _ref40 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee39(correlationId) {
|
|
2316
|
-
return _regenerator.default.wrap(function _callee39$(_context39) {
|
|
2317
|
-
while (1) switch (_context39.prev = _context39.next) {
|
|
2318
|
-
case 0:
|
|
2319
|
-
expect(correlationId).toStrictEqual(call.getCorrelationId());
|
|
2320
|
-
case 1:
|
|
2321
|
-
case "end":
|
|
2322
|
-
return _context39.stop();
|
|
2323
|
-
}
|
|
2324
|
-
}, _callee39);
|
|
2325
|
-
}));
|
|
2326
|
-
return function (_x2) {
|
|
2327
|
-
return _ref40.apply(this, arguments);
|
|
2328
|
-
};
|
|
2329
|
-
}());
|
|
2330
|
-
call.doHoldResume();
|
|
2331
|
-
_context40.next = 11;
|
|
2332
|
-
return _promise.default.resolve();
|
|
2333
|
-
case 11:
|
|
2334
|
-
_context40.next = 13;
|
|
2335
|
-
return _promise.default.resolve();
|
|
2336
|
-
case 13:
|
|
2337
|
-
expect(setTimeout).not.toHaveBeenCalled();
|
|
2338
|
-
call.handleMidCallEvent(mockHeldEvent);
|
|
2339
|
-
|
|
2340
|
-
/* At this point, the Call State should be S_CALL_HOLD
|
|
2341
|
-
*/
|
|
2342
|
-
expect(call['callStateMachine'].state.value).toStrictEqual('S_CALL_HOLD');
|
|
2343
|
-
expect(call.isHeld()).toBe(true);
|
|
2344
|
-
/* We simulate the media Connection events manually here as we are not really testing with actual
|
|
2345
|
-
* media.
|
|
2346
|
-
*/
|
|
2347
|
-
call['handleIncomingRoapOffer']({}, dummyEvent);
|
|
2348
|
-
roapEvent = JSON.parse((0, _stringify.default)(dummyEvent));
|
|
2349
|
-
roapEvent.data.type = 'ANSWER';
|
|
2350
|
-
_context40.next = 22;
|
|
2351
|
-
return call['handleOutgoingRoapAnswer']({}, dummyEvent);
|
|
2352
|
-
case 22:
|
|
2353
|
-
roapEvent.data.type = 'OK';
|
|
2354
|
-
_context40.next = 25;
|
|
2355
|
-
return call['handleRoapEstablished']({}, dummyEvent);
|
|
2356
|
-
case 25:
|
|
2357
|
-
expect(clearTimeout).not.toHaveBeenCalled();
|
|
2358
|
-
/* isHeld flag should be set and an Hold event should be emitted */
|
|
2359
|
-
expect(call.isHeld()).toStrictEqual(true);
|
|
2360
|
-
/* We should return back to call established state */
|
|
2361
|
-
expect(call['callStateMachine'].state.value).toStrictEqual('S_CALL_ESTABLISHED');
|
|
2362
|
-
jest.advanceTimersByTime(12000);
|
|
2363
|
-
expect(warnSpy).not.toHaveBeenCalledWith('Hold response timed out', {
|
|
2364
|
-
file: 'call',
|
|
2365
|
-
method: 'handleCallHold'
|
|
2366
|
-
});
|
|
2367
|
-
case 30:
|
|
2368
|
-
case "end":
|
|
2369
|
-
return _context40.stop();
|
|
2370
|
-
}
|
|
2371
|
-
}, _callee40);
|
|
2372
|
-
})));
|
|
2373
|
-
it('Handle failure Call Hold case during signalling', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee42() {
|
|
2374
|
-
var responsePayload;
|
|
2375
|
-
return _regenerator.default.wrap(function _callee42$(_context42) {
|
|
2376
|
-
while (1) switch (_context42.prev = _context42.next) {
|
|
2377
|
-
case 0:
|
|
2378
|
-
expect.assertions(4);
|
|
2379
|
-
responsePayload = {
|
|
2380
|
-
statusCode: 503,
|
|
2381
|
-
body: mockResponseBody
|
|
2382
|
-
};
|
|
2383
|
-
jest.spyOn(webex, 'request').mockRejectedValue(responsePayload);
|
|
2384
|
-
call['held'] = false;
|
|
2385
|
-
call.on(_types2.CALL_EVENT_KEYS.HOLD_ERROR, /*#__PURE__*/function () {
|
|
2386
|
-
var _ref42 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee41(errObj) {
|
|
2387
|
-
return _regenerator.default.wrap(function _callee41$(_context41) {
|
|
2388
|
-
while (1) switch (_context41.prev = _context41.next) {
|
|
2389
|
-
case 0:
|
|
2390
|
-
expect(errObj.type).toStrictEqual(_types.ERROR_TYPE.SERVICE_UNAVAILABLE);
|
|
2391
|
-
expect(errObj.message).toStrictEqual('An unknown error occurred. Wait a moment and try again.');
|
|
2392
|
-
case 2:
|
|
2393
|
-
case "end":
|
|
2394
|
-
return _context41.stop();
|
|
2395
|
-
}
|
|
2396
|
-
}, _callee41);
|
|
2397
|
-
}));
|
|
2398
|
-
return function (_x3) {
|
|
2399
|
-
return _ref42.apply(this, arguments);
|
|
2400
|
-
};
|
|
2401
|
-
}());
|
|
2402
|
-
_context42.next = 7;
|
|
2403
|
-
return call.doHoldResume();
|
|
2404
|
-
case 7:
|
|
2405
|
-
_context42.next = 9;
|
|
2406
|
-
return (0, _testUtil.flushPromises)(2);
|
|
2407
|
-
case 9:
|
|
2408
|
-
expect(call.isHeld()).toStrictEqual(false);
|
|
2409
|
-
|
|
2410
|
-
/* At this point , the Call State should transition to S_CALL_ESTABLISHED
|
|
2411
|
-
*/
|
|
2412
|
-
expect(call['callStateMachine'].state.value).toStrictEqual('S_CALL_ESTABLISHED');
|
|
2413
|
-
case 11:
|
|
2414
|
-
case "end":
|
|
2415
|
-
return _context42.stop();
|
|
2416
|
-
}
|
|
2417
|
-
}, _callee42);
|
|
2418
|
-
})));
|
|
2419
|
-
it('Handle failure Call Hold case during offer/answer exchange', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee44() {
|
|
2420
|
-
var responsePayload, rejectPayload, roapEvent;
|
|
2421
|
-
return _regenerator.default.wrap(function _callee44$(_context44) {
|
|
2422
|
-
while (1) switch (_context44.prev = _context44.next) {
|
|
2423
|
-
case 0:
|
|
2424
|
-
expect.assertions(5);
|
|
2425
|
-
responsePayload = {
|
|
2426
|
-
statusCode: 200,
|
|
2427
|
-
body: mockResponseBody
|
|
2428
|
-
};
|
|
2429
|
-
rejectPayload = {
|
|
2430
|
-
statusCode: 503,
|
|
2431
|
-
body: mockResponseBody
|
|
2432
|
-
};
|
|
2433
|
-
jest.spyOn(webex, 'request').mockResolvedValueOnce(responsePayload).mockRejectedValueOnce(rejectPayload);
|
|
2434
|
-
call['held'] = false;
|
|
2435
|
-
call.on(_types2.CALL_EVENT_KEYS.HOLD_ERROR, /*#__PURE__*/function () {
|
|
2436
|
-
var _ref44 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee43(errObj) {
|
|
2437
|
-
return _regenerator.default.wrap(function _callee43$(_context43) {
|
|
2438
|
-
while (1) switch (_context43.prev = _context43.next) {
|
|
2439
|
-
case 0:
|
|
2440
|
-
expect(errObj.type).toStrictEqual(_types.ERROR_TYPE.SERVICE_UNAVAILABLE);
|
|
2441
|
-
expect(errObj.message).toStrictEqual('An unknown error occurred. Wait a moment and try again.');
|
|
2442
|
-
case 2:
|
|
2443
|
-
case "end":
|
|
2444
|
-
return _context43.stop();
|
|
2445
|
-
}
|
|
2446
|
-
}, _callee43);
|
|
2447
|
-
}));
|
|
2448
|
-
return function (_x4) {
|
|
2449
|
-
return _ref44.apply(this, arguments);
|
|
2450
|
-
};
|
|
2451
|
-
}());
|
|
2452
|
-
call.doHoldResume();
|
|
2453
|
-
_context44.next = 9;
|
|
2454
|
-
return (0, _testUtil.flushPromises)(2);
|
|
2455
|
-
case 9:
|
|
2456
|
-
/* the Call State should transition to S_CALL_ESTABLISHED
|
|
2457
|
-
*/
|
|
2458
|
-
expect(call['callStateMachine'].state.value).toStrictEqual('S_CALL_HOLD');
|
|
2459
|
-
call['handleIncomingRoapOffer']({}, dummyEvent);
|
|
2460
|
-
roapEvent = JSON.parse((0, _stringify.default)(dummyEvent));
|
|
2461
|
-
/* We are intentionally failing the ROAP ANSWER */
|
|
2462
|
-
roapEvent.data.type = 'ANSWER';
|
|
2463
|
-
_context44.next = 15;
|
|
2464
|
-
return call['handleOutgoingRoapAnswer']({}, dummyEvent);
|
|
2465
|
-
case 15:
|
|
2466
|
-
expect(call.isHeld()).toStrictEqual(false);
|
|
2467
|
-
/* We should return back to call established state */
|
|
2468
|
-
expect(call['callStateMachine'].state.value).toStrictEqual('S_CALL_ESTABLISHED');
|
|
2469
|
-
case 17:
|
|
2470
|
-
case "end":
|
|
2471
|
-
return _context44.stop();
|
|
2472
|
-
}
|
|
2473
|
-
}, _callee44);
|
|
2474
|
-
})));
|
|
2475
|
-
it('Handle failure Call Hold case during roap ok out', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee45() {
|
|
2476
|
-
var responsePayload, warnSpy, roapEvent;
|
|
2477
|
-
return _regenerator.default.wrap(function _callee45$(_context45) {
|
|
2478
|
-
while (1) switch (_context45.prev = _context45.next) {
|
|
2479
|
-
case 0:
|
|
2480
|
-
responsePayload = {
|
|
2481
|
-
statusCode: 200,
|
|
2482
|
-
body: mockResponseBody
|
|
2483
|
-
};
|
|
2484
|
-
jest.spyOn(webex, 'request').mockResolvedValue(responsePayload);
|
|
2485
|
-
jest.spyOn(global, 'setTimeout');
|
|
2486
|
-
jest.spyOn(global, 'clearTimeout');
|
|
2487
|
-
warnSpy = jest.spyOn(_Logger.default, 'warn');
|
|
2488
|
-
call['held'] = false;
|
|
2489
|
-
_context45.next = 8;
|
|
2490
|
-
return call.doHoldResume();
|
|
2491
|
-
case 8:
|
|
2492
|
-
_context45.next = 10;
|
|
2493
|
-
return (0, _testUtil.flushPromises)(2);
|
|
2494
|
-
case 10:
|
|
2495
|
-
expect(setTimeout).toHaveBeenCalledTimes(1);
|
|
2496
|
-
|
|
2497
|
-
/* At this point, the Call State should be S_CALL_HOLD
|
|
2498
|
-
*/
|
|
2499
|
-
expect(call['callStateMachine'].state.value).toStrictEqual('S_CALL_HOLD');
|
|
2500
|
-
|
|
2501
|
-
/* We simulate the media Connection events manually here as we are not really testing with actual
|
|
2502
|
-
* media.
|
|
2503
|
-
*/
|
|
2504
|
-
call['handleIncomingRoapOffer']({}, dummyEvent);
|
|
2505
|
-
roapEvent = JSON.parse((0, _stringify.default)(dummyEvent));
|
|
2506
|
-
roapEvent.data.type = 'ANSWER';
|
|
2507
|
-
_context45.next = 17;
|
|
2508
|
-
return call['handleOutgoingRoapAnswer']({}, dummyEvent);
|
|
2509
|
-
case 17:
|
|
2510
|
-
jest.spyOn(webex, 'request').mockRejectedValue({
|
|
2511
|
-
statusCode: 403
|
|
2512
|
-
});
|
|
2513
|
-
roapEvent.data.type = 'OK';
|
|
2514
|
-
_context45.next = 21;
|
|
2515
|
-
return call['handleRoapEstablished']({}, dummyEvent);
|
|
2516
|
-
case 21:
|
|
2517
|
-
/* this is for coverage */
|
|
2518
|
-
call['callStateMachine'].state.value = 'S_CALL_HOLD';
|
|
2519
|
-
_context45.next = 24;
|
|
2520
|
-
return call['handleRoapEstablished']({}, dummyEvent);
|
|
2521
|
-
case 24:
|
|
2522
|
-
expect(call.isHeld()).toStrictEqual(false);
|
|
2523
|
-
/* We should return back to call established state */
|
|
2524
|
-
expect(call['callStateMachine'].state.value).toStrictEqual('S_CALL_ESTABLISHED');
|
|
2525
|
-
expect(warnSpy).toHaveBeenCalledWith('Failed to process MediaOk request', {
|
|
2526
|
-
file: 'call',
|
|
2527
|
-
method: 'handleRoapEstablished'
|
|
2528
|
-
});
|
|
2529
|
-
case 27:
|
|
2530
|
-
case "end":
|
|
2531
|
-
return _context45.stop();
|
|
2532
|
-
}
|
|
2533
|
-
}, _callee45);
|
|
2534
|
-
})));
|
|
2535
|
-
it('Handle failure Call resume case during roap ok out', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee46() {
|
|
2536
|
-
var responsePayload, warnSpy, roapEvent;
|
|
2537
|
-
return _regenerator.default.wrap(function _callee46$(_context46) {
|
|
2538
|
-
while (1) switch (_context46.prev = _context46.next) {
|
|
2539
|
-
case 0:
|
|
2540
|
-
responsePayload = {
|
|
2541
|
-
statusCode: 200,
|
|
2542
|
-
body: mockResponseBody
|
|
2543
|
-
};
|
|
2544
|
-
jest.spyOn(webex, 'request').mockResolvedValue(responsePayload);
|
|
2545
|
-
jest.spyOn(global, 'setTimeout');
|
|
2546
|
-
jest.spyOn(global, 'clearTimeout');
|
|
2547
|
-
warnSpy = jest.spyOn(_Logger.default, 'warn');
|
|
2548
|
-
call['held'] = true;
|
|
2549
|
-
_context46.next = 8;
|
|
2550
|
-
return call.doHoldResume();
|
|
2551
|
-
case 8:
|
|
2552
|
-
_context46.next = 10;
|
|
2553
|
-
return (0, _testUtil.flushPromises)(2);
|
|
2554
|
-
case 10:
|
|
2555
|
-
expect(setTimeout).toHaveBeenCalledTimes(1);
|
|
2556
|
-
|
|
2557
|
-
/* At this point, the Call State should be S_CALL_RESUME
|
|
2558
|
-
*/
|
|
2559
|
-
expect(call['callStateMachine'].state.value).toStrictEqual('S_CALL_RESUME');
|
|
2560
|
-
|
|
2561
|
-
/* We simulate the media Connection events manually here as we are not really testing with actual
|
|
2562
|
-
* media.
|
|
2563
|
-
*/
|
|
2564
|
-
call['handleIncomingRoapOffer']({}, dummyEvent);
|
|
2565
|
-
roapEvent = JSON.parse((0, _stringify.default)(dummyEvent));
|
|
2566
|
-
roapEvent.data.type = 'ANSWER';
|
|
2567
|
-
_context46.next = 17;
|
|
2568
|
-
return call['handleOutgoingRoapAnswer']({}, dummyEvent);
|
|
2569
|
-
case 17:
|
|
2570
|
-
jest.spyOn(webex, 'request').mockRejectedValue({
|
|
2571
|
-
statusCode: 403
|
|
2572
|
-
});
|
|
2573
|
-
roapEvent.data.type = 'OK';
|
|
2574
|
-
_context46.next = 21;
|
|
2575
|
-
return call['handleRoapEstablished']({}, dummyEvent);
|
|
2576
|
-
case 21:
|
|
2577
|
-
expect(call.isHeld()).toStrictEqual(true);
|
|
2578
|
-
/* We should return back to call established state */
|
|
2579
|
-
expect(call['callStateMachine'].state.value).toStrictEqual('S_CALL_ESTABLISHED');
|
|
2580
|
-
expect(warnSpy).toHaveBeenCalledWith('Failed to process MediaOk request', {
|
|
2581
|
-
file: 'call',
|
|
2582
|
-
method: 'handleRoapEstablished'
|
|
2583
|
-
});
|
|
2584
|
-
case 24:
|
|
2585
|
-
case "end":
|
|
2586
|
-
return _context46.stop();
|
|
2587
|
-
}
|
|
2588
|
-
}, _callee46);
|
|
2589
|
-
})));
|
|
2590
|
-
it('Handle Call hold case where successful Held response does not come', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee48() {
|
|
2591
|
-
var responsePayload, roapEvent;
|
|
2592
|
-
return _regenerator.default.wrap(function _callee48$(_context48) {
|
|
2593
|
-
while (1) switch (_context48.prev = _context48.next) {
|
|
2594
|
-
case 0:
|
|
2595
|
-
expect.assertions(5);
|
|
2596
|
-
responsePayload = {
|
|
2597
|
-
statusCode: 200,
|
|
2598
|
-
body: mockResponseBody
|
|
2599
|
-
};
|
|
2600
|
-
jest.spyOn(webex, 'request').mockResolvedValue(responsePayload);
|
|
2601
|
-
call['held'] = false;
|
|
2602
|
-
call.on(_types2.CALL_EVENT_KEYS.HOLD_ERROR, /*#__PURE__*/function () {
|
|
2603
|
-
var _ref48 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee47(errObj) {
|
|
2604
|
-
return _regenerator.default.wrap(function _callee47$(_context47) {
|
|
2605
|
-
while (1) switch (_context47.prev = _context47.next) {
|
|
2606
|
-
case 0:
|
|
2607
|
-
expect(errObj.type).toStrictEqual(_types.ERROR_TYPE.TIMEOUT);
|
|
2608
|
-
expect(errObj.message).toStrictEqual('An error occurred while placing the call on hold. Wait a moment and try again.');
|
|
2609
|
-
case 2:
|
|
2610
|
-
case "end":
|
|
2611
|
-
return _context47.stop();
|
|
2612
|
-
}
|
|
2613
|
-
}, _callee47);
|
|
2614
|
-
}));
|
|
2615
|
-
return function (_x5) {
|
|
2616
|
-
return _ref48.apply(this, arguments);
|
|
2617
|
-
};
|
|
2618
|
-
}());
|
|
2619
|
-
jest.runAllTimers();
|
|
2620
|
-
call.doHoldResume();
|
|
2621
|
-
_context48.next = 9;
|
|
2622
|
-
return (0, _testUtil.flushPromises)(2);
|
|
2623
|
-
case 9:
|
|
2624
|
-
/* At this point, the Call State should be S_CALL_HOLD
|
|
2625
|
-
*/
|
|
2626
|
-
expect(call['callStateMachine'].state.value).toStrictEqual('S_CALL_HOLD');
|
|
2627
|
-
|
|
2628
|
-
/* We simulate the media Connection events manually here as we are not really testing with actual
|
|
2629
|
-
* media.
|
|
2630
|
-
*/
|
|
2631
|
-
call['handleIncomingRoapOffer']({}, dummyEvent);
|
|
2632
|
-
roapEvent = JSON.parse((0, _stringify.default)(dummyEvent));
|
|
2633
|
-
roapEvent.data.type = 'ANSWER';
|
|
2634
|
-
_context48.next = 15;
|
|
2635
|
-
return call['handleOutgoingRoapAnswer']({}, dummyEvent);
|
|
2636
|
-
case 15:
|
|
2637
|
-
roapEvent.data.type = 'OK';
|
|
2638
|
-
_context48.next = 18;
|
|
2639
|
-
return call['handleRoapEstablished']({}, dummyEvent);
|
|
2640
|
-
case 18:
|
|
2641
|
-
/* Advancing timer by 12 seconds so that it gets timed out */
|
|
2642
|
-
jest.advanceTimersByTime(12000);
|
|
2643
|
-
|
|
2644
|
-
/* isHeld flag should be unset */
|
|
2645
|
-
expect(call.isHeld()).toStrictEqual(false);
|
|
2646
|
-
/* We should return back to call established state */
|
|
2647
|
-
expect(call['callStateMachine'].state.value).toStrictEqual('S_CALL_ESTABLISHED');
|
|
2648
|
-
case 21:
|
|
2649
|
-
case "end":
|
|
2650
|
-
return _context48.stop();
|
|
2651
|
-
}
|
|
2652
|
-
}, _callee48);
|
|
2653
|
-
})));
|
|
2654
|
-
it('Handle successful Call Resume case without delayed http response', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee50() {
|
|
2655
|
-
var responsePayload, warnSpy, roapEvent;
|
|
2656
|
-
return _regenerator.default.wrap(function _callee50$(_context50) {
|
|
2657
|
-
while (1) switch (_context50.prev = _context50.next) {
|
|
2658
|
-
case 0:
|
|
2659
|
-
expect.assertions(7);
|
|
2660
|
-
responsePayload = {
|
|
2661
|
-
statusCode: 200,
|
|
2662
|
-
body: mockResponseBody
|
|
2663
|
-
};
|
|
2664
|
-
jest.spyOn(webex, 'request').mockResolvedValue(responsePayload);
|
|
2665
|
-
jest.spyOn(global, 'setTimeout');
|
|
2666
|
-
jest.spyOn(global, 'clearTimeout');
|
|
2667
|
-
warnSpy = jest.spyOn(_Logger.default, 'warn');
|
|
2668
|
-
call['held'] = true;
|
|
2669
|
-
call.on(_types2.CALL_EVENT_KEYS.RESUMED, /*#__PURE__*/function () {
|
|
2670
|
-
var _ref50 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee49(correlationId) {
|
|
2671
|
-
return _regenerator.default.wrap(function _callee49$(_context49) {
|
|
2672
|
-
while (1) switch (_context49.prev = _context49.next) {
|
|
2673
|
-
case 0:
|
|
2674
|
-
expect(correlationId).toStrictEqual(call.getCorrelationId());
|
|
2675
|
-
case 1:
|
|
2676
|
-
case "end":
|
|
2677
|
-
return _context49.stop();
|
|
2678
|
-
}
|
|
2679
|
-
}, _callee49);
|
|
2680
|
-
}));
|
|
2681
|
-
return function (_x6) {
|
|
2682
|
-
return _ref50.apply(this, arguments);
|
|
2683
|
-
};
|
|
2684
|
-
}());
|
|
2685
|
-
_context50.next = 10;
|
|
2686
|
-
return call.doHoldResume();
|
|
2687
|
-
case 10:
|
|
2688
|
-
_context50.next = 12;
|
|
2689
|
-
return (0, _testUtil.flushPromises)(2);
|
|
2690
|
-
case 12:
|
|
2691
|
-
expect(setTimeout).toHaveBeenCalledTimes(1);
|
|
2692
|
-
call.handleMidCallEvent(mockResumeEvent);
|
|
2693
|
-
|
|
2694
|
-
/* At this point ,the Call State should be S_CALL_RESUME
|
|
2695
|
-
*/
|
|
2696
|
-
expect(call['callStateMachine'].state.value).toStrictEqual('S_CALL_RESUME');
|
|
2697
|
-
|
|
2698
|
-
/* We simulate the media Connection events manually here as we are not really testing with actual
|
|
2699
|
-
* media.
|
|
2700
|
-
*/
|
|
2701
|
-
call['handleIncomingRoapOffer']({}, dummyEvent);
|
|
2702
|
-
roapEvent = JSON.parse((0, _stringify.default)(dummyEvent));
|
|
2703
|
-
roapEvent.data.type = 'ANSWER';
|
|
2704
|
-
_context50.next = 20;
|
|
2705
|
-
return call['handleOutgoingRoapAnswer']({}, dummyEvent);
|
|
2706
|
-
case 20:
|
|
2707
|
-
roapEvent.data.type = 'OK';
|
|
2708
|
-
_context50.next = 23;
|
|
2709
|
-
return call['handleRoapEstablished']({}, dummyEvent);
|
|
2710
|
-
case 23:
|
|
2711
|
-
expect(clearTimeout).toHaveBeenCalledTimes(1);
|
|
2712
|
-
/* isHeld flag should not be set and an Resume event should be emitted */
|
|
2713
|
-
expect(call.isHeld()).toStrictEqual(false);
|
|
2714
|
-
/* We should return back to call established state */
|
|
2715
|
-
expect(call['callStateMachine'].state.value).toStrictEqual('S_CALL_ESTABLISHED');
|
|
2716
|
-
jest.advanceTimersByTime(12000);
|
|
2717
|
-
expect(warnSpy).not.toHaveBeenCalledWith('Resume response timed out', {
|
|
2718
|
-
file: 'call',
|
|
2719
|
-
method: 'handleCallResume'
|
|
2720
|
-
});
|
|
2721
|
-
case 28:
|
|
2722
|
-
case "end":
|
|
2723
|
-
return _context50.stop();
|
|
2724
|
-
}
|
|
2725
|
-
}, _callee50);
|
|
2726
|
-
})));
|
|
2727
|
-
it('Handle successful Call Resume case with delayed http response', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee52() {
|
|
2728
|
-
var responsePayload, warnSpy, roapEvent;
|
|
2729
|
-
return _regenerator.default.wrap(function _callee52$(_context52) {
|
|
2730
|
-
while (1) switch (_context52.prev = _context52.next) {
|
|
2731
|
-
case 0:
|
|
2732
|
-
expect.assertions(7);
|
|
2733
|
-
responsePayload = {
|
|
2734
|
-
statusCode: 200,
|
|
2735
|
-
body: mockResponseBody
|
|
2736
|
-
};
|
|
2737
|
-
jest.spyOn(webex, 'request').mockResolvedValue(responsePayload);
|
|
2738
|
-
jest.spyOn(global, 'setTimeout');
|
|
2739
|
-
jest.spyOn(global, 'clearTimeout');
|
|
2740
|
-
warnSpy = jest.spyOn(_Logger.default, 'warn');
|
|
2741
|
-
call['held'] = true;
|
|
2742
|
-
call.on(_types2.CALL_EVENT_KEYS.RESUMED, /*#__PURE__*/function () {
|
|
2743
|
-
var _ref52 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee51(correlationId) {
|
|
2744
|
-
return _regenerator.default.wrap(function _callee51$(_context51) {
|
|
2745
|
-
while (1) switch (_context51.prev = _context51.next) {
|
|
2746
|
-
case 0:
|
|
2747
|
-
expect(correlationId).toStrictEqual(call.getCorrelationId());
|
|
2748
|
-
case 1:
|
|
2749
|
-
case "end":
|
|
2750
|
-
return _context51.stop();
|
|
2751
|
-
}
|
|
2752
|
-
}, _callee51);
|
|
2753
|
-
}));
|
|
2754
|
-
return function (_x7) {
|
|
2755
|
-
return _ref52.apply(this, arguments);
|
|
2756
|
-
};
|
|
2757
|
-
}());
|
|
2758
|
-
call.doHoldResume();
|
|
2759
|
-
_context52.next = 11;
|
|
2760
|
-
return _promise.default.resolve();
|
|
2761
|
-
case 11:
|
|
2762
|
-
_context52.next = 13;
|
|
2763
|
-
return _promise.default.resolve();
|
|
2764
|
-
case 13:
|
|
2765
|
-
expect(setTimeout).not.toHaveBeenCalled();
|
|
2766
|
-
call.handleMidCallEvent(mockResumeEvent);
|
|
2767
|
-
|
|
2768
|
-
/* At this point ,the Call State should be S_CALL_RESUME
|
|
2769
|
-
*/
|
|
2770
|
-
expect(call['callStateMachine'].state.value).toStrictEqual('S_CALL_RESUME');
|
|
2771
|
-
|
|
2772
|
-
/* We simulate the media Connection events manually here as we are not really testing with actual
|
|
2773
|
-
* media.
|
|
2774
|
-
*/
|
|
2775
|
-
call['handleIncomingRoapOffer']({}, dummyEvent);
|
|
2776
|
-
roapEvent = JSON.parse((0, _stringify.default)(dummyEvent));
|
|
2777
|
-
roapEvent.data.type = 'ANSWER';
|
|
2778
|
-
_context52.next = 21;
|
|
2779
|
-
return call['handleOutgoingRoapAnswer']({}, dummyEvent);
|
|
2780
|
-
case 21:
|
|
2781
|
-
roapEvent.data.type = 'OK';
|
|
2782
|
-
_context52.next = 24;
|
|
2783
|
-
return call['handleRoapEstablished']({}, dummyEvent);
|
|
2784
|
-
case 24:
|
|
2785
|
-
expect(clearTimeout).not.toHaveBeenCalled();
|
|
2786
|
-
/* isHeld flag should not be set and an Resume event should be emitted */
|
|
2787
|
-
expect(call.isHeld()).toStrictEqual(false);
|
|
2788
|
-
/* We should return back to call established state */
|
|
2789
|
-
expect(call['callStateMachine'].state.value).toStrictEqual('S_CALL_ESTABLISHED');
|
|
2790
|
-
jest.advanceTimersByTime(12000);
|
|
2791
|
-
expect(warnSpy).not.toHaveBeenCalledWith('Resume response timed out', {
|
|
2792
|
-
file: 'call',
|
|
2793
|
-
method: 'handleCallResume'
|
|
2794
|
-
});
|
|
2795
|
-
case 29:
|
|
2796
|
-
case "end":
|
|
2797
|
-
return _context52.stop();
|
|
2798
|
-
}
|
|
2799
|
-
}, _callee52);
|
|
2800
|
-
})));
|
|
2801
|
-
it('Handle failure Call Resume case during signalling', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee54() {
|
|
2802
|
-
var responsePayload;
|
|
2803
|
-
return _regenerator.default.wrap(function _callee54$(_context54) {
|
|
2804
|
-
while (1) switch (_context54.prev = _context54.next) {
|
|
2805
|
-
case 0:
|
|
2806
|
-
expect.assertions(4);
|
|
2807
|
-
responsePayload = {
|
|
2808
|
-
statusCode: 503,
|
|
2809
|
-
body: mockResponseBody
|
|
2810
|
-
};
|
|
2811
|
-
jest.spyOn(webex, 'request').mockRejectedValue(responsePayload);
|
|
2812
|
-
call['held'] = true;
|
|
2813
|
-
call.on(_types2.CALL_EVENT_KEYS.RESUME_ERROR, /*#__PURE__*/function () {
|
|
2814
|
-
var _ref54 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee53(errObj) {
|
|
2815
|
-
return _regenerator.default.wrap(function _callee53$(_context53) {
|
|
2816
|
-
while (1) switch (_context53.prev = _context53.next) {
|
|
2817
|
-
case 0:
|
|
2818
|
-
expect(errObj.type).toStrictEqual(_types.ERROR_TYPE.SERVICE_UNAVAILABLE);
|
|
2819
|
-
expect(errObj.message).toStrictEqual('An unknown error occurred. Wait a moment and try again.');
|
|
2820
|
-
case 2:
|
|
2821
|
-
case "end":
|
|
2822
|
-
return _context53.stop();
|
|
2823
|
-
}
|
|
2824
|
-
}, _callee53);
|
|
2825
|
-
}));
|
|
2826
|
-
return function (_x8) {
|
|
2827
|
-
return _ref54.apply(this, arguments);
|
|
2828
|
-
};
|
|
2829
|
-
}());
|
|
2830
|
-
_context54.next = 7;
|
|
2831
|
-
return call.doHoldResume();
|
|
2832
|
-
case 7:
|
|
2833
|
-
_context54.next = 9;
|
|
2834
|
-
return (0, _testUtil.flushPromises)(2);
|
|
2835
|
-
case 9:
|
|
2836
|
-
expect(call.isHeld()).toStrictEqual(true);
|
|
2837
|
-
|
|
2838
|
-
/* At this point , the Call State should transition to S_CALL_ESTABLISHED
|
|
2839
|
-
*/
|
|
2840
|
-
|
|
2841
|
-
expect(call['callStateMachine'].state.value).toStrictEqual('S_CALL_ESTABLISHED');
|
|
2842
|
-
case 11:
|
|
2843
|
-
case "end":
|
|
2844
|
-
return _context54.stop();
|
|
2845
|
-
}
|
|
2846
|
-
}, _callee54);
|
|
2847
|
-
})));
|
|
2848
|
-
it('Handle failure Call Resume case during offer/answer exchange', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee56() {
|
|
2849
|
-
var responsePayload, rejectPayload, roapEvent;
|
|
2850
|
-
return _regenerator.default.wrap(function _callee56$(_context56) {
|
|
2851
|
-
while (1) switch (_context56.prev = _context56.next) {
|
|
2852
|
-
case 0:
|
|
2853
|
-
expect.assertions(5);
|
|
2854
|
-
responsePayload = {
|
|
2855
|
-
statusCode: 200,
|
|
2856
|
-
body: mockResponseBody
|
|
2857
|
-
};
|
|
2858
|
-
rejectPayload = {
|
|
2859
|
-
statusCode: 503,
|
|
2860
|
-
body: mockResponseBody
|
|
2861
|
-
};
|
|
2862
|
-
jest.spyOn(webex, 'request').mockResolvedValueOnce(responsePayload).mockRejectedValueOnce(rejectPayload);
|
|
2863
|
-
call['held'] = true;
|
|
2864
|
-
call.on(_types2.CALL_EVENT_KEYS.RESUME_ERROR, /*#__PURE__*/function () {
|
|
2865
|
-
var _ref56 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee55(errObj) {
|
|
2866
|
-
return _regenerator.default.wrap(function _callee55$(_context55) {
|
|
2867
|
-
while (1) switch (_context55.prev = _context55.next) {
|
|
2868
|
-
case 0:
|
|
2869
|
-
expect(errObj.type).toStrictEqual(_types.ERROR_TYPE.SERVICE_UNAVAILABLE);
|
|
2870
|
-
expect(errObj.message).toStrictEqual('An unknown error occurred. Wait a moment and try again.');
|
|
2871
|
-
case 2:
|
|
2872
|
-
case "end":
|
|
2873
|
-
return _context55.stop();
|
|
2874
|
-
}
|
|
2875
|
-
}, _callee55);
|
|
2876
|
-
}));
|
|
2877
|
-
return function (_x9) {
|
|
2878
|
-
return _ref56.apply(this, arguments);
|
|
2879
|
-
};
|
|
2880
|
-
}());
|
|
2881
|
-
call.doHoldResume();
|
|
2882
|
-
_context56.next = 9;
|
|
2883
|
-
return (0, _testUtil.flushPromises)(2);
|
|
2884
|
-
case 9:
|
|
2885
|
-
/* At this point , the Call State should transition to S_CALL_ESTABLISHED
|
|
2886
|
-
*/
|
|
2887
|
-
|
|
2888
|
-
expect(call['callStateMachine'].state.value).toStrictEqual('S_CALL_RESUME');
|
|
2889
|
-
call['handleIncomingRoapOffer']({}, dummyEvent);
|
|
2890
|
-
roapEvent = JSON.parse((0, _stringify.default)(dummyEvent));
|
|
2891
|
-
/* We are intentionally failing the ROAP ANSWER */
|
|
2892
|
-
roapEvent.data.type = 'ANSWER';
|
|
2893
|
-
_context56.next = 15;
|
|
2894
|
-
return call['handleOutgoingRoapAnswer']({}, dummyEvent);
|
|
2895
|
-
case 15:
|
|
2896
|
-
expect(call.isHeld()).toStrictEqual(true);
|
|
2897
|
-
/* We should return back to call established state */
|
|
2898
|
-
expect(call['callStateMachine'].state.value).toStrictEqual('S_CALL_ESTABLISHED');
|
|
2899
|
-
case 17:
|
|
2900
|
-
case "end":
|
|
2901
|
-
return _context56.stop();
|
|
2902
|
-
}
|
|
2903
|
-
}, _callee56);
|
|
2904
|
-
})));
|
|
2905
|
-
it('Handle Call resume case where successful response does not come', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee58() {
|
|
2906
|
-
var responsePayload, roapEvent;
|
|
2907
|
-
return _regenerator.default.wrap(function _callee58$(_context58) {
|
|
2908
|
-
while (1) switch (_context58.prev = _context58.next) {
|
|
2909
|
-
case 0:
|
|
2910
|
-
expect.assertions(5);
|
|
2911
|
-
responsePayload = {
|
|
2912
|
-
statusCode: 200,
|
|
2913
|
-
body: mockResponseBody
|
|
2914
|
-
};
|
|
2915
|
-
jest.spyOn(webex, 'request').mockResolvedValue(responsePayload);
|
|
2916
|
-
call['held'] = true;
|
|
2917
|
-
call.on(_types2.CALL_EVENT_KEYS.RESUME_ERROR, /*#__PURE__*/function () {
|
|
2918
|
-
var _ref58 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee57(errObj) {
|
|
2919
|
-
return _regenerator.default.wrap(function _callee57$(_context57) {
|
|
2920
|
-
while (1) switch (_context57.prev = _context57.next) {
|
|
2921
|
-
case 0:
|
|
2922
|
-
expect(errObj.type).toStrictEqual(_types.ERROR_TYPE.TIMEOUT);
|
|
2923
|
-
expect(errObj.message).toStrictEqual('An error occurred while resuming the call. Wait a moment and try again.');
|
|
2924
|
-
case 2:
|
|
2925
|
-
case "end":
|
|
2926
|
-
return _context57.stop();
|
|
2927
|
-
}
|
|
2928
|
-
}, _callee57);
|
|
2929
|
-
}));
|
|
2930
|
-
return function (_x0) {
|
|
2931
|
-
return _ref58.apply(this, arguments);
|
|
2932
|
-
};
|
|
2933
|
-
}());
|
|
2934
|
-
call.doHoldResume();
|
|
2935
|
-
_context58.next = 8;
|
|
2936
|
-
return (0, _testUtil.flushPromises)(2);
|
|
2937
|
-
case 8:
|
|
2938
|
-
/* At this point ,the Call State should be S_CALL_RESUME
|
|
2939
|
-
*/
|
|
2940
|
-
expect(call['callStateMachine'].state.value).toStrictEqual('S_CALL_RESUME');
|
|
2941
|
-
|
|
2942
|
-
/* We simulate the media Connection events manually here as we are not really testing with actual
|
|
2943
|
-
* media.
|
|
2944
|
-
*/
|
|
2945
|
-
call['handleIncomingRoapOffer']({}, dummyEvent);
|
|
2946
|
-
roapEvent = JSON.parse((0, _stringify.default)(dummyEvent));
|
|
2947
|
-
roapEvent.data.type = 'ANSWER';
|
|
2948
|
-
_context58.next = 14;
|
|
2949
|
-
return call['handleOutgoingRoapAnswer']({}, dummyEvent);
|
|
2950
|
-
case 14:
|
|
2951
|
-
roapEvent.data.type = 'OK';
|
|
2952
|
-
_context58.next = 17;
|
|
2953
|
-
return call['handleRoapEstablished']({}, dummyEvent);
|
|
2954
|
-
case 17:
|
|
2955
|
-
/* Advancing timer by 12 seconds so that it gets timed out */
|
|
2956
|
-
jest.advanceTimersByTime(12000);
|
|
2957
|
-
expect(call.isHeld()).toStrictEqual(true);
|
|
2958
|
-
/* We should return back to call established state */
|
|
2959
|
-
expect(call['callStateMachine'].state.value).toStrictEqual('S_CALL_ESTABLISHED');
|
|
2960
|
-
case 20:
|
|
2961
|
-
case "end":
|
|
2962
|
-
return _context58.stop();
|
|
2963
|
-
}
|
|
2964
|
-
}, _callee58);
|
|
2965
|
-
})));
|
|
2966
|
-
});
|
|
2967
|
-
describe('Call transfer tests', function () {
|
|
2968
|
-
var transfereeNumber = '5004';
|
|
2969
|
-
var transfereeDest = {
|
|
2970
|
-
type: _types3.CallType.URI,
|
|
2971
|
-
address: "tel:".concat(transfereeNumber)
|
|
2972
|
-
};
|
|
2973
|
-
var secondCall;
|
|
2974
|
-
|
|
2975
|
-
/* A spy on handleCallErrors to check whether it is being invoked or not depending on tests */
|
|
2976
|
-
var handleErrorSpy = jest.spyOn(Utils, 'handleCallErrors');
|
|
2977
|
-
var uploadLogsSpy = jest.spyOn(Utils, 'uploadLogs');
|
|
2978
|
-
var transferLoggingContext = {
|
|
2979
|
-
file: 'call',
|
|
2980
|
-
method: 'completeTransfer'
|
|
2981
|
-
};
|
|
2982
|
-
beforeEach(function () {
|
|
2983
|
-
/* We will put the first call on hold to perform the transfer */
|
|
2984
|
-
call['held'] = true;
|
|
2985
|
-
|
|
2986
|
-
/* We will create a second call just like the first call, but call is active, i.e, not held */
|
|
2987
|
-
secondCall = new _call.Call(activeUrl, webex, _types3.CallDirection.OUTBOUND, deviceId, mockLineId, function () {
|
|
2988
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2989
|
-
var dummy = 10;
|
|
2990
|
-
}, defaultServiceIndicator, transfereeDest);
|
|
2991
|
-
secondCall['connected'] = true;
|
|
2992
|
-
secondCall['earlyMedia'] = false;
|
|
2993
|
-
secondCall['callStateMachine'].state.value = 'S_CALL_ESTABLISHED';
|
|
2994
|
-
secondCall.removeAllListeners(_types2.CALL_EVENT_KEYS.CALL_ERROR);
|
|
2995
|
-
secondCall['held'] = false;
|
|
2996
|
-
});
|
|
2997
|
-
it('Handle successful consult transfer case ', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee61() {
|
|
2998
|
-
var responsePayload, requestSpy, warnSpy, infoSpy, metricSpy;
|
|
2999
|
-
return _regenerator.default.wrap(function _callee61$(_context61) {
|
|
3000
|
-
while (1) switch (_context61.prev = _context61.next) {
|
|
3001
|
-
case 0:
|
|
3002
|
-
expect.assertions(12); // Updated to match actual assertion count
|
|
3003
|
-
responsePayload = {
|
|
3004
|
-
statusCode: 200,
|
|
3005
|
-
body: mockResponseBody
|
|
3006
|
-
};
|
|
3007
|
-
requestSpy = jest.spyOn(webex, 'request').mockResolvedValue(responsePayload);
|
|
3008
|
-
warnSpy = jest.spyOn(_Logger.default, 'warn');
|
|
3009
|
-
infoSpy = jest.spyOn(_Logger.default, 'info');
|
|
3010
|
-
metricSpy = jest.spyOn(call['metricManager'], 'submitCallMetric');
|
|
3011
|
-
call.on(_types2.CALL_EVENT_KEYS.DISCONNECT, /*#__PURE__*/function () {
|
|
3012
|
-
var _ref60 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee59(correlationId) {
|
|
3013
|
-
return _regenerator.default.wrap(function _callee59$(_context59) {
|
|
3014
|
-
while (1) switch (_context59.prev = _context59.next) {
|
|
3015
|
-
case 0:
|
|
3016
|
-
expect(correlationId).toStrictEqual(call.getCorrelationId());
|
|
3017
|
-
case 1:
|
|
3018
|
-
case "end":
|
|
3019
|
-
return _context59.stop();
|
|
3020
|
-
}
|
|
3021
|
-
}, _callee59);
|
|
3022
|
-
}));
|
|
3023
|
-
return function (_x1) {
|
|
3024
|
-
return _ref60.apply(this, arguments);
|
|
3025
|
-
};
|
|
3026
|
-
}());
|
|
3027
|
-
secondCall.on(_types2.CALL_EVENT_KEYS.DISCONNECT, /*#__PURE__*/function () {
|
|
3028
|
-
var _ref61 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee60(correlationId) {
|
|
3029
|
-
return _regenerator.default.wrap(function _callee60$(_context60) {
|
|
3030
|
-
while (1) switch (_context60.prev = _context60.next) {
|
|
3031
|
-
case 0:
|
|
3032
|
-
expect(correlationId).toStrictEqual(secondCall.getCorrelationId());
|
|
3033
|
-
case 1:
|
|
3034
|
-
case "end":
|
|
3035
|
-
return _context60.stop();
|
|
3036
|
-
}
|
|
3037
|
-
}, _callee60);
|
|
3038
|
-
}));
|
|
3039
|
-
return function (_x10) {
|
|
3040
|
-
return _ref61.apply(this, arguments);
|
|
3041
|
-
};
|
|
3042
|
-
}());
|
|
3043
|
-
_context61.next = 10;
|
|
3044
|
-
return call.completeTransfer(_types5.TransferType.CONSULT, secondCall.getCallId(), undefined);
|
|
3045
|
-
case 10:
|
|
3046
|
-
_context61.next = 12;
|
|
3047
|
-
return (0, _testUtil.flushPromises)(2);
|
|
3048
|
-
case 12:
|
|
3049
|
-
expect(requestSpy).toBeCalled();
|
|
3050
|
-
expect(metricSpy).toHaveBeenCalledWith(_types4.METRIC_EVENT.CALL, _types4.TRANSFER_ACTION.CONSULT, _types4.METRIC_TYPE.BEHAVIORAL, call.getCallId(), call.getCorrelationId(), undefined);
|
|
3051
|
-
call.sendCallStateMachineEvt({
|
|
3052
|
-
type: 'E_RECV_CALL_DISCONNECT'
|
|
3053
|
-
});
|
|
3054
|
-
secondCall.sendCallStateMachineEvt({
|
|
3055
|
-
type: 'E_RECV_CALL_DISCONNECT'
|
|
3056
|
-
});
|
|
3057
|
-
|
|
3058
|
-
/* We should return back to S_RECV_CALL_DISCONNECT state for both the calls */
|
|
3059
|
-
expect(call['callStateMachine'].state.value).toStrictEqual('S_RECV_CALL_DISCONNECT');
|
|
3060
|
-
expect(secondCall['callStateMachine'].state.value).toStrictEqual('S_RECV_CALL_DISCONNECT');
|
|
3061
|
-
expect(handleErrorSpy).not.toBeCalled();
|
|
3062
|
-
expect(uploadLogsSpy).not.toBeCalled();
|
|
3063
|
-
expect(infoSpy).toHaveBeenCalledWith("Initiating Consult transfer between : ".concat(call.getCallId(), " and ").concat(secondCall.getCallId()), transferLoggingContext);
|
|
3064
|
-
expect(warnSpy).not.toHaveBeenCalledWith("Consult Transfer failed for correlationId ".concat(call.getCorrelationId()), transferLoggingContext);
|
|
3065
|
-
expect(infoSpy).toHaveBeenCalledWith("Initiating Consult transfer between : ".concat(call.getCallId(), " and ").concat(secondCall.getCallId()), transferLoggingContext);
|
|
3066
|
-
expect(warnSpy).not.toHaveBeenCalledWith("Consult Transfer failed for correlationId ".concat(call.getCorrelationId()), transferLoggingContext);
|
|
3067
|
-
case 24:
|
|
3068
|
-
case "end":
|
|
3069
|
-
return _context61.stop();
|
|
3070
|
-
}
|
|
3071
|
-
}, _callee61);
|
|
3072
|
-
})));
|
|
3073
|
-
it('Handle successful blind transfer case ', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee63() {
|
|
3074
|
-
var responsePayload, requestSpy, warnSpy, infoSpy, metricSpy;
|
|
3075
|
-
return _regenerator.default.wrap(function _callee63$(_context63) {
|
|
3076
|
-
while (1) switch (_context63.prev = _context63.next) {
|
|
3077
|
-
case 0:
|
|
3078
|
-
expect.assertions(10); // Updated to match actual assertion count
|
|
3079
|
-
responsePayload = {
|
|
3080
|
-
statusCode: 200,
|
|
3081
|
-
body: mockResponseBody
|
|
3082
|
-
};
|
|
3083
|
-
requestSpy = jest.spyOn(webex, 'request').mockResolvedValue(responsePayload);
|
|
3084
|
-
warnSpy = jest.spyOn(_Logger.default, 'warn');
|
|
3085
|
-
infoSpy = jest.spyOn(_Logger.default, 'info');
|
|
3086
|
-
metricSpy = jest.spyOn(call['metricManager'], 'submitCallMetric');
|
|
3087
|
-
call.on(_types2.CALL_EVENT_KEYS.DISCONNECT, /*#__PURE__*/function () {
|
|
3088
|
-
var _ref63 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee62(correlationId) {
|
|
3089
|
-
return _regenerator.default.wrap(function _callee62$(_context62) {
|
|
3090
|
-
while (1) switch (_context62.prev = _context62.next) {
|
|
3091
|
-
case 0:
|
|
3092
|
-
expect(correlationId).toStrictEqual(call.getCorrelationId());
|
|
3093
|
-
case 1:
|
|
3094
|
-
case "end":
|
|
3095
|
-
return _context62.stop();
|
|
3096
|
-
}
|
|
3097
|
-
}, _callee62);
|
|
3098
|
-
}));
|
|
3099
|
-
return function (_x11) {
|
|
3100
|
-
return _ref63.apply(this, arguments);
|
|
3101
|
-
};
|
|
3102
|
-
}());
|
|
3103
|
-
_context63.next = 9;
|
|
3104
|
-
return call.completeTransfer(_types5.TransferType.BLIND, undefined, transfereeNumber);
|
|
3105
|
-
case 9:
|
|
3106
|
-
_context63.next = 11;
|
|
3107
|
-
return (0, _testUtil.flushPromises)(2);
|
|
3108
|
-
case 11:
|
|
3109
|
-
expect(requestSpy).toBeCalled();
|
|
3110
|
-
expect(metricSpy).toHaveBeenCalledWith(_types4.METRIC_EVENT.CALL, _types4.TRANSFER_ACTION.BLIND, _types4.METRIC_TYPE.BEHAVIORAL, call.getCallId(), call.getCorrelationId(), undefined);
|
|
3111
|
-
call.sendCallStateMachineEvt({
|
|
3112
|
-
type: 'E_RECV_CALL_DISCONNECT'
|
|
3113
|
-
});
|
|
3114
|
-
|
|
3115
|
-
/* We should return back to S_RECV_CALL_DISCONNECT state */
|
|
3116
|
-
expect(call['callStateMachine'].state.value).toStrictEqual('S_RECV_CALL_DISCONNECT');
|
|
3117
|
-
expect(handleErrorSpy).not.toBeCalled();
|
|
3118
|
-
expect(uploadLogsSpy).not.toBeCalled();
|
|
3119
|
-
expect(infoSpy).toHaveBeenCalledWith("Initiating Blind transfer with : ".concat(transfereeNumber), transferLoggingContext);
|
|
3120
|
-
expect(warnSpy).not.toHaveBeenCalledWith("Blind Transfer failed for correlationId ".concat(call.getCorrelationId()), transferLoggingContext);
|
|
3121
|
-
expect(infoSpy).toHaveBeenCalledWith("Initiating Blind transfer with : ".concat(transfereeNumber), transferLoggingContext);
|
|
3122
|
-
expect(warnSpy).not.toHaveBeenCalledWith("Blind Transfer failed for correlationId ".concat(call.getCorrelationId()), transferLoggingContext);
|
|
3123
|
-
case 21:
|
|
3124
|
-
case "end":
|
|
3125
|
-
return _context63.stop();
|
|
3126
|
-
}
|
|
3127
|
-
}, _callee63);
|
|
3128
|
-
})));
|
|
3129
|
-
it('Handle unsuccessful blind transfer case', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee64() {
|
|
3130
|
-
var responsePayload, emitSpy, requestSpy, warnSpy, metricSpy;
|
|
3131
|
-
return _regenerator.default.wrap(function _callee64$(_context64) {
|
|
3132
|
-
while (1) switch (_context64.prev = _context64.next) {
|
|
3133
|
-
case 0:
|
|
3134
|
-
responsePayload = {
|
|
3135
|
-
statusCode: 403,
|
|
3136
|
-
body: mockResponseBody
|
|
3137
|
-
};
|
|
3138
|
-
emitSpy = jest.spyOn(call, 'emit');
|
|
3139
|
-
requestSpy = jest.spyOn(webex, 'request').mockRejectedValue(responsePayload);
|
|
3140
|
-
warnSpy = jest.spyOn(_Logger.default, 'warn');
|
|
3141
|
-
metricSpy = jest.spyOn(call['metricManager'], 'submitCallMetric');
|
|
3142
|
-
call['broadworksCorrelationInfo'] = 'dummy-broadworks-correlation-info';
|
|
3143
|
-
_context64.next = 8;
|
|
3144
|
-
return call.completeTransfer(_types5.TransferType.BLIND, undefined, transfereeNumber);
|
|
3145
|
-
case 8:
|
|
3146
|
-
_context64.next = 10;
|
|
3147
|
-
return (0, _testUtil.flushPromises)(1);
|
|
3148
|
-
case 10:
|
|
3149
|
-
expect(requestSpy).toBeCalled();
|
|
3150
|
-
/* We should be in CALL_ESTABLISHED state */
|
|
3151
|
-
expect(call['callStateMachine'].state.value).toStrictEqual('S_CALL_ESTABLISHED');
|
|
3152
|
-
expect(call['held']).toBe(true);
|
|
3153
|
-
expect(handleErrorSpy).toHaveBeenCalledWith(expect.anything(), _types.ERROR_LAYER.CALL_CONTROL,
|
|
3154
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
3155
|
-
expect.anything(), call.getCorrelationId(), responsePayload, 'completeTransfer', 'call');
|
|
3156
|
-
expect(uploadLogsSpy).toHaveBeenCalledWith({
|
|
3157
|
-
correlationId: call.getCorrelationId(),
|
|
3158
|
-
callId: call.getCallId(),
|
|
3159
|
-
broadworksCorrelationInfo: 'dummy-broadworks-correlation-info'
|
|
3160
|
-
});
|
|
3161
|
-
/* check whether error event is being emitted by sdk */
|
|
3162
|
-
expect(emitSpy).toBeCalledOnceWith(_types2.CALL_EVENT_KEYS.TRANSFER_ERROR, expect.any(_Errors.CallError));
|
|
3163
|
-
expect(warnSpy).toHaveBeenCalledWith("Blind Transfer failed for correlationId ".concat(call.getCorrelationId()), transferLoggingContext);
|
|
3164
|
-
expect(metricSpy).toHaveBeenCalledWith(_types4.METRIC_EVENT.CALL_ERROR, _types4.TRANSFER_ACTION.BLIND, _types4.METRIC_TYPE.BEHAVIORAL, call.getCallId(), call.getCorrelationId(), expect.any(_Errors.CallError));
|
|
3165
|
-
case 18:
|
|
3166
|
-
case "end":
|
|
3167
|
-
return _context64.stop();
|
|
3168
|
-
}
|
|
3169
|
-
}, _callee64);
|
|
3170
|
-
})));
|
|
3171
|
-
it('Handle unsuccessful consult transfer case', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee65() {
|
|
3172
|
-
var responsePayload, emitSpy, requestSpy, warnSpy, metricSpy;
|
|
3173
|
-
return _regenerator.default.wrap(function _callee65$(_context65) {
|
|
3174
|
-
while (1) switch (_context65.prev = _context65.next) {
|
|
3175
|
-
case 0:
|
|
3176
|
-
responsePayload = {
|
|
3177
|
-
statusCode: 403,
|
|
3178
|
-
body: mockResponseBody
|
|
3179
|
-
};
|
|
3180
|
-
emitSpy = jest.spyOn(call, 'emit');
|
|
3181
|
-
requestSpy = jest.spyOn(webex, 'request').mockRejectedValue(responsePayload);
|
|
3182
|
-
warnSpy = jest.spyOn(_Logger.default, 'warn');
|
|
3183
|
-
metricSpy = jest.spyOn(call['metricManager'], 'submitCallMetric');
|
|
3184
|
-
_context65.next = 7;
|
|
3185
|
-
return call.completeTransfer(_types5.TransferType.CONSULT, secondCall.getCallId(), undefined);
|
|
3186
|
-
case 7:
|
|
3187
|
-
_context65.next = 9;
|
|
3188
|
-
return (0, _testUtil.flushPromises)(2);
|
|
3189
|
-
case 9:
|
|
3190
|
-
expect(requestSpy).toBeCalled();
|
|
3191
|
-
/* We should be in CALL_ESTABLISHED state */
|
|
3192
|
-
expect(call['callStateMachine'].state.value).toStrictEqual('S_CALL_ESTABLISHED');
|
|
3193
|
-
expect(call['held']).toBe(true);
|
|
3194
|
-
expect(secondCall['callStateMachine'].state.value).toStrictEqual('S_CALL_ESTABLISHED');
|
|
3195
|
-
expect(handleErrorSpy).toHaveBeenCalledWith(expect.anything(), _types.ERROR_LAYER.CALL_CONTROL,
|
|
3196
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
3197
|
-
expect.anything(), call.getCorrelationId(), responsePayload, 'completeTransfer', 'call');
|
|
3198
|
-
expect(uploadLogsSpy).toHaveBeenCalledWith({
|
|
3199
|
-
correlationId: call.getCorrelationId(),
|
|
3200
|
-
callId: call.getCallId()
|
|
3201
|
-
});
|
|
3202
|
-
/* check whether error event is being emitted by sdk */
|
|
3203
|
-
expect(emitSpy).toHaveBeenCalledWith(_types2.CALL_EVENT_KEYS.TRANSFER_ERROR, expect.any(_Errors.CallError));
|
|
3204
|
-
expect(warnSpy).toHaveBeenCalledWith("Consult Transfer failed for correlationId ".concat(call.getCorrelationId()), transferLoggingContext);
|
|
3205
|
-
expect(metricSpy).toHaveBeenCalledWith(_types4.METRIC_EVENT.CALL_ERROR, _types4.TRANSFER_ACTION.CONSULT, _types4.METRIC_TYPE.BEHAVIORAL, call.getCallId(), call.getCorrelationId(), expect.any(_Errors.CallError));
|
|
3206
|
-
case 18:
|
|
3207
|
-
case "end":
|
|
3208
|
-
return _context65.stop();
|
|
3209
|
-
}
|
|
3210
|
-
}, _callee65);
|
|
3211
|
-
})));
|
|
3212
|
-
it('Handle blind transfer with undefined transferTarget', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee66() {
|
|
3213
|
-
var requestSpy, warnSpy;
|
|
3214
|
-
return _regenerator.default.wrap(function _callee66$(_context66) {
|
|
3215
|
-
while (1) switch (_context66.prev = _context66.next) {
|
|
3216
|
-
case 0:
|
|
3217
|
-
requestSpy = jest.spyOn(webex, 'request');
|
|
3218
|
-
warnSpy = jest.spyOn(_Logger.default, 'warn');
|
|
3219
|
-
_context66.next = 4;
|
|
3220
|
-
return call.completeTransfer(_types5.TransferType.BLIND, undefined, undefined);
|
|
3221
|
-
case 4:
|
|
3222
|
-
/* We should be in CALL_ESTABLISHED state */
|
|
3223
|
-
expect(call['callStateMachine'].state.value).toStrictEqual('S_CALL_ESTABLISHED');
|
|
3224
|
-
expect(secondCall['callStateMachine'].state.value).toStrictEqual('S_CALL_ESTABLISHED');
|
|
3225
|
-
expect(handleErrorSpy).not.toBeCalled();
|
|
3226
|
-
expect(uploadLogsSpy).not.toBeCalled();
|
|
3227
|
-
expect(requestSpy).not.toBeCalled();
|
|
3228
|
-
expect(warnSpy).toBeCalledOnceWith("Invalid information received, transfer failed for correlationId: ".concat(call.getCorrelationId()), transferLoggingContext);
|
|
3229
|
-
case 10:
|
|
3230
|
-
case "end":
|
|
3231
|
-
return _context66.stop();
|
|
3232
|
-
}
|
|
3233
|
-
}, _callee66);
|
|
3234
|
-
})));
|
|
3235
|
-
it('Handle consult transfer with undefined transferCallId', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee67() {
|
|
3236
|
-
var requestSpy, warnSpy;
|
|
3237
|
-
return _regenerator.default.wrap(function _callee67$(_context67) {
|
|
3238
|
-
while (1) switch (_context67.prev = _context67.next) {
|
|
3239
|
-
case 0:
|
|
3240
|
-
requestSpy = jest.spyOn(webex, 'request');
|
|
3241
|
-
warnSpy = jest.spyOn(_Logger.default, 'warn');
|
|
3242
|
-
_context67.next = 4;
|
|
3243
|
-
return call.completeTransfer(_types5.TransferType.CONSULT, undefined, undefined);
|
|
3244
|
-
case 4:
|
|
3245
|
-
/* We should be in CALL_ESTABLISHED state */
|
|
3246
|
-
expect(call['callStateMachine'].state.value).toStrictEqual('S_CALL_ESTABLISHED');
|
|
3247
|
-
expect(secondCall['callStateMachine'].state.value).toStrictEqual('S_CALL_ESTABLISHED');
|
|
3248
|
-
expect(handleErrorSpy).not.toBeCalled();
|
|
3249
|
-
expect(uploadLogsSpy).not.toBeCalled();
|
|
3250
|
-
expect(requestSpy).not.toBeCalled();
|
|
3251
|
-
expect(warnSpy).toBeCalledOnceWith("Invalid information received, transfer failed for correlationId: ".concat(call.getCorrelationId()), transferLoggingContext);
|
|
3252
|
-
case 10:
|
|
3253
|
-
case "end":
|
|
3254
|
-
return _context67.stop();
|
|
3255
|
-
}
|
|
3256
|
-
}, _callee67);
|
|
3257
|
-
})));
|
|
3258
|
-
});
|
|
3259
|
-
});
|
|
3260
|
-
//# sourceMappingURL=call.test.js.map
|