@testim/testim-cli 3.243.0 → 3.244.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testim/testim-cli",
3
- "version": "3.243.0",
3
+ "version": "3.244.0",
4
4
  "description": "Command line interface for running Testing on your CI",
5
5
  "author": "Oren Rubin",
6
6
  "contributors": [{
@@ -1,4 +1,6 @@
1
- "use strict";
1
+ /* globals getLocatedElement, dispatchFocus */
2
+
3
+ 'use strict';
2
4
 
3
5
  var doClick = function (eventData, done) {
4
6
  var eventConstructorSupported = typeof Event === 'function';
@@ -1,4 +1,6 @@
1
- "use strict";
1
+ /* global getLocatedElement */
2
+
3
+ 'use strict';
2
4
 
3
5
  var html5dndAction = function(eventData) {
4
6
  var data = {};
@@ -1,4 +1,6 @@
1
- "use strict";
1
+ /* global getLocatedElement */
2
+
3
+ 'use strict';
2
4
 
3
5
  var html5dndAction = function (eventData, done) {
4
6
  var mouseEventConstructorSupported = typeof MouseEvent === 'function';
@@ -3,23 +3,40 @@
3
3
  'use strict';
4
4
 
5
5
  const runCode = function (eventData, preCompiledCode) {
6
+ typeof Object.tstassign !== 'function' && (Object.tstassign = function (n, t) {
7
+ 'use strict';
6
8
 
7
- "function"!=typeof Object.tstassign&&(Object.tstassign=function(n,t){"use strict";if(null==n)throw new TypeError("Cannot convert undefined or null to object");for(var r=Object(n),e=1;e<arguments.length;e++){var o=arguments[e];if(null!=o)for(var a in o)Object.prototype.hasOwnProperty.call(o,a)&&(r[a]=o[a])}return r});
8
- Object.assign = typeof Object.assign !== "function" ? Object.tstassign : Object.assign;
9
+ if (n == null) throw new TypeError('Cannot convert undefined or null to object'); for (var r = Object(n), e = 1; e < arguments.length; e++) { var o = arguments[e]; if (o != null) for (var a in o)Object.prototype.hasOwnProperty.call(o, a) && (r[a] = o[a]); } return r;
10
+ });
11
+ Object.assign = typeof Object.assign !== 'function' ? Object.tstassign : Object.assign;
9
12
 
10
13
  function appendToStorage(name, data) {
11
14
  const sessionItem = 'data-testim-' + name;
15
+
16
+ const nativeFuncErrMsg = 'Native sessionStorage is not available';
17
+ function isNativeFunction(fn) {
18
+ if (!fn || !fn.toString) {
19
+ return false;
20
+ }
21
+ return fn.toString().indexOf('[native code]') > -1;
22
+ }
12
23
  try {
24
+ if (![window.sessionStorage.setItem, window.sessionStorage.getItem].every(isNativeFunction)) {
25
+ throw new Error(nativeFuncErrMsg);
26
+ }
13
27
  const oldData = JSON.parse(window.sessionStorage.getItem(sessionItem) || '{}');
14
28
  const newData = Object.tstassign({}, oldData, data);
15
29
  window.sessionStorage.setItem(sessionItem, JSON.stringify(newData));
16
30
  } catch (err) {
17
- // any vernation QuotaExceededError from browsers
31
+ // any variation QuotaExceededError from browsers
18
32
  const isQuotaExceededError = err.message.toLowerCase().indexOf('quota') > -1;
33
+ const isNativeFunctionError = err.message === nativeFuncErrMsg;
34
+
19
35
  if (err.message.indexOf('sessionStorage') > -1 || // Chrome + Firefox
20
36
  err.message.indexOf('The operation is insecure') > -1 || // Safari
21
37
  err.message.indexOf('SecurityError') > -1 || // Edge
22
- isQuotaExceededError
38
+ isQuotaExceededError ||
39
+ isNativeFunctionError
23
40
  ) {
24
41
  var storage = document.head.querySelector('#testim-storage-backup');
25
42
  if (!storage) {
@@ -30,13 +47,13 @@ const runCode = function (eventData, preCompiledCode) {
30
47
  const oldData = JSON.parse(storage.getAttribute(sessionItem) || '{}');
31
48
  const newData = Object.tstassign({}, oldData, data);
32
49
  storage.setAttribute(sessionItem, JSON.stringify(newData));
33
- if (isQuotaExceededError) {
50
+ if (isQuotaExceededError || isNativeFunctionError) {
34
51
  try {
35
52
  window.sessionStorage.removeItem(sessionItem);
36
53
  } catch (e) {
37
54
  // Prevents future retries from looking in sessionStorage with old data
38
55
  }
39
- window.TSTA.useFallbackStorage = true;
56
+ (window.TSTA = window.TSTA || {}).useFallbackStorage = true;
40
57
  }
41
58
  return;
42
59
  }
@@ -1,9 +1,4 @@
1
- // Disabling the eslint to keep this in a format which works on IE 11.
2
- /* eslint-disable no-var */
3
- /* eslint-disable no-redeclare */
4
- /* eslint-disable object-shorthand */
5
- /* eslint-disable one-var */
6
- /* eslint-disable operator-linebreak */
1
+ /* globals getLocatedElement, elementScrollTo */
7
2
 
8
3
  'use strict';
9
4
 
@@ -1,4 +1,7 @@
1
- "use strict";
1
+ /* globals getLocatedElement, dispatchFocus */
2
+
3
+ 'use strict';
4
+
2
5
  /*global KeyboardEvent */
3
6
  var setText = function (eventData, done) {
4
7
  var eventConstructorSupported = typeof Event === 'function';
package/utils.js CHANGED
@@ -71,20 +71,16 @@ function getRunConfigByBrowserName(browser, saucelabs, browserstack) {
71
71
  return _.merge(selectedBrowser, selectedOS);
72
72
  }
73
73
 
74
- function handleAngularURIComponent(part) {
75
- return part.replace(/(~|\/)/g, m => ({ '~': '~~', '/': '~2F' }[m]));
76
- }
77
-
78
74
  function getTestUrl(editorUrl, projectId, testId, resultId, branch) {
79
75
  let testUrl = '';
80
- branch = branch ? handleAngularURIComponent(branch) : 'master';
76
+ branch = branch ? encodeURIComponent(branch) : 'master';
81
77
  if (projectId && testId) {
82
78
  testUrl = `${editorUrl}/#/project/${projectId}/branch/${branch}/test/${testId}`;
83
79
  if (resultId) {
84
80
  testUrl += `?result-id=${resultId}`;
85
81
  }
86
82
  }
87
- return encodeURI(testUrl);
83
+ return testUrl;
88
84
  }
89
85
 
90
86
  function isPromise(obj) {
package/utils.test.js CHANGED
@@ -32,7 +32,7 @@ describe('utils', () => {
32
32
  expect(utils.getTestUrl('http://localhost:8080', 'project', 'test', 'result', 'normal-branch-name'))
33
33
  .to.equal('http://localhost:8080/#/project/project/branch/normal-branch-name/test/test?result-id=result');
34
34
  expect(utils.getTestUrl('http://localhost:8080', 'project', 'test', 'result', 'branch/with/slashes'))
35
- .to.equal('http://localhost:8080/#/project/project/branch/branch~2Fwith~2Fslashes/test/test?result-id=result');
35
+ .to.equal('http://localhost:8080/#/project/project/branch/branch%2Fwith%2Fslashes/test/test?result-id=result');
36
36
  expect(utils.getTestUrl('http://localhost:8080', 'project', 'test', 'result', 'branch with spaces'))
37
37
  .to.equal('http://localhost:8080/#/project/project/branch/branch%20with%20spaces/test/test?result-id=result');
38
38
  expect(utils.getTestUrl('http://localhost:8080', 'project', 'test', 'result', 'encoded%20branch'))