@webex/calling 3.13.0-next.6 → 3.13.0-next.8

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.
@@ -1702,87 +1702,123 @@ describe('Registration Tests', function () {
1702
1702
  }
1703
1703
  }, _callee34);
1704
1704
  })));
1705
- it('checks for keep-alive failure with 429', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee35() {
1706
- var _reg$deviceInfo$devic;
1707
- var keepaliveSpy, postMessageSpy, clearTimerSpy, retry429Spy, keepaliveInterval, retryAfter, adjustedResumeDelayMs;
1708
- return _regenerator.default.wrap(function (_context35) {
1709
- while (1) switch (_context35.prev = _context35.next) {
1710
- case 0:
1711
- _context35.next = 1;
1712
- return beforeEachSetupForKeepalive();
1713
- case 1:
1714
- keepaliveSpy = jest.spyOn(reg, 'startKeepaliveTimer');
1715
- postMessageSpy = jest.spyOn(Worker.prototype, 'postMessage');
1716
- clearTimerSpy = jest.spyOn(reg, 'clearKeepaliveTimer');
1717
- retry429Spy = jest.spyOn(reg, 'handle429Retry');
1718
- keepaliveInterval = reg.deviceInfo.keepaliveInterval; // Choose a retryAfter strictly greater than keepaliveInterval so the
1719
- // adjusted resume delay (retryAfter - keepaliveInterval) is positive and verifiable.
1720
- retryAfter = keepaliveInterval + 30;
1721
- adjustedResumeDelayMs = (retryAfter - keepaliveInterval) * _constants.SEC_TO_MSEC_MFACTOR;
1722
- reg.webWorker.onmessage({
1723
- data: {
1724
- type: _types.WorkerMessageType.KEEPALIVE_FAILURE,
1705
+ it.each([{
1706
+ headerNames: ['retry-after']
1707
+ }, {
1708
+ headerNames: ['Retry-After']
1709
+ }, {
1710
+ headerNames: ['retry-after', 'Retry-After']
1711
+ }])('checks for keep-alive failure with 429 and $headerNames', /*#__PURE__*/function () {
1712
+ var _ref36 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee35(_ref35) {
1713
+ var _reg$deviceInfo$devic;
1714
+ var headerNames, keepaliveSpy, postMessageSpy, clearTimerSpy, retry429Spy, keepaliveInterval, retryAfter, headers, adjustedResumeDelayMs, worker, _postMessageSpy$mock$, _postMessageSpy$mock$2, result;
1715
+ return _regenerator.default.wrap(function (_context35) {
1716
+ while (1) switch (_context35.prev = _context35.next) {
1717
+ case 0:
1718
+ headerNames = _ref35.headerNames;
1719
+ _context35.next = 1;
1720
+ return beforeEachSetupForKeepalive();
1721
+ case 1:
1722
+ keepaliveSpy = jest.spyOn(reg, 'startKeepaliveTimer');
1723
+ postMessageSpy = jest.spyOn(Worker.prototype, 'postMessage');
1724
+ clearTimerSpy = jest.spyOn(reg, 'clearKeepaliveTimer');
1725
+ retry429Spy = jest.spyOn(reg, 'handle429Retry');
1726
+ keepaliveInterval = reg.deviceInfo.keepaliveInterval; // Choose a retryAfter strictly greater than keepaliveInterval so the
1727
+ // adjusted resume delay (retryAfter - keepaliveInterval) is positive and verifiable.
1728
+ retryAfter = keepaliveInterval + 30;
1729
+ headers = Object.fromEntries(headerNames.map(function (name, index) {
1730
+ return [name, String(retryAfter - index * 30)];
1731
+ }));
1732
+ adjustedResumeDelayMs = (retryAfter - keepaliveInterval) * _constants.SEC_TO_MSEC_MFACTOR;
1733
+ worker = reg.webWorker;
1734
+ jest.spyOn(reg, 'postKeepAlive').mockRejectedValueOnce({
1735
+ statusCode: 429,
1736
+ headers: headers
1737
+ });
1738
+ _context35.next = 2;
1739
+ return worker.onmessage({
1740
+ data: {
1741
+ type: _types.WorkerMessageType.SEND_KEEPALIVE
1742
+ }
1743
+ });
1744
+ case 2:
1745
+ _postMessageSpy$mock$ = postMessageSpy.mock.calls.find(function (_ref37) {
1746
+ var _ref38 = (0, _slicedToArray2.default)(_ref37, 1),
1747
+ message = _ref38[0];
1748
+ return message.type === _types.WorkerMessageType.KEEPALIVE_RESULT;
1749
+ }), _postMessageSpy$mock$2 = (0, _slicedToArray2.default)(_postMessageSpy$mock$, 1), result = _postMessageSpy$mock$2[0];
1750
+ expect(result).toEqual({
1751
+ type: _types.WorkerMessageType.KEEPALIVE_RESULT,
1725
1752
  err: {
1726
1753
  statusCode: 429,
1727
1754
  headers: {
1728
- 'retry-after': retryAfter
1729
- }
1730
- },
1731
- keepAliveRetryCount: 1
1732
- }
1733
- });
1734
- _context35.next = 2;
1735
- return flushPromises();
1736
- case 2:
1737
- expect(warnSpy).toBeCalledWith('Keep-alive missed 1 times. Status -> 429 ', expect.objectContaining({
1738
- file: _constants.REGISTRATION_FILE,
1739
- method: 'startKeepaliveTimer'
1740
- }));
1741
- expect(handleErrorSpy).toBeCalledOnceWith({
1742
- statusCode: 429,
1743
- headers: {
1744
- 'retry-after': retryAfter
1745
- }
1746
- }, expect.anything(), {
1747
- file: _constants.REGISTRATION_FILE,
1748
- method: _constants.KEEPALIVE_UTIL
1749
- }, expect.anything());
1750
- expect(retry429Spy).toBeCalledOnceWith(retryAfter, 'startKeepaliveTimer');
1751
- expect(clearTimerSpy).toBeCalledTimes(1);
1752
- expect(reg.reconnectPending).toStrictEqual(false);
1753
- expect(reg.keepaliveTimer).toBe(undefined);
1754
- expect(reg.webWorker).toBeUndefined();
1755
+ trackingid: undefined,
1756
+ 'retry-after': String(retryAfter)
1757
+ },
1758
+ statusText: undefined,
1759
+ type: undefined
1760
+ }
1761
+ });
1762
+ _context35.next = 3;
1763
+ return worker.onmessage({
1764
+ data: {
1765
+ type: _types.WorkerMessageType.KEEPALIVE_FAILURE,
1766
+ err: result.err,
1767
+ keepAliveRetryCount: 1
1768
+ }
1769
+ });
1770
+ case 3:
1771
+ _context35.next = 4;
1772
+ return flushPromises();
1773
+ case 4:
1774
+ expect(warnSpy).toBeCalledWith('Keep-alive missed 1 times. Status -> 429 ', expect.objectContaining({
1775
+ file: _constants.REGISTRATION_FILE,
1776
+ method: 'startKeepaliveTimer'
1777
+ }));
1778
+ expect(handleErrorSpy).toBeCalledOnceWith(result.err, expect.anything(), {
1779
+ file: _constants.REGISTRATION_FILE,
1780
+ method: _constants.KEEPALIVE_UTIL
1781
+ }, expect.anything());
1782
+ expect(retry429Spy).toBeCalledOnceWith(retryAfter, 'startKeepaliveTimer');
1783
+ expect(clearTimerSpy).toBeCalledTimes(1);
1784
+ expect(reg.reconnectPending).toStrictEqual(false);
1785
+ expect(reg.keepaliveTimer).toBe(undefined);
1786
+ expect(reg.webWorker).toBeUndefined();
1755
1787
 
1756
- // Resume timer must NOT fire before the adjusted (retryAfter - keepaliveInterval) interval.
1757
- jest.advanceTimersByTime(adjustedResumeDelayMs - 1);
1758
- _context35.next = 3;
1759
- return flushPromises();
1760
- case 3:
1761
- expect(keepaliveSpy).not.toBeCalled();
1762
- expect(reg.webWorker).toBeUndefined();
1788
+ // Resume timer must NOT fire before the adjusted (retryAfter - keepaliveInterval) interval.
1789
+ jest.advanceTimersByTime(adjustedResumeDelayMs - 1);
1790
+ _context35.next = 5;
1791
+ return flushPromises();
1792
+ case 5:
1793
+ expect(keepaliveSpy).not.toBeCalled();
1794
+ expect(reg.webWorker).toBeUndefined();
1763
1795
 
1764
- // Advance the remaining 1ms to hit the exact adjusted timeout; keepalive must resume now.
1765
- jest.advanceTimersByTime(1);
1766
- _context35.next = 4;
1767
- return flushPromises();
1768
- case 4:
1769
- expect(keepaliveSpy).toBeCalledOnceWith((_reg$deviceInfo$devic = reg.deviceInfo.device) === null || _reg$deviceInfo$devic === void 0 ? void 0 : _reg$deviceInfo$devic.uri, keepaliveInterval, 'UNKNOWN');
1770
- expect(logSpy).toBeCalledWith("Resuming keepalive after ".concat(retryAfter, " seconds"), {
1771
- file: _constants.REGISTRATION_FILE,
1772
- method: 'handle429Retry'
1773
- });
1774
- expect(reg.webWorker).toBeDefined();
1775
- expect(postMessageSpy).toHaveBeenCalledWith(expect.objectContaining({
1776
- type: 'START_KEEPALIVE',
1777
- interval: expect.any(Number),
1778
- retryCountThreshold: expect.any(Number)
1779
- }));
1780
- case 5:
1781
- case "end":
1782
- return _context35.stop();
1783
- }
1784
- }, _callee35);
1785
- })));
1796
+ // Advance the remaining 1ms to hit the exact adjusted timeout; keepalive must resume now.
1797
+ jest.advanceTimersByTime(1);
1798
+ _context35.next = 6;
1799
+ return flushPromises();
1800
+ case 6:
1801
+ expect(keepaliveSpy).toBeCalledOnceWith((_reg$deviceInfo$devic = reg.deviceInfo.device) === null || _reg$deviceInfo$devic === void 0 ? void 0 : _reg$deviceInfo$devic.uri, keepaliveInterval, 'UNKNOWN');
1802
+ expect(logSpy).toBeCalledWith("Resuming keepalive after ".concat(retryAfter, " seconds"), {
1803
+ file: _constants.REGISTRATION_FILE,
1804
+ method: 'handle429Retry'
1805
+ });
1806
+ expect(reg.webWorker).toBeDefined();
1807
+ expect(postMessageSpy).toHaveBeenCalledWith(expect.objectContaining({
1808
+ type: 'START_KEEPALIVE',
1809
+ interval: expect.any(Number),
1810
+ retryCountThreshold: expect.any(Number)
1811
+ }));
1812
+ case 7:
1813
+ case "end":
1814
+ return _context35.stop();
1815
+ }
1816
+ }, _callee35);
1817
+ }));
1818
+ return function (_x) {
1819
+ return _ref36.apply(this, arguments);
1820
+ };
1821
+ }());
1786
1822
  it.each([{
1787
1823
  description: 'retryAfter less than keepaliveInterval -> negative delay fires immediately',
1788
1824
  retryAfterDelta: -10
@@ -1790,13 +1826,13 @@ describe('Registration Tests', function () {
1790
1826
  description: 'retryAfter equal to keepaliveInterval -> zero delay fires immediately',
1791
1827
  retryAfterDelta: 0
1792
1828
  }])('adjusts retry-after with keepaliveInterval on 429 keepalive failure ($description)', /*#__PURE__*/function () {
1793
- var _ref37 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee36(_ref36) {
1829
+ var _ref40 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee36(_ref39) {
1794
1830
  var _reg$deviceInfo$devic2;
1795
1831
  var retryAfterDelta, keepaliveSpy, keepaliveInterval, retryAfter;
1796
1832
  return _regenerator.default.wrap(function (_context36) {
1797
1833
  while (1) switch (_context36.prev = _context36.next) {
1798
1834
  case 0:
1799
- retryAfterDelta = _ref36.retryAfterDelta;
1835
+ retryAfterDelta = _ref39.retryAfterDelta;
1800
1836
  _context36.next = 1;
1801
1837
  return beforeEachSetupForKeepalive();
1802
1838
  case 1:
@@ -1837,8 +1873,8 @@ describe('Registration Tests', function () {
1837
1873
  }
1838
1874
  }, _callee36);
1839
1875
  }));
1840
- return function (_x) {
1841
- return _ref37.apply(this, arguments);
1876
+ return function (_x2) {
1877
+ return _ref40.apply(this, arguments);
1842
1878
  };
1843
1879
  }());
1844
1880
  it('ensure retryAfter is set when 429 occurs during failover retry', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee37() {
@@ -1921,7 +1957,7 @@ describe('Registration Tests', function () {
1921
1957
  }
1922
1958
  };
1923
1959
  var sendKeepaliveFailure = /*#__PURE__*/function () {
1924
- var _ref40 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee39(err, keepAliveRetryCount) {
1960
+ var _ref43 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee39(err, keepAliveRetryCount) {
1925
1961
  return _regenerator.default.wrap(function (_context39) {
1926
1962
  while (1) switch (_context39.prev = _context39.next) {
1927
1963
  case 0:
@@ -1940,14 +1976,14 @@ describe('Registration Tests', function () {
1940
1976
  }
1941
1977
  }, _callee39);
1942
1978
  }));
1943
- return function sendKeepaliveFailure(_x2, _x3) {
1944
- return _ref40.apply(this, arguments);
1979
+ return function sendKeepaliveFailure(_x3, _x4) {
1980
+ return _ref43.apply(this, arguments);
1945
1981
  };
1946
1982
  }();
1947
1983
  var getSupersededError = function getSupersededError() {
1948
- var unregisteredCall = lineEmitter.mock.calls.find(function (_ref41) {
1949
- var _ref42 = (0, _slicedToArray2.default)(_ref41, 1),
1950
- event = _ref42[0];
1984
+ var unregisteredCall = lineEmitter.mock.calls.find(function (_ref44) {
1985
+ var _ref45 = (0, _slicedToArray2.default)(_ref44, 1),
1986
+ event = _ref45[0];
1951
1987
  return event === _types4.LINE_EVENTS.UNREGISTERED;
1952
1988
  });
1953
1989
  return unregisteredCall === null || unregisteredCall === void 0 ? void 0 : unregisteredCall[2];
@@ -1959,12 +1995,12 @@ describe('Registration Tests', function () {
1959
1995
  description: 'when the retry count already reached the threshold',
1960
1996
  keepAliveRetryCount: 5
1961
1997
  }])('stops keepalive without re-registration $description', /*#__PURE__*/function () {
1962
- var _ref44 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee40(_ref43) {
1998
+ var _ref47 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee40(_ref46) {
1963
1999
  var keepAliveRetryCount, clearTimerSpy, reconnectSpy, registerSpy, handle404Spy;
1964
2000
  return _regenerator.default.wrap(function (_context40) {
1965
2001
  while (1) switch (_context40.prev = _context40.next) {
1966
2002
  case 0:
1967
- keepAliveRetryCount = _ref43.keepAliveRetryCount;
2003
+ keepAliveRetryCount = _ref46.keepAliveRetryCount;
1968
2004
  _context40.next = 1;
1969
2005
  return beforeEachSetupForKeepalive();
1970
2006
  case 1:
@@ -2012,8 +2048,8 @@ describe('Registration Tests', function () {
2012
2048
  }
2013
2049
  }, _callee40);
2014
2050
  }));
2015
- return function (_x4) {
2016
- return _ref44.apply(this, arguments);
2051
+ return function (_x5) {
2052
+ return _ref47.apply(this, arguments);
2017
2053
  };
2018
2054
  }());
2019
2055
  it('notifies the consumer with a single UNREGISTERED carrying the superseded reason', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee41() {
@@ -2028,9 +2064,9 @@ describe('Registration Tests', function () {
2028
2064
  _context41.next = 2;
2029
2065
  return sendKeepaliveFailure(conflictError, 1);
2030
2066
  case 2:
2031
- expect(lineEmitter.mock.calls.filter(function (_ref46) {
2032
- var _ref47 = (0, _slicedToArray2.default)(_ref46, 1),
2033
- event = _ref47[0];
2067
+ expect(lineEmitter.mock.calls.filter(function (_ref49) {
2068
+ var _ref50 = (0, _slicedToArray2.default)(_ref49, 1),
2069
+ event = _ref50[0];
2034
2070
  return event === _types4.LINE_EVENTS.UNREGISTERED;
2035
2071
  })).toHaveLength(1);
2036
2072
  expect(lineEmitter).not.toHaveBeenCalledWith(_types4.LINE_EVENTS.RECONNECTING);
@@ -2149,12 +2185,12 @@ describe('Registration Tests', function () {
2149
2185
  statusCode: 503
2150
2186
  }
2151
2187
  }])('leaves the existing handling of $description untouched', /*#__PURE__*/function () {
2152
- var _ref52 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee45(_ref51) {
2188
+ var _ref55 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee45(_ref54) {
2153
2189
  var err, handle409Spy;
2154
2190
  return _regenerator.default.wrap(function (_context45) {
2155
2191
  while (1) switch (_context45.prev = _context45.next) {
2156
2192
  case 0:
2157
- err = _ref51.err;
2193
+ err = _ref54.err;
2158
2194
  _context45.next = 1;
2159
2195
  return beforeEachSetupForKeepalive();
2160
2196
  case 1:
@@ -2176,8 +2212,8 @@ describe('Registration Tests', function () {
2176
2212
  }
2177
2213
  }, _callee45);
2178
2214
  }));
2179
- return function (_x5) {
2180
- return _ref52.apply(this, arguments);
2215
+ return function (_x6) {
2216
+ return _ref55.apply(this, arguments);
2181
2217
  };
2182
2218
  }());
2183
2219
  it('stays terminal when the network recovers after a superseded session', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee46() {