@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.
- package/core/execution/ApiTestUtils.js +12 -2
- package/execution/index.js +1 -1
- package/mablscript/MablStepV2.js +10 -40
- package/mablscript/MablStepWithFindAction.js +2 -126
- package/mablscript/actions/AwaitDownloadAction.js +3 -4
- package/mablscript/actions/AwaitPDFDownloadAction.js +5 -6
- package/mablscript/actions/ConditionAction.js +1 -2
- package/mablscript/actions/ExtractAction.js +13 -8
- package/mablscript/actions/FindAction.js +0 -20
- package/mablscript/actions/GetVariableValue.js +4 -15
- package/mablscript/actions/JavaScriptAction.js +39 -25
- package/mablscript/diffing/diffingUtil.js +5 -5
- package/mablscript/importer.js +59 -79
- package/mablscript/mobile/steps/CreateVariableMobileStep.js +1 -3
- package/mablscript/mobile/steps/stepUtil.js +2 -2
- package/mablscript/steps/AbstractAssertionsAndVariablesStep.js +8 -10
- package/mablscript/steps/AccessibilityCheck.js +36 -76
- package/mablscript/steps/AssertStep.js +86 -266
- package/mablscript/steps/AssertStepOld.js +139 -69
- package/mablscript/steps/AwaitTabStep.js +9 -30
- package/mablscript/steps/AwaitUploadsStep.js +8 -22
- package/mablscript/steps/ClearCookiesStep.js +8 -22
- package/mablscript/steps/ClickAndHoldStep.js +47 -45
- package/mablscript/steps/ClickStep.js +33 -36
- package/mablscript/steps/CreateVariableStep.js +137 -169
- package/mablscript/steps/DatabaseQueryStep.js +4 -14
- package/mablscript/steps/DoubleClickStep.js +40 -37
- package/mablscript/steps/DownloadStep.js +63 -79
- package/mablscript/steps/EchoStep.js +8 -26
- package/mablscript/steps/ElseIfConditionStep.js +12 -23
- package/mablscript/steps/ElseStep.js +9 -22
- package/mablscript/steps/EndStep.js +9 -22
- package/mablscript/steps/EnterAuthCodeStep.js +34 -36
- package/mablscript/steps/EnterTextStep.js +64 -51
- package/mablscript/steps/EvaluateFlowStep.js +18 -39
- package/mablscript/steps/EvaluateJavaScriptStep.js +19 -17
- package/mablscript/steps/HoverStep.js +39 -37
- package/mablscript/steps/IfConditionStep.js +99 -139
- package/mablscript/steps/NavigateStep.js +9 -29
- package/mablscript/steps/OpenEmailStep.js +21 -39
- package/mablscript/steps/ReleaseStep.js +38 -46
- package/mablscript/steps/RemoveCookieStep.js +9 -25
- package/mablscript/steps/RightClickStep.js +33 -36
- package/mablscript/steps/SelectStep.js +46 -69
- package/mablscript/steps/SendHttpRequestStep.js +4 -13
- package/mablscript/steps/SendKeyStep.js +50 -174
- package/mablscript/steps/SetCookieStep.js +23 -56
- package/mablscript/steps/SetFilesStep.js +43 -42
- package/mablscript/steps/SetViewportStep.js +13 -39
- package/mablscript/steps/SwitchContextStep.js +83 -89
- package/mablscript/steps/SyntheticStep.js +1 -1
- package/mablscript/steps/VisitUrlStep.js +22 -30
- package/mablscript/steps/WaitStep.js +9 -20
- package/mablscript/steps/WaitUntilStep.js +14 -31
- package/mablscript/types/ConditionDescriptor.js +5 -5
- package/mablscript/types/GetVariableDescriptor.js +8 -0
- package/package.json +1 -1
- package/mablscript/steps/StepGroupStep.js +0 -70
- package/mablscript/types/AssertStepDescriptor.js +0 -2
- package/mablscript/types/StepGroupStepDescriptor.js +0 -2
package/mablscript/MablStepV2.js
CHANGED
|
@@ -10,73 +10,43 @@ class MablStepV2 extends MablStep_1.MablStep {
|
|
|
10
10
|
super(name, [], [], actionCode);
|
|
11
11
|
this.stepVersion = 2;
|
|
12
12
|
this.descriptor = descriptor;
|
|
13
|
-
this.descriptor.actionCode = actionCode;
|
|
14
|
-
this.description = descriptor.description;
|
|
15
|
-
this.disabled = descriptor.disabled;
|
|
16
13
|
}
|
|
17
14
|
stepId() {
|
|
18
|
-
return this.descriptor.id
|
|
15
|
+
return this.descriptor.id;
|
|
19
16
|
}
|
|
20
17
|
setStepId(id) {
|
|
21
|
-
super.setStepId(id);
|
|
22
18
|
this.descriptor.id = id;
|
|
23
19
|
}
|
|
24
20
|
static fromYaml(stepName, stepDescriptor, actionCode) {
|
|
25
21
|
return new MablStepV2(stepName, stepDescriptor, actionCode);
|
|
26
22
|
}
|
|
27
|
-
static fromLegacyMablscript(_args, _actions) {
|
|
28
|
-
throw new Error('Legacy mablscript conversion not supported for MablStepV2 base class');
|
|
29
|
-
}
|
|
30
23
|
getStepName() {
|
|
31
24
|
return this.name;
|
|
32
25
|
}
|
|
33
|
-
getActionName() {
|
|
34
|
-
return this.actionCode ?? super.getActionName();
|
|
35
|
-
}
|
|
36
26
|
toStepDescriptor() {
|
|
37
27
|
return this.descriptor;
|
|
38
28
|
}
|
|
39
29
|
getFormattedStep(_fullLocatorsOn) {
|
|
40
|
-
const { descriptorToActionMap, ...stepDescriptor } = this.toStepDescriptor();
|
|
41
|
-
const result = {
|
|
42
|
-
description: this.getDescription(),
|
|
43
|
-
...stepDescriptor,
|
|
44
|
-
};
|
|
45
|
-
if (this.annotation?.description || this.annotation?.note) {
|
|
46
|
-
result.annotation = this.annotation;
|
|
47
|
-
}
|
|
48
|
-
if (this.isDisabled()) {
|
|
49
|
-
result.disabled = true;
|
|
50
|
-
}
|
|
51
30
|
return {
|
|
52
|
-
[this.getStepName()]:
|
|
31
|
+
[this.getStepName()]: {
|
|
32
|
+
description: this.stepDescription(),
|
|
33
|
+
...this.descriptor,
|
|
34
|
+
},
|
|
53
35
|
};
|
|
54
36
|
}
|
|
55
|
-
getDescription() {
|
|
56
|
-
return (this.description ?? this.descriptor.description ?? this.stepDescription());
|
|
57
|
-
}
|
|
58
|
-
setDescription(description) {
|
|
59
|
-
this.description = description;
|
|
60
|
-
this.descriptor.description = description;
|
|
61
|
-
}
|
|
62
37
|
stepDescription() {
|
|
63
38
|
throw new Error('Step description not implemented');
|
|
64
39
|
}
|
|
65
40
|
isDisabled() {
|
|
66
|
-
return !!this.disabled;
|
|
41
|
+
return !!this.descriptor.disabled;
|
|
67
42
|
}
|
|
68
43
|
setDisabled(disabled) {
|
|
69
|
-
this.disabled = disabled;
|
|
70
44
|
this.descriptor.disabled = disabled;
|
|
71
45
|
}
|
|
72
|
-
canContinueOnFailure() {
|
|
73
|
-
return false;
|
|
74
|
-
}
|
|
75
|
-
canFailAtEnd() {
|
|
76
|
-
return false;
|
|
77
|
-
}
|
|
78
46
|
getDescriptionForLogging() {
|
|
79
|
-
return this.annotation?.description
|
|
47
|
+
return (this.annotation?.description ||
|
|
48
|
+
this.stepDescription() ||
|
|
49
|
+
this.getStepName());
|
|
80
50
|
}
|
|
81
51
|
toLineDiffFormat() {
|
|
82
52
|
const lineDiffProperties = {
|
|
@@ -91,7 +61,7 @@ exports.MablStepV2 = MablStepV2;
|
|
|
91
61
|
MablStepV2.mablScriptStepNames = [];
|
|
92
62
|
MablStepV2.yamlMablScriptNames = ['MablStepV2'];
|
|
93
63
|
function isMablStepV2(value) {
|
|
94
|
-
if (
|
|
64
|
+
if (value === undefined || value === null) {
|
|
95
65
|
return false;
|
|
96
66
|
}
|
|
97
67
|
const mablStep = value;
|
|
@@ -2,134 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MablStepWithFindAction = void 0;
|
|
4
4
|
exports.isStepWithFindAction = isStepWithFindAction;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
exports.humanizeQuery = humanizeQuery;
|
|
8
|
-
exports.humanizeFindEmail = humanizeFindEmail;
|
|
9
|
-
exports.humanizeFindCookie = humanizeFindCookie;
|
|
10
|
-
exports.humanizeFindTab = humanizeFindTab;
|
|
11
|
-
exports.getTagNameFromFoundSelectors = getTagNameFromFoundSelectors;
|
|
12
|
-
exports.isCustomFindDescriptor = isCustomFindDescriptor;
|
|
13
|
-
exports.isEmailFindDescriptor = isEmailFindDescriptor;
|
|
14
|
-
exports.isCookieFindDescriptor = isCookieFindDescriptor;
|
|
15
|
-
exports.isTabFindDescriptor = isTabFindDescriptor;
|
|
16
|
-
const MablStepV2_1 = require("./MablStepV2");
|
|
17
|
-
const domUtil_1 = require("../domUtil");
|
|
18
|
-
const mablscriptFind_1 = require("../mablscriptFind");
|
|
19
|
-
const stepUtil_1 = require("./mobile/steps/stepUtil");
|
|
20
|
-
class MablStepWithFindAction extends MablStepV2_1.MablStepV2 {
|
|
21
|
-
constructor(name, descriptor, actionCode, findAction) {
|
|
22
|
-
super(name, descriptor, actionCode);
|
|
23
|
-
this.findAction = findAction;
|
|
24
|
-
}
|
|
25
|
-
humanizeFind() {
|
|
26
|
-
const findDescriptor = this.findAction.toDescriptor();
|
|
27
|
-
return humanizeFindDescriptor(findDescriptor);
|
|
28
|
-
}
|
|
5
|
+
const MablStep_1 = require("./MablStep");
|
|
6
|
+
class MablStepWithFindAction extends MablStep_1.MablStep {
|
|
29
7
|
}
|
|
30
8
|
exports.MablStepWithFindAction = MablStepWithFindAction;
|
|
31
9
|
function isStepWithFindAction(step) {
|
|
32
10
|
return step instanceof MablStepWithFindAction || 'findAction' in step;
|
|
33
11
|
}
|
|
34
|
-
function humanizeFindDescriptor(findDescriptor) {
|
|
35
|
-
switch (findDescriptor.findType) {
|
|
36
|
-
case domUtil_1.FindType.FIND_FIRST:
|
|
37
|
-
case domUtil_1.FindType.FIND_LAST:
|
|
38
|
-
case domUtil_1.FindType.FIND_ALL:
|
|
39
|
-
return humanizeCustomFind(findDescriptor);
|
|
40
|
-
case domUtil_1.FindType.FIND_ONE:
|
|
41
|
-
const maybeMobileFindDescriptor = (0, domUtil_1.isMobileFindSpecification)(findDescriptor.findTarget)
|
|
42
|
-
? {
|
|
43
|
-
findTarget: { ...findDescriptor.findTarget },
|
|
44
|
-
findType: findDescriptor.findType,
|
|
45
|
-
}
|
|
46
|
-
: findDescriptor;
|
|
47
|
-
if ((0, domUtil_1.isMobileFindDescriptor)(maybeMobileFindDescriptor)) {
|
|
48
|
-
return (0, stepUtil_1.getElementDescriptionFromMobileFindDescriptor)(maybeMobileFindDescriptor);
|
|
49
|
-
}
|
|
50
|
-
return (0, mablscriptFind_1.humanizeFindOneDescriptor)(findDescriptor.findTarget);
|
|
51
|
-
case domUtil_1.FindType.FIND_EMAIL:
|
|
52
|
-
return humanizeFindEmail(findDescriptor);
|
|
53
|
-
case domUtil_1.FindType.FIND_COOKIE:
|
|
54
|
-
return humanizeFindCookie(findDescriptor);
|
|
55
|
-
case domUtil_1.FindType.FIND_TAB:
|
|
56
|
-
return humanizeFindTab(findDescriptor);
|
|
57
|
-
default:
|
|
58
|
-
return 'element';
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
function humanizeCustomFind(findDescriptor) {
|
|
62
|
-
if (!isCustomFindDescriptor(findDescriptor)) {
|
|
63
|
-
return 'element';
|
|
64
|
-
}
|
|
65
|
-
const type = findDescriptor.findType.replace('find_', '');
|
|
66
|
-
let tagText;
|
|
67
|
-
const foundElementSelectors = findDescriptor.foundElementSelectors;
|
|
68
|
-
const tagName = getTagNameFromFoundSelectors(foundElementSelectors);
|
|
69
|
-
if (tagName) {
|
|
70
|
-
tagText = `${type} ${tagName.toLowerCase()} element`;
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
const s = findDescriptor.findType === domUtil_1.FindType.FIND_ALL ? 's' : '';
|
|
74
|
-
tagText = `${type} element${s}`;
|
|
75
|
-
}
|
|
76
|
-
return `${tagText} ${humanizeQuery(findDescriptor)}`;
|
|
77
|
-
}
|
|
78
|
-
function humanizeQuery(findDescriptor) {
|
|
79
|
-
const primarySelectors = findDescriptor.primarySelectors;
|
|
80
|
-
if ((0, domUtil_1.isCssSelector)(primarySelectors)) {
|
|
81
|
-
const compactQuery = primarySelectors.css_query.replace(/\s+/g, ' ').trim();
|
|
82
|
-
return `matching css query "${compactQuery}"`;
|
|
83
|
-
}
|
|
84
|
-
else if ((0, domUtil_1.isXPathSelector)(primarySelectors)) {
|
|
85
|
-
const compactQuery = primarySelectors.xpath.replace(/\s+/g, ' ').trim();
|
|
86
|
-
return `matching xpath "${compactQuery}"`;
|
|
87
|
-
}
|
|
88
|
-
return 'matching "<unrecognized query>"';
|
|
89
|
-
}
|
|
90
|
-
function humanizeFindEmail(findDescriptor) {
|
|
91
|
-
if (!isEmailFindDescriptor(findDescriptor)) {
|
|
92
|
-
return 'email';
|
|
93
|
-
}
|
|
94
|
-
return (0, mablscriptFind_1.humanizeEmailSelector)(findDescriptor.findTarget.selector);
|
|
95
|
-
}
|
|
96
|
-
function humanizeFindCookie(findDescriptor) {
|
|
97
|
-
if (!isCookieFindDescriptor(findDescriptor)) {
|
|
98
|
-
return 'cookie';
|
|
99
|
-
}
|
|
100
|
-
return (0, mablscriptFind_1.humanizeCookieSelector)(findDescriptor.findTarget);
|
|
101
|
-
}
|
|
102
|
-
function humanizeFindTab(findDescriptor) {
|
|
103
|
-
if (!isTabFindDescriptor(findDescriptor)) {
|
|
104
|
-
return 'tab';
|
|
105
|
-
}
|
|
106
|
-
if (findDescriptor.findTarget === 'initial') {
|
|
107
|
-
return 'the initial tab';
|
|
108
|
-
}
|
|
109
|
-
return (0, mablscriptFind_1.humanizeTabSelector)(findDescriptor.findTarget);
|
|
110
|
-
}
|
|
111
|
-
function getTagNameFromFoundSelectors(foundElementSelectors) {
|
|
112
|
-
if (!foundElementSelectors) {
|
|
113
|
-
return undefined;
|
|
114
|
-
}
|
|
115
|
-
if (typeof foundElementSelectors === 'object' &&
|
|
116
|
-
'tag_name' in foundElementSelectors) {
|
|
117
|
-
return foundElementSelectors.tag_name;
|
|
118
|
-
}
|
|
119
|
-
return undefined;
|
|
120
|
-
}
|
|
121
|
-
function isCustomFindDescriptor(descriptor) {
|
|
122
|
-
return ((descriptor.findType === domUtil_1.FindType.FIND_FIRST ||
|
|
123
|
-
descriptor.findType === domUtil_1.FindType.FIND_LAST ||
|
|
124
|
-
descriptor.findType === domUtil_1.FindType.FIND_ALL) &&
|
|
125
|
-
'primarySelectors' in descriptor);
|
|
126
|
-
}
|
|
127
|
-
function isEmailFindDescriptor(descriptor) {
|
|
128
|
-
return descriptor.findType === domUtil_1.FindType.FIND_EMAIL;
|
|
129
|
-
}
|
|
130
|
-
function isCookieFindDescriptor(descriptor) {
|
|
131
|
-
return descriptor.findType === domUtil_1.FindType.FIND_COOKIE;
|
|
132
|
-
}
|
|
133
|
-
function isTabFindDescriptor(descriptor) {
|
|
134
|
-
return descriptor.findType === domUtil_1.FindType.FIND_TAB;
|
|
135
|
-
}
|
|
@@ -3,13 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AwaitDownloadAction = void 0;
|
|
4
4
|
const MablAction_1 = require("../MablAction");
|
|
5
5
|
class AwaitDownloadAction extends MablAction_1.MablAction {
|
|
6
|
-
constructor(
|
|
7
|
-
super(
|
|
6
|
+
constructor(name, args) {
|
|
7
|
+
super(name, 'await_download', args);
|
|
8
8
|
}
|
|
9
9
|
toMablscript() {
|
|
10
10
|
return 'await_download()';
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
exports.AwaitDownloadAction = AwaitDownloadAction;
|
|
14
|
-
AwaitDownloadAction.
|
|
15
|
-
AwaitDownloadAction.mablScriptStepNames = [AwaitDownloadAction.actionCode];
|
|
14
|
+
AwaitDownloadAction.mablScriptStepNames = ['await_download'];
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AwaitPDFDownloadAction = void 0;
|
|
4
|
-
const
|
|
4
|
+
const AwaitDownloadAction_1 = require("./AwaitDownloadAction");
|
|
5
5
|
const domUtil_1 = require("../../domUtil");
|
|
6
|
-
class AwaitPDFDownloadAction extends
|
|
7
|
-
constructor(
|
|
8
|
-
super(
|
|
6
|
+
class AwaitPDFDownloadAction extends AwaitDownloadAction_1.AwaitDownloadAction {
|
|
7
|
+
constructor(name, args) {
|
|
8
|
+
super(name, args);
|
|
9
9
|
this.pdfUUID = this.getActionArgs()[0].uuid;
|
|
10
10
|
}
|
|
11
11
|
toMablscript() {
|
|
@@ -16,5 +16,4 @@ class AwaitPDFDownloadAction extends MablAction_1.MablAction {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
exports.AwaitPDFDownloadAction = AwaitPDFDownloadAction;
|
|
19
|
-
AwaitPDFDownloadAction.
|
|
20
|
-
AwaitPDFDownloadAction.mablScriptStepNames = [AwaitPDFDownloadAction.actionCode];
|
|
19
|
+
AwaitPDFDownloadAction.mablScriptStepNames = ['await_pdf'];
|
|
@@ -40,8 +40,7 @@ class ConditionAction extends MablAction_1.MablAction {
|
|
|
40
40
|
if (!(0, ConditionDescriptor_1.isComparisonType)(conditionAttribute)) {
|
|
41
41
|
throw new Error(`Invalid equality condition. Invalid comparison type: ${conditionAttribute}`);
|
|
42
42
|
}
|
|
43
|
-
if (options
|
|
44
|
-
Object.values(options).some((value) => value !== undefined)) {
|
|
43
|
+
if (options) {
|
|
45
44
|
this.hasOptionsAtInstantiation = true;
|
|
46
45
|
}
|
|
47
46
|
return {
|
|
@@ -21,25 +21,30 @@ class ExtractAction extends MablAction_1.MablAction {
|
|
|
21
21
|
else {
|
|
22
22
|
this.extractionAttribute = this.getActionArgs()[0];
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const extractionOptions = actionArgs[1];
|
|
24
|
+
if (this.name === ExtractDescriptor_1.ExtractType.EXTRACT_ATTRIBUTE && this.args.length > 1) {
|
|
25
|
+
const extractionOptions = this.args[1];
|
|
27
26
|
const metaExtractionType = extractionOptions.extraction_type;
|
|
28
27
|
if (metaExtractionType?.toLowerCase() === exports.CSS_EXTRACTION_VALUE) {
|
|
29
|
-
this.
|
|
28
|
+
this.extractionType = ExtractDescriptor_1.ExtractType.EXTRACT_CSS_PROPERTIES.toString();
|
|
30
29
|
}
|
|
30
|
+
else {
|
|
31
|
+
this.extractionType = this.name;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
this.extractionType = this.name;
|
|
31
36
|
}
|
|
32
|
-
this.
|
|
37
|
+
this.extractDescriptor = this.getExtractDescriptor();
|
|
38
|
+
}
|
|
39
|
+
getExtractDescriptor() {
|
|
33
40
|
if (!this.extractionAttribute) {
|
|
34
41
|
throw new Error(`Attribute name is required for extract attribute action.`);
|
|
35
42
|
}
|
|
36
43
|
if (typeof this.extractionAttribute !== 'string') {
|
|
37
44
|
throw new Error(`Invalid attribute provided for extract attribute extractor: ${this.extractionAttribute}`);
|
|
38
45
|
}
|
|
39
|
-
}
|
|
40
|
-
toDescriptor() {
|
|
41
46
|
return {
|
|
42
|
-
extractType: this.extractionType,
|
|
47
|
+
extractType: ExtractDescriptor_1.ExtractType.fromString(this.extractionType),
|
|
43
48
|
attributeName: this.extractionAttribute,
|
|
44
49
|
};
|
|
45
50
|
}
|
|
@@ -112,26 +112,6 @@ class FindAction extends MablAction_1.MablAction {
|
|
|
112
112
|
}
|
|
113
113
|
static findActionFromStepArgs(stepArgs, suppliedFindType) {
|
|
114
114
|
let findType;
|
|
115
|
-
if (stepArgs.find) {
|
|
116
|
-
findType = stepArgs.find.findType || 'find_one';
|
|
117
|
-
const findTarget = stepArgs.find.findTarget;
|
|
118
|
-
const findOptions = stepArgs.find.findOptions;
|
|
119
|
-
if (findType === 'find_one' && findTarget.selector) {
|
|
120
|
-
if (findTarget.auxiliaryDescriptors?.length) {
|
|
121
|
-
const ancestors = findTarget.auxiliaryDescriptors.map((descriptor) => descriptor.selector);
|
|
122
|
-
return new FindAction(findType, [
|
|
123
|
-
[findTarget, ...ancestors],
|
|
124
|
-
findOptions,
|
|
125
|
-
]);
|
|
126
|
-
}
|
|
127
|
-
return new FindAction(findType, [findTarget, findOptions]);
|
|
128
|
-
}
|
|
129
|
-
return new FindAction(findType, [
|
|
130
|
-
findTarget,
|
|
131
|
-
stepArgs.find.foundElementSelectors,
|
|
132
|
-
findOptions,
|
|
133
|
-
]);
|
|
134
|
-
}
|
|
135
115
|
if (stepArgs.selector) {
|
|
136
116
|
if (suppliedFindType) {
|
|
137
117
|
findType = suppliedFindType;
|
|
@@ -11,23 +11,13 @@ class GetVariableValue extends MablAction_1.MablAction {
|
|
|
11
11
|
if (typeof arg !== 'string') {
|
|
12
12
|
throw new Error('Expected string argument');
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
if (legacyPatternMatches) {
|
|
16
|
-
this.variable = new MablSymbol_1.MablSymbol(legacyPatternMatches[1]);
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
this.variable = new MablSymbol_1.MablSymbol(arg);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
static buildAction(variable) {
|
|
23
|
-
const variableName = typeof variable === 'string' ? variable : variable.name;
|
|
24
|
-
return new GetVariableValue(GetVariableValue.actionCode, [variableName]);
|
|
14
|
+
this.variable = MablSymbol_1.MablSymbol.fromString(arg);
|
|
25
15
|
}
|
|
26
16
|
toMablscript() {
|
|
27
17
|
return `get_variable_value(${this.subVariable(this.variable.toString())})`;
|
|
28
18
|
}
|
|
29
19
|
toDescriptor() {
|
|
30
|
-
return
|
|
20
|
+
return (0, GetVariableDescriptor_1.newGetVariableDescriptor)(this.variable);
|
|
31
21
|
}
|
|
32
22
|
generateFindMablscript() {
|
|
33
23
|
return `get_variable_value(${this.variable.name})`;
|
|
@@ -37,6 +27,5 @@ class GetVariableValue extends MablAction_1.MablAction {
|
|
|
37
27
|
}
|
|
38
28
|
}
|
|
39
29
|
exports.GetVariableValue = GetVariableValue;
|
|
40
|
-
GetVariableValue.
|
|
41
|
-
GetVariableValue.
|
|
42
|
-
GetVariableValue.yamlMablScriptNames = [GetVariableDescriptor_1.GET_VARIABLE_VALUE];
|
|
30
|
+
GetVariableValue.mablScriptStepNames = ['get_variable_value'];
|
|
31
|
+
GetVariableValue.yamlMablScriptNames = ['GetVariableValueAs'];
|
|
@@ -109,44 +109,58 @@ class JavaScriptAction extends MablAction_1.MablAction {
|
|
|
109
109
|
}
|
|
110
110
|
throw new Error(`Invalid javascript action descriptor: ${JSON.stringify(descriptor)}`);
|
|
111
111
|
}
|
|
112
|
+
toYaml() {
|
|
113
|
+
return JavaScriptAction.toYamlFromJavaScriptDescriptor(this.javaScript);
|
|
114
|
+
}
|
|
115
|
+
static toYamlFromJavaScriptDescriptor(javaScript) {
|
|
116
|
+
const actionYaml = {};
|
|
117
|
+
if ((0, SnippetsDescriptor_1.isReusableSnippetDescriptor)(javaScript)) {
|
|
118
|
+
actionYaml.snippetId = javaScript.snippetId;
|
|
119
|
+
actionYaml.snippetInvariantId = javaScript.snippetInvariantId;
|
|
120
|
+
actionYaml.parameterOverrides = javaScript.parameterOverrides;
|
|
121
|
+
}
|
|
122
|
+
else if ((0, SnippetsDescriptor_1.isInlineSnippetDescriptor)(javaScript)) {
|
|
123
|
+
actionYaml.snippet = { ...actionYaml, ...javaScript.inlineSnippet };
|
|
124
|
+
actionYaml.parameterOverrides = javaScript.parameterOverrides;
|
|
125
|
+
}
|
|
126
|
+
else if ((0, SnippetsDescriptor_1.isLegacyReusableSnippetDescriptor)(javaScript)) {
|
|
127
|
+
actionYaml.snippetId = javaScript.snippetInvariantId;
|
|
128
|
+
}
|
|
129
|
+
else if ((0, SnippetsDescriptor_1.isLegacyInlineJavaScriptDescriptor)(javaScript)) {
|
|
130
|
+
actionYaml.code = javaScript.encodedJS;
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
throw new Error(`Cannot export action to yaml: ${JSON.stringify(javaScript)}`);
|
|
134
|
+
}
|
|
135
|
+
return actionYaml;
|
|
136
|
+
}
|
|
112
137
|
static fromYaml(formatted) {
|
|
113
|
-
const jsDescriptor = formatted.javaScript ?? formatted;
|
|
114
138
|
let snippetOptions;
|
|
115
|
-
if (
|
|
139
|
+
if (formatted.parameterOverrides) {
|
|
116
140
|
snippetOptions = {
|
|
117
|
-
parameter_overrides:
|
|
141
|
+
parameter_overrides: formatted.parameterOverrides,
|
|
118
142
|
};
|
|
119
143
|
}
|
|
120
144
|
const args = [];
|
|
121
|
-
if (
|
|
122
|
-
args.push(
|
|
123
|
-
}
|
|
124
|
-
else if (jsDescriptor.encodedJS) {
|
|
125
|
-
args.push(jsDescriptor.encodedJS);
|
|
145
|
+
if (formatted.code) {
|
|
146
|
+
args.push(formatted.code);
|
|
126
147
|
}
|
|
127
|
-
else if (
|
|
128
|
-
|
|
148
|
+
else if (formatted.body) {
|
|
149
|
+
delete formatted.parameterOverrides;
|
|
150
|
+
args.push(formatted);
|
|
129
151
|
}
|
|
130
|
-
else if (
|
|
131
|
-
args.push(
|
|
132
|
-
}
|
|
133
|
-
else if (jsDescriptor.snippet) {
|
|
134
|
-
args.push(jsDescriptor.snippet);
|
|
135
|
-
}
|
|
136
|
-
else if (jsDescriptor.snippetInvariantId && jsDescriptor.snippetId) {
|
|
137
|
-
args.push({
|
|
138
|
-
id: jsDescriptor.snippetId,
|
|
139
|
-
invariant_id: jsDescriptor.snippetInvariantId,
|
|
140
|
-
});
|
|
152
|
+
else if (formatted.snippet) {
|
|
153
|
+
args.push(formatted.snippet);
|
|
141
154
|
}
|
|
142
|
-
else if (
|
|
155
|
+
else if (formatted.snippetInvariantId && formatted.snippetId) {
|
|
143
156
|
args.push({
|
|
144
|
-
id:
|
|
157
|
+
id: formatted.snippetId,
|
|
158
|
+
invariant_id: formatted.snippetInvariantId,
|
|
145
159
|
});
|
|
146
160
|
}
|
|
147
|
-
else if (
|
|
161
|
+
else if (formatted.snippetId) {
|
|
148
162
|
args.push({
|
|
149
|
-
id:
|
|
163
|
+
id: formatted.snippetId,
|
|
150
164
|
});
|
|
151
165
|
}
|
|
152
166
|
else {
|
|
@@ -62,10 +62,7 @@ function convertFlowToStepList(flow, flowConfig) {
|
|
|
62
62
|
flow.flow_type === mablApi_1.FlowTypeEnum.Mobile)) {
|
|
63
63
|
return parseFlowIntoStepList(flow);
|
|
64
64
|
}
|
|
65
|
-
const evaluateFlowStep = new EvaluateFlowStep_1.EvaluateFlowStep({
|
|
66
|
-
flow: { invariant_id: flow?.invariant_id ?? '' },
|
|
67
|
-
config: flowConfig,
|
|
68
|
-
});
|
|
65
|
+
const evaluateFlowStep = new EvaluateFlowStep_1.EvaluateFlowStep(EvaluateFlowStep_1.EvaluateFlowStep.mablScriptStepNames[0], [{ invariant_id: flow?.invariant_id }, flowConfig], []);
|
|
69
66
|
if (flow.description) {
|
|
70
67
|
evaluateFlowStep.setDescription(flow.description);
|
|
71
68
|
}
|
|
@@ -94,9 +91,12 @@ function convertStepListToFlow(steps, flowType = mablApi_1.FlowTypeEnum.Mablscri
|
|
|
94
91
|
return annotations;
|
|
95
92
|
}, {});
|
|
96
93
|
const flow = {
|
|
97
|
-
json_steps: flowType === mablApi_1.FlowTypeEnum.
|
|
94
|
+
json_steps: flowType === mablApi_1.FlowTypeEnum.Mobile
|
|
98
95
|
? { steps: steps.map((step) => step.getFormattedStep(true)) }
|
|
99
96
|
: undefined,
|
|
97
|
+
script: flowType === mablApi_1.FlowTypeEnum.Mablscript
|
|
98
|
+
? addTrailingNewline((0, importer_1.mablscriptTheLoadedSteps)(steps))
|
|
99
|
+
: undefined,
|
|
100
100
|
script_description: steps.map(getStepDescription).join('\n'),
|
|
101
101
|
step_annotations: stepAnnotations,
|
|
102
102
|
};
|