@mablhq/mabl-cli 2.72.0 → 2.72.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/browserLauncher/index.js +3 -3
- 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 +3 -3
- package/mablscript/steps/StepGroupStep.js +0 -70
- package/mablscript/types/AssertStepDescriptor.js +0 -2
- package/mablscript/types/StepGroupStepDescriptor.js +0 -2
|
@@ -3,46 +3,35 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.EvaluateFlowStep = exports.EVALUATE_FLOW_STEP_NAME = void 0;
|
|
4
4
|
exports.isEvaluateFlowStep = isEvaluateFlowStep;
|
|
5
5
|
const domUtil_1 = require("../../domUtil");
|
|
6
|
-
const
|
|
7
|
-
const MablStepV2_1 = require("../MablStepV2");
|
|
6
|
+
const MablStep_1 = require("../MablStep");
|
|
8
7
|
exports.EVALUATE_FLOW_STEP_NAME = 'EvaluateFlow';
|
|
9
|
-
class EvaluateFlowStep extends
|
|
10
|
-
constructor(
|
|
11
|
-
super(
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
class EvaluateFlowStep extends MablStep_1.MablStep {
|
|
9
|
+
constructor(name, args, actions) {
|
|
10
|
+
super(name, args, actions, 'evaluate_flow');
|
|
11
|
+
if (args.length < 1 || args.length > 2) {
|
|
12
|
+
throw new Error('EvaluateFlowStep expects 1 or 2 arguments');
|
|
13
|
+
}
|
|
14
|
+
this.flowDescriptor = this.getActionArgs()[0];
|
|
15
|
+
if (args.length === 2) {
|
|
16
|
+
this.config = this.getActionArgs()[1];
|
|
17
|
+
}
|
|
14
18
|
}
|
|
15
19
|
getStepName() {
|
|
16
|
-
return
|
|
20
|
+
return exports.EVALUATE_FLOW_STEP_NAME;
|
|
17
21
|
}
|
|
18
22
|
toStepDescriptor() {
|
|
19
23
|
return {
|
|
20
|
-
|
|
21
|
-
flow: { invariant_id: this.flowDescriptor.invariant_id },
|
|
24
|
+
descriptor: this.flowDescriptor,
|
|
22
25
|
config: this.config,
|
|
26
|
+
actionCode: this.actionCode,
|
|
23
27
|
};
|
|
24
28
|
}
|
|
25
|
-
stepDescription() {
|
|
26
|
-
return `Evaluate Flow "${this.flowDescriptor.invariant_id}"`;
|
|
27
|
-
}
|
|
28
29
|
static fromYaml(_stepName, stepArgs) {
|
|
29
|
-
const {
|
|
30
|
-
const step = new EvaluateFlowStep(
|
|
30
|
+
const { descriptor, config } = stepArgs;
|
|
31
|
+
const step = new EvaluateFlowStep(EvaluateFlowStep.mablScriptStepNames[0], [descriptor, config], []);
|
|
31
32
|
step.setStepId(stepArgs.id);
|
|
32
33
|
return step;
|
|
33
34
|
}
|
|
34
|
-
static fromLegacyMablscript(args, _actions) {
|
|
35
|
-
if (args.length < 1 || args.length > 2) {
|
|
36
|
-
throw new Error(`EvaluateFlowStep.fromLegacyMablscript expects 1 or 2 arguments but received ${args.length}`);
|
|
37
|
-
}
|
|
38
|
-
const flowDescriptor = args[0];
|
|
39
|
-
const config = args.length === 2 ? args[1] : undefined;
|
|
40
|
-
const stepDescriptor = {
|
|
41
|
-
flow: flowDescriptor,
|
|
42
|
-
config,
|
|
43
|
-
};
|
|
44
|
-
return new EvaluateFlowStep(stepDescriptor);
|
|
45
|
-
}
|
|
46
35
|
toMablscript() {
|
|
47
36
|
const flowReference = (0, domUtil_1.buildStepArgumentString)({
|
|
48
37
|
params: { ...this.flowDescriptor },
|
|
@@ -53,20 +42,10 @@ class EvaluateFlowStep extends MablStepV2_1.MablStepV2 {
|
|
|
53
42
|
: '';
|
|
54
43
|
return `${EvaluateFlowStep.mablScriptStepNames[0]}(${flowReference}${flowConfig})`;
|
|
55
44
|
}
|
|
56
|
-
getInputVariables() {
|
|
57
|
-
return (0, MablAction_1.distinctStrings)([
|
|
58
|
-
...MablAction_1.MablAction.findUniqueVariableReferencesInValue(this.flowDescriptor),
|
|
59
|
-
...(this.config
|
|
60
|
-
? MablAction_1.MablAction.findUniqueVariableReferencesInValue(this.config)
|
|
61
|
-
: []),
|
|
62
|
-
]);
|
|
63
|
-
}
|
|
64
45
|
}
|
|
65
46
|
exports.EvaluateFlowStep = EvaluateFlowStep;
|
|
66
|
-
EvaluateFlowStep.
|
|
67
|
-
EvaluateFlowStep.
|
|
68
|
-
EvaluateFlowStep.mablScriptStepNames = [EvaluateFlowStep.actionCode];
|
|
69
|
-
EvaluateFlowStep.yamlMablScriptNames = [EvaluateFlowStep.stepName];
|
|
47
|
+
EvaluateFlowStep.mablScriptStepNames = ['evaluate_flow'];
|
|
48
|
+
EvaluateFlowStep.yamlMablScriptNames = [exports.EVALUATE_FLOW_STEP_NAME];
|
|
70
49
|
function isEvaluateFlowStep(step) {
|
|
71
50
|
return step?.getStepName() === exports.EVALUATE_FLOW_STEP_NAME;
|
|
72
51
|
}
|
|
@@ -2,45 +2,47 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EvaluateJavaScriptStep = void 0;
|
|
4
4
|
exports.isEvaluateJavaScriptStep = isEvaluateJavaScriptStep;
|
|
5
|
-
const
|
|
5
|
+
const MablStep_1 = require("../MablStep");
|
|
6
6
|
const JavaScriptAction_1 = require("../actions/JavaScriptAction");
|
|
7
7
|
const STEP_NAME = 'EvaluateJavaScript';
|
|
8
|
-
class EvaluateJavaScriptStep extends
|
|
9
|
-
constructor(
|
|
10
|
-
super(
|
|
11
|
-
this.evaluateJsAction = JavaScriptAction_1.JavaScriptAction.
|
|
8
|
+
class EvaluateJavaScriptStep extends MablStep_1.MablStep {
|
|
9
|
+
constructor(name, args, actions) {
|
|
10
|
+
super(name, args, actions || [], 'evaluate_js');
|
|
11
|
+
this.evaluateJsAction = new JavaScriptAction_1.JavaScriptAction(JavaScriptAction_1.JavaScriptAction.mablscriptName, args);
|
|
12
12
|
}
|
|
13
13
|
getStepName() {
|
|
14
|
-
return
|
|
14
|
+
return STEP_NAME;
|
|
15
15
|
}
|
|
16
16
|
toStepDescriptor() {
|
|
17
17
|
return this.evaluateJsAction.toDescriptor();
|
|
18
18
|
}
|
|
19
|
+
getFormattedStep() {
|
|
20
|
+
const step = {
|
|
21
|
+
[STEP_NAME]: {
|
|
22
|
+
...super.annotationsAsYml(),
|
|
23
|
+
...this.evaluateJsAction.toYaml(),
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
if (this.stepId()) {
|
|
27
|
+
step[STEP_NAME].id = this.stepId();
|
|
28
|
+
}
|
|
29
|
+
return step;
|
|
30
|
+
}
|
|
19
31
|
static fromYaml(_stepName, stepArgs) {
|
|
20
32
|
const evaluateJsAction = JavaScriptAction_1.JavaScriptAction.fromYaml(stepArgs);
|
|
21
|
-
const
|
|
22
|
-
const step = new EvaluateJavaScriptStep(stepDescriptor);
|
|
33
|
+
const step = new EvaluateJavaScriptStep(evaluateJsAction.name, evaluateJsAction.args);
|
|
23
34
|
step.setStepId(stepArgs.id);
|
|
24
35
|
return step;
|
|
25
36
|
}
|
|
26
|
-
static fromLegacyMablscript(args, _actions) {
|
|
27
|
-
const evaluateJsAction = new JavaScriptAction_1.JavaScriptAction(JavaScriptAction_1.JavaScriptAction.mablscriptName, args);
|
|
28
|
-
const stepDescriptor = evaluateJsAction.toDescriptor();
|
|
29
|
-
return new EvaluateJavaScriptStep(stepDescriptor);
|
|
30
|
-
}
|
|
31
37
|
toMablscript() {
|
|
32
38
|
return this.evaluateJsAction.toMablscript();
|
|
33
39
|
}
|
|
34
40
|
getInputVariables() {
|
|
35
41
|
return this.evaluateJsAction.getInputVariables();
|
|
36
42
|
}
|
|
37
|
-
stepDescription() {
|
|
38
|
-
return 'Evaluate JavaScript';
|
|
39
|
-
}
|
|
40
43
|
}
|
|
41
44
|
exports.EvaluateJavaScriptStep = EvaluateJavaScriptStep;
|
|
42
45
|
EvaluateJavaScriptStep.stepName = STEP_NAME;
|
|
43
|
-
EvaluateJavaScriptStep.actionCode = 'evaluate_js';
|
|
44
46
|
EvaluateJavaScriptStep.mablScriptStepNames = [JavaScriptAction_1.JavaScriptAction.mablscriptName];
|
|
45
47
|
EvaluateJavaScriptStep.yamlMablScriptNames = [STEP_NAME];
|
|
46
48
|
function isEvaluateJavaScriptStep(value) {
|
|
@@ -4,58 +4,60 @@ exports.HoverStep = void 0;
|
|
|
4
4
|
const FindAction_1 = require("../actions/FindAction");
|
|
5
5
|
const domUtil_1 = require("../../domUtil");
|
|
6
6
|
const MablStepWithFindAction_1 = require("../MablStepWithFindAction");
|
|
7
|
-
const ActionsUtils_1 = require("./ActionsUtils");
|
|
8
7
|
class HoverStep extends MablStepWithFindAction_1.MablStepWithFindAction {
|
|
9
|
-
constructor(
|
|
10
|
-
super(
|
|
8
|
+
constructor(name, args, actions) {
|
|
9
|
+
super(name, args, actions, 'hover');
|
|
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('Hover steps should have exactly on sub action and it should be a find');
|
|
16
|
+
}
|
|
11
17
|
}
|
|
12
18
|
getStepName() {
|
|
13
|
-
return
|
|
19
|
+
return 'Hover';
|
|
14
20
|
}
|
|
15
21
|
toStepDescriptor() {
|
|
16
|
-
|
|
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_ONE:
|
|
28
|
+
return {
|
|
29
|
+
find,
|
|
30
|
+
descriptorToActionMap: new Map().set(find, this.findAction),
|
|
31
|
+
actionCode: this.actionCode,
|
|
32
|
+
};
|
|
33
|
+
default:
|
|
34
|
+
throw new Error(`Error generating step descriptor for ${this.getStepName()}: Unexpected find type ${find.findType}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
getFormattedStep(_fullLocatorsOn) {
|
|
38
|
+
const step = {
|
|
39
|
+
Hover: {
|
|
40
|
+
...super.annotationsAsYml(),
|
|
41
|
+
...this.findAction.toYaml(),
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
if (this.stepId()) {
|
|
45
|
+
step.Hover.id = this.stepId();
|
|
46
|
+
}
|
|
47
|
+
return step;
|
|
17
48
|
}
|
|
18
49
|
static fromYaml(_stepName, stepArgs) {
|
|
19
|
-
const
|
|
20
|
-
const stepDescriptor = buildStepDescriptor(findAction);
|
|
21
|
-
const step = new HoverStep(stepDescriptor, findAction);
|
|
50
|
+
const step = new HoverStep('hover', [], [FindAction_1.FindAction.findActionFromStepArgs(stepArgs)]);
|
|
22
51
|
step.setStepId(stepArgs.id);
|
|
23
52
|
return step;
|
|
24
53
|
}
|
|
25
|
-
static fromLegacyMablscript(_args, actions) {
|
|
26
|
-
const findAction = ActionsUtils_1.ActionsUtils.validateSingleFindAction(actions);
|
|
27
|
-
const stepDescriptor = buildStepDescriptor(findAction);
|
|
28
|
-
return new HoverStep(stepDescriptor, findAction);
|
|
29
|
-
}
|
|
30
54
|
toMablscript() {
|
|
31
55
|
return `${this.findAction.toMablscript()}.hover()`;
|
|
32
56
|
}
|
|
33
57
|
getInputVariables() {
|
|
34
58
|
return this.findAction.getInputVariables();
|
|
35
59
|
}
|
|
36
|
-
stepDescription() {
|
|
37
|
-
const elementDescription = this.humanizeFind();
|
|
38
|
-
return `Hover over ${elementDescription}`;
|
|
39
|
-
}
|
|
40
60
|
}
|
|
41
61
|
exports.HoverStep = HoverStep;
|
|
42
|
-
HoverStep.
|
|
43
|
-
HoverStep.
|
|
44
|
-
HoverStep.mablScriptStepNames = [HoverStep.actionCode];
|
|
45
|
-
HoverStep.yamlMablScriptNames = [HoverStep.stepName];
|
|
46
|
-
function buildStepDescriptor(findAction) {
|
|
47
|
-
const find = findAction.toDescriptor();
|
|
48
|
-
switch (find.findType) {
|
|
49
|
-
case domUtil_1.FindType.FIND_FIRST:
|
|
50
|
-
case domUtil_1.FindType.FIND_LAST:
|
|
51
|
-
case domUtil_1.FindType.FIND_ANY:
|
|
52
|
-
case domUtil_1.FindType.FIND_ONE:
|
|
53
|
-
return {
|
|
54
|
-
find,
|
|
55
|
-
descriptorToActionMap: new Map().set(find, findAction),
|
|
56
|
-
actionCode: HoverStep.actionCode,
|
|
57
|
-
};
|
|
58
|
-
default:
|
|
59
|
-
throw new Error(`Error generating step descriptor for ${HoverStep.stepName}: Unexpected find type ${find.findType}`);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
+
HoverStep.mablScriptStepNames = ['hover'];
|
|
63
|
+
HoverStep.yamlMablScriptNames = ['Hover'];
|
|
@@ -7,7 +7,7 @@ const GetVariableValue_1 = require("../actions/GetVariableValue");
|
|
|
7
7
|
const AssertStep_1 = require("./AssertStep");
|
|
8
8
|
const FindAction_1 = require("../actions/FindAction");
|
|
9
9
|
const MablAction_1 = require("../MablAction");
|
|
10
|
-
const
|
|
10
|
+
const MablStep_1 = require("../MablStep");
|
|
11
11
|
const ExtractAction_1 = require("../actions/ExtractAction");
|
|
12
12
|
const domUtil_1 = require("../../domUtil");
|
|
13
13
|
const JavaScriptAction_1 = require("../actions/JavaScriptAction");
|
|
@@ -15,21 +15,9 @@ const GetUrlAction_1 = require("../actions/GetUrlAction");
|
|
|
15
15
|
const ConditionDescriptor_1 = require("../types/ConditionDescriptor");
|
|
16
16
|
const GetViewportAction_1 = require("../actions/GetViewportAction");
|
|
17
17
|
const MobileFindAction_1 = require("../mobile/steps/actions/MobileFindAction");
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
super(stepName, descriptor, actionCode);
|
|
22
|
-
this.primaryAction = stepActions.primaryAction;
|
|
23
|
-
this.conditionAction = stepActions.conditionAction;
|
|
24
|
-
this.extractAction = stepActions.extractAction;
|
|
25
|
-
this.countAction = stepActions.countAction;
|
|
26
|
-
}
|
|
27
|
-
static fromLegacyMablscript(_args, actions) {
|
|
28
|
-
const validatedActions = IfConditionStep.validateAndParseActions(actions);
|
|
29
|
-
const stepDescriptor = IfConditionStep.buildDescriptor(validatedActions);
|
|
30
|
-
return new IfConditionStep(IfConditionStep.stepName, IfConditionStep.actionCode, stepDescriptor, validatedActions);
|
|
31
|
-
}
|
|
32
|
-
static validateAndParseActions(actions) {
|
|
18
|
+
class IfConditionStep extends MablStep_1.MablStep {
|
|
19
|
+
constructor(name, args, actions) {
|
|
20
|
+
super(name, args, actions, 'conditional_if');
|
|
33
21
|
const candidatePrimaryActions = actions.filter((action) => action instanceof FindAction_1.FindAction ||
|
|
34
22
|
action instanceof MobileFindAction_1.MobileFindAction ||
|
|
35
23
|
action instanceof GetVariableValue_1.GetVariableValue ||
|
|
@@ -38,127 +26,106 @@ class IfConditionStep extends MablStepV2_1.MablStepV2 {
|
|
|
38
26
|
if (candidatePrimaryActions.length > 1) {
|
|
39
27
|
throw new Error(`Too many primary actions. Only one primary action is allowed of: Find, Get Url, Get Variable, or Javascript actions`);
|
|
40
28
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const countAction = actions.find((action) => action instanceof CountAction_1.CountAction);
|
|
44
|
-
let primaryAction;
|
|
29
|
+
this.conditionAction = actions.find((action) => action instanceof ConditionAction_1.ConditionAction);
|
|
30
|
+
this.extractAction = actions.find((action) => action instanceof ExtractAction_1.ExtractAction);
|
|
45
31
|
if (candidatePrimaryActions[0] === undefined) {
|
|
46
|
-
if (conditionAction !== undefined &&
|
|
47
|
-
(0, ConditionDescriptor_1.isAIPromptCondition)(conditionAction.conditionDescriptor)) {
|
|
48
|
-
primaryAction = new GetViewportAction_1.GetViewportAction();
|
|
32
|
+
if (this.conditionAction !== undefined &&
|
|
33
|
+
(0, ConditionDescriptor_1.isAIPromptCondition)(this.conditionAction.conditionDescriptor)) {
|
|
34
|
+
this.primaryAction = new GetViewportAction_1.GetViewportAction();
|
|
49
35
|
}
|
|
50
36
|
else {
|
|
51
37
|
throw new Error(`At least one primary action is required: Find, Get Url, Get Variable, or Javascript action.`);
|
|
52
38
|
}
|
|
53
39
|
}
|
|
54
40
|
else {
|
|
55
|
-
primaryAction = candidatePrimaryActions[0];
|
|
41
|
+
this.primaryAction = candidatePrimaryActions[0];
|
|
56
42
|
}
|
|
57
|
-
return { primaryAction, conditionAction, extractAction, countAction };
|
|
58
43
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
44
|
+
getStepName() {
|
|
45
|
+
return 'If';
|
|
46
|
+
}
|
|
47
|
+
toStepDescriptor() {
|
|
48
|
+
const conditionDescriptor = this.conditionAction !== undefined
|
|
49
|
+
? this.conditionAction?.conditionDescriptor
|
|
62
50
|
: { conditionType: ConditionDescriptor_1.ConditionType.Truthy };
|
|
63
|
-
const
|
|
64
|
-
const count = validatedActions.countAction?.countDescriptor;
|
|
65
|
-
const extract = validatedActions.extractAction?.toDescriptor();
|
|
51
|
+
const find = this.primaryAction.toDescriptor();
|
|
66
52
|
return {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
count,
|
|
53
|
+
find,
|
|
54
|
+
extractDescriptor: this.extractAction?.extractDescriptor,
|
|
55
|
+
conditionDescriptor,
|
|
71
56
|
onFailure: AssertStep_1.OnFailure.FailImmediately,
|
|
72
|
-
descriptorToActionMap: new Map().set(
|
|
73
|
-
actionCode:
|
|
57
|
+
descriptorToActionMap: new Map().set(find, this.primaryAction),
|
|
58
|
+
actionCode: this.actionCode,
|
|
74
59
|
};
|
|
75
60
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
extractAction: this.extractAction,
|
|
84
|
-
});
|
|
61
|
+
getFormattedStep(_fullLocatorsOn) {
|
|
62
|
+
const result = {};
|
|
63
|
+
result[this.getStepName()] = this.toYamlConditionDetails();
|
|
64
|
+
if (this.stepId()) {
|
|
65
|
+
result[this.getStepName()].id = this.stepId();
|
|
66
|
+
}
|
|
67
|
+
return result;
|
|
85
68
|
}
|
|
86
|
-
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
else if (stepArgs.target.kind === 'GetVariable') {
|
|
108
|
-
actions.push(GetVariableValue_1.GetVariableValue.buildAction(stepArgs.target.variable));
|
|
109
|
-
}
|
|
110
|
-
else if (stepArgs.target.javaScript) {
|
|
111
|
-
actions.push(JavaScriptAction_1.JavaScriptAction.fromDescriptor(stepArgs.target));
|
|
112
|
-
}
|
|
69
|
+
toYamlConditionDetails() {
|
|
70
|
+
const details = {
|
|
71
|
+
...super.annotationsAsYml(),
|
|
72
|
+
};
|
|
73
|
+
if (this.conditionAction) {
|
|
74
|
+
details.condition =
|
|
75
|
+
ConditionDescriptor_1.AssertionConditionFieldToStepName[(0, ConditionDescriptor_1.getAssertionConditionFieldFromDescriptor)(this.conditionAction.conditionDescriptor)];
|
|
76
|
+
details.conditionValue = (0, ConditionDescriptor_1.getOptionalComparatorValue)(this.conditionAction.conditionDescriptor);
|
|
77
|
+
const optionalConditionOptions = (0, ConditionDescriptor_1.getOptionalConditionOptions)(this.conditionAction.conditionDescriptor);
|
|
78
|
+
details.conditionOptions = this.conditionAction.hasOptionsAtInstantiation
|
|
79
|
+
? optionalConditionOptions
|
|
80
|
+
: undefined;
|
|
81
|
+
if (this.conditionAction.conditionDescriptor.conditionType ===
|
|
82
|
+
ConditionDescriptor_1.ConditionType.AIPrompt) {
|
|
83
|
+
details.aiPrompt = {
|
|
84
|
+
userPrompt: this.conditionAction.conditionDescriptor.userPrompt,
|
|
85
|
+
metaPrompt: this.conditionAction.conditionDescriptor.metaPrompt,
|
|
86
|
+
criteria: this.conditionAction.conditionDescriptor.criteria,
|
|
87
|
+
};
|
|
113
88
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
89
|
+
}
|
|
90
|
+
if (this.primaryAction instanceof GetVariableValue_1.GetVariableValue) {
|
|
91
|
+
details.variableName = this.substituteMablscriptVariable(this.primaryAction.variable);
|
|
92
|
+
}
|
|
93
|
+
if (this.primaryAction instanceof JavaScriptAction_1.JavaScriptAction) {
|
|
94
|
+
const jsYaml = JavaScriptAction_1.JavaScriptAction.toYamlFromJavaScriptDescriptor(this.primaryAction.javaScript);
|
|
95
|
+
if (jsYaml.snippet) {
|
|
96
|
+
details.snippet = jsYaml.snippet;
|
|
97
|
+
details.snippet.parameterOverrides = jsYaml.parameterOverrides;
|
|
121
98
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
const comparisonType = stepArgs.condition
|
|
125
|
-
.comparisonType;
|
|
126
|
-
const stepName = ConditionDescriptor_1.AssertionConditionFieldToStepName[comparisonType];
|
|
127
|
-
const conditionType = ConditionDescriptor_1.AssertionStepNameToField[stepName];
|
|
128
|
-
actions.push(new ConditionAction_1.ConditionAction(this.getConditionActionNameForConditionType(conditionType), [
|
|
129
|
-
comparisonType,
|
|
130
|
-
stepArgs.condition.comparatorValue,
|
|
131
|
-
{
|
|
132
|
-
caseInsensitive: stepArgs.condition.caseInsensitive,
|
|
133
|
-
},
|
|
134
|
-
]));
|
|
135
|
-
}
|
|
136
|
-
else if (stepArgs.condition.conditionType === 'presence') {
|
|
137
|
-
const conditionType = stepArgs.condition.presenceType === 'present'
|
|
138
|
-
? 'present'
|
|
139
|
-
: 'not_present';
|
|
140
|
-
actions.push(new ConditionAction_1.ConditionAction(this.getConditionActionNameForConditionType(conditionType), [conditionType]));
|
|
141
|
-
}
|
|
142
|
-
else if (stepArgs.condition.conditionType === 'truthy') {
|
|
143
|
-
}
|
|
144
|
-
else if (stepArgs.condition.conditionType === 'ai_prompt') {
|
|
145
|
-
actions.push(new ConditionAction_1.ConditionAction(this.getConditionActionNameForConditionType('ai_prompt'), [
|
|
146
|
-
stepArgs.condition.userPrompt,
|
|
147
|
-
{
|
|
148
|
-
metaPrompt: stepArgs.condition.metaPrompt,
|
|
149
|
-
criteria: stepArgs.condition.criteria,
|
|
150
|
-
},
|
|
151
|
-
]));
|
|
152
|
-
}
|
|
99
|
+
else {
|
|
100
|
+
details.snippet = jsYaml;
|
|
153
101
|
}
|
|
154
|
-
return actions;
|
|
155
102
|
}
|
|
103
|
+
if (this.extractAction) {
|
|
104
|
+
details.attribute = this.extractAction.extractionAttribute;
|
|
105
|
+
}
|
|
106
|
+
if (this.primaryAction instanceof FindAction_1.FindAction ||
|
|
107
|
+
this.primaryAction instanceof MobileFindAction_1.MobileFindAction) {
|
|
108
|
+
const find = this.primaryAction.toDescriptor();
|
|
109
|
+
details.find = find;
|
|
110
|
+
}
|
|
111
|
+
return details;
|
|
112
|
+
}
|
|
113
|
+
static getActionsFromYamlForCondition(stepArgs) {
|
|
114
|
+
const actions = [];
|
|
156
115
|
if (stepArgs.find) {
|
|
157
116
|
if ((0, domUtil_1.isMobileFindDescriptor)(stepArgs.find)) {
|
|
158
117
|
actions.push(MobileFindAction_1.MobileFindAction.fromDescriptor(stepArgs.find));
|
|
159
118
|
}
|
|
160
119
|
else {
|
|
161
|
-
|
|
120
|
+
if (stepArgs.find.findType === domUtil_1.FindType.FIND_ONE) {
|
|
121
|
+
actions.push(FindAction_1.FindAction.findActionFromStepArgs({
|
|
122
|
+
selector: stepArgs.find.findTarget.selector,
|
|
123
|
+
findOptions: stepArgs.find.findOptions,
|
|
124
|
+
}));
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
actions.push(FindAction_1.FindAction.findActionFromStepArgs(stepArgs.find.findTarget));
|
|
128
|
+
}
|
|
162
129
|
}
|
|
163
130
|
}
|
|
164
131
|
else if (stepArgs.selector) {
|
|
@@ -181,14 +148,15 @@ class IfConditionStep extends MablStepV2_1.MablStepV2 {
|
|
|
181
148
|
actions.push(new ExtractAction_1.ExtractAction('extract_attribute', extractArgs));
|
|
182
149
|
}
|
|
183
150
|
if (stepArgs.variableName) {
|
|
184
|
-
actions.push(GetVariableValue_1.GetVariableValue
|
|
151
|
+
actions.push(new GetVariableValue_1.GetVariableValue('get_variable_value', [
|
|
152
|
+
`{{@${stepArgs.variableName}}}`,
|
|
153
|
+
]));
|
|
185
154
|
}
|
|
186
155
|
if (stepArgs.snippet) {
|
|
187
156
|
actions.push(JavaScriptAction_1.JavaScriptAction.fromYaml(stepArgs.snippet));
|
|
188
157
|
}
|
|
189
158
|
if (stepArgs.condition) {
|
|
190
|
-
const
|
|
191
|
-
const conditionType = ConditionDescriptor_1.AssertionStepNameToField[conditionStepName];
|
|
159
|
+
const conditionType = ConditionDescriptor_1.AssertionStepNameToField[stepArgs.condition];
|
|
192
160
|
if (conditionType === 'ai_prompt') {
|
|
193
161
|
actions.push(new ConditionAction_1.ConditionAction(this.getConditionActionNameForConditionType(conditionType), [
|
|
194
162
|
stepArgs.aiPrompt?.userPrompt ?? stepArgs.userPrompt,
|
|
@@ -199,7 +167,11 @@ class IfConditionStep extends MablStepV2_1.MablStepV2 {
|
|
|
199
167
|
]));
|
|
200
168
|
}
|
|
201
169
|
else {
|
|
202
|
-
actions.push(new ConditionAction_1.ConditionAction(this.getConditionActionNameForConditionType(conditionType), [
|
|
170
|
+
actions.push(new ConditionAction_1.ConditionAction(this.getConditionActionNameForConditionType(conditionType), [
|
|
171
|
+
ConditionDescriptor_1.AssertionStepNameToField[stepArgs.condition],
|
|
172
|
+
stepArgs.conditionValue,
|
|
173
|
+
stepArgs.conditionOptions,
|
|
174
|
+
]));
|
|
203
175
|
}
|
|
204
176
|
}
|
|
205
177
|
return actions;
|
|
@@ -215,37 +187,25 @@ class IfConditionStep extends MablStepV2_1.MablStepV2 {
|
|
|
215
187
|
}
|
|
216
188
|
static fromYaml(_stepName, stepArgs) {
|
|
217
189
|
const actions = IfConditionStep.getActionsFromYamlForCondition(stepArgs);
|
|
218
|
-
const
|
|
219
|
-
const stepDescriptor = IfConditionStep.buildDescriptor(validatedActions);
|
|
220
|
-
const step = new IfConditionStep(IfConditionStep.stepName, IfConditionStep.actionCode, stepDescriptor, validatedActions);
|
|
190
|
+
const step = new IfConditionStep('conditional_if', [], actions);
|
|
221
191
|
step.setStepId(stepArgs.id);
|
|
222
192
|
return step;
|
|
223
193
|
}
|
|
224
194
|
toMablscript() {
|
|
225
|
-
|
|
226
|
-
this.primaryAction,
|
|
227
|
-
this.extractAction,
|
|
228
|
-
this.conditionAction,
|
|
229
|
-
].filter(Boolean);
|
|
230
|
-
return `${actions.reduce((mablscript, action) => `${mablscript}${action?.toMablscript()}.`, '')}conditional_if()`;
|
|
195
|
+
return `${this.actions.reduce((mablscript, action) => `${mablscript}${action.toMablscript()}.`, '')}conditional_if()`;
|
|
231
196
|
}
|
|
232
197
|
getInputVariables() {
|
|
233
|
-
|
|
234
|
-
this.primaryAction,
|
|
235
|
-
this.
|
|
236
|
-
this.
|
|
237
|
-
]
|
|
238
|
-
return (0, MablAction_1.distinctStrings)(actions.flatMap((action) => action?.getInputVariables() ?? []));
|
|
239
|
-
}
|
|
240
|
-
stepDescription() {
|
|
241
|
-
return 'IF condition';
|
|
198
|
+
return (0, MablAction_1.distinctStrings)([
|
|
199
|
+
...this.primaryAction.getInputVariables(),
|
|
200
|
+
...(this.conditionAction?.getInputVariables() ?? []),
|
|
201
|
+
...(this.extractAction?.getInputVariables() ?? []),
|
|
202
|
+
]);
|
|
242
203
|
}
|
|
243
204
|
}
|
|
244
205
|
exports.IfConditionStep = IfConditionStep;
|
|
245
|
-
IfConditionStep.stepName = '
|
|
246
|
-
IfConditionStep.
|
|
247
|
-
IfConditionStep.
|
|
248
|
-
IfConditionStep.yamlMablScriptNames = [IfConditionStep.stepName];
|
|
206
|
+
IfConditionStep.stepName = 'conditional_if';
|
|
207
|
+
IfConditionStep.mablScriptStepNames = [IfConditionStep.stepName];
|
|
208
|
+
IfConditionStep.yamlMablScriptNames = ['If'];
|
|
249
209
|
function isIfConditionStep(value) {
|
|
250
210
|
return (value?.getStepName &&
|
|
251
211
|
value?.getStepName() === IfConditionStep.yamlMablScriptNames[0]);
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NavigateStep = void 0;
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
this.navigation = descriptor.navigation;
|
|
4
|
+
const MablStep_1 = require("../MablStep");
|
|
5
|
+
class NavigateStep extends MablStep_1.MablStep {
|
|
6
|
+
constructor(name, args, actions) {
|
|
7
|
+
super(name, args, actions, 'navigate');
|
|
8
|
+
this.navigation = this.getActionArgs()[0];
|
|
10
9
|
}
|
|
11
10
|
getStepName() {
|
|
12
|
-
return
|
|
11
|
+
return 'Navigate';
|
|
13
12
|
}
|
|
14
13
|
toStepDescriptor() {
|
|
15
14
|
return {
|
|
@@ -18,33 +17,14 @@ class NavigateStep extends MablStepV2_1.MablStepV2 {
|
|
|
18
17
|
};
|
|
19
18
|
}
|
|
20
19
|
static fromYaml(_stepName, stepArgs) {
|
|
21
|
-
const
|
|
22
|
-
navigation: stepArgs.navigation,
|
|
23
|
-
actionCode: NavigateStep.actionCode,
|
|
24
|
-
};
|
|
25
|
-
const step = new NavigateStep(stepDescriptor);
|
|
20
|
+
const step = new NavigateStep('navigate', [stepArgs.navigation], []);
|
|
26
21
|
step.setStepId(stepArgs.id);
|
|
27
22
|
return step;
|
|
28
23
|
}
|
|
29
|
-
static fromLegacyMablscript(args, _actions) {
|
|
30
|
-
const stepDescriptor = {
|
|
31
|
-
navigation: args[0],
|
|
32
|
-
actionCode: NavigateStep.actionCode,
|
|
33
|
-
};
|
|
34
|
-
return new NavigateStep(stepDescriptor);
|
|
35
|
-
}
|
|
36
24
|
toMablscript() {
|
|
37
25
|
return `navigate("${this.navigation}")`;
|
|
38
26
|
}
|
|
39
|
-
getInputVariables() {
|
|
40
|
-
return MablAction_1.MablAction.findUniqueVariableReferencesInValue(this.navigation);
|
|
41
|
-
}
|
|
42
|
-
stepDescription() {
|
|
43
|
-
return `Navigate to "${this.navigation}"`;
|
|
44
|
-
}
|
|
45
27
|
}
|
|
46
28
|
exports.NavigateStep = NavigateStep;
|
|
47
|
-
NavigateStep.
|
|
48
|
-
NavigateStep.
|
|
49
|
-
NavigateStep.mablScriptStepNames = [NavigateStep.actionCode];
|
|
50
|
-
NavigateStep.yamlMablScriptNames = [NavigateStep.stepName];
|
|
29
|
+
NavigateStep.mablScriptStepNames = ['navigate'];
|
|
30
|
+
NavigateStep.yamlMablScriptNames = ['Navigate'];
|