@mablhq/mabl-cli 2.72.0 → 2.72.3

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 (60) hide show
  1. package/core/execution/ApiTestUtils.js +12 -2
  2. package/execution/index.js +1 -1
  3. package/mablscript/MablStepV2.js +10 -40
  4. package/mablscript/MablStepWithFindAction.js +2 -126
  5. package/mablscript/actions/AwaitDownloadAction.js +3 -4
  6. package/mablscript/actions/AwaitPDFDownloadAction.js +5 -6
  7. package/mablscript/actions/ConditionAction.js +1 -2
  8. package/mablscript/actions/ExtractAction.js +13 -8
  9. package/mablscript/actions/FindAction.js +0 -20
  10. package/mablscript/actions/GetVariableValue.js +4 -15
  11. package/mablscript/actions/JavaScriptAction.js +39 -25
  12. package/mablscript/diffing/diffingUtil.js +5 -5
  13. package/mablscript/importer.js +59 -79
  14. package/mablscript/mobile/steps/CreateVariableMobileStep.js +1 -3
  15. package/mablscript/mobile/steps/stepUtil.js +2 -2
  16. package/mablscript/steps/AbstractAssertionsAndVariablesStep.js +8 -10
  17. package/mablscript/steps/AccessibilityCheck.js +36 -76
  18. package/mablscript/steps/AssertStep.js +86 -266
  19. package/mablscript/steps/AssertStepOld.js +139 -69
  20. package/mablscript/steps/AwaitTabStep.js +9 -30
  21. package/mablscript/steps/AwaitUploadsStep.js +8 -22
  22. package/mablscript/steps/ClearCookiesStep.js +8 -22
  23. package/mablscript/steps/ClickAndHoldStep.js +47 -45
  24. package/mablscript/steps/ClickStep.js +33 -36
  25. package/mablscript/steps/CreateVariableStep.js +137 -169
  26. package/mablscript/steps/DatabaseQueryStep.js +4 -14
  27. package/mablscript/steps/DoubleClickStep.js +40 -37
  28. package/mablscript/steps/DownloadStep.js +63 -79
  29. package/mablscript/steps/EchoStep.js +8 -26
  30. package/mablscript/steps/ElseIfConditionStep.js +12 -23
  31. package/mablscript/steps/ElseStep.js +9 -22
  32. package/mablscript/steps/EndStep.js +9 -22
  33. package/mablscript/steps/EnterAuthCodeStep.js +34 -36
  34. package/mablscript/steps/EnterTextStep.js +64 -51
  35. package/mablscript/steps/EvaluateFlowStep.js +18 -39
  36. package/mablscript/steps/EvaluateJavaScriptStep.js +19 -17
  37. package/mablscript/steps/HoverStep.js +39 -37
  38. package/mablscript/steps/IfConditionStep.js +99 -139
  39. package/mablscript/steps/NavigateStep.js +9 -29
  40. package/mablscript/steps/OpenEmailStep.js +21 -39
  41. package/mablscript/steps/ReleaseStep.js +38 -46
  42. package/mablscript/steps/RemoveCookieStep.js +9 -25
  43. package/mablscript/steps/RightClickStep.js +33 -36
  44. package/mablscript/steps/SelectStep.js +46 -69
  45. package/mablscript/steps/SendHttpRequestStep.js +4 -13
  46. package/mablscript/steps/SendKeyStep.js +50 -174
  47. package/mablscript/steps/SetCookieStep.js +23 -56
  48. package/mablscript/steps/SetFilesStep.js +43 -42
  49. package/mablscript/steps/SetViewportStep.js +13 -39
  50. package/mablscript/steps/SwitchContextStep.js +83 -89
  51. package/mablscript/steps/SyntheticStep.js +1 -1
  52. package/mablscript/steps/VisitUrlStep.js +22 -30
  53. package/mablscript/steps/WaitStep.js +9 -20
  54. package/mablscript/steps/WaitUntilStep.js +14 -31
  55. package/mablscript/types/ConditionDescriptor.js +5 -5
  56. package/mablscript/types/GetVariableDescriptor.js +8 -0
  57. package/package.json +1 -1
  58. package/mablscript/steps/StepGroupStep.js +0 -70
  59. package/mablscript/types/AssertStepDescriptor.js +0 -2
  60. package/mablscript/types/StepGroupStepDescriptor.js +0 -2
@@ -1,89 +1,159 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AssertStepOldConverter = exports.oldToV2StepNameMap = void 0;
4
- const AssertStep_1 = require("./AssertStep");
5
- const ConditionAction_1 = require("../actions/ConditionAction");
6
- const ConditionDescriptor_1 = require("../types/ConditionDescriptor");
7
- exports.oldToV2StepNameMap = {
8
- assert_equals: 'AssertEquals',
9
- assert_present: 'AssertPresent',
10
- assert_not_present: 'AssertNotPresent',
11
- assert_does_not_equal: 'AssertDoesNotEqual',
3
+ exports.AssertStepOld = void 0;
4
+ const ExtractAction_1 = require("../actions/ExtractAction");
5
+ const MablStep_1 = require("../MablStep");
6
+ const FindAction_1 = require("../actions/FindAction");
7
+ const domUtil_1 = require("../../domUtil");
8
+ const importer_1 = require("../importer");
9
+ const GetCurrentLocationDescriptor_1 = require("../types/GetCurrentLocationDescriptor");
10
+ const GetVariableDescriptor_1 = require("../types/GetVariableDescriptor");
11
+ const GetViewportDescriptor_1 = require("../types/GetViewportDescriptor");
12
+ const oldToNewAssertionTypes = {
12
13
  assert_contains: 'AssertContains',
13
14
  assert_does_not_contain: 'AssertDoesNotContain',
15
+ assert_does_not_equal: 'AssertDoesNotEqual',
16
+ assert_download: 'AssertDownload',
17
+ assert_equals: 'AssertEquals',
18
+ assert_greater_than: 'AssertGreaterThan',
19
+ assert_greater_than_or_equals: 'AssertGreaterThanOrEquals',
20
+ assert_less_than: 'AssertLessThan',
21
+ assert_less_than_or_equals: 'AssertLessThanOrEquals',
22
+ assert_not_present: 'AssertNotPresent',
23
+ assert_present: 'AssertPresent',
14
24
  assert_starts_with: 'AssertStartsWith',
15
25
  assert_starts_without: 'AssertStartsWithout',
16
26
  assert_ends_with: 'AssertEndsWith',
17
27
  assert_ends_without: 'AssertEndsWithout',
18
- assert_greater_than: 'AssertGreaterThan',
19
- assert_less_than: 'AssertLessThan',
20
- assert_greater_than_or_equals: 'AssertGreaterThanOrEquals',
21
- assert_less_than_or_equals: 'AssertLessThanOrEquals',
22
- assert_matches_regex: 'AssertMatchesRegex',
23
- assert_ai_prompt: 'AssertAIPrompt',
24
28
  };
25
- class AssertStepOldConverter {
26
- static convert(name, args, actions) {
27
- const v2StepName = exports.oldToV2StepNameMap[name];
28
- if (!v2StepName) {
29
- throw new Error(`Unknown old assertion type: ${name}`);
29
+ class AssertStepOld extends MablStep_1.MablStep {
30
+ constructor(name, args, actions) {
31
+ super(name, args, actions, name);
32
+ this.assertionType = '';
33
+ this.assertAttribute = '';
34
+ this.validate();
35
+ this.setAssertAttribute();
36
+ this.assertionType = this.name;
37
+ this.primaryAction = actions[0];
38
+ this.extractAction = actions[1];
39
+ if (args.length === 1) {
40
+ this.onFailure = args[0].onFailure;
41
+ this.observationScope = args[0].observationScope;
30
42
  }
31
- const newActions = [];
32
- newActions.push(actions[0]);
33
- if (actions[1]) {
34
- newActions.push(actions[1]);
43
+ else if (args.length === 2) {
44
+ this.onFailure = args[1].onFailure;
45
+ this.observationScope = args[1].observationScope;
35
46
  }
36
- let assertionValue;
37
- let assertionArguments = {};
38
- if (args.length > 0) {
39
- const firstArg = args[0];
40
- if (typeof firstArg === 'object' && firstArg !== undefined) {
41
- if ('onFailure' in firstArg || 'observationScope' in firstArg) {
42
- assertionArguments = firstArg;
43
- if (name === 'assert_present' || name === 'assert_not_present') {
44
- assertionValue = undefined;
45
- }
46
- else {
47
- assertionValue = args[1];
48
- }
49
- }
50
- else {
51
- assertionValue = firstArg;
52
- if (args[1] && typeof args[1] === 'object') {
53
- assertionArguments = args[1];
54
- }
55
- }
56
- }
57
- else {
58
- assertionValue = firstArg;
59
- if (args[1] && typeof args[1] === 'object') {
60
- assertionArguments = args[1];
61
- }
62
- }
47
+ }
48
+ validate() {
49
+ if (this.actions.length !== 2 &&
50
+ !(this.actions[0] instanceof FindAction_1.FindAction) &&
51
+ !(this.actions[1] instanceof ExtractAction_1.ExtractAction)) {
52
+ throw new Error('Legacy assert steps should have exactly two sub action: a find and an extract');
63
53
  }
64
- let conditionAction;
65
- if (name === 'assert_present') {
66
- conditionAction = new ConditionAction_1.ConditionAction('evaluate_presence', ['present']);
54
+ }
55
+ setAssertAttribute() {
56
+ this.assertAttribute = this.getActionArgs()[0];
57
+ }
58
+ getStepName() {
59
+ return oldToNewAssertionTypes[this.getAssertionType()];
60
+ }
61
+ getAssertionType() {
62
+ return this.assertionType;
63
+ }
64
+ toStepDescriptor() {
65
+ const formatted = {};
66
+ if (this.assertionType !== 'assert_present' &&
67
+ this.assertionType !== 'assert_not_present') {
68
+ formatted.assertionValue = this.assertAttribute;
67
69
  }
68
- else if (name === 'assert_not_present') {
69
- conditionAction = new ConditionAction_1.ConditionAction('evaluate_presence', [
70
- 'not_present',
71
- ]);
70
+ if (this.extractAction) {
71
+ formatted.extractType =
72
+ ExtractAction_1.ExtractAction.mablscriptToYamlType[this.extractAction.extractionType];
73
+ formatted.attribute = this.extractAction.extractionAttribute;
74
+ }
75
+ const find = this.primaryAction.toDescriptor();
76
+ formatted.findOptions = find.selectorFindOption;
77
+ if ((0, GetCurrentLocationDescriptor_1.isGetCurrentLocationDescriptor)(find) ||
78
+ (0, GetVariableDescriptor_1.isGetVariableDescriptor)(find) ||
79
+ (0, GetViewportDescriptor_1.isGetViewportDescriptor)(find)) {
80
+ formatted.kind = find.kind;
72
81
  }
73
82
  else {
74
- const conditionType = ConditionDescriptor_1.AssertionStepNameToField[v2StepName];
75
- if (!conditionType) {
76
- throw new Error(`Unknown assertion type: ${v2StepName}`);
83
+ switch (find.findType) {
84
+ case domUtil_1.FindType.FIND_COOKIE:
85
+ case domUtil_1.FindType.FIND_EMAIL:
86
+ formatted.findType = FindAction_1.findTypesToFormattedType[find.findType];
87
+ formatted.selector = find.findTarget;
88
+ break;
89
+ case domUtil_1.FindType.FIND_FIRST:
90
+ case domUtil_1.FindType.FIND_LAST:
91
+ case domUtil_1.FindType.FIND_ANY:
92
+ case domUtil_1.FindType.FIND_ALL:
93
+ formatted.findType = FindAction_1.findTypesToFormattedType[find.findType];
94
+ formatted.selector = find.findTarget;
95
+ break;
96
+ case domUtil_1.FindType.FIND_ONE:
97
+ formatted.selector = find.findTarget.selector;
98
+ break;
99
+ default:
100
+ throw new Error(`Error generating step descriptor for ${this.getStepName()}: Unexpected find type ${find.findType}`);
77
101
  }
78
- conditionAction = new ConditionAction_1.ConditionAction('evaluate_condition', [
79
- conditionType,
80
- assertionValue || '',
81
- ]);
82
102
  }
83
- newActions.push(conditionAction);
84
- const descriptor = (0, AssertStep_1.buildAssertStepDescriptor)(v2StepName, [assertionArguments], newActions);
85
- const result = new AssertStep_1.AssertStep(v2StepName, [assertionArguments], newActions, descriptor);
103
+ formatted.assertArguments = {
104
+ onFailure: this.onFailure,
105
+ observationScope: this.observationScope,
106
+ };
107
+ return formatted;
108
+ }
109
+ getFormattedStep(_fullLocatorsOn) {
110
+ const result = {};
111
+ result[this.getStepName()] = { ...this.annotationsAsYml() };
112
+ const formatted = result[this.getStepName()];
113
+ if (this.extractAction) {
114
+ formatted.attribute = this.extractAction.extractionAttribute;
115
+ formatted.extractType =
116
+ ExtractAction_1.ExtractAction.mablscriptToYamlType[this.extractAction.extractionType];
117
+ }
118
+ if (this.assertionType !== 'assert_present' &&
119
+ this.assertionType !== 'assert_not_present') {
120
+ formatted.assertionValue = this.assertAttribute;
121
+ }
122
+ const targetDescriptor = this.primaryAction.toDescriptor();
123
+ if ((0, GetVariableDescriptor_1.isGetVariableDescriptor)(targetDescriptor)) {
124
+ formatted.target = (0, GetVariableDescriptor_1.convertGetVariableDescriptorToYaml)(targetDescriptor);
125
+ }
126
+ else {
127
+ formatted.target = targetDescriptor;
128
+ }
129
+ formatted.assertArguments = {
130
+ onFailure: this.onFailure,
131
+ observationScope: this.observationScope,
132
+ };
133
+ if (this.stepId()) {
134
+ formatted.id = this.stepId();
135
+ }
86
136
  return result;
87
137
  }
138
+ getNewAssertionStep() {
139
+ const yamlified = (0, importer_1.yamlifyTheLoadedSteps)([this]);
140
+ const reloadedSteps = (0, importer_1.loadYamlSteps)(yamlified);
141
+ const result = reloadedSteps[0];
142
+ if (this.stepSourceIndexInFlow !== undefined) {
143
+ result.setStepSourceIndexInFlow(this.stepSourceIndexInFlow);
144
+ }
145
+ this.actions.forEach((_oldAction, actionIndex) => {
146
+ result.actions[actionIndex].setActionSourceIndexInStep(actionIndex);
147
+ });
148
+ if (this.actionSourceIndexInStep !== undefined) {
149
+ result.setActionSourceIndexInStep(this.actionSourceIndexInStep);
150
+ }
151
+ return result;
152
+ }
153
+ static fromYaml(stepName, _stepArgs) {
154
+ return new MablStep_1.MablStep(stepName, [], [], 'assert');
155
+ }
88
156
  }
89
- exports.AssertStepOldConverter = AssertStepOldConverter;
157
+ exports.AssertStepOld = AssertStepOld;
158
+ AssertStepOld.mablScriptStepNames = Object.keys(oldToNewAssertionTypes);
159
+ AssertStepOld.yamlMablScriptNames = [];
@@ -3,16 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AwaitTabStep = void 0;
4
4
  exports.hasCustomFindOptions = hasCustomFindOptions;
5
5
  const domUtil_1 = require("../../domUtil");
6
- const MablAction_1 = require("../MablAction");
7
- const MablStepV2_1 = require("../MablStepV2");
8
- const mablscriptFind_1 = require("../../mablscriptFind");
9
- class AwaitTabStep extends MablStepV2_1.MablStepV2 {
10
- constructor(descriptor) {
11
- super(AwaitTabStep.stepName, descriptor, AwaitTabStep.actionCode);
12
- this.tab = descriptor.tab;
6
+ const MablStep_1 = require("../MablStep");
7
+ class AwaitTabStep extends MablStep_1.MablStep {
8
+ constructor(name, args, actions) {
9
+ super(name, args, actions, 'await_tab');
10
+ this.tab = this.getActionArgs()[0];
13
11
  }
14
12
  getStepName() {
15
- return AwaitTabStep.stepName;
13
+ return 'AwaitTab';
16
14
  }
17
15
  toStepDescriptor() {
18
16
  return {
@@ -21,30 +19,13 @@ class AwaitTabStep extends MablStepV2_1.MablStepV2 {
21
19
  };
22
20
  }
23
21
  static fromYaml(_stepName, stepArgs) {
24
- const stepDescriptor = {
25
- actionCode: AwaitTabStep.actionCode,
26
- tab: stepArgs.tab,
27
- };
28
- const step = new AwaitTabStep(stepDescriptor);
22
+ const step = new AwaitTabStep('await_tab', [stepArgs.tab], []);
29
23
  step.setStepId(stepArgs.id);
30
24
  return step;
31
25
  }
32
- static fromLegacyMablscript(args, _actions) {
33
- const stepDescriptor = {
34
- actionCode: AwaitTabStep.actionCode,
35
- tab: args[0],
36
- };
37
- return new AwaitTabStep(stepDescriptor);
38
- }
39
26
  toMablscript() {
40
27
  return `await_tab(${AwaitTabStep.getMablscriptSelectorFromTabFindAction(this.tab)})`;
41
28
  }
42
- getInputVariables() {
43
- return MablAction_1.MablAction.findUniqueVariableReferencesInValue(this.tab);
44
- }
45
- stepDescription() {
46
- return `Wait for ${(0, mablscriptFind_1.humanizeTabSelector)(this.tab)}`;
47
- }
48
29
  static hasCustomFindOptions(tab) {
49
30
  return Object.keys(tab.configuration?.propertyPreferences ?? {}).length > 0;
50
31
  }
@@ -80,10 +61,8 @@ class AwaitTabStep extends MablStepV2_1.MablStepV2 {
80
61
  }
81
62
  }
82
63
  exports.AwaitTabStep = AwaitTabStep;
83
- AwaitTabStep.stepName = 'AwaitTab';
84
- AwaitTabStep.actionCode = 'await_tab';
85
- AwaitTabStep.mablScriptStepNames = [AwaitTabStep.actionCode];
86
- AwaitTabStep.yamlMablScriptNames = [AwaitTabStep.stepName];
64
+ AwaitTabStep.mablScriptStepNames = ['await_tab'];
65
+ AwaitTabStep.yamlMablScriptNames = ['AwaitTab'];
87
66
  function hasCustomFindOptions(tab) {
88
67
  return AwaitTabStep.hasCustomFindOptions(tab);
89
68
  }
@@ -1,40 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AwaitUploadsStep = void 0;
4
- const MablStepV2_1 = require("../MablStepV2");
5
- class AwaitUploadsStep extends MablStepV2_1.MablStepV2 {
6
- constructor(descriptor) {
7
- super(AwaitUploadsStep.stepName, descriptor, AwaitUploadsStep.actionCode);
4
+ const MablStep_1 = require("../MablStep");
5
+ class AwaitUploadsStep extends MablStep_1.MablStep {
6
+ constructor(name, args, actions) {
7
+ super(name, args, actions, 'await_uploads');
8
8
  }
9
9
  getStepName() {
10
- return AwaitUploadsStep.stepName;
10
+ return 'AwaitUploads';
11
11
  }
12
12
  toStepDescriptor() {
13
13
  return { actionCode: this.actionCode };
14
14
  }
15
15
  static fromYaml(_stepName, stepArgs) {
16
- const stepDescriptor = {
17
- actionCode: AwaitUploadsStep.actionCode,
18
- };
19
- const step = new AwaitUploadsStep(stepDescriptor);
16
+ const step = new AwaitUploadsStep('await_uploads', [], []);
20
17
  step.setStepId(stepArgs.id);
21
18
  return step;
22
19
  }
23
- static fromLegacyMablscript(_args, _actions) {
24
- const stepDescriptor = {
25
- actionCode: AwaitUploadsStep.actionCode,
26
- };
27
- return new AwaitUploadsStep(stepDescriptor);
28
- }
29
20
  toMablscript() {
30
21
  return `await_uploads()`;
31
22
  }
32
- stepDescription() {
33
- return 'Wait for uploads to complete';
34
- }
35
23
  }
36
24
  exports.AwaitUploadsStep = AwaitUploadsStep;
37
- AwaitUploadsStep.stepName = 'AwaitUploads';
38
- AwaitUploadsStep.actionCode = 'await_uploads';
39
- AwaitUploadsStep.mablScriptStepNames = [AwaitUploadsStep.actionCode];
40
- AwaitUploadsStep.yamlMablScriptNames = [AwaitUploadsStep.stepName];
25
+ AwaitUploadsStep.mablScriptStepNames = ['await_uploads'];
26
+ AwaitUploadsStep.yamlMablScriptNames = ['AwaitUploads'];
@@ -1,40 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ClearCookiesStep = void 0;
4
- const MablStepV2_1 = require("../MablStepV2");
5
- class ClearCookiesStep extends MablStepV2_1.MablStepV2 {
6
- constructor(descriptor) {
7
- super(ClearCookiesStep.stepName, descriptor, ClearCookiesStep.actionCode);
4
+ const MablStep_1 = require("../MablStep");
5
+ class ClearCookiesStep extends MablStep_1.MablStep {
6
+ constructor(name, args, actions) {
7
+ super(name, args, actions, 'clear_cookies');
8
8
  }
9
9
  getStepName() {
10
- return ClearCookiesStep.stepName;
10
+ return 'ClearCookies';
11
11
  }
12
12
  toStepDescriptor() {
13
13
  return { actionCode: this.actionCode };
14
14
  }
15
15
  static fromYaml(_stepName, stepArgs) {
16
- const stepDescriptor = {
17
- actionCode: ClearCookiesStep.actionCode,
18
- };
19
- const step = new ClearCookiesStep(stepDescriptor);
16
+ const step = new ClearCookiesStep('clear_cookies', [], []);
20
17
  step.setStepId(stepArgs.id);
21
18
  return step;
22
19
  }
23
- static fromLegacyMablscript(_args, _actions) {
24
- const stepDescriptor = {
25
- actionCode: ClearCookiesStep.actionCode,
26
- };
27
- return new ClearCookiesStep(stepDescriptor);
28
- }
29
20
  toMablscript() {
30
21
  return `clear_cookies()`;
31
22
  }
32
- stepDescription() {
33
- return 'Clear cookies from the current domain';
34
- }
35
23
  }
36
24
  exports.ClearCookiesStep = ClearCookiesStep;
37
- ClearCookiesStep.stepName = 'ClearCookies';
38
- ClearCookiesStep.actionCode = 'clear_cookies';
39
- ClearCookiesStep.mablScriptStepNames = [ClearCookiesStep.actionCode];
40
- ClearCookiesStep.yamlMablScriptNames = [ClearCookiesStep.stepName];
25
+ ClearCookiesStep.mablScriptStepNames = ['clear_cookies'];
26
+ ClearCookiesStep.yamlMablScriptNames = ['ClearCookies'];
@@ -6,68 +6,70 @@ const domUtil_1 = require("../../domUtil");
6
6
  const ActionsUtils_1 = require("./ActionsUtils");
7
7
  const MablStepWithFindAction_1 = require("../MablStepWithFindAction");
8
8
  class ClickAndHoldStep extends MablStepWithFindAction_1.MablStepWithFindAction {
9
- constructor(descriptor, findAction) {
10
- super(ClickAndHoldStep.stepName, descriptor, ClickAndHoldStep.actionCode, findAction);
11
- this.clickArgs = { isHtml5: descriptor.isHtml5 };
9
+ constructor(name, args, actions) {
10
+ super(name, args, actions, 'click_and_hold');
11
+ this.findAction = ActionsUtils_1.ActionsUtils.validateSingleFindAction(this.actions);
12
+ this.clickArgs = this.parseArgs(args) ?? { isHtml5: false };
12
13
  }
13
- static parseArgs(args) {
14
+ parseArgs(args) {
14
15
  if (args.length === 0) {
15
16
  return undefined;
16
17
  }
17
- return {
18
- isHtml5: args[0].isHtml5,
19
- };
18
+ if (args.length !== 1) {
19
+ throw new Error(`Unexpected number of arguments to ${this.getStepName()} step.`);
20
+ }
21
+ if (!isClickAndHoldArgs(args[0])) {
22
+ throw new Error(`Invalid argument passed to ${this.getStepName()} step.`);
23
+ }
24
+ return args[0];
20
25
  }
21
26
  getStepName() {
22
- return ClickAndHoldStep.stepName;
27
+ return 'ClickAndHold';
23
28
  }
24
29
  toStepDescriptor() {
25
- return buildStepDescriptor(this.findAction, this.clickArgs);
26
- }
27
- getInputVariables() {
28
- return this.findAction.getInputVariables();
30
+ const find = this.findAction.toDescriptor();
31
+ switch (find.findType) {
32
+ case domUtil_1.FindType.FIND_FIRST:
33
+ case domUtil_1.FindType.FIND_LAST:
34
+ case domUtil_1.FindType.FIND_ANY:
35
+ case domUtil_1.FindType.FIND_ONE:
36
+ return {
37
+ find,
38
+ isHtml5: this.clickArgs.isHtml5,
39
+ descriptorToActionMap: new Map().set(find, this.findAction),
40
+ actionCode: this.actionCode,
41
+ };
42
+ default:
43
+ throw new Error(`Error generating step descriptor for ${this.getStepName()}: Unexpected find type ${find.findType}`);
44
+ }
29
45
  }
30
- stepDescription() {
31
- const elementDescription = this.humanizeFind();
32
- return `Click and hold ${elementDescription}`;
46
+ getFormattedStep(_fullLocatorsOn) {
47
+ const step = {
48
+ ClickAndHold: {
49
+ ...super.annotationsAsYml(),
50
+ ...this.findAction.toYaml(),
51
+ },
52
+ };
53
+ if (this.stepId()) {
54
+ step.ClickAndHold.id = this.stepId();
55
+ }
56
+ return step;
33
57
  }
34
58
  static fromYaml(_stepName, stepArgs) {
35
- const findAction = FindAction_1.FindAction.findActionFromStepArgs(stepArgs);
36
- const clickArgs = { isHtml5: false };
37
- const stepDescriptor = buildStepDescriptor(findAction, clickArgs);
38
- const step = new ClickAndHoldStep(stepDescriptor, findAction);
59
+ const step = new ClickAndHoldStep('click_and_hold', [], [FindAction_1.FindAction.findActionFromStepArgs(stepArgs)]);
39
60
  step.setStepId(stepArgs.id);
40
61
  return step;
41
62
  }
42
- static fromLegacyMablscript(args, actions) {
43
- const findAction = ActionsUtils_1.ActionsUtils.validateSingleFindAction(actions);
44
- const clickArgs = ClickAndHoldStep.parseArgs(args) ?? { isHtml5: false };
45
- const stepDescriptor = buildStepDescriptor(findAction, clickArgs);
46
- return new ClickAndHoldStep(stepDescriptor, findAction);
47
- }
48
63
  toMablscript() {
49
64
  return `${this.findAction.toMablscript()}.click_and_hold({isHtml5:${this.clickArgs.isHtml5}})`;
50
65
  }
66
+ getInputVariables() {
67
+ return this.findAction.getInputVariables();
68
+ }
51
69
  }
52
70
  exports.ClickAndHoldStep = ClickAndHoldStep;
53
- ClickAndHoldStep.stepName = 'Click and Hold';
54
- ClickAndHoldStep.actionCode = 'click_and_hold';
55
- ClickAndHoldStep.mablScriptStepNames = [ClickAndHoldStep.actionCode];
56
- ClickAndHoldStep.yamlMablScriptNames = [ClickAndHoldStep.stepName];
57
- function buildStepDescriptor(findAction, clickArgs) {
58
- const find = findAction.toDescriptor();
59
- switch (find.findType) {
60
- case domUtil_1.FindType.FIND_FIRST:
61
- case domUtil_1.FindType.FIND_LAST:
62
- case domUtil_1.FindType.FIND_ANY:
63
- case domUtil_1.FindType.FIND_ONE:
64
- return {
65
- find,
66
- descriptorToActionMap: new Map().set(find, findAction),
67
- actionCode: ClickAndHoldStep.actionCode,
68
- isHtml5: clickArgs.isHtml5,
69
- };
70
- default:
71
- throw new Error(`Error generating step descriptor for ${ClickAndHoldStep.stepName}: Unexpected find type ${find.findType}`);
72
- }
71
+ ClickAndHoldStep.mablScriptStepNames = ['click_and_hold'];
72
+ ClickAndHoldStep.yamlMablScriptNames = ['ClickAndHold'];
73
+ function isClickAndHoldArgs(value) {
74
+ return value.isHtml5 !== undefined;
73
75
  }
@@ -6,56 +6,53 @@ const domUtil_1 = require("../../domUtil");
6
6
  const ActionsUtils_1 = require("./ActionsUtils");
7
7
  const MablStepWithFindAction_1 = require("../MablStepWithFindAction");
8
8
  class ClickStep extends MablStepWithFindAction_1.MablStepWithFindAction {
9
- constructor(descriptor, findAction) {
10
- super(ClickStep.stepName, descriptor, ClickStep.actionCode, findAction);
9
+ constructor(name, args, actions) {
10
+ super(name, args, actions, 'click');
11
+ this.findAction = ActionsUtils_1.ActionsUtils.validateSingleFindAction(this.actions);
11
12
  }
12
13
  getStepName() {
13
- return ClickStep.stepName;
14
+ return 'Click';
14
15
  }
15
16
  toStepDescriptor() {
16
- return buildStepDescriptor(this.findAction);
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
+ Click: {
35
+ ...super.annotationsAsYml(),
36
+ ...this.findAction.toYaml(),
37
+ },
38
+ };
39
+ if (this.stepId()) {
40
+ step.Click.id = this.stepId();
41
+ }
42
+ return step;
17
43
  }
18
44
  static fromYaml(_stepName, stepArgs) {
19
- const findAction = FindAction_1.FindAction.findActionFromStepArgs(stepArgs);
20
- const stepDescriptor = buildStepDescriptor(findAction);
21
- const step = new ClickStep(stepDescriptor, findAction);
45
+ const step = new ClickStep('click', [], [FindAction_1.FindAction.findActionFromStepArgs(stepArgs)]);
22
46
  step.setStepId(stepArgs.id);
23
47
  return step;
24
48
  }
25
- static fromLegacyMablscript(_args, actions) {
26
- const findAction = ActionsUtils_1.ActionsUtils.validateSingleFindAction(actions);
27
- const stepDescriptor = buildStepDescriptor(findAction);
28
- return new ClickStep(stepDescriptor, findAction);
29
- }
30
49
  toMablscript() {
31
50
  return `${this.findAction.toMablscript()}.click()`;
32
51
  }
33
52
  getInputVariables() {
34
53
  return this.findAction.getInputVariables();
35
54
  }
36
- stepDescription() {
37
- const elementDescription = this.humanizeFind();
38
- return `Click on ${elementDescription}`;
39
- }
40
55
  }
41
56
  exports.ClickStep = ClickStep;
42
- ClickStep.stepName = 'Click';
43
- ClickStep.actionCode = 'click';
44
- ClickStep.mablScriptStepNames = [ClickStep.actionCode];
45
- ClickStep.yamlMablScriptNames = [ClickStep.stepName];
46
- function buildStepDescriptor(findAction) {
47
- const find = findAction.toDescriptor();
48
- switch (find.findType) {
49
- case domUtil_1.FindType.FIND_FIRST:
50
- case domUtil_1.FindType.FIND_LAST:
51
- case domUtil_1.FindType.FIND_ANY:
52
- case domUtil_1.FindType.FIND_ONE:
53
- return {
54
- find,
55
- descriptorToActionMap: new Map().set(find, findAction),
56
- actionCode: ClickStep.actionCode,
57
- };
58
- default:
59
- throw new Error(`Error generating step descriptor for ${ClickStep.stepName}: Unexpected find type ${find.findType}`);
60
- }
61
- }
57
+ ClickStep.mablScriptStepNames = ['click'];
58
+ ClickStep.yamlMablScriptNames = ['Click'];