@webex/calling 3.12.0-llmrefactor.1 → 3.12.0-llmrefactor.10

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 (51) hide show
  1. package/dist/CallingClient/CallingClient.js +17 -11
  2. package/dist/CallingClient/CallingClient.js.map +1 -1
  3. package/dist/CallingClient/CallingClient.test.js +383 -185
  4. package/dist/CallingClient/CallingClient.test.js.map +1 -1
  5. package/dist/CallingClient/calling/call.js +1 -1
  6. package/dist/CallingClient/calling/call.js.map +1 -1
  7. package/dist/CallingClient/calling/call.test.js +545 -513
  8. package/dist/CallingClient/calling/call.test.js.map +1 -1
  9. package/dist/CallingClient/constants.js +4 -2
  10. package/dist/CallingClient/constants.js.map +1 -1
  11. package/dist/CallingClient/line/index.js +4 -0
  12. package/dist/CallingClient/line/index.js.map +1 -1
  13. package/dist/CallingClient/line/line.test.js +47 -10
  14. package/dist/CallingClient/line/line.test.js.map +1 -1
  15. package/dist/CallingClient/registration/register.js +555 -409
  16. package/dist/CallingClient/registration/register.js.map +1 -1
  17. package/dist/CallingClient/registration/register.test.js +636 -81
  18. package/dist/CallingClient/registration/register.test.js.map +1 -1
  19. package/dist/CallingClient/registration/types.js +26 -0
  20. package/dist/CallingClient/registration/types.js.map +1 -1
  21. package/dist/Errors/types.js +2 -0
  22. package/dist/Errors/types.js.map +1 -1
  23. package/dist/Events/types.js.map +1 -1
  24. package/dist/common/Utils.js +68 -44
  25. package/dist/common/Utils.js.map +1 -1
  26. package/dist/common/Utils.test.js +267 -195
  27. package/dist/common/Utils.test.js.map +1 -1
  28. package/dist/module/CallingClient/CallingClient.js +11 -10
  29. package/dist/module/CallingClient/calling/call.js +3 -1
  30. package/dist/module/CallingClient/constants.js +2 -0
  31. package/dist/module/CallingClient/line/index.js +2 -0
  32. package/dist/module/CallingClient/registration/register.js +65 -14
  33. package/dist/module/CallingClient/registration/types.js +5 -1
  34. package/dist/module/Errors/types.js +2 -0
  35. package/dist/module/common/Utils.js +15 -2
  36. package/dist/types/CallingClient/CallingClient.d.ts.map +1 -1
  37. package/dist/types/CallingClient/calling/call.d.ts.map +1 -1
  38. package/dist/types/CallingClient/constants.d.ts +2 -0
  39. package/dist/types/CallingClient/constants.d.ts.map +1 -1
  40. package/dist/types/CallingClient/line/index.d.ts.map +1 -1
  41. package/dist/types/CallingClient/registration/register.d.ts +3 -1
  42. package/dist/types/CallingClient/registration/register.d.ts.map +1 -1
  43. package/dist/types/CallingClient/registration/types.d.ts +22 -0
  44. package/dist/types/CallingClient/registration/types.d.ts.map +1 -1
  45. package/dist/types/Errors/types.d.ts +2 -0
  46. package/dist/types/Errors/types.d.ts.map +1 -1
  47. package/dist/types/Events/types.d.ts +1 -1
  48. package/dist/types/Events/types.d.ts.map +1 -1
  49. package/dist/types/common/Utils.d.ts +2 -5
  50. package/dist/types/common/Utils.d.ts.map +1 -1
  51. package/package.json +11 -11
@@ -33,7 +33,7 @@ var _types4 = require("../line/types");
33
33
  var _LineError = require("../../Errors/catalog/LineError");
34
34
  var _types5 = require("../../Metrics/types");
35
35
  var _request = require("../utils/request");
36
- function _interopRequireWildcard(e, t) { if ("function" == typeof _WeakMap) var r = new _WeakMap(), n = new _WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = _Object$defineProperty) && _Object$getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
36
+ function _interopRequireWildcard(e, t) { if ("function" == typeof _WeakMap) var r = new _WeakMap(), n = new _WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = _Object$defineProperty) && _Object$getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
37
37
  function ownKeys(e, r) { var t = _Object$keys2(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; }
38
38
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; } /* eslint-disable @typescript-eslint/no-shadow */
39
39
  jest.mock('../../mobius-socket', function () {
@@ -1905,21 +1905,575 @@ describe('Registration Tests', function () {
1905
1905
  }
1906
1906
  }, _callee38);
1907
1907
  })));
1908
+ describe('409 Conflict on keepalive (session superseded)', function () {
1909
+ var conflictError = {
1910
+ statusCode: 409,
1911
+ headers: {
1912
+ trackingid: 'tid-409'
1913
+ }
1914
+ };
1915
+ var sendKeepaliveFailure = /*#__PURE__*/function () {
1916
+ var _ref40 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee39(err, keepAliveRetryCount) {
1917
+ return _regenerator.default.wrap(function (_context39) {
1918
+ while (1) switch (_context39.prev = _context39.next) {
1919
+ case 0:
1920
+ reg.webWorker.onmessage({
1921
+ data: {
1922
+ type: _types.WorkerMessageType.KEEPALIVE_FAILURE,
1923
+ err: err,
1924
+ keepAliveRetryCount: keepAliveRetryCount
1925
+ }
1926
+ });
1927
+ _context39.next = 1;
1928
+ return flushPromises();
1929
+ case 1:
1930
+ case "end":
1931
+ return _context39.stop();
1932
+ }
1933
+ }, _callee39);
1934
+ }));
1935
+ return function sendKeepaliveFailure(_x2, _x3) {
1936
+ return _ref40.apply(this, arguments);
1937
+ };
1938
+ }();
1939
+ var getSupersededError = function getSupersededError() {
1940
+ var unregisteredCall = lineEmitter.mock.calls.find(function (_ref41) {
1941
+ var _ref42 = (0, _slicedToArray2.default)(_ref41, 1),
1942
+ event = _ref42[0];
1943
+ return event === _types4.LINE_EVENTS.UNREGISTERED;
1944
+ });
1945
+ return unregisteredCall === null || unregisteredCall === void 0 ? void 0 : unregisteredCall[2];
1946
+ };
1947
+ it.each([{
1948
+ description: 'on the very first keepalive failure',
1949
+ keepAliveRetryCount: 1
1950
+ }, {
1951
+ description: 'when the retry count already reached the threshold',
1952
+ keepAliveRetryCount: 5
1953
+ }])('stops keepalive without re-registration $description', /*#__PURE__*/function () {
1954
+ var _ref44 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee40(_ref43) {
1955
+ var keepAliveRetryCount, clearTimerSpy, reconnectSpy, registerSpy, handle404Spy;
1956
+ return _regenerator.default.wrap(function (_context40) {
1957
+ while (1) switch (_context40.prev = _context40.next) {
1958
+ case 0:
1959
+ keepAliveRetryCount = _ref43.keepAliveRetryCount;
1960
+ _context40.next = 1;
1961
+ return beforeEachSetupForKeepalive();
1962
+ case 1:
1963
+ clearTimerSpy = jest.spyOn(reg, 'clearKeepaliveTimer');
1964
+ reconnectSpy = jest.spyOn(reg, 'reconnectOnFailure');
1965
+ registerSpy = jest.spyOn(reg, 'attemptRegistrationWithServers');
1966
+ handle404Spy = jest.spyOn(reg, 'handle404KeepaliveFailure');
1967
+ lineEmitter.mockClear();
1968
+ _context40.next = 2;
1969
+ return sendKeepaliveFailure(conflictError, keepAliveRetryCount);
1970
+ case 2:
1971
+ // The 409 is classified by the common registration error handler.
1972
+ expect(handleErrorSpy).toHaveBeenCalledWith(conflictError, expect.anything(), {
1973
+ file: _constants.REGISTRATION_FILE,
1974
+ method: _constants.KEEPALIVE_UTIL
1975
+ }, expect.objectContaining({
1976
+ sessionSupersededCb: expect.any(Function)
1977
+ }));
1978
+ expect(warnSpy).toBeCalledWith('409 Conflict: session superseded by another device for this user', {
1979
+ file: _constants.REGISTRATION_FILE,
1980
+ method: _constants.KEEPALIVE_UTIL
1981
+ });
1982
+ expect(warnSpy).toBeCalledWith("Stopping keepalive without re-registration, session superseded by another device for this user - keepaliveRetryCount: ".concat(keepAliveRetryCount), {
1983
+ file: _constants.REGISTRATION_FILE,
1984
+ method: _constants.METHODS.HANDLE_409_KEEPALIVE_FAILURE
1985
+ });
1986
+
1987
+ // Keepalive is stopped and no further keepalive can be sent.
1988
+ expect(clearTimerSpy).toHaveBeenCalled();
1989
+ expect(reg.webWorker).toBeUndefined();
1990
+ expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
1991
+ expect(reg.failbackTimer).toStrictEqual(undefined);
1992
+
1993
+ // No re-registration of any kind is attempted.
1994
+ expect(reconnectSpy).not.toHaveBeenCalled();
1995
+ expect(restoreSpy).not.toHaveBeenCalled();
1996
+ expect(restartSpy).not.toHaveBeenCalled();
1997
+ expect(failoverSpy).not.toHaveBeenCalled();
1998
+ expect(registerSpy).not.toHaveBeenCalled();
1999
+ expect(handle404Spy).not.toHaveBeenCalled();
2000
+ expect(reg.reconnectPending).toStrictEqual(false);
2001
+ case 3:
2002
+ case "end":
2003
+ return _context40.stop();
2004
+ }
2005
+ }, _callee40);
2006
+ }));
2007
+ return function (_x4) {
2008
+ return _ref44.apply(this, arguments);
2009
+ };
2010
+ }());
2011
+ it('notifies the consumer with a single UNREGISTERED carrying the superseded reason', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee41() {
2012
+ var supersededError;
2013
+ return _regenerator.default.wrap(function (_context41) {
2014
+ while (1) switch (_context41.prev = _context41.next) {
2015
+ case 0:
2016
+ _context41.next = 1;
2017
+ return beforeEachSetupForKeepalive();
2018
+ case 1:
2019
+ lineEmitter.mockClear();
2020
+ _context41.next = 2;
2021
+ return sendKeepaliveFailure(conflictError, 1);
2022
+ case 2:
2023
+ expect(lineEmitter.mock.calls.filter(function (_ref46) {
2024
+ var _ref47 = (0, _slicedToArray2.default)(_ref46, 1),
2025
+ event = _ref47[0];
2026
+ return event === _types4.LINE_EVENTS.UNREGISTERED;
2027
+ })).toHaveLength(1);
2028
+ expect(lineEmitter).not.toHaveBeenCalledWith(_types4.LINE_EVENTS.RECONNECTING);
2029
+ expect(lineEmitter).toHaveBeenLastCalledWith(_types4.LINE_EVENTS.UNREGISTERED, undefined, expect.any(_LineError.LineError));
2030
+ supersededError = getSupersededError();
2031
+ expect(supersededError.getError()).toStrictEqual({
2032
+ message: _constants.SESSION_SUPERSEDED_MESSAGE,
2033
+ type: _types3.ERROR_TYPE.SESSION_SUPERSEDED,
2034
+ status: _types.RegistrationStatus.INACTIVE,
2035
+ context: {
2036
+ file: _constants.REGISTRATION_FILE,
2037
+ method: _constants.KEEPALIVE_UTIL
2038
+ }
2039
+ });
2040
+ case 3:
2041
+ case "end":
2042
+ return _context41.stop();
2043
+ }
2044
+ }, _callee41);
2045
+ })));
2046
+ it('submits the keepalive failure metric and uploads logs', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee42() {
2047
+ var uploadLogsSpy;
2048
+ return _regenerator.default.wrap(function (_context42) {
2049
+ while (1) switch (_context42.prev = _context42.next) {
2050
+ case 0:
2051
+ _context42.next = 1;
2052
+ return beforeEachSetupForKeepalive();
2053
+ case 1:
2054
+ uploadLogsSpy = jest.spyOn(utils, 'uploadLogs');
2055
+ lineEmitter.mockClear();
2056
+ metricSpy.mockClear();
2057
+ _context42.next = 2;
2058
+ return sendKeepaliveFailure(conflictError, 2);
2059
+ case 2:
2060
+ expect(metricSpy).toBeCalledOnceWith(_types5.METRIC_EVENT.KEEPALIVE_ERROR, _types5.REG_ACTION.KEEPALIVE_FAILURE, _types5.METRIC_TYPE.BEHAVIORAL, _constants.METHODS.HANDLE_409_KEEPALIVE_FAILURE, 'PRIMARY', conflictError.headers.trackingid, 2, getSupersededError());
2061
+ expect(uploadLogsSpy).toHaveBeenCalled();
2062
+ case 3:
2063
+ case "end":
2064
+ return _context42.stop();
2065
+ }
2066
+ }, _callee42);
2067
+ })));
2068
+ it('closes the Mobius WebSocket when the socket transport is enabled', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee43() {
2069
+ var apiRequest, disconnectSocketSpy;
2070
+ return _regenerator.default.wrap(function (_context43) {
2071
+ while (1) switch (_context43.prev = _context43.next) {
2072
+ case 0:
2073
+ _context43.next = 1;
2074
+ return beforeEachSetupForKeepalive();
2075
+ case 1:
2076
+ apiRequest = _request.APIRequest.getInstance({
2077
+ webex: webex
2078
+ });
2079
+ jest.spyOn(apiRequest, 'isSocketEnabled').mockReturnValue(true);
2080
+ disconnectSocketSpy = jest.spyOn(apiRequest, 'disconnectFromMobiusSocket').mockResolvedValue();
2081
+ lineEmitter.mockClear();
2082
+ _context43.next = 2;
2083
+ return sendKeepaliveFailure(conflictError, 1);
2084
+ case 2:
2085
+ expect(disconnectSocketSpy).toBeCalledOnceWith({
2086
+ code: 3050,
2087
+ reason: 'done (permanent)'
2088
+ });
2089
+ expect(lineEmitter).toHaveBeenLastCalledWith(_types4.LINE_EVENTS.UNREGISTERED, undefined, expect.any(_LineError.LineError));
2090
+ case 3:
2091
+ case "end":
2092
+ return _context43.stop();
2093
+ }
2094
+ }, _callee43);
2095
+ })));
2096
+ it('still notifies the consumer when the Mobius WebSocket teardown fails', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee44() {
2097
+ var apiRequest;
2098
+ return _regenerator.default.wrap(function (_context44) {
2099
+ while (1) switch (_context44.prev = _context44.next) {
2100
+ case 0:
2101
+ _context44.next = 1;
2102
+ return beforeEachSetupForKeepalive();
2103
+ case 1:
2104
+ apiRequest = _request.APIRequest.getInstance({
2105
+ webex: webex
2106
+ });
2107
+ jest.spyOn(apiRequest, 'isSocketEnabled').mockReturnValue(true);
2108
+ jest.spyOn(apiRequest, 'disconnectFromMobiusSocket').mockRejectedValue(new Error('socket teardown failed'));
2109
+ lineEmitter.mockClear();
2110
+ _context44.next = 2;
2111
+ return sendKeepaliveFailure(conflictError, 1);
2112
+ case 2:
2113
+ expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining('Mobius socket disconnect failed after session-superseded'), {
2114
+ file: _constants.REGISTRATION_FILE,
2115
+ method: _constants.METHODS.HANDLE_409_KEEPALIVE_FAILURE
2116
+ });
2117
+ expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
2118
+ expect(lineEmitter).toHaveBeenLastCalledWith(_types4.LINE_EVENTS.UNREGISTERED, undefined, expect.any(_LineError.LineError));
2119
+ case 3:
2120
+ case "end":
2121
+ return _context44.stop();
2122
+ }
2123
+ }, _callee44);
2124
+ })));
2125
+ it.each([{
2126
+ description: '404 device not found',
2127
+ err: {
2128
+ statusCode: 404
2129
+ }
2130
+ }, {
2131
+ description: '429 too many requests',
2132
+ err: {
2133
+ statusCode: 429,
2134
+ headers: {
2135
+ 'retry-after': 5
2136
+ }
2137
+ }
2138
+ }, {
2139
+ description: '503 service unavailable',
2140
+ err: {
2141
+ statusCode: 503
2142
+ }
2143
+ }])('leaves the existing handling of $description untouched', /*#__PURE__*/function () {
2144
+ var _ref52 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee45(_ref51) {
2145
+ var err, handle409Spy;
2146
+ return _regenerator.default.wrap(function (_context45) {
2147
+ while (1) switch (_context45.prev = _context45.next) {
2148
+ case 0:
2149
+ err = _ref51.err;
2150
+ _context45.next = 1;
2151
+ return beforeEachSetupForKeepalive();
2152
+ case 1:
2153
+ handle409Spy = jest.spyOn(reg, 'handle409KeepaliveFailure');
2154
+ lineEmitter.mockClear();
2155
+ handleErrorSpy.mockClear();
2156
+ _context45.next = 2;
2157
+ return sendKeepaliveFailure(err, 1);
2158
+ case 2:
2159
+ expect(handle409Spy).not.toHaveBeenCalled();
2160
+ expect(handleErrorSpy).toHaveBeenCalledWith(err, expect.anything(), {
2161
+ file: _constants.REGISTRATION_FILE,
2162
+ method: _constants.KEEPALIVE_UTIL
2163
+ }, expect.anything());
2164
+ expect(lineEmitter).not.toHaveBeenCalledWith(_types4.LINE_EVENTS.UNREGISTERED, undefined, expect.anything());
2165
+ case 3:
2166
+ case "end":
2167
+ return _context45.stop();
2168
+ }
2169
+ }, _callee45);
2170
+ }));
2171
+ return function (_x5) {
2172
+ return _ref52.apply(this, arguments);
2173
+ };
2174
+ }());
2175
+ it('stays terminal when the network recovers after a superseded session', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee46() {
2176
+ var retry;
2177
+ return _regenerator.default.wrap(function (_context46) {
2178
+ while (1) switch (_context46.prev = _context46.next) {
2179
+ case 0:
2180
+ _context46.next = 1;
2181
+ return beforeEachSetupForKeepalive();
2182
+ case 1:
2183
+ lineEmitter.mockClear();
2184
+ _context46.next = 2;
2185
+ return sendKeepaliveFailure(conflictError, 1);
2186
+ case 2:
2187
+ expect(reg.sessionSuperseded).toStrictEqual(true);
2188
+ restoreSpy.mockClear();
2189
+ restartSpy.mockClear();
2190
+ postRegistrationSpy.mockClear();
2191
+ failoverSpy.mockClear();
2192
+ _context46.next = 3;
2193
+ return reg.handleConnectionRestoration(true);
2194
+ case 3:
2195
+ retry = _context46.sent;
2196
+ /* The restoration runs, but every registration attempt it makes is refused at the
2197
+ * choke point, so nothing reaches Mobius and no failover is rescheduled. */
2198
+ expect(retry).toStrictEqual(false);
2199
+ expect(warnSpy).toHaveBeenCalledWith("Session superseded, skipping registration attempt - caller: ".concat(_constants.METHODS.HANDLE_CONNECTION_RESTORATION), {
2200
+ file: _constants.REGISTRATION_FILE,
2201
+ method: _constants.METHODS.HANDLE_CONNECTION_RESTORATION
2202
+ });
2203
+ expect(postRegistrationSpy).not.toHaveBeenCalled();
2204
+ expect(restartSpy).not.toHaveBeenCalled();
2205
+ expect(failoverSpy).not.toHaveBeenCalled();
2206
+ expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
2207
+ case 4:
2208
+ case "end":
2209
+ return _context46.stop();
2210
+ }
2211
+ }, _callee46);
2212
+ })));
2213
+ it('abandons a restoration that was already queued when the session was superseded', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee47() {
2214
+ var release, restoration, _t;
2215
+ return _regenerator.default.wrap(function (_context47) {
2216
+ while (1) switch (_context47.prev = _context47.next) {
2217
+ case 0:
2218
+ _context47.next = 1;
2219
+ return beforeEachSetupForKeepalive();
2220
+ case 1:
2221
+ lineEmitter.mockClear();
2222
+ postRegistrationSpy.mockClear();
2223
+ restartSpy.mockClear();
2224
+ failoverSpy.mockClear();
2225
+
2226
+ /* Something else holds the mutex, so the restoration queues behind it having
2227
+ * begun while the session was still valid. */
2228
+ _context47.next = 2;
2229
+ return reg.mutex.acquire();
2230
+ case 2:
2231
+ release = _context47.sent;
2232
+ restoration = reg.handleConnectionRestoration(true);
2233
+ _context47.next = 3;
2234
+ return flushPromises();
2235
+ case 3:
2236
+ /* The 409 cleanup latches without the mutex, so the flip lands mid-wait. */
2237
+ reg.sessionSuperseded = true;
2238
+ release();
2239
+ _t = expect;
2240
+ _context47.next = 4;
2241
+ return restoration;
2242
+ case 4:
2243
+ _t(_context47.sent).toStrictEqual(false);
2244
+ /* The latch flipped after this restoration had already started, so the choke
2245
+ * point is what stops it: no device is registered for the dead session. */
2246
+ expect(warnSpy).toHaveBeenCalledWith("Session superseded, skipping registration attempt - caller: ".concat(_constants.METHODS.HANDLE_CONNECTION_RESTORATION), {
2247
+ file: _constants.REGISTRATION_FILE,
2248
+ method: _constants.METHODS.HANDLE_CONNECTION_RESTORATION
2249
+ });
2250
+ expect(postRegistrationSpy).not.toHaveBeenCalled();
2251
+ expect(restartSpy).not.toHaveBeenCalled();
2252
+ expect(failoverSpy).not.toHaveBeenCalled();
2253
+ case 5:
2254
+ case "end":
2255
+ return _context47.stop();
2256
+ }
2257
+ }, _callee47);
2258
+ })));
2259
+ it('stays terminal when all calls are cleared after a superseded session', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee48() {
2260
+ return _regenerator.default.wrap(function (_context48) {
2261
+ while (1) switch (_context48.prev = _context48.next) {
2262
+ case 0:
2263
+ _context48.next = 1;
2264
+ return beforeEachSetupForKeepalive();
2265
+ case 1:
2266
+ lineEmitter.mockClear();
2267
+ _context48.next = 2;
2268
+ return sendKeepaliveFailure(conflictError, 1);
2269
+ case 2:
2270
+ postRegistrationSpy.mockClear();
2271
+ restartSpy.mockClear();
2272
+ failoverSpy.mockClear();
2273
+ _context48.next = 3;
2274
+ return reg.reconnectOnFailure(_constants.CALLS_CLEARED_HANDLER_UTIL);
2275
+ case 3:
2276
+ expect(warnSpy).toHaveBeenCalledWith("Session superseded, skipping registration attempt - caller: ".concat(_constants.CALLS_CLEARED_HANDLER_UTIL), {
2277
+ file: _constants.REGISTRATION_FILE,
2278
+ method: _constants.CALLS_CLEARED_HANDLER_UTIL
2279
+ });
2280
+ expect(postRegistrationSpy).not.toHaveBeenCalled();
2281
+ expect(restartSpy).not.toHaveBeenCalled();
2282
+ expect(failoverSpy).not.toHaveBeenCalled();
2283
+ expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
2284
+ case 4:
2285
+ case "end":
2286
+ return _context48.stop();
2287
+ }
2288
+ }, _callee48);
2289
+ })));
2290
+ it('lets an explicit registration by the consumer clear the superseded state', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee49() {
2291
+ return _regenerator.default.wrap(function (_context49) {
2292
+ while (1) switch (_context49.prev = _context49.next) {
2293
+ case 0:
2294
+ _context49.next = 1;
2295
+ return beforeEachSetupForKeepalive();
2296
+ case 1:
2297
+ lineEmitter.mockClear();
2298
+ _context49.next = 2;
2299
+ return sendKeepaliveFailure(conflictError, 1);
2300
+ case 2:
2301
+ expect(reg.sessionSuperseded).toStrictEqual(true);
2302
+ postRegistrationSpy.mockResolvedValueOnce(successPayload);
2303
+ _context49.next = 3;
2304
+ return reg.triggerRegistration();
2305
+ case 3:
2306
+ expect(reg.sessionSuperseded).toStrictEqual(false);
2307
+ expect(reg.getStatus()).toBe(_types.RegistrationStatus.ACTIVE);
2308
+ case 4:
2309
+ case "end":
2310
+ return _context49.stop();
2311
+ }
2312
+ }, _callee49);
2313
+ })));
2314
+ it('latches the superseded state before waiting on the shared mutex', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee50() {
2315
+ var worker, release, inFlight, abort;
2316
+ return _regenerator.default.wrap(function (_context50) {
2317
+ while (1) switch (_context50.prev = _context50.next) {
2318
+ case 0:
2319
+ _context50.next = 1;
2320
+ return beforeEachSetupForKeepalive();
2321
+ case 1:
2322
+ worker = reg.webWorker;
2323
+ lineEmitter.mockClear();
2324
+ postRegistrationSpy.mockClear();
2325
+
2326
+ /* A recovery already holds the mutex, so the 409 cleanup queues behind it. */
2327
+ _context50.next = 2;
2328
+ return reg.mutex.acquire();
2329
+ case 2:
2330
+ release = _context50.sent;
2331
+ inFlight = worker.onmessage({
2332
+ data: {
2333
+ type: _types.WorkerMessageType.KEEPALIVE_FAILURE,
2334
+ err: conflictError,
2335
+ keepAliveRetryCount: 1
2336
+ }
2337
+ });
2338
+ _context50.next = 3;
2339
+ return flushPromises();
2340
+ case 3:
2341
+ /* The latch and the worker teardown are visible before cleanup has run. */
2342
+ expect(reg.sessionSuperseded).toStrictEqual(true);
2343
+ expect(reg.webWorker).toBeUndefined();
2344
+ expect(lineEmitter).not.toHaveBeenCalledWith(_types4.LINE_EVENTS.UNREGISTERED, undefined, expect.anything());
2345
+
2346
+ /* A registration path starting now aborts instead of racing the queued cleanup. */
2347
+ _context50.next = 4;
2348
+ return reg.attemptRegistrationWithServers(_constants.FAILOVER_UTIL);
2349
+ case 4:
2350
+ abort = _context50.sent;
2351
+ expect(abort).toStrictEqual(true);
2352
+ expect(postRegistrationSpy).not.toHaveBeenCalled();
2353
+ expect(warnSpy).toHaveBeenCalledWith("Session superseded, skipping registration attempt - caller: ".concat(_constants.FAILOVER_UTIL), {
2354
+ file: _constants.REGISTRATION_FILE,
2355
+ method: _constants.FAILOVER_UTIL
2356
+ });
2357
+ release();
2358
+ _context50.next = 5;
2359
+ return inFlight;
2360
+ case 5:
2361
+ _context50.next = 6;
2362
+ return flushPromises();
2363
+ case 6:
2364
+ expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
2365
+ case 7:
2366
+ case "end":
2367
+ return _context50.stop();
2368
+ }
2369
+ }, _callee50);
2370
+ })));
2371
+ it('discards a 409 delivered by a keepalive worker that has been replaced', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee51() {
2372
+ var staleWorker, staleWorkerPostSpy, handle409Spy, failKeepalive, inFlight, currentWorker;
2373
+ return _regenerator.default.wrap(function (_context51) {
2374
+ while (1) switch (_context51.prev = _context51.next) {
2375
+ case 0:
2376
+ _context51.next = 1;
2377
+ return beforeEachSetupForKeepalive();
2378
+ case 1:
2379
+ staleWorker = reg.webWorker;
2380
+ staleWorkerPostSpy = jest.spyOn(staleWorker, 'postMessage');
2381
+ handle409Spy = jest.spyOn(reg, 'handle409KeepaliveFailure');
2382
+ jest.spyOn(reg, 'postKeepAlive').mockReturnValue(new _promise.default(function (_, reject) {
2383
+ failKeepalive = reject;
2384
+ }));
2385
+ lineEmitter.mockClear();
2386
+ inFlight = staleWorker.onmessage({
2387
+ data: {
2388
+ type: _types.WorkerMessageType.SEND_KEEPALIVE
2389
+ }
2390
+ });
2391
+ /* A re-registration (failback, connection restoration) swaps the worker while the
2392
+ * keepalive of the previous registration is still in flight. */
2393
+ currentWorker = {
2394
+ postMessage: jest.fn(),
2395
+ terminate: jest.fn(),
2396
+ onmessage: null
2397
+ };
2398
+ reg.webWorker = currentWorker;
2399
+ failKeepalive(conflictError);
2400
+ _context51.next = 2;
2401
+ return inFlight;
2402
+ case 2:
2403
+ _context51.next = 3;
2404
+ return flushPromises();
2405
+ case 3:
2406
+ expect(staleWorkerPostSpy).not.toHaveBeenCalledWith(expect.objectContaining({
2407
+ type: _types.WorkerMessageType.KEEPALIVE_RESULT
2408
+ }));
2409
+ expect(currentWorker.postMessage).not.toHaveBeenCalled();
2410
+ expect(handle409Spy).not.toHaveBeenCalled();
2411
+ expect(lineEmitter).not.toHaveBeenCalledWith(_types4.LINE_EVENTS.UNREGISTERED, undefined, expect.anything());
2412
+ case 4:
2413
+ case "end":
2414
+ return _context51.stop();
2415
+ }
2416
+ }, _callee51);
2417
+ })));
2418
+ });
2419
+ });
2420
+ describe('409 Conflict outside the keepalive flow', function () {
2421
+ /* The registration flow passes no sessionSupersededCb, so a 409 there is logged and
2422
+ * ignored: no consumer event, no registration-error metric, and non-final so the
2423
+ * server loop and failover proceed as they would for any non-fatal status. */
2424
+ it('ignores a 409 during registration without notifying the consumer', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee52() {
2425
+ var conflictPayload;
2426
+ return _regenerator.default.wrap(function (_context52) {
2427
+ while (1) switch (_context52.prev = _context52.next) {
2428
+ case 0:
2429
+ jest.useFakeTimers();
2430
+ conflictPayload = {
2431
+ statusCode: 409,
2432
+ headers: {
2433
+ trackingid: 'tid-reg-409'
2434
+ }
2435
+ };
2436
+ webex.request.mockRejectedValue(conflictPayload);
2437
+ lineEmitter.mockClear();
2438
+ metricSpy.mockClear();
2439
+ _context52.next = 1;
2440
+ return reg.triggerRegistration();
2441
+ case 1:
2442
+ expect(warnSpy).toHaveBeenCalledWith('409 Conflict: ignored, caller does not handle a superseded session', {
2443
+ file: _constants.REGISTRATION_FILE,
2444
+ method: _constants.REGISTRATION_UTIL
2445
+ });
2446
+
2447
+ /* No consumer notification and no registration-error metric on this path. */
2448
+ expect(lineEmitter).not.toHaveBeenCalledWith(_types4.LINE_EVENTS.UNREGISTERED);
2449
+ expect(lineEmitter).not.toHaveBeenCalledWith(_types4.LINE_EVENTS.ERROR, undefined, expect.anything());
2450
+ expect(metricSpy).not.toHaveBeenCalledWith(_types5.METRIC_EVENT.REGISTRATION_ERROR, _types5.REG_ACTION.REGISTER, _types5.METRIC_TYPE.BEHAVIORAL, expect.anything(), expect.anything(), expect.anything(), expect.anything(), expect.anything());
2451
+
2452
+ /* Non-final: every server was tried and failover was scheduled. */
2453
+ expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
2454
+ expect(reg.sessionSuperseded).toStrictEqual(false);
2455
+ expect(failoverSpy).toHaveBeenCalled();
2456
+ case 2:
2457
+ case "end":
2458
+ return _context52.stop();
2459
+ }
2460
+ }, _callee52);
2461
+ })));
1908
2462
  });
1909
2463
  describe('Primary server status checks', function () {
1910
- it('success: primary server status to be up', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee39() {
2464
+ it('success: primary server status to be up', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee53() {
1911
2465
  var pingSuccessPayload, status;
1912
- return _regenerator.default.wrap(function (_context39) {
1913
- while (1) switch (_context39.prev = _context39.next) {
2466
+ return _regenerator.default.wrap(function (_context53) {
2467
+ while (1) switch (_context53.prev = _context53.next) {
1914
2468
  case 0:
1915
2469
  pingSuccessPayload = {
1916
2470
  statusCode: 200
1917
2471
  };
1918
2472
  webex.request.mockResolvedValue(pingSuccessPayload);
1919
- _context39.next = 1;
2473
+ _context53.next = 1;
1920
2474
  return reg.isPrimaryActive();
1921
2475
  case 1:
1922
- status = _context39.sent;
2476
+ status = _context53.sent;
1923
2477
  expect(webex.request).toBeCalledWith(_objectSpread({
1924
2478
  method: 'GET',
1925
2479
  uri: "https://mobius-dfw.webex.com/api/v1/ping"
@@ -1927,23 +2481,23 @@ describe('Registration Tests', function () {
1927
2481
  expect(status).toEqual(true);
1928
2482
  case 2:
1929
2483
  case "end":
1930
- return _context39.stop();
2484
+ return _context53.stop();
1931
2485
  }
1932
- }, _callee39);
2486
+ }, _callee53);
1933
2487
  })));
1934
- it('failed: primary server status to be down', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee40() {
2488
+ it('failed: primary server status to be down', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee54() {
1935
2489
  var pingFailurePayload, status;
1936
- return _regenerator.default.wrap(function (_context40) {
1937
- while (1) switch (_context40.prev = _context40.next) {
2490
+ return _regenerator.default.wrap(function (_context54) {
2491
+ while (1) switch (_context54.prev = _context54.next) {
1938
2492
  case 0:
1939
2493
  pingFailurePayload = {
1940
2494
  statusCode: 500
1941
2495
  };
1942
2496
  webex.request.mockResolvedValue(pingFailurePayload);
1943
- _context40.next = 1;
2497
+ _context54.next = 1;
1944
2498
  return reg.isPrimaryActive();
1945
2499
  case 1:
1946
- status = _context40.sent;
2500
+ status = _context54.sent;
1947
2501
  expect(webex.request).toBeCalledWith(_objectSpread({
1948
2502
  method: 'GET',
1949
2503
  uri: "https://mobius-dfw.webex.com/api/v1/ping"
@@ -1951,9 +2505,9 @@ describe('Registration Tests', function () {
1951
2505
  expect(status).toEqual(false);
1952
2506
  case 2:
1953
2507
  case "end":
1954
- return _context40.stop();
2508
+ return _context54.stop();
1955
2509
  }
1956
- }, _callee40);
2510
+ }, _callee54);
1957
2511
  })));
1958
2512
  });
1959
2513
  describe('handleRegistrationDownEvent tests', function () {
@@ -1973,20 +2527,20 @@ describe('Registration Tests', function () {
1973
2527
  }
1974
2528
  }
1975
2529
  };
1976
- beforeEach(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee41() {
1977
- return _regenerator.default.wrap(function (_context41) {
1978
- while (1) switch (_context41.prev = _context41.next) {
2530
+ beforeEach(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee55() {
2531
+ return _regenerator.default.wrap(function (_context55) {
2532
+ while (1) switch (_context55.prev = _context55.next) {
1979
2533
  case 0:
1980
2534
  postRegistrationSpy.mockResolvedValueOnce(successPayload);
1981
- _context41.next = 1;
2535
+ _context55.next = 1;
1982
2536
  return reg.triggerRegistration();
1983
2537
  case 1:
1984
2538
  expect(reg.getStatus()).toBe(_types.RegistrationStatus.ACTIVE);
1985
2539
  case 2:
1986
2540
  case "end":
1987
- return _context41.stop();
2541
+ return _context55.stop();
1988
2542
  }
1989
- }, _callee41);
2543
+ }, _callee55);
1990
2544
  })));
1991
2545
  afterEach(function () {
1992
2546
  var calls = (0, _values.default)(reg.callManager.getActiveCalls());
@@ -1995,10 +2549,10 @@ describe('Registration Tests', function () {
1995
2549
  });
1996
2550
  reg.callManager.callCollection = {};
1997
2551
  });
1998
- it('runs cleanup immediately when no active calls are present (socket disabled)', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee42() {
2552
+ it('runs cleanup immediately when no active calls are present (socket disabled)', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee56() {
1999
2553
  var clearKeepaliveSpy, setStatusSpy, disconnectSocketSpy;
2000
- return _regenerator.default.wrap(function (_context42) {
2001
- while (1) switch (_context42.prev = _context42.next) {
2554
+ return _regenerator.default.wrap(function (_context56) {
2555
+ while (1) switch (_context56.prev = _context56.next) {
2002
2556
  case 0:
2003
2557
  clearKeepaliveSpy = jest.spyOn(reg, 'clearKeepaliveTimer');
2004
2558
  setStatusSpy = jest.spyOn(reg, 'setStatus');
@@ -2007,7 +2561,7 @@ describe('Registration Tests', function () {
2007
2561
  }), 'disconnectFromMobiusSocket');
2008
2562
  lineEmitter.mockClear();
2009
2563
  expect((0, _keys.default)(reg.callManager.getActiveCalls()).length).toBe(0);
2010
- _context42.next = 1;
2564
+ _context56.next = 1;
2011
2565
  return reg.handleRegistrationDownEvent(registrationDownEvent);
2012
2566
  case 1:
2013
2567
  expect(clearKeepaliveSpy).toHaveBeenCalled();
@@ -2019,17 +2573,18 @@ describe('Registration Tests', function () {
2019
2573
  expect(reg.retryAfter).toBeUndefined();
2020
2574
  expect(reg.registerRetry).toBe(false);
2021
2575
  expect(disconnectSocketSpy).not.toHaveBeenCalled();
2022
- expect(lineEmitter).toHaveBeenCalledWith(_types4.LINE_EVENTS.UNREGISTERED);
2576
+ /* A registration-down stop has no reason to report to the consumer. */
2577
+ expect(lineEmitter).toHaveBeenCalledWith(_types4.LINE_EVENTS.UNREGISTERED, undefined, undefined);
2023
2578
  case 2:
2024
2579
  case "end":
2025
- return _context42.stop();
2580
+ return _context56.stop();
2026
2581
  }
2027
- }, _callee42);
2582
+ }, _callee56);
2028
2583
  })));
2029
- it('ends the active call and still runs cleanup when an active call is present', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee43() {
2584
+ it('ends the active call and still runs cleanup when an active call is present', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee57() {
2030
2585
  var clearKeepaliveSpy, setStatusSpy, activeCall, endSpy;
2031
- return _regenerator.default.wrap(function (_context43) {
2032
- while (1) switch (_context43.prev = _context43.next) {
2586
+ return _regenerator.default.wrap(function (_context57) {
2587
+ while (1) switch (_context57.prev = _context57.next) {
2033
2588
  case 0:
2034
2589
  clearKeepaliveSpy = jest.spyOn(reg, 'clearKeepaliveTimer');
2035
2590
  setStatusSpy = jest.spyOn(reg, 'setStatus');
@@ -2037,28 +2592,28 @@ describe('Registration Tests', function () {
2037
2592
  endSpy = jest.spyOn(activeCall, 'end');
2038
2593
  expect((0, _keys.default)(reg.callManager.getActiveCalls()).length).toBe(1);
2039
2594
  lineEmitter.mockClear();
2040
- _context43.next = 1;
2595
+ _context57.next = 1;
2041
2596
  return reg.handleRegistrationDownEvent(registrationDownEvent);
2042
2597
  case 1:
2043
2598
  expect(endSpy).toHaveBeenCalledTimes(1);
2044
2599
  expect(clearKeepaliveSpy).toHaveBeenCalled();
2045
2600
  expect(setStatusSpy).toHaveBeenCalledWith(_types.RegistrationStatus.INACTIVE);
2046
2601
  expect(reg.getStatus()).toBe(_types.RegistrationStatus.INACTIVE);
2047
- expect(lineEmitter).toHaveBeenCalledWith(_types4.LINE_EVENTS.UNREGISTERED);
2602
+ expect(lineEmitter).toHaveBeenCalledWith(_types4.LINE_EVENTS.UNREGISTERED, undefined, undefined);
2048
2603
  case 2:
2049
2604
  case "end":
2050
- return _context43.stop();
2605
+ return _context57.stop();
2051
2606
  }
2052
- }, _callee43);
2607
+ }, _callee57);
2053
2608
  })));
2054
- it('runs cleanup without calling end when no active call is present on re-invocation', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee44() {
2609
+ it('runs cleanup without calling end when no active call is present on re-invocation', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee58() {
2055
2610
  var clearKeepaliveSpy, setStatusSpy;
2056
- return _regenerator.default.wrap(function (_context44) {
2057
- while (1) switch (_context44.prev = _context44.next) {
2611
+ return _regenerator.default.wrap(function (_context58) {
2612
+ while (1) switch (_context58.prev = _context58.next) {
2058
2613
  case 0:
2059
2614
  clearKeepaliveSpy = jest.spyOn(reg, 'clearKeepaliveTimer');
2060
2615
  setStatusSpy = jest.spyOn(reg, 'setStatus');
2061
- _context44.next = 1;
2616
+ _context58.next = 1;
2062
2617
  return reg.handleRegistrationDownEvent(registrationDownEvent);
2063
2618
  case 1:
2064
2619
  expect(reg.getStatus()).toBe(_types.RegistrationStatus.INACTIVE);
@@ -2066,23 +2621,23 @@ describe('Registration Tests', function () {
2066
2621
  setStatusSpy.mockClear();
2067
2622
  lineEmitter.mockClear();
2068
2623
  expect((0, _keys.default)(reg.callManager.getActiveCalls()).length).toBe(0);
2069
- _context44.next = 2;
2624
+ _context58.next = 2;
2070
2625
  return reg.handleRegistrationDownEvent(registrationDownEvent);
2071
2626
  case 2:
2072
2627
  expect(clearKeepaliveSpy).toHaveBeenCalled();
2073
2628
  expect(setStatusSpy).toHaveBeenCalledWith(_types.RegistrationStatus.INACTIVE);
2074
2629
  expect(reg.getStatus()).toBe(_types.RegistrationStatus.INACTIVE);
2075
- expect(lineEmitter).toHaveBeenCalledWith(_types4.LINE_EVENTS.UNREGISTERED);
2630
+ expect(lineEmitter).toHaveBeenCalledWith(_types4.LINE_EVENTS.UNREGISTERED, undefined, undefined);
2076
2631
  case 3:
2077
2632
  case "end":
2078
- return _context44.stop();
2633
+ return _context58.stop();
2079
2634
  }
2080
- }, _callee44);
2635
+ }, _callee58);
2081
2636
  })));
2082
- it('disconnects the Mobius WebSocket when socket is enabled', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee45() {
2637
+ it('disconnects the Mobius WebSocket when socket is enabled', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee59() {
2083
2638
  var apiRequest, disconnectSocketSpy;
2084
- return _regenerator.default.wrap(function (_context45) {
2085
- while (1) switch (_context45.prev = _context45.next) {
2639
+ return _regenerator.default.wrap(function (_context59) {
2640
+ while (1) switch (_context59.prev = _context59.next) {
2086
2641
  case 0:
2087
2642
  apiRequest = _request.APIRequest.getInstance({
2088
2643
  webex: webex
@@ -2091,7 +2646,7 @@ describe('Registration Tests', function () {
2091
2646
  disconnectSocketSpy = jest.spyOn(apiRequest, 'disconnectFromMobiusSocket').mockResolvedValue();
2092
2647
  lineEmitter.mockClear();
2093
2648
  expect((0, _keys.default)(reg.callManager.getActiveCalls()).length).toBe(0);
2094
- _context45.next = 1;
2649
+ _context59.next = 1;
2095
2650
  return reg.handleRegistrationDownEvent(registrationDownEvent);
2096
2651
  case 1:
2097
2652
  expect(disconnectSocketSpy).toHaveBeenCalledWith({
@@ -2099,17 +2654,17 @@ describe('Registration Tests', function () {
2099
2654
  reason: 'done (permanent)'
2100
2655
  });
2101
2656
  expect(reg.getStatus()).toBe(_types.RegistrationStatus.INACTIVE);
2102
- expect(lineEmitter).toHaveBeenCalledWith(_types4.LINE_EVENTS.UNREGISTERED);
2657
+ expect(lineEmitter).toHaveBeenCalledWith(_types4.LINE_EVENTS.UNREGISTERED, undefined, undefined);
2103
2658
  case 2:
2104
2659
  case "end":
2105
- return _context45.stop();
2660
+ return _context59.stop();
2106
2661
  }
2107
- }, _callee45);
2662
+ }, _callee59);
2108
2663
  })));
2109
- it('still emits UNREGISTERED when socket disconnect fails', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee46() {
2664
+ it('still emits UNREGISTERED when socket disconnect fails', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee60() {
2110
2665
  var apiRequest, disconnectSocketSpy;
2111
- return _regenerator.default.wrap(function (_context46) {
2112
- while (1) switch (_context46.prev = _context46.next) {
2666
+ return _regenerator.default.wrap(function (_context60) {
2667
+ while (1) switch (_context60.prev = _context60.next) {
2113
2668
  case 0:
2114
2669
  apiRequest = _request.APIRequest.getInstance({
2115
2670
  webex: webex
@@ -2117,7 +2672,7 @@ describe('Registration Tests', function () {
2117
2672
  jest.spyOn(apiRequest, 'isSocketEnabled').mockReturnValue(true);
2118
2673
  disconnectSocketSpy = jest.spyOn(apiRequest, 'disconnectFromMobiusSocket').mockRejectedValue(new Error('socket teardown failed'));
2119
2674
  lineEmitter.mockClear();
2120
- _context46.next = 1;
2675
+ _context60.next = 1;
2121
2676
  return reg.handleRegistrationDownEvent(registrationDownEvent);
2122
2677
  case 1:
2123
2678
  expect(disconnectSocketSpy).toHaveBeenCalled();
@@ -2126,12 +2681,12 @@ describe('Registration Tests', function () {
2126
2681
  method: _constants.METHODS.HANDLE_REGISTRATION_DOWN_EVENT
2127
2682
  });
2128
2683
  expect(reg.getStatus()).toBe(_types.RegistrationStatus.INACTIVE);
2129
- expect(lineEmitter).toHaveBeenCalledWith(_types4.LINE_EVENTS.UNREGISTERED);
2684
+ expect(lineEmitter).toHaveBeenCalledWith(_types4.LINE_EVENTS.UNREGISTERED, undefined, undefined);
2130
2685
  case 2:
2131
2686
  case "end":
2132
- return _context46.stop();
2687
+ return _context60.stop();
2133
2688
  }
2134
- }, _callee46);
2689
+ }, _callee60);
2135
2690
  })));
2136
2691
  });
2137
2692
  describe('attemptRegistrationWithServers transport alignment', function () {
@@ -2146,61 +2701,61 @@ describe('Registration Tests', function () {
2146
2701
  setSocketEnabledSpy = jest.spyOn(apiRequest, 'setSocketEnabled').mockImplementation(function () {});
2147
2702
  webex.request.mockResolvedValue(successPayload);
2148
2703
  });
2149
- it('enables the WebSocket transport when the server group uses the wss:// scheme', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee47() {
2150
- return _regenerator.default.wrap(function (_context47) {
2151
- while (1) switch (_context47.prev = _context47.next) {
2704
+ it('enables the WebSocket transport when the server group uses the wss:// scheme', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee61() {
2705
+ return _regenerator.default.wrap(function (_context61) {
2706
+ while (1) switch (_context61.prev = _context61.next) {
2152
2707
  case 0:
2153
- _context47.next = 1;
2708
+ _context61.next = 1;
2154
2709
  return reg.attemptRegistrationWithServers(_constants.REGISTRATION_UTIL, ['wss://mobius.example.com/api/v1/calling/web/']);
2155
2710
  case 1:
2156
2711
  expect(setSocketEnabledSpy).toHaveBeenCalledWith(true);
2157
2712
  case 2:
2158
2713
  case "end":
2159
- return _context47.stop();
2714
+ return _context61.stop();
2160
2715
  }
2161
- }, _callee47);
2716
+ }, _callee61);
2162
2717
  })));
2163
- it('falls back to the HTTP transport when the server group uses the https:// scheme', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee48() {
2164
- return _regenerator.default.wrap(function (_context48) {
2165
- while (1) switch (_context48.prev = _context48.next) {
2718
+ it('falls back to the HTTP transport when the server group uses the https:// scheme', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee62() {
2719
+ return _regenerator.default.wrap(function (_context62) {
2720
+ while (1) switch (_context62.prev = _context62.next) {
2166
2721
  case 0:
2167
- _context48.next = 1;
2722
+ _context62.next = 1;
2168
2723
  return reg.attemptRegistrationWithServers(_constants.REGISTRATION_UTIL, ['https://mobius.example.com/api/v1/calling/web/']);
2169
2724
  case 1:
2170
2725
  expect(setSocketEnabledSpy).toHaveBeenCalledWith(false);
2171
2726
  case 2:
2172
2727
  case "end":
2173
- return _context48.stop();
2728
+ return _context62.stop();
2174
2729
  }
2175
- }, _callee48);
2730
+ }, _callee62);
2176
2731
  })));
2177
- it('does not change the transport when the server group is empty', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee49() {
2178
- return _regenerator.default.wrap(function (_context49) {
2179
- while (1) switch (_context49.prev = _context49.next) {
2732
+ it('does not change the transport when the server group is empty', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee63() {
2733
+ return _regenerator.default.wrap(function (_context63) {
2734
+ while (1) switch (_context63.prev = _context63.next) {
2180
2735
  case 0:
2181
- _context49.next = 1;
2736
+ _context63.next = 1;
2182
2737
  return reg.attemptRegistrationWithServers(_constants.REGISTRATION_UTIL, []);
2183
2738
  case 1:
2184
2739
  expect(setSocketEnabledSpy).not.toHaveBeenCalled();
2185
2740
  case 2:
2186
2741
  case "end":
2187
- return _context49.stop();
2742
+ return _context63.stop();
2188
2743
  }
2189
- }, _callee49);
2744
+ }, _callee63);
2190
2745
  })));
2191
- it('derives the transport from the first server in the group', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee50() {
2192
- return _regenerator.default.wrap(function (_context50) {
2193
- while (1) switch (_context50.prev = _context50.next) {
2746
+ it('derives the transport from the first server in the group', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee64() {
2747
+ return _regenerator.default.wrap(function (_context64) {
2748
+ while (1) switch (_context64.prev = _context64.next) {
2194
2749
  case 0:
2195
- _context50.next = 1;
2750
+ _context64.next = 1;
2196
2751
  return reg.attemptRegistrationWithServers(_constants.REGISTRATION_UTIL, ['wss://primary.example.com/api/v1/calling/web/', 'https://backup.example.com/api/v1/calling/web/']);
2197
2752
  case 1:
2198
2753
  expect(setSocketEnabledSpy).toHaveBeenCalledWith(true);
2199
2754
  case 2:
2200
2755
  case "end":
2201
- return _context50.stop();
2756
+ return _context64.stop();
2202
2757
  }
2203
- }, _callee50);
2758
+ }, _callee64);
2204
2759
  })));
2205
2760
  });
2206
2761
  });