@mablhq/mabl-cli 2.0.3 → 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 (79) hide show
  1. package/commands/tests/tests_cmds/run-mobile.js +1 -1
  2. package/commands/tests/tests_cmds/run.js +1 -1
  3. package/execution/index.js +5 -5
  4. package/http/MablHttpAgent.js +1 -4
  5. package/http/RequestFilteringHttpAgent.js +3 -3
  6. package/http/axiosProxyConfig.js +10 -7
  7. package/http/httpUtil.js +10 -6
  8. package/index.js +3 -2
  9. package/mablscript/MablAction.js +5 -1
  10. package/mablscript/MablStep.js +13 -3
  11. package/mablscript/MablStepV2.js +10 -4
  12. package/mablscript/actions/AwaitDownloadAction.js +1 -1
  13. package/mablscript/actions/ConditionAction.js +1 -1
  14. package/mablscript/actions/CountAction.js +1 -1
  15. package/mablscript/actions/ExtractAction.js +1 -1
  16. package/mablscript/actions/FindAction.js +1 -1
  17. package/mablscript/actions/GenerateEmailAddressAction.js +1 -1
  18. package/mablscript/actions/GenerateRandomStringAction.js +1 -1
  19. package/mablscript/actions/GetUrlAction.js +1 -1
  20. package/mablscript/actions/GetVariableValue.js +1 -1
  21. package/mablscript/actions/JavaScriptAction.js +6 -2
  22. package/mablscript/importer.js +3 -3
  23. package/mablscript/mobile/steps/CreateVariableMobileStep.js +1 -1
  24. package/mablscript/mobile/steps/EnterTextStep.js +2 -2
  25. package/mablscript/mobile/steps/NavigateBackStep.js +1 -1
  26. package/mablscript/mobile/steps/NavigateHomeStep.js +1 -1
  27. package/mablscript/mobile/steps/ScrollStep.js +1 -1
  28. package/mablscript/mobile/steps/SetOrientationStep.js +1 -1
  29. package/mablscript/mobile/steps/TapStep.js +2 -2
  30. package/mablscript/mobile/steps/actions/MobileFindAction.js +1 -1
  31. package/mablscript/mobile/steps/stepUtil.js +20 -17
  32. package/mablscript/mobile/tests/steps/CreateVariableMobileStep.mobiletest.js +13 -2
  33. package/mablscript/mobile/tests/steps/EnterTextStep.mobiletest.js +5 -0
  34. package/mablscript/mobile/tests/steps/NavigateBackStep.mobiletest.js +7 -2
  35. package/mablscript/mobile/tests/steps/NavigateHomeStep.mobiletest.js +7 -2
  36. package/mablscript/mobile/tests/steps/ScrollStep.mobiletest.js +9 -0
  37. package/mablscript/mobile/tests/steps/SetOrientationStep.mobiletest.js +5 -0
  38. package/mablscript/mobile/tests/steps/TapStep.mobiletest.js +4 -0
  39. package/mablscript/steps/AccessibilityCheck.js +20 -9
  40. package/mablscript/steps/AssertStep.js +6 -1
  41. package/mablscript/steps/AssertStepOld.js +5 -2
  42. package/mablscript/steps/AwaitTabStep.js +5 -2
  43. package/mablscript/steps/AwaitUploadsStep.js +6 -4
  44. package/mablscript/steps/ClearCookiesStep.js +6 -4
  45. package/mablscript/steps/ClickAndHoldStep.js +10 -3
  46. package/mablscript/steps/ClickStep.js +10 -3
  47. package/mablscript/steps/CreateVariableStep.js +16 -6
  48. package/mablscript/steps/DoubleClickStep.js +10 -3
  49. package/mablscript/steps/DownloadStep.js +4 -2
  50. package/mablscript/steps/EchoStep.js +5 -3
  51. package/mablscript/steps/ElseIfConditionStep.js +6 -2
  52. package/mablscript/steps/ElseStep.js +6 -4
  53. package/mablscript/steps/EndStep.js +6 -4
  54. package/mablscript/steps/EnterAuthCodeStep.js +10 -3
  55. package/mablscript/steps/EnterTextStep.js +8 -2
  56. package/mablscript/steps/EvaluateFlowStep.js +5 -2
  57. package/mablscript/steps/EvaluateJavaScriptStep.js +9 -3
  58. package/mablscript/steps/HoverStep.js +10 -3
  59. package/mablscript/steps/IfConditionStep.js +8 -2
  60. package/mablscript/steps/NavigateStep.js +5 -2
  61. package/mablscript/steps/OpenEmailStep.js +5 -2
  62. package/mablscript/steps/ReleaseStep.js +10 -3
  63. package/mablscript/steps/RemoveCookieStep.js +5 -2
  64. package/mablscript/steps/RightClickStep.js +10 -3
  65. package/mablscript/steps/SelectStep.js +9 -3
  66. package/mablscript/steps/SendHttpRequestStep.js +5 -2
  67. package/mablscript/steps/SendKeyStep.js +10 -3
  68. package/mablscript/steps/SetCookieStep.js +5 -2
  69. package/mablscript/steps/SetFilesStep.js +9 -3
  70. package/mablscript/steps/SetViewportStep.js +5 -3
  71. package/mablscript/steps/SwitchContextStep.js +14 -3
  72. package/mablscript/steps/SyntheticStep.js +1 -1
  73. package/mablscript/steps/VisitUrlStep.js +5 -2
  74. package/mablscript/steps/WaitStep.js +5 -2
  75. package/mablscript/steps/WaitUntilStep.js +6 -3
  76. package/observers/ObserverBase.js +9 -0
  77. package/observers/mockObserver.js +3 -3
  78. package/package.json +4 -4
  79. package/util/javaScriptStepMigration.js +1 -0
@@ -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; } });
@@ -4,9 +4,10 @@ exports.convertObjectToMablscriptArgs = exports.distinctStrings = exports.parseA
4
4
  const domUtil_1 = require("../domUtil");
5
5
  const MablSymbol_1 = require("./MablSymbol");
6
6
  class MablAction {
7
- constructor(name, args) {
7
+ constructor(name, actionCode, args) {
8
8
  this.name = name;
9
9
  this.args = args;
10
+ this.actionCode = actionCode;
10
11
  }
11
12
  getActionArgs() {
12
13
  return this.args ? this.args : [];
@@ -17,6 +18,9 @@ class MablAction {
17
18
  getActionSourceIndexInStep() {
18
19
  return this.actionSourceIndexInStep;
19
20
  }
21
+ getActionCode() {
22
+ return this.actionCode;
23
+ }
20
24
  subVariable(argument) {
21
25
  if (argumentIsMablVariable(argument)) {
22
26
  const matches = argument.match(MablSymbol_1.SINGLE_VARIABLE_PATTERN_REGEX);
@@ -9,14 +9,20 @@ const MablAction_1 = require("./MablAction");
9
9
  const MablSymbol_1 = require("./MablSymbol");
10
10
  const fast_json_stable_stringify_1 = __importDefault(require("fast-json-stable-stringify"));
11
11
  class MablStep extends MablAction_1.MablAction {
12
- constructor(name, args, actions) {
13
- super(name, args);
12
+ constructor(name, args, actions, actionCode) {
13
+ super(name, actionCode, args);
14
14
  this.stepVersion = 1;
15
15
  this.actions = actions;
16
16
  }
17
17
  getStepVersion() {
18
18
  return this.stepVersion;
19
19
  }
20
+ setStepId(id) {
21
+ this.id = id;
22
+ }
23
+ stepId() {
24
+ return this.id;
25
+ }
20
26
  canContinueOnFailure() {
21
27
  return false;
22
28
  }
@@ -94,7 +100,11 @@ class MablStep extends MablAction_1.MablAction {
94
100
  const formatted = {};
95
101
  formatted[this.getStepName()] =
96
102
  this.annotationsAsYml();
97
- Object.assign(formatted[this.getStepName()], this.toStepDescriptor(fullLocatorsOn));
103
+ const { actionCode, ...stepDescriptor } = this.toStepDescriptor(fullLocatorsOn);
104
+ Object.assign(formatted[this.getStepName()], stepDescriptor);
105
+ if (this.stepId()) {
106
+ formatted[this.getStepName()].id = this.stepId();
107
+ }
98
108
  return formatted;
99
109
  }
100
110
  toMablscript() {
@@ -3,13 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isMablStepV2 = exports.MablStepV2 = void 0;
4
4
  const MablStep_1 = require("./MablStep");
5
5
  class MablStepV2 extends MablStep_1.MablStep {
6
- constructor(name, descriptor) {
7
- super(name, [], []);
6
+ constructor(name, descriptor, actionCode) {
7
+ super(name, [], [], actionCode);
8
8
  this.stepVersion = 2;
9
9
  this.descriptor = descriptor;
10
10
  }
11
- static fromYaml(stepName, stepDescriptor) {
12
- return new MablStepV2(stepName, stepDescriptor);
11
+ stepId() {
12
+ return this.descriptor.id;
13
+ }
14
+ setStepId(id) {
15
+ this.descriptor.id = id;
16
+ }
17
+ static fromYaml(stepName, stepDescriptor, actionCode) {
18
+ return new MablStepV2(stepName, stepDescriptor, actionCode);
13
19
  }
14
20
  getStepName() {
15
21
  return this.name;
@@ -4,7 +4,7 @@ exports.AwaitDownloadAction = void 0;
4
4
  const MablAction_1 = require("../MablAction");
5
5
  class AwaitDownloadAction extends MablAction_1.MablAction {
6
6
  constructor(name, args) {
7
- super(name, args);
7
+ super(name, 'await_download', args);
8
8
  }
9
9
  toMablscript() {
10
10
  return 'await_download()';
@@ -6,7 +6,7 @@ const MablAction_1 = require("../MablAction");
6
6
  const ConditionDescriptor_1 = require("../types/ConditionDescriptor");
7
7
  class ConditionAction extends MablAction_1.MablAction {
8
8
  constructor(name, args) {
9
- super(name, args);
9
+ super(name, name, args);
10
10
  this.conditionAttribute = '';
11
11
  this.conditionValueAttribute = '';
12
12
  this.setConditionAttributes();
@@ -4,7 +4,7 @@ exports.CountAction = void 0;
4
4
  const MablAction_1 = require("../MablAction");
5
5
  class CountAction extends MablAction_1.MablAction {
6
6
  constructor(name, args) {
7
- super(name, args);
7
+ super(name, 'count', args);
8
8
  this.countDescriptor = { count: true };
9
9
  }
10
10
  toMablscript() {
@@ -13,7 +13,7 @@ var ExtractTypeName;
13
13
  })(ExtractTypeName = exports.ExtractTypeName || (exports.ExtractTypeName = {}));
14
14
  class ExtractAction extends MablAction_1.MablAction {
15
15
  constructor(name, args) {
16
- super(name, args);
16
+ super(name, name, args);
17
17
  if (this.name === ExtractDescriptor_1.ExtractType.EXTRACT_INNER_TEXT) {
18
18
  this.name = ExtractDescriptor_1.ExtractType.EXTRACT_ATTRIBUTE;
19
19
  this.extractionAttribute = 'innerText';
@@ -18,7 +18,7 @@ exports.formattedFindTypeToMablscript = {};
18
18
  Object.entries(exports.findTypesToFormattedType).forEach(([findType, field]) => (exports.formattedFindTypeToMablscript[field] = findType));
19
19
  class FindAction extends MablAction_1.MablAction {
20
20
  constructor(name, args) {
21
- super(name, args);
21
+ super(name, name, args);
22
22
  const actionName = this.getActionName();
23
23
  if (!(0, domUtil_1.isFindType)(actionName)) {
24
24
  throw new Error(`Unknown find type for action: ${actionName}`);
@@ -4,7 +4,7 @@ exports.GenerateEmailAddressAction = void 0;
4
4
  const MablAction_1 = require("../MablAction");
5
5
  class GenerateEmailAddressAction extends MablAction_1.MablAction {
6
6
  constructor(name, args) {
7
- super(name, args);
7
+ super(name, 'generate_email_address', args);
8
8
  }
9
9
  toMablscript() {
10
10
  return 'generate_email_address()';
@@ -5,7 +5,7 @@ const MablAction_1 = require("../MablAction");
5
5
  const domUtil_1 = require("../../domUtil");
6
6
  class GenerateRandomStringAction extends MablAction_1.MablAction {
7
7
  constructor(name, args) {
8
- super(name, args);
8
+ super(name, 'generate_random_string', args);
9
9
  this.generateString = this.getActionArgs()[0];
10
10
  }
11
11
  toMablscript() {
@@ -5,7 +5,7 @@ const MablAction_1 = require("../MablAction");
5
5
  const GetCurrentLocationDescriptor_1 = require("../types/GetCurrentLocationDescriptor");
6
6
  class GetUrlAction extends MablAction_1.MablAction {
7
7
  constructor(name, args) {
8
- super(name, args);
8
+ super(name, 'get_current_location', args);
9
9
  }
10
10
  toMablscript() {
11
11
  return `get_current_location()`;
@@ -6,7 +6,7 @@ const MablSymbol_1 = require("../MablSymbol");
6
6
  const GetVariableDescriptor_1 = require("../types/GetVariableDescriptor");
7
7
  class GetVariableValue extends MablAction_1.MablAction {
8
8
  constructor(name, args) {
9
- super(name, args);
9
+ super(name, 'get_variable_value', args);
10
10
  const arg = this.getActionArgs()[0];
11
11
  if (typeof arg !== 'string') {
12
12
  throw new Error('Expected string argument');
@@ -23,7 +23,7 @@ function isSnippetOptions(value) {
23
23
  }
24
24
  class JavaScriptAction extends MablAction_1.MablAction {
25
25
  constructor(name, args) {
26
- super(name, args);
26
+ super(name, MABLSCRIPT_NAME, args);
27
27
  if (args.length < 1 || args.length > 2) {
28
28
  throw new Error('EvaluateJS action expects 1 or 2 arguments');
29
29
  }
@@ -36,12 +36,14 @@ class JavaScriptAction extends MablAction_1.MablAction {
36
36
  if (typeof scriptOrSnippetReference === 'string') {
37
37
  this.javaScript = {
38
38
  encodedJS: scriptOrSnippetReference,
39
+ actionCode: MABLSCRIPT_NAME,
39
40
  };
40
41
  }
41
42
  else if (isLegacySnippetReference(scriptOrSnippetReference)) {
42
43
  const { id } = scriptOrSnippetReference;
43
44
  this.javaScript = {
44
45
  snippetInvariantId: id,
46
+ actionCode: MABLSCRIPT_NAME,
45
47
  };
46
48
  }
47
49
  else if (isReusableSnippetReference(scriptOrSnippetReference)) {
@@ -50,6 +52,7 @@ class JavaScriptAction extends MablAction_1.MablAction {
50
52
  snippetId: id,
51
53
  snippetInvariantId: invariant_id,
52
54
  parameterOverrides: [],
55
+ actionCode: MABLSCRIPT_NAME,
53
56
  };
54
57
  const snippetOptions = args[1];
55
58
  if (isSnippetOptions(snippetOptions)) {
@@ -60,6 +63,7 @@ class JavaScriptAction extends MablAction_1.MablAction {
60
63
  this.javaScript = {
61
64
  inlineSnippet: scriptOrSnippetReference,
62
65
  parameterOverrides: [],
66
+ actionCode: MABLSCRIPT_NAME,
63
67
  };
64
68
  const snippetOptions = args[1];
65
69
  if (isSnippetOptions(snippetOptions)) {
@@ -71,7 +75,7 @@ class JavaScriptAction extends MablAction_1.MablAction {
71
75
  }
72
76
  }
73
77
  toDescriptor() {
74
- return { javaScript: this.javaScript };
78
+ return { javaScript: this.javaScript, actionCode: this.actionCode };
75
79
  }
76
80
  static fromDescriptor(descriptor) {
77
81
  const { javaScript } = descriptor;
@@ -171,13 +171,13 @@ function loadMablScriptIntoSteps(parsedMablscript) {
171
171
  const actionType = rawMablscriptToObjectsActionsMap[parsedAction.name];
172
172
  const action = actionType
173
173
  ? new actionType(parsedAction.name, parsedAction.arguments)
174
- : new MablAction_1.MablAction(parsedAction.name, parsedAction.arguments);
174
+ : new MablAction_1.MablAction(parsedAction.name, parsedAction.name, parsedAction.arguments);
175
175
  action.setActionSourceIndexInStep(actionIndex);
176
176
  return action;
177
177
  });
178
178
  let step = stepType
179
179
  ? new stepType(lastAction.name, lastAction.arguments, actions)
180
- : new MablStep_1.MablStep(lastAction.name, lastAction.arguments, actions);
180
+ : new MablStep_1.MablStep(lastAction.name, lastAction.arguments, actions, lastAction.name);
181
181
  if (step instanceof AssertStepOld_1.AssertStepOld) {
182
182
  step = step.getNewAssertionStep();
183
183
  }
@@ -234,7 +234,7 @@ function stepFromObjectInfo(stepName, stepArgs, isMobile) {
234
234
  if (Object.keys(yamlMablscriptToObjectsStepV1Map).includes(stepName)) {
235
235
  return yamlMablscriptToObjectsStepV1Map[stepName](stepName, stepArgs);
236
236
  }
237
- return new MablStep_1.MablStep(stepName, [], []);
237
+ return new MablStep_1.MablStep(stepName, [], [], stepName);
238
238
  }
239
239
  function getMablscriptMaybeWithComment(step) {
240
240
  return `${step.isDisabled() ? '//' : ''}${step.toMablscript()}`;
@@ -8,7 +8,7 @@ const MobileFindAction_1 = require("./actions/MobileFindAction");
8
8
  const stepUtil_1 = require("./stepUtil");
9
9
  class CreateVariableMobileStep extends MablStepV2_1.MablStepV2 {
10
10
  constructor(descriptor) {
11
- super(CreateVariableMobileStep.stepName, descriptor);
11
+ super(CreateVariableMobileStep.stepName, descriptor, 'mablscript_as');
12
12
  if ((0, CreateVariableMobileStepDescriptor_1.isCreateVariableMobileFindStepDescriptor)(this.descriptor)) {
13
13
  this.findAction = MobileFindAction_1.MobileFindAction.fromDescriptor(this.descriptor.find);
14
14
  this.actions = [this.findAction];
@@ -8,7 +8,7 @@ const MablAction_1 = require("../../MablAction");
8
8
  const STEP_NAME = 'EnterText';
9
9
  class EnterTextStep extends MablStepV2_1.MablStepV2 {
10
10
  constructor(descriptor) {
11
- super(EnterTextStep.stepName, descriptor);
11
+ super(EnterTextStep.stepName, descriptor, 'enter_text');
12
12
  }
13
13
  getInputVariables() {
14
14
  const { find, text } = this.descriptor;
@@ -17,7 +17,7 @@ class EnterTextStep extends MablStepV2_1.MablStepV2 {
17
17
  return vars;
18
18
  }
19
19
  stepDescription() {
20
- return (0, stepUtil_1.getDescriptionForMobileStep)(`Enter text "${this.descriptor.text}" in`, this.descriptor);
20
+ return (0, stepUtil_1.getDescriptionForMobileStepDescriptor)(`Enter text "${this.descriptor.text}" in`, this.descriptor);
21
21
  }
22
22
  static fromYaml(_stepName, stepDescriptor) {
23
23
  if (!stepDescriptor.find &&
@@ -5,7 +5,7 @@ const MablStepV2_1 = require("../../MablStepV2");
5
5
  const STEP_NAME = 'NavigateBack';
6
6
  class NavigateBackStep extends MablStepV2_1.MablStepV2 {
7
7
  constructor(descriptor) {
8
- super(NavigateBackStep.stepName, descriptor);
8
+ super(NavigateBackStep.stepName, descriptor, 'navigate_back');
9
9
  }
10
10
  stepDescription() {
11
11
  return `Navigate back`;
@@ -5,7 +5,7 @@ const MablStepV2_1 = require("../../MablStepV2");
5
5
  const STEP_NAME = 'NavigateHome';
6
6
  class NavigateHomeStep extends MablStepV2_1.MablStepV2 {
7
7
  constructor(descriptor) {
8
- super(NavigateHomeStep.stepName, descriptor);
8
+ super(NavigateHomeStep.stepName, descriptor, 'navigate_home');
9
9
  this.descriptor = descriptor;
10
10
  }
11
11
  stepDescription() {
@@ -5,7 +5,7 @@ const MablStepV2_1 = require("../../MablStepV2");
5
5
  const STEP_NAME = 'Scroll';
6
6
  class ScrollStep extends MablStepV2_1.MablStepV2 {
7
7
  constructor(descriptor) {
8
- super(ScrollStep.stepName, descriptor);
8
+ super(ScrollStep.stepName, descriptor, 'scroll');
9
9
  }
10
10
  stepDescription() {
11
11
  return humanizeScrollInformation(this.descriptor.coordinates);
@@ -5,7 +5,7 @@ const MablStepV2_1 = require("../../MablStepV2");
5
5
  const STEP_NAME = 'SetOrientation';
6
6
  class SetOrientationStep extends MablStepV2_1.MablStepV2 {
7
7
  constructor(descriptor) {
8
- super(SetOrientationStep.stepName, descriptor);
8
+ super(SetOrientationStep.stepName, descriptor, 'set_orientation');
9
9
  }
10
10
  stepDescription() {
11
11
  return `Set orientation of device to ${this.descriptor.orientation.toLowerCase()}`;
@@ -8,7 +8,7 @@ const stepUtil_1 = require("./stepUtil");
8
8
  const MablAction_1 = require("../../MablAction");
9
9
  class TapStep extends MablStepV2_1.MablStepV2 {
10
10
  constructor(descriptor) {
11
- super(TapStep.stepName, descriptor);
11
+ super(TapStep.stepName, descriptor, 'tap');
12
12
  this.findAction = MobileFindAction_1.MobileFindAction.fromDescriptor(this.descriptor.find);
13
13
  this.actions = [this.findAction];
14
14
  }
@@ -25,7 +25,7 @@ class TapStep extends MablStepV2_1.MablStepV2 {
25
25
  default:
26
26
  prependedText = `Tap on`;
27
27
  }
28
- return (0, stepUtil_1.getDescriptionForMobileStep)(prependedText, this.descriptor);
28
+ return (0, stepUtil_1.getDescriptionForMobileStepDescriptor)(prependedText, this.descriptor);
29
29
  }
30
30
  static fromYaml(_stepName, stepDescriptor) {
31
31
  return new TapStep(stepDescriptor);
@@ -4,7 +4,7 @@ exports.MobileFindAction = void 0;
4
4
  const MablAction_1 = require("../../../MablAction");
5
5
  class MobileFindAction extends MablAction_1.MablAction {
6
6
  constructor(findDescriptor) {
7
- super('MobileFindAction', [[]]);
7
+ super('MobileFindAction', 'mobile_find_action', [[]]);
8
8
  this.findDescriptor = findDescriptor;
9
9
  }
10
10
  toDescriptor() {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isStepWithFind = exports.humanizeCustomFind = exports.getDescriptionForMobileStep = exports.getSimpleIOSElementName = exports.getSimpleAndroidElementName = void 0;
3
+ exports.isStepWithFind = exports.humanizeCustomFind = exports.getElementDescriptionFromMobileFindDescriptor = exports.getDescriptionForMobileStepDescriptor = exports.getSimpleIOSElementName = exports.getSimpleAndroidElementName = void 0;
4
4
  const domUtil_1 = require("../../../domUtil");
5
5
  const mablscriptFind_1 = require("../../../mablscriptFind");
6
6
  function getSimpleAndroidElementName(className) {
@@ -22,39 +22,42 @@ function getSimpleIOSElementName(elementName) {
22
22
  return 'unknown';
23
23
  }
24
24
  exports.getSimpleIOSElementName = getSimpleIOSElementName;
25
- function getDescriptionForMobileStep(predicateAction, descriptor) {
26
- var _a;
27
- const findTarget = (_a = descriptor.find) === null || _a === void 0 ? void 0 : _a.findTarget;
25
+ function getDescriptionForMobileStepDescriptor(predicateAction, descriptor) {
26
+ const elementDescription = getElementDescriptionFromMobileFindDescriptor(descriptor.find);
27
+ return `${predicateAction} ${elementDescription}`;
28
+ }
29
+ exports.getDescriptionForMobileStepDescriptor = getDescriptionForMobileStepDescriptor;
30
+ function getElementDescriptionFromMobileFindDescriptor(descriptor) {
31
+ const findTarget = descriptor === null || descriptor === void 0 ? void 0 : descriptor.findTarget;
28
32
  if ((0, domUtil_1.isMobileFindSpecification)(findTarget)) {
29
- if ((0, domUtil_1.isWebViewFindElementDescriptor)(descriptor.find)) {
30
- return getDescriptionForWebViewStep(predicateAction, descriptor.find);
33
+ if ((0, domUtil_1.isWebViewFindElementDescriptor)(descriptor)) {
34
+ return getDescriptionForWebViewFindDescriptor(descriptor);
31
35
  }
32
36
  const selector = findTarget.selector;
33
37
  if (selector.android && Object.keys(selector.android).length) {
34
38
  if (selector.android.text) {
35
- return `${predicateAction} element with text "${selector.android.text}"`;
39
+ return `element with text "${selector.android.text}"`;
36
40
  }
37
- return `${predicateAction} "${getSimpleAndroidElementName(selector.android.class)}" element`;
41
+ return `"${getSimpleAndroidElementName(selector.android.class)}" element`;
38
42
  }
39
43
  else if (selector.iOS) {
40
44
  if (selector.iOS.name) {
41
- return `${predicateAction} "${selector.iOS.name}" element`;
45
+ return `"${selector.iOS.name}" element`;
42
46
  }
43
47
  if (selector.iOS.label) {
44
- return `${predicateAction} element with text "${selector.iOS.label}"`;
48
+ return `element with text "${selector.iOS.label}"`;
45
49
  }
46
- return `${predicateAction} the "${getSimpleIOSElementName(selector.iOS.type)}" element`;
50
+ return `the "${getSimpleIOSElementName(selector.iOS.type)}" element`;
47
51
  }
48
52
  }
49
- return `${predicateAction} unknown element`;
53
+ return 'unknown element';
50
54
  }
51
- exports.getDescriptionForMobileStep = getDescriptionForMobileStep;
52
- function getDescriptionForWebViewStep(predicateAction, webViewElementDescriptor) {
55
+ exports.getElementDescriptionFromMobileFindDescriptor = getElementDescriptionFromMobileFindDescriptor;
56
+ function getDescriptionForWebViewFindDescriptor(webViewElementDescriptor) {
53
57
  if ((0, domUtil_1.isFindElementDescriptor)(webViewElementDescriptor.webView.descriptor)) {
54
- const elementDescription = (0, mablscriptFind_1.humanizeFindOneDescriptor)(webViewElementDescriptor.webView.descriptor.findTarget);
55
- return `${predicateAction} ${elementDescription}`;
58
+ return (0, mablscriptFind_1.humanizeFindOneDescriptor)(webViewElementDescriptor.webView.descriptor.findTarget);
56
59
  }
57
- return `Unknown webview descriptor type.`;
60
+ return `unknown webview element`;
58
61
  }
59
62
  function humanizeCustomFind(descriptor) {
60
63
  if (isStepWithFind(descriptor)) {
@@ -7,10 +7,12 @@ const StepTestsUtil_1 = require("../StepTestsUtil");
7
7
  describe('CreateVariable mobile steps parse correctly', () => {
8
8
  it('Parses a CreateVariable mobile step with variable pattern', () => {
9
9
  const stepDescriptor = {
10
+ id: 'VariableSchmariable',
10
11
  generator: {
11
12
  pattern: `my value: {{digit:3}}`,
12
13
  type: CreateVariableStepDescriptor_1.VariableGenerator.PATTERN,
13
14
  },
15
+ actionCode: 'mablscript_as',
14
16
  name: 'myValue',
15
17
  };
16
18
  const steps = [
@@ -19,6 +21,8 @@ describe('CreateVariable mobile steps parse correctly', () => {
19
21
  },
20
22
  ];
21
23
  (0, StepTestsUtil_1.parseAndValidateYamlConversion)(steps, CreateVariableMobileStep_1.CreateVariableMobileStep.stepName, stepDescriptor);
24
+ const varStep = new CreateVariableMobileStep_1.CreateVariableMobileStep(stepDescriptor);
25
+ expect(varStep.stepId()).toEqual(stepDescriptor.id);
22
26
  });
23
27
  it('Parses a CreateVariable mobile step for generating email address', () => {
24
28
  const stepDescriptor = {
@@ -26,6 +30,7 @@ describe('CreateVariable mobile steps parse correctly', () => {
26
30
  type: CreateVariableStepDescriptor_1.VariableGenerator.EMAIL,
27
31
  },
28
32
  name: 'email',
33
+ actionCode: 'mablscript_as',
29
34
  };
30
35
  const steps = [
31
36
  {
@@ -52,6 +57,7 @@ describe('CreateVariable mobile steps parse correctly', () => {
52
57
  type: CreateVariableStepDescriptor_1.VariableGenerator.ATTRIBUTE,
53
58
  },
54
59
  name: 'profile',
60
+ actionCode: 'mablscript_as',
55
61
  };
56
62
  const steps = [
57
63
  {
@@ -78,6 +84,7 @@ describe('CreateVariable mobile steps parse correctly', () => {
78
84
  type: CreateVariableStepDescriptor_1.VariableGenerator.ATTRIBUTE,
79
85
  },
80
86
  name: 'profile',
87
+ actionCode: 'mablscript_as',
81
88
  };
82
89
  const steps = [
83
90
  {
@@ -107,6 +114,7 @@ describe('CreateVariable mobile steps parse correctly', () => {
107
114
  type: CreateVariableStepDescriptor_1.VariableGenerator.ELEMENT_COUNT,
108
115
  },
109
116
  name: 'count',
117
+ actionCode: 'mablscript_as',
110
118
  };
111
119
  const steps = [
112
120
  {
@@ -136,6 +144,7 @@ describe('CreateVariable mobile steps parse correctly', () => {
136
144
  type: CreateVariableStepDescriptor_1.VariableGenerator.ELEMENT_COUNT,
137
145
  },
138
146
  name: 'count',
147
+ actionCode: 'mablscript_as',
139
148
  };
140
149
  const steps = [
141
150
  {
@@ -147,9 +156,10 @@ describe('CreateVariable mobile steps parse correctly', () => {
147
156
  it('Parses a CreateVariable mobile step for JavaScript snippet (Android)', () => {
148
157
  const stepDescriptor = {
149
158
  generator: {
150
- javaScript: { encodedJS: 'myScript' },
159
+ javaScript: { encodedJS: 'myScript', actionCode: 'evaluate_js' },
151
160
  type: CreateVariableStepDescriptor_1.VariableGenerator.JAVASCRIPT,
152
161
  },
162
+ actionCode: 'mablscript_as',
153
163
  name: 'result',
154
164
  };
155
165
  const steps = [
@@ -162,10 +172,11 @@ describe('CreateVariable mobile steps parse correctly', () => {
162
172
  it('Parses a CreateVariable mobile step for element count (iOS)', () => {
163
173
  const stepDescriptor = {
164
174
  generator: {
165
- javaScript: { encodedJS: 'myScript' },
175
+ javaScript: { encodedJS: 'myScript', actionCode: 'evaluate_js' },
166
176
  type: CreateVariableStepDescriptor_1.VariableGenerator.JAVASCRIPT,
167
177
  },
168
178
  name: 'result',
179
+ actionCode: 'mablscript_as',
169
180
  };
170
181
  const steps = [
171
182
  {