@mablhq/mabl-cli 2.72.4 → 2.72.12

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 (70) hide show
  1. package/browserEngines/chromiumBrowserEngine.js +17 -0
  2. package/browserLauncher/index.js +3 -3
  3. package/commands/mcp/mcp_cmds/tools/createTest.js +10 -0
  4. package/commands/mcp/mcp_cmds/tools/getApplications.js +69 -0
  5. package/commands/mcp/mcp_cmds/tools/{getPlanResults.js → getLatestPlanRuns.js} +6 -6
  6. package/commands/mcp/mcp_cmds/tools/{getPlanRun.js → getPlanRunResult.js} +5 -5
  7. package/commands/mcp/mcp_cmds/tools/index.js +6 -4
  8. package/core/execution/ApiTestUtils.js +3 -1
  9. package/execution/index.js +1 -1
  10. package/http/requestInterceptor.js +10 -5
  11. package/index.d.ts +2 -0
  12. package/mablscript/MablStepV2.js +40 -10
  13. package/mablscript/MablStepWithFindAction.js +126 -2
  14. package/mablscript/actions/AwaitDownloadAction.js +4 -3
  15. package/mablscript/actions/AwaitPDFDownloadAction.js +6 -5
  16. package/mablscript/actions/ConditionAction.js +2 -1
  17. package/mablscript/actions/ExtractAction.js +8 -13
  18. package/mablscript/actions/FindAction.js +20 -0
  19. package/mablscript/actions/GetVariableValue.js +15 -4
  20. package/mablscript/actions/JavaScriptAction.js +25 -39
  21. package/mablscript/diffing/diffingUtil.js +5 -5
  22. package/mablscript/importer.js +79 -59
  23. package/mablscript/mobile/steps/CreateVariableMobileStep.js +3 -1
  24. package/mablscript/steps/AbstractAssertionsAndVariablesStep.js +10 -8
  25. package/mablscript/steps/AccessibilityCheck.js +78 -36
  26. package/mablscript/steps/AssertStep.js +267 -86
  27. package/mablscript/steps/AssertStepOld.js +69 -139
  28. package/mablscript/steps/AwaitTabStep.js +32 -9
  29. package/mablscript/steps/AwaitUploadsStep.js +24 -8
  30. package/mablscript/steps/ClearCookiesStep.js +24 -8
  31. package/mablscript/steps/ClickAndHoldStep.js +47 -47
  32. package/mablscript/steps/ClickStep.js +38 -33
  33. package/mablscript/steps/CreateVariableStep.js +169 -137
  34. package/mablscript/steps/DatabaseQueryStep.js +16 -4
  35. package/mablscript/steps/DoubleClickStep.js +39 -40
  36. package/mablscript/steps/DownloadStep.js +81 -63
  37. package/mablscript/steps/EchoStep.js +28 -8
  38. package/mablscript/steps/ElseIfConditionStep.js +25 -12
  39. package/mablscript/steps/ElseStep.js +24 -9
  40. package/mablscript/steps/EndStep.js +24 -9
  41. package/mablscript/steps/EnterAuthCodeStep.js +38 -34
  42. package/mablscript/steps/EnterTextStep.js +53 -64
  43. package/mablscript/steps/EvaluateFlowStep.js +41 -18
  44. package/mablscript/steps/EvaluateJavaScriptStep.js +19 -19
  45. package/mablscript/steps/HoverStep.js +39 -39
  46. package/mablscript/steps/IfConditionStep.js +141 -99
  47. package/mablscript/steps/NavigateStep.js +31 -9
  48. package/mablscript/steps/OpenEmailStep.js +41 -21
  49. package/mablscript/steps/ReleaseStep.js +48 -38
  50. package/mablscript/steps/RemoveCookieStep.js +27 -9
  51. package/mablscript/steps/RightClickStep.js +38 -33
  52. package/mablscript/steps/SelectStep.js +71 -46
  53. package/mablscript/steps/SendHttpRequestStep.js +11 -4
  54. package/mablscript/steps/SendKeyStep.js +175 -49
  55. package/mablscript/steps/SetCookieStep.js +58 -23
  56. package/mablscript/steps/SetFilesStep.js +44 -43
  57. package/mablscript/steps/SetViewportStep.js +40 -12
  58. package/mablscript/steps/StepGroupStep.js +70 -0
  59. package/mablscript/steps/SwitchContextStep.js +93 -83
  60. package/mablscript/steps/SyntheticStep.js +1 -1
  61. package/mablscript/steps/VisitUrlStep.js +31 -21
  62. package/mablscript/steps/WaitStep.js +21 -8
  63. package/mablscript/steps/WaitUntilStep.js +32 -13
  64. package/mablscript/types/AssertStepDescriptor.js +2 -0
  65. package/mablscript/types/ConditionDescriptor.js +5 -5
  66. package/mablscript/types/GetVariableDescriptor.js +0 -8
  67. package/mablscript/types/StepGroupStepDescriptor.js +2 -0
  68. package/package.json +4 -4
  69. package/proxy/index.js +1 -1
  70. package/upload/index.js +1 -1
@@ -4,43 +4,63 @@ exports.OpenEmailStep = void 0;
4
4
  const FindAction_1 = require("../actions/FindAction");
5
5
  const MablStepWithFindAction_1 = require("../MablStepWithFindAction");
6
6
  class OpenEmailStep extends MablStepWithFindAction_1.MablStepWithFindAction {
7
- constructor(name, args, actions) {
8
- super(name, args, actions, OpenEmailStep.stepName);
9
- this.tabUuid = this.getActionArgs()[0] || {};
10
- this.validate();
11
- this.findAction = this.actions[0];
12
- }
13
- validate() {
14
- if (this.actions.length !== 1 && !(this.actions[0] instanceof FindAction_1.FindAction)) {
7
+ constructor(descriptor, findAction) {
8
+ super(OpenEmailStep.stepName, descriptor, OpenEmailStep.actionCode, findAction);
9
+ this.tabUuid = descriptor.tab;
10
+ }
11
+ static validateActions(actions) {
12
+ if (actions.length !== 1 || !(actions[0] instanceof FindAction_1.FindAction)) {
15
13
  throw new Error('Open email steps should have exactly one sub action and it should be a find');
16
14
  }
15
+ return actions[0];
17
16
  }
18
17
  getStepName() {
19
- return 'OpenEmail';
18
+ return OpenEmailStep.stepName;
20
19
  }
21
20
  toStepDescriptor() {
22
- const find = this.findAction.toDescriptor();
23
- return {
24
- tab: this.tabUuid,
25
- selector: find.findTarget.selector,
26
- findType: 'FindEmail',
27
- configuration: find.findTarget.configuration,
28
- actionCode: this.actionCode,
29
- };
21
+ return buildStepDescriptor(this.findAction, this.tabUuid);
30
22
  }
31
23
  static fromYaml(_stepName, stepArgs) {
32
- const step = new OpenEmailStep(OpenEmailStep.stepName, [stepArgs.tab], [FindAction_1.FindAction.findActionFromStepArgs(stepArgs)]);
24
+ const findAction = FindAction_1.FindAction.findActionFromStepArgs(stepArgs);
25
+ const stepDescriptor = buildStepDescriptor(findAction, stepArgs.tab);
26
+ const step = new OpenEmailStep(stepDescriptor, findAction);
33
27
  step.setStepId(stepArgs.id);
34
28
  return step;
35
29
  }
30
+ static fromLegacyMablscript(args, actions) {
31
+ const tabUuid = args[0] ?? '';
32
+ if (actions.length !== 1 || !(actions[0] instanceof FindAction_1.FindAction)) {
33
+ throw new Error('Open email steps should have exactly one sub action and it should be a find');
34
+ }
35
+ const findAction = actions[0];
36
+ const stepDescriptor = buildStepDescriptor(findAction, tabUuid);
37
+ const step = new OpenEmailStep(stepDescriptor, findAction);
38
+ step.actions = actions;
39
+ return step;
40
+ }
36
41
  toMablscript() {
37
42
  return `${this.findAction.toMablscript()}.open_email("${this.tabUuid}")`;
38
43
  }
39
44
  getInputVariables() {
40
45
  return this.findAction.getInputVariables();
41
46
  }
47
+ stepDescription() {
48
+ const emailDescription = this.humanizeFind();
49
+ return `Open ${emailDescription}`;
50
+ }
42
51
  }
43
52
  exports.OpenEmailStep = OpenEmailStep;
44
- OpenEmailStep.stepName = 'open_email';
45
- OpenEmailStep.mablScriptStepNames = [OpenEmailStep.stepName];
46
- OpenEmailStep.yamlMablScriptNames = ['OpenEmail'];
53
+ OpenEmailStep.stepName = 'OpenEmail';
54
+ OpenEmailStep.actionCode = 'open_email';
55
+ OpenEmailStep.mablScriptStepNames = [OpenEmailStep.actionCode];
56
+ OpenEmailStep.yamlMablScriptNames = [OpenEmailStep.stepName];
57
+ function buildStepDescriptor(findAction, tabUuid) {
58
+ const find = findAction.toDescriptor();
59
+ return {
60
+ tab: tabUuid,
61
+ selector: find.findTarget.selector,
62
+ findType: 'FindEmail',
63
+ configuration: find.findTarget.configuration,
64
+ actionCode: OpenEmailStep.actionCode,
65
+ };
66
+ }
@@ -8,60 +8,44 @@ const ActionsUtils_1 = require("./ActionsUtils");
8
8
  const ReleaseStepDescriptor_1 = require("../types/ReleaseStepDescriptor");
9
9
  const MablStepWithFindAction_1 = require("../MablStepWithFindAction");
10
10
  class ReleaseStep extends MablStepWithFindAction_1.MablStepWithFindAction {
11
- constructor(name, args, actions) {
12
- super(name, args, actions, 'release');
13
- this.findAction = ActionsUtils_1.ActionsUtils.validateSingleFindAction(this.actions);
14
- this.releaseArgs = this.parseArgs(args) ?? { isHtml5: false };
11
+ constructor(descriptor, findAction) {
12
+ super(ReleaseStep.stepName, descriptor, ReleaseStep.actionCode, findAction);
13
+ this.releaseArgs = descriptor.releaseArgs;
15
14
  }
16
- parseArgs(args) {
15
+ static parseArgs(args) {
17
16
  if (args.length === 0) {
18
17
  return undefined;
19
18
  }
20
19
  if (args.length !== 1) {
21
- throw new Error(`Unexpected number of arguments to ${this.getStepName()} step.`);
20
+ throw new Error(`Unexpected number of arguments to Release step.`);
22
21
  }
23
22
  if (!(0, ReleaseStepDescriptor_1.isReleaseArgs)(args[0])) {
24
- throw new Error(`Invalid argument passed to ${this.getStepName()} step.`);
23
+ throw new Error(`Invalid argument passed to Release step.`);
25
24
  }
26
25
  return args[0];
27
26
  }
28
27
  getStepName() {
29
- return 'Release';
28
+ return ReleaseStep.stepName;
30
29
  }
31
30
  toStepDescriptor() {
32
- const find = this.findAction.toDescriptor();
33
- switch (find.findType) {
34
- case domUtil_1.FindType.FIND_FIRST:
35
- case domUtil_1.FindType.FIND_LAST:
36
- case domUtil_1.FindType.FIND_ANY:
37
- case domUtil_1.FindType.FIND_ONE:
38
- return {
39
- find,
40
- descriptorToActionMap: new Map().set(find, this.findAction),
41
- actionCode: this.actionCode,
42
- releaseArgs: this.releaseArgs,
43
- };
44
- default:
45
- throw new Error(`Error generating step descriptor for ${this.getStepName()}: Unexpected find type ${find.findType}`);
46
- }
47
- }
48
- getFormattedStep(_fullLocatorsOn) {
49
- const step = {
50
- Release: {
51
- ...super.annotationsAsYml(),
52
- ...this.findAction.toYaml(),
53
- },
54
- };
55
- if (this.stepId()) {
56
- step.Release.id = this.stepId();
57
- }
58
- return step;
31
+ return buildStepDescriptor(this.findAction, this.releaseArgs);
59
32
  }
60
33
  static fromYaml(_stepName, stepArgs) {
61
- const step = new ReleaseStep('release', [], [FindAction_1.FindAction.findActionFromStepArgs(stepArgs)]);
34
+ const findAction = FindAction_1.FindAction.findActionFromStepArgs(stepArgs);
35
+ const releaseArgs = { isHtml5: false };
36
+ const stepDescriptor = buildStepDescriptor(findAction, releaseArgs);
37
+ const step = new ReleaseStep(stepDescriptor, findAction);
62
38
  step.setStepId(stepArgs.id);
63
39
  return step;
64
40
  }
41
+ static fromLegacyMablscript(args, actions) {
42
+ const findAction = ActionsUtils_1.ActionsUtils.validateSingleFindAction(actions);
43
+ const releaseArgs = ReleaseStep.parseArgs(args) ?? { isHtml5: false };
44
+ const stepDescriptor = buildStepDescriptor(findAction, releaseArgs);
45
+ const step = new ReleaseStep(stepDescriptor, findAction);
46
+ step.actions = actions;
47
+ return step;
48
+ }
65
49
  toMablscript() {
66
50
  const args = (0, MablAction_1.convertObjectToMablscriptArgs)(this.releaseArgs);
67
51
  return `${this.findAction.toMablscript()}.release(${args})`;
@@ -69,7 +53,33 @@ class ReleaseStep extends MablStepWithFindAction_1.MablStepWithFindAction {
69
53
  getInputVariables() {
70
54
  return this.findAction.getInputVariables();
71
55
  }
56
+ stepDescription() {
57
+ const actionPrefix = this.releaseArgs.isHtml5
58
+ ? 'Simulate release'
59
+ : 'Release';
60
+ const elementDescription = this.humanizeFind();
61
+ return `${actionPrefix} on ${elementDescription}`;
62
+ }
72
63
  }
73
64
  exports.ReleaseStep = ReleaseStep;
74
- ReleaseStep.mablScriptStepNames = ['release'];
75
- ReleaseStep.yamlMablScriptNames = ['Release'];
65
+ ReleaseStep.stepName = 'Release';
66
+ ReleaseStep.actionCode = 'release';
67
+ ReleaseStep.mablScriptStepNames = [ReleaseStep.actionCode];
68
+ ReleaseStep.yamlMablScriptNames = [ReleaseStep.stepName];
69
+ function buildStepDescriptor(findAction, releaseArgs) {
70
+ const find = findAction.toDescriptor();
71
+ switch (find.findType) {
72
+ case domUtil_1.FindType.FIND_FIRST:
73
+ case domUtil_1.FindType.FIND_LAST:
74
+ case domUtil_1.FindType.FIND_ANY:
75
+ case domUtil_1.FindType.FIND_ONE:
76
+ return {
77
+ find,
78
+ descriptorToActionMap: new Map().set(find, findAction),
79
+ actionCode: 'release',
80
+ releaseArgs,
81
+ };
82
+ default:
83
+ throw new Error(`Error generating step descriptor for Release: Unexpected find type ${find.findType}`);
84
+ }
85
+ }
@@ -1,17 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RemoveCookieStep = void 0;
4
- const MablStep_1 = require("../MablStep");
4
+ const MablStepV2_1 = require("../MablStepV2");
5
5
  const MablAction_1 = require("../MablAction");
6
6
  const CookieUtils_1 = require("./CookieUtils");
7
7
  const domUtil_1 = require("../../domUtil");
8
- class RemoveCookieStep extends MablStep_1.MablStep {
9
- constructor(name, args, actions) {
10
- super(name, args, actions, 'remove_cookie');
11
- this.cookieName = CookieUtils_1.CookieUtils.normalizeName(this.getActionArgs()[0].name);
8
+ class RemoveCookieStep extends MablStepV2_1.MablStepV2 {
9
+ constructor(descriptor) {
10
+ super(RemoveCookieStep.stepName, descriptor, RemoveCookieStep.actionCode);
11
+ this.cookieName = descriptor.name;
12
12
  }
13
13
  getStepName() {
14
- return 'RemoveCookie';
14
+ return RemoveCookieStep.stepName;
15
15
  }
16
16
  toStepDescriptor() {
17
17
  return {
@@ -20,17 +20,35 @@ class RemoveCookieStep extends MablStep_1.MablStep {
20
20
  };
21
21
  }
22
22
  static fromYaml(_stepName, stepArgs) {
23
- const step = new RemoveCookieStep('remove_cookie', [stepArgs], []);
23
+ const stepDescriptor = {
24
+ actionCode: RemoveCookieStep.actionCode,
25
+ name: CookieUtils_1.CookieUtils.normalizeName(stepArgs.name),
26
+ };
27
+ const step = new RemoveCookieStep(stepDescriptor);
24
28
  step.setStepId(stepArgs.id);
25
29
  return step;
26
30
  }
31
+ static fromLegacyMablscript(args, _actions) {
32
+ const stepDescriptor = {
33
+ actionCode: RemoveCookieStep.actionCode,
34
+ name: CookieUtils_1.CookieUtils.normalizeName(args[0].name),
35
+ };
36
+ const step = new RemoveCookieStep(stepDescriptor);
37
+ step.actions = _actions;
38
+ return step;
39
+ }
27
40
  toMablscript() {
28
41
  return `remove_cookie({ name : "${(0, domUtil_1.escapeMablscriptString)(this.cookieName)}" })`;
29
42
  }
30
43
  getInputVariables() {
31
44
  return MablAction_1.MablAction.findUniqueVariableReferencesInValue(this.cookieName);
32
45
  }
46
+ stepDescription() {
47
+ return `Remove cookie: "${this.cookieName}"`;
48
+ }
33
49
  }
34
50
  exports.RemoveCookieStep = RemoveCookieStep;
35
- RemoveCookieStep.mablScriptStepNames = ['remove_cookie'];
36
- RemoveCookieStep.yamlMablScriptNames = ['RemoveCookie'];
51
+ RemoveCookieStep.stepName = 'RemoveCookie';
52
+ RemoveCookieStep.actionCode = 'remove_cookie';
53
+ RemoveCookieStep.mablScriptStepNames = [RemoveCookieStep.actionCode];
54
+ RemoveCookieStep.yamlMablScriptNames = [RemoveCookieStep.stepName];
@@ -6,53 +6,58 @@ const domUtil_1 = require("../../domUtil");
6
6
  const ActionsUtils_1 = require("./ActionsUtils");
7
7
  const MablStepWithFindAction_1 = require("../MablStepWithFindAction");
8
8
  class RightClickStep extends MablStepWithFindAction_1.MablStepWithFindAction {
9
- constructor(name, args, actions) {
10
- super(name, args, actions, 'right_click');
11
- this.findAction = ActionsUtils_1.ActionsUtils.validateSingleFindAction(this.actions);
9
+ constructor(descriptor, findAction) {
10
+ super(RightClickStep.stepName, descriptor, RightClickStep.actionCode, findAction);
12
11
  }
13
12
  getStepName() {
14
- return 'RightClick';
13
+ return RightClickStep.stepName;
15
14
  }
16
15
  toStepDescriptor() {
17
- const find = this.findAction.toDescriptor();
18
- switch (find.findType) {
19
- case domUtil_1.FindType.FIND_FIRST:
20
- case domUtil_1.FindType.FIND_LAST:
21
- case domUtil_1.FindType.FIND_ANY:
22
- case domUtil_1.FindType.FIND_ONE:
23
- return {
24
- find,
25
- descriptorToActionMap: new Map().set(find, this.findAction),
26
- actionCode: this.actionCode,
27
- };
28
- default:
29
- throw new Error(`Error generating step descriptor for ${this.getStepName()}: Unexpected find type ${find.findType}`);
30
- }
31
- }
32
- getFormattedStep(_fullLocatorsOn) {
33
- const step = {
34
- RightClick: {
35
- ...super.annotationsAsYml(),
36
- ...this.findAction.toYaml(),
37
- },
38
- };
39
- if (this.stepId()) {
40
- step.RightClick.id = this.stepId();
41
- }
42
- return step;
16
+ return buildStepDescriptor(this.findAction);
43
17
  }
44
18
  static fromYaml(_stepName, stepArgs) {
45
- const step = new RightClickStep('right_click', [], [FindAction_1.FindAction.findActionFromStepArgs(stepArgs)]);
19
+ const findAction = FindAction_1.FindAction.findActionFromStepArgs(stepArgs);
20
+ const stepDescriptor = buildStepDescriptor(findAction);
21
+ const step = new RightClickStep(stepDescriptor, findAction);
46
22
  step.setStepId(stepArgs.id);
47
23
  return step;
48
24
  }
25
+ static fromLegacyMablscript(_args, actions) {
26
+ const findAction = ActionsUtils_1.ActionsUtils.validateSingleFindAction(actions);
27
+ const stepDescriptor = buildStepDescriptor(findAction);
28
+ const step = new RightClickStep(stepDescriptor, findAction);
29
+ step.actions = actions;
30
+ return step;
31
+ }
49
32
  toMablscript() {
50
33
  return `${this.findAction.toMablscript()}.right_click()`;
51
34
  }
52
35
  getInputVariables() {
53
36
  return this.findAction.getInputVariables();
54
37
  }
38
+ stepDescription() {
39
+ const elementDescription = this.humanizeFind();
40
+ return `Right click on ${elementDescription}`;
41
+ }
55
42
  }
56
43
  exports.RightClickStep = RightClickStep;
57
- RightClickStep.mablScriptStepNames = ['right_click'];
58
- RightClickStep.yamlMablScriptNames = ['RightClick'];
44
+ RightClickStep.stepName = 'Right Click';
45
+ RightClickStep.actionCode = 'right_click';
46
+ RightClickStep.mablScriptStepNames = [RightClickStep.actionCode];
47
+ RightClickStep.yamlMablScriptNames = [RightClickStep.stepName];
48
+ function buildStepDescriptor(findAction) {
49
+ const find = findAction.toDescriptor();
50
+ switch (find.findType) {
51
+ case domUtil_1.FindType.FIND_FIRST:
52
+ case domUtil_1.FindType.FIND_LAST:
53
+ case domUtil_1.FindType.FIND_ANY:
54
+ case domUtil_1.FindType.FIND_ONE:
55
+ return {
56
+ find,
57
+ descriptorToActionMap: new Map().set(find, findAction),
58
+ actionCode: RightClickStep.actionCode,
59
+ };
60
+ default:
61
+ throw new Error(`Error generating step descriptor for ${RightClickStep.stepName}: Unexpected find type ${find.findType}`);
62
+ }
63
+ }
@@ -6,37 +6,20 @@ const MablAction_1 = require("../MablAction");
6
6
  const domUtil_1 = require("../../domUtil");
7
7
  const MablStepWithFindAction_1 = require("../MablStepWithFindAction");
8
8
  class SelectStep extends MablStepWithFindAction_1.MablStepWithFindAction {
9
- constructor(name, args, actions) {
10
- super(name, args, actions, 'select');
11
- this.selectOptions = this.getActionArgs()[0];
12
- this.selectOptionType = this.getActionArgs()[1];
13
- this.validate();
14
- this.findAction = this.actions[0];
9
+ constructor(descriptor, findAction) {
10
+ super(SelectStep.stepName, descriptor, SelectStep.actionCode, findAction);
15
11
  }
16
- validate() {
17
- if (this.actions.length !== 1 && !(this.actions[0] instanceof FindAction_1.FindAction)) {
18
- throw new Error('Select steps should have exactly on sub action and it should be a find');
12
+ static validateActions(actions) {
13
+ if (actions.length !== 1 || !(actions[0] instanceof FindAction_1.FindAction)) {
14
+ throw new Error('Select steps should have exactly one sub action and it should be a find');
19
15
  }
16
+ return actions[0];
20
17
  }
21
18
  getStepName() {
22
- return 'Select';
19
+ return SelectStep.stepName;
23
20
  }
24
21
  toStepDescriptor() {
25
- const selectOptionsCopy = this.selectOptions;
26
- selectOptionsCopy.selectOptionType = this.selectOptionType;
27
- const formatted = { ...selectOptionsCopy };
28
- const find = this.findAction.toDescriptor();
29
- switch (find.findType) {
30
- case domUtil_1.FindType.FIND_FIRST:
31
- case domUtil_1.FindType.FIND_LAST:
32
- case domUtil_1.FindType.FIND_ANY:
33
- case domUtil_1.FindType.FIND_ONE:
34
- formatted.find = find;
35
- formatted.descriptorToActionMap = new Map().set(find, this.findAction);
36
- return formatted;
37
- default:
38
- throw new Error(`Error generating step descriptor for ${this.getStepName()}: Unexpected find type ${find.findType}`);
39
- }
22
+ return this.descriptor;
40
23
  }
41
24
  static fromYaml(_stepName, stepArgs) {
42
25
  const findAction = FindAction_1.FindAction.findActionFromStepArgs(stepArgs);
@@ -45,38 +28,80 @@ class SelectStep extends MablStepWithFindAction_1.MablStepWithFindAction {
45
28
  delete stepArgs.selectorAncestors;
46
29
  delete stepArgs.selectOptionType;
47
30
  const selectOptions = stepArgs;
48
- const step = new SelectStep('select', [selectOptions, selectOptionType], [findAction]);
31
+ const stepDescriptor = buildStepDescriptor(findAction, selectOptions, selectOptionType);
32
+ const step = new SelectStep(stepDescriptor, findAction);
49
33
  step.setStepId(stepArgs.id);
50
34
  return step;
51
35
  }
52
- getFormattedStep(_fullLocatorsOn) {
53
- const step = this.selectOptions;
54
- const { find, ...ymlStep } = step;
55
- const finalStep = {
56
- Select: {
57
- ...ymlStep,
58
- ...super.annotationsAsYml(),
59
- ...this.findAction.toYaml(),
60
- },
61
- };
62
- if (this.stepId()) {
63
- finalStep.Select.id = this.stepId();
64
- }
65
- return finalStep;
36
+ static fromLegacyMablscript(args, actions) {
37
+ const selectOptions = args[0];
38
+ const selectOptionType = args[1];
39
+ const findAction = SelectStep.validateActions(actions);
40
+ const stepDescriptor = buildStepDescriptor(findAction, selectOptions, selectOptionType);
41
+ const step = new SelectStep(stepDescriptor, findAction);
42
+ step.actions = actions;
43
+ return step;
66
44
  }
67
45
  toMablscript() {
68
- const selectOptionType = this.selectOptionType
69
- ? `, "${this.selectOptionType}"`
46
+ const descriptor = this.descriptor;
47
+ const selectOptionType = descriptor.selectOptionType;
48
+ const selectOptions = {
49
+ index: descriptor.index,
50
+ position: descriptor.position,
51
+ selector_type: descriptor.selector_type,
52
+ text: descriptor.text,
53
+ uuid: descriptor.uuid,
54
+ value: descriptor.value,
55
+ };
56
+ const mablscriptSelectOptions = (0, MablAction_1.convertObjectToMablscriptArgs)(selectOptions);
57
+ const mablscriptSelectType = selectOptionType
58
+ ? `, "${selectOptionType}"`
70
59
  : '';
71
- return `${this.findAction.toMablscript()}.select(${(0, MablAction_1.convertObjectToMablscriptArgs)(this.selectOptions)}${selectOptionType})`;
60
+ const mablscriptSelectArgs = mablscriptSelectOptions + mablscriptSelectType;
61
+ return `${this.findAction.toMablscript()}.select(${mablscriptSelectArgs})`;
72
62
  }
73
63
  getInputVariables() {
74
64
  return (0, MablAction_1.distinctStrings)([
75
65
  ...this.findAction.getInputVariables(),
76
- ...MablAction_1.MablAction.findUniqueVariableReferencesInValue(this.selectOptions),
66
+ ...MablAction_1.MablAction.findUniqueVariableReferencesInValue(this.descriptor),
77
67
  ]);
78
68
  }
69
+ stepDescription() {
70
+ let selectionDescription = 'option';
71
+ const descriptor = this.descriptor;
72
+ if (descriptor.value) {
73
+ selectionDescription = `"${descriptor.value}"`;
74
+ }
75
+ else if (descriptor.text) {
76
+ selectionDescription = `"${descriptor.text}"`;
77
+ }
78
+ else if (descriptor.index !== undefined) {
79
+ selectionDescription = `option ${descriptor.index}`;
80
+ }
81
+ const elementDescription = this.humanizeFind();
82
+ return `Select ${selectionDescription} from ${elementDescription}`;
83
+ }
79
84
  }
80
85
  exports.SelectStep = SelectStep;
81
- SelectStep.mablScriptStepNames = ['select'];
82
- SelectStep.yamlMablScriptNames = ['Select'];
86
+ SelectStep.stepName = 'Select';
87
+ SelectStep.actionCode = 'select';
88
+ SelectStep.mablScriptStepNames = [SelectStep.actionCode];
89
+ SelectStep.yamlMablScriptNames = [SelectStep.stepName];
90
+ function buildStepDescriptor(findAction, selectOptions, selectOptionType) {
91
+ const find = findAction.toDescriptor();
92
+ switch (find.findType) {
93
+ case domUtil_1.FindType.FIND_FIRST:
94
+ case domUtil_1.FindType.FIND_LAST:
95
+ case domUtil_1.FindType.FIND_ANY:
96
+ case domUtil_1.FindType.FIND_ONE:
97
+ const descriptorToActionMap = new Map().set(find, findAction);
98
+ return {
99
+ find,
100
+ descriptorToActionMap,
101
+ selectOptionType,
102
+ ...selectOptions,
103
+ };
104
+ default:
105
+ throw new Error(`Error generating step descriptor for ${SelectStep.stepName}: Unexpected find type ${find.findType}`);
106
+ }
107
+ }
@@ -4,8 +4,8 @@ exports.SendHttpRequestVariableSource = exports.SendHttpRequestStep = void 0;
4
4
  const ConditionDescriptor_1 = require("../types/ConditionDescriptor");
5
5
  const AbstractAssertionsAndVariablesStep_1 = require("./AbstractAssertionsAndVariablesStep");
6
6
  class SendHttpRequestStep extends AbstractAssertionsAndVariablesStep_1.AbstractAssertionsAndVariablesStep {
7
- constructor(name, args, actions) {
8
- super(name, args, actions, 'send_http_request', SendHttpRequestStep.stepName, args[0]);
7
+ constructor(descriptor) {
8
+ super(SendHttpRequestStep.stepName, descriptor, SendHttpRequestStep.actionCode);
9
9
  }
10
10
  static fromYaml(_stepName, stepArgs) {
11
11
  const formatted = stepArgs;
@@ -28,14 +28,21 @@ class SendHttpRequestStep extends AbstractAssertionsAndVariablesStep_1.AbstractA
28
28
  assertion.assertion = comparisonTypeConverter[assertion.assertion];
29
29
  }
30
30
  });
31
- const step = new SendHttpRequestStep(SendHttpRequestStep.stepName, [formatted], []);
31
+ const step = new SendHttpRequestStep(formatted);
32
32
  step.setStepId(stepArgs.id);
33
33
  return step;
34
34
  }
35
+ static fromLegacyMablscript(args, _actions) {
36
+ if (args.length !== 1) {
37
+ throw new Error(`SendHttpRequestStep fromLegacyMablscript expects 1 argument, got ${args.length}`);
38
+ }
39
+ return new SendHttpRequestStep(args[0]);
40
+ }
35
41
  }
36
42
  exports.SendHttpRequestStep = SendHttpRequestStep;
37
43
  SendHttpRequestStep.stepName = 'SendHttpRequest';
38
- SendHttpRequestStep.mablScriptStepNames = ['send_http_request'];
44
+ SendHttpRequestStep.actionCode = 'send_http_request';
45
+ SendHttpRequestStep.mablScriptStepNames = [SendHttpRequestStep.actionCode];
39
46
  SendHttpRequestStep.yamlMablScriptNames = [SendHttpRequestStep.stepName];
40
47
  var SendHttpRequestVariableSource;
41
48
  (function (SendHttpRequestVariableSource) {