@mablhq/mabl-cli 1.50.5 → 1.52.2

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.
@@ -16,6 +16,9 @@ class MablStep extends MablAction_1.MablAction {
16
16
  canContinueOnFailure() {
17
17
  return false;
18
18
  }
19
+ canFailAtEnd() {
20
+ return false;
21
+ }
19
22
  getStepName() {
20
23
  return 'UnimplementedStep';
21
24
  }
@@ -51,20 +51,17 @@ class FindAction extends MablAction_1.MablAction {
51
51
  case domUtil_1.FindType.FIND_LAST:
52
52
  case domUtil_1.FindType.FIND_ANY:
53
53
  case domUtil_1.FindType.FIND_ALL: {
54
- const [primarySelector, foundSelector, findOptions] = this.getActionArgs();
54
+ const [primarySelector, foundElementSelectors, findOptions] = this.getActionArgs();
55
55
  if (!(0, domUtil_1.isCssSelector)(primarySelector) &&
56
56
  !(0, domUtil_1.isXPathSelector)(primarySelector)) {
57
57
  this.isValid = false;
58
58
  }
59
59
  this.findDescriptor = {
60
- findType,
60
+ findOptions,
61
61
  findTarget: primarySelector,
62
- foundElementSelectors: foundSelector,
63
- primarySelectors: {
64
- ...primarySelector,
65
- uuid: primarySelector.uuid,
66
- },
67
- hints: findOptions === null || findOptions === void 0 ? void 0 : findOptions.hints,
62
+ findType,
63
+ foundElementSelectors,
64
+ primarySelectors: primarySelector,
68
65
  };
69
66
  break;
70
67
  }
@@ -196,10 +193,10 @@ class FindAction extends MablAction_1.MablAction {
196
193
  else {
197
194
  foundElementSelectors = '{selector_type: "element"}';
198
195
  }
199
- args = [selector, foundElementSelectors].join(', ');
200
- if (find.hints) {
201
- args += `, ${(0, mablscriptFind_1.buildFindHintsString)(find.hints)}`;
202
- }
196
+ const options = buildFindOptionsString(find.findOptions);
197
+ args = [selector, foundElementSelectors, options]
198
+ .filter(Boolean)
199
+ .join(', ');
203
200
  if (find.findType === domUtil_1.FindType.FIND_ANY) {
204
201
  action = domUtil_1.FindType.FIND_FIRST;
205
202
  }
@@ -250,7 +247,7 @@ FindAction.yamlMablScriptNames = [
250
247
  ];
251
248
  function buildFindOptionsString(findOptions) {
252
249
  if (!findOptions) {
253
- return '';
250
+ return undefined;
254
251
  }
255
252
  return JSON.stringify(findOptions);
256
253
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AssertStep = exports.fieldToAssertionStep = exports.assertionStepToField = void 0;
3
+ exports.AssertStep = exports.fieldToAssertionStep = exports.assertionStepToField = exports.OnFailure = void 0;
4
4
  const ConditionAction_1 = require("../actions/ConditionAction");
5
5
  const FindAction_1 = require("../actions/FindAction");
6
6
  const MablStep_1 = require("../MablStep");
@@ -12,6 +12,12 @@ const GetCurrentLocationDescriptor_1 = require("../types/GetCurrentLocationDescr
12
12
  const GetVariableValue_1 = require("../actions/GetVariableValue");
13
13
  const GetVariableDescriptor_1 = require("../types/GetVariableDescriptor");
14
14
  const CountAction_1 = require("../actions/CountAction");
15
+ var OnFailure;
16
+ (function (OnFailure) {
17
+ OnFailure["ContinueWithWarning"] = "continue";
18
+ OnFailure["FailImmediately"] = "terminate";
19
+ OnFailure["FailTestAtEnd"] = "failAtEnd";
20
+ })(OnFailure = exports.OnFailure || (exports.OnFailure = {}));
15
21
  exports.assertionStepToField = {
16
22
  AssertEquals: 'equals',
17
23
  AssertPresent: 'present',
@@ -67,9 +73,17 @@ class AssertStep extends MablStep_1.MablStep {
67
73
  args[0] && typeof args[0] === 'object'
68
74
  ? args[0]
69
75
  : undefined;
70
- this.continueOnFailure = ((_a = this.assertArguments) === null || _a === void 0 ? void 0 : _a.onFailure) === 'continue';
76
+ this.onFailure =
77
+ ((_a = this.assertArguments) === null || _a === void 0 ? void 0 : _a.onFailure) ||
78
+ OnFailure.FailImmediately;
71
79
  this.observationScope = (_b = this.assertArguments) === null || _b === void 0 ? void 0 : _b.observationScope;
72
80
  }
81
+ canContinueOnFailure() {
82
+ return this.onFailure !== OnFailure.FailImmediately;
83
+ }
84
+ canFailAtEnd() {
85
+ return this.onFailure === OnFailure.FailTestAtEnd;
86
+ }
73
87
  validate() {
74
88
  if (!(this.actions.length === 2 || this.actions.length === 3) &&
75
89
  !(this.actions[0] instanceof FindAction_1.FindAction) &&
@@ -110,7 +124,7 @@ class AssertStep extends MablStep_1.MablStep {
110
124
  extractDescriptor: (_a = this.extractAction) === null || _a === void 0 ? void 0 : _a.extractDescriptor,
111
125
  conditionDescriptor: this.conditionAction.conditionDescriptor,
112
126
  countDescriptor: (_b = this.countAction) === null || _b === void 0 ? void 0 : _b.countDescriptor,
113
- continueOnFailure: this.continueOnFailure,
127
+ onFailure: this.onFailure,
114
128
  observationScope: this.observationScope,
115
129
  descriptorToActionMap,
116
130
  };
@@ -199,16 +213,21 @@ class AssertStep extends MablStep_1.MablStep {
199
213
  }
200
214
  return new AssertStep('assert', [
201
215
  {
202
- onFailure: stepArgs.continueOnFailure ? 'continue' : undefined,
216
+ onFailure: stepArgs.onFailure,
203
217
  observationScope: stepArgs.observationScope,
204
218
  },
205
219
  ], actions);
206
220
  }
207
221
  toMablscript() {
208
- var _a, _b;
222
+ var _a, _b, _c, _d;
209
223
  const assertAction = `.assert(${!!(((_a = this.assertArguments) === null || _a === void 0 ? void 0 : _a.onFailure) ||
210
224
  ((_b = this.assertArguments) === null || _b === void 0 ? void 0 : _b.observationScope))
211
- ? (0, MablAction_1.convertObjectToMablscriptArgs)(this.assertArguments)
225
+ ? (0, MablAction_1.convertObjectToMablscriptArgs)({
226
+ ...this.assertArguments,
227
+ onFailure: ((_c = this.assertArguments) === null || _c === void 0 ? void 0 : _c.onFailure) === OnFailure.FailImmediately
228
+ ? undefined
229
+ : (_d = this.assertArguments) === null || _d === void 0 ? void 0 : _d.onFailure,
230
+ })
212
231
  : ''})`;
213
232
  if (this.countAction) {
214
233
  return `${this.primaryAction.toMablscript()}.${this.countAction.toMablscript()}.${this.conditionAction.toMablscript()}${assertAction}`;
@@ -36,11 +36,11 @@ class AssertStepOld extends MablStep_1.MablStep {
36
36
  this.primaryAction = actions[0];
37
37
  this.extractAction = actions[1];
38
38
  if (args.length === 1) {
39
- this.continueOnFailure = args[0].onFailure === 'continue';
39
+ this.onFailure = args[0].onFailure;
40
40
  this.observationScope = args[0].observationScope;
41
41
  }
42
42
  else if (args.length === 2) {
43
- this.continueOnFailure = args[1].onFailure === 'continue';
43
+ this.onFailure = args[1].onFailure;
44
44
  this.observationScope = args[1].observationScope;
45
45
  }
46
46
  }
@@ -97,7 +97,7 @@ class AssertStepOld extends MablStep_1.MablStep {
97
97
  throw new Error(`Error generating step descriptor for ${this.getStepName()}: Unexpected find type ${find.findType}`);
98
98
  }
99
99
  }
100
- formatted.continueOnFailure = this.continueOnFailure;
100
+ formatted.onFailure = this.onFailure;
101
101
  formatted.observationScope = this.observationScope;
102
102
  return formatted;
103
103
  }
@@ -42,7 +42,7 @@ class IfConditionStep extends MablStep_1.MablStep {
42
42
  find,
43
43
  extractDescriptor: (_b = this.extractAction) === null || _b === void 0 ? void 0 : _b.extractDescriptor,
44
44
  conditionDescriptor,
45
- continueOnFailure: false,
45
+ onFailure: AssertStep_1.OnFailure.FailImmediately,
46
46
  descriptorToActionMap: new Map().set(find, this.primaryAction),
47
47
  };
48
48
  }