@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.
Files changed (221) hide show
  1. package/dist/module/CallHistory/CallHistory.js +20 -11
  2. package/dist/module/CallSettings/UcmBackendConnector.js +21 -8
  3. package/dist/module/CallSettings/WxCallBackendConnector.js +10 -15
  4. package/dist/module/CallingClient/CallingClient.js +83 -123
  5. package/dist/module/CallingClient/calling/call.js +73 -58
  6. package/dist/module/CallingClient/calling/callManager.js +7 -0
  7. package/dist/module/CallingClient/constants.js +3 -0
  8. package/dist/module/CallingClient/registration/register.js +85 -5
  9. package/dist/module/CallingClient/registration/webWorker.js +2 -2
  10. package/dist/module/CallingClient/registration/webWorkerStr.js +2 -2
  11. package/dist/module/Contacts/ContactsClient.js +19 -25
  12. package/dist/module/Events/impl/index.js +1 -1
  13. package/dist/module/Logger/index.js +2 -2
  14. package/dist/module/Voicemail/BroadworksBackendConnector.js +10 -18
  15. package/dist/module/Voicemail/UcmBackendConnector.js +7 -11
  16. package/dist/module/Voicemail/Voicemail.js +42 -68
  17. package/dist/module/Voicemail/WxCallBackendConnector.js +14 -28
  18. package/dist/module/common/Utils.js +31 -5
  19. package/dist/module/common/constants.js +2 -0
  20. package/dist/module/common/testUtil.js +1 -0
  21. package/dist/types/CallHistory/CallHistory.d.ts.map +1 -1
  22. package/dist/types/CallSettings/UcmBackendConnector.d.ts +1 -0
  23. package/dist/types/CallSettings/UcmBackendConnector.d.ts.map +1 -1
  24. package/dist/types/CallSettings/WxCallBackendConnector.d.ts.map +1 -1
  25. package/dist/types/CallingClient/CallingClient.d.ts.map +1 -1
  26. package/dist/types/CallingClient/calling/call.d.ts +4 -0
  27. package/dist/types/CallingClient/calling/call.d.ts.map +1 -1
  28. package/dist/types/CallingClient/calling/callManager.d.ts.map +1 -1
  29. package/dist/types/CallingClient/constants.d.ts +3 -0
  30. package/dist/types/CallingClient/constants.d.ts.map +1 -1
  31. package/dist/types/CallingClient/registration/register.d.ts +4 -0
  32. package/dist/types/CallingClient/registration/register.d.ts.map +1 -1
  33. package/dist/types/CallingClient/registration/types.d.ts +6 -0
  34. package/dist/types/CallingClient/registration/types.d.ts.map +1 -1
  35. package/dist/types/CallingClient/registration/webWorkerStr.d.ts +1 -1
  36. package/dist/types/CallingClient/registration/webWorkerStr.d.ts.map +1 -1
  37. package/dist/types/Contacts/ContactsClient.d.ts +1 -0
  38. package/dist/types/Contacts/ContactsClient.d.ts.map +1 -1
  39. package/dist/types/Logger/index.d.ts +1 -2
  40. package/dist/types/Logger/index.d.ts.map +1 -1
  41. package/dist/types/SDKConnector/types.d.ts +16 -0
  42. package/dist/types/SDKConnector/types.d.ts.map +1 -1
  43. package/dist/types/Voicemail/BroadworksBackendConnector.d.ts.map +1 -1
  44. package/dist/types/Voicemail/UcmBackendConnector.d.ts.map +1 -1
  45. package/dist/types/Voicemail/Voicemail.d.ts.map +1 -1
  46. package/dist/types/Voicemail/WxCallBackendConnector.d.ts.map +1 -1
  47. package/dist/types/common/Utils.d.ts +1 -1
  48. package/dist/types/common/Utils.d.ts.map +1 -1
  49. package/dist/types/common/constants.d.ts +2 -0
  50. package/dist/types/common/constants.d.ts.map +1 -1
  51. package/dist/types/common/testUtil.d.ts +1 -0
  52. package/dist/types/common/testUtil.d.ts.map +1 -1
  53. package/package.json +4 -4
  54. package/dist/CallHistory/CallHistory.js +0 -584
  55. package/dist/CallHistory/CallHistory.js.map +0 -1
  56. package/dist/CallHistory/CallHistory.test.js +0 -813
  57. package/dist/CallHistory/CallHistory.test.js.map +0 -1
  58. package/dist/CallHistory/callHistoryFixtures.js +0 -650
  59. package/dist/CallHistory/callHistoryFixtures.js.map +0 -1
  60. package/dist/CallHistory/constants.js +0 -38
  61. package/dist/CallHistory/constants.js.map +0 -1
  62. package/dist/CallHistory/types.js +0 -7
  63. package/dist/CallHistory/types.js.map +0 -1
  64. package/dist/CallSettings/CallSettings.js +0 -312
  65. package/dist/CallSettings/CallSettings.js.map +0 -1
  66. package/dist/CallSettings/CallSettings.test.js +0 -122
  67. package/dist/CallSettings/CallSettings.test.js.map +0 -1
  68. package/dist/CallSettings/UcmBackendConnector.js +0 -261
  69. package/dist/CallSettings/UcmBackendConnector.js.map +0 -1
  70. package/dist/CallSettings/UcmBackendConnector.test.js +0 -321
  71. package/dist/CallSettings/UcmBackendConnector.test.js.map +0 -1
  72. package/dist/CallSettings/WxCallBackendConnector.js +0 -604
  73. package/dist/CallSettings/WxCallBackendConnector.js.map +0 -1
  74. package/dist/CallSettings/WxCallBackendConnector.test.js +0 -905
  75. package/dist/CallSettings/WxCallBackendConnector.test.js.map +0 -1
  76. package/dist/CallSettings/constants.js +0 -31
  77. package/dist/CallSettings/constants.js.map +0 -1
  78. package/dist/CallSettings/testFixtures.js +0 -68
  79. package/dist/CallSettings/testFixtures.js.map +0 -1
  80. package/dist/CallSettings/types.js +0 -7
  81. package/dist/CallSettings/types.js.map +0 -1
  82. package/dist/CallingClient/CallingClient.js +0 -1071
  83. package/dist/CallingClient/CallingClient.js.map +0 -1
  84. package/dist/CallingClient/CallingClient.test.js +0 -1289
  85. package/dist/CallingClient/CallingClient.test.js.map +0 -1
  86. package/dist/CallingClient/callRecordFixtures.js +0 -101
  87. package/dist/CallingClient/callRecordFixtures.js.map +0 -1
  88. package/dist/CallingClient/calling/CallerId/index.js +0 -276
  89. package/dist/CallingClient/calling/CallerId/index.js.map +0 -1
  90. package/dist/CallingClient/calling/CallerId/index.test.js +0 -275
  91. package/dist/CallingClient/calling/CallerId/index.test.js.map +0 -1
  92. package/dist/CallingClient/calling/CallerId/types.js +0 -7
  93. package/dist/CallingClient/calling/CallerId/types.js.map +0 -1
  94. package/dist/CallingClient/calling/call.js +0 -3444
  95. package/dist/CallingClient/calling/call.js.map +0 -1
  96. package/dist/CallingClient/calling/call.test.js +0 -3260
  97. package/dist/CallingClient/calling/call.test.js.map +0 -1
  98. package/dist/CallingClient/calling/callManager.js +0 -456
  99. package/dist/CallingClient/calling/callManager.js.map +0 -1
  100. package/dist/CallingClient/calling/callManager.test.js +0 -741
  101. package/dist/CallingClient/calling/callManager.test.js.map +0 -1
  102. package/dist/CallingClient/calling/index.js +0 -30
  103. package/dist/CallingClient/calling/index.js.map +0 -1
  104. package/dist/CallingClient/calling/types.js +0 -74
  105. package/dist/CallingClient/calling/types.js.map +0 -1
  106. package/dist/CallingClient/callingClientFixtures.js +0 -143
  107. package/dist/CallingClient/callingClientFixtures.js.map +0 -1
  108. package/dist/CallingClient/constants.js +0 -237
  109. package/dist/CallingClient/constants.js.map +0 -1
  110. package/dist/CallingClient/line/index.js +0 -349
  111. package/dist/CallingClient/line/index.js.map +0 -1
  112. package/dist/CallingClient/line/line.test.js +0 -327
  113. package/dist/CallingClient/line/line.test.js.map +0 -1
  114. package/dist/CallingClient/line/types.js +0 -21
  115. package/dist/CallingClient/line/types.js.map +0 -1
  116. package/dist/CallingClient/registration/index.js +0 -19
  117. package/dist/CallingClient/registration/index.js.map +0 -1
  118. package/dist/CallingClient/registration/register.js +0 -1538
  119. package/dist/CallingClient/registration/register.js.map +0 -1
  120. package/dist/CallingClient/registration/register.test.js +0 -1537
  121. package/dist/CallingClient/registration/register.test.js.map +0 -1
  122. package/dist/CallingClient/registration/registerFixtures.js +0 -36
  123. package/dist/CallingClient/registration/registerFixtures.js.map +0 -1
  124. package/dist/CallingClient/registration/types.js +0 -7
  125. package/dist/CallingClient/registration/types.js.map +0 -1
  126. package/dist/CallingClient/registration/webWorker.js +0 -130
  127. package/dist/CallingClient/registration/webWorker.js.map +0 -1
  128. package/dist/CallingClient/registration/webWorker.test.js +0 -303
  129. package/dist/CallingClient/registration/webWorker.test.js.map +0 -1
  130. package/dist/CallingClient/registration/webWorkerStr.js +0 -15
  131. package/dist/CallingClient/registration/webWorkerStr.js.map +0 -1
  132. package/dist/CallingClient/types.js +0 -7
  133. package/dist/CallingClient/types.js.map +0 -1
  134. package/dist/CallingClient/windowsChromiumIceWarmupUtils.js +0 -142
  135. package/dist/CallingClient/windowsChromiumIceWarmupUtils.js.map +0 -1
  136. package/dist/Contacts/ContactsClient.js +0 -1215
  137. package/dist/Contacts/ContactsClient.js.map +0 -1
  138. package/dist/Contacts/ContactsClient.test.js +0 -1003
  139. package/dist/Contacts/ContactsClient.test.js.map +0 -1
  140. package/dist/Contacts/constants.js +0 -40
  141. package/dist/Contacts/constants.js.map +0 -1
  142. package/dist/Contacts/contactFixtures.js +0 -430
  143. package/dist/Contacts/contactFixtures.js.map +0 -1
  144. package/dist/Contacts/types.js +0 -43
  145. package/dist/Contacts/types.js.map +0 -1
  146. package/dist/Errors/catalog/CallError.js +0 -92
  147. package/dist/Errors/catalog/CallError.js.map +0 -1
  148. package/dist/Errors/catalog/CallingDeviceError.js +0 -86
  149. package/dist/Errors/catalog/CallingDeviceError.js.map +0 -1
  150. package/dist/Errors/catalog/ExtendedError.js +0 -44
  151. package/dist/Errors/catalog/ExtendedError.js.map +0 -1
  152. package/dist/Errors/catalog/LineError.js +0 -88
  153. package/dist/Errors/catalog/LineError.js.map +0 -1
  154. package/dist/Errors/index.js +0 -28
  155. package/dist/Errors/index.js.map +0 -1
  156. package/dist/Errors/types.js +0 -59
  157. package/dist/Errors/types.js.map +0 -1
  158. package/dist/Events/impl/index.js +0 -81
  159. package/dist/Events/impl/index.js.map +0 -1
  160. package/dist/Events/types.js +0 -107
  161. package/dist/Events/types.js.map +0 -1
  162. package/dist/Logger/index.js +0 -228
  163. package/dist/Logger/index.js.map +0 -1
  164. package/dist/Logger/index.test.js +0 -87
  165. package/dist/Logger/index.test.js.map +0 -1
  166. package/dist/Logger/types.js +0 -34
  167. package/dist/Logger/types.js.map +0 -1
  168. package/dist/Metrics/index.js +0 -535
  169. package/dist/Metrics/index.js.map +0 -1
  170. package/dist/Metrics/index.test.js +0 -463
  171. package/dist/Metrics/index.test.js.map +0 -1
  172. package/dist/Metrics/types.js +0 -64
  173. package/dist/Metrics/types.js.map +0 -1
  174. package/dist/SDKConnector/index.js +0 -103
  175. package/dist/SDKConnector/index.js.map +0 -1
  176. package/dist/SDKConnector/index.test.js +0 -9
  177. package/dist/SDKConnector/index.test.js.map +0 -1
  178. package/dist/SDKConnector/types.js +0 -7
  179. package/dist/SDKConnector/types.js.map +0 -1
  180. package/dist/SDKConnector/utils.js +0 -39
  181. package/dist/SDKConnector/utils.js.map +0 -1
  182. package/dist/SDKConnector/utils.test.js +0 -9
  183. package/dist/SDKConnector/utils.test.js.map +0 -1
  184. package/dist/Voicemail/BroadworksBackendConnector.js +0 -707
  185. package/dist/Voicemail/BroadworksBackendConnector.js.map +0 -1
  186. package/dist/Voicemail/BroadworksBackendConnector.test.js +0 -812
  187. package/dist/Voicemail/BroadworksBackendConnector.test.js.map +0 -1
  188. package/dist/Voicemail/UcmBackendConnector.js +0 -632
  189. package/dist/Voicemail/UcmBackendConnector.js.map +0 -1
  190. package/dist/Voicemail/UcmBackendConnector.test.js +0 -738
  191. package/dist/Voicemail/UcmBackendConnector.test.js.map +0 -1
  192. package/dist/Voicemail/Voicemail.js +0 -500
  193. package/dist/Voicemail/Voicemail.js.map +0 -1
  194. package/dist/Voicemail/Voicemail.test.js +0 -391
  195. package/dist/Voicemail/Voicemail.test.js.map +0 -1
  196. package/dist/Voicemail/WxCallBackendConnector.js +0 -671
  197. package/dist/Voicemail/WxCallBackendConnector.js.map +0 -1
  198. package/dist/Voicemail/WxCallBackendConnector.test.js +0 -1199
  199. package/dist/Voicemail/WxCallBackendConnector.test.js.map +0 -1
  200. package/dist/Voicemail/constants.js +0 -61
  201. package/dist/Voicemail/constants.js.map +0 -1
  202. package/dist/Voicemail/types.js +0 -7
  203. package/dist/Voicemail/types.js.map +0 -1
  204. package/dist/Voicemail/voicemailFixture.js +0 -524
  205. package/dist/Voicemail/voicemailFixture.js.map +0 -1
  206. package/dist/api.js +0 -157
  207. package/dist/api.js.map +0 -1
  208. package/dist/common/Utils.js +0 -1451
  209. package/dist/common/Utils.js.map +0 -1
  210. package/dist/common/Utils.test.js +0 -1744
  211. package/dist/common/Utils.test.js.map +0 -1
  212. package/dist/common/constants.js +0 -60
  213. package/dist/common/constants.js.map +0 -1
  214. package/dist/common/index.js +0 -19
  215. package/dist/common/index.js.map +0 -1
  216. package/dist/common/testUtil.js +0 -982
  217. package/dist/common/testUtil.js.map +0 -1
  218. package/dist/common/types.js +0 -75
  219. package/dist/common/types.js.map +0 -1
  220. package/dist/index.js +0 -321
  221. package/dist/index.js.map +0 -1
@@ -1,1744 +0,0 @@
1
- "use strict";
2
-
3
- var _Object$keys = require("@babel/runtime-corejs2/core-js/object/keys");
4
- var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs2/core-js/object/get-own-property-symbols");
5
- var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
6
- var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptors");
7
- var _Object$defineProperties = require("@babel/runtime-corejs2/core-js/object/define-properties");
8
- var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
9
- var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
10
- var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
11
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
12
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
13
- var _assign = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/assign"));
14
- var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
15
- var _uuid = require("uuid");
16
- var _calling = require("../CallingClient/calling");
17
- var _Errors = require("../Errors");
18
- var _testUtil = require("./testUtil");
19
- var _types = require("./types");
20
- var _Logger = _interopRequireDefault(require("../Logger"));
21
- var _constants = require("../CallingClient/constants");
22
- var _types2 = require("../Errors/types");
23
- var _Utils = require("./Utils");
24
- var _voicemailFixture = require("../Voicemail/voicemailFixture");
25
- var _constants2 = require("./constants");
26
- var _types3 = require("../Events/types");
27
- var _SDKConnector = _interopRequireDefault(require("../SDKConnector"));
28
- function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
29
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; } /* eslint-disable no-underscore-dangle */
30
- // Mock uuid
31
- jest.mock('uuid', function () {
32
- return {
33
- v4: jest.fn()
34
- };
35
- });
36
- var mockUuid = _uuid.v4;
37
- var mockSubmitRegistrationMetric = jest.fn();
38
- var mockEmitterCb = jest.fn();
39
- var mockRestoreCb = jest.fn();
40
- var mock429RetryCb = jest.fn();
41
- var webex = (0, _testUtil.getTestUtilsWebex)();
42
- _SDKConnector.default.setWebex(webex);
43
- webex.internal.metrics.submitClientMetrics = mockSubmitRegistrationMetric;
44
- describe('Mobius service discovery tests', function () {
45
- it('test filter mobius uris', function () {
46
- var defaultMobiusUrl = 'https://mobius.webex.com/api/v1/calling/web';
47
- var callingContext = '/calling/web/';
48
- var discoveryResponse = (0, _testUtil.getMobiusDiscoveryResponse)();
49
-
50
- // add a duplicate which will be filtered out
51
- discoveryResponse.backup.uris.push(discoveryResponse.backup.uris[0]);
52
- var filteredUris = (0, _Utils.filterMobiusUris)(discoveryResponse, defaultMobiusUrl);
53
- expect(filteredUris.primary.length).toBe(1);
54
- expect(filteredUris.backup.length).toBe(2);
55
- expect(filteredUris.primary[0]).toBe(discoveryResponse.primary.uris[0] + callingContext);
56
- expect(filteredUris.backup[0]).toBe(discoveryResponse.backup.uris[0] + callingContext);
57
- expect(filteredUris.backup[1]).toBe(defaultMobiusUrl + callingContext);
58
-
59
- /** Remove Uris and test if the defaultUrls is returned */
60
- discoveryResponse.backup.uris = [];
61
- discoveryResponse.primary.uris = [];
62
- filteredUris = (0, _Utils.filterMobiusUris)(discoveryResponse, defaultMobiusUrl);
63
- expect(filteredUris.primary.length).toBe(1);
64
- expect(filteredUris.primary[0]).toBe(defaultMobiusUrl + callingContext);
65
- expect(filteredUris.backup.length).toBe(0);
66
- });
67
- });
68
- describe('Registration Tests', function () {
69
- /**
70
- * TestCase inputs
71
- * name: TestCase name
72
- * code: Response code of type ERROR_CODE
73
- * bodyPresent: Indicates if response has a body
74
- * subErrorCode: sub error code of type CALL_ERROR_CODE
75
- * retryAfter: Indicates if retry-after header is present
76
- * message: Custom message for the error context
77
- * type: Error type based on the response code
78
- * errorLayer: Call control or media layer
79
- * cbExpected: Indicates if event emitter callback is expected
80
- * logMsg: log message.
81
- */
82
- var errorCodes = [{
83
- name: 'verify 429 error response',
84
- statusCode: _types2.ERROR_CODE.TOO_MANY_REQUESTS,
85
- deviceErrorCode: 0,
86
- retryAfter: 30,
87
- message: '',
88
- errorType: _types2.ERROR_TYPE.REGISTRATION_ERROR,
89
- emitterCbExpected: false,
90
- finalError: false,
91
- retry429CbExpected: true,
92
- restoreCbExpected: false,
93
- logMsg: '429 Too Many Requests'
94
- }, {
95
- name: 'verify 404 error response',
96
- statusCode: _types2.ERROR_CODE.DEVICE_NOT_FOUND,
97
- deviceErrorCode: 0,
98
- message: 'Webex Calling is unable to find your device. Sign out, then sign back in',
99
- errorType: _types2.ERROR_TYPE.NOT_FOUND,
100
- emitterCbExpected: true,
101
- finalError: true,
102
- restoreCbExpected: false,
103
- retry429CbExpected: false,
104
- logMsg: '404 Device Not Found'
105
- }, {
106
- name: 'verify 500 error response',
107
- statusCode: _types2.ERROR_CODE.INTERNAL_SERVER_ERROR,
108
- deviceErrorCode: 0,
109
- message: 'An unknown error occurred while placing the request. Wait a moment and try again.',
110
- errorType: _types2.ERROR_TYPE.SERVICE_UNAVAILABLE,
111
- emitterCbExpected: true,
112
- finalError: false,
113
- restoreCbExpected: false,
114
- retry429CbExpected: false,
115
- logMsg: '500 Internal Server Error'
116
- }, {
117
- name: 'verify 503 error response',
118
- statusCode: _types2.ERROR_CODE.SERVICE_UNAVAILABLE,
119
- deviceErrorCode: 0,
120
- message: 'An error occurred on the server while processing the request. Wait a moment and try again.',
121
- errorType: _types2.ERROR_TYPE.SERVICE_UNAVAILABLE,
122
- emitterCbExpected: true,
123
- finalError: false,
124
- restoreCbExpected: false,
125
- retry429CbExpected: false,
126
- logMsg: '503 Service Unavailable'
127
- }, {
128
- name: 'verify 403 response with no response body',
129
- statusCode: _types2.ERROR_CODE.FORBIDDEN,
130
- deviceErrorCode: 0,
131
- message: 'An unauthorized action has been received. This action has been blocked. Please contact the administrator if this persists.',
132
- errorType: _types2.ERROR_TYPE.FORBIDDEN_ERROR,
133
- emitterCbExpected: true,
134
- finalError: false,
135
- restoreCbExpected: false,
136
- retry429CbExpected: false,
137
- logMsg: 'Error response has no body, throwing default error',
138
- customBodyPresent: true,
139
- body: undefined
140
- }, {
141
- name: 'verify 403 response with unknown device.errorCode',
142
- statusCode: _types2.ERROR_CODE.FORBIDDEN,
143
- deviceErrorCode: 0,
144
- message: 'An unknown error occurred. Wait a moment and try again. Please contact the administrator if the problem persists.',
145
- errorType: _types2.ERROR_TYPE.FORBIDDEN_ERROR,
146
- emitterCbExpected: true,
147
- finalError: false,
148
- restoreCbExpected: false,
149
- retry429CbExpected: false,
150
- logMsg: 'Error code found : 0'
151
- }, {
152
- name: 'verify 403 response with code 101',
153
- statusCode: _types2.ERROR_CODE.FORBIDDEN,
154
- deviceErrorCode: _types2.DEVICE_ERROR_CODE.DEVICE_LIMIT_EXCEEDED,
155
- message: 'User device limit exceeded',
156
- errorType: _types2.ERROR_TYPE.FORBIDDEN_ERROR,
157
- emitterCbExpected: false,
158
- finalError: false,
159
- restoreCbExpected: true,
160
- retry429CbExpected: false,
161
- logMsg: 'User device limit exceeded'
162
- }, {
163
- name: 'verify 403 response with code 102',
164
- statusCode: _types2.ERROR_CODE.FORBIDDEN,
165
- deviceErrorCode: _types2.DEVICE_ERROR_CODE.DEVICE_CREATION_DISABLED,
166
- message: 'User is not configured for WebRTC calling. Please contact the administrator to resolve this issue.',
167
- errorType: _types2.ERROR_TYPE.FORBIDDEN_ERROR,
168
- emitterCbExpected: true,
169
- finalError: true,
170
- restoreCbExpected: false,
171
- retry429CbExpected: false,
172
- logMsg: 'User is not configured for WebRTC calling. Please contact the administrator to resolve this issue.'
173
- }, {
174
- name: 'verify 403 response with code 103',
175
- statusCode: _types2.ERROR_CODE.FORBIDDEN,
176
- deviceErrorCode: _types2.DEVICE_ERROR_CODE.DEVICE_CREATION_FAILED,
177
- message: 'An unknown error occurred while provisioning the device. Wait a moment and try again.',
178
- errorType: _types2.ERROR_TYPE.FORBIDDEN_ERROR,
179
- emitterCbExpected: true,
180
- finalError: false,
181
- restoreCbExpected: false,
182
- retry429CbExpected: false,
183
- logMsg: 'An unknown error occurred while provisioning the device. Wait a moment and try again.'
184
- }, {
185
- name: 'verify 401 error response',
186
- statusCode: _types2.ERROR_CODE.UNAUTHORIZED,
187
- deviceErrorCode: 0,
188
- message: 'User is unauthorized due to an expired token. Sign out, then sign back in.',
189
- errorType: _types2.ERROR_TYPE.TOKEN_ERROR,
190
- emitterCbExpected: true,
191
- finalError: true,
192
- restoreCbExpected: false,
193
- retry429CbExpected: false,
194
- logMsg: '401 Unauthorized'
195
- }, {
196
- name: 'verify 400 error response',
197
- statusCode: _types2.ERROR_CODE.BAD_REQUEST,
198
- deviceErrorCode: 0,
199
- message: 'Invalid input. Please verify the required parameters, sign out and then sign back in with the valid data',
200
- errorType: _types2.ERROR_TYPE.SERVER_ERROR,
201
- emitterCbExpected: true,
202
- finalError: true,
203
- restoreCbExpected: false,
204
- retry429CbExpected: false,
205
- logMsg: '400 Bad Request'
206
- }, {
207
- name: 'verify unknown error response',
208
- statusCode: 206,
209
- deviceErrorCode: 0,
210
- message: 'Unknown error',
211
- errorType: _types2.ERROR_TYPE.DEFAULT,
212
- emitterCbExpected: true,
213
- finalError: false,
214
- restoreCbExpected: false,
215
- retry429CbExpected: false,
216
- logMsg: 'Unknown Error'
217
- }].map(function (stat) {
218
- return (0, _assign.default)(stat, {
219
- toString: function toString() {
220
- return this.name;
221
- }
222
- });
223
- });
224
- var logSpy = jest.spyOn(_Logger.default, 'warn');
225
- var logObj = {
226
- file: 'CallingClient',
227
- method: _constants.REGISTER_UTIL
228
- };
229
-
230
- /* eslint-disable @typescript-eslint/no-explicit-any */
231
- it.each(errorCodes)('%s', function (codeObj) {
232
- var webexPayload = {
233
- statusCode: codeObj.statusCode,
234
- headers: _objectSpread({
235
- trackingid: 'webex-js-sdk_b5812e58-7246-4a9b-bf64-831bdf13b0cd_31'
236
- }, codeObj.retryAfter && {
237
- 'retry-after': codeObj.retryAfter.toString()
238
- }),
239
- body: {
240
- device: {
241
- deviceId: '8a67806f-fc4d-446b-a131-31e71ea5b010'
242
- },
243
- userId: '8a67806f-fc4d-446b-a131-31e71ea5b0e9',
244
- errorCode: codeObj.deviceErrorCode,
245
- devices: [{
246
- deviceId: '8a67806f-fc4d-446b-a131-31e71ea5b010',
247
- uri: 'https://mobius.webex.com/api/v1/calling/web/',
248
- status: 'active',
249
- lastSeen: '2022-04-07T18:00:40Z',
250
- addresses: ['sip:sipAddress@webex.com']
251
- }]
252
- }
253
- };
254
- if (codeObj.customBodyPresent) {
255
- webexPayload.body = codeObj.body;
256
- }
257
- var mockErrorEvent = {
258
- type: codeObj.errorType,
259
- message: codeObj.message,
260
- context: logObj
261
- };
262
- var callClientError = new _Errors.CallingClientError(mockErrorEvent.message, mockErrorEvent.context, mockErrorEvent.type, _types.RegistrationStatus.ACTIVE);
263
- (0, _Utils.handleRegistrationErrors)(webexPayload, mockEmitterCb, logObj, mock429RetryCb, mockRestoreCb);
264
- if (codeObj.emitterCbExpected) {
265
- expect(mockEmitterCb).toBeCalledOnceWith(callClientError, codeObj.finalError);
266
- }
267
- if (codeObj.restoreCbExpected) {
268
- expect(mockRestoreCb).toBeCalledOnceWith(webexPayload.body, logObj.method);
269
- } else {
270
- expect(mockRestoreCb).not.toHaveBeenCalled();
271
- }
272
- if (codeObj.retry429CbExpected) {
273
- expect(mock429RetryCb).toBeCalledOnceWith(codeObj.retryAfter, logObj.method);
274
- } else {
275
- expect(mock429RetryCb).not.toHaveBeenCalled();
276
- }
277
- expect(logSpy).toHaveBeenCalledWith("Status code: -> ".concat(codeObj.statusCode), logObj);
278
- expect(logSpy).toHaveBeenCalledWith(codeObj.logMsg, logObj);
279
- });
280
- });
281
- describe('CallingClient Error Tests', function () {
282
- var logSpy = jest.spyOn(_Logger.default, 'warn');
283
- var logObj = {
284
- file: 'CallingClient',
285
- method: 'handleCallingClientErrors'
286
- };
287
- beforeEach(function () {
288
- jest.clearAllMocks();
289
- });
290
- it('verify 401 error response for calling client', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee() {
291
- var statusCode, message, errorType, finalError, webexPayload, mockErrorEvent, callClientError, result;
292
- return _regenerator.default.wrap(function _callee$(_context) {
293
- while (1) switch (_context.prev = _context.next) {
294
- case 0:
295
- statusCode = _types2.ERROR_CODE.UNAUTHORIZED;
296
- message = 'User is unauthorized due to an expired token.';
297
- errorType = _types2.ERROR_TYPE.TOKEN_ERROR;
298
- finalError = true;
299
- webexPayload = {
300
- statusCode: statusCode,
301
- headers: {
302
- trackingid: 'webex-js-sdk_b5812e58-7246-4a9b-bf64-831bdf13b0cd_31'
303
- },
304
- body: {
305
- device: {
306
- deviceId: '8a67806f-fc4d-446b-a131-31e71ea5b010'
307
- },
308
- userId: '8a67806f-fc4d-446b-a131-31e71ea5b0e9',
309
- errorCode: 0
310
- }
311
- };
312
- mockErrorEvent = {
313
- type: errorType,
314
- message: message,
315
- context: logObj
316
- };
317
- callClientError = new _Errors.CallingClientError(mockErrorEvent.message, mockErrorEvent.context, mockErrorEvent.type, _types.RegistrationStatus.ACTIVE);
318
- _context.next = 9;
319
- return (0, _Utils.handleCallingClientErrors)(webexPayload, mockEmitterCb, logObj);
320
- case 9:
321
- result = _context.sent;
322
- expect(mockEmitterCb).toHaveBeenCalledWith(callClientError, finalError);
323
- expect(result).toBe(finalError);
324
- expect(logSpy).toHaveBeenCalledWith("Status code: -> ".concat(statusCode), logObj);
325
- expect(logSpy).toHaveBeenCalledWith('401 Unauthorized', logObj);
326
- case 14:
327
- case "end":
328
- return _context.stop();
329
- }
330
- }, _callee);
331
- })));
332
- it('verify 500 error response for calling client', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee2() {
333
- var statusCode, message, errorType, finalError, webexPayload, mockErrorEvent, callClientError, result;
334
- return _regenerator.default.wrap(function _callee2$(_context2) {
335
- while (1) switch (_context2.prev = _context2.next) {
336
- case 0:
337
- statusCode = _types2.ERROR_CODE.INTERNAL_SERVER_ERROR;
338
- message = 'An unknown error occurred while placing the request. Wait a moment and try again.';
339
- errorType = _types2.ERROR_TYPE.SERVICE_UNAVAILABLE;
340
- finalError = false;
341
- webexPayload = {
342
- statusCode: statusCode,
343
- headers: {
344
- trackingid: 'webex-js-sdk_b5812e58-7246-4a9b-bf64-831bdf13b0cd_31'
345
- },
346
- body: {
347
- device: {
348
- deviceId: '8a67806f-fc4d-446b-a131-31e71ea5b010'
349
- },
350
- userId: '8a67806f-fc4d-446b-a131-31e71ea5b0e9',
351
- errorCode: 0
352
- }
353
- };
354
- mockErrorEvent = {
355
- type: errorType,
356
- message: message,
357
- context: logObj
358
- };
359
- callClientError = new _Errors.CallingClientError(mockErrorEvent.message, mockErrorEvent.context, mockErrorEvent.type, _types.RegistrationStatus.ACTIVE);
360
- _context2.next = 9;
361
- return (0, _Utils.handleCallingClientErrors)(webexPayload, mockEmitterCb, logObj);
362
- case 9:
363
- result = _context2.sent;
364
- expect(mockEmitterCb).toHaveBeenCalledWith(callClientError, finalError);
365
- expect(result).toBe(finalError);
366
- expect(logSpy).toHaveBeenCalledWith("Status code: -> ".concat(statusCode), logObj);
367
- expect(logSpy).toHaveBeenCalledWith('500 Internal Server Error', logObj);
368
- case 14:
369
- case "end":
370
- return _context2.stop();
371
- }
372
- }, _callee2);
373
- })));
374
- it('verify unknown error response for calling client', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee3() {
375
- var statusCode, message, errorType, finalError, webexPayload, mockErrorEvent, callClientError, result;
376
- return _regenerator.default.wrap(function _callee3$(_context3) {
377
- while (1) switch (_context3.prev = _context3.next) {
378
- case 0:
379
- statusCode = 206;
380
- message = 'Unknown error';
381
- errorType = _types2.ERROR_TYPE.DEFAULT;
382
- finalError = false;
383
- webexPayload = {
384
- statusCode: statusCode,
385
- headers: {
386
- trackingid: 'webex-js-sdk_b5812e58-7246-4a9b-bf64-831bdf13b0cd_31'
387
- },
388
- body: {
389
- device: {
390
- deviceId: '8a67806f-fc4d-446b-a131-31e71ea5b010'
391
- },
392
- userId: '8a67806f-fc4d-446b-a131-31e71ea5b0e9',
393
- errorCode: 0
394
- }
395
- };
396
- mockErrorEvent = {
397
- type: errorType,
398
- message: message,
399
- context: logObj
400
- };
401
- callClientError = new _Errors.CallingClientError(mockErrorEvent.message, mockErrorEvent.context, mockErrorEvent.type, _types.RegistrationStatus.ACTIVE);
402
- _context3.next = 9;
403
- return (0, _Utils.handleCallingClientErrors)(webexPayload, mockEmitterCb, logObj);
404
- case 9:
405
- result = _context3.sent;
406
- expect(mockEmitterCb).toHaveBeenCalledWith(callClientError, finalError);
407
- expect(result).toBe(finalError);
408
- expect(logSpy).toHaveBeenCalledWith("Status code: -> ".concat(statusCode), logObj);
409
- expect(logSpy).toHaveBeenCalledWith('Unknown Error', logObj);
410
- case 14:
411
- case "end":
412
- return _context3.stop();
413
- }
414
- }, _callee3);
415
- })));
416
- });
417
- describe('Call Tests', function () {
418
- /* Error flows tests starts */
419
- var logSpy = jest.spyOn(_Logger.default, 'warn');
420
- var logObj = {
421
- file: _constants.CALL_FILE,
422
- method: 'handleCallErrors'
423
- };
424
- var deviceId = '55dfb53f-bed2-36da-8e85-cee7f02aa68e';
425
- var dest = {
426
- type: _types.CallType.URI,
427
- address: 'tel:5003'
428
- };
429
- var deleteCallFromCollection = jest.fn();
430
- var retryCallback = jest.fn();
431
- var activeUrl = 'FakeActiveUrl';
432
- var defaultServiceIndicator = _types.ServiceIndicator.CALLING;
433
- var call = new _calling.Call(activeUrl, webex, dest, _types.CallDirection.OUTBOUND, deviceId, deleteCallFromCollection, defaultServiceIndicator);
434
- var dummyCorrelationId = '8a67806f-fc4d-446b-a131-31e71ea5b010';
435
- beforeEach(function () {
436
- jest.clearAllTimers();
437
- jest.useFakeTimers();
438
- call.removeAllListeners(_types3.CALL_EVENT_KEYS.CALL_ERROR);
439
- });
440
-
441
- /**
442
- * TestCase inputs
443
- * name: TestCase name
444
- * code: Response code of type ERROR_CODE
445
- * bodyPresent: Indicates if response has a body
446
- * subErrorCode: sub error code of type CALL_ERROR_CODE
447
- * retryAfter: Indicates if retry-after header is present
448
- * message: Custom message for the error context
449
- * type: Error type based on the response code
450
- * errorLayer: Call control or media layer
451
- * cbExpected: Indicates if event emitter callback is expected
452
- * logMsg: log message.
453
- */
454
- var errorCodes = [/* 401 Unauthorized. */
455
- {
456
- name: 'verify 401 error response',
457
- code: 401,
458
- bodyPresent: true,
459
- subErrorCode: 0,
460
- retryAfter: 0,
461
- message: 'User is unauthorized due to an expired token. Sign out, then sign back in.',
462
- type: _types2.ERROR_TYPE.TOKEN_ERROR,
463
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
464
- cbExpected: true,
465
- logMsg: '401 Unauthorized'
466
- }, /* 403 error code from here. */
467
- // Without body
468
- {
469
- name: 'verify 403 error response without body',
470
- code: 403,
471
- bodyPresent: false,
472
- subErrorCode: 0,
473
- retryAfter: 0,
474
- message: 'An unauthorized action has been received. This action has been blocked. Please contact the administrator if this persists.',
475
- type: _types2.ERROR_TYPE.FORBIDDEN_ERROR,
476
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
477
- cbExpected: true,
478
- logMsg: 'Error response has no body, throwing default error'
479
- },
480
- // error body with sub error code 111
481
- {
482
- name: 'verify 403 error response with code 111',
483
- code: 403,
484
- bodyPresent: true,
485
- subErrorCode: _types2.CALL_ERROR_CODE.INVALID_STATUS_UPDATE,
486
- retryAfter: 0,
487
- message: 'An invalid status update has been received for the call. Wait a moment and try again.',
488
- type: _types2.ERROR_TYPE.FORBIDDEN_ERROR,
489
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
490
- cbExpected: true,
491
- logMsg: 'Status code: ->403'
492
- },
493
- // error body with sub error code 112
494
- {
495
- name: 'verify 403 error response with code 112',
496
- code: 403,
497
- bodyPresent: true,
498
- subErrorCode: _types2.CALL_ERROR_CODE.DEVICE_NOT_REGISTERED,
499
- retryAfter: 0,
500
- 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.',
501
- type: _types2.ERROR_TYPE.FORBIDDEN_ERROR,
502
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
503
- cbExpected: true,
504
- logMsg: 'Status code: ->403'
505
- },
506
- // error body with sub error code 113
507
- {
508
- name: 'verify 403 error response with code 113',
509
- code: 403,
510
- bodyPresent: true,
511
- subErrorCode: _types2.CALL_ERROR_CODE.CALL_NOT_FOUND,
512
- retryAfter: 0,
513
- message: 'Call is not found on the server. Wait a moment and try again.',
514
- type: _types2.ERROR_TYPE.FORBIDDEN_ERROR,
515
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
516
- cbExpected: true,
517
- logMsg: 'Status code: ->403'
518
- },
519
- // error body with sub error code 114
520
- {
521
- name: 'verify 403 error response with code 114',
522
- code: 403,
523
- bodyPresent: true,
524
- subErrorCode: _types2.CALL_ERROR_CODE.ERROR_PROCESSING,
525
- retryAfter: 0,
526
- message: 'An error occurred while processing the call on the server. Wait a moment and try again.',
527
- type: _types2.ERROR_TYPE.FORBIDDEN_ERROR,
528
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
529
- cbExpected: true,
530
- logMsg: 'Status code: ->403'
531
- },
532
- // error body with sub error code 115
533
- {
534
- name: 'verify 403 error response with code 115',
535
- code: 403,
536
- bodyPresent: true,
537
- subErrorCode: _types2.CALL_ERROR_CODE.USER_BUSY,
538
- retryAfter: 0,
539
- message: 'Called user is busy.',
540
- type: _types2.ERROR_TYPE.FORBIDDEN_ERROR,
541
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
542
- cbExpected: true,
543
- logMsg: 'Status code: ->403'
544
- },
545
- // error body with sub error code 116
546
- {
547
- name: 'verify 403 error response with code 116',
548
- code: 403,
549
- bodyPresent: true,
550
- subErrorCode: _types2.CALL_ERROR_CODE.PARSING_ERROR,
551
- retryAfter: 0,
552
- message: 'An error occurred while parsing the provided information. Wait a moment and try again.',
553
- type: _types2.ERROR_TYPE.FORBIDDEN_ERROR,
554
- errorLayer: _types2.ERROR_LAYER.MEDIA,
555
- cbExpected: true,
556
- logMsg: 'Status code: ->403'
557
- },
558
- // error body with sub error code 118
559
- {
560
- name: 'verify 403 error response with code 118',
561
- code: 403,
562
- bodyPresent: true,
563
- subErrorCode: _types2.CALL_ERROR_CODE.NOT_ACCEPTABLE,
564
- retryAfter: 0,
565
- message: 'An error occurred on the server while accepting the call. Wait a moment and try again. Please contact the administrator if this persists.',
566
- type: _types2.ERROR_TYPE.FORBIDDEN_ERROR,
567
- errorLayer: _types2.ERROR_LAYER.MEDIA,
568
- cbExpected: true,
569
- logMsg: 'Status code: ->403'
570
- },
571
- // error body with sub error code 119
572
- {
573
- name: 'verify 403 error response with code 119',
574
- code: 403,
575
- bodyPresent: true,
576
- subErrorCode: _types2.CALL_ERROR_CODE.CALL_REJECTED,
577
- retryAfter: 0,
578
- message: 'Call rejected by the server. Wait a moment and try again. Please contact the administrator if this persists.',
579
- type: _types2.ERROR_TYPE.FORBIDDEN_ERROR,
580
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
581
- cbExpected: true,
582
- logMsg: 'Status code: ->403'
583
- },
584
- // error body with sub error code 120
585
- {
586
- name: 'verify 403 error response with code 120',
587
- code: 403,
588
- bodyPresent: true,
589
- subErrorCode: _types2.CALL_ERROR_CODE.NOT_AVAILABLE,
590
- retryAfter: 0,
591
- message: 'Calling services not available. Wait a moment and try again. Please contact the administrator if this persists.',
592
- type: _types2.ERROR_TYPE.FORBIDDEN_ERROR,
593
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
594
- cbExpected: true,
595
- logMsg: 'Status code: ->403'
596
- },
597
- // error body with unknown/unhandled sub error code
598
- {
599
- name: 'verify 403 error response with unknown error code',
600
- code: 403,
601
- bodyPresent: true,
602
- subErrorCode: 999,
603
- retryAfter: 0,
604
- message: 'An unknown error occurred. Wait a moment and try again.',
605
- type: _types2.ERROR_TYPE.FORBIDDEN_ERROR,
606
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
607
- cbExpected: true,
608
- logMsg: 'Status code: ->403'
609
- }, /* 403 error code till here. */
610
- /* 503 error code from here. */
611
- // Without body
612
- {
613
- name: 'verify 503 error response without body',
614
- code: 503,
615
- bodyPresent: false,
616
- subErrorCode: 0,
617
- retryAfter: 0,
618
- message: 'An error occurred on the server while processing the request. Wait a moment and try again.',
619
- type: _types2.ERROR_TYPE.SERVICE_UNAVAILABLE,
620
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
621
- cbExpected: true,
622
- logMsg: 'Error response has no body, throwing default error'
623
- },
624
- // error body with sub error code 111
625
- {
626
- name: 'verify 503 error response with code 111',
627
- code: 503,
628
- bodyPresent: true,
629
- subErrorCode: _types2.CALL_ERROR_CODE.INVALID_STATUS_UPDATE,
630
- retryAfter: 0,
631
- message: 'An invalid status update has been received for the call. Wait a moment and try again.',
632
- type: _types2.ERROR_TYPE.SERVICE_UNAVAILABLE,
633
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
634
- cbExpected: true,
635
- logMsg: 'Status code: ->503'
636
- },
637
- // error body with sub error code 112
638
- {
639
- name: 'verify 503 error response with code 112',
640
- code: 503,
641
- bodyPresent: true,
642
- subErrorCode: _types2.CALL_ERROR_CODE.DEVICE_NOT_REGISTERED,
643
- retryAfter: 0,
644
- 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.',
645
- type: _types2.ERROR_TYPE.SERVICE_UNAVAILABLE,
646
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
647
- cbExpected: true,
648
- logMsg: 'Status code: ->503'
649
- },
650
- // error body with sub error code 113
651
- {
652
- name: 'verify 503 error response with code 113',
653
- code: 503,
654
- bodyPresent: true,
655
- subErrorCode: _types2.CALL_ERROR_CODE.CALL_NOT_FOUND,
656
- retryAfter: 0,
657
- message: 'Call is not found on the server. Wait a moment and try again.',
658
- type: _types2.ERROR_TYPE.SERVICE_UNAVAILABLE,
659
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
660
- cbExpected: true,
661
- logMsg: 'Status code: ->503'
662
- },
663
- // error body with sub error code 114
664
- {
665
- name: 'verify 503 error response with code 114',
666
- code: 503,
667
- bodyPresent: true,
668
- subErrorCode: _types2.CALL_ERROR_CODE.ERROR_PROCESSING,
669
- retryAfter: 0,
670
- message: 'An error occurred while processing the call on the server. Wait a moment and try again.',
671
- type: _types2.ERROR_TYPE.SERVICE_UNAVAILABLE,
672
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
673
- cbExpected: true,
674
- logMsg: 'Status code: ->503'
675
- },
676
- // error body with sub error code 115
677
- {
678
- name: 'verify 503 error response with code 115',
679
- code: 503,
680
- bodyPresent: true,
681
- subErrorCode: _types2.CALL_ERROR_CODE.USER_BUSY,
682
- retryAfter: 0,
683
- message: 'Called user is busy.',
684
- type: _types2.ERROR_TYPE.SERVICE_UNAVAILABLE,
685
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
686
- cbExpected: true,
687
- logMsg: 'Status code: ->503'
688
- },
689
- // error body with sub error code 116
690
- {
691
- name: 'verify 503 error response with code 116',
692
- code: 503,
693
- bodyPresent: true,
694
- subErrorCode: _types2.CALL_ERROR_CODE.PARSING_ERROR,
695
- retryAfter: 0,
696
- message: 'An error occurred while parsing the provided information. Wait a moment and try again.',
697
- type: _types2.ERROR_TYPE.SERVICE_UNAVAILABLE,
698
- errorLayer: _types2.ERROR_LAYER.MEDIA,
699
- cbExpected: true,
700
- logMsg: 'Status code: ->503'
701
- },
702
- // error body with sub error code 118
703
- {
704
- name: 'verify 503 error response with code 118',
705
- code: 503,
706
- bodyPresent: true,
707
- subErrorCode: _types2.CALL_ERROR_CODE.NOT_ACCEPTABLE,
708
- retryAfter: 0,
709
- message: 'An error occurred on the server while accepting the call. Wait a moment and try again. Please contact the administrator if this persists.',
710
- type: _types2.ERROR_TYPE.SERVICE_UNAVAILABLE,
711
- errorLayer: _types2.ERROR_LAYER.MEDIA,
712
- cbExpected: true,
713
- logMsg: 'Status code: ->503'
714
- },
715
- // error body with sub error code 119
716
- {
717
- name: 'verify 503 error response with code 119',
718
- code: 503,
719
- bodyPresent: true,
720
- subErrorCode: _types2.CALL_ERROR_CODE.CALL_REJECTED,
721
- retryAfter: 0,
722
- message: 'Call rejected by the server. Wait a moment and try again. Please contact the administrator if this persists.',
723
- type: _types2.ERROR_TYPE.SERVICE_UNAVAILABLE,
724
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
725
- cbExpected: true,
726
- logMsg: 'Status code: ->503'
727
- },
728
- // error body with sub error code 120
729
- {
730
- name: 'verify 503 error response with code 120',
731
- code: 503,
732
- bodyPresent: true,
733
- subErrorCode: _types2.CALL_ERROR_CODE.NOT_AVAILABLE,
734
- retryAfter: 0,
735
- message: 'Calling services not available. Wait a moment and try again. Please contact the administrator if this persists.',
736
- type: _types2.ERROR_TYPE.SERVICE_UNAVAILABLE,
737
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
738
- cbExpected: true,
739
- logMsg: 'Status code: ->503'
740
- },
741
- // error body with unknown/unhandled sub error code
742
- {
743
- name: 'verify 503 error response with unknown error code',
744
- code: 503,
745
- bodyPresent: true,
746
- subErrorCode: 999,
747
- retryAfter: 0,
748
- message: 'An unknown error occurred. Wait a moment and try again.',
749
- type: _types2.ERROR_TYPE.SERVICE_UNAVAILABLE,
750
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
751
- cbExpected: true,
752
- logMsg: 'Status code: ->503'
753
- },
754
- // with retry-after
755
- {
756
- name: 'verify 503 error response with retry-after',
757
- code: 503,
758
- bodyPresent: true,
759
- subErrorCode: 0,
760
- retryAfter: 60,
761
- message: 'An unknown error occurred. Wait a moment and try again.',
762
- type: _types2.ERROR_TYPE.SERVICE_UNAVAILABLE,
763
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
764
- cbExpected: false,
765
- logMsg: 'Retry Interval received: 60'
766
- }, /* 503 error code till here. */
767
- /* 404 Not Found. */
768
- {
769
- name: 'verify 404 error response',
770
- code: 404,
771
- bodyPresent: true,
772
- subErrorCode: 0,
773
- retryAfter: 0,
774
- message: 'Call is no longer active. Wait a moment and try again.',
775
- type: _types2.ERROR_TYPE.NOT_FOUND,
776
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
777
- cbExpected: true,
778
- logMsg: '404 Call Not Found'
779
- }, /* 500 Internal Server Error. */
780
- {
781
- name: 'verify 500 error response',
782
- code: 500,
783
- bodyPresent: true,
784
- subErrorCode: 0,
785
- retryAfter: 0,
786
- message: 'An unknown error occurred in the call. Wait a moment and try again.',
787
- type: _types2.ERROR_TYPE.SERVER_ERROR,
788
- errorLayer: _types2.ERROR_LAYER.MEDIA,
789
- cbExpected: true,
790
- logMsg: '500 Internal Server Error'
791
- }, /* Unknown error code. */
792
- {
793
- name: 'verify unknown error response',
794
- code: 0,
795
- bodyPresent: true,
796
- subErrorCode: 0,
797
- retryAfter: 0,
798
- message: 'An unknown error occurred in the call. Wait a moment and try again.',
799
- type: _types2.ERROR_TYPE.DEFAULT,
800
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
801
- cbExpected: false,
802
- logMsg: 'Unknown Error'
803
- }].map(function (stat) {
804
- return (0, _assign.default)(stat, {
805
- toString: function toString() {
806
- return this.name;
807
- }
808
- });
809
- });
810
-
811
- /* eslint-disable @typescript-eslint/no-explicit-any */
812
- it.each(errorCodes)('%s', function (codeObj, done) {
813
- var cbTriggered = false;
814
- var mockPayload = _objectSpread({
815
- statusCode: codeObj.code,
816
- headers: _objectSpread({
817
- trackingid: 'webex-js-sdk_b5812e58-7246-4a9b-bf64-831bdf13b0cd_31'
818
- }, codeObj.retryAfter && {
819
- 'retry-after': codeObj.retryAfter
820
- })
821
- }, codeObj.bodyPresent && {
822
- body: _objectSpread({
823
- device: {
824
- deviceId: '8a67806f-fc4d-446b-a131-31e71ea5b010'
825
- }
826
- }, codeObj.subErrorCode ? {
827
- errorCode: codeObj.subErrorCode
828
- } : {})
829
- });
830
- var mockErrorEvent = {
831
- type: codeObj.type,
832
- message: codeObj.message,
833
- context: logObj,
834
- correlationId: dummyCorrelationId,
835
- errorLayer: codeObj.errorLayer
836
- };
837
- if (codeObj.cbExpected) {
838
- call.on(_types3.CALL_EVENT_KEYS.CALL_ERROR, function (errObj) {
839
- expect(errObj).toMatchObject(mockErrorEvent);
840
- done();
841
- });
842
- } else {
843
- done();
844
- }
845
- (0, _Utils.handleCallErrors)(function (error) {
846
- call.emit(_types3.CALL_EVENT_KEYS.CALL_ERROR, error);
847
- cbTriggered = true;
848
- }, codeObj.errorLayer, retryCallback, dummyCorrelationId, mockPayload, logObj.method, logObj.file);
849
- expect(cbTriggered).toBe(codeObj.cbExpected);
850
- expect(logSpy).toBeCalledWith(codeObj.logMsg, logObj);
851
- if (codeObj.retryAfter) {
852
- expect(retryCallback).toBeCalledOnceWith(codeObj.retryAfter);
853
- } else {
854
- expect(retryCallback).not.toBeCalled();
855
- }
856
- });
857
- });
858
- describe('parseMediaQualityStatistics tests', function () {
859
- var logSpyObj = jest.spyOn(_Logger.default, 'log');
860
- var infoSpyObj = jest.spyOn(_Logger.default, 'info');
861
- var warnSpyObj = jest.spyOn(_Logger.default, 'warn');
862
- var logObj = {
863
- file: _constants.UTILS_FILE,
864
- method: _Utils.parseMediaQualityStatistics.name
865
- };
866
- var stats = (0, _testUtil.getSampleRawAndParsedMediaStats)();
867
- var statsWithVoOneWayDelayAndNw = stats.statsWithVoOneWayDelayAndNw;
868
- var statsWithoutVoOneWayDelayAndNw = stats.statsWithoutVoOneWayDelayAndNw;
869
-
870
- /**
871
- * TestCase inputs
872
- * name: TestCase name
873
- * original: Original RTCStatsReport
874
- * parsed: Parsed stats in form of CallRtpStats
875
- * logSpy: SpyInstance on the log object
876
- * logMsg: Expected log message.
877
- */
878
- var mqStats = [{
879
- name: 'Valid stats with non-zero VoOneWayDelayMs and networkType vpn',
880
- original: statsWithVoOneWayDelayAndNw.raw,
881
- parsed: statsWithVoOneWayDelayAndNw.parsed,
882
- logSpy: logSpyObj,
883
- logMsg: (0, _stringify.default)(statsWithVoOneWayDelayAndNw.parsed)
884
- }, {
885
- name: 'Valid stats with zero VoOneWayDelayMs and undefined networkType',
886
- original: statsWithoutVoOneWayDelayAndNw.raw,
887
- parsed: statsWithoutVoOneWayDelayAndNw.parsed,
888
- logSpy: logSpyObj,
889
- logMsg: (0, _stringify.default)(statsWithoutVoOneWayDelayAndNw.parsed)
890
- }, {
891
- name: 'undefined stats passed to parse function',
892
- original: undefined,
893
- parsed: _constants.DUMMY_METRICS,
894
- logSpy: infoSpyObj,
895
- logMsg: 'RTCStatsReport is null, adding dummy stats'
896
- }, {
897
- name: 'invalid metrics passed when outbound call is disconnected before a connect',
898
- original: {
899
- size: 26
900
- },
901
- parsed: _constants.DUMMY_METRICS,
902
- logSpy: warnSpyObj,
903
- logMsg: 'Caught error while parsing RTP stats, TypeError: stats.forEach is not a function'
904
- }].map(function (stat) {
905
- return (0, _assign.default)(stat, {
906
- toString: function toString() {
907
- return this.name;
908
- }
909
- });
910
- });
911
- it.each(mqStats)('%s', function (stat) {
912
- var result = (0, _Utils.parseMediaQualityStatistics)(stat.original);
913
- expect(result).toStrictEqual(stat.parsed);
914
- expect(stat.logSpy).toBeCalledOnceWith(stat.logMsg, logObj);
915
- });
916
- });
917
- describe('Voicemail Sorting Tests', function () {
918
- /* Tests Voicemail sorting in ascending and descending orders */
919
-
920
- it('verify VoiceMails sorting in Ascending order', function () {
921
- var voiceMailList = _voicemailFixture.getVoicemailListJsonWXC.body.VoiceMessagingMessages.messageInfoList.messageInfo;
922
- var sortedVoicemail = (0, _Utils.getSortedVoicemailList)(voiceMailList, _types.SORT.ASC);
923
- var voiceMailListAscOrder = _voicemailFixture.getAscVoicemailListJsonWXC.body.VoiceMessagingMessages.messageInfoList.messageInfo;
924
- expect(sortedVoicemail).toStrictEqual(voiceMailListAscOrder);
925
- });
926
- it('verify VoiceMails sorting in Descending Order', function () {
927
- var voiceMailList = _voicemailFixture.getVoicemailListJsonWXC.body.VoiceMessagingMessages.messageInfoList.messageInfo;
928
- var sortedVoicemail = (0, _Utils.getSortedVoicemailList)(voiceMailList, _types.SORT.DESC);
929
- var voiceMailListDescOrder = _voicemailFixture.getDescVoicemailListJsonWXC.body.VoiceMessagingMessages.messageInfoList.messageInfo;
930
- expect(sortedVoicemail).toStrictEqual(voiceMailListDescOrder);
931
- });
932
- });
933
- describe('resolveContact tests', function () {
934
- var scimUrl = "".concat(_constants2.WEBEX_API_BTS, "/").concat(_constants2.IDENTITY_ENDPOINT_RESOURCE, "/").concat(_constants2.SCIM_ENDPOINT_RESOURCE, "/").concat(webex.internal.device.orgId, "/").concat(_constants2.SCIM_USER_FILTER);
935
- it('Invalid CallingPartyInfo', function () {
936
- var callingPartyInfo = {};
937
- (0, _Utils.resolveContact)(callingPartyInfo).then(function (result) {
938
- expect(result).toBeNull();
939
- });
940
- });
941
- it('Resolve by userExternalId', function () {
942
- var callingPartyInfo = {};
943
- var webexSpy = jest.spyOn(webex, 'request').mockResolvedValue({
944
- statusCode: 200,
945
- body: (0, _testUtil.getSampleScimResponse)()
946
- });
947
- callingPartyInfo.userExternalId = {
948
- $: 'userExternalId'
949
- };
950
- (0, _Utils.resolveContact)(callingPartyInfo).then(function (displayInfo) {
951
- var _callingPartyInfo$use;
952
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.name).toStrictEqual('Cathy');
953
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.num).toStrictEqual('5008');
954
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.avatarSrc).toStrictEqual((0, _testUtil.getSampleScimResponse)().Resources[0].photos[0].value);
955
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.id).toStrictEqual((0, _testUtil.getSampleScimResponse)().Resources[0].id);
956
- var query = scimUrl + encodeURIComponent("id eq \"".concat((_callingPartyInfo$use = callingPartyInfo.userExternalId) === null || _callingPartyInfo$use === void 0 ? void 0 : _callingPartyInfo$use.$, "\""));
957
- expect(webexSpy).toBeCalledOnceWith(expect.objectContaining({
958
- uri: query
959
- }));
960
- });
961
- });
962
- it('Resolve by userExternalId - SCIM exception', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee4() {
963
- var _callingPartyInfo$use2;
964
- var callingPartyInfo, warnSpy, webexSpy, displayInfo, query;
965
- return _regenerator.default.wrap(function _callee4$(_context4) {
966
- while (1) switch (_context4.prev = _context4.next) {
967
- case 0:
968
- callingPartyInfo = {};
969
- warnSpy = jest.spyOn(_Logger.default, 'warn');
970
- webexSpy = jest.spyOn(webex, 'request').mockRejectedValueOnce({
971
- statusCode: 500
972
- });
973
- callingPartyInfo.userExternalId = {
974
- $: 'userExternalId'
975
- };
976
- _context4.next = 6;
977
- return (0, _Utils.resolveContact)(callingPartyInfo);
978
- case 6:
979
- displayInfo = _context4.sent;
980
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.name).toBeUndefined();
981
- expect(warnSpy).toHaveBeenCalledWith('Error response: - 500', {
982
- file: _constants.UTILS_FILE,
983
- method: 'resolveCallerIdDisplay'
984
- });
985
- query = scimUrl + encodeURIComponent("id eq \"".concat((_callingPartyInfo$use2 = callingPartyInfo.userExternalId) === null || _callingPartyInfo$use2 === void 0 ? void 0 : _callingPartyInfo$use2.$, "\""));
986
- expect(webexSpy).toBeCalledOnceWith(expect.objectContaining({
987
- uri: query
988
- }));
989
- case 11:
990
- case "end":
991
- return _context4.stop();
992
- }
993
- }, _callee4);
994
- })));
995
- it('Resolve by userExternalId - totalResults zero', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee5() {
996
- var _callingPartyInfo$use3;
997
- var callingPartyInfo, scimResponse, webexSpy, displayInfo, query;
998
- return _regenerator.default.wrap(function _callee5$(_context5) {
999
- while (1) switch (_context5.prev = _context5.next) {
1000
- case 0:
1001
- callingPartyInfo = {};
1002
- scimResponse = (0, _testUtil.getSampleScimResponse)();
1003
- scimResponse.totalResults = '0';
1004
- webexSpy = jest.spyOn(webex, 'request').mockResolvedValueOnce({
1005
- statusCode: 200,
1006
- body: scimResponse
1007
- });
1008
- callingPartyInfo.userExternalId = {
1009
- $: 'userExternalId'
1010
- };
1011
- _context5.next = 7;
1012
- return (0, _Utils.resolveContact)(callingPartyInfo);
1013
- case 7:
1014
- displayInfo = _context5.sent;
1015
- query = scimUrl + encodeURIComponent("id eq \"".concat((_callingPartyInfo$use3 = callingPartyInfo.userExternalId) === null || _callingPartyInfo$use3 === void 0 ? void 0 : _callingPartyInfo$use3.$, "\""));
1016
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.name).toBeUndefined();
1017
- expect(webexSpy).toBeCalledOnceWith(expect.objectContaining({
1018
- uri: query
1019
- }));
1020
- scimResponse.totalResults = '1';
1021
- case 12:
1022
- case "end":
1023
- return _context5.stop();
1024
- }
1025
- }, _callee5);
1026
- })));
1027
- it('Resolve by userExternalId - no primary number and no phone numbers', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee6() {
1028
- var _callingPartyInfo$use4, _displayInfo, _displayInfo2;
1029
- var callingPartyInfo, scimResponse, webexSpy, displayInfo, query, phoneNumbers;
1030
- return _regenerator.default.wrap(function _callee6$(_context6) {
1031
- while (1) switch (_context6.prev = _context6.next) {
1032
- case 0:
1033
- callingPartyInfo = {};
1034
- scimResponse = (0, _testUtil.getSampleScimResponse)();
1035
- scimResponse.Resources[0].phoneNumbers[1].primary = false;
1036
- webexSpy = jest.spyOn(webex, 'request').mockResolvedValueOnce({
1037
- statusCode: 200,
1038
- body: scimResponse
1039
- });
1040
- callingPartyInfo.userExternalId = {
1041
- $: 'userExternalId'
1042
- };
1043
- _context6.next = 7;
1044
- return (0, _Utils.resolveContact)(callingPartyInfo);
1045
- case 7:
1046
- displayInfo = _context6.sent;
1047
- query = scimUrl + encodeURIComponent("id eq \"".concat((_callingPartyInfo$use4 = callingPartyInfo.userExternalId) === null || _callingPartyInfo$use4 === void 0 ? void 0 : _callingPartyInfo$use4.$, "\""));
1048
- expect(webexSpy).toBeCalledOnceWith(expect.objectContaining({
1049
- uri: query
1050
- }));
1051
- expect((_displayInfo = displayInfo) === null || _displayInfo === void 0 ? void 0 : _displayInfo.num).toStrictEqual('5008');
1052
- webexSpy.mockReset();
1053
- scimResponse.Resources[0].phoneNumbers[1].primary = true;
1054
-
1055
- /* No phone numbers */
1056
- phoneNumbers = scimResponse.Resources[0].phoneNumbers;
1057
- scimResponse.Resources[0].phoneNumbers = [];
1058
- webex.request.mockResolvedValueOnce({
1059
- statusCode: 200,
1060
- body: scimResponse
1061
- });
1062
- _context6.next = 18;
1063
- return (0, _Utils.resolveContact)(callingPartyInfo);
1064
- case 18:
1065
- displayInfo = _context6.sent;
1066
- expect((_displayInfo2 = displayInfo) === null || _displayInfo2 === void 0 ? void 0 : _displayInfo2.num).toBeUndefined();
1067
- expect(webexSpy).toBeCalledOnceWith(expect.objectContaining({
1068
- uri: query
1069
- }));
1070
- scimResponse.Resources[0].phoneNumbers = phoneNumbers;
1071
- case 22:
1072
- case "end":
1073
- return _context6.stop();
1074
- }
1075
- }, _callee6);
1076
- })));
1077
- it('Resolve by userExternalId - no photo', function () {
1078
- var callingPartyInfo = {};
1079
- var scimResponse = (0, _testUtil.getSampleScimResponse)();
1080
- scimResponse.Resources[0].photos = [];
1081
- var webexSpy = jest.spyOn(webex, 'request').mockResolvedValue({
1082
- statusCode: 200,
1083
- body: scimResponse
1084
- });
1085
- callingPartyInfo.userExternalId = {
1086
- $: 'userExternalId'
1087
- };
1088
- (0, _Utils.resolveContact)(callingPartyInfo).then(function (displayInfo) {
1089
- var _callingPartyInfo$use5;
1090
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.name).toStrictEqual('Cathy');
1091
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.num).toStrictEqual('5008');
1092
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.avatarSrc).toStrictEqual('unknown');
1093
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.id).toStrictEqual((0, _testUtil.getSampleScimResponse)().Resources[0].id);
1094
- var query = scimUrl + encodeURIComponent("id eq \"".concat((_callingPartyInfo$use5 = callingPartyInfo.userExternalId) === null || _callingPartyInfo$use5 === void 0 ? void 0 : _callingPartyInfo$use5.$, "\""));
1095
- expect(webexSpy).toBeCalledOnceWith(expect.objectContaining({
1096
- uri: query
1097
- }));
1098
- });
1099
- });
1100
- it('Resolve with minimal response from SCIM', function () {
1101
- var callingPartyInfo = {};
1102
- var scimResponse = (0, _testUtil.getSampleMinimumScimResponse)();
1103
-
1104
- // scimResponse.Resources[0].photos = [];
1105
- var webexSpy = jest.spyOn(webex, 'request').mockResolvedValue({
1106
- statusCode: 200,
1107
- body: scimResponse
1108
- });
1109
- callingPartyInfo.userExternalId = {
1110
- $: 'userExternalId'
1111
- };
1112
- (0, _Utils.resolveContact)(callingPartyInfo).then(function (displayInfo) {
1113
- var _callingPartyInfo$use6;
1114
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.name).toBeUndefined();
1115
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.num).toBeUndefined();
1116
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.avatarSrc).toStrictEqual('unknown');
1117
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.id).toStrictEqual((0, _testUtil.getSampleMinimumScimResponse)().Resources[0].id);
1118
- var query = scimUrl + encodeURIComponent("id eq \"".concat((_callingPartyInfo$use6 = callingPartyInfo.userExternalId) === null || _callingPartyInfo$use6 === void 0 ? void 0 : _callingPartyInfo$use6.$, "\""));
1119
- expect(webexSpy).toBeCalledOnceWith(expect.objectContaining({
1120
- uri: query
1121
- }));
1122
- });
1123
- });
1124
- it('Resolve by name', function () {
1125
- var callingPartyInfo = {};
1126
- var webexSpy = jest.spyOn(webex.people, 'list').mockResolvedValue((0, _testUtil.getSamplePeopleListResponse)());
1127
- callingPartyInfo.name = {
1128
- $: 'Name'
1129
- };
1130
- (0, _Utils.resolveContact)(callingPartyInfo).then(function (displayInfo) {
1131
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.name).toStrictEqual((0, _testUtil.getSamplePeopleListResponse)().items[0].displayName);
1132
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.num).toStrictEqual((0, _testUtil.getSamplePeopleListResponse)().items[0].phoneNumbers[0].value);
1133
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.avatarSrc).toStrictEqual((0, _testUtil.getSamplePeopleListResponse)().items[0].avatar);
1134
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.id).toStrictEqual(Buffer.from((0, _testUtil.getSamplePeopleListResponse)().items[0].id, 'base64').toString('binary').split('/').pop());
1135
- expect(webexSpy).toBeCalledOnceWith(expect.objectContaining({
1136
- displayName: 'Name'
1137
- }));
1138
- });
1139
- });
1140
- it('Resolve by name - Empty Info', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee7() {
1141
- var callingPartyInfo, peopleListResponse, items, webexSpy, displayInfo;
1142
- return _regenerator.default.wrap(function _callee7$(_context7) {
1143
- while (1) switch (_context7.prev = _context7.next) {
1144
- case 0:
1145
- callingPartyInfo = {};
1146
- peopleListResponse = (0, _testUtil.getSamplePeopleListResponse)();
1147
- items = peopleListResponse.items;
1148
- peopleListResponse.items = [];
1149
- webexSpy = jest.spyOn(webex.people, 'list').mockResolvedValueOnce(peopleListResponse);
1150
- callingPartyInfo.name = {
1151
- $: 'Name'
1152
- };
1153
- _context7.next = 8;
1154
- return (0, _Utils.resolveContact)(callingPartyInfo);
1155
- case 8:
1156
- displayInfo = _context7.sent;
1157
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.name).toBeUndefined();
1158
- expect(webexSpy).toBeCalledOnceWith(expect.objectContaining({
1159
- displayName: 'Name'
1160
- }));
1161
- peopleListResponse.items = items;
1162
- case 12:
1163
- case "end":
1164
- return _context7.stop();
1165
- }
1166
- }, _callee7);
1167
- })));
1168
- it('Resolve by name - ID as plain UUID instead of part of URI', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee8() {
1169
- var _displayInfo3, _displayInfo4, _displayInfo5, _displayInfo6, _displayInfo7, _displayInfo8;
1170
- var callingPartyInfo, peopleListResponse, id, webexSpy, displayInfo;
1171
- return _regenerator.default.wrap(function _callee8$(_context8) {
1172
- while (1) switch (_context8.prev = _context8.next) {
1173
- case 0:
1174
- callingPartyInfo = {};
1175
- peopleListResponse = (0, _testUtil.getSamplePeopleListResponse)();
1176
- id = peopleListResponse.items[0].id;
1177
- /* Yjg1M2JiZDEtMTEzNi00ZDI1LTkzOGQtMGMzNzUzMWIxMjMz -> b853bbd1-1136-4d25-938d-0c37531b1233 */
1178
- peopleListResponse.items[0].id = 'Yjg1M2JiZDEtMTEzNi00ZDI1LTkzOGQtMGMzNzUzMWIxMjMz';
1179
- webexSpy = jest.spyOn(webex.people, 'list').mockResolvedValueOnce(peopleListResponse);
1180
- callingPartyInfo.name = {
1181
- $: 'Name'
1182
- };
1183
- _context8.next = 8;
1184
- return (0, _Utils.resolveContact)(callingPartyInfo);
1185
- case 8:
1186
- displayInfo = _context8.sent;
1187
- expect(webexSpy).toBeCalledOnceWith(expect.objectContaining({
1188
- displayName: 'Name'
1189
- }));
1190
- expect((_displayInfo3 = displayInfo) === null || _displayInfo3 === void 0 ? void 0 : _displayInfo3.name).toStrictEqual(peopleListResponse.items[0].displayName);
1191
- expect((_displayInfo4 = displayInfo) === null || _displayInfo4 === void 0 ? void 0 : _displayInfo4.num).toStrictEqual(peopleListResponse.items[0].phoneNumbers[0].value);
1192
- expect((_displayInfo5 = displayInfo) === null || _displayInfo5 === void 0 ? void 0 : _displayInfo5.avatarSrc).toStrictEqual(peopleListResponse.items[0].avatar);
1193
- expect((_displayInfo6 = displayInfo) === null || _displayInfo6 === void 0 ? void 0 : _displayInfo6.id).toStrictEqual(Buffer.from(peopleListResponse.items[0].id, 'base64').toString('binary').split('/').pop());
1194
- webexSpy.mockReset();
1195
-
1196
- /* Also test empty id */
1197
- peopleListResponse.items[0].id = '';
1198
- webex.people.list.mockResolvedValueOnce(peopleListResponse);
1199
- _context8.next = 19;
1200
- return (0, _Utils.resolveContact)(callingPartyInfo);
1201
- case 19:
1202
- displayInfo = _context8.sent;
1203
- expect((_displayInfo7 = displayInfo) === null || _displayInfo7 === void 0 ? void 0 : _displayInfo7.id).toStrictEqual('');
1204
- expect((_displayInfo8 = displayInfo) === null || _displayInfo8 === void 0 ? void 0 : _displayInfo8.name).toStrictEqual(peopleListResponse.items[0].displayName);
1205
- expect(webexSpy).toBeCalledOnceWith(expect.objectContaining({
1206
- displayName: 'Name'
1207
- }));
1208
- peopleListResponse.items[0].id = id;
1209
- case 24:
1210
- case "end":
1211
- return _context8.stop();
1212
- }
1213
- }, _callee8);
1214
- })));
1215
- it('Resolve by name - Phone numbers no match for type - work', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee9() {
1216
- var callingPartyInfo, peopleListResponse, phoneNumbers, webexSpy, displayInfo;
1217
- return _regenerator.default.wrap(function _callee9$(_context9) {
1218
- while (1) switch (_context9.prev = _context9.next) {
1219
- case 0:
1220
- callingPartyInfo = {};
1221
- peopleListResponse = (0, _testUtil.getSamplePeopleListResponse)();
1222
- phoneNumbers = peopleListResponse.items[0].phoneNumbers;
1223
- peopleListResponse.items[0].phoneNumbers[0].type = 'mobile';
1224
- peopleListResponse.items[0].phoneNumbers[1].type = 'mobile';
1225
- webexSpy = jest.spyOn(webex.people, 'list').mockResolvedValueOnce(peopleListResponse);
1226
- callingPartyInfo.name = {
1227
- $: 'Name'
1228
- };
1229
- _context9.next = 9;
1230
- return (0, _Utils.resolveContact)(callingPartyInfo);
1231
- case 9:
1232
- displayInfo = _context9.sent;
1233
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.name).toStrictEqual(peopleListResponse.items[0].displayName);
1234
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.num).toStrictEqual(peopleListResponse.items[0].phoneNumbers[0].value);
1235
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.avatarSrc).toStrictEqual(peopleListResponse.items[0].avatar);
1236
- expect(webexSpy).toBeCalledOnceWith(expect.objectContaining({
1237
- displayName: 'Name'
1238
- }));
1239
- peopleListResponse.items[0].phoneNumbers = phoneNumbers;
1240
- case 15:
1241
- case "end":
1242
- return _context9.stop();
1243
- }
1244
- }, _callee9);
1245
- })));
1246
- it('Resolve by name - Phone numbers empty', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee0() {
1247
- var callingPartyInfo, peopleListResponse, phoneNumbers, webexSpy, displayInfo;
1248
- return _regenerator.default.wrap(function _callee0$(_context0) {
1249
- while (1) switch (_context0.prev = _context0.next) {
1250
- case 0:
1251
- callingPartyInfo = {};
1252
- peopleListResponse = (0, _testUtil.getSamplePeopleListResponse)();
1253
- phoneNumbers = peopleListResponse.items[0].phoneNumbers;
1254
- peopleListResponse.items[0].phoneNumbers = [];
1255
- webexSpy = jest.spyOn(webex.people, 'list').mockResolvedValueOnce(peopleListResponse);
1256
- callingPartyInfo.name = {
1257
- $: 'Name'
1258
- };
1259
- _context0.next = 8;
1260
- return (0, _Utils.resolveContact)(callingPartyInfo);
1261
- case 8:
1262
- displayInfo = _context0.sent;
1263
- expect(webexSpy).toBeCalledOnceWith(expect.objectContaining({
1264
- displayName: 'Name'
1265
- }));
1266
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.name).toStrictEqual(peopleListResponse.items[0].displayName);
1267
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.num).toBeUndefined();
1268
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.avatarSrc).toStrictEqual(peopleListResponse.items[0].avatar);
1269
- peopleListResponse.items[0].phoneNumbers = phoneNumbers;
1270
- case 14:
1271
- case "end":
1272
- return _context0.stop();
1273
- }
1274
- }, _callee0);
1275
- })));
1276
- });
1277
- describe('Store and Fetch voicemail tests', function () {
1278
- /* Tests Voicemail pagination - storing voicemail list to and fetching from session storage */
1279
- var dummyContext = 'dummy';
1280
- var logContext = {
1281
- file: 'voicemail',
1282
- method: 'fetchVoicemail'
1283
- };
1284
- var getEncryptedVoicemail = function getEncryptedVoicemail(vmList) {
1285
- return Buffer.from((0, _stringify.default)(vmList), 'utf8').toString('base64');
1286
- };
1287
- var getDecryptedVoicemail = function getDecryptedVoicemail() {
1288
- var decryptedList = JSON.parse(Buffer.from(sessionStorage.getItem(dummyContext), 'base64').toString('utf8'));
1289
- return decryptedList;
1290
- };
1291
- beforeAll(function () {
1292
- // Mock storage
1293
- var vmListStorage = {};
1294
- global.Storage.prototype.setItem = jest.fn(function (key, value) {
1295
- vmListStorage[key] = value;
1296
- });
1297
- global.Storage.prototype.getItem = jest.fn(function (key) {
1298
- return vmListStorage[key];
1299
- });
1300
- });
1301
- it('verify saving Voicemails in session storage', function () {
1302
- var voicemailList = _voicemailFixture.getVoicemailListJsonWXC.body.VoiceMessagingMessages.messageInfoList.messageInfo;
1303
- (0, _Utils.storeVoicemailList)(dummyContext, voicemailList);
1304
- var voicemailFromSessionStorage = getDecryptedVoicemail();
1305
- expect(global.sessionStorage.setItem).toHaveBeenCalledTimes(1);
1306
- expect(voicemailFromSessionStorage).toEqual(voicemailList);
1307
- });
1308
- it('verify fetching all 5 voicemails from session storage', function () {
1309
- var voicemailList = _voicemailFixture.getVoicemailListJsonWXC.body.VoiceMessagingMessages.messageInfoList.messageInfo;
1310
- var encryptedVm = getEncryptedVoicemail(voicemailList);
1311
- global.sessionStorage.setItem(dummyContext, encryptedVm.toString());
1312
- var voicemailFromSessionStorage = (0, _Utils.fetchVoicemailList)(dummyContext, 0, 5, logContext);
1313
- expect(global.Storage.prototype.getItem).toHaveBeenCalledTimes(1);
1314
- expect(voicemailFromSessionStorage).toEqual({
1315
- messages: voicemailList,
1316
- moreVMAvailable: false
1317
- });
1318
- });
1319
- it('verify fetching first 3 VoiceMails from session storage', function () {
1320
- var voicemailList = _voicemailFixture.getVoicemailListJsonWXC.body.VoiceMessagingMessages.messageInfoList.messageInfo;
1321
- var encryptedVm = getEncryptedVoicemail(voicemailList);
1322
- global.sessionStorage.setItem(dummyContext, encryptedVm.toString());
1323
- var voicemailFromSessionStorage = (0, _Utils.fetchVoicemailList)(dummyContext, 0, 3, logContext);
1324
- expect(global.Storage.prototype.getItem).toHaveBeenCalledTimes(1);
1325
- expect(voicemailFromSessionStorage).toEqual({
1326
- messages: voicemailList.slice(0, 3),
1327
- moreVMAvailable: true
1328
- });
1329
- });
1330
- it('verify fetching 2nd and 3rd Voicemails from session storage', function () {
1331
- var voicemailList = _voicemailFixture.getVoicemailListJsonWXC.body.VoiceMessagingMessages.messageInfoList.messageInfo;
1332
- var encryptedVm = getEncryptedVoicemail(voicemailList);
1333
- global.sessionStorage.setItem(dummyContext, encryptedVm.toString());
1334
- var voicemailFromSessionStorage = (0, _Utils.fetchVoicemailList)(dummyContext, 1, 2, logContext);
1335
- expect(global.Storage.prototype.getItem).toHaveBeenCalledTimes(1);
1336
- expect(voicemailFromSessionStorage).toEqual({
1337
- messages: voicemailList.slice(1, 3),
1338
- moreVMAvailable: true
1339
- });
1340
- });
1341
- it('verify fetch Voicemails with offset limit more than the available ones from session storage', function () {
1342
- var voicemailList = [];
1343
- var encryptedVm = getEncryptedVoicemail(voicemailList);
1344
- global.sessionStorage.setItem(dummyContext, encryptedVm.toString());
1345
- var voicemailFromSessionStorage = (0, _Utils.fetchVoicemailList)(dummyContext, 1, 5, logContext);
1346
- expect(global.Storage.prototype.getItem).toHaveBeenCalledTimes(1);
1347
- expect(voicemailFromSessionStorage).toEqual({
1348
- messages: voicemailList.slice(1, 5),
1349
- moreVMAvailable: false
1350
- });
1351
- });
1352
- it('verify fetching Voicemails when it is []', function () {
1353
- var voicemailFromSessionStorage = (0, _Utils.fetchVoicemailList)(dummyContext, 1, 5, logContext);
1354
- expect(global.Storage.prototype.getItem).toHaveBeenCalledTimes(1);
1355
- expect(voicemailFromSessionStorage).toEqual({
1356
- messages: [],
1357
- moreVMAvailable: false
1358
- });
1359
- });
1360
- it('verify fetching Voicemails when there is exception', function () {
1361
- var voiceMailList = '$%%ˆ';
1362
- var logSpy = jest.spyOn(_Logger.default, 'warn');
1363
- global.sessionStorage.setItem(dummyContext, voiceMailList);
1364
- var voicemailFromSessionStorage = (0, _Utils.fetchVoicemailList)(dummyContext, 1, 5, logContext);
1365
- expect(global.Storage.prototype.getItem).toBeCalledOnceWith('dummy');
1366
- expect(logSpy).toHaveBeenCalledTimes(2);
1367
- expect(logSpy).toHaveBeenCalledWith('Caught exception while fetching voicemail from storage. SyntaxError: Unexpected end of JSON input', logContext);
1368
- expect(logSpy).toHaveBeenCalledWith('422 Exception has occurred', {});
1369
- expect(voicemailFromSessionStorage).toEqual({
1370
- messages: [],
1371
- moreVMAvailable: false
1372
- });
1373
- });
1374
- });
1375
- describe('Infer id from UUID Tests', function () {
1376
- /* Tests conversion of UUID to hydra Id */
1377
-
1378
- it('verify encoding of userId to personId', function () {
1379
- var uuidVal = '14533573-f6aa-429d-b4fe-58aa04a2b631';
1380
- var hydraId = (0, _Utils.inferIdFromUuid)(uuidVal, _types.DecodeType.PEOPLE);
1381
- var uuidAgain = Buffer.from(hydraId, 'base64').toString('binary');
1382
- expect("".concat(_constants2.INFER_ID_CONSTANT, "/").concat(_types.DecodeType.PEOPLE, "/").concat(uuidVal)).toStrictEqual(uuidAgain);
1383
- });
1384
- it('verify encoding of orgId', function () {
1385
- var orgId = '24533573-f6aa-429d-b4fe-58aa04a2b630';
1386
- var encodedOrgId = (0, _Utils.inferIdFromUuid)(orgId, _types.DecodeType.ORGANIZATION);
1387
- var orgIdAgain = Buffer.from(encodedOrgId, 'base64').toString('binary');
1388
- expect("".concat(_constants2.INFER_ID_CONSTANT, "/").concat(_types.DecodeType.ORGANIZATION, "/").concat(orgId)).toStrictEqual(orgIdAgain);
1389
- });
1390
- });
1391
- describe('Get endpoint by CALLING_BACKEND tests', function () {
1392
- it('verify invalid calling backend ucm for xsi endpoint', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee1() {
1393
- return _regenerator.default.wrap(function _callee1$(_context1) {
1394
- while (1) switch (_context1.prev = _context1.next) {
1395
- case 0:
1396
- _context1.t0 = expect;
1397
- _context1.next = 3;
1398
- return (0, _Utils.getXsiActionEndpoint)(webex, {
1399
- file: 'testFile',
1400
- method: 'testMethod'
1401
- }, _types.CALLING_BACKEND.UCM);
1402
- case 3:
1403
- _context1.t1 = _context1.sent;
1404
- (0, _context1.t0)(_context1.t1).toBeInstanceOf(Error);
1405
- case 5:
1406
- case "end":
1407
- return _context1.stop();
1408
- }
1409
- }, _callee1);
1410
- })));
1411
- it('verify invalid calling backend wxc for vg endpoint', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee10() {
1412
- return _regenerator.default.wrap(function _callee10$(_context10) {
1413
- while (1) switch (_context10.prev = _context10.next) {
1414
- case 0:
1415
- _context10.t0 = expect;
1416
- _context10.next = 3;
1417
- return (0, _Utils.getVgActionEndpoint)(webex, _types.CALLING_BACKEND.WXC);
1418
- case 3:
1419
- _context10.t1 = _context10.sent;
1420
- (0, _context10.t0)(_context10.t1).toBeInstanceOf(Error);
1421
- case 5:
1422
- case "end":
1423
- return _context10.stop();
1424
- }
1425
- }, _callee10);
1426
- })));
1427
- });
1428
- describe('Get XSI Action Endpoint tests', function () {
1429
- var mockWebex = {
1430
- request: jest.fn(),
1431
- internal: {
1432
- services: {
1433
- _serviceUrls: {
1434
- wdm: 'https://fake-webex-url.com'
1435
- }
1436
- }
1437
- }
1438
- };
1439
- var loggerContext = {
1440
- file: 'testFile',
1441
- method: 'testMethod'
1442
- };
1443
- it('should return xsiEndpoint for BWRKS backend when URL ends with /v2.0', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee11() {
1444
- var mockResponse, xsiEndpoint;
1445
- return _regenerator.default.wrap(function _callee11$(_context11) {
1446
- while (1) switch (_context11.prev = _context11.next) {
1447
- case 0:
1448
- mockResponse = {
1449
- body: {
1450
- devices: [{
1451
- settings: {
1452
- broadworksXsiActionsUrl: 'https://fake-broadworks-url.com/v2.0'
1453
- }
1454
- }]
1455
- }
1456
- };
1457
- mockWebex.request.mockResolvedValue(mockResponse);
1458
- _context11.next = 4;
1459
- return (0, _Utils.getXsiActionEndpoint)(mockWebex, loggerContext, _types.CALLING_BACKEND.BWRKS);
1460
- case 4:
1461
- xsiEndpoint = _context11.sent;
1462
- expect(mockWebex.request).toHaveBeenCalledTimes(1);
1463
- expect(xsiEndpoint).toBe('https://fake-broadworks-url.com');
1464
- case 7:
1465
- case "end":
1466
- return _context11.stop();
1467
- }
1468
- }, _callee11);
1469
- })));
1470
- it('should return xsiEndpoint for BWRKS backend when URL ends with /v2.0/', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee12() {
1471
- var mockResponse, xsiEndpoint;
1472
- return _regenerator.default.wrap(function _callee12$(_context12) {
1473
- while (1) switch (_context12.prev = _context12.next) {
1474
- case 0:
1475
- mockResponse = {
1476
- body: {
1477
- devices: [{
1478
- settings: {
1479
- broadworksXsiActionsUrl: 'https://fake-broadworks-url.com/v2.0/'
1480
- }
1481
- }]
1482
- }
1483
- };
1484
- mockWebex.request.mockResolvedValue(mockResponse);
1485
- _context12.next = 4;
1486
- return (0, _Utils.getXsiActionEndpoint)(mockWebex, loggerContext, _types.CALLING_BACKEND.BWRKS);
1487
- case 4:
1488
- xsiEndpoint = _context12.sent;
1489
- expect(mockWebex.request).toHaveBeenCalledTimes(1);
1490
- expect(xsiEndpoint).toBe('https://fake-broadworks-url.com');
1491
- case 7:
1492
- case "end":
1493
- return _context12.stop();
1494
- }
1495
- }, _callee12);
1496
- })));
1497
- it('should return xsiEndpoint for BWRKS backend when URL does not end with any version', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee13() {
1498
- var mockResponse, xsiEndpoint;
1499
- return _regenerator.default.wrap(function _callee13$(_context13) {
1500
- while (1) switch (_context13.prev = _context13.next) {
1501
- case 0:
1502
- mockResponse = {
1503
- body: {
1504
- devices: [{
1505
- settings: {
1506
- broadworksXsiActionsUrl: 'https://fake-broadworks-url.com'
1507
- }
1508
- }]
1509
- }
1510
- };
1511
- mockWebex.request.mockResolvedValue(mockResponse);
1512
- _context13.next = 4;
1513
- return (0, _Utils.getXsiActionEndpoint)(mockWebex, loggerContext, _types.CALLING_BACKEND.BWRKS);
1514
- case 4:
1515
- xsiEndpoint = _context13.sent;
1516
- expect(mockWebex.request).toHaveBeenCalledTimes(1);
1517
- expect(xsiEndpoint).toBe('https://fake-broadworks-url.com');
1518
- case 7:
1519
- case "end":
1520
- return _context13.stop();
1521
- }
1522
- }, _callee13);
1523
- })));
1524
- });
1525
- describe('modifySdpForIPv4', function () {
1526
- it('should return original SDP if input is empty', function () {
1527
- expect((0, _Utils.modifySdpForIPv4)('')).toBe('');
1528
- });
1529
- it('should return original SDP if there is no IPv6 c= line', function () {
1530
- var sdp = "v=0\no=- 12345 67890 IN IP4 192.168.1.1\n\ns=Test Session";
1531
- expect((0, _Utils.modifySdpForIPv4)(sdp)).toEqual(sdp);
1532
- });
1533
- it('should replace IPv6 c= line with default IPv4 if no IPv4 candidate exists', function () {
1534
- var sdp = "v=0\n o=- 12345 67890 IN IP6 2001:db8::1\n s=Test Session\n c=IN IP6 2001:db8::1\n a=candidate:1 1 UDP 2122260223 2001:db8::1 3478 typ host";
1535
- var expectedSdp = "v=0\no=- 12345 67890 IN IP6 2001:db8::1\ns=Test Session\nc=IN IP4 192.1.1.1\na=candidate:1 1 UDP 2122260223 2001:db8::1 3478 typ host\na=candidate:2 1 UDP 2122260223 192.1.1.1 3478 typ host generation 0 network-id 1 network-cost 10";
1536
- var result = (0, _Utils.modifySdpForIPv4)(sdp);
1537
- expect(result).toEqual(expectedSdp);
1538
- });
1539
- it('should replace IPv6 c= line with an existing IPv4 candidate address', function () {
1540
- var sdp = "v=0\n o=- 12345 67890 IN IP6 2001:db8::1\n s=Test Session\n c=IN IP6 2001:db8::1\n a=candidate:1 1 UDP 2122260223 192.168.1.2 3478 typ host";
1541
- var expectedSdp = "v=0\no=- 12345 67890 IN IP6 2001:db8::1\ns=Test Session\nc=IN IP4 192.168.1.2\na=candidate:1 1 UDP 2122260223 192.168.1.2 3478 typ host";
1542
- expect((0, _Utils.modifySdpForIPv4)(sdp).trim()).toEqual(expectedSdp.trim());
1543
- });
1544
- it('should correctly handle both UDP and TCP candidates by adding only one IPv4 candidate UDP first', function () {
1545
- var sdp = "v=0\n o=- 12345 67890 IN IP6 2001:db8::1\n s=Test Session\n c=IN IP6 2001:db8::1\n a=candidate:1 1 UDP 2122260223 2001:db8::1 3478 typ host\n a=candidate:2 1 TCP 2122260223 2001:db8::2 3479 typ host";
1546
- var expectedSdp = "v=0\no=- 12345 67890 IN IP6 2001:db8::1\ns=Test Session\nc=IN IP4 192.1.1.1\na=candidate:1 1 UDP 2122260223 2001:db8::1 3478 typ host\na=candidate:2 1 UDP 2122260223 192.1.1.1 3478 typ host generation 0 network-id 1 network-cost 10\na=candidate:2 1 TCP 2122260223 2001:db8::2 3479 typ host\n";
1547
- expect((0, _Utils.modifySdpForIPv4)(sdp).trim()).toEqual(expectedSdp.trim());
1548
- });
1549
- it('should correctly handle both UDP and TCP candidates by adding only one IPv4 candidate TCP first', function () {
1550
- var sdp = "v=0\n o=- 12345 67890 IN IP6 2001:db8::1\n s=Test Session\n c=IN IP6 2001:db8::1\n a=candidate:1 1 TCP 2122260223 2001:db8::2 3479 typ host\n a=candidate:1 1 UDP 2122260223 2001:db8::1 3478 typ host";
1551
- var expectedSdp = "v=0\no=- 12345 67890 IN IP6 2001:db8::1\ns=Test Session\nc=IN IP4 192.1.1.1\na=candidate:1 1 TCP 2122260223 2001:db8::2 3479 typ host\na=candidate:2 1 TCP 2122260223 192.1.1.1 3479 typ host generation 0 network-id 1 network-cost 10\na=candidate:1 1 UDP 2122260223 2001:db8::1 3478 typ host";
1552
- expect((0, _Utils.modifySdpForIPv4)(sdp).trim()).toEqual(expectedSdp.trim());
1553
- });
1554
- it('should replace all IPv6 c= line if multiple exist', function () {
1555
- var sdp = "v=0\n o=- 12345 67890 IN IP6 2001:db8::1\n s=Test Session\n c=IN IP6 2001:db8::1\n c=IN IP6 2001:db8::2\n a=candidate:1 1 UDP 2122260223 2001:db8::1 3478 typ host";
1556
- var expectedSdp = "v=0\no=- 12345 67890 IN IP6 2001:db8::1\ns=Test Session\nc=IN IP4 192.1.1.1\nc=IN IP4 192.1.1.1\na=candidate:1 1 UDP 2122260223 2001:db8::1 3478 typ host\na=candidate:2 1 UDP 2122260223 192.1.1.1 3478 typ host generation 0 network-id 1 network-cost 10";
1557
- expect((0, _Utils.modifySdpForIPv4)(sdp).trim()).toEqual(expectedSdp.trim());
1558
- });
1559
- it('should not modify SDP if IPv6 c= line is absent and IPv4 candidate already exists', function () {
1560
- var sdp = "v=0\no=- 12345 67890 IN IP4 192.168.1.1\ns=Test Session\nc=IN IP4 192.168.1.1\na=candidate:1 1 UDP 2122260223 192.168.1.1 3478 typ host";
1561
- expect((0, _Utils.modifySdpForIPv4)(sdp).trim()).toEqual(sdp.trim());
1562
- });
1563
- it('should handle malformed SDP gracefully and return unmodified input', function () {
1564
- var malformedSdp = "random text without proper format";
1565
- expect((0, _Utils.modifySdpForIPv4)(malformedSdp).trim()).toEqual(malformedSdp.trim());
1566
- });
1567
- it('should handle an SDP with both IP6 and IP4 c= lines correctly', function () {
1568
- var sdp = "v=0\n o=- 12345 67890 IN IP6 2001:db8::1\n s=Test Session\n c=IN IP6 2001:db8::1\n c=IN IP4 192.168.1.3\n a=candidate:1 1 UDP 2122260223 192.168.1.3 3478 typ host";
1569
- var expectedSdp = "v=0\no=- 12345 67890 IN IP6 2001:db8::1\ns=Test Session\nc=IN IP4 192.168.1.3\nc=IN IP4 192.168.1.3\na=candidate:1 1 UDP 2122260223 192.168.1.3 3478 typ host";
1570
- expect((0, _Utils.modifySdpForIPv4)(sdp).trim()).toEqual(expectedSdp.trim());
1571
- });
1572
- });
1573
- describe('uploadLogs', function () {
1574
- var submitLogsMock;
1575
- beforeEach(function () {
1576
- // Mock uuid to return a consistent value
1577
- mockUuid.mockReturnValue('mocked-uuid-12345');
1578
- // Mock the metrics manager submit function directly
1579
- mockSubmitRegistrationMetric.mockClear();
1580
-
1581
- // Mock webex.internal.support.submitLogs
1582
- submitLogsMock = jest.fn().mockResolvedValue({
1583
- trackingid: '1234'
1584
- });
1585
- webex.internal.support = {
1586
- submitLogs: submitLogsMock
1587
- };
1588
- });
1589
- afterEach(function () {
1590
- jest.clearAllMocks();
1591
- });
1592
- it('should upload logs and return the response', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee14() {
1593
- var mockMetaData, logSpy, result;
1594
- return _regenerator.default.wrap(function _callee14$(_context14) {
1595
- while (1) switch (_context14.prev = _context14.next) {
1596
- case 0:
1597
- mockMetaData = {
1598
- correlationId: 'test-correlation'
1599
- };
1600
- logSpy = jest.spyOn(_Logger.default, 'info');
1601
- _context14.next = 4;
1602
- return (0, _Utils.uploadLogs)(mockMetaData, true);
1603
- case 4:
1604
- result = _context14.sent;
1605
- expect(result).toEqual({
1606
- trackingid: '1234',
1607
- feedbackId: 'mocked-uuid-12345'
1608
- });
1609
- expect(logSpy).toHaveBeenCalledWith("Logs uploaded successfully with feedbackId: mocked-uuid-12345", {
1610
- file: _constants.UTILS_FILE,
1611
- method: 'uploadLogs'
1612
- });
1613
- expect(mockSubmitRegistrationMetric).toHaveBeenCalledWith('web-calling-sdk-upload-logs-success', {
1614
- fields: {
1615
- call_id: undefined,
1616
- calling_sdk_version: 'unknown',
1617
- correlation_id: 'test-correlation',
1618
- device_url: undefined,
1619
- feedback_id: 'mocked-uuid-12345',
1620
- mobius_url: undefined,
1621
- tracking_id: '1234'
1622
- },
1623
- tags: {
1624
- action: 'upload_logs',
1625
- device_id: undefined,
1626
- service_indicator: 'calling'
1627
- },
1628
- type: 'behavioral'
1629
- });
1630
- expect(submitLogsMock).toHaveBeenCalledWith(_objectSpread(_objectSpread({}, mockMetaData), {}, {
1631
- feedbackId: 'mocked-uuid-12345'
1632
- }), undefined, {
1633
- type: 'diff'
1634
- });
1635
- case 9:
1636
- case "end":
1637
- return _context14.stop();
1638
- }
1639
- }, _callee14);
1640
- })));
1641
- it('should log and throw an error if the upload fails', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee15() {
1642
- var mockMetaData, mockError, logSpy;
1643
- return _regenerator.default.wrap(function _callee15$(_context15) {
1644
- while (1) switch (_context15.prev = _context15.next) {
1645
- case 0:
1646
- mockMetaData = {
1647
- correlationId: 'test-correlation'
1648
- };
1649
- mockError = new Error('Upload failed'); // Mock the submitLogs to fail
1650
- submitLogsMock.mockRejectedValueOnce(mockError);
1651
- logSpy = jest.spyOn(_Logger.default, 'error');
1652
- _context15.prev = 4;
1653
- _context15.next = 7;
1654
- return (0, _Utils.uploadLogs)(mockMetaData, true);
1655
- case 7:
1656
- // If we get here, the test should fail since we expected an exception
1657
- expect(true).toBe(false); // This will fail the test if no exception is thrown
1658
- _context15.next = 15;
1659
- break;
1660
- case 10:
1661
- _context15.prev = 10;
1662
- _context15.t0 = _context15["catch"](4);
1663
- expect(_context15.t0).toBe(mockError);
1664
- expect(logSpy).toHaveBeenCalledWith(expect.objectContaining({
1665
- message: expect.stringContaining('Failed to upload Logs')
1666
- }), {
1667
- file: _constants.UTILS_FILE,
1668
- method: 'uploadLogs'
1669
- });
1670
- expect(mockSubmitRegistrationMetric).toHaveBeenCalledWith('web-calling-sdk-upload-logs-failed', {
1671
- fields: {
1672
- device_url: undefined,
1673
- mobius_url: undefined,
1674
- calling_sdk_version: 'unknown',
1675
- correlation_id: 'test-correlation',
1676
- broadworksCorrelationInfo: undefined,
1677
- tracking_id: undefined,
1678
- feedback_id: 'mocked-uuid-12345',
1679
- call_id: undefined,
1680
- error: 'Failed to upload Logs Error: Upload failed'
1681
- },
1682
- tags: {
1683
- action: 'upload_logs',
1684
- device_id: undefined,
1685
- service_indicator: 'calling'
1686
- },
1687
- type: 'behavioral'
1688
- });
1689
- case 15:
1690
- case "end":
1691
- return _context15.stop();
1692
- }
1693
- }, _callee15, null, [[4, 10]]);
1694
- })));
1695
- 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 _callee16() {
1696
- var mockMetaData, mockError, logSpy, result;
1697
- return _regenerator.default.wrap(function _callee16$(_context16) {
1698
- while (1) switch (_context16.prev = _context16.next) {
1699
- case 0:
1700
- mockMetaData = {
1701
- correlationId: 'test-correlation',
1702
- broadworksCorrelationInfo: 'test-broadworks-correlation'
1703
- };
1704
- mockError = new Error('Upload failed'); // Mock the submitLogs to fail
1705
- submitLogsMock.mockRejectedValueOnce(mockError);
1706
- logSpy = jest.spyOn(_Logger.default, 'error');
1707
- _context16.next = 6;
1708
- return (0, _Utils.uploadLogs)(mockMetaData, false);
1709
- case 6:
1710
- result = _context16.sent;
1711
- expect(result).toBeUndefined();
1712
- expect(logSpy).toHaveBeenCalledWith(expect.objectContaining({
1713
- message: expect.stringContaining('Failed to upload Logs')
1714
- }), {
1715
- file: _constants.UTILS_FILE,
1716
- method: 'uploadLogs'
1717
- });
1718
- expect(mockSubmitRegistrationMetric).toHaveBeenCalledWith('web-calling-sdk-upload-logs-failed', {
1719
- fields: {
1720
- device_url: undefined,
1721
- mobius_url: undefined,
1722
- calling_sdk_version: 'unknown',
1723
- correlation_id: 'test-correlation',
1724
- broadworksCorrelationInfo: 'test-broadworks-correlation',
1725
- tracking_id: undefined,
1726
- feedback_id: 'mocked-uuid-12345',
1727
- call_id: undefined,
1728
- error: 'Failed to upload Logs Error: Upload failed'
1729
- },
1730
- tags: {
1731
- action: 'upload_logs',
1732
- device_id: undefined,
1733
- service_indicator: 'calling'
1734
- },
1735
- type: 'behavioral'
1736
- });
1737
- case 10:
1738
- case "end":
1739
- return _context16.stop();
1740
- }
1741
- }, _callee16);
1742
- })));
1743
- });
1744
- //# sourceMappingURL=Utils.test.js.map