@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
@@ -103,7 +103,6 @@ const ActionTypes = [
103
103
  const StepTypes = [
104
104
  AccessibilityCheck_1.AccessibilityCheckStep,
105
105
  AssertStep_1.AssertStep,
106
- AssertStepOld_1.AssertStepOld,
107
106
  AwaitTabStep_1.AwaitTabStep,
108
107
  AwaitUploadsStep_1.AwaitUploadsStep,
109
108
  ClearCookiesStep_1.ClearCookiesStep,
@@ -156,15 +155,6 @@ const MobileStepTypes = [
156
155
  PushFileStep_1.PushFileStep,
157
156
  UninstallAppStep_1.UninstallAppStep,
158
157
  ];
159
- const SyntheticActionCodes = [
160
- 'autologin',
161
- 'capture_application_state',
162
- 'root_page',
163
- 'verify_url',
164
- 'validate_links',
165
- 'validate_page',
166
- ];
167
- const ACCESSIBILITY_CHECK_ACTION_NAME = 'accessibility_check';
168
158
  function parseMablScript(mablscript) {
169
159
  const ast = (0, esprima_1.parseScript)(mablscript, { loc: true });
170
160
  const stepStack = {};
@@ -198,16 +188,24 @@ function parseMablScript(mablscript) {
198
188
  }
199
189
  const rawMablscriptToObjectsStepMap = {};
200
190
  StepTypes.forEach((step) => {
201
- step.mablScriptStepNames.forEach((name) => (rawMablscriptToObjectsStepMap[name] = step));
191
+ step.mablScriptStepNames
192
+ .concat(step.yamlMablScriptNames)
193
+ .forEach((name) => (rawMablscriptToObjectsStepMap[name] = step));
202
194
  });
203
195
  const rawMablscriptToObjectsActionsMap = {};
204
196
  ActionTypes.forEach((step) => {
205
197
  step.mablScriptStepNames.forEach((name) => (rawMablscriptToObjectsActionsMap[name] = step));
206
198
  });
199
+ const legacyMablscriptStepGeneratorMap = {};
200
+ StepTypes.forEach((step) => {
201
+ step.mablScriptStepNames.forEach((name) => {
202
+ legacyMablscriptStepGeneratorMap[name] = step
203
+ .fromLegacyMablscript;
204
+ });
205
+ });
207
206
  function loadMablScriptIntoSteps(parsedMablscript) {
208
207
  return Object.entries(parsedMablscript).map(([stepIndexString, [...parsed]]) => {
209
208
  const lastAction = parsed.pop();
210
- const stepType = rawMablscriptToObjectsStepMap[lastAction.name];
211
209
  const actions = parsed.map((parsedAction, actionIndex) => {
212
210
  const actionType = rawMablscriptToObjectsActionsMap[parsedAction.name];
213
211
  const action = actionType
@@ -216,13 +214,33 @@ function loadMablScriptIntoSteps(parsedMablscript) {
216
214
  action.setActionSourceIndexInStep(actionIndex);
217
215
  return action;
218
216
  });
219
- let step = stepType
220
- ? new stepType(lastAction.name, lastAction.arguments, actions)
221
- : new MablStep_1.MablStep(lastAction.name, lastAction.arguments, actions, lastAction.name);
222
- if (step instanceof AssertStepOld_1.AssertStepOld) {
223
- step = step.getNewAssertionStep();
217
+ let step;
218
+ let wasAssertStepOld = false;
219
+ if (lastAction.name.startsWith('assert_') &&
220
+ lastAction.name !== 'assert_download') {
221
+ step = AssertStepOld_1.AssertStepOldConverter.convert(lastAction.name, lastAction.arguments, actions);
222
+ wasAssertStepOld = true;
223
+ }
224
+ else if (lastAction.name === 'assert') {
225
+ step = new AssertStep_1.AssertStep(lastAction.name, lastAction.arguments, actions);
226
+ }
227
+ else {
228
+ const stepGenerator = legacyMablscriptStepGeneratorMap[lastAction.name];
229
+ step = stepGenerator
230
+ ? stepGenerator(lastAction.arguments, actions)
231
+ : new MablStep_1.MablStep(lastAction.name, lastAction.arguments, actions, lastAction.name);
232
+ }
233
+ if ((0, MablStepV2_1.isMablStepV2)(step)) {
234
+ if (wasAssertStepOld) {
235
+ step.setActionSourceIndexInStep(actions.length);
236
+ }
237
+ else {
238
+ step.setActionSourceIndexInStep(step.actions.length);
239
+ }
240
+ }
241
+ else {
242
+ step.setActionSourceIndexInStep(actions.length);
224
243
  }
225
- step.setActionSourceIndexInStep(actions.length);
226
244
  step.setStepSourceIndexInFlow(parseInt(stepIndexString));
227
245
  return step;
228
246
  });
@@ -233,7 +251,9 @@ function yamlifyTheLoadedSteps(translatedSteps, fullLocatorsOn = true) {
233
251
  }
234
252
  const yamlMablscriptToObjectsStepV1Map = {};
235
253
  StepTypes.forEach((step) => {
236
- step.yamlMablScriptNames.forEach((name) => (yamlMablscriptToObjectsStepV1Map[name] = step.fromYaml));
254
+ step.yamlMablScriptNames.forEach((name) => {
255
+ yamlMablscriptToObjectsStepV1Map[name] = step.fromYaml;
256
+ });
237
257
  });
238
258
  const yamlMablscriptToObjectsMobileStepMap = {};
239
259
  MobileStepTypes.forEach((step) => {
@@ -245,41 +265,38 @@ function loadYamlSteps(yamlSteps, isMobile) {
245
265
  }
246
266
  function interpretStepsFromObjectsInFlow(flow, isMobile) {
247
267
  const steps = interpretStepsFromObjects(flow.json_steps?.steps, isMobile);
248
- let flowDescriptions = [];
249
- if (flow.script_description) {
250
- flowDescriptions = flow.script_description?.split('\n') ?? [];
251
- }
252
- steps.forEach((step, index) => {
253
- step.setDescription(flowDescriptions[index]);
254
- if (flow?.step_annotations?.[index]) {
255
- step.setAnnotation(flow.step_annotations[index]);
256
- }
257
- });
268
+ applyStepDescriptionsAndAnnotations(steps, flow);
258
269
  return steps;
259
270
  }
271
+ function applyStepDescriptionsAndAnnotations(steps, flow) {
272
+ if (flow.script_description || flow.step_annotations) {
273
+ const flowDescriptions = flow.script_description?.split('\n') ?? [];
274
+ steps.forEach((step, index) => {
275
+ if (flowDescriptions[index]) {
276
+ step.setDescription(flowDescriptions[index]);
277
+ }
278
+ const stepAnnotation = flow?.step_annotations?.[index];
279
+ if (stepAnnotation) {
280
+ step.setAnnotation(stepAnnotation);
281
+ }
282
+ });
283
+ }
284
+ }
260
285
  function interpretStepsFromObjects(steps, isMobile) {
261
- let cumulativeIndex = 0;
262
286
  return steps.map((stepObject, index) => {
263
287
  const stepName = Object.keys(stepObject)[0];
264
288
  const stepArgs = stepObject[stepName];
265
289
  const isStepDisabled = stepObject[stepName].disabled;
266
290
  const step = stepFromObjectInfo(stepName, stepArgs, isMobile ?? false);
267
291
  step.setStepSourceIndexInFlow(index);
268
- const actionCount = step.actions.length;
269
292
  step.actions?.forEach((action, actionIndex) => {
270
- if ((0, MablStepV2_1.isMablStepV2)(step) && actionIndex + 1 !== actionCount) {
293
+ if ((0, MablStepV2_1.isMablStepV2)(step)) {
271
294
  action.setActionSourceIndexInStep(actionIndex);
272
- if (step.actionCode && SyntheticActionCodes.includes(step.actionCode)) {
273
- step.cumulativeActionSourceIndexInFlow = steps.length;
274
- }
275
- else if (step.actionCode === ACCESSIBILITY_CHECK_ACTION_NAME) {
276
- step.cumulativeActionSourceIndexInFlow = 1;
277
- }
278
- else {
279
- action.cumulativeActionSourceIndexInFlow = cumulativeIndex++;
280
- }
281
295
  }
282
296
  });
297
+ if ((0, MablStepV2_1.isMablStepV2)(step)) {
298
+ step.setActionSourceIndexInStep(step.actions.length);
299
+ }
283
300
  if (isStepDisabled) {
284
301
  step.setDisabled(isStepDisabled);
285
302
  }
@@ -287,6 +304,9 @@ function interpretStepsFromObjects(steps, isMobile) {
287
304
  });
288
305
  }
289
306
  function stepFromObjectInfo(stepName, stepArgs, isMobile) {
307
+ if (stepName.startsWith('assert_') && stepName !== 'assert_download') {
308
+ return AssertStepOld_1.AssertStepOldConverter.convert(stepName, stepArgs, []);
309
+ }
290
310
  if (isMobile &&
291
311
  Object.keys(yamlMablscriptToObjectsMobileStepMap).includes(stepName)) {
292
312
  return yamlMablscriptToObjectsMobileStepMap[stepName](stepName, stepArgs);
@@ -458,23 +478,20 @@ function removeCommentsAndGetDisabledIndices(mablscript) {
458
478
  return { updatedScript, disabledIndices };
459
479
  }
460
480
  function parseMablScriptIntoSteps(flow) {
461
- if (!flow.script) {
462
- return [];
481
+ let loadedSteps = [];
482
+ if (flow.json_steps?.steps) {
483
+ const isMobile = flow.flow_type === mablApi_1.TestTypeEnum.Mobile;
484
+ loadedSteps = interpretStepsFromObjects(flow.json_steps.steps, isMobile);
463
485
  }
464
- let flowDescriptions = [];
465
- if (flow.script_description) {
466
- flowDescriptions = flow.script_description.split('\n');
486
+ else if (flow.script) {
487
+ const { updatedScript, disabledIndices } = removeCommentsAndGetDisabledIndices(flow.script);
488
+ const parsed = parseMablScript(updatedScript);
489
+ loadedSteps = loadMablScriptIntoSteps(parsed);
490
+ loadedSteps
491
+ .filter((_step, index) => disabledIndices.includes(index))
492
+ .forEach((step) => step.setDisabled(true));
467
493
  }
468
- const { updatedScript, disabledIndices } = removeCommentsAndGetDisabledIndices(flow.script);
469
- const parsed = parseMablScript(updatedScript);
470
- const loadedSteps = loadMablScriptIntoSteps(parsed);
471
- loadedSteps.forEach((step, index) => {
472
- step.setDescription(flowDescriptions[index]);
473
- if (flow?.step_annotations?.[index]) {
474
- step.setAnnotation(flow.step_annotations[index]);
475
- }
476
- step.setDisabled(disabledIndices.includes(index));
477
- });
494
+ applyStepDescriptionsAndAnnotations(loadedSteps, flow);
478
495
  return loadedSteps;
479
496
  }
480
497
  function extractInputVariables(steps) {
@@ -491,7 +508,10 @@ function parseMablScriptIntoV2Step(script) {
491
508
  script,
492
509
  });
493
510
  const stepAsObject = parsedMablscriptStep[0].getFormattedStep(true);
494
- const [parsedStep] = interpretStepsFromObjects([stepAsObject], true);
511
+ let [parsedStep] = interpretStepsFromObjects([stepAsObject], true);
512
+ if (parsedStep.getStepName() === 'UnimplementedStep') {
513
+ [parsedStep] = interpretStepsFromObjects([stepAsObject], false);
514
+ }
495
515
  return parsedStep;
496
516
  }
497
517
  function getQueryIds(flows, testType) {
@@ -513,8 +533,8 @@ function getSnippetIdFromStep(step) {
513
533
  }
514
534
  else if ((0, CreateVariableStep_1.isCreateVariableStep)(step)) {
515
535
  if (step.generationType === CreateVariableStepDescriptor_1.VariableGenerator.JAVASCRIPT &&
516
- (0, JavaScriptAction_1.isJavaScriptActionDescriptor)(step.actions[0])) {
517
- jsDescriptor = step.actions[0].javaScript;
536
+ (0, JavaScriptAction_1.isJavaScriptActionDescriptor)(step.descriptor.generator)) {
537
+ jsDescriptor = step.descriptor.generator.javaScript;
518
538
  }
519
539
  }
520
540
  else if ((0, DatabaseQueryStep_1.isDatabaseQueryStep)(step)) {
@@ -33,7 +33,9 @@ class CreateVariableMobileStep extends MablStepV2_1.MablStepV2 {
33
33
  }
34
34
  }
35
35
  static fromYaml(_stepName, stepDescriptor) {
36
- if (!stepDescriptor.find) {
36
+ if (stepDescriptor.selector &&
37
+ !stepDescriptor.find &&
38
+ stepDescriptor.generator.find) {
37
39
  stepDescriptor.find = stepDescriptor.generator.find;
38
40
  delete stepDescriptor.generator.find;
39
41
  delete stepDescriptor.selector;
@@ -3,17 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AbstractAssertionsAndVariablesStep = void 0;
4
4
  const domUtil_1 = require("../../domUtil");
5
5
  const MablAction_1 = require("../MablAction");
6
- const MablStep_1 = require("../MablStep");
6
+ const MablStepV2_1 = require("../MablStepV2");
7
7
  const ConditionDescriptor_1 = require("../types/ConditionDescriptor");
8
8
  const AssertStep_1 = require("./AssertStep");
9
- class AbstractAssertionsAndVariablesStep extends MablStep_1.MablStep {
10
- constructor(name, args, actions, mablScriptName, stepName, descriptor) {
11
- super(name, args, actions, mablScriptName);
12
- this.stepName = stepName;
13
- this.descriptor = descriptor;
9
+ class AbstractAssertionsAndVariablesStep extends MablStepV2_1.MablStepV2 {
10
+ constructor(name, descriptor, actionCode) {
11
+ super(name, descriptor, actionCode);
14
12
  }
15
13
  getStepName() {
16
- return this.stepName;
14
+ return this.name;
15
+ }
16
+ stepDescription() {
17
+ return `Execute ${this.getStepName()}`;
17
18
  }
18
19
  toStepDescriptor() {
19
20
  const formatted = JSON.parse(JSON.stringify(this.descriptor));
@@ -26,8 +27,9 @@ class AbstractAssertionsAndVariablesStep extends MablStep_1.MablStep {
26
27
  return formatted;
27
28
  }
28
29
  toMablscript() {
30
+ const { actionCode, description, ...params } = this.toStepDescriptor();
29
31
  return `${this.getActionCode()}(${(0, domUtil_1.buildStepArgumentString)({
30
- params: { ...this.descriptor },
32
+ params,
31
33
  legacy: true,
32
34
  })})`;
33
35
  }
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AccessibilityCheckStep = exports.AccessibilityCheckSeverity = void 0;
4
4
  const MablStep_1 = require("../MablStep");
5
+ const MablStepV2_1 = require("../MablStepV2");
5
6
  const FindAction_1 = require("../actions/FindAction");
6
7
  const ActionsUtils_1 = require("./ActionsUtils");
7
8
  const domUtil_1 = require("../../domUtil");
@@ -12,19 +13,39 @@ var AccessibilityCheckSeverity;
12
13
  AccessibilityCheckSeverity["Moderate"] = "moderate";
13
14
  AccessibilityCheckSeverity["Serious"] = "serious";
14
15
  })(AccessibilityCheckSeverity || (exports.AccessibilityCheckSeverity = AccessibilityCheckSeverity = {}));
15
- class AccessibilityCheckStep extends MablStep_1.MablStep {
16
- constructor(name, args, actions) {
17
- super(name, args, actions, 'accessibility_check');
18
- if (this.actions.length) {
19
- this.findAction = ActionsUtils_1.ActionsUtils.validateSingleFindAction(this.actions);
16
+ class AccessibilityCheckStep extends MablStepV2_1.MablStepV2 {
17
+ constructor(descriptor) {
18
+ super(AccessibilityCheckStep.stepName, descriptor, AccessibilityCheckStep.actionCode);
19
+ if (descriptor.find && descriptor.descriptorToActionMap) {
20
+ this.findAction = descriptor.descriptorToActionMap.get(descriptor.find);
21
+ }
22
+ const maybeCheckConfig = {
23
+ ...(descriptor.tags && { tags: descriptor.tags }),
24
+ ...(descriptor.rules && { rules: descriptor.rules }),
25
+ ...(descriptor.disabledRules && {
26
+ disabledRules: descriptor.disabledRules,
27
+ }),
28
+ ...(descriptor.failOn && { failOn: descriptor.failOn }),
29
+ ...(descriptor.runInMainFrame !== undefined && {
30
+ runInMainFrame: descriptor.runInMainFrame,
31
+ }),
32
+ ...(descriptor.bypassCors !== undefined && {
33
+ bypassCors: descriptor.bypassCors,
34
+ }),
35
+ ...(descriptor.disabledRulesOnIframes && {
36
+ disabledRulesOnIframes: descriptor.disabledRulesOnIframes,
37
+ }),
38
+ };
39
+ const hasCheckConfig = Object.values(maybeCheckConfig).filter((value) => !!value).length > 0;
40
+ if (hasCheckConfig) {
41
+ this.checkConfig = maybeCheckConfig;
20
42
  }
21
- this.checkConfig = this.getActionArgs()[0];
22
43
  }
23
44
  canContinueOnFailure() {
24
45
  return true;
25
46
  }
26
47
  getStepName() {
27
- return AccessibilityCheckStep.yamlMablScriptNames[0];
48
+ return AccessibilityCheckStep.stepName;
28
49
  }
29
50
  toStepDescriptor() {
30
51
  if (this.findAction) {
@@ -37,7 +58,7 @@ class AccessibilityCheckStep extends MablStep_1.MablStep {
37
58
  return {
38
59
  ...this.checkConfig,
39
60
  find,
40
- descriptorToActionMap: new Map().set(find, this),
61
+ descriptorToActionMap: new Map().set(find, this.findAction),
41
62
  actionCode: this.actionCode,
42
63
  };
43
64
  default:
@@ -49,33 +70,12 @@ class AccessibilityCheckStep extends MablStep_1.MablStep {
49
70
  ...this.checkConfig,
50
71
  };
51
72
  }
52
- getFormattedStep(_fullLocatorsOn) {
53
- let finalStep;
54
- if (this.findAction) {
55
- finalStep = {
56
- AccessibilityCheck: {
57
- ...super.annotationsAsYml(),
58
- ...this.findAction.toYaml(),
59
- ...this.checkConfig,
60
- },
61
- };
62
- }
63
- else {
64
- finalStep = {
65
- AccessibilityCheck: {
66
- ...super.annotationsAsYml(),
67
- ...this.checkConfig,
68
- },
69
- };
70
- }
71
- if (this.stepId()) {
72
- finalStep.AccessibilityCheck.id = this.stepId();
73
- }
74
- return finalStep;
75
- }
76
73
  static fromYaml(_stepName, stepArgs) {
77
74
  const actions = [];
78
- if (stepArgs.selector) {
75
+ if (stepArgs.find) {
76
+ actions.push(FindAction_1.FindAction.findActionFromStepArgs(stepArgs));
77
+ }
78
+ else if (stepArgs.selector) {
79
79
  actions.push(FindAction_1.FindAction.findActionFromStepArgs(stepArgs));
80
80
  }
81
81
  const checkConfig = {
@@ -84,10 +84,21 @@ class AccessibilityCheckStep extends MablStep_1.MablStep {
84
84
  disabledRules: stepArgs.disabledRules,
85
85
  failOn: stepArgs.failOn,
86
86
  };
87
- const step = new AccessibilityCheckStep(AccessibilityCheckStep.mablScriptStepNames[0], [checkConfig], actions);
87
+ const stepDescriptor = buildStepDescriptor(actions.length ? actions[0] : undefined, checkConfig);
88
+ const step = new AccessibilityCheckStep(stepDescriptor);
88
89
  step.setStepId(stepArgs.id);
89
90
  return step;
90
91
  }
92
+ static fromLegacyMablscript(args, actions) {
93
+ const checkConfig = args[0];
94
+ const findAction = actions.length
95
+ ? ActionsUtils_1.ActionsUtils.validateSingleFindAction(actions)
96
+ : undefined;
97
+ const stepDescriptor = buildStepDescriptor(findAction, checkConfig);
98
+ const step = new AccessibilityCheckStep(stepDescriptor);
99
+ step.actions = actions;
100
+ return step;
101
+ }
91
102
  toMablscript() {
92
103
  let argString = '';
93
104
  if (this.checkConfig?.tags ||
@@ -101,7 +112,38 @@ class AccessibilityCheckStep extends MablStep_1.MablStep {
101
112
  }
102
113
  return `${findAction}${AccessibilityCheckStep.mablScriptStepNames[0]}(${argString})`;
103
114
  }
115
+ getInputVariables() {
116
+ return this.findAction?.getInputVariables() ?? [];
117
+ }
118
+ stepDescription() {
119
+ return 'Check accessibility';
120
+ }
104
121
  }
105
122
  exports.AccessibilityCheckStep = AccessibilityCheckStep;
106
- AccessibilityCheckStep.mablScriptStepNames = ['accessibility_check'];
107
- AccessibilityCheckStep.yamlMablScriptNames = ['AccessibilityCheck'];
123
+ AccessibilityCheckStep.stepName = 'AccessibilityCheck';
124
+ AccessibilityCheckStep.actionCode = 'accessibility_check';
125
+ AccessibilityCheckStep.mablScriptStepNames = [AccessibilityCheckStep.actionCode];
126
+ AccessibilityCheckStep.yamlMablScriptNames = [AccessibilityCheckStep.stepName];
127
+ function buildStepDescriptor(findAction, checkConfig) {
128
+ if (findAction) {
129
+ const find = findAction.toDescriptor();
130
+ switch (find.findType) {
131
+ case domUtil_1.FindType.FIND_FIRST:
132
+ case domUtil_1.FindType.FIND_LAST:
133
+ case domUtil_1.FindType.FIND_ANY:
134
+ case domUtil_1.FindType.FIND_ONE:
135
+ return {
136
+ ...checkConfig,
137
+ find,
138
+ descriptorToActionMap: new Map().set(find, findAction),
139
+ actionCode: AccessibilityCheckStep.actionCode,
140
+ };
141
+ default:
142
+ throw new Error(`Error generating step descriptor for ${AccessibilityCheckStep.stepName}: Unexpected find type ${find.findType}`);
143
+ }
144
+ }
145
+ return {
146
+ actionCode: AccessibilityCheckStep.actionCode,
147
+ ...checkConfig,
148
+ };
149
+ }