@webex/calling 3.8.0 → 3.8.1-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CallHistory/CallHistory.js +100 -63
- package/dist/CallHistory/CallHistory.js.map +1 -1
- package/dist/CallHistory/CallHistory.test.js +115 -19
- package/dist/CallHistory/CallHistory.test.js.map +1 -1
- package/dist/CallHistory/constants.js +9 -1
- package/dist/CallHistory/constants.js.map +1 -1
- package/dist/CallSettings/CallSettings.js +46 -13
- package/dist/CallSettings/CallSettings.js.map +1 -1
- package/dist/CallSettings/UcmBackendConnector.js +62 -18
- package/dist/CallSettings/UcmBackendConnector.js.map +1 -1
- package/dist/CallSettings/UcmBackendConnector.test.js +70 -7
- package/dist/CallSettings/UcmBackendConnector.test.js.map +1 -1
- package/dist/CallSettings/WxCallBackendConnector.js +153 -103
- package/dist/CallSettings/WxCallBackendConnector.js.map +1 -1
- package/dist/CallSettings/WxCallBackendConnector.test.js +52 -15
- package/dist/CallSettings/WxCallBackendConnector.test.js.map +1 -1
- package/dist/CallSettings/constants.js +15 -1
- package/dist/CallSettings/constants.js.map +1 -1
- package/dist/CallingClient/CallingClient.js +220 -159
- package/dist/CallingClient/CallingClient.js.map +1 -1
- package/dist/CallingClient/CallingClient.test.js +53 -24
- package/dist/CallingClient/CallingClient.test.js.map +1 -1
- package/dist/CallingClient/calling/call.js +251 -189
- package/dist/CallingClient/calling/call.js.map +1 -1
- package/dist/CallingClient/calling/call.test.js +96 -41
- package/dist/CallingClient/calling/call.test.js.map +1 -1
- package/dist/CallingClient/calling/callManager.js +73 -48
- package/dist/CallingClient/calling/callManager.js.map +1 -1
- package/dist/CallingClient/calling/callManager.test.js +96 -37
- package/dist/CallingClient/calling/callManager.test.js.map +1 -1
- package/dist/CallingClient/constants.js +105 -3
- package/dist/CallingClient/constants.js.map +1 -1
- package/dist/CallingClient/line/index.js +47 -18
- package/dist/CallingClient/line/index.js.map +1 -1
- package/dist/CallingClient/line/line.test.js +2 -2
- package/dist/CallingClient/line/line.test.js.map +1 -1
- package/dist/CallingClient/registration/register.js +359 -297
- package/dist/CallingClient/registration/register.js.map +1 -1
- package/dist/CallingClient/registration/register.test.js +561 -163
- package/dist/CallingClient/registration/register.test.js.map +1 -1
- package/dist/CallingClient/registration/types.js.map +1 -1
- package/dist/Contacts/ContactsClient.js +156 -102
- package/dist/Contacts/ContactsClient.js.map +1 -1
- package/dist/Contacts/ContactsClient.test.js +197 -49
- package/dist/Contacts/ContactsClient.test.js.map +1 -1
- package/dist/Contacts/constants.js +11 -1
- package/dist/Contacts/constants.js.map +1 -1
- package/dist/Errors/types.js +2 -0
- package/dist/Errors/types.js.map +1 -1
- package/dist/Events/impl/index.js +1 -1
- package/dist/Events/impl/index.js.map +1 -1
- package/dist/Metrics/index.js +102 -41
- package/dist/Metrics/index.js.map +1 -1
- package/dist/Metrics/index.test.js +10 -4
- package/dist/Metrics/index.test.js.map +1 -1
- package/dist/Metrics/types.js +4 -1
- package/dist/Metrics/types.js.map +1 -1
- package/dist/SDKConnector/types.js.map +1 -1
- package/dist/Voicemail/BroadworksBackendConnector.js +154 -91
- package/dist/Voicemail/BroadworksBackendConnector.js.map +1 -1
- package/dist/Voicemail/BroadworksBackendConnector.test.js +99 -19
- package/dist/Voicemail/BroadworksBackendConnector.test.js.map +1 -1
- package/dist/Voicemail/UcmBackendConnector.js +105 -54
- package/dist/Voicemail/UcmBackendConnector.js.map +1 -1
- package/dist/Voicemail/UcmBackendConnector.test.js +127 -17
- package/dist/Voicemail/UcmBackendConnector.test.js.map +1 -1
- package/dist/Voicemail/Voicemail.js +198 -79
- package/dist/Voicemail/Voicemail.js.map +1 -1
- package/dist/Voicemail/Voicemail.test.js +188 -23
- package/dist/Voicemail/Voicemail.test.js.map +1 -1
- package/dist/Voicemail/WxCallBackendConnector.js +277 -161
- package/dist/Voicemail/WxCallBackendConnector.js.map +1 -1
- package/dist/Voicemail/WxCallBackendConnector.test.js +268 -10
- package/dist/Voicemail/WxCallBackendConnector.test.js.map +1 -1
- package/dist/Voicemail/constants.js +25 -1
- package/dist/Voicemail/constants.js.map +1 -1
- package/dist/Voicemail/types.js.map +1 -1
- package/dist/common/Utils.js +168 -104
- package/dist/common/Utils.js.map +1 -1
- package/dist/common/Utils.test.js +199 -35
- package/dist/common/Utils.test.js.map +1 -1
- package/dist/common/constants.js +2 -1
- package/dist/common/constants.js.map +1 -1
- package/dist/common/testUtil.js +3 -0
- package/dist/common/testUtil.js.map +1 -1
- package/dist/common/types.js.map +1 -1
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/dist/module/CallHistory/CallHistory.js +32 -13
- package/dist/module/CallHistory/constants.js +6 -0
- package/dist/module/CallSettings/CallSettings.js +36 -3
- package/dist/module/CallSettings/UcmBackendConnector.js +50 -5
- package/dist/module/CallSettings/WxCallBackendConnector.js +54 -18
- package/dist/module/CallSettings/constants.js +12 -0
- package/dist/module/CallingClient/CallingClient.js +54 -16
- package/dist/module/CallingClient/calling/call.js +172 -121
- package/dist/module/CallingClient/calling/callManager.js +51 -26
- package/dist/module/CallingClient/constants.js +102 -2
- package/dist/module/CallingClient/line/index.js +37 -8
- package/dist/module/CallingClient/registration/register.js +103 -64
- package/dist/module/Contacts/ContactsClient.js +65 -21
- package/dist/module/Contacts/constants.js +10 -0
- package/dist/module/Errors/types.js +2 -0
- package/dist/module/Events/impl/index.js +1 -1
- package/dist/module/Metrics/index.js +57 -2
- package/dist/module/Metrics/types.js +3 -0
- package/dist/module/Voicemail/BroadworksBackendConnector.js +66 -17
- package/dist/module/Voicemail/UcmBackendConnector.js +51 -11
- package/dist/module/Voicemail/Voicemail.js +109 -9
- package/dist/module/Voicemail/WxCallBackendConnector.js +67 -18
- package/dist/module/Voicemail/constants.js +21 -0
- package/dist/module/common/Utils.js +51 -12
- package/dist/module/common/constants.js +1 -0
- package/dist/module/common/testUtil.js +3 -0
- package/dist/module/index.js +1 -0
- package/dist/types/CallHistory/CallHistory.d.ts.map +1 -1
- package/dist/types/CallHistory/constants.d.ts +6 -0
- package/dist/types/CallHistory/constants.d.ts.map +1 -1
- package/dist/types/CallSettings/CallSettings.d.ts.map +1 -1
- package/dist/types/CallSettings/UcmBackendConnector.d.ts.map +1 -1
- package/dist/types/CallSettings/WxCallBackendConnector.d.ts.map +1 -1
- package/dist/types/CallSettings/constants.d.ts +12 -0
- package/dist/types/CallSettings/constants.d.ts.map +1 -1
- package/dist/types/CallingClient/CallingClient.d.ts +2 -3
- package/dist/types/CallingClient/CallingClient.d.ts.map +1 -1
- package/dist/types/CallingClient/calling/call.d.ts.map +1 -1
- package/dist/types/CallingClient/calling/callManager.d.ts.map +1 -1
- package/dist/types/CallingClient/constants.d.ts +102 -2
- package/dist/types/CallingClient/constants.d.ts.map +1 -1
- package/dist/types/CallingClient/line/index.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/register.d.ts +3 -1
- package/dist/types/CallingClient/registration/register.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/types.d.ts +1 -0
- package/dist/types/CallingClient/registration/types.d.ts.map +1 -1
- package/dist/types/Contacts/ContactsClient.d.ts.map +1 -1
- package/dist/types/Contacts/constants.d.ts +10 -0
- package/dist/types/Contacts/constants.d.ts.map +1 -1
- package/dist/types/Errors/types.d.ts +2 -0
- package/dist/types/Errors/types.d.ts.map +1 -1
- package/dist/types/Metrics/index.d.ts +1 -1
- package/dist/types/Metrics/index.d.ts.map +1 -1
- package/dist/types/Metrics/types.d.ts +7 -2
- package/dist/types/Metrics/types.d.ts.map +1 -1
- package/dist/types/SDKConnector/types.d.ts +11 -2
- 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 +1 -1
- package/dist/types/Voicemail/Voicemail.d.ts.map +1 -1
- package/dist/types/Voicemail/WxCallBackendConnector.d.ts +3 -1
- package/dist/types/Voicemail/WxCallBackendConnector.d.ts.map +1 -1
- package/dist/types/Voicemail/constants.d.ts +21 -0
- package/dist/types/Voicemail/constants.d.ts.map +1 -1
- package/dist/types/Voicemail/types.d.ts +1 -1
- package/dist/types/Voicemail/types.d.ts.map +1 -1
- package/dist/types/common/Utils.d.ts +4 -4
- package/dist/types/common/Utils.d.ts.map +1 -1
- package/dist/types/common/constants.d.ts +1 -0
- package/dist/types/common/constants.d.ts.map +1 -1
- package/dist/types/common/testUtil.d.ts +3 -0
- package/dist/types/common/testUtil.d.ts.map +1 -1
- package/dist/types/common/types.d.ts +12 -0
- package/dist/types/common/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +4 -3
|
@@ -29,6 +29,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
29
29
|
var mockSubmitRegistrationMetric = jest.fn();
|
|
30
30
|
var mockEmitterCb = jest.fn();
|
|
31
31
|
var mockRestoreCb = jest.fn();
|
|
32
|
+
var mock429RetryCb = jest.fn();
|
|
32
33
|
var webex = (0, _testUtil.getTestUtilsWebex)();
|
|
33
34
|
_SDKConnector.default.setWebex(webex);
|
|
34
35
|
webex.internal.metrics.submitClientMetrics = mockSubmitRegistrationMetric;
|
|
@@ -71,48 +72,60 @@ describe('Registration Tests', function () {
|
|
|
71
72
|
* logMsg: log message.
|
|
72
73
|
*/
|
|
73
74
|
var errorCodes = [{
|
|
75
|
+
name: 'verify 429 error response',
|
|
76
|
+
statusCode: _types2.ERROR_CODE.TOO_MANY_REQUESTS,
|
|
77
|
+
deviceErrorCode: 0,
|
|
78
|
+
retryAfter: 30,
|
|
79
|
+
message: '',
|
|
80
|
+
errorType: _types2.ERROR_TYPE.REGISTRATION_ERROR,
|
|
81
|
+
emitterCbExpected: false,
|
|
82
|
+
finalError: false,
|
|
83
|
+
retry429CbExpected: true,
|
|
84
|
+
restoreCbExpected: false,
|
|
85
|
+
logMsg: '429 Too Many Requests'
|
|
86
|
+
}, {
|
|
74
87
|
name: 'verify 404 error response',
|
|
75
88
|
statusCode: _types2.ERROR_CODE.DEVICE_NOT_FOUND,
|
|
76
89
|
deviceErrorCode: 0,
|
|
77
|
-
|
|
78
|
-
message: 'The client has unregistered. Please wait for the client to register before attempting the call. If error persists, sign out, sign back in and attempt the call.',
|
|
90
|
+
message: 'Webex Calling is unable to find your device. Sign out, then sign back in',
|
|
79
91
|
errorType: _types2.ERROR_TYPE.NOT_FOUND,
|
|
80
92
|
emitterCbExpected: true,
|
|
81
93
|
finalError: true,
|
|
82
94
|
restoreCbExpected: false,
|
|
95
|
+
retry429CbExpected: false,
|
|
83
96
|
logMsg: '404 Device Not Found'
|
|
84
97
|
}, {
|
|
85
98
|
name: 'verify 500 error response',
|
|
86
99
|
statusCode: _types2.ERROR_CODE.INTERNAL_SERVER_ERROR,
|
|
87
100
|
deviceErrorCode: 0,
|
|
88
|
-
retryAfter: 0,
|
|
89
101
|
message: 'An unknown error occurred while placing the request. Wait a moment and try again.',
|
|
90
102
|
errorType: _types2.ERROR_TYPE.SERVICE_UNAVAILABLE,
|
|
91
103
|
emitterCbExpected: true,
|
|
92
104
|
finalError: false,
|
|
93
105
|
restoreCbExpected: false,
|
|
106
|
+
retry429CbExpected: false,
|
|
94
107
|
logMsg: '500 Internal Server Error'
|
|
95
108
|
}, {
|
|
96
109
|
name: 'verify 503 error response',
|
|
97
110
|
statusCode: _types2.ERROR_CODE.SERVICE_UNAVAILABLE,
|
|
98
111
|
deviceErrorCode: 0,
|
|
99
|
-
retryAfter: 0,
|
|
100
112
|
message: 'An error occurred on the server while processing the request. Wait a moment and try again.',
|
|
101
113
|
errorType: _types2.ERROR_TYPE.SERVICE_UNAVAILABLE,
|
|
102
114
|
emitterCbExpected: true,
|
|
103
115
|
finalError: false,
|
|
104
116
|
restoreCbExpected: false,
|
|
117
|
+
retry429CbExpected: false,
|
|
105
118
|
logMsg: '503 Service Unavailable'
|
|
106
119
|
}, {
|
|
107
120
|
name: 'verify 403 response with no response body',
|
|
108
121
|
statusCode: _types2.ERROR_CODE.FORBIDDEN,
|
|
109
122
|
deviceErrorCode: 0,
|
|
110
|
-
retryAfter: 0,
|
|
111
123
|
message: 'An unauthorized action has been received. This action has been blocked. Please contact the administrator if this persists.',
|
|
112
124
|
errorType: _types2.ERROR_TYPE.FORBIDDEN_ERROR,
|
|
113
125
|
emitterCbExpected: true,
|
|
114
126
|
finalError: false,
|
|
115
127
|
restoreCbExpected: false,
|
|
128
|
+
retry429CbExpected: false,
|
|
116
129
|
logMsg: 'Error response has no body, throwing default error',
|
|
117
130
|
customBodyPresent: true,
|
|
118
131
|
body: undefined
|
|
@@ -120,67 +133,78 @@ describe('Registration Tests', function () {
|
|
|
120
133
|
name: 'verify 403 response with unknown device.errorCode',
|
|
121
134
|
statusCode: _types2.ERROR_CODE.FORBIDDEN,
|
|
122
135
|
deviceErrorCode: 0,
|
|
123
|
-
retryAfter: 0,
|
|
124
136
|
message: 'An unknown error occurred. Wait a moment and try again. Please contact the administrator if the problem persists.',
|
|
125
137
|
errorType: _types2.ERROR_TYPE.FORBIDDEN_ERROR,
|
|
126
138
|
emitterCbExpected: true,
|
|
127
139
|
finalError: false,
|
|
128
140
|
restoreCbExpected: false,
|
|
141
|
+
retry429CbExpected: false,
|
|
129
142
|
logMsg: 'Error code found : 0'
|
|
130
143
|
}, {
|
|
131
144
|
name: 'verify 403 response with code 101',
|
|
132
145
|
statusCode: _types2.ERROR_CODE.FORBIDDEN,
|
|
133
146
|
deviceErrorCode: _types2.DEVICE_ERROR_CODE.DEVICE_LIMIT_EXCEEDED,
|
|
134
|
-
retryAfter: 0,
|
|
135
147
|
message: 'User device limit exceeded',
|
|
136
148
|
errorType: _types2.ERROR_TYPE.FORBIDDEN_ERROR,
|
|
137
149
|
emitterCbExpected: false,
|
|
138
150
|
finalError: false,
|
|
139
151
|
restoreCbExpected: true,
|
|
152
|
+
retry429CbExpected: false,
|
|
140
153
|
logMsg: 'User device limit exceeded'
|
|
141
154
|
}, {
|
|
142
155
|
name: 'verify 403 response with code 102',
|
|
143
156
|
statusCode: _types2.ERROR_CODE.FORBIDDEN,
|
|
144
157
|
deviceErrorCode: _types2.DEVICE_ERROR_CODE.DEVICE_CREATION_DISABLED,
|
|
145
|
-
retryAfter: 0,
|
|
146
158
|
message: 'User is not configured for WebRTC calling. Please contact the administrator to resolve this issue.',
|
|
147
159
|
errorType: _types2.ERROR_TYPE.FORBIDDEN_ERROR,
|
|
148
160
|
emitterCbExpected: true,
|
|
149
161
|
finalError: true,
|
|
150
162
|
restoreCbExpected: false,
|
|
163
|
+
retry429CbExpected: false,
|
|
151
164
|
logMsg: 'User is not configured for WebRTC calling. Please contact the administrator to resolve this issue.'
|
|
152
165
|
}, {
|
|
153
166
|
name: 'verify 403 response with code 103',
|
|
154
167
|
statusCode: _types2.ERROR_CODE.FORBIDDEN,
|
|
155
168
|
deviceErrorCode: _types2.DEVICE_ERROR_CODE.DEVICE_CREATION_FAILED,
|
|
156
|
-
retryAfter: 0,
|
|
157
169
|
message: 'An unknown error occurred while provisioning the device. Wait a moment and try again.',
|
|
158
170
|
errorType: _types2.ERROR_TYPE.FORBIDDEN_ERROR,
|
|
159
171
|
emitterCbExpected: true,
|
|
160
172
|
finalError: false,
|
|
161
173
|
restoreCbExpected: false,
|
|
174
|
+
retry429CbExpected: false,
|
|
162
175
|
logMsg: 'An unknown error occurred while provisioning the device. Wait a moment and try again.'
|
|
163
176
|
}, {
|
|
164
177
|
name: 'verify 401 error response',
|
|
165
178
|
statusCode: _types2.ERROR_CODE.UNAUTHORIZED,
|
|
166
179
|
deviceErrorCode: 0,
|
|
167
|
-
retryAfter: 0,
|
|
168
180
|
message: 'User is unauthorized due to an expired token. Sign out, then sign back in.',
|
|
169
181
|
errorType: _types2.ERROR_TYPE.TOKEN_ERROR,
|
|
170
182
|
emitterCbExpected: true,
|
|
171
183
|
finalError: true,
|
|
172
184
|
restoreCbExpected: false,
|
|
185
|
+
retry429CbExpected: false,
|
|
173
186
|
logMsg: '401 Unauthorized'
|
|
187
|
+
}, {
|
|
188
|
+
name: 'verify 400 error response',
|
|
189
|
+
statusCode: _types2.ERROR_CODE.BAD_REQUEST,
|
|
190
|
+
deviceErrorCode: 0,
|
|
191
|
+
message: 'Invalid input. Please verify the required parameters, sign out and then sign back in with the valid data',
|
|
192
|
+
errorType: _types2.ERROR_TYPE.SERVER_ERROR,
|
|
193
|
+
emitterCbExpected: true,
|
|
194
|
+
finalError: true,
|
|
195
|
+
restoreCbExpected: false,
|
|
196
|
+
retry429CbExpected: false,
|
|
197
|
+
logMsg: '400 Bad Request'
|
|
174
198
|
}, {
|
|
175
199
|
name: 'verify unknown error response',
|
|
176
200
|
statusCode: 206,
|
|
177
201
|
deviceErrorCode: 0,
|
|
178
|
-
retryAfter: 0,
|
|
179
202
|
message: 'Unknown error',
|
|
180
203
|
errorType: _types2.ERROR_TYPE.DEFAULT,
|
|
181
204
|
emitterCbExpected: true,
|
|
182
205
|
finalError: false,
|
|
183
206
|
restoreCbExpected: false,
|
|
207
|
+
retry429CbExpected: false,
|
|
184
208
|
logMsg: 'Unknown Error'
|
|
185
209
|
}].map(function (stat) {
|
|
186
210
|
return (0, _assign.default)(stat, {
|
|
@@ -199,9 +223,11 @@ describe('Registration Tests', function () {
|
|
|
199
223
|
it.each(errorCodes)('%s', function (codeObj) {
|
|
200
224
|
var webexPayload = {
|
|
201
225
|
statusCode: codeObj.statusCode,
|
|
202
|
-
headers: {
|
|
226
|
+
headers: _objectSpread({
|
|
203
227
|
trackingid: 'webex-js-sdk_b5812e58-7246-4a9b-bf64-831bdf13b0cd_31'
|
|
204
|
-
},
|
|
228
|
+
}, codeObj.retryAfter && {
|
|
229
|
+
'retry-after': codeObj.retryAfter.toString()
|
|
230
|
+
}),
|
|
205
231
|
body: {
|
|
206
232
|
device: {
|
|
207
233
|
deviceId: '8a67806f-fc4d-446b-a131-31e71ea5b010'
|
|
@@ -226,7 +252,7 @@ describe('Registration Tests', function () {
|
|
|
226
252
|
context: logObj
|
|
227
253
|
};
|
|
228
254
|
var callClientError = new _Errors.CallingClientError(mockErrorEvent.message, mockErrorEvent.context, mockErrorEvent.type, _types.RegistrationStatus.ACTIVE);
|
|
229
|
-
(0, _Utils.handleRegistrationErrors)(webexPayload, mockEmitterCb, logObj, mockRestoreCb);
|
|
255
|
+
(0, _Utils.handleRegistrationErrors)(webexPayload, mockEmitterCb, logObj, mock429RetryCb, mockRestoreCb);
|
|
230
256
|
if (codeObj.emitterCbExpected) {
|
|
231
257
|
expect(mockEmitterCb).toBeCalledOnceWith(callClientError, codeObj.finalError);
|
|
232
258
|
}
|
|
@@ -235,6 +261,11 @@ describe('Registration Tests', function () {
|
|
|
235
261
|
} else {
|
|
236
262
|
expect(mockRestoreCb).not.toHaveBeenCalled();
|
|
237
263
|
}
|
|
264
|
+
if (codeObj.retry429CbExpected) {
|
|
265
|
+
expect(mock429RetryCb).toBeCalledOnceWith(codeObj.retryAfter, logObj.method);
|
|
266
|
+
} else {
|
|
267
|
+
expect(mock429RetryCb).not.toHaveBeenCalled();
|
|
268
|
+
}
|
|
238
269
|
expect(logSpy).toHaveBeenCalledWith("Status code: -> ".concat(codeObj.statusCode), logObj);
|
|
239
270
|
expect(logSpy).toHaveBeenCalledWith(codeObj.logMsg, logObj);
|
|
240
271
|
});
|
|
@@ -1395,46 +1426,179 @@ describe('modifySdpForIPv4', function () {
|
|
|
1395
1426
|
expect((0, _Utils.modifySdpForIPv4)(sdp).trim()).toEqual(expectedSdp.trim());
|
|
1396
1427
|
});
|
|
1397
1428
|
});
|
|
1398
|
-
describe('uploadLogs
|
|
1399
|
-
|
|
1400
|
-
|
|
1429
|
+
describe('uploadLogs', function () {
|
|
1430
|
+
var originalCrypto;
|
|
1431
|
+
var submitLogsMock;
|
|
1432
|
+
beforeEach(function () {
|
|
1433
|
+
// Save original crypto and mock it
|
|
1434
|
+
originalCrypto = global.crypto;
|
|
1435
|
+
global.crypto = {
|
|
1436
|
+
randomUUID: jest.fn().mockReturnValue('mocked-uuid-12345')
|
|
1437
|
+
};
|
|
1438
|
+
|
|
1439
|
+
// Mock the metrics manager submit function directly
|
|
1440
|
+
mockSubmitRegistrationMetric.mockClear();
|
|
1441
|
+
|
|
1442
|
+
// Mock webex.internal.support.submitLogs
|
|
1443
|
+
submitLogsMock = jest.fn().mockResolvedValue({
|
|
1444
|
+
trackingid: '1234'
|
|
1445
|
+
});
|
|
1446
|
+
webex.internal.support = {
|
|
1447
|
+
submitLogs: submitLogsMock
|
|
1448
|
+
};
|
|
1449
|
+
});
|
|
1450
|
+
afterEach(function () {
|
|
1451
|
+
// Restore original crypto
|
|
1452
|
+
global.crypto = originalCrypto;
|
|
1453
|
+
jest.clearAllMocks();
|
|
1454
|
+
});
|
|
1455
|
+
it('should upload logs and return the response', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13() {
|
|
1456
|
+
var mockMetaData, logSpy, result;
|
|
1401
1457
|
return _regenerator.default.wrap(function _callee13$(_context13) {
|
|
1402
1458
|
while (1) switch (_context13.prev = _context13.next) {
|
|
1403
1459
|
case 0:
|
|
1404
|
-
|
|
1405
|
-
|
|
1460
|
+
mockMetaData = {
|
|
1461
|
+
correlationId: 'test-correlation'
|
|
1406
1462
|
};
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1463
|
+
logSpy = jest.spyOn(_Logger.default, 'info');
|
|
1464
|
+
_context13.next = 4;
|
|
1465
|
+
return (0, _Utils.uploadLogs)(mockMetaData, true);
|
|
1466
|
+
case 4:
|
|
1467
|
+
result = _context13.sent;
|
|
1468
|
+
expect(result).toEqual({
|
|
1469
|
+
trackingid: '1234',
|
|
1470
|
+
feedbackId: 'mocked-uuid-12345'
|
|
1471
|
+
});
|
|
1472
|
+
expect(logSpy).toHaveBeenCalledWith("Logs uploaded successfully with feedbackId: mocked-uuid-12345", {
|
|
1473
|
+
file: _constants.UTILS_FILE,
|
|
1474
|
+
method: 'uploadLogs'
|
|
1475
|
+
});
|
|
1476
|
+
expect(mockSubmitRegistrationMetric).toHaveBeenCalledWith('web-calling-sdk-upload-logs-success', {
|
|
1477
|
+
fields: {
|
|
1478
|
+
call_id: undefined,
|
|
1479
|
+
calling_sdk_version: 'unknown',
|
|
1480
|
+
correlation_id: 'test-correlation',
|
|
1481
|
+
device_url: undefined,
|
|
1482
|
+
feedback_id: 'mocked-uuid-12345',
|
|
1483
|
+
mobius_url: undefined,
|
|
1484
|
+
tracking_id: '1234'
|
|
1485
|
+
},
|
|
1486
|
+
tags: {
|
|
1487
|
+
action: 'upload_logs',
|
|
1488
|
+
device_id: undefined,
|
|
1489
|
+
service_indicator: 'calling'
|
|
1490
|
+
},
|
|
1491
|
+
type: 'behavioral'
|
|
1492
|
+
});
|
|
1493
|
+
expect(submitLogsMock).toHaveBeenCalledWith(_objectSpread(_objectSpread({}, mockMetaData), {}, {
|
|
1494
|
+
feedbackId: 'mocked-uuid-12345'
|
|
1495
|
+
}), undefined, {
|
|
1496
|
+
type: 'diff'
|
|
1497
|
+
});
|
|
1498
|
+
case 9:
|
|
1413
1499
|
case "end":
|
|
1414
1500
|
return _context13.stop();
|
|
1415
1501
|
}
|
|
1416
1502
|
}, _callee13);
|
|
1417
1503
|
})));
|
|
1418
|
-
it('should
|
|
1419
|
-
var mockError, logSpy;
|
|
1504
|
+
it('should log and throw an error if the upload fails', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14() {
|
|
1505
|
+
var mockMetaData, mockError, logSpy;
|
|
1420
1506
|
return _regenerator.default.wrap(function _callee14$(_context14) {
|
|
1421
1507
|
while (1) switch (_context14.prev = _context14.next) {
|
|
1422
1508
|
case 0:
|
|
1423
|
-
|
|
1424
|
-
|
|
1509
|
+
mockMetaData = {
|
|
1510
|
+
correlationId: 'test-correlation'
|
|
1511
|
+
};
|
|
1512
|
+
mockError = new Error('Upload failed'); // Mock the submitLogs to fail
|
|
1513
|
+
submitLogsMock.mockRejectedValueOnce(mockError);
|
|
1425
1514
|
logSpy = jest.spyOn(_Logger.default, 'error');
|
|
1426
|
-
_context14.
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1515
|
+
_context14.prev = 4;
|
|
1516
|
+
_context14.next = 7;
|
|
1517
|
+
return (0, _Utils.uploadLogs)(mockMetaData, true);
|
|
1518
|
+
case 7:
|
|
1519
|
+
// If we get here, the test should fail since we expected an exception
|
|
1520
|
+
expect(true).toBe(false); // This will fail the test if no exception is thrown
|
|
1521
|
+
_context14.next = 15;
|
|
1522
|
+
break;
|
|
1523
|
+
case 10:
|
|
1524
|
+
_context14.prev = 10;
|
|
1525
|
+
_context14.t0 = _context14["catch"](4);
|
|
1526
|
+
expect(_context14.t0).toBe(mockError);
|
|
1527
|
+
expect(logSpy).toHaveBeenCalledWith(expect.objectContaining({
|
|
1528
|
+
message: expect.stringContaining('Failed to upload Logs')
|
|
1529
|
+
}), {
|
|
1430
1530
|
file: _constants.UTILS_FILE,
|
|
1431
1531
|
method: 'uploadLogs'
|
|
1432
1532
|
});
|
|
1433
|
-
|
|
1533
|
+
expect(mockSubmitRegistrationMetric).toHaveBeenCalledWith('web-calling-sdk-upload-logs-failed', {
|
|
1534
|
+
fields: {
|
|
1535
|
+
call_id: undefined,
|
|
1536
|
+
calling_sdk_version: 'unknown',
|
|
1537
|
+
correlation_id: 'Failed to upload Logs Error: Upload failed',
|
|
1538
|
+
device_url: undefined,
|
|
1539
|
+
error: undefined,
|
|
1540
|
+
feedback_id: 'test-correlation',
|
|
1541
|
+
mobius_url: undefined,
|
|
1542
|
+
tracking_id: 'mocked-uuid-12345'
|
|
1543
|
+
},
|
|
1544
|
+
tags: {
|
|
1545
|
+
action: 'upload_logs',
|
|
1546
|
+
device_id: undefined,
|
|
1547
|
+
service_indicator: 'calling'
|
|
1548
|
+
},
|
|
1549
|
+
type: 'behavioral'
|
|
1550
|
+
});
|
|
1551
|
+
case 15:
|
|
1434
1552
|
case "end":
|
|
1435
1553
|
return _context14.stop();
|
|
1436
1554
|
}
|
|
1437
|
-
}, _callee14);
|
|
1555
|
+
}, _callee14, null, [[4, 10]]);
|
|
1556
|
+
})));
|
|
1557
|
+
it('should log error and not throw an error if the upload fails with throw exception false', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15() {
|
|
1558
|
+
var mockMetaData, mockError, logSpy, result;
|
|
1559
|
+
return _regenerator.default.wrap(function _callee15$(_context15) {
|
|
1560
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1561
|
+
case 0:
|
|
1562
|
+
mockMetaData = {
|
|
1563
|
+
correlationId: 'test-correlation'
|
|
1564
|
+
};
|
|
1565
|
+
mockError = new Error('Upload failed'); // Mock the submitLogs to fail
|
|
1566
|
+
submitLogsMock.mockRejectedValueOnce(mockError);
|
|
1567
|
+
logSpy = jest.spyOn(_Logger.default, 'error');
|
|
1568
|
+
_context15.next = 6;
|
|
1569
|
+
return (0, _Utils.uploadLogs)(mockMetaData, false);
|
|
1570
|
+
case 6:
|
|
1571
|
+
result = _context15.sent;
|
|
1572
|
+
expect(result).toBeUndefined();
|
|
1573
|
+
expect(logSpy).toHaveBeenCalledWith(expect.objectContaining({
|
|
1574
|
+
message: expect.stringContaining('Failed to upload Logs')
|
|
1575
|
+
}), {
|
|
1576
|
+
file: _constants.UTILS_FILE,
|
|
1577
|
+
method: 'uploadLogs'
|
|
1578
|
+
});
|
|
1579
|
+
expect(mockSubmitRegistrationMetric).toHaveBeenCalledWith('web-calling-sdk-upload-logs-failed', {
|
|
1580
|
+
fields: {
|
|
1581
|
+
call_id: undefined,
|
|
1582
|
+
calling_sdk_version: 'unknown',
|
|
1583
|
+
correlation_id: 'Failed to upload Logs Error: Upload failed',
|
|
1584
|
+
device_url: undefined,
|
|
1585
|
+
error: undefined,
|
|
1586
|
+
feedback_id: 'test-correlation',
|
|
1587
|
+
mobius_url: undefined,
|
|
1588
|
+
tracking_id: 'mocked-uuid-12345'
|
|
1589
|
+
},
|
|
1590
|
+
tags: {
|
|
1591
|
+
action: 'upload_logs',
|
|
1592
|
+
device_id: undefined,
|
|
1593
|
+
service_indicator: 'calling'
|
|
1594
|
+
},
|
|
1595
|
+
type: 'behavioral'
|
|
1596
|
+
});
|
|
1597
|
+
case 10:
|
|
1598
|
+
case "end":
|
|
1599
|
+
return _context15.stop();
|
|
1600
|
+
}
|
|
1601
|
+
}, _callee15);
|
|
1438
1602
|
})));
|
|
1439
1603
|
});
|
|
1440
1604
|
//# sourceMappingURL=Utils.test.js.map
|