@webex/calling 3.0.0-next.2 → 3.0.0-next.4

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 (283) hide show
  1. package/CHANGELOG.md +1403 -0
  2. package/README.md +74 -74
  3. package/dist/module/CallHistory/CallHistory.js +81 -81
  4. package/dist/module/CallHistory/callHistoryFixtures.js +307 -307
  5. package/dist/module/CallHistory/constants.js +9 -9
  6. package/dist/module/CallHistory/types.js +1 -1
  7. package/dist/module/CallSettings/CallSettings.js +65 -65
  8. package/dist/module/CallSettings/UcmBackendConnector.js +100 -100
  9. package/dist/module/CallSettings/WxCallBackendConnector.js +287 -287
  10. package/dist/module/CallSettings/constants.js +11 -11
  11. package/dist/module/CallSettings/testFixtures.js +62 -62
  12. package/dist/module/CallSettings/types.js +1 -1
  13. package/dist/module/CallingClient/CallingClient.js +248 -248
  14. package/dist/module/CallingClient/callRecordFixtures.js +93 -93
  15. package/dist/module/CallingClient/calling/CallerId/index.js +169 -169
  16. package/dist/module/CallingClient/calling/CallerId/types.js +1 -1
  17. package/dist/module/CallingClient/calling/call.js +1658 -1658
  18. package/dist/module/CallingClient/calling/callManager.js +284 -284
  19. package/dist/module/CallingClient/calling/index.js +2 -2
  20. package/dist/module/CallingClient/calling/types.js +53 -53
  21. package/dist/module/CallingClient/callingClientFixtures.js +38 -38
  22. package/dist/module/CallingClient/constants.js +122 -122
  23. package/dist/module/CallingClient/line/index.js +158 -158
  24. package/dist/module/CallingClient/line/types.js +15 -15
  25. package/dist/module/CallingClient/registration/index.js +1 -1
  26. package/dist/module/CallingClient/registration/register.js +507 -507
  27. package/dist/module/CallingClient/registration/registerFixtures.js +28 -28
  28. package/dist/module/CallingClient/registration/types.js +1 -1
  29. package/dist/module/CallingClient/types.js +1 -1
  30. package/dist/module/Contacts/ContactsClient.js +484 -484
  31. package/dist/module/Contacts/constants.js +20 -20
  32. package/dist/module/Contacts/contactFixtures.js +284 -284
  33. package/dist/module/Contacts/types.js +10 -10
  34. package/dist/module/Errors/catalog/CallError.js +26 -26
  35. package/dist/module/Errors/catalog/CallingDeviceError.js +18 -18
  36. package/dist/module/Errors/catalog/ExtendedError.js +10 -10
  37. package/dist/module/Errors/catalog/LineError.js +24 -24
  38. package/dist/module/Errors/index.js +2 -2
  39. package/dist/module/Errors/types.js +48 -48
  40. package/dist/module/Events/impl/index.js +19 -19
  41. package/dist/module/Events/types.js +83 -83
  42. package/dist/module/Logger/index.js +114 -114
  43. package/dist/module/Logger/types.js +25 -25
  44. package/dist/module/Metrics/index.js +232 -232
  45. package/dist/module/Metrics/types.js +37 -37
  46. package/dist/module/SDKConnector/index.js +39 -39
  47. package/dist/module/SDKConnector/types.js +1 -1
  48. package/dist/module/SDKConnector/utils.js +12 -12
  49. package/dist/module/Voicemail/BroadworksBackendConnector.js +291 -291
  50. package/dist/module/Voicemail/UcmBackendConnector.js +279 -279
  51. package/dist/module/Voicemail/Voicemail.js +110 -110
  52. package/dist/module/Voicemail/WxCallBackendConnector.js +279 -279
  53. package/dist/module/Voicemail/constants.js +29 -29
  54. package/dist/module/Voicemail/types.js +1 -1
  55. package/dist/module/Voicemail/voicemailFixture.js +510 -510
  56. package/dist/module/api.js +6 -6
  57. package/dist/module/common/Utils.js +802 -802
  58. package/dist/module/common/constants.js +41 -41
  59. package/dist/module/common/index.js +1 -1
  60. package/dist/module/common/testUtil.js +938 -938
  61. package/dist/module/common/types.js +57 -57
  62. package/dist/module/index.js +8 -8
  63. package/dist/types/CallHistory/CallHistory.d.ts +17 -17
  64. package/dist/types/CallHistory/callHistoryFixtures.d.ts +94 -94
  65. package/dist/types/CallHistory/constants.d.ts +9 -9
  66. package/dist/types/CallHistory/types.d.ts +18 -18
  67. package/dist/types/CallSettings/CallSettings.d.ts +19 -19
  68. package/dist/types/CallSettings/UcmBackendConnector.d.ts +19 -19
  69. package/dist/types/CallSettings/WxCallBackendConnector.d.ts +21 -21
  70. package/dist/types/CallSettings/constants.d.ts +11 -11
  71. package/dist/types/CallSettings/testFixtures.d.ts +15 -15
  72. package/dist/types/CallSettings/types.d.ts +107 -107
  73. package/dist/types/CallingClient/CallingClient.d.ts +35 -35
  74. package/dist/types/CallingClient/callRecordFixtures.d.ts +3 -3
  75. package/dist/types/CallingClient/calling/CallerId/index.d.ts +17 -17
  76. package/dist/types/CallingClient/calling/CallerId/types.d.ts +41 -41
  77. package/dist/types/CallingClient/calling/call.d.ts +96 -96
  78. package/dist/types/CallingClient/calling/callManager.d.ts +25 -25
  79. package/dist/types/CallingClient/calling/index.d.ts +2 -2
  80. package/dist/types/CallingClient/calling/types.d.ts +206 -206
  81. package/dist/types/CallingClient/callingClientFixtures.d.ts +18 -18
  82. package/dist/types/CallingClient/constants.d.ts +122 -122
  83. package/dist/types/CallingClient/line/index.d.ts +43 -43
  84. package/dist/types/CallingClient/line/types.d.ts +55 -55
  85. package/dist/types/CallingClient/registration/index.d.ts +1 -1
  86. package/dist/types/CallingClient/registration/register.d.ts +64 -64
  87. package/dist/types/CallingClient/registration/registerFixtures.d.ts +28 -28
  88. package/dist/types/CallingClient/registration/types.d.ts +20 -20
  89. package/dist/types/CallingClient/types.d.ts +29 -29
  90. package/dist/types/Contacts/ContactsClient.d.ts +26 -26
  91. package/dist/types/Contacts/constants.d.ts +19 -19
  92. package/dist/types/Contacts/contactFixtures.d.ts +280 -280
  93. package/dist/types/Contacts/types.d.ts +72 -72
  94. package/dist/types/Errors/catalog/CallError.d.ts +11 -11
  95. package/dist/types/Errors/catalog/CallingDeviceError.d.ts +10 -10
  96. package/dist/types/Errors/catalog/ExtendedError.d.ts +6 -6
  97. package/dist/types/Errors/catalog/LineError.d.ts +10 -10
  98. package/dist/types/Errors/index.d.ts +2 -2
  99. package/dist/types/Errors/types.d.ts +60 -60
  100. package/dist/types/Events/impl/index.d.ts +8 -8
  101. package/dist/types/Events/types.d.ts +288 -288
  102. package/dist/types/Logger/index.d.ts +12 -12
  103. package/dist/types/Logger/types.d.ts +25 -25
  104. package/dist/types/Metrics/index.d.ts +5 -5
  105. package/dist/types/Metrics/types.d.ts +42 -42
  106. package/dist/types/SDKConnector/index.d.ts +12 -12
  107. package/dist/types/SDKConnector/types.d.ts +128 -128
  108. package/dist/types/SDKConnector/utils.d.ts +5 -5
  109. package/dist/types/Voicemail/BroadworksBackendConnector.d.ts +27 -27
  110. package/dist/types/Voicemail/UcmBackendConnector.d.ts +34 -34
  111. package/dist/types/Voicemail/Voicemail.d.ts +27 -27
  112. package/dist/types/Voicemail/WxCallBackendConnector.d.ts +23 -23
  113. package/dist/types/Voicemail/constants.d.ts +29 -29
  114. package/dist/types/Voicemail/types.d.ts +133 -133
  115. package/dist/types/Voicemail/voicemailFixture.d.ts +417 -417
  116. package/dist/types/api.d.ts +16 -16
  117. package/dist/types/common/Utils.d.ts +34 -34
  118. package/dist/types/common/constants.d.ts +41 -41
  119. package/dist/types/common/index.d.ts +1 -1
  120. package/dist/types/common/testUtil.d.ts +3611 -3611
  121. package/dist/types/common/types.d.ts +191 -191
  122. package/dist/types/index.d.ts +8 -8
  123. package/package.json +4 -4
  124. package/dist/CallHistory/CallHistory.js +0 -203
  125. package/dist/CallHistory/CallHistory.js.map +0 -1
  126. package/dist/CallHistory/CallHistory.test.js +0 -133
  127. package/dist/CallHistory/CallHistory.test.js.map +0 -1
  128. package/dist/CallHistory/callHistoryFixtures.js +0 -310
  129. package/dist/CallHistory/callHistoryFixtures.js.map +0 -1
  130. package/dist/CallHistory/constants.js +0 -26
  131. package/dist/CallHistory/constants.js.map +0 -1
  132. package/dist/CallHistory/types.js +0 -7
  133. package/dist/CallHistory/types.js.map +0 -1
  134. package/dist/CallSettings/CallSettings.js +0 -276
  135. package/dist/CallSettings/CallSettings.js.map +0 -1
  136. package/dist/CallSettings/CallSettings.test.js +0 -122
  137. package/dist/CallSettings/CallSettings.test.js.map +0 -1
  138. package/dist/CallSettings/UcmBackendConnector.js +0 -217
  139. package/dist/CallSettings/UcmBackendConnector.js.map +0 -1
  140. package/dist/CallSettings/UcmBackendConnector.test.js +0 -227
  141. package/dist/CallSettings/UcmBackendConnector.test.js.map +0 -1
  142. package/dist/CallSettings/WxCallBackendConnector.js +0 -541
  143. package/dist/CallSettings/WxCallBackendConnector.js.map +0 -1
  144. package/dist/CallSettings/WxCallBackendConnector.test.js +0 -802
  145. package/dist/CallSettings/WxCallBackendConnector.test.js.map +0 -1
  146. package/dist/CallSettings/constants.js +0 -30
  147. package/dist/CallSettings/constants.js.map +0 -1
  148. package/dist/CallSettings/testFixtures.js +0 -72
  149. package/dist/CallSettings/testFixtures.js.map +0 -1
  150. package/dist/CallSettings/types.js +0 -7
  151. package/dist/CallSettings/types.js.map +0 -1
  152. package/dist/CallingClient/CallingClient.js +0 -572
  153. package/dist/CallingClient/CallingClient.js.map +0 -1
  154. package/dist/CallingClient/CallingClient.test.js +0 -931
  155. package/dist/CallingClient/CallingClient.test.js.map +0 -1
  156. package/dist/CallingClient/callRecordFixtures.js +0 -103
  157. package/dist/CallingClient/callRecordFixtures.js.map +0 -1
  158. package/dist/CallingClient/calling/CallerId/index.js +0 -287
  159. package/dist/CallingClient/calling/CallerId/index.js.map +0 -1
  160. package/dist/CallingClient/calling/CallerId/index.test.js +0 -274
  161. package/dist/CallingClient/calling/CallerId/index.test.js.map +0 -1
  162. package/dist/CallingClient/calling/CallerId/types.js +0 -7
  163. package/dist/CallingClient/calling/CallerId/types.js.map +0 -1
  164. package/dist/CallingClient/calling/call.js +0 -2995
  165. package/dist/CallingClient/calling/call.js.map +0 -1
  166. package/dist/CallingClient/calling/call.test.js +0 -2614
  167. package/dist/CallingClient/calling/call.test.js.map +0 -1
  168. package/dist/CallingClient/calling/callManager.js +0 -443
  169. package/dist/CallingClient/calling/callManager.js.map +0 -1
  170. package/dist/CallingClient/calling/callManager.test.js +0 -683
  171. package/dist/CallingClient/calling/callManager.test.js.map +0 -1
  172. package/dist/CallingClient/calling/index.js +0 -30
  173. package/dist/CallingClient/calling/index.js.map +0 -1
  174. package/dist/CallingClient/calling/types.js +0 -71
  175. package/dist/CallingClient/calling/types.js.map +0 -1
  176. package/dist/CallingClient/callingClientFixtures.js +0 -53
  177. package/dist/CallingClient/callingClientFixtures.js.map +0 -1
  178. package/dist/CallingClient/constants.js +0 -226
  179. package/dist/CallingClient/constants.js.map +0 -1
  180. package/dist/CallingClient/line/index.js +0 -312
  181. package/dist/CallingClient/line/index.js.map +0 -1
  182. package/dist/CallingClient/line/line.test.js +0 -270
  183. package/dist/CallingClient/line/line.test.js.map +0 -1
  184. package/dist/CallingClient/line/types.js +0 -25
  185. package/dist/CallingClient/line/types.js.map +0 -1
  186. package/dist/CallingClient/registration/index.js +0 -19
  187. package/dist/CallingClient/registration/index.js.map +0 -1
  188. package/dist/CallingClient/registration/register.js +0 -1295
  189. package/dist/CallingClient/registration/register.js.map +0 -1
  190. package/dist/CallingClient/registration/register.test.js +0 -838
  191. package/dist/CallingClient/registration/register.test.js.map +0 -1
  192. package/dist/CallingClient/registration/registerFixtures.js +0 -41
  193. package/dist/CallingClient/registration/registerFixtures.js.map +0 -1
  194. package/dist/CallingClient/registration/types.js +0 -7
  195. package/dist/CallingClient/registration/types.js.map +0 -1
  196. package/dist/CallingClient/types.js +0 -7
  197. package/dist/CallingClient/types.js.map +0 -1
  198. package/dist/Contacts/ContactsClient.js +0 -1139
  199. package/dist/Contacts/ContactsClient.js.map +0 -1
  200. package/dist/Contacts/ContactsClient.test.js +0 -725
  201. package/dist/Contacts/ContactsClient.test.js.map +0 -1
  202. package/dist/Contacts/constants.js +0 -36
  203. package/dist/Contacts/constants.js.map +0 -1
  204. package/dist/Contacts/contactFixtures.js +0 -340
  205. package/dist/Contacts/contactFixtures.js.map +0 -1
  206. package/dist/Contacts/types.js +0 -20
  207. package/dist/Contacts/types.js.map +0 -1
  208. package/dist/Errors/catalog/CallError.js +0 -94
  209. package/dist/Errors/catalog/CallError.js.map +0 -1
  210. package/dist/Errors/catalog/CallingDeviceError.js +0 -88
  211. package/dist/Errors/catalog/CallingDeviceError.js.map +0 -1
  212. package/dist/Errors/catalog/ExtendedError.js +0 -45
  213. package/dist/Errors/catalog/ExtendedError.js.map +0 -1
  214. package/dist/Errors/catalog/LineError.js +0 -90
  215. package/dist/Errors/catalog/LineError.js.map +0 -1
  216. package/dist/Errors/index.js +0 -21
  217. package/dist/Errors/index.js.map +0 -1
  218. package/dist/Errors/types.js +0 -62
  219. package/dist/Errors/types.js.map +0 -1
  220. package/dist/Events/impl/index.js +0 -82
  221. package/dist/Events/impl/index.js.map +0 -1
  222. package/dist/Events/types.js +0 -111
  223. package/dist/Events/types.js.map +0 -1
  224. package/dist/Logger/index.js +0 -221
  225. package/dist/Logger/index.js.map +0 -1
  226. package/dist/Logger/index.test.js +0 -62
  227. package/dist/Logger/index.test.js.map +0 -1
  228. package/dist/Logger/types.js +0 -37
  229. package/dist/Logger/types.js.map +0 -1
  230. package/dist/Metrics/index.js +0 -329
  231. package/dist/Metrics/index.js.map +0 -1
  232. package/dist/Metrics/index.test.js +0 -291
  233. package/dist/Metrics/index.test.js.map +0 -1
  234. package/dist/Metrics/types.js +0 -50
  235. package/dist/Metrics/types.js.map +0 -1
  236. package/dist/SDKConnector/index.js +0 -105
  237. package/dist/SDKConnector/index.js.map +0 -1
  238. package/dist/SDKConnector/index.test.js +0 -9
  239. package/dist/SDKConnector/index.test.js.map +0 -1
  240. package/dist/SDKConnector/types.js +0 -7
  241. package/dist/SDKConnector/types.js.map +0 -1
  242. package/dist/SDKConnector/utils.js +0 -40
  243. package/dist/SDKConnector/utils.js.map +0 -1
  244. package/dist/SDKConnector/utils.test.js +0 -9
  245. package/dist/SDKConnector/utils.test.js.map +0 -1
  246. package/dist/Voicemail/BroadworksBackendConnector.js +0 -632
  247. package/dist/Voicemail/BroadworksBackendConnector.js.map +0 -1
  248. package/dist/Voicemail/BroadworksBackendConnector.test.js +0 -733
  249. package/dist/Voicemail/BroadworksBackendConnector.test.js.map +0 -1
  250. package/dist/Voicemail/UcmBackendConnector.js +0 -566
  251. package/dist/Voicemail/UcmBackendConnector.js.map +0 -1
  252. package/dist/Voicemail/UcmBackendConnector.test.js +0 -628
  253. package/dist/Voicemail/UcmBackendConnector.test.js.map +0 -1
  254. package/dist/Voicemail/Voicemail.js +0 -378
  255. package/dist/Voicemail/Voicemail.js.map +0 -1
  256. package/dist/Voicemail/Voicemail.test.js +0 -226
  257. package/dist/Voicemail/Voicemail.test.js.map +0 -1
  258. package/dist/Voicemail/WxCallBackendConnector.js +0 -540
  259. package/dist/Voicemail/WxCallBackendConnector.js.map +0 -1
  260. package/dist/Voicemail/WxCallBackendConnector.test.js +0 -942
  261. package/dist/Voicemail/WxCallBackendConnector.test.js.map +0 -1
  262. package/dist/Voicemail/constants.js +0 -66
  263. package/dist/Voicemail/constants.js.map +0 -1
  264. package/dist/Voicemail/types.js +0 -7
  265. package/dist/Voicemail/types.js.map +0 -1
  266. package/dist/Voicemail/voicemailFixture.js +0 -559
  267. package/dist/Voicemail/voicemailFixture.js.map +0 -1
  268. package/dist/api.js +0 -134
  269. package/dist/api.js.map +0 -1
  270. package/dist/common/Utils.js +0 -1264
  271. package/dist/common/Utils.js.map +0 -1
  272. package/dist/common/Utils.test.js +0 -1227
  273. package/dist/common/Utils.test.js.map +0 -1
  274. package/dist/common/constants.js +0 -90
  275. package/dist/common/constants.js.map +0 -1
  276. package/dist/common/index.js +0 -19
  277. package/dist/common/index.js.map +0 -1
  278. package/dist/common/testUtil.js +0 -968
  279. package/dist/common/testUtil.js.map +0 -1
  280. package/dist/common/types.js +0 -75
  281. package/dist/common/types.js.map +0 -1
  282. package/dist/index.js +0 -63
  283. package/dist/index.js.map +0 -1
@@ -1,1227 +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 _calling = require("../CallingClient/calling");
16
- var _Errors = require("../Errors");
17
- var _testUtil = require("./testUtil");
18
- var _types = require("./types");
19
- var _Logger = _interopRequireDefault(require("../Logger"));
20
- var _constants = require("../CallingClient/constants");
21
- var _types2 = require("../Errors/types");
22
- var _Utils = require("./Utils");
23
- var _voicemailFixture = require("../Voicemail/voicemailFixture");
24
- var _constants2 = require("./constants");
25
- var _types3 = require("../Events/types");
26
- function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
27
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
28
- var mockSubmitRegistrationMetric = jest.fn();
29
- var mockEmitterCb = jest.fn();
30
- var mockRestoreCb = jest.fn();
31
- var webex = (0, _testUtil.getTestUtilsWebex)();
32
- webex.internal.metrics.submitClientMetrics = mockSubmitRegistrationMetric;
33
- describe('Mobius service discovery tests', function () {
34
- it('test filter mobius uris', function () {
35
- var defaultMobiusUrl = 'https://mobius.webex.com/api/v1/calling/web';
36
- var callingContext = '/calling/web/';
37
- var discoveryResponse = (0, _testUtil.getMobiusDiscoveryResponse)();
38
-
39
- // add a duplicate which will be filtered out
40
- discoveryResponse.backup.uris.push(discoveryResponse.backup.uris[0]);
41
- var filteredUris = (0, _Utils.filterMobiusUris)(discoveryResponse, defaultMobiusUrl);
42
- expect(filteredUris.primary.length).toBe(1);
43
- expect(filteredUris.backup.length).toBe(2);
44
- expect(filteredUris.primary[0]).toBe(discoveryResponse.primary.uris[0] + callingContext);
45
- expect(filteredUris.backup[0]).toBe(discoveryResponse.backup.uris[0] + callingContext);
46
- expect(filteredUris.backup[1]).toBe(defaultMobiusUrl + callingContext);
47
-
48
- /** Remove Uris and test if the defaultUrls is returned */
49
- discoveryResponse.backup.uris = [];
50
- discoveryResponse.primary.uris = [];
51
- filteredUris = (0, _Utils.filterMobiusUris)(discoveryResponse, defaultMobiusUrl);
52
- expect(filteredUris.primary.length).toBe(1);
53
- expect(filteredUris.primary[0]).toBe(defaultMobiusUrl + callingContext);
54
- expect(filteredUris.backup.length).toBe(0);
55
- });
56
- });
57
- describe('Registration Tests', function () {
58
- /**
59
- * TestCase inputs
60
- * name: TestCase name
61
- * code: Response code of type ERROR_CODE
62
- * bodyPresent: Indicates if response has a body
63
- * subErrorCode: sub error code of type CALL_ERROR_CODE
64
- * retryAfter: Indicates if retry-after header is present
65
- * message: Custom message for the error context
66
- * type: Error type based on the response code
67
- * errorLayer: Call control or media layer
68
- * cbExpected: Indicates if event emitter callback is expected
69
- * logMsg: log message.
70
- */
71
- var errorCodes = [{
72
- name: 'verify 404 error response',
73
- statusCode: _types2.ERROR_CODE.DEVICE_NOT_FOUND,
74
- deviceErrorCode: 0,
75
- retryAfter: 0,
76
- 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.',
77
- errorType: _types2.ERROR_TYPE.NOT_FOUND,
78
- emitterCbExpected: true,
79
- finalError: true,
80
- restoreCbExpected: false,
81
- logMsg: '404 Device Not Found'
82
- }, {
83
- name: 'verify 500 error response',
84
- statusCode: _types2.ERROR_CODE.INTERNAL_SERVER_ERROR,
85
- deviceErrorCode: 0,
86
- retryAfter: 0,
87
- message: 'An unknown error occurred while placing the request. Wait a moment and try again.',
88
- errorType: _types2.ERROR_TYPE.SERVICE_UNAVAILABLE,
89
- emitterCbExpected: true,
90
- finalError: false,
91
- restoreCbExpected: false,
92
- logMsg: '500 Internal Server Error'
93
- }, {
94
- name: 'verify 503 error response',
95
- statusCode: _types2.ERROR_CODE.SERVICE_UNAVAILABLE,
96
- deviceErrorCode: 0,
97
- retryAfter: 0,
98
- message: 'An error occurred on the server while processing the request. Wait a moment and try again.',
99
- errorType: _types2.ERROR_TYPE.SERVICE_UNAVAILABLE,
100
- emitterCbExpected: true,
101
- finalError: false,
102
- restoreCbExpected: false,
103
- logMsg: '503 Service Unavailable'
104
- }, {
105
- name: 'verify 403 response with no response body',
106
- statusCode: _types2.ERROR_CODE.FORBIDDEN,
107
- deviceErrorCode: 0,
108
- retryAfter: 0,
109
- message: 'An unauthorized action has been received. This action has been blocked. Please contact the administrator if this persists.',
110
- errorType: _types2.ERROR_TYPE.FORBIDDEN_ERROR,
111
- emitterCbExpected: true,
112
- finalError: false,
113
- restoreCbExpected: false,
114
- logMsg: 'Error response has no body, throwing default error',
115
- customBodyPresent: true,
116
- body: undefined
117
- }, {
118
- name: 'verify 403 response with unknown device.errorCode',
119
- statusCode: _types2.ERROR_CODE.FORBIDDEN,
120
- deviceErrorCode: 0,
121
- retryAfter: 0,
122
- message: 'An unknown error occurred. Wait a moment and try again. Please contact the administrator if the problem persists.',
123
- errorType: _types2.ERROR_TYPE.FORBIDDEN_ERROR,
124
- emitterCbExpected: true,
125
- finalError: false,
126
- restoreCbExpected: false,
127
- logMsg: 'Error code found : 0'
128
- }, {
129
- name: 'verify 403 response with code 101',
130
- statusCode: _types2.ERROR_CODE.FORBIDDEN,
131
- deviceErrorCode: _types2.DEVICE_ERROR_CODE.DEVICE_LIMIT_EXCEEDED,
132
- retryAfter: 0,
133
- message: 'User device limit exceeded',
134
- errorType: _types2.ERROR_TYPE.FORBIDDEN_ERROR,
135
- emitterCbExpected: false,
136
- finalError: false,
137
- restoreCbExpected: true,
138
- logMsg: 'User device limit exceeded'
139
- }, {
140
- name: 'verify 403 response with code 102',
141
- statusCode: _types2.ERROR_CODE.FORBIDDEN,
142
- deviceErrorCode: _types2.DEVICE_ERROR_CODE.DEVICE_CREATION_DISABLED,
143
- retryAfter: 0,
144
- message: 'User is not configured for WebRTC calling. Please contact the administrator to resolve this issue.',
145
- errorType: _types2.ERROR_TYPE.FORBIDDEN_ERROR,
146
- emitterCbExpected: true,
147
- finalError: true,
148
- restoreCbExpected: false,
149
- logMsg: 'User is not configured for WebRTC calling. Please contact the administrator to resolve this issue.'
150
- }, {
151
- name: 'verify 403 response with code 103',
152
- statusCode: _types2.ERROR_CODE.FORBIDDEN,
153
- deviceErrorCode: _types2.DEVICE_ERROR_CODE.DEVICE_CREATION_FAILED,
154
- retryAfter: 0,
155
- message: 'An unknown error occurred while provisioning the device. Wait a moment and try again.',
156
- errorType: _types2.ERROR_TYPE.FORBIDDEN_ERROR,
157
- emitterCbExpected: true,
158
- finalError: false,
159
- restoreCbExpected: false,
160
- logMsg: 'An unknown error occurred while provisioning the device. Wait a moment and try again.'
161
- }, {
162
- name: 'verify 401 error response',
163
- statusCode: _types2.ERROR_CODE.UNAUTHORIZED,
164
- deviceErrorCode: 0,
165
- retryAfter: 0,
166
- message: 'User is unauthorized due to an expired token. Sign out, then sign back in.',
167
- errorType: _types2.ERROR_TYPE.TOKEN_ERROR,
168
- emitterCbExpected: true,
169
- finalError: true,
170
- restoreCbExpected: false,
171
- logMsg: '401 Unauthorized'
172
- }, {
173
- name: 'verify unknown error response',
174
- statusCode: 206,
175
- deviceErrorCode: 0,
176
- retryAfter: 0,
177
- message: 'Unknown error',
178
- errorType: _types2.ERROR_TYPE.DEFAULT,
179
- emitterCbExpected: true,
180
- finalError: false,
181
- restoreCbExpected: false,
182
- logMsg: 'Unknown Error'
183
- }].map(function (stat) {
184
- return (0, _assign.default)(stat, {
185
- toString: function toString() {
186
- return this.name;
187
- }
188
- });
189
- });
190
- var logSpy = jest.spyOn(_Logger.default, 'warn');
191
- var logObj = {
192
- file: 'CallingClient',
193
- method: _constants.REGISTER_UTIL
194
- };
195
-
196
- /* eslint-disable @typescript-eslint/no-explicit-any */
197
- it.each(errorCodes)('%s', function (codeObj) {
198
- var webexPayload = {
199
- statusCode: codeObj.statusCode,
200
- headers: {
201
- trackingid: 'webex-js-sdk_b5812e58-7246-4a9b-bf64-831bdf13b0cd_31'
202
- },
203
- body: {
204
- device: {
205
- deviceId: '8a67806f-fc4d-446b-a131-31e71ea5b010'
206
- },
207
- userId: '8a67806f-fc4d-446b-a131-31e71ea5b0e9',
208
- errorCode: codeObj.deviceErrorCode,
209
- devices: [{
210
- deviceId: '8a67806f-fc4d-446b-a131-31e71ea5b010',
211
- uri: 'https://mobius.webex.com/api/v1/calling/web/',
212
- status: 'active',
213
- lastSeen: '2022-04-07T18:00:40Z',
214
- addresses: ['sip:sipAddress@webex.com']
215
- }]
216
- }
217
- };
218
- if (codeObj.customBodyPresent) {
219
- webexPayload.body = codeObj.body;
220
- }
221
- var mockErrorEvent = {
222
- type: codeObj.errorType,
223
- message: codeObj.message,
224
- context: logObj
225
- };
226
- var callClientError = new _Errors.CallingClientError(mockErrorEvent.message, mockErrorEvent.context, mockErrorEvent.type, _types.MobiusStatus.ACTIVE);
227
- (0, _Utils.handleRegistrationErrors)(webexPayload, mockEmitterCb, logObj, mockRestoreCb);
228
- if (codeObj.emitterCbExpected) {
229
- expect(mockEmitterCb).toBeCalledOnceWith(callClientError, codeObj.finalError);
230
- }
231
- if (codeObj.restoreCbExpected) {
232
- expect(mockRestoreCb).toBeCalledOnceWith(webexPayload.body, logObj.method);
233
- } else {
234
- expect(mockRestoreCb).not.toHaveBeenCalled();
235
- }
236
- expect(logSpy).toHaveBeenCalledWith("Status code: -> ".concat(codeObj.statusCode), logObj);
237
- expect(logSpy).toHaveBeenCalledWith(codeObj.logMsg, logObj);
238
- });
239
- });
240
- describe('Call Tests', function () {
241
- /* Error flows tests starts */
242
- var logSpy = jest.spyOn(_Logger.default, 'warn');
243
- var logObj = {
244
- file: _constants.CALL_FILE,
245
- method: 'handleCallErrors'
246
- };
247
- var deviceId = '55dfb53f-bed2-36da-8e85-cee7f02aa68e';
248
- var dest = {
249
- type: _types.CallType.URI,
250
- address: 'tel:5003'
251
- };
252
- var deleteCallFromCollection = jest.fn();
253
- var retryCallback = jest.fn();
254
- var activeUrl = 'FakeActiveUrl';
255
- var defaultServiceIndicator = _types.ServiceIndicator.CALLING;
256
- var call = new _calling.Call(activeUrl, webex, dest, _types.CallDirection.OUTBOUND, deviceId, deleteCallFromCollection, defaultServiceIndicator);
257
- var dummyCorrelationId = '8a67806f-fc4d-446b-a131-31e71ea5b010';
258
- beforeEach(function () {
259
- jest.clearAllTimers();
260
- jest.useFakeTimers();
261
- call.removeAllListeners(_types3.CALL_EVENT_KEYS.CALL_ERROR);
262
- });
263
-
264
- /**
265
- * TestCase inputs
266
- * name: TestCase name
267
- * code: Response code of type ERROR_CODE
268
- * bodyPresent: Indicates if response has a body
269
- * subErrorCode: sub error code of type CALL_ERROR_CODE
270
- * retryAfter: Indicates if retry-after header is present
271
- * message: Custom message for the error context
272
- * type: Error type based on the response code
273
- * errorLayer: Call control or media layer
274
- * cbExpected: Indicates if event emitter callback is expected
275
- * logMsg: log message.
276
- */
277
- var errorCodes = [/* 401 Unauthorized. */
278
- {
279
- name: 'verify 401 error response',
280
- code: 401,
281
- bodyPresent: true,
282
- subErrorCode: 0,
283
- retryAfter: 0,
284
- message: 'User is unauthorized due to an expired token. Sign out, then sign back in.',
285
- type: _types2.ERROR_TYPE.TOKEN_ERROR,
286
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
287
- cbExpected: true,
288
- logMsg: '401 Unauthorized'
289
- }, /* 403 error code from here. */
290
- // Without body
291
- {
292
- name: 'verify 403 error response without body',
293
- code: 403,
294
- bodyPresent: false,
295
- subErrorCode: 0,
296
- retryAfter: 0,
297
- message: 'An unauthorized action has been received. This action has been blocked. Please contact the administrator if this persists.',
298
- type: _types2.ERROR_TYPE.FORBIDDEN_ERROR,
299
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
300
- cbExpected: true,
301
- logMsg: 'Error response has no body, throwing default error'
302
- },
303
- // error body with sub error code 111
304
- {
305
- name: 'verify 403 error response with code 111',
306
- code: 403,
307
- bodyPresent: true,
308
- subErrorCode: _types2.CALL_ERROR_CODE.INVALID_STATUS_UPDATE,
309
- retryAfter: 0,
310
- message: 'An invalid status update has been received for the call. Wait a moment and try again.',
311
- type: _types2.ERROR_TYPE.FORBIDDEN_ERROR,
312
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
313
- cbExpected: true,
314
- logMsg: 'Status code: ->403'
315
- },
316
- // error body with sub error code 112
317
- {
318
- name: 'verify 403 error response with code 112',
319
- code: 403,
320
- bodyPresent: true,
321
- subErrorCode: _types2.CALL_ERROR_CODE.DEVICE_NOT_REGISTERED,
322
- retryAfter: 0,
323
- 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.',
324
- type: _types2.ERROR_TYPE.FORBIDDEN_ERROR,
325
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
326
- cbExpected: true,
327
- logMsg: 'Status code: ->403'
328
- },
329
- // error body with sub error code 113
330
- {
331
- name: 'verify 403 error response with code 113',
332
- code: 403,
333
- bodyPresent: true,
334
- subErrorCode: _types2.CALL_ERROR_CODE.CALL_NOT_FOUND,
335
- retryAfter: 0,
336
- message: 'Call is not found on the server. Wait a moment and try again.',
337
- type: _types2.ERROR_TYPE.FORBIDDEN_ERROR,
338
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
339
- cbExpected: true,
340
- logMsg: 'Status code: ->403'
341
- },
342
- // error body with sub error code 114
343
- {
344
- name: 'verify 403 error response with code 114',
345
- code: 403,
346
- bodyPresent: true,
347
- subErrorCode: _types2.CALL_ERROR_CODE.ERROR_PROCESSING,
348
- retryAfter: 0,
349
- message: 'An error occurred while processing the call on the server. Wait a moment and try again.',
350
- type: _types2.ERROR_TYPE.FORBIDDEN_ERROR,
351
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
352
- cbExpected: true,
353
- logMsg: 'Status code: ->403'
354
- },
355
- // error body with sub error code 115
356
- {
357
- name: 'verify 403 error response with code 115',
358
- code: 403,
359
- bodyPresent: true,
360
- subErrorCode: _types2.CALL_ERROR_CODE.USER_BUSY,
361
- retryAfter: 0,
362
- message: 'Called user is busy.',
363
- type: _types2.ERROR_TYPE.FORBIDDEN_ERROR,
364
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
365
- cbExpected: true,
366
- logMsg: 'Status code: ->403'
367
- },
368
- // error body with sub error code 116
369
- {
370
- name: 'verify 403 error response with code 116',
371
- code: 403,
372
- bodyPresent: true,
373
- subErrorCode: _types2.CALL_ERROR_CODE.PARSING_ERROR,
374
- retryAfter: 0,
375
- message: 'An error occurred while parsing the provided information. Wait a moment and try again.',
376
- type: _types2.ERROR_TYPE.FORBIDDEN_ERROR,
377
- errorLayer: _types2.ERROR_LAYER.MEDIA,
378
- cbExpected: true,
379
- logMsg: 'Status code: ->403'
380
- },
381
- // error body with sub error code 118
382
- {
383
- name: 'verify 403 error response with code 118',
384
- code: 403,
385
- bodyPresent: true,
386
- subErrorCode: _types2.CALL_ERROR_CODE.NOT_ACCEPTABLE,
387
- retryAfter: 0,
388
- message: 'An error occurred on the server while accepting the call. Wait a moment and try again. Please contact the administrator if this persists.',
389
- type: _types2.ERROR_TYPE.FORBIDDEN_ERROR,
390
- errorLayer: _types2.ERROR_LAYER.MEDIA,
391
- cbExpected: true,
392
- logMsg: 'Status code: ->403'
393
- },
394
- // error body with sub error code 119
395
- {
396
- name: 'verify 403 error response with code 119',
397
- code: 403,
398
- bodyPresent: true,
399
- subErrorCode: _types2.CALL_ERROR_CODE.CALL_REJECTED,
400
- retryAfter: 0,
401
- message: 'Call rejected by the server. Wait a moment and try again. Please contact the administrator if this persists.',
402
- type: _types2.ERROR_TYPE.FORBIDDEN_ERROR,
403
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
404
- cbExpected: true,
405
- logMsg: 'Status code: ->403'
406
- },
407
- // error body with sub error code 120
408
- {
409
- name: 'verify 403 error response with code 120',
410
- code: 403,
411
- bodyPresent: true,
412
- subErrorCode: _types2.CALL_ERROR_CODE.NOT_AVAILABLE,
413
- retryAfter: 0,
414
- message: 'Calling services not available. Wait a moment and try again. Please contact the administrator if this persists.',
415
- type: _types2.ERROR_TYPE.FORBIDDEN_ERROR,
416
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
417
- cbExpected: true,
418
- logMsg: 'Status code: ->403'
419
- },
420
- // error body with unknown/unhandled sub error code
421
- {
422
- name: 'verify 403 error response with unknown error code',
423
- code: 403,
424
- bodyPresent: true,
425
- subErrorCode: 999,
426
- retryAfter: 0,
427
- message: 'An unknown error occurred. Wait a moment and try again.',
428
- type: _types2.ERROR_TYPE.FORBIDDEN_ERROR,
429
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
430
- cbExpected: true,
431
- logMsg: 'Status code: ->403'
432
- }, /* 403 error code till here. */
433
- /* 503 error code from here. */
434
- // Without body
435
- {
436
- name: 'verify 503 error response without body',
437
- code: 503,
438
- bodyPresent: false,
439
- subErrorCode: 0,
440
- retryAfter: 0,
441
- message: 'An error occurred on the server while processing the request. Wait a moment and try again.',
442
- type: _types2.ERROR_TYPE.SERVICE_UNAVAILABLE,
443
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
444
- cbExpected: true,
445
- logMsg: 'Error response has no body, throwing default error'
446
- },
447
- // error body with sub error code 111
448
- {
449
- name: 'verify 503 error response with code 111',
450
- code: 503,
451
- bodyPresent: true,
452
- subErrorCode: _types2.CALL_ERROR_CODE.INVALID_STATUS_UPDATE,
453
- retryAfter: 0,
454
- message: 'An invalid status update has been received for the call. Wait a moment and try again.',
455
- type: _types2.ERROR_TYPE.SERVICE_UNAVAILABLE,
456
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
457
- cbExpected: true,
458
- logMsg: 'Status code: ->503'
459
- },
460
- // error body with sub error code 112
461
- {
462
- name: 'verify 503 error response with code 112',
463
- code: 503,
464
- bodyPresent: true,
465
- subErrorCode: _types2.CALL_ERROR_CODE.DEVICE_NOT_REGISTERED,
466
- retryAfter: 0,
467
- 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.',
468
- type: _types2.ERROR_TYPE.SERVICE_UNAVAILABLE,
469
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
470
- cbExpected: true,
471
- logMsg: 'Status code: ->503'
472
- },
473
- // error body with sub error code 113
474
- {
475
- name: 'verify 503 error response with code 113',
476
- code: 503,
477
- bodyPresent: true,
478
- subErrorCode: _types2.CALL_ERROR_CODE.CALL_NOT_FOUND,
479
- retryAfter: 0,
480
- message: 'Call is not found on the server. Wait a moment and try again.',
481
- type: _types2.ERROR_TYPE.SERVICE_UNAVAILABLE,
482
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
483
- cbExpected: true,
484
- logMsg: 'Status code: ->503'
485
- },
486
- // error body with sub error code 114
487
- {
488
- name: 'verify 503 error response with code 114',
489
- code: 503,
490
- bodyPresent: true,
491
- subErrorCode: _types2.CALL_ERROR_CODE.ERROR_PROCESSING,
492
- retryAfter: 0,
493
- message: 'An error occurred while processing the call on the server. Wait a moment and try again.',
494
- type: _types2.ERROR_TYPE.SERVICE_UNAVAILABLE,
495
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
496
- cbExpected: true,
497
- logMsg: 'Status code: ->503'
498
- },
499
- // error body with sub error code 115
500
- {
501
- name: 'verify 503 error response with code 115',
502
- code: 503,
503
- bodyPresent: true,
504
- subErrorCode: _types2.CALL_ERROR_CODE.USER_BUSY,
505
- retryAfter: 0,
506
- message: 'Called user is busy.',
507
- type: _types2.ERROR_TYPE.SERVICE_UNAVAILABLE,
508
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
509
- cbExpected: true,
510
- logMsg: 'Status code: ->503'
511
- },
512
- // error body with sub error code 116
513
- {
514
- name: 'verify 503 error response with code 116',
515
- code: 503,
516
- bodyPresent: true,
517
- subErrorCode: _types2.CALL_ERROR_CODE.PARSING_ERROR,
518
- retryAfter: 0,
519
- message: 'An error occurred while parsing the provided information. Wait a moment and try again.',
520
- type: _types2.ERROR_TYPE.SERVICE_UNAVAILABLE,
521
- errorLayer: _types2.ERROR_LAYER.MEDIA,
522
- cbExpected: true,
523
- logMsg: 'Status code: ->503'
524
- },
525
- // error body with sub error code 118
526
- {
527
- name: 'verify 503 error response with code 118',
528
- code: 503,
529
- bodyPresent: true,
530
- subErrorCode: _types2.CALL_ERROR_CODE.NOT_ACCEPTABLE,
531
- retryAfter: 0,
532
- message: 'An error occurred on the server while accepting the call. Wait a moment and try again. Please contact the administrator if this persists.',
533
- type: _types2.ERROR_TYPE.SERVICE_UNAVAILABLE,
534
- errorLayer: _types2.ERROR_LAYER.MEDIA,
535
- cbExpected: true,
536
- logMsg: 'Status code: ->503'
537
- },
538
- // error body with sub error code 119
539
- {
540
- name: 'verify 503 error response with code 119',
541
- code: 503,
542
- bodyPresent: true,
543
- subErrorCode: _types2.CALL_ERROR_CODE.CALL_REJECTED,
544
- retryAfter: 0,
545
- message: 'Call rejected by the server. Wait a moment and try again. Please contact the administrator if this persists.',
546
- type: _types2.ERROR_TYPE.SERVICE_UNAVAILABLE,
547
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
548
- cbExpected: true,
549
- logMsg: 'Status code: ->503'
550
- },
551
- // error body with sub error code 120
552
- {
553
- name: 'verify 503 error response with code 120',
554
- code: 503,
555
- bodyPresent: true,
556
- subErrorCode: _types2.CALL_ERROR_CODE.NOT_AVAILABLE,
557
- retryAfter: 0,
558
- message: 'Calling services not available. Wait a moment and try again. Please contact the administrator if this persists.',
559
- type: _types2.ERROR_TYPE.SERVICE_UNAVAILABLE,
560
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
561
- cbExpected: true,
562
- logMsg: 'Status code: ->503'
563
- },
564
- // error body with unknown/unhandled sub error code
565
- {
566
- name: 'verify 503 error response with unknown error code',
567
- code: 503,
568
- bodyPresent: true,
569
- subErrorCode: 999,
570
- retryAfter: 0,
571
- message: 'An unknown error occurred. Wait a moment and try again.',
572
- type: _types2.ERROR_TYPE.SERVICE_UNAVAILABLE,
573
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
574
- cbExpected: true,
575
- logMsg: 'Status code: ->503'
576
- },
577
- // with retry-after
578
- {
579
- name: 'verify 503 error response with retry-after',
580
- code: 503,
581
- bodyPresent: true,
582
- subErrorCode: 0,
583
- retryAfter: 60,
584
- message: 'An unknown error occurred. Wait a moment and try again.',
585
- type: _types2.ERROR_TYPE.SERVICE_UNAVAILABLE,
586
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
587
- cbExpected: false,
588
- logMsg: 'Retry Interval received: 60'
589
- }, /* 503 error code till here. */
590
- /* 404 Not Found. */
591
- {
592
- name: 'verify 404 error response',
593
- code: 404,
594
- bodyPresent: true,
595
- subErrorCode: 0,
596
- retryAfter: 0,
597
- message: 'Call is no longer active. Wait a moment and try again.',
598
- type: _types2.ERROR_TYPE.NOT_FOUND,
599
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
600
- cbExpected: true,
601
- logMsg: '404 Call Not Found'
602
- }, /* 500 Internal Server Error. */
603
- {
604
- name: 'verify 500 error response',
605
- code: 500,
606
- bodyPresent: true,
607
- subErrorCode: 0,
608
- retryAfter: 0,
609
- message: 'An unknown error occurred in the call. Wait a moment and try again.',
610
- type: _types2.ERROR_TYPE.SERVER_ERROR,
611
- errorLayer: _types2.ERROR_LAYER.MEDIA,
612
- cbExpected: true,
613
- logMsg: '500 Internal Server Error'
614
- }, /* Unknown error code. */
615
- {
616
- name: 'verify unknown error response',
617
- code: 0,
618
- bodyPresent: true,
619
- subErrorCode: 0,
620
- retryAfter: 0,
621
- message: 'An unknown error occurred in the call. Wait a moment and try again.',
622
- type: _types2.ERROR_TYPE.DEFAULT,
623
- errorLayer: _types2.ERROR_LAYER.CALL_CONTROL,
624
- cbExpected: false,
625
- logMsg: 'Unknown Error'
626
- }].map(function (stat) {
627
- return (0, _assign.default)(stat, {
628
- toString: function toString() {
629
- return this.name;
630
- }
631
- });
632
- });
633
-
634
- /* eslint-disable @typescript-eslint/no-explicit-any */
635
- it.each(errorCodes)('%s', function (codeObj, done) {
636
- var cbTriggered = false;
637
- var mockPayload = _objectSpread({
638
- statusCode: codeObj.code,
639
- headers: _objectSpread({
640
- trackingid: 'webex-js-sdk_b5812e58-7246-4a9b-bf64-831bdf13b0cd_31'
641
- }, codeObj.retryAfter && {
642
- 'retry-after': codeObj.retryAfter
643
- })
644
- }, codeObj.bodyPresent && {
645
- body: _objectSpread({
646
- device: {
647
- deviceId: '8a67806f-fc4d-446b-a131-31e71ea5b010'
648
- }
649
- }, codeObj.subErrorCode ? {
650
- errorCode: codeObj.subErrorCode
651
- } : {})
652
- });
653
- var mockErrorEvent = {
654
- type: codeObj.type,
655
- message: codeObj.message,
656
- context: logObj,
657
- correlationId: dummyCorrelationId,
658
- errorLayer: codeObj.errorLayer
659
- };
660
- if (codeObj.cbExpected) {
661
- call.on(_types3.CALL_EVENT_KEYS.CALL_ERROR, function (errObj) {
662
- expect(errObj).toMatchObject(mockErrorEvent);
663
- done();
664
- });
665
- } else {
666
- done();
667
- }
668
- (0, _Utils.handleCallErrors)(function (error) {
669
- call.emit(_types3.CALL_EVENT_KEYS.CALL_ERROR, error);
670
- cbTriggered = true;
671
- }, codeObj.errorLayer, retryCallback, dummyCorrelationId, mockPayload, logObj.method, logObj.file);
672
- expect(cbTriggered).toBe(codeObj.cbExpected);
673
- expect(logSpy).toBeCalledWith(codeObj.logMsg, logObj);
674
- if (codeObj.retryAfter) {
675
- expect(retryCallback).toBeCalledOnceWith(codeObj.retryAfter);
676
- } else {
677
- expect(retryCallback).not.toBeCalled();
678
- }
679
- });
680
- });
681
- describe('parseMediaQualityStatistics tests', function () {
682
- var logSpyObj = jest.spyOn(_Logger.default, 'log');
683
- var infoSpyObj = jest.spyOn(_Logger.default, 'info');
684
- var warnSpyObj = jest.spyOn(_Logger.default, 'warn');
685
- var logObj = {
686
- file: _constants.UTILS_FILE,
687
- method: _Utils.parseMediaQualityStatistics.name
688
- };
689
- var stats = (0, _testUtil.getSampleRawAndParsedMediaStats)();
690
- var statsWithVoOneWayDelayAndNw = stats.statsWithVoOneWayDelayAndNw;
691
- var statsWithoutVoOneWayDelayAndNw = stats.statsWithoutVoOneWayDelayAndNw;
692
-
693
- /**
694
- * TestCase inputs
695
- * name: TestCase name
696
- * original: Original RTCStatsReport
697
- * parsed: Parsed stats in form of CallRtpStats
698
- * logSpy: SpyInstance on the log object
699
- * logMsg: Expected log message.
700
- */
701
- var mqStats = [{
702
- name: 'Valid stats with non-zero VoOneWayDelayMs and networkType vpn',
703
- original: statsWithVoOneWayDelayAndNw.raw,
704
- parsed: statsWithVoOneWayDelayAndNw.parsed,
705
- logSpy: logSpyObj,
706
- logMsg: (0, _stringify.default)(statsWithVoOneWayDelayAndNw.parsed)
707
- }, {
708
- name: 'Valid stats with zero VoOneWayDelayMs and undefined networkType',
709
- original: statsWithoutVoOneWayDelayAndNw.raw,
710
- parsed: statsWithoutVoOneWayDelayAndNw.parsed,
711
- logSpy: logSpyObj,
712
- logMsg: (0, _stringify.default)(statsWithoutVoOneWayDelayAndNw.parsed)
713
- }, {
714
- name: 'undefined stats passed to parse function',
715
- original: undefined,
716
- parsed: _constants.DUMMY_METRICS,
717
- logSpy: infoSpyObj,
718
- logMsg: 'RTCStatsReport is null, adding dummy stats'
719
- }, {
720
- name: 'invalid metrics passed when outbound call is disconnected before a connect',
721
- original: {
722
- size: 26
723
- },
724
- parsed: _constants.DUMMY_METRICS,
725
- logSpy: warnSpyObj,
726
- logMsg: 'Caught error while parsing RTP stats, TypeError: stats.forEach is not a function'
727
- }].map(function (stat) {
728
- return (0, _assign.default)(stat, {
729
- toString: function toString() {
730
- return this.name;
731
- }
732
- });
733
- });
734
- it.each(mqStats)('%s', function (stat) {
735
- var result = (0, _Utils.parseMediaQualityStatistics)(stat.original);
736
- expect(result).toStrictEqual(stat.parsed);
737
- expect(stat.logSpy).toBeCalledOnceWith(stat.logMsg, logObj);
738
- });
739
- });
740
- describe('Voicemail Sorting Tests', function () {
741
- /* Tests Voicemail sorting in ascending and descending orders */
742
-
743
- it('verify VoiceMails sorting in Ascending order', function () {
744
- var voiceMailList = _voicemailFixture.getVoicemailListJsonWXC.body.VoiceMessagingMessages.messageInfoList.messageInfo;
745
- var sortedVoicemail = (0, _Utils.getSortedVoicemailList)(voiceMailList, _types.SORT.ASC);
746
- var voiceMailListAscOrder = _voicemailFixture.getAscVoicemailListJsonWXC.body.VoiceMessagingMessages.messageInfoList.messageInfo;
747
- expect(sortedVoicemail).toStrictEqual(voiceMailListAscOrder);
748
- });
749
- it('verify VoiceMails sorting in Descending Order', function () {
750
- var voiceMailList = _voicemailFixture.getVoicemailListJsonWXC.body.VoiceMessagingMessages.messageInfoList.messageInfo;
751
- var sortedVoicemail = (0, _Utils.getSortedVoicemailList)(voiceMailList, _types.SORT.DESC);
752
- var voiceMailListDescOrder = _voicemailFixture.getDescVoicemailListJsonWXC.body.VoiceMessagingMessages.messageInfoList.messageInfo;
753
- expect(sortedVoicemail).toStrictEqual(voiceMailListDescOrder);
754
- });
755
- });
756
- describe('resolveContact tests', function () {
757
- var scimUrl = "".concat(webex.internal.services._serviceUrls.identity, "/").concat(_constants.IDENTITY_ENDPOINT_RESOURCE, "/").concat(_constants.SCIM_ENDPOINT_RESOURCE, "/").concat(webex.internal.device.orgId, "/").concat(_constants.SCIM_USER_FILTER);
758
- it('Invalid CallingPartyInfo', function () {
759
- var callingPartyInfo = {};
760
- (0, _Utils.resolveContact)(callingPartyInfo).then(function (result) {
761
- expect(result).toBeNull();
762
- });
763
- });
764
- it('Resolve by userExternalId', function () {
765
- var callingPartyInfo = {};
766
- var webexSpy = jest.spyOn(webex, 'request').mockResolvedValue({
767
- statusCode: 200,
768
- body: (0, _testUtil.getSampleScimResponse)()
769
- });
770
- callingPartyInfo.userExternalId = {
771
- $: 'userExternalId'
772
- };
773
- (0, _Utils.resolveContact)(callingPartyInfo).then(function (displayInfo) {
774
- var _callingPartyInfo$use;
775
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.name).toStrictEqual('Cathy');
776
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.num).toStrictEqual('5008');
777
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.avatarSrc).toStrictEqual((0, _testUtil.getSampleScimResponse)().Resources[0].photos[0].value);
778
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.id).toStrictEqual((0, _testUtil.getSampleScimResponse)().Resources[0].id);
779
- var query = scimUrl + encodeURIComponent("id eq \"".concat((_callingPartyInfo$use = callingPartyInfo.userExternalId) === null || _callingPartyInfo$use === void 0 ? void 0 : _callingPartyInfo$use.$, "\""));
780
- expect(webexSpy).toBeCalledOnceWith(expect.objectContaining({
781
- uri: query
782
- }));
783
- });
784
- });
785
- it('Resolve by userExternalId - SCIM exception', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
786
- var _callingPartyInfo$use2;
787
- var callingPartyInfo, warnSpy, webexSpy, displayInfo, query;
788
- return _regenerator.default.wrap(function _callee$(_context) {
789
- while (1) switch (_context.prev = _context.next) {
790
- case 0:
791
- callingPartyInfo = {};
792
- warnSpy = jest.spyOn(_Logger.default, 'warn');
793
- webexSpy = jest.spyOn(webex, 'request').mockRejectedValueOnce({
794
- statusCode: 500
795
- });
796
- callingPartyInfo.userExternalId = {
797
- $: 'userExternalId'
798
- };
799
- _context.next = 6;
800
- return (0, _Utils.resolveContact)(callingPartyInfo);
801
- case 6:
802
- displayInfo = _context.sent;
803
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.name).toBeUndefined();
804
- expect(warnSpy).toHaveBeenCalledWith('Error response: - 500', {
805
- file: 'utils',
806
- method: 'resolveCallerIdDisplay'
807
- });
808
- query = scimUrl + encodeURIComponent("id eq \"".concat((_callingPartyInfo$use2 = callingPartyInfo.userExternalId) === null || _callingPartyInfo$use2 === void 0 ? void 0 : _callingPartyInfo$use2.$, "\""));
809
- expect(webexSpy).toBeCalledOnceWith(expect.objectContaining({
810
- uri: query
811
- }));
812
- case 11:
813
- case "end":
814
- return _context.stop();
815
- }
816
- }, _callee);
817
- })));
818
- it('Resolve by userExternalId - totalResults zero', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
819
- var _callingPartyInfo$use3;
820
- var callingPartyInfo, scimResponse, webexSpy, displayInfo, query;
821
- return _regenerator.default.wrap(function _callee2$(_context2) {
822
- while (1) switch (_context2.prev = _context2.next) {
823
- case 0:
824
- callingPartyInfo = {};
825
- scimResponse = (0, _testUtil.getSampleScimResponse)();
826
- scimResponse.totalResults = '0';
827
- webexSpy = jest.spyOn(webex, 'request').mockResolvedValueOnce({
828
- statusCode: 200,
829
- body: scimResponse
830
- });
831
- callingPartyInfo.userExternalId = {
832
- $: 'userExternalId'
833
- };
834
- _context2.next = 7;
835
- return (0, _Utils.resolveContact)(callingPartyInfo);
836
- case 7:
837
- displayInfo = _context2.sent;
838
- query = scimUrl + encodeURIComponent("id eq \"".concat((_callingPartyInfo$use3 = callingPartyInfo.userExternalId) === null || _callingPartyInfo$use3 === void 0 ? void 0 : _callingPartyInfo$use3.$, "\""));
839
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.name).toBeUndefined();
840
- expect(webexSpy).toBeCalledOnceWith(expect.objectContaining({
841
- uri: query
842
- }));
843
- scimResponse.totalResults = '1';
844
- case 12:
845
- case "end":
846
- return _context2.stop();
847
- }
848
- }, _callee2);
849
- })));
850
- it('Resolve by userExternalId - no primary number and no phone numbers', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
851
- var _callingPartyInfo$use4, _displayInfo, _displayInfo2;
852
- var callingPartyInfo, scimResponse, webexSpy, displayInfo, query, phoneNumbers;
853
- return _regenerator.default.wrap(function _callee3$(_context3) {
854
- while (1) switch (_context3.prev = _context3.next) {
855
- case 0:
856
- callingPartyInfo = {};
857
- scimResponse = (0, _testUtil.getSampleScimResponse)();
858
- scimResponse.Resources[0].phoneNumbers[1].primary = false;
859
- webexSpy = jest.spyOn(webex, 'request').mockResolvedValueOnce({
860
- statusCode: 200,
861
- body: scimResponse
862
- });
863
- callingPartyInfo.userExternalId = {
864
- $: 'userExternalId'
865
- };
866
- _context3.next = 7;
867
- return (0, _Utils.resolveContact)(callingPartyInfo);
868
- case 7:
869
- displayInfo = _context3.sent;
870
- query = scimUrl + encodeURIComponent("id eq \"".concat((_callingPartyInfo$use4 = callingPartyInfo.userExternalId) === null || _callingPartyInfo$use4 === void 0 ? void 0 : _callingPartyInfo$use4.$, "\""));
871
- expect(webexSpy).toBeCalledOnceWith(expect.objectContaining({
872
- uri: query
873
- }));
874
- expect((_displayInfo = displayInfo) === null || _displayInfo === void 0 ? void 0 : _displayInfo.num).toStrictEqual('5008');
875
- webexSpy.mockReset();
876
- scimResponse.Resources[0].phoneNumbers[1].primary = true;
877
-
878
- /* No phone numbers */
879
- phoneNumbers = scimResponse.Resources[0].phoneNumbers;
880
- scimResponse.Resources[0].phoneNumbers = [];
881
- webex.request.mockResolvedValueOnce({
882
- statusCode: 200,
883
- body: scimResponse
884
- });
885
- _context3.next = 18;
886
- return (0, _Utils.resolveContact)(callingPartyInfo);
887
- case 18:
888
- displayInfo = _context3.sent;
889
- expect((_displayInfo2 = displayInfo) === null || _displayInfo2 === void 0 ? void 0 : _displayInfo2.num).toBeUndefined();
890
- expect(webexSpy).toBeCalledOnceWith(expect.objectContaining({
891
- uri: query
892
- }));
893
- scimResponse.Resources[0].phoneNumbers = phoneNumbers;
894
- case 22:
895
- case "end":
896
- return _context3.stop();
897
- }
898
- }, _callee3);
899
- })));
900
- it('Resolve by userExternalId - no photo', function () {
901
- var callingPartyInfo = {};
902
- var scimResponse = (0, _testUtil.getSampleScimResponse)();
903
- scimResponse.Resources[0].photos = [];
904
- var webexSpy = jest.spyOn(webex, 'request').mockResolvedValue({
905
- statusCode: 200,
906
- body: scimResponse
907
- });
908
- callingPartyInfo.userExternalId = {
909
- $: 'userExternalId'
910
- };
911
- (0, _Utils.resolveContact)(callingPartyInfo).then(function (displayInfo) {
912
- var _callingPartyInfo$use5;
913
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.name).toStrictEqual('Cathy');
914
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.num).toStrictEqual('5008');
915
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.avatarSrc).toStrictEqual('unknown');
916
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.id).toStrictEqual((0, _testUtil.getSampleScimResponse)().Resources[0].id);
917
- var query = scimUrl + encodeURIComponent("id eq \"".concat((_callingPartyInfo$use5 = callingPartyInfo.userExternalId) === null || _callingPartyInfo$use5 === void 0 ? void 0 : _callingPartyInfo$use5.$, "\""));
918
- expect(webexSpy).toBeCalledOnceWith(expect.objectContaining({
919
- uri: query
920
- }));
921
- });
922
- });
923
- it('Resolve by name', function () {
924
- var callingPartyInfo = {};
925
- var webexSpy = jest.spyOn(webex.people, 'list').mockResolvedValue((0, _testUtil.getSamplePeopleListResponse)());
926
- callingPartyInfo.name = {
927
- $: 'Name'
928
- };
929
- (0, _Utils.resolveContact)(callingPartyInfo).then(function (displayInfo) {
930
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.name).toStrictEqual((0, _testUtil.getSamplePeopleListResponse)().items[0].displayName);
931
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.num).toStrictEqual((0, _testUtil.getSamplePeopleListResponse)().items[0].phoneNumbers[0].value);
932
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.avatarSrc).toStrictEqual((0, _testUtil.getSamplePeopleListResponse)().items[0].avatar);
933
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.id).toStrictEqual(Buffer.from((0, _testUtil.getSamplePeopleListResponse)().items[0].id, 'base64').toString('binary').split('/').pop());
934
- expect(webexSpy).toBeCalledOnceWith(expect.objectContaining({
935
- displayName: 'Name'
936
- }));
937
- });
938
- });
939
- it('Resolve by name - Empty Info', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
940
- var callingPartyInfo, peopleListResponse, items, webexSpy, displayInfo;
941
- return _regenerator.default.wrap(function _callee4$(_context4) {
942
- while (1) switch (_context4.prev = _context4.next) {
943
- case 0:
944
- callingPartyInfo = {};
945
- peopleListResponse = (0, _testUtil.getSamplePeopleListResponse)();
946
- items = peopleListResponse.items;
947
- peopleListResponse.items = [];
948
- webexSpy = jest.spyOn(webex.people, 'list').mockResolvedValueOnce(peopleListResponse);
949
- callingPartyInfo.name = {
950
- $: 'Name'
951
- };
952
- _context4.next = 8;
953
- return (0, _Utils.resolveContact)(callingPartyInfo);
954
- case 8:
955
- displayInfo = _context4.sent;
956
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.name).toBeUndefined();
957
- expect(webexSpy).toBeCalledOnceWith(expect.objectContaining({
958
- displayName: 'Name'
959
- }));
960
- peopleListResponse.items = items;
961
- case 12:
962
- case "end":
963
- return _context4.stop();
964
- }
965
- }, _callee4);
966
- })));
967
- it('Resolve by name - ID as plain UUID instead of part of URI', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
968
- var _displayInfo3, _displayInfo4, _displayInfo5, _displayInfo6, _displayInfo7, _displayInfo8;
969
- var callingPartyInfo, peopleListResponse, id, webexSpy, displayInfo;
970
- return _regenerator.default.wrap(function _callee5$(_context5) {
971
- while (1) switch (_context5.prev = _context5.next) {
972
- case 0:
973
- callingPartyInfo = {};
974
- peopleListResponse = (0, _testUtil.getSamplePeopleListResponse)();
975
- id = peopleListResponse.items[0].id;
976
- /* Yjg1M2JiZDEtMTEzNi00ZDI1LTkzOGQtMGMzNzUzMWIxMjMz -> b853bbd1-1136-4d25-938d-0c37531b1233 */
977
- peopleListResponse.items[0].id = 'Yjg1M2JiZDEtMTEzNi00ZDI1LTkzOGQtMGMzNzUzMWIxMjMz';
978
- webexSpy = jest.spyOn(webex.people, 'list').mockResolvedValueOnce(peopleListResponse);
979
- callingPartyInfo.name = {
980
- $: 'Name'
981
- };
982
- _context5.next = 8;
983
- return (0, _Utils.resolveContact)(callingPartyInfo);
984
- case 8:
985
- displayInfo = _context5.sent;
986
- expect(webexSpy).toBeCalledOnceWith(expect.objectContaining({
987
- displayName: 'Name'
988
- }));
989
- expect((_displayInfo3 = displayInfo) === null || _displayInfo3 === void 0 ? void 0 : _displayInfo3.name).toStrictEqual(peopleListResponse.items[0].displayName);
990
- expect((_displayInfo4 = displayInfo) === null || _displayInfo4 === void 0 ? void 0 : _displayInfo4.num).toStrictEqual(peopleListResponse.items[0].phoneNumbers[0].value);
991
- expect((_displayInfo5 = displayInfo) === null || _displayInfo5 === void 0 ? void 0 : _displayInfo5.avatarSrc).toStrictEqual(peopleListResponse.items[0].avatar);
992
- expect((_displayInfo6 = displayInfo) === null || _displayInfo6 === void 0 ? void 0 : _displayInfo6.id).toStrictEqual(Buffer.from(peopleListResponse.items[0].id, 'base64').toString('binary').split('/').pop());
993
- webexSpy.mockReset();
994
-
995
- /* Also test empty id */
996
- peopleListResponse.items[0].id = '';
997
- webex.people.list.mockResolvedValueOnce(peopleListResponse);
998
- _context5.next = 19;
999
- return (0, _Utils.resolveContact)(callingPartyInfo);
1000
- case 19:
1001
- displayInfo = _context5.sent;
1002
- expect((_displayInfo7 = displayInfo) === null || _displayInfo7 === void 0 ? void 0 : _displayInfo7.id).toStrictEqual('');
1003
- expect((_displayInfo8 = displayInfo) === null || _displayInfo8 === void 0 ? void 0 : _displayInfo8.name).toStrictEqual(peopleListResponse.items[0].displayName);
1004
- expect(webexSpy).toBeCalledOnceWith(expect.objectContaining({
1005
- displayName: 'Name'
1006
- }));
1007
- peopleListResponse.items[0].id = id;
1008
- case 24:
1009
- case "end":
1010
- return _context5.stop();
1011
- }
1012
- }, _callee5);
1013
- })));
1014
- it('Resolve by name - Phone numbers no match for type - work', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
1015
- var callingPartyInfo, peopleListResponse, phoneNumbers, webexSpy, displayInfo;
1016
- return _regenerator.default.wrap(function _callee6$(_context6) {
1017
- while (1) switch (_context6.prev = _context6.next) {
1018
- case 0:
1019
- callingPartyInfo = {};
1020
- peopleListResponse = (0, _testUtil.getSamplePeopleListResponse)();
1021
- phoneNumbers = peopleListResponse.items[0].phoneNumbers;
1022
- peopleListResponse.items[0].phoneNumbers[0].type = 'mobile';
1023
- peopleListResponse.items[0].phoneNumbers[1].type = 'mobile';
1024
- webexSpy = jest.spyOn(webex.people, 'list').mockResolvedValueOnce(peopleListResponse);
1025
- callingPartyInfo.name = {
1026
- $: 'Name'
1027
- };
1028
- _context6.next = 9;
1029
- return (0, _Utils.resolveContact)(callingPartyInfo);
1030
- case 9:
1031
- displayInfo = _context6.sent;
1032
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.name).toStrictEqual(peopleListResponse.items[0].displayName);
1033
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.num).toStrictEqual(peopleListResponse.items[0].phoneNumbers[0].value);
1034
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.avatarSrc).toStrictEqual(peopleListResponse.items[0].avatar);
1035
- expect(webexSpy).toBeCalledOnceWith(expect.objectContaining({
1036
- displayName: 'Name'
1037
- }));
1038
- peopleListResponse.items[0].phoneNumbers = phoneNumbers;
1039
- case 15:
1040
- case "end":
1041
- return _context6.stop();
1042
- }
1043
- }, _callee6);
1044
- })));
1045
- it('Resolve by name - Phone numbers empty', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
1046
- var callingPartyInfo, peopleListResponse, phoneNumbers, webexSpy, displayInfo;
1047
- return _regenerator.default.wrap(function _callee7$(_context7) {
1048
- while (1) switch (_context7.prev = _context7.next) {
1049
- case 0:
1050
- callingPartyInfo = {};
1051
- peopleListResponse = (0, _testUtil.getSamplePeopleListResponse)();
1052
- phoneNumbers = peopleListResponse.items[0].phoneNumbers;
1053
- peopleListResponse.items[0].phoneNumbers = [];
1054
- webexSpy = jest.spyOn(webex.people, 'list').mockResolvedValueOnce(peopleListResponse);
1055
- callingPartyInfo.name = {
1056
- $: 'Name'
1057
- };
1058
- _context7.next = 8;
1059
- return (0, _Utils.resolveContact)(callingPartyInfo);
1060
- case 8:
1061
- displayInfo = _context7.sent;
1062
- expect(webexSpy).toBeCalledOnceWith(expect.objectContaining({
1063
- displayName: 'Name'
1064
- }));
1065
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.name).toStrictEqual(peopleListResponse.items[0].displayName);
1066
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.num).toBeUndefined();
1067
- expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.avatarSrc).toStrictEqual(peopleListResponse.items[0].avatar);
1068
- peopleListResponse.items[0].phoneNumbers = phoneNumbers;
1069
- case 14:
1070
- case "end":
1071
- return _context7.stop();
1072
- }
1073
- }, _callee7);
1074
- })));
1075
- });
1076
- describe('Store and Fetch voicemail tests', function () {
1077
- /* Tests Voicemail pagination - storing voicemail list to and fetching from session storage */
1078
- var dummyContext = 'dummy';
1079
- var logContext = {
1080
- file: 'voicemail',
1081
- method: 'fetchVoicemail'
1082
- };
1083
- var getEncryptedVoicemail = function getEncryptedVoicemail(vmList) {
1084
- return Buffer.from((0, _stringify.default)(vmList), 'utf8').toString('base64');
1085
- };
1086
- var getDecryptedVoicemail = function getDecryptedVoicemail() {
1087
- var decryptedList = JSON.parse(Buffer.from(sessionStorage.getItem(dummyContext), 'base64').toString('utf8'));
1088
- return decryptedList;
1089
- };
1090
- beforeAll(function () {
1091
- // Mock storage
1092
- var vmListStorage = {};
1093
- global.Storage.prototype.setItem = jest.fn(function (key, value) {
1094
- vmListStorage[key] = value;
1095
- });
1096
- global.Storage.prototype.getItem = jest.fn(function (key) {
1097
- return vmListStorage[key];
1098
- });
1099
- });
1100
- it('verify saving Voicemails in session storage', function () {
1101
- var voicemailList = _voicemailFixture.getVoicemailListJsonWXC.body.VoiceMessagingMessages.messageInfoList.messageInfo;
1102
- (0, _Utils.storeVoicemailList)(dummyContext, voicemailList);
1103
- var voicemailFromSessionStorage = getDecryptedVoicemail();
1104
- expect(global.sessionStorage.setItem).toHaveBeenCalledTimes(1);
1105
- expect(voicemailFromSessionStorage).toEqual(voicemailList);
1106
- });
1107
- it('verify fetching all 5 voicemails from session storage', function () {
1108
- var voicemailList = _voicemailFixture.getVoicemailListJsonWXC.body.VoiceMessagingMessages.messageInfoList.messageInfo;
1109
- var encryptedVm = getEncryptedVoicemail(voicemailList);
1110
- global.sessionStorage.setItem(dummyContext, encryptedVm.toString());
1111
- var voicemailFromSessionStorage = (0, _Utils.fetchVoicemailList)(dummyContext, 0, 5, logContext);
1112
- expect(global.Storage.prototype.getItem).toHaveBeenCalledTimes(1);
1113
- expect(voicemailFromSessionStorage).toEqual({
1114
- messages: voicemailList,
1115
- moreVMAvailable: false
1116
- });
1117
- });
1118
- it('verify fetching first 3 VoiceMails from session storage', function () {
1119
- var voicemailList = _voicemailFixture.getVoicemailListJsonWXC.body.VoiceMessagingMessages.messageInfoList.messageInfo;
1120
- var encryptedVm = getEncryptedVoicemail(voicemailList);
1121
- global.sessionStorage.setItem(dummyContext, encryptedVm.toString());
1122
- var voicemailFromSessionStorage = (0, _Utils.fetchVoicemailList)(dummyContext, 0, 3, logContext);
1123
- expect(global.Storage.prototype.getItem).toHaveBeenCalledTimes(1);
1124
- expect(voicemailFromSessionStorage).toEqual({
1125
- messages: voicemailList.slice(0, 3),
1126
- moreVMAvailable: true
1127
- });
1128
- });
1129
- it('verify fetching 2nd and 3rd Voicemails from session storage', function () {
1130
- var voicemailList = _voicemailFixture.getVoicemailListJsonWXC.body.VoiceMessagingMessages.messageInfoList.messageInfo;
1131
- var encryptedVm = getEncryptedVoicemail(voicemailList);
1132
- global.sessionStorage.setItem(dummyContext, encryptedVm.toString());
1133
- var voicemailFromSessionStorage = (0, _Utils.fetchVoicemailList)(dummyContext, 1, 2, logContext);
1134
- expect(global.Storage.prototype.getItem).toHaveBeenCalledTimes(1);
1135
- expect(voicemailFromSessionStorage).toEqual({
1136
- messages: voicemailList.slice(1, 3),
1137
- moreVMAvailable: true
1138
- });
1139
- });
1140
- it('verify fetch Voicemails with offset limit more than the available ones from session storage', function () {
1141
- var voicemailList = [];
1142
- var encryptedVm = getEncryptedVoicemail(voicemailList);
1143
- global.sessionStorage.setItem(dummyContext, encryptedVm.toString());
1144
- var voicemailFromSessionStorage = (0, _Utils.fetchVoicemailList)(dummyContext, 1, 5, logContext);
1145
- expect(global.Storage.prototype.getItem).toHaveBeenCalledTimes(1);
1146
- expect(voicemailFromSessionStorage).toEqual({
1147
- messages: voicemailList.slice(1, 5),
1148
- moreVMAvailable: false
1149
- });
1150
- });
1151
- it('verify fetching Voicemails when it is []', function () {
1152
- var voicemailFromSessionStorage = (0, _Utils.fetchVoicemailList)(dummyContext, 1, 5, logContext);
1153
- expect(global.Storage.prototype.getItem).toHaveBeenCalledTimes(1);
1154
- expect(voicemailFromSessionStorage).toEqual({
1155
- messages: [],
1156
- moreVMAvailable: false
1157
- });
1158
- });
1159
- it('verify fetching Voicemails when there is exception', function () {
1160
- var voiceMailList = '$%%ˆ';
1161
- var logSpy = jest.spyOn(_Logger.default, 'warn');
1162
- global.sessionStorage.setItem(dummyContext, voiceMailList);
1163
- var voicemailFromSessionStorage = (0, _Utils.fetchVoicemailList)(dummyContext, 1, 5, logContext);
1164
- expect(global.Storage.prototype.getItem).toBeCalledOnceWith('dummy');
1165
- expect(logSpy).toHaveBeenCalledTimes(2);
1166
- expect(logSpy).toHaveBeenCalledWith('Caught exception while fetching voicemail from storage. SyntaxError: Unexpected end of JSON input', logContext);
1167
- expect(logSpy).toHaveBeenCalledWith('422 Exception has occurred', {});
1168
- expect(voicemailFromSessionStorage).toEqual({
1169
- messages: [],
1170
- moreVMAvailable: false
1171
- });
1172
- });
1173
- });
1174
- describe('Infer id from UUID Tests', function () {
1175
- /* Tests conversion of UUID to hydra Id */
1176
-
1177
- it('verify encoding of userId to personId', function () {
1178
- var uuid = '14533573-f6aa-429d-b4fe-58aa04a2b631';
1179
- var hydraId = (0, _Utils.inferIdFromUuid)(uuid, _types.DecodeType.PEOPLE);
1180
- var uuidAgain = Buffer.from(hydraId, 'base64').toString('binary');
1181
- expect("".concat(_constants2.INFER_ID_CONSTANT, "/").concat(_types.DecodeType.PEOPLE, "/").concat(uuid)).toStrictEqual(uuidAgain);
1182
- });
1183
- it('verify encoding of orgId', function () {
1184
- var orgId = '24533573-f6aa-429d-b4fe-58aa04a2b630';
1185
- var encodedOrgId = (0, _Utils.inferIdFromUuid)(orgId, _types.DecodeType.ORGANIZATION);
1186
- var orgIdAgain = Buffer.from(encodedOrgId, 'base64').toString('binary');
1187
- expect("".concat(_constants2.INFER_ID_CONSTANT, "/").concat(_types.DecodeType.ORGANIZATION, "/").concat(orgId)).toStrictEqual(orgIdAgain);
1188
- });
1189
- });
1190
- describe('Get endpoint by CALLING_BACKEND tests', function () {
1191
- it('verify invalid calling backend ucm for xsi endpoint', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
1192
- return _regenerator.default.wrap(function _callee8$(_context8) {
1193
- while (1) switch (_context8.prev = _context8.next) {
1194
- case 0:
1195
- _context8.t0 = expect;
1196
- _context8.next = 3;
1197
- return (0, _Utils.getXsiActionEndpoint)(webex, {
1198
- file: 'testFile',
1199
- method: 'testMethod'
1200
- }, _types.CALLING_BACKEND.UCM);
1201
- case 3:
1202
- _context8.t1 = _context8.sent;
1203
- (0, _context8.t0)(_context8.t1).toBeInstanceOf(Error);
1204
- case 5:
1205
- case "end":
1206
- return _context8.stop();
1207
- }
1208
- }, _callee8);
1209
- })));
1210
- it('verify invalid calling backend wxc for vg endpoint', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9() {
1211
- return _regenerator.default.wrap(function _callee9$(_context9) {
1212
- while (1) switch (_context9.prev = _context9.next) {
1213
- case 0:
1214
- _context9.t0 = expect;
1215
- _context9.next = 3;
1216
- return (0, _Utils.getVgActionEndpoint)(webex, _types.CALLING_BACKEND.WXC);
1217
- case 3:
1218
- _context9.t1 = _context9.sent;
1219
- (0, _context9.t0)(_context9.t1).toBeInstanceOf(Error);
1220
- case 5:
1221
- case "end":
1222
- return _context9.stop();
1223
- }
1224
- }, _callee9);
1225
- })));
1226
- });
1227
- //# sourceMappingURL=Utils.test.js.map