@mablhq/mabl-cli 1.62.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/api/basicApiClient.js +10 -10
  2. package/api/mablApiClient.js +39 -1
  3. package/browserLauncher/playwrightBrowserLauncher/playwrightBrowser.js +6 -6
  4. package/cli.js +1 -0
  5. package/commands/app-files/app-files.js +5 -0
  6. package/commands/app-files/app-files_cmds/create.js +98 -0
  7. package/commands/app-files/app-files_cmds/delete.js +31 -0
  8. package/commands/app-files/app-files_cmds/download.js +50 -0
  9. package/commands/app-files/app-files_cmds/list.js +72 -0
  10. package/commands/config/config_cmds/install.js +92 -0
  11. package/commands/constants.js +9 -2
  12. package/commands/tests/testsUtil.js +9 -1
  13. package/commands/tests/tests_cmds/run-mobile.js +218 -0
  14. package/commands/tests/tests_cmds/run.js +1 -1
  15. package/core/util.js +36 -2
  16. package/env/defaultEnv.js +2 -1
  17. package/env/dev.js +2 -1
  18. package/env/env.js +3 -1
  19. package/env/local.js +2 -1
  20. package/env/prod.js +2 -1
  21. package/execution/index.js +13 -1
  22. package/execution/runAppiumServer.js +133 -0
  23. package/http/MablHttpAgent.js +1 -4
  24. package/http/RequestFilteringHttpAgent.js +3 -3
  25. package/http/axiosProxyConfig.js +10 -7
  26. package/http/httpUtil.js +10 -6
  27. package/index.js +3 -2
  28. package/mablApi/index.js +1 -1
  29. package/mablscript/MablAction.js +6 -2
  30. package/mablscript/MablStep.js +41 -5
  31. package/mablscript/MablStepV2.js +57 -0
  32. package/mablscript/MablSymbol.js +6 -2
  33. package/mablscript/actions/AwaitDownloadAction.js +1 -1
  34. package/mablscript/actions/ConditionAction.js +1 -1
  35. package/mablscript/actions/CountAction.js +1 -1
  36. package/mablscript/actions/ExtractAction.js +12 -7
  37. package/mablscript/actions/FindAction.js +6 -6
  38. package/mablscript/actions/GenerateEmailAddressAction.js +1 -1
  39. package/mablscript/actions/GenerateRandomStringAction.js +1 -1
  40. package/mablscript/actions/GetUrlAction.js +1 -1
  41. package/mablscript/actions/GetVariableValue.js +1 -1
  42. package/mablscript/actions/JavaScriptAction.js +25 -14
  43. package/mablscript/importer.js +99 -16
  44. package/mablscript/mobile/steps/CreateVariableMobileStep.js +53 -0
  45. package/mablscript/mobile/steps/EnterTextStep.js +41 -0
  46. package/mablscript/mobile/steps/NavigateBackStep.js +20 -0
  47. package/mablscript/mobile/steps/NavigateHomeStep.js +21 -0
  48. package/mablscript/mobile/steps/ScrollStep.js +37 -0
  49. package/mablscript/mobile/steps/SetOrientationStep.js +20 -0
  50. package/mablscript/mobile/steps/TapStep.js +37 -0
  51. package/mablscript/mobile/steps/actions/MobileFindAction.js +23 -0
  52. package/mablscript/mobile/steps/stepUtil.js +74 -0
  53. package/mablscript/mobile/tests/StepTestsUtil.js +20 -0
  54. package/mablscript/mobile/tests/TestMobileFindDescriptors.js +215 -0
  55. package/mablscript/mobile/tests/steps/CreateVariableMobileStep.mobiletest.js +298 -0
  56. package/mablscript/mobile/tests/steps/EnterTextStep.mobiletest.js +79 -0
  57. package/mablscript/mobile/tests/steps/GeneralHumanization.mobiletest.js +167 -0
  58. package/mablscript/mobile/tests/steps/NavigateBackStep.mobiletest.js +27 -0
  59. package/mablscript/mobile/tests/steps/NavigateHomeStep.mobiletest.js +27 -0
  60. package/mablscript/mobile/tests/steps/ScrollStep.mobiletest.js +121 -0
  61. package/mablscript/mobile/tests/steps/SetOrientationStep.mobiletest.js +32 -0
  62. package/mablscript/mobile/tests/steps/TapStep.mobiletest.js +57 -0
  63. package/mablscript/steps/AccessibilityCheck.js +20 -9
  64. package/mablscript/steps/AssertStep.js +54 -39
  65. package/mablscript/steps/AssertStepOld.js +35 -4
  66. package/mablscript/steps/AwaitTabStep.js +5 -2
  67. package/mablscript/steps/AwaitUploadsStep.js +6 -4
  68. package/mablscript/steps/ClearCookiesStep.js +6 -4
  69. package/mablscript/steps/ClickAndHoldStep.js +10 -3
  70. package/mablscript/steps/ClickStep.js +10 -3
  71. package/mablscript/steps/CreateVariableStep.js +25 -8
  72. package/mablscript/steps/DoubleClickStep.js +10 -3
  73. package/mablscript/steps/DownloadStep.js +4 -2
  74. package/mablscript/steps/EchoStep.js +8 -5
  75. package/mablscript/steps/ElseIfConditionStep.js +14 -4
  76. package/mablscript/steps/ElseStep.js +8 -5
  77. package/mablscript/steps/EndStep.js +8 -5
  78. package/mablscript/steps/EnterAuthCodeStep.js +10 -3
  79. package/mablscript/steps/EnterTextStep.js +8 -2
  80. package/mablscript/steps/EvaluateFlowStep.js +5 -2
  81. package/mablscript/steps/EvaluateJavaScriptStep.js +15 -4
  82. package/mablscript/steps/HoverStep.js +10 -3
  83. package/mablscript/steps/IfConditionStep.js +25 -12
  84. package/mablscript/steps/NavigateStep.js +5 -2
  85. package/mablscript/steps/OpenEmailStep.js +5 -2
  86. package/mablscript/steps/ReleaseStep.js +10 -3
  87. package/mablscript/steps/RemoveCookieStep.js +5 -2
  88. package/mablscript/steps/RightClickStep.js +10 -3
  89. package/mablscript/steps/SelectStep.js +9 -3
  90. package/mablscript/steps/SendHttpRequestStep.js +8 -4
  91. package/mablscript/steps/SendKeyStep.js +10 -3
  92. package/mablscript/steps/SetCookieStep.js +5 -2
  93. package/mablscript/steps/SetFilesStep.js +9 -3
  94. package/mablscript/steps/SetViewportStep.js +5 -3
  95. package/mablscript/steps/SwitchContextStep.js +14 -3
  96. package/mablscript/steps/SyntheticStep.js +1 -1
  97. package/mablscript/steps/VisitUrlStep.js +5 -2
  98. package/mablscript/steps/WaitStep.js +8 -4
  99. package/mablscript/steps/WaitUntilStep.js +6 -3
  100. package/mablscript/types/GetVariableDescriptor.js +8 -3
  101. package/mablscript/types/mobile/CreateVariableMobileStepDescriptor.js +9 -0
  102. package/mablscript/types/mobile/EnterTextStepDescriptor.js +2 -0
  103. package/mablscript/types/mobile/NavigateBackStepDescriptor.js +2 -0
  104. package/mablscript/types/mobile/NavigateHomeStepDescriptor.js +2 -0
  105. package/mablscript/types/mobile/ScrollStepDescriptor.js +2 -0
  106. package/mablscript/types/mobile/SetOrientationStepDescriptor.js +8 -0
  107. package/mablscript/types/mobile/StepWithMobileFindDescriptor.js +2 -0
  108. package/mablscript/types/mobile/TapStepDescriptor.js +8 -0
  109. package/mablscriptFind/index.js +1 -1
  110. package/observers/ObserverBase.js +9 -0
  111. package/observers/mockObserver.js +3 -3
  112. package/package.json +11 -6
  113. package/resources/webdriver.js +21 -0
  114. package/upload/index.js +5 -0
  115. package/util/FileCache.js +180 -0
  116. package/util/Lazy.js +90 -0
  117. package/util/MobileAppFileCache.js +102 -0
  118. package/util/RichPromise.js +3 -1
  119. package/util/javaScriptStepMigration.js +1 -0
  120. package/webdriver/index.js +41 -0
@@ -0,0 +1,133 @@
1
+ const appium = require('appium');
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+ const APPIUM_SERVER_READY = 'APPIUM_SERVER_READY';
10
+ const APPIUM_SERVER_SHUTDOWN = 'APPIUM_SERVER_SHUTDOWN';
11
+ const APPIUM_SERVER_LOG = 'APPIUM_SERVER_LOG';
12
+ const APPIUM_SERVER_PARENT_ALIVE = 'APPIUM_SERVER_PARENT_ALIVE';
13
+ const APPIUM_SERVER_CHECK_IN = 'APPIUM_SERVER_CHECK_IN';
14
+
15
+
16
+ const CHECK_IN_FAIL_LIMIT_MILLIS = 15_000;
17
+
18
+ const CHECK_IN_INTERVAL_MILLIS = 5_000;
19
+
20
+
21
+ const appiumConfig = JSON.parse(process.argv[2]);
22
+
23
+ if (appiumConfig.androidHome) {
24
+ process.env.ANDROID_HOME = appiumConfig.androidHome;
25
+ delete appiumConfig.androidHome;
26
+ }
27
+
28
+
29
+
30
+ appiumConfig.allowInsecure = ['chromedriver_autodownload'];
31
+
32
+ let server;
33
+ let shutdownCalled = false;
34
+ let lastKnownCheckInTime = Date.now();
35
+ let intervalCheckIn;
36
+
37
+ appium
38
+ .main({...appiumConfig, logHandler: logHandlerFunc})
39
+ .then((serverInstance) => {
40
+ server = serverInstance;
41
+ process.send({type: APPIUM_SERVER_READY});
42
+ lastKnownCheckInTime = Date.now();
43
+ intervalCheckIn = global.setInterval(
44
+ checkInOnParent,
45
+ CHECK_IN_INTERVAL_MILLIS,
46
+ );
47
+ })
48
+ .catch((error) => {
49
+
50
+ throw error;
51
+ });
52
+ process.on('message', (message) => {
53
+ switch (message) {
54
+ case APPIUM_SERVER_PARENT_ALIVE:
55
+ lastKnownCheckInTime = Date.now();
56
+ break;
57
+ case APPIUM_SERVER_SHUTDOWN:
58
+ shutdownCalled = true;
59
+ server.close().catch((error) => {
60
+
61
+ throw error;
62
+ });
63
+ break;
64
+ default:
65
+ console.log('unsupported message', message);
66
+ }
67
+ });
68
+
69
+
70
+ function logHandlerFunc(logLevel, log) {
71
+ process.send({
72
+ type: APPIUM_SERVER_LOG,
73
+ payload: {
74
+ logLevel,
75
+ log,
76
+ },
77
+ });
78
+ }
79
+
80
+
81
+ const originalExit = process.exit;
82
+
83
+
84
+
85
+ process.exit = (code) => {
86
+ if (shutdownCalled) {
87
+ global.clearInterval(intervalCheckIn);
88
+
89
+
90
+ originalExit();
91
+ process.kill();
92
+ }
93
+ if (code && code > 0) {
94
+ const stack = new Error().stack;
95
+ process.send({
96
+ type: APPIUM_SERVER_LOG,
97
+ payload: {
98
+ logLevel: 'error',
99
+ log: `process.exit() call prevented - ${stack}`,
100
+ },
101
+ });
102
+ return;
103
+ }
104
+ };
105
+
106
+ process.on('disconnect', () => {
107
+ console.log(
108
+ '[runAppiumServer.js] lost connection to parent process, terminating',
109
+ );
110
+ originalExit();
111
+ process.kill();
112
+ });
113
+
114
+
115
+ function checkInOnParent() {
116
+ try {
117
+ process.send({type: APPIUM_SERVER_CHECK_IN});
118
+ const currentTime = Date.now();
119
+ const timeSinceLastCheckIn = currentTime - lastKnownCheckInTime;
120
+ if (timeSinceLastCheckIn > CHECK_IN_FAIL_LIMIT_MILLIS) {
121
+ console.log(
122
+ '[runAppiumServer.js] parent process has gone dark, terminating',
123
+ );
124
+ global.clearInterval(intervalCheckIn);
125
+ originalExit();
126
+ process.kill();
127
+ }
128
+ lastKnownCheckInTime = currentTime;
129
+ } catch (error) {
130
+ console.error('Could not run checkin function', error);
131
+ }
132
+ return;
133
+ }
@@ -55,14 +55,11 @@ class MablHttpAgent extends agent_base_1.Agent {
55
55
  httpsAgent: (_b = httpsAgent !== null && httpsAgent !== void 0 ? httpsAgent : proxyConfig.httpsAgent) !== null && _b !== void 0 ? _b : https.globalAgent,
56
56
  };
57
57
  }
58
- createSocket(req, options, cb) {
58
+ callback(req, opts) {
59
59
  var _a;
60
60
  if ((_a = this.maybeGetFirstStringHeader(req, httpUtil_1.USER_AGENT_HEADER)) === null || _a === void 0 ? void 0 : _a.startsWith('PostmanRuntime/')) {
61
61
  req.setHeader(httpUtil_1.USER_AGENT_HEADER, httpUtil_1.USER_AGENT);
62
62
  }
63
- super.createSocket(req, options, cb);
64
- }
65
- connect(_req, opts) {
66
63
  return Promise.resolve(opts.secureEndpoint ? this.httpsAgent : this.httpAgent);
67
64
  }
68
65
  maybeGetFirstStringHeader(req, name) {
@@ -45,17 +45,17 @@ class RequestFilteringHttpAgent extends MablHttpAgent_1.MablHttpAgent {
45
45
  const constructorParameters = await MablHttpAgent_1.MablHttpAgent.getConstructorParameters();
46
46
  return new RequestFilteringHttpAgent(constructorParameters.httpAgent, constructorParameters.httpsAgent);
47
47
  }
48
- connect(req, opts) {
48
+ callback(req, opts) {
49
49
  if (isForbiddenHost(opts.host)) {
50
50
  return Promise.reject(new RequestSecurityError_1.RequestSecurityError('Request contains forbidden host'));
51
51
  }
52
- else if (containsForbiddenHeader(req.getHeaders())) {
52
+ else if (containsForbiddenHeader(opts.headers)) {
53
53
  return Promise.reject(new RequestSecurityError_1.RequestSecurityError('Request contains forbidden header'));
54
54
  }
55
55
  else if (isPrivateAddress(opts.host)) {
56
56
  return Promise.reject(new RequestSecurityError_1.RequestSecurityError('Request contains private address'));
57
57
  }
58
- return super.connect(req, opts);
58
+ return super.callback(req, opts);
59
59
  }
60
60
  }
61
61
  exports.RequestFilteringHttpAgent = RequestFilteringHttpAgent;
@@ -59,8 +59,7 @@ function axiosProxyConfig(httpConfig) {
59
59
  if (testExecutionProxyUrl || ((_a = httpConfig.proxyHost) === null || _a === void 0 ? void 0 : _a.href)) {
60
60
  config.proxy = proxyUrlToPortConfig((testExecutionProxyUrl !== null && testExecutionProxyUrl !== void 0 ? testExecutionProxyUrl : httpConfig.proxyHost));
61
61
  }
62
- const result = maybeGetModifiedAxiosConfigForHttpProxy(config, sslVerify, proxyType);
63
- return result;
62
+ return maybeGetModifiedAxiosConfigForHttpProxy(config, sslVerify, proxyType);
64
63
  }
65
64
  exports.axiosProxyConfig = axiosProxyConfig;
66
65
  function escapeRegexDots(input) {
@@ -103,9 +102,13 @@ function maybeGetModifiedAxiosConfigForHttpProxy(config, sslVerify, proxyType) {
103
102
  proxyString += `${authConfig.username}:${authConfig.password}@`;
104
103
  }
105
104
  proxyString += `${config.proxy.host}:${config.proxy.port}`;
106
- const proxyUrl = new URL(proxyString);
107
105
  const configOptions = {
108
- rejectUnauthorized: sslVerify !== false,
106
+ host: config.proxy.host,
107
+ port: config.proxy.port,
108
+ auth: authConfig
109
+ ? `${authConfig.username}:${authConfig.password}`
110
+ : undefined,
111
+ rejectUnauthorized: sslVerify === true,
109
112
  };
110
113
  if (proxyType === 'current') {
111
114
  const agentConfig = {
@@ -114,14 +117,14 @@ function maybeGetModifiedAxiosConfigForHttpProxy(config, sslVerify, proxyType) {
114
117
  maxSockets: 256,
115
118
  maxFreeSockets: 256,
116
119
  proxy: proxyString,
117
- rejectUnauthorized: sslVerify !== false,
120
+ rejectUnauthorized: sslVerify === true,
118
121
  };
119
122
  newConfig.httpsAgent = new hpagent_1.HttpsProxyAgent(agentConfig);
120
123
  }
121
124
  else {
122
- newConfig.httpsAgent = new https_proxy_agent_1.HttpsProxyAgent(proxyUrl, configOptions);
125
+ newConfig.httpsAgent = new https_proxy_agent_1.HttpsProxyAgent(configOptions);
123
126
  }
124
- newConfig.httpAgent = new https_proxy_agent_1.HttpsProxyAgent(proxyUrl, configOptions);
127
+ newConfig.httpAgent = new https_proxy_agent_1.HttpsProxyAgent(configOptions);
125
128
  return newConfig;
126
129
  }
127
130
  return config;
package/http/httpUtil.js CHANGED
@@ -27,12 +27,16 @@ function maybeGetSocksAgent(linkServer) {
27
27
  if (!linkServer) {
28
28
  return;
29
29
  }
30
- const user = linkServer.workspace_id;
31
- const password = linkServer.label;
32
- const host = linkServer.forwarding_host;
33
- const port = linkServer.forwarding_port;
34
- const url = new URL(`socks5h://${user}:${password}@${host}:${port}`);
35
- return new socks_proxy_agent_1.SocksProxyAgent(url);
30
+ const agentOptions = {
31
+ host: linkServer.forwarding_host,
32
+ port: linkServer.forwarding_port,
33
+ userId: linkServer.workspace_id,
34
+ password: linkServer.label,
35
+ tls: {
36
+ rejectUnauthorized: false,
37
+ },
38
+ };
39
+ return new socks_proxy_agent_1.SocksProxyAgent(agentOptions);
36
40
  }
37
41
  function postProcessHeaders(response) {
38
42
  var _a, _b, _c;
package/index.js CHANGED
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getRunnerVersion = exports.createRunConfig = exports.createMablTestRunner = exports.editTest = exports.trainNewTest = void 0;
3
+ exports.getRunnerVersion = exports.createRunConfig = exports.MobileTestsRunner = exports.BrowserTestsRunner = exports.editTest = exports.trainNewTest = void 0;
4
4
  var trainingSessions_1 = require("./core/trainer/trainingSessions");
5
5
  Object.defineProperty(exports, "trainNewTest", { enumerable: true, get: function () { return trainingSessions_1.trainNewTest; } });
6
6
  Object.defineProperty(exports, "editTest", { enumerable: true, get: function () { return trainingSessions_1.editTest; } });
7
7
  var index_1 = require("./execution/index");
8
- Object.defineProperty(exports, "createMablTestRunner", { enumerable: true, get: function () { return index_1.createTestRunner; } });
8
+ Object.defineProperty(exports, "BrowserTestsRunner", { enumerable: true, get: function () { return index_1.BrowserTestsRunner; } });
9
+ Object.defineProperty(exports, "MobileTestsRunner", { enumerable: true, get: function () { return index_1.MobileTestsRunner; } });
9
10
  Object.defineProperty(exports, "createRunConfig", { enumerable: true, get: function () { return index_1.createRunConfig; } });
10
11
  Object.defineProperty(exports, "getRunnerVersion", { enumerable: true, get: function () { return index_1.getRunnerVersion; } });