@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
@@ -9,188 +9,161 @@ const FindAction_1 = require("../actions/FindAction");
9
9
  const GenerateEmailAddressAction_1 = require("../actions/GenerateEmailAddressAction");
10
10
  const GenerateRandomStringAction_1 = require("../actions/GenerateRandomStringAction");
11
11
  const JavaScriptAction_1 = require("../actions/JavaScriptAction");
12
- const MablStep_1 = require("../MablStep");
12
+ const MablStepV2_1 = require("../MablStepV2");
13
13
  const CreateVariableStepDescriptor_1 = require("../types/CreateVariableStepDescriptor");
14
- class CreateVariableStep extends MablStep_1.MablStep {
15
- constructor(name, args, actions) {
16
- super(name, args, actions, 'as');
17
- this.variableName = this.getActionArgs()[0];
18
- this.generationType = this.calculateGenerationType();
14
+ class CreateVariableStep extends MablStepV2_1.MablStepV2 {
15
+ constructor(descriptor) {
16
+ super(CreateVariableStep.stepName, descriptor, CreateVariableStep.actionCode);
17
+ this.variableName = descriptor.name;
18
+ this.generationType = descriptor.generator.type;
19
+ this.actions = this.buildActions(descriptor);
19
20
  }
20
21
  getStepName() {
21
22
  return CreateVariableStep.stepName;
22
23
  }
23
- calculateGenerationType() {
24
- if (this.actions.length === 2 && this.actions[0] instanceof FindAction_1.FindAction) {
25
- if (this.actions[0].findDescriptor.findType === domUtil_1.FindType.FIND_COOKIE) {
26
- return CreateVariableStepDescriptor_1.VariableGenerator.COOKIE_ATTRIBUTE;
27
- }
28
- if (this.actions[1] instanceof ExtractAction_1.ExtractAction) {
29
- return CreateVariableStepDescriptor_1.VariableGenerator.ATTRIBUTE;
30
- }
31
- else if (this.actions[1] instanceof CountAction_1.CountAction) {
32
- return CreateVariableStepDescriptor_1.VariableGenerator.ELEMENT_COUNT;
33
- }
34
- }
35
- else if (this.actions.length === 1 &&
36
- this.actions[0] instanceof GenerateEmailAddressAction_1.GenerateEmailAddressAction) {
37
- return CreateVariableStepDescriptor_1.VariableGenerator.EMAIL;
38
- }
39
- else if (this.actions.length === 1 &&
40
- this.actions[0] instanceof JavaScriptAction_1.JavaScriptAction) {
41
- return CreateVariableStepDescriptor_1.VariableGenerator.JAVASCRIPT;
42
- }
43
- else if (this.actions.length === 1 &&
44
- this.actions[0] instanceof GenerateRandomStringAction_1.GenerateRandomStringAction) {
45
- return CreateVariableStepDescriptor_1.VariableGenerator.PATTERN;
46
- }
47
- throw new Error('Unsupported variable generation type');
48
- }
49
24
  toStepDescriptor() {
50
- let step;
51
- switch (this.generationType) {
52
- case CreateVariableStepDescriptor_1.VariableGenerator.COOKIE_ATTRIBUTE:
53
- const cookieFindAction = this.actions[0];
54
- const cookieFind = cookieFindAction.toDescriptor();
55
- step = {
56
- name: this.variableName,
57
- generator: {
58
- type: CreateVariableStepDescriptor_1.VariableGenerator.COOKIE_ATTRIBUTE,
59
- cookieSelector: cookieFind.findTarget,
60
- attribute: this.actions[1].extractionAttribute,
61
- },
62
- find: cookieFind,
63
- descriptorToActionMap: new Map().set(cookieFind, cookieFindAction),
64
- actionCode: this.actionCode,
65
- };
66
- break;
25
+ return CreateVariableStep.buildStepDescriptor(this.variableName, this.generationType, this.actions);
26
+ }
27
+ static buildStepDescriptor(variableName, generationType, actions) {
28
+ switch (generationType) {
67
29
  case CreateVariableStepDescriptor_1.VariableGenerator.ATTRIBUTE:
68
- const findAction = this.actions[0];
30
+ const findAction = actions[0];
31
+ const extractAction = actions[1];
69
32
  const find = findAction.toDescriptor();
70
- step = {
71
- name: this.variableName,
33
+ return {
34
+ name: variableName,
72
35
  generator: {
73
36
  type: CreateVariableStepDescriptor_1.VariableGenerator.ATTRIBUTE,
74
- attribute: this.actions[1].extractionAttribute,
37
+ attribute: extractAction.extractionAttribute,
75
38
  find,
76
39
  },
77
40
  find,
78
- descriptorToActionMap: new Map().set(find, findAction),
79
- actionCode: this.actionCode,
41
+ descriptorToActionMap: new Map([[find, findAction]]),
42
+ actionCode: CreateVariableStep.actionCode,
43
+ };
44
+ case CreateVariableStepDescriptor_1.VariableGenerator.ELEMENT_COUNT:
45
+ const countFindAction = actions[0];
46
+ const countFind = countFindAction.toDescriptor();
47
+ return {
48
+ find: countFind,
49
+ name: variableName,
50
+ generator: {
51
+ type: CreateVariableStepDescriptor_1.VariableGenerator.ELEMENT_COUNT,
52
+ find: countFind,
53
+ },
54
+ descriptorToActionMap: new Map([[countFind, countFindAction]]),
55
+ actionCode: CreateVariableStep.actionCode,
80
56
  };
81
- break;
82
57
  case CreateVariableStepDescriptor_1.VariableGenerator.EMAIL:
83
- step = {
84
- name: this.variableName,
58
+ return {
59
+ name: variableName,
85
60
  generator: { type: CreateVariableStepDescriptor_1.VariableGenerator.EMAIL },
86
- actionCode: this.actionCode,
61
+ actionCode: CreateVariableStep.actionCode,
87
62
  };
88
- break;
89
63
  case CreateVariableStepDescriptor_1.VariableGenerator.JAVASCRIPT:
90
- step = {
91
- name: this.variableName,
64
+ const jsAction = actions[0];
65
+ return {
66
+ name: variableName,
92
67
  generator: {
93
68
  type: CreateVariableStepDescriptor_1.VariableGenerator.JAVASCRIPT,
94
- javaScript: this.actions[0].javaScript,
69
+ javaScript: jsAction.toDescriptor().javaScript,
95
70
  },
96
- actionCode: this.actionCode,
71
+ actionCode: CreateVariableStep.actionCode,
97
72
  };
98
- break;
99
73
  case CreateVariableStepDescriptor_1.VariableGenerator.PATTERN:
100
- step = {
101
- name: this.variableName,
74
+ const patternAction = actions[0];
75
+ return {
76
+ name: variableName,
102
77
  generator: {
103
78
  type: CreateVariableStepDescriptor_1.VariableGenerator.PATTERN,
104
- pattern: this.actions[0]
105
- .generateString,
79
+ pattern: patternAction.generateString,
106
80
  },
107
- actionCode: this.actionCode,
81
+ actionCode: CreateVariableStep.actionCode,
108
82
  };
109
- break;
110
- case CreateVariableStepDescriptor_1.VariableGenerator.ELEMENT_COUNT:
111
- const countFindAction = this.actions[0];
112
- const countFind = countFindAction.toDescriptor();
113
- step = {
114
- find: countFind,
115
- name: this.variableName,
83
+ case CreateVariableStepDescriptor_1.VariableGenerator.COOKIE_ATTRIBUTE:
84
+ const cookieFindAction = actions[0];
85
+ const cookieExtractAction = actions[1];
86
+ const cookieFind = cookieFindAction.toDescriptor();
87
+ return {
88
+ name: variableName,
116
89
  generator: {
117
- type: CreateVariableStepDescriptor_1.VariableGenerator.ELEMENT_COUNT,
118
- find: countFind,
90
+ type: CreateVariableStepDescriptor_1.VariableGenerator.COOKIE_ATTRIBUTE,
91
+ cookieSelector: cookieFind.findTarget,
92
+ attribute: cookieExtractAction.extractionAttribute,
119
93
  },
120
- descriptorToActionMap: new Map().set(countFind, countFindAction),
121
- actionCode: this.actionCode,
94
+ find: cookieFind,
95
+ descriptorToActionMap: new Map([[cookieFind, cookieFindAction]]),
96
+ actionCode: CreateVariableStep.actionCode,
122
97
  };
123
- break;
98
+ default:
99
+ throw new Error(`Unsupported variable generation type: ${generationType}`);
124
100
  }
125
- return step;
126
101
  }
127
- getFormattedStep() {
128
- const step = this.toStepDescriptor();
129
- const stepName = this.getStepName();
130
- const formatted = {
131
- [stepName]: {},
132
- };
133
- if (this.annotationsOnStep()) {
134
- formatted[stepName].annotation = this.annotation;
135
- }
136
- if (this.description) {
137
- formatted[stepName].description = this.description;
138
- }
139
- switch (step.generator.type) {
102
+ buildActions(descriptor) {
103
+ const actions = [];
104
+ switch (descriptor.generator.type) {
105
+ case CreateVariableStepDescriptor_1.VariableGenerator.ATTRIBUTE:
106
+ if ('find' in descriptor) {
107
+ const attrGenerator = descriptor.generator;
108
+ actions.push(FindAction_1.FindAction.findActionFromStepArgs(descriptor));
109
+ actions.push(new ExtractAction_1.ExtractAction('extract_attribute', [attrGenerator.attribute]));
110
+ }
111
+ break;
140
112
  case CreateVariableStepDescriptor_1.VariableGenerator.ELEMENT_COUNT:
141
- formatted[stepName] = {
142
- ...formatted[stepName],
143
- generator: step.generator,
144
- name: this.variableName,
145
- selector: step.generator.find.findTarget,
146
- };
113
+ if ('find' in descriptor) {
114
+ const findDescriptor = descriptor.find;
115
+ actions.push(new FindAction_1.FindAction('find_all', [
116
+ findDescriptor.findTarget,
117
+ findDescriptor.foundElementSelectors,
118
+ findDescriptor.findOptions,
119
+ ]));
120
+ actions.push(new CountAction_1.CountAction('count', []));
121
+ }
147
122
  break;
148
- case CreateVariableStepDescriptor_1.VariableGenerator.ATTRIBUTE:
149
- formatted[stepName] = {
150
- ...formatted[stepName],
151
- generator: step.generator,
152
- name: this.variableName,
153
- selector: step.generator.find.findTarget.selector,
154
- selectorAncestors: (step.generator.find.findTarget.auxiliaryDescriptors ?? []).map((descriptor) => descriptor.selector),
155
- };
123
+ case CreateVariableStepDescriptor_1.VariableGenerator.EMAIL:
124
+ actions.push(new GenerateEmailAddressAction_1.GenerateEmailAddressAction('generate_email_address', []));
156
125
  break;
157
126
  case CreateVariableStepDescriptor_1.VariableGenerator.JAVASCRIPT:
158
- formatted[stepName] = {
159
- ...formatted[stepName],
160
- generator: {
161
- type: CreateVariableStepDescriptor_1.VariableGenerator.JAVASCRIPT,
162
- javaScript: this.actions[0].toYaml(),
163
- },
164
- name: this.variableName,
165
- };
127
+ const jsGenerator = descriptor.generator;
128
+ actions.push(JavaScriptAction_1.JavaScriptAction.fromDescriptor({
129
+ javaScript: jsGenerator.javaScript,
130
+ }));
131
+ break;
132
+ case CreateVariableStepDescriptor_1.VariableGenerator.PATTERN:
133
+ const patternGenerator = descriptor.generator;
134
+ actions.push(new GenerateRandomStringAction_1.GenerateRandomStringAction('generate_random_string', [
135
+ patternGenerator.pattern,
136
+ ]));
137
+ break;
138
+ case CreateVariableStepDescriptor_1.VariableGenerator.COOKIE_ATTRIBUTE:
139
+ if ('find' in descriptor) {
140
+ const cookieGenerator = descriptor.generator;
141
+ actions.push(new FindAction_1.FindAction('find_cookie', [cookieGenerator.cookieSelector]));
142
+ actions.push(new ExtractAction_1.ExtractAction('extract_attribute', [cookieGenerator.attribute]));
143
+ }
166
144
  break;
167
145
  default:
168
- formatted[stepName] = {
169
- ...formatted[stepName],
170
- generator: step.generator,
171
- name: this.variableName,
172
- };
173
- }
174
- if (this.stepId()) {
175
- formatted[stepName].id = this.stepId();
146
+ throw new Error(`Unsupported variable generation type: ${descriptor.generator.type}`);
176
147
  }
177
- return formatted;
148
+ return actions;
178
149
  }
179
150
  static fromYaml(_stepName, stepArgs) {
180
151
  const variableName = stepArgs.name;
181
- const generator = stepArgs.generator;
152
+ const generator = stepArgs.generator ?? {};
182
153
  const generationType = generator.type;
183
154
  const actions = [];
184
155
  switch (generationType) {
185
156
  case CreateVariableStepDescriptor_1.VariableGenerator.ATTRIBUTE:
186
- actions.push(FindAction_1.FindAction.findActionFromStepArgs(stepArgs));
157
+ const findAction = FindAction_1.FindAction.findActionFromStepArgs(stepArgs);
158
+ actions.push(findAction);
187
159
  const extractArgs = generator.metadata
188
160
  ? [generator.attribute, generator.metadata]
189
161
  : [generator.attribute];
190
162
  actions.push(new ExtractAction_1.ExtractAction('extract_attribute', extractArgs));
191
163
  break;
192
164
  case CreateVariableStepDescriptor_1.VariableGenerator.ELEMENT_COUNT:
193
- actions.push(FindAction_1.FindAction.findActionFromStepArgs(stepArgs, domUtil_1.FindType.FIND_ALL));
165
+ const countFindAction = FindAction_1.FindAction.findActionFromStepArgs(stepArgs, domUtil_1.FindType.FIND_ALL);
166
+ actions.push(countFindAction);
194
167
  actions.push(new CountAction_1.CountAction('count', []));
195
168
  break;
196
169
  case CreateVariableStepDescriptor_1.VariableGenerator.EMAIL:
@@ -205,29 +178,88 @@ class CreateVariableStep extends MablStep_1.MablStep {
205
178
  ]));
206
179
  break;
207
180
  case CreateVariableStepDescriptor_1.VariableGenerator.COOKIE_ATTRIBUTE:
208
- actions.push(new FindAction_1.FindAction('find_cookie', [generator.cookieSelector]));
209
- const extractCookieArgs = [generator.attribute];
210
- actions.push(new ExtractAction_1.ExtractAction('extract_attribute', extractCookieArgs));
181
+ const cookieFindAction = new FindAction_1.FindAction('find_cookie', [
182
+ generator.cookieSelector,
183
+ ]);
184
+ actions.push(cookieFindAction);
185
+ actions.push(new ExtractAction_1.ExtractAction('extract_attribute', [generator.attribute]));
211
186
  break;
187
+ default:
188
+ throw new Error(`Unsupported variable generation type: ${generationType}`);
212
189
  }
213
- const step = new CreateVariableStep('as', [variableName], actions);
190
+ const stepDescriptor = CreateVariableStep.buildStepDescriptor(variableName, generationType, actions);
191
+ const step = new CreateVariableStep(stepDescriptor);
214
192
  step.setStepId(stepArgs.id);
215
193
  return step;
216
194
  }
195
+ static fromLegacyMablscript(args, actions) {
196
+ const variableName = args[0];
197
+ const generationType = CreateVariableStep.calculateGenerationType(actions);
198
+ const stepDescriptor = CreateVariableStep.buildStepDescriptor(variableName, generationType, actions);
199
+ const step = new CreateVariableStep(stepDescriptor);
200
+ return step;
201
+ }
202
+ static calculateGenerationType(actions) {
203
+ if (actions.length === 2 && actions[0] instanceof FindAction_1.FindAction) {
204
+ if (actions[0].findDescriptor.findType === domUtil_1.FindType.FIND_COOKIE) {
205
+ return CreateVariableStepDescriptor_1.VariableGenerator.COOKIE_ATTRIBUTE;
206
+ }
207
+ if (actions[1] instanceof ExtractAction_1.ExtractAction) {
208
+ return CreateVariableStepDescriptor_1.VariableGenerator.ATTRIBUTE;
209
+ }
210
+ else if (actions[1] instanceof CountAction_1.CountAction) {
211
+ return CreateVariableStepDescriptor_1.VariableGenerator.ELEMENT_COUNT;
212
+ }
213
+ }
214
+ else if (actions.length === 1 &&
215
+ actions[0] instanceof GenerateEmailAddressAction_1.GenerateEmailAddressAction) {
216
+ return CreateVariableStepDescriptor_1.VariableGenerator.EMAIL;
217
+ }
218
+ else if (actions.length === 1 && actions[0] instanceof JavaScriptAction_1.JavaScriptAction) {
219
+ return CreateVariableStepDescriptor_1.VariableGenerator.JAVASCRIPT;
220
+ }
221
+ else if (actions.length === 1 &&
222
+ actions[0] instanceof GenerateRandomStringAction_1.GenerateRandomStringAction) {
223
+ return CreateVariableStepDescriptor_1.VariableGenerator.PATTERN;
224
+ }
225
+ throw new Error('Unsupported variable generation type');
226
+ }
217
227
  toMablscript() {
218
228
  return `${this.actions.reduce((mablscript, action) => `${mablscript}${action.toMablscript()}.`, '')}as("${this.variableName}")`;
219
229
  }
220
230
  getInputVariables() {
221
- return this.actions[0].getInputVariables();
231
+ return this.actions.length > 0 ? this.actions[0].getInputVariables() : [];
222
232
  }
223
233
  getOutputVariables() {
224
234
  return [this.variableName];
225
235
  }
236
+ stepDescription() {
237
+ switch (this.generationType) {
238
+ case CreateVariableStepDescriptor_1.VariableGenerator.EMAIL:
239
+ return `Generate email address for variable "${this.variableName}"`;
240
+ case CreateVariableStepDescriptor_1.VariableGenerator.JAVASCRIPT:
241
+ return `Execute JavaScript to create variable "${this.variableName}"`;
242
+ case CreateVariableStepDescriptor_1.VariableGenerator.PATTERN:
243
+ return `Generate random string for variable "${this.variableName}"`;
244
+ case CreateVariableStepDescriptor_1.VariableGenerator.ATTRIBUTE:
245
+ return `Extract attribute value to variable "${this.variableName}"`;
246
+ case CreateVariableStepDescriptor_1.VariableGenerator.COOKIE_ATTRIBUTE:
247
+ return `Extract cookie attribute to variable "${this.variableName}"`;
248
+ case CreateVariableStepDescriptor_1.VariableGenerator.ELEMENT_COUNT:
249
+ return `Count elements and store in variable "${this.variableName}"`;
250
+ default:
251
+ return `Create variable "${this.variableName}"`;
252
+ }
253
+ }
226
254
  }
227
255
  exports.CreateVariableStep = CreateVariableStep;
228
256
  CreateVariableStep.stepName = 'CreateVariable';
229
- CreateVariableStep.mablScriptStepNames = ['as'];
230
- CreateVariableStep.yamlMablScriptNames = ['CreateVariable', 'GenerateEmailAddress'];
257
+ CreateVariableStep.actionCode = 'as';
258
+ CreateVariableStep.mablScriptStepNames = [CreateVariableStep.actionCode];
259
+ CreateVariableStep.yamlMablScriptNames = [
260
+ CreateVariableStep.stepName,
261
+ 'GenerateEmailAddress',
262
+ ];
231
263
  function isCreateVariableStep(value) {
232
264
  return (value?.getStepName &&
233
265
  value.getStepName() === CreateVariableStep.stepName &&
@@ -4,19 +4,31 @@ exports.DatabaseQueryVariableSource = exports.DatabaseQueryStep = void 0;
4
4
  exports.isDatabaseQueryStep = isDatabaseQueryStep;
5
5
  const AbstractAssertionsAndVariablesStep_1 = require("./AbstractAssertionsAndVariablesStep");
6
6
  class DatabaseQueryStep extends AbstractAssertionsAndVariablesStep_1.AbstractAssertionsAndVariablesStep {
7
- constructor(name, args, actions) {
8
- super(name, args, actions, DatabaseQueryStep.mablScriptStepNames[0], DatabaseQueryStep.stepName, args[0]);
7
+ constructor(descriptor) {
8
+ super(DatabaseQueryStep.stepName, descriptor, DatabaseQueryStep.actionCode);
9
9
  }
10
10
  static fromYaml(_stepName, stepArgs) {
11
11
  const formatted = stepArgs;
12
- const step = new DatabaseQueryStep(DatabaseQueryStep.stepName, [formatted], []);
12
+ const step = new DatabaseQueryStep(formatted);
13
13
  step.setStepId(stepArgs.id);
14
14
  return step;
15
15
  }
16
+ static fromLegacyMablscript(args, _actions) {
17
+ if (args.length !== 1) {
18
+ throw new Error(`DatabaseQueryStep fromLegacyMablscript expects 1 argument, got ${args.length}`);
19
+ }
20
+ const step = new DatabaseQueryStep(args[0]);
21
+ step.actions = _actions;
22
+ return step;
23
+ }
24
+ stepDescription() {
25
+ return `Database query execution`;
26
+ }
16
27
  }
17
28
  exports.DatabaseQueryStep = DatabaseQueryStep;
18
29
  DatabaseQueryStep.stepName = 'DatabaseQuery';
19
- DatabaseQueryStep.mablScriptStepNames = ['database_query'];
30
+ DatabaseQueryStep.actionCode = 'database_query';
31
+ DatabaseQueryStep.mablScriptStepNames = [DatabaseQueryStep.actionCode];
20
32
  DatabaseQueryStep.yamlMablScriptNames = [DatabaseQueryStep.stepName];
21
33
  var DatabaseQueryVariableSource;
22
34
  (function (DatabaseQueryVariableSource) {
@@ -3,62 +3,61 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DoubleClickStep = void 0;
4
4
  const FindAction_1 = require("../actions/FindAction");
5
5
  const domUtil_1 = require("../../domUtil");
6
+ const ActionsUtils_1 = require("./ActionsUtils");
6
7
  const MablStepWithFindAction_1 = require("../MablStepWithFindAction");
7
8
  class DoubleClickStep extends MablStepWithFindAction_1.MablStepWithFindAction {
8
- constructor(name, args, actions) {
9
- super(name, args, actions, 'double_click');
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)) {
15
- throw new Error('Double click steps should have exactly on sub action and it should be a find');
16
- }
9
+ constructor(descriptor, findAction) {
10
+ super(DoubleClickStep.stepName, descriptor, DoubleClickStep.actionCode, findAction);
17
11
  }
18
12
  getStepName() {
19
- return 'DoubleClick';
13
+ return DoubleClickStep.stepName;
20
14
  }
21
15
  toStepDescriptor() {
22
- const find = this.findAction.toDescriptor();
23
- switch (find.findType) {
24
- case domUtil_1.FindType.FIND_FIRST:
25
- case domUtil_1.FindType.FIND_LAST:
26
- case domUtil_1.FindType.FIND_ANY:
27
- case domUtil_1.FindType.FIND_ALL:
28
- case domUtil_1.FindType.FIND_ONE:
29
- return {
30
- find,
31
- descriptorToActionMap: new Map().set(find, this.findAction),
32
- actionCode: this.actionCode,
33
- };
34
- default:
35
- throw new Error(`Error generating step descriptor for ${this.getStepName()}: Unexpected find type ${find.findType}`);
36
- }
37
- }
38
- getFormattedStep(_fullLocatorsOn) {
39
- const step = {
40
- DoubleClick: {
41
- ...super.annotationsAsYml(),
42
- ...this.findAction.toYaml(),
43
- },
44
- };
45
- if (this.stepId()) {
46
- step.DoubleClick.id = this.stepId();
47
- }
48
- return step;
16
+ return buildStepDescriptor(this.findAction);
49
17
  }
50
18
  static fromYaml(_stepName, stepArgs) {
51
- const step = new DoubleClickStep('double_click', [], [FindAction_1.FindAction.findActionFromStepArgs(stepArgs)]);
19
+ const findAction = FindAction_1.FindAction.findActionFromStepArgs(stepArgs);
20
+ const stepDescriptor = buildStepDescriptor(findAction);
21
+ const step = new DoubleClickStep(stepDescriptor, findAction);
52
22
  step.setStepId(stepArgs.id);
53
23
  return step;
54
24
  }
25
+ static fromLegacyMablscript(_args, actions) {
26
+ const findAction = ActionsUtils_1.ActionsUtils.validateSingleFindAction(actions);
27
+ const stepDescriptor = buildStepDescriptor(findAction);
28
+ const step = new DoubleClickStep(stepDescriptor, findAction);
29
+ step.actions = actions;
30
+ return step;
31
+ }
55
32
  toMablscript() {
56
33
  return `${this.findAction.toMablscript()}.double_click()`;
57
34
  }
58
35
  getInputVariables() {
59
36
  return this.findAction.getInputVariables();
60
37
  }
38
+ stepDescription() {
39
+ const elementDescription = this.humanizeFind();
40
+ return `Double click on ${elementDescription}`;
41
+ }
61
42
  }
62
43
  exports.DoubleClickStep = DoubleClickStep;
63
- DoubleClickStep.mablScriptStepNames = ['double_click'];
64
- DoubleClickStep.yamlMablScriptNames = ['DoubleClick'];
44
+ DoubleClickStep.stepName = 'DoubleClick';
45
+ DoubleClickStep.actionCode = 'double_click';
46
+ DoubleClickStep.mablScriptStepNames = [DoubleClickStep.actionCode];
47
+ DoubleClickStep.yamlMablScriptNames = [DoubleClickStep.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: DoubleClickStep.actionCode,
59
+ };
60
+ default:
61
+ throw new Error(`Error generating step descriptor for ${DoubleClickStep.stepName}: Unexpected find type ${find.findType}`);
62
+ }
63
+ }