@mablhq/mabl-cli 1.40.12 → 1.41.4
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.
- package/cli.js +0 -0
- package/execution/index.js +1 -1
- package/mablscript/MablAction.js +19 -1
- package/mablscript/MablStep.js +0 -17
- package/mablscript/actions/ConditionAction.js +7 -2
- package/mablscript/steps/AssertStep.js +24 -15
- package/mablscript/steps/IfConditionStep.js +8 -1
- package/mablscript/steps/ReleaseStep.js +2 -1
- package/mablscript/steps/SelectStep.js +1 -1
- package/mablscript/steps/SetFilesStep.js +2 -1
- package/mablscript/steps/SyntheticStep.js +1 -1
- package/package.json +1 -1
package/mablscript/MablAction.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.distinctStrings = exports.parseArgument = exports.argumentIsMablVariable = exports.MablAction = void 0;
|
|
3
|
+
exports.convertObjectToMablscriptArgs = exports.distinctStrings = exports.parseArgument = exports.argumentIsMablVariable = exports.MablAction = void 0;
|
|
4
4
|
const domUtil_1 = require("../domUtil");
|
|
5
5
|
const MablSymbol_1 = require("./MablSymbol");
|
|
6
6
|
class MablAction {
|
|
@@ -78,3 +78,21 @@ function distinctStrings(values) {
|
|
|
78
78
|
return Array.from(new Set(values));
|
|
79
79
|
}
|
|
80
80
|
exports.distinctStrings = distinctStrings;
|
|
81
|
+
function convertObjectToMablscriptArgs(objectArgs) {
|
|
82
|
+
const mablArgs = Object.keys(objectArgs)
|
|
83
|
+
.sort()
|
|
84
|
+
.filter((key) => (objectArgs === null || objectArgs === void 0 ? void 0 : objectArgs[key]) !== undefined)
|
|
85
|
+
.map((key) => {
|
|
86
|
+
switch (typeof objectArgs[key]) {
|
|
87
|
+
case 'object':
|
|
88
|
+
return `${key}: ${convertObjectToMablscriptArgs(objectArgs[key])}`;
|
|
89
|
+
case 'boolean':
|
|
90
|
+
case 'number':
|
|
91
|
+
return `${key}: ${objectArgs[key]}`;
|
|
92
|
+
default:
|
|
93
|
+
return `${key}: "${(0, domUtil_1.escapeMablscriptString)(objectArgs[key])}"`;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
return `{${mablArgs.join(', ')}}`;
|
|
97
|
+
}
|
|
98
|
+
exports.convertObjectToMablscriptArgs = convertObjectToMablscriptArgs;
|
package/mablscript/MablStep.js
CHANGED
|
@@ -100,23 +100,6 @@ class MablStep extends MablAction_1.MablAction {
|
|
|
100
100
|
selIdeEcho.target = unSupportedStepMessage;
|
|
101
101
|
return [selIdeEcho];
|
|
102
102
|
}
|
|
103
|
-
convertObjectToMablscriptArgs(objectArgs) {
|
|
104
|
-
const mablArgs = Object.keys(objectArgs)
|
|
105
|
-
.sort()
|
|
106
|
-
.filter((key) => (objectArgs === null || objectArgs === void 0 ? void 0 : objectArgs[key]) !== undefined)
|
|
107
|
-
.map((key) => {
|
|
108
|
-
switch (typeof objectArgs[key]) {
|
|
109
|
-
case 'object':
|
|
110
|
-
return `${key}: ${this.convertObjectToMablscriptArgs(objectArgs[key])}`;
|
|
111
|
-
case 'boolean':
|
|
112
|
-
case 'number':
|
|
113
|
-
return `${key}: ${objectArgs[key]}`;
|
|
114
|
-
default:
|
|
115
|
-
return `${key}: "${(0, domUtil_1.escapeMablscriptString)(objectArgs[key])}"`;
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
return `{${mablArgs.join(', ')}}`;
|
|
119
|
-
}
|
|
120
103
|
toMablscript() {
|
|
121
104
|
return '';
|
|
122
105
|
}
|
|
@@ -15,7 +15,7 @@ class ConditionAction extends MablAction_1.MablAction {
|
|
|
15
15
|
setConditionAttributes() {
|
|
16
16
|
const conditionActionArgs = this.getActionArgs();
|
|
17
17
|
if (conditionActionArgs) {
|
|
18
|
-
[this.conditionAttribute, this.conditionValueAttribute] =
|
|
18
|
+
[this.conditionAttribute, this.conditionValueAttribute, this.options] =
|
|
19
19
|
this.getActionArgs();
|
|
20
20
|
}
|
|
21
21
|
}
|
|
@@ -30,6 +30,7 @@ class ConditionAction extends MablAction_1.MablAction {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
getEvaluateCondition() {
|
|
33
|
+
var _a;
|
|
33
34
|
if (this.conditionValueAttribute === undefined) {
|
|
34
35
|
throw new Error('Invalid equality condition. Missing value to compare.');
|
|
35
36
|
}
|
|
@@ -37,6 +38,7 @@ class ConditionAction extends MablAction_1.MablAction {
|
|
|
37
38
|
conditionType: ConditionDescriptor_1.ConditionType.Comparison,
|
|
38
39
|
comparisonType: ConditionDescriptor_1.ComparisonType.fromString(this.conditionAttribute),
|
|
39
40
|
comparatorValue: (0, MablAction_1.parseArgument)(this.conditionValueAttribute),
|
|
41
|
+
caseInsensitive: (_a = this.options) === null || _a === void 0 ? void 0 : _a.caseInsensitive,
|
|
40
42
|
};
|
|
41
43
|
}
|
|
42
44
|
getEvaluatePresence() {
|
|
@@ -58,7 +60,10 @@ class ConditionAction extends MablAction_1.MablAction {
|
|
|
58
60
|
value = `, ${this.subVariable(this.conditionValueAttribute)}`;
|
|
59
61
|
}
|
|
60
62
|
}
|
|
61
|
-
|
|
63
|
+
const conditionOptionsString = this.options !== undefined
|
|
64
|
+
? `, ${(0, MablAction_1.convertObjectToMablscriptArgs)(this.options)}`
|
|
65
|
+
: '';
|
|
66
|
+
return `${this.name}("${this.conditionAttribute}"${value}${conditionOptionsString})`;
|
|
62
67
|
}
|
|
63
68
|
toMablscript() {
|
|
64
69
|
return `${this.generateEvaluateConditionMablscript()}`;
|
|
@@ -158,12 +158,16 @@ class AssertStep extends MablStep_1.MablStep {
|
|
|
158
158
|
throw new Error(`Error generating step descriptor for ${this.getStepName()}: Unexpected find type ${find.findType}`);
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
|
+
if (this.conditionAction.options) {
|
|
162
|
+
formatted.conditionOptions = this.conditionAction.options;
|
|
163
|
+
}
|
|
161
164
|
return result;
|
|
162
165
|
}
|
|
163
166
|
static fromYaml(stepName, stepArgs) {
|
|
164
167
|
const actions = [];
|
|
165
168
|
const assertionType = exports.assertionStepToField[stepName];
|
|
166
169
|
const assertionValue = stepArgs.assertionValue;
|
|
170
|
+
const conditionOptions = stepArgs.conditionOptions;
|
|
167
171
|
let primaryAction;
|
|
168
172
|
if (stepArgs.kind === GetCurrentLocationDescriptor_1.GET_CURRENT_LOCATION_KIND) {
|
|
169
173
|
primaryAction = new GetUrlAction_1.GetUrlAction(GetUrlAction_1.GetUrlAction.mablScriptStepNames[0], []);
|
|
@@ -188,6 +192,7 @@ class AssertStep extends MablStep_1.MablStep {
|
|
|
188
192
|
actions.push(new ConditionAction_1.ConditionAction('evaluate_condition', [
|
|
189
193
|
assertionType,
|
|
190
194
|
assertionValue,
|
|
195
|
+
conditionOptions,
|
|
191
196
|
]));
|
|
192
197
|
}
|
|
193
198
|
return new AssertStep('assert', [
|
|
@@ -198,6 +203,7 @@ class AssertStep extends MablStep_1.MablStep {
|
|
|
198
203
|
], actions);
|
|
199
204
|
}
|
|
200
205
|
produceSelIdeFormattedSteps(stepIndex) {
|
|
206
|
+
var _a;
|
|
201
207
|
const find = this.primaryAction.toDescriptor();
|
|
202
208
|
if (!(0, GetCurrentLocationDescriptor_1.isGetCurrentLocationDescriptor)(find) &&
|
|
203
209
|
!(0, GetVariableDescriptor_1.isGetVariableDescriptor)(find) &&
|
|
@@ -231,7 +237,7 @@ class AssertStep extends MablStep_1.MablStep {
|
|
|
231
237
|
!(0, GetVariableDescriptor_1.isGetVariableDescriptor)(find) &&
|
|
232
238
|
find.findType === domUtil_1.FindType.FIND_ONE &&
|
|
233
239
|
find.findTarget.selector.xpath) ||
|
|
234
|
-
'', this.extractAction ? this.extractAction.extractionAttribute : '', this.substituteSeleniumVariable(this.conditionAction.conditionValueAttribute || ''), this.assertionType, this);
|
|
240
|
+
'', this.extractAction ? this.extractAction.extractionAttribute : '', this.substituteSeleniumVariable(this.conditionAction.conditionValueAttribute || ''), this.assertionType, this, (_a = this.conditionAction.options) === null || _a === void 0 ? void 0 : _a.caseInsensitive);
|
|
235
241
|
}
|
|
236
242
|
unsupportedSelIdeExportStep() {
|
|
237
243
|
const seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('echo', this);
|
|
@@ -246,7 +252,7 @@ class AssertStep extends MablStep_1.MablStep {
|
|
|
246
252
|
var _a, _b;
|
|
247
253
|
const assertAction = `.assert(${!!(((_a = this.assertArguments) === null || _a === void 0 ? void 0 : _a.onFailure) ||
|
|
248
254
|
((_b = this.assertArguments) === null || _b === void 0 ? void 0 : _b.observationScope))
|
|
249
|
-
?
|
|
255
|
+
? (0, MablAction_1.convertObjectToMablscriptArgs)(this.assertArguments)
|
|
250
256
|
: ''})`;
|
|
251
257
|
if (this.countAction) {
|
|
252
258
|
return `${this.primaryAction.toMablscript()}.${this.countAction.toMablscript()}.${this.conditionAction.toMablscript()}${assertAction}`;
|
|
@@ -273,7 +279,7 @@ class AssertStep extends MablStep_1.MablStep {
|
|
|
273
279
|
exports.AssertStep = AssertStep;
|
|
274
280
|
AssertStep.mablScriptStepNames = ['assert'];
|
|
275
281
|
AssertStep.yamlMablScriptNames = yamlMablScriptNames();
|
|
276
|
-
function buildSeleniumIdeJsAssertion(stepIndex, xpath, assertionAttribute, assertAgainst, assertionType, step) {
|
|
282
|
+
function buildSeleniumIdeJsAssertion(stepIndex, xpath, assertionAttribute, assertAgainst, assertionType, step, caseInsensitive = false) {
|
|
277
283
|
const variableName = `assertVariable-${stepIndex}`;
|
|
278
284
|
let storeAttribute;
|
|
279
285
|
if (assertionAttribute !== 'innerText') {
|
|
@@ -286,42 +292,45 @@ function buildSeleniumIdeJsAssertion(stepIndex, xpath, assertionAttribute, asser
|
|
|
286
292
|
}
|
|
287
293
|
storeAttribute.value = variableName;
|
|
288
294
|
let condition = '';
|
|
295
|
+
const toLowerCaseString = caseInsensitive
|
|
296
|
+
? '.toUpperCase().toLowerCase()'
|
|
297
|
+
: '';
|
|
289
298
|
switch (assertionType) {
|
|
290
299
|
case 'equals':
|
|
291
|
-
condition = `\${${variableName}} !== '${assertAgainst}'`;
|
|
300
|
+
condition = `\${${variableName}}${toLowerCaseString} !== '${assertAgainst}'${toLowerCaseString}`;
|
|
292
301
|
break;
|
|
293
302
|
case 'does_not_equal':
|
|
294
|
-
condition = `\${${variableName}} === '${assertAgainst}'`;
|
|
303
|
+
condition = `\${${variableName}}${toLowerCaseString} === '${assertAgainst}'${toLowerCaseString}`;
|
|
295
304
|
break;
|
|
296
305
|
case 'contains':
|
|
297
|
-
condition = `!\${${variableName}}.includes('${assertAgainst}')`;
|
|
306
|
+
condition = `!\${${variableName}}${toLowerCaseString}.includes('${assertAgainst}'${toLowerCaseString})`;
|
|
298
307
|
break;
|
|
299
308
|
case 'does_not_contain':
|
|
300
|
-
condition = `\${${variableName}}.includes('${assertAgainst}')`;
|
|
309
|
+
condition = `\${${variableName}}${toLowerCaseString}.includes('${assertAgainst}'${toLowerCaseString})`;
|
|
301
310
|
break;
|
|
302
311
|
case 'starts_with':
|
|
303
|
-
condition = `!\${${variableName}}.startsWith('${assertAgainst}')`;
|
|
312
|
+
condition = `!\${${variableName}}${toLowerCaseString}.startsWith('${assertAgainst}'${toLowerCaseString})`;
|
|
304
313
|
break;
|
|
305
314
|
case 'starts_without':
|
|
306
|
-
condition = `\${${variableName}}.startsWith('${assertAgainst}')`;
|
|
315
|
+
condition = `\${${variableName}}${toLowerCaseString}.startsWith('${assertAgainst}'${toLowerCaseString})`;
|
|
307
316
|
break;
|
|
308
317
|
case 'ends_with':
|
|
309
|
-
condition = `!\${${variableName}}.endsWith('${assertAgainst}')`;
|
|
318
|
+
condition = `!\${${variableName}}${toLowerCaseString}.endsWith('${assertAgainst}'${toLowerCaseString})`;
|
|
310
319
|
break;
|
|
311
320
|
case 'ends_without':
|
|
312
|
-
condition = `\${${variableName}}.endsWith('${assertAgainst}')`;
|
|
321
|
+
condition = `\${${variableName}}${toLowerCaseString}.endsWith('${assertAgainst}'${toLowerCaseString})`;
|
|
313
322
|
break;
|
|
314
323
|
case 'greater_than':
|
|
315
|
-
condition = `!\${${variableName}} > '${assertAgainst}'`;
|
|
324
|
+
condition = `!\${${variableName}}${toLowerCaseString} > '${assertAgainst}'${toLowerCaseString}`;
|
|
316
325
|
break;
|
|
317
326
|
case 'less_than':
|
|
318
|
-
condition = `!\${${variableName}} < '${assertAgainst}'`;
|
|
327
|
+
condition = `!\${${variableName}}${toLowerCaseString} < '${assertAgainst}'${toLowerCaseString}`;
|
|
319
328
|
break;
|
|
320
329
|
case 'greater_than_or_equals':
|
|
321
|
-
condition = `!\${${variableName}} >= '${assertAgainst}'`;
|
|
330
|
+
condition = `!\${${variableName}}${toLowerCaseString} >= '${assertAgainst}'${toLowerCaseString}`;
|
|
322
331
|
break;
|
|
323
332
|
case 'less_than_or_equals':
|
|
324
|
-
condition = `!\${${variableName}} <= '${assertAgainst}'`;
|
|
333
|
+
condition = `!\${${variableName}}${toLowerCaseString} <= '${assertAgainst}'${toLowerCaseString}`;
|
|
325
334
|
break;
|
|
326
335
|
}
|
|
327
336
|
const ifStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('if', step);
|
|
@@ -59,6 +59,9 @@ class IfConditionStep extends MablStep_1.MablStep {
|
|
|
59
59
|
if (this.conditionAction.conditionValueAttribute) {
|
|
60
60
|
details.conditionValue = this.conditionAction.conditionValueAttribute;
|
|
61
61
|
}
|
|
62
|
+
if (this.conditionAction.options !== undefined) {
|
|
63
|
+
details.conditionOptions = this.conditionAction.options;
|
|
64
|
+
}
|
|
62
65
|
}
|
|
63
66
|
if (this.primaryAction instanceof GetVariableValue_1.GetVariableValue) {
|
|
64
67
|
details.variableName = this.substituteMablscriptVariable(this.primaryAction.variable);
|
|
@@ -115,7 +118,11 @@ class IfConditionStep extends MablStep_1.MablStep {
|
|
|
115
118
|
const conditionType = AssertStep_1.assertionStepToField[stepArgs.condition];
|
|
116
119
|
actions.push(new ConditionAction_1.ConditionAction(conditionType === 'present' || conditionType === 'not_present'
|
|
117
120
|
? 'evaluate_presence'
|
|
118
|
-
: 'evaluate_condition', [
|
|
121
|
+
: 'evaluate_condition', [
|
|
122
|
+
AssertStep_1.assertionStepToField[stepArgs.condition],
|
|
123
|
+
stepArgs.conditionValue,
|
|
124
|
+
stepArgs.conditionOptions,
|
|
125
|
+
]));
|
|
119
126
|
}
|
|
120
127
|
return actions;
|
|
121
128
|
}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ReleaseStep = void 0;
|
|
4
4
|
const FindAction_1 = require("../actions/FindAction");
|
|
5
5
|
const MablStep_1 = require("../MablStep");
|
|
6
|
+
const MablAction_1 = require("../MablAction");
|
|
6
7
|
const domUtil_1 = require("../../domUtil");
|
|
7
8
|
const ActionsUtils_1 = require("./ActionsUtils");
|
|
8
9
|
class ReleaseStep extends MablStep_1.MablStep {
|
|
@@ -55,7 +56,7 @@ class ReleaseStep extends MablStep_1.MablStep {
|
|
|
55
56
|
return new ReleaseStep('release', [], [FindAction_1.FindAction.findActionFromStepArgs(stepArgs)]);
|
|
56
57
|
}
|
|
57
58
|
toMablscript() {
|
|
58
|
-
const args =
|
|
59
|
+
const args = (0, MablAction_1.convertObjectToMablscriptArgs)(this.releaseArgs);
|
|
59
60
|
return `${this.findAction.toMablscript()}.release(${args})`;
|
|
60
61
|
}
|
|
61
62
|
getInputVariables() {
|
|
@@ -62,7 +62,7 @@ class SelectStep extends MablStep_1.MablStep {
|
|
|
62
62
|
const selectOptionType = this.selectOptionType
|
|
63
63
|
? `, "${this.selectOptionType}"`
|
|
64
64
|
: '';
|
|
65
|
-
return `${this.findAction.toMablscript()}.select(${
|
|
65
|
+
return `${this.findAction.toMablscript()}.select(${(0, MablAction_1.convertObjectToMablscriptArgs)(this.selectOptions)}${selectOptionType})`;
|
|
66
66
|
}
|
|
67
67
|
getInputVariables() {
|
|
68
68
|
return (0, MablAction_1.distinctStrings)([
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SetFilesStep = void 0;
|
|
4
4
|
const FindAction_1 = require("../actions/FindAction");
|
|
5
|
+
const MablAction_1 = require("../MablAction");
|
|
5
6
|
const MablStep_1 = require("../MablStep");
|
|
6
7
|
const domUtil_1 = require("../../domUtil");
|
|
7
8
|
class SetFilesStep extends MablStep_1.MablStep {
|
|
@@ -51,7 +52,7 @@ class SetFilesStep extends MablStep_1.MablStep {
|
|
|
51
52
|
}
|
|
52
53
|
toMablscript() {
|
|
53
54
|
const files = this.files
|
|
54
|
-
.map((key) =>
|
|
55
|
+
.map((key) => (0, MablAction_1.convertObjectToMablscriptArgs)(key))
|
|
55
56
|
.join(', ');
|
|
56
57
|
return `${this.findAction.toMablscript()}.set_files(${files})`;
|
|
57
58
|
}
|
|
@@ -4,7 +4,7 @@ exports.SyntheticStep = exports.DEFAULT_STEP_SOURCE_INDEX_IN_FLOW = void 0;
|
|
|
4
4
|
const MablStep_1 = require("../MablStep");
|
|
5
5
|
exports.DEFAULT_STEP_SOURCE_INDEX_IN_FLOW = -1;
|
|
6
6
|
class SyntheticStep extends MablStep_1.MablStep {
|
|
7
|
-
constructor(name, args, actions, stepSourceIndexInFlow = exports.DEFAULT_STEP_SOURCE_INDEX_IN_FLOW) {
|
|
7
|
+
constructor(name, args = [], actions = [], stepSourceIndexInFlow = exports.DEFAULT_STEP_SOURCE_INDEX_IN_FLOW) {
|
|
8
8
|
super(name, args, actions);
|
|
9
9
|
this.stepSourceIndexInFlow = stepSourceIndexInFlow;
|
|
10
10
|
this.actionSourceIndexInStep = 0;
|