@mablhq/mabl-cli 2.70.35 → 2.72.0
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/api/mablApiClient.js +2 -4
- package/execution/index.js +1 -1
- package/mablscript/MablStepV2.js +40 -10
- package/mablscript/MablStepWithFindAction.js +126 -2
- package/mablscript/actions/AwaitDownloadAction.js +4 -3
- package/mablscript/actions/AwaitPDFDownloadAction.js +6 -5
- package/mablscript/actions/ConditionAction.js +2 -1
- package/mablscript/actions/ExtractAction.js +8 -13
- package/mablscript/actions/FindAction.js +20 -0
- package/mablscript/actions/GetVariableValue.js +15 -4
- package/mablscript/actions/JavaScriptAction.js +25 -39
- package/mablscript/diffing/diffingUtil.js +5 -5
- package/mablscript/importer.js +79 -59
- package/mablscript/mobile/steps/CreateVariableMobileStep.js +3 -1
- package/mablscript/steps/AbstractAssertionsAndVariablesStep.js +10 -8
- package/mablscript/steps/AccessibilityCheck.js +76 -36
- package/mablscript/steps/AssertStep.js +266 -86
- package/mablscript/steps/AssertStepOld.js +69 -139
- package/mablscript/steps/AwaitTabStep.js +30 -9
- package/mablscript/steps/AwaitUploadsStep.js +22 -8
- package/mablscript/steps/ClearCookiesStep.js +22 -8
- package/mablscript/steps/ClickAndHoldStep.js +45 -47
- package/mablscript/steps/ClickStep.js +36 -33
- package/mablscript/steps/CreateVariableStep.js +169 -137
- package/mablscript/steps/DatabaseQueryStep.js +14 -4
- package/mablscript/steps/DoubleClickStep.js +37 -40
- package/mablscript/steps/DownloadStep.js +79 -63
- package/mablscript/steps/EchoStep.js +26 -8
- package/mablscript/steps/ElseIfConditionStep.js +23 -12
- package/mablscript/steps/ElseStep.js +22 -9
- package/mablscript/steps/EndStep.js +22 -9
- package/mablscript/steps/EnterAuthCodeStep.js +36 -34
- package/mablscript/steps/EnterTextStep.js +51 -64
- package/mablscript/steps/EvaluateFlowStep.js +39 -18
- package/mablscript/steps/EvaluateJavaScriptStep.js +17 -19
- package/mablscript/steps/HoverStep.js +37 -39
- package/mablscript/steps/IfConditionStep.js +139 -99
- package/mablscript/steps/NavigateStep.js +29 -9
- package/mablscript/steps/OpenEmailStep.js +39 -21
- package/mablscript/steps/ReleaseStep.js +46 -38
- package/mablscript/steps/RemoveCookieStep.js +25 -9
- package/mablscript/steps/RightClickStep.js +36 -33
- package/mablscript/steps/SelectStep.js +69 -46
- package/mablscript/steps/SendHttpRequestStep.js +13 -4
- package/mablscript/steps/SendKeyStep.js +174 -50
- package/mablscript/steps/SetCookieStep.js +56 -23
- package/mablscript/steps/SetFilesStep.js +42 -43
- package/mablscript/steps/SetViewportStep.js +39 -13
- package/mablscript/steps/StepGroupStep.js +70 -0
- package/mablscript/steps/SwitchContextStep.js +89 -83
- package/mablscript/steps/SyntheticStep.js +1 -1
- package/mablscript/steps/VisitUrlStep.js +30 -22
- package/mablscript/steps/WaitStep.js +20 -9
- package/mablscript/steps/WaitUntilStep.js +31 -14
- package/mablscript/types/AssertStepDescriptor.js +2 -0
- package/mablscript/types/ConditionDescriptor.js +5 -5
- package/mablscript/types/GetVariableDescriptor.js +0 -8
- package/mablscript/types/StepGroupStepDescriptor.js +2 -0
- package/package.json +1 -1
|
@@ -3,35 +3,46 @@ 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
|
|
6
|
+
const MablAction_1 = require("../MablAction");
|
|
7
|
+
const MablStepV2_1 = require("../MablStepV2");
|
|
7
8
|
exports.EVALUATE_FLOW_STEP_NAME = 'EvaluateFlow';
|
|
8
|
-
class EvaluateFlowStep extends
|
|
9
|
-
constructor(
|
|
10
|
-
super(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
this.flowDescriptor = this.getActionArgs()[0];
|
|
15
|
-
if (args.length === 2) {
|
|
16
|
-
this.config = this.getActionArgs()[1];
|
|
17
|
-
}
|
|
9
|
+
class EvaluateFlowStep extends MablStepV2_1.MablStepV2 {
|
|
10
|
+
constructor(descriptor) {
|
|
11
|
+
super(EvaluateFlowStep.stepName, descriptor, EvaluateFlowStep.actionCode);
|
|
12
|
+
this.flowDescriptor = descriptor.flow;
|
|
13
|
+
this.config = descriptor.config;
|
|
18
14
|
}
|
|
19
15
|
getStepName() {
|
|
20
|
-
return
|
|
16
|
+
return EvaluateFlowStep.stepName;
|
|
21
17
|
}
|
|
22
18
|
toStepDescriptor() {
|
|
23
19
|
return {
|
|
24
|
-
|
|
20
|
+
actionCode: EvaluateFlowStep.actionCode,
|
|
21
|
+
flow: { invariant_id: this.flowDescriptor.invariant_id },
|
|
25
22
|
config: this.config,
|
|
26
|
-
actionCode: this.actionCode,
|
|
27
23
|
};
|
|
28
24
|
}
|
|
25
|
+
stepDescription() {
|
|
26
|
+
return `Evaluate Flow "${this.flowDescriptor.invariant_id}"`;
|
|
27
|
+
}
|
|
29
28
|
static fromYaml(_stepName, stepArgs) {
|
|
30
|
-
const {
|
|
31
|
-
const step = new EvaluateFlowStep(
|
|
29
|
+
const { flow, config } = stepArgs;
|
|
30
|
+
const step = new EvaluateFlowStep({ flow, config });
|
|
32
31
|
step.setStepId(stepArgs.id);
|
|
33
32
|
return step;
|
|
34
33
|
}
|
|
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
|
+
}
|
|
35
46
|
toMablscript() {
|
|
36
47
|
const flowReference = (0, domUtil_1.buildStepArgumentString)({
|
|
37
48
|
params: { ...this.flowDescriptor },
|
|
@@ -42,10 +53,20 @@ class EvaluateFlowStep extends MablStep_1.MablStep {
|
|
|
42
53
|
: '';
|
|
43
54
|
return `${EvaluateFlowStep.mablScriptStepNames[0]}(${flowReference}${flowConfig})`;
|
|
44
55
|
}
|
|
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
|
+
}
|
|
45
64
|
}
|
|
46
65
|
exports.EvaluateFlowStep = EvaluateFlowStep;
|
|
47
|
-
EvaluateFlowStep.
|
|
48
|
-
EvaluateFlowStep.
|
|
66
|
+
EvaluateFlowStep.stepName = exports.EVALUATE_FLOW_STEP_NAME;
|
|
67
|
+
EvaluateFlowStep.actionCode = 'evaluate_flow';
|
|
68
|
+
EvaluateFlowStep.mablScriptStepNames = [EvaluateFlowStep.actionCode];
|
|
69
|
+
EvaluateFlowStep.yamlMablScriptNames = [EvaluateFlowStep.stepName];
|
|
49
70
|
function isEvaluateFlowStep(step) {
|
|
50
71
|
return step?.getStepName() === exports.EVALUATE_FLOW_STEP_NAME;
|
|
51
72
|
}
|
|
@@ -2,47 +2,45 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EvaluateJavaScriptStep = void 0;
|
|
4
4
|
exports.isEvaluateJavaScriptStep = isEvaluateJavaScriptStep;
|
|
5
|
-
const
|
|
5
|
+
const MablStepV2_1 = require("../MablStepV2");
|
|
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 =
|
|
8
|
+
class EvaluateJavaScriptStep extends MablStepV2_1.MablStepV2 {
|
|
9
|
+
constructor(descriptor) {
|
|
10
|
+
super(EvaluateJavaScriptStep.stepName, descriptor, EvaluateJavaScriptStep.actionCode);
|
|
11
|
+
this.evaluateJsAction = JavaScriptAction_1.JavaScriptAction.fromDescriptor(descriptor);
|
|
12
12
|
}
|
|
13
13
|
getStepName() {
|
|
14
|
-
return
|
|
14
|
+
return EvaluateJavaScriptStep.stepName;
|
|
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
|
-
}
|
|
31
19
|
static fromYaml(_stepName, stepArgs) {
|
|
32
20
|
const evaluateJsAction = JavaScriptAction_1.JavaScriptAction.fromYaml(stepArgs);
|
|
33
|
-
const
|
|
21
|
+
const stepDescriptor = evaluateJsAction.toDescriptor();
|
|
22
|
+
const step = new EvaluateJavaScriptStep(stepDescriptor);
|
|
34
23
|
step.setStepId(stepArgs.id);
|
|
35
24
|
return step;
|
|
36
25
|
}
|
|
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
|
+
}
|
|
37
31
|
toMablscript() {
|
|
38
32
|
return this.evaluateJsAction.toMablscript();
|
|
39
33
|
}
|
|
40
34
|
getInputVariables() {
|
|
41
35
|
return this.evaluateJsAction.getInputVariables();
|
|
42
36
|
}
|
|
37
|
+
stepDescription() {
|
|
38
|
+
return 'Evaluate JavaScript';
|
|
39
|
+
}
|
|
43
40
|
}
|
|
44
41
|
exports.EvaluateJavaScriptStep = EvaluateJavaScriptStep;
|
|
45
42
|
EvaluateJavaScriptStep.stepName = STEP_NAME;
|
|
43
|
+
EvaluateJavaScriptStep.actionCode = 'evaluate_js';
|
|
46
44
|
EvaluateJavaScriptStep.mablScriptStepNames = [JavaScriptAction_1.JavaScriptAction.mablscriptName];
|
|
47
45
|
EvaluateJavaScriptStep.yamlMablScriptNames = [STEP_NAME];
|
|
48
46
|
function isEvaluateJavaScriptStep(value) {
|
|
@@ -4,60 +4,58 @@ 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");
|
|
7
8
|
class HoverStep extends MablStepWithFindAction_1.MablStepWithFindAction {
|
|
8
|
-
constructor(
|
|
9
|
-
super(
|
|
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
|
-
}
|
|
9
|
+
constructor(descriptor, findAction) {
|
|
10
|
+
super(HoverStep.stepName, descriptor, HoverStep.actionCode, findAction);
|
|
17
11
|
}
|
|
18
12
|
getStepName() {
|
|
19
|
-
return
|
|
13
|
+
return HoverStep.stepName;
|
|
20
14
|
}
|
|
21
15
|
toStepDescriptor() {
|
|
22
|
-
|
|
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;
|
|
16
|
+
return buildStepDescriptor(this.findAction);
|
|
48
17
|
}
|
|
49
18
|
static fromYaml(_stepName, stepArgs) {
|
|
50
|
-
const
|
|
19
|
+
const findAction = FindAction_1.FindAction.findActionFromStepArgs(stepArgs);
|
|
20
|
+
const stepDescriptor = buildStepDescriptor(findAction);
|
|
21
|
+
const step = new HoverStep(stepDescriptor, findAction);
|
|
51
22
|
step.setStepId(stepArgs.id);
|
|
52
23
|
return step;
|
|
53
24
|
}
|
|
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
|
+
}
|
|
54
30
|
toMablscript() {
|
|
55
31
|
return `${this.findAction.toMablscript()}.hover()`;
|
|
56
32
|
}
|
|
57
33
|
getInputVariables() {
|
|
58
34
|
return this.findAction.getInputVariables();
|
|
59
35
|
}
|
|
36
|
+
stepDescription() {
|
|
37
|
+
const elementDescription = this.humanizeFind();
|
|
38
|
+
return `Hover over ${elementDescription}`;
|
|
39
|
+
}
|
|
60
40
|
}
|
|
61
41
|
exports.HoverStep = HoverStep;
|
|
62
|
-
HoverStep.
|
|
63
|
-
HoverStep.
|
|
42
|
+
HoverStep.stepName = 'Hover';
|
|
43
|
+
HoverStep.actionCode = 'hover';
|
|
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
|
+
}
|
|
@@ -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 MablStepV2_1 = require("../MablStepV2");
|
|
11
11
|
const ExtractAction_1 = require("../actions/ExtractAction");
|
|
12
12
|
const domUtil_1 = require("../../domUtil");
|
|
13
13
|
const JavaScriptAction_1 = require("../actions/JavaScriptAction");
|
|
@@ -15,9 +15,21 @@ 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
|
-
|
|
18
|
+
const CountAction_1 = require("../actions/CountAction");
|
|
19
|
+
class IfConditionStep extends MablStepV2_1.MablStepV2 {
|
|
20
|
+
constructor(stepName, actionCode, descriptor, stepActions) {
|
|
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) {
|
|
21
33
|
const candidatePrimaryActions = actions.filter((action) => action instanceof FindAction_1.FindAction ||
|
|
22
34
|
action instanceof MobileFindAction_1.MobileFindAction ||
|
|
23
35
|
action instanceof GetVariableValue_1.GetVariableValue ||
|
|
@@ -26,106 +38,127 @@ class IfConditionStep extends MablStep_1.MablStep {
|
|
|
26
38
|
if (candidatePrimaryActions.length > 1) {
|
|
27
39
|
throw new Error(`Too many primary actions. Only one primary action is allowed of: Find, Get Url, Get Variable, or Javascript actions`);
|
|
28
40
|
}
|
|
29
|
-
|
|
30
|
-
|
|
41
|
+
const conditionAction = actions.find((action) => action instanceof ConditionAction_1.ConditionAction);
|
|
42
|
+
const extractAction = actions.find((action) => action instanceof ExtractAction_1.ExtractAction);
|
|
43
|
+
const countAction = actions.find((action) => action instanceof CountAction_1.CountAction);
|
|
44
|
+
let primaryAction;
|
|
31
45
|
if (candidatePrimaryActions[0] === undefined) {
|
|
32
|
-
if (
|
|
33
|
-
(0, ConditionDescriptor_1.isAIPromptCondition)(
|
|
34
|
-
|
|
46
|
+
if (conditionAction !== undefined &&
|
|
47
|
+
(0, ConditionDescriptor_1.isAIPromptCondition)(conditionAction.conditionDescriptor)) {
|
|
48
|
+
primaryAction = new GetViewportAction_1.GetViewportAction();
|
|
35
49
|
}
|
|
36
50
|
else {
|
|
37
51
|
throw new Error(`At least one primary action is required: Find, Get Url, Get Variable, or Javascript action.`);
|
|
38
52
|
}
|
|
39
53
|
}
|
|
40
54
|
else {
|
|
41
|
-
|
|
55
|
+
primaryAction = candidatePrimaryActions[0];
|
|
42
56
|
}
|
|
57
|
+
return { primaryAction, conditionAction, extractAction, countAction };
|
|
43
58
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
toStepDescriptor() {
|
|
48
|
-
const conditionDescriptor = this.conditionAction !== undefined
|
|
49
|
-
? this.conditionAction?.conditionDescriptor
|
|
59
|
+
static buildDescriptor(validatedActions) {
|
|
60
|
+
const conditionDescriptor = validatedActions.conditionAction !== undefined
|
|
61
|
+
? validatedActions.conditionAction?.conditionDescriptor
|
|
50
62
|
: { conditionType: ConditionDescriptor_1.ConditionType.Truthy };
|
|
51
|
-
const
|
|
63
|
+
const target = validatedActions.primaryAction.toDescriptor();
|
|
64
|
+
const count = validatedActions.countAction?.countDescriptor;
|
|
65
|
+
const extract = validatedActions.extractAction?.toDescriptor();
|
|
52
66
|
return {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
conditionDescriptor,
|
|
67
|
+
target,
|
|
68
|
+
extract,
|
|
69
|
+
condition: conditionDescriptor,
|
|
70
|
+
count,
|
|
56
71
|
onFailure: AssertStep_1.OnFailure.FailImmediately,
|
|
57
|
-
descriptorToActionMap: new Map().set(
|
|
58
|
-
actionCode:
|
|
72
|
+
descriptorToActionMap: new Map().set(target, validatedActions.primaryAction),
|
|
73
|
+
actionCode: IfConditionStep.actionCode,
|
|
59
74
|
};
|
|
60
75
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
result[this.getStepName()] = this.toYamlConditionDetails();
|
|
64
|
-
if (this.stepId()) {
|
|
65
|
-
result[this.getStepName()].id = this.stepId();
|
|
66
|
-
}
|
|
67
|
-
return result;
|
|
76
|
+
getStepName() {
|
|
77
|
+
return IfConditionStep.stepName;
|
|
68
78
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
79
|
+
toStepDescriptor() {
|
|
80
|
+
return IfConditionStep.buildDescriptor({
|
|
81
|
+
primaryAction: this.primaryAction,
|
|
82
|
+
conditionAction: this.conditionAction,
|
|
83
|
+
extractAction: this.extractAction,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
static getActionsFromYamlForCondition(stepArgs) {
|
|
87
|
+
const actions = [];
|
|
88
|
+
const isNewFormat = stepArgs.target && typeof stepArgs.condition === 'object';
|
|
89
|
+
if (isNewFormat) {
|
|
90
|
+
if (stepArgs.target) {
|
|
91
|
+
if (stepArgs.target.findType) {
|
|
92
|
+
if ((0, domUtil_1.isMobileFindDescriptor)(stepArgs.target)) {
|
|
93
|
+
actions.push(MobileFindAction_1.MobileFindAction.fromDescriptor(stepArgs.target));
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
if (stepArgs.target.findType === domUtil_1.FindType.FIND_ONE) {
|
|
97
|
+
actions.push(FindAction_1.FindAction.findActionFromStepArgs({
|
|
98
|
+
selector: stepArgs.target.findTarget.selector,
|
|
99
|
+
findOptions: stepArgs.target.findOptions,
|
|
100
|
+
}));
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
actions.push(FindAction_1.FindAction.findActionFromStepArgs(stepArgs.target.findTarget));
|
|
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
|
+
}
|
|
88
113
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
details.snippet = jsYaml.snippet;
|
|
97
|
-
details.snippet.parameterOverrides = jsYaml.parameterOverrides;
|
|
114
|
+
if (stepArgs.extract) {
|
|
115
|
+
if (stepArgs.extract.extractType === 'extract_attribute') {
|
|
116
|
+
const extractArgs = stepArgs.extract.metadata
|
|
117
|
+
? [stepArgs.extract.attributeName, stepArgs.extract.metadata]
|
|
118
|
+
: [stepArgs.extract.attributeName];
|
|
119
|
+
actions.push(new ExtractAction_1.ExtractAction('extract_attribute', extractArgs));
|
|
120
|
+
}
|
|
98
121
|
}
|
|
99
|
-
|
|
100
|
-
|
|
122
|
+
if (stepArgs.condition) {
|
|
123
|
+
if (stepArgs.condition.conditionType === 'comparison') {
|
|
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
|
+
}
|
|
101
153
|
}
|
|
154
|
+
return actions;
|
|
102
155
|
}
|
|
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 = [];
|
|
115
156
|
if (stepArgs.find) {
|
|
116
157
|
if ((0, domUtil_1.isMobileFindDescriptor)(stepArgs.find)) {
|
|
117
158
|
actions.push(MobileFindAction_1.MobileFindAction.fromDescriptor(stepArgs.find));
|
|
118
159
|
}
|
|
119
160
|
else {
|
|
120
|
-
|
|
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
|
-
}
|
|
161
|
+
actions.push(FindAction_1.FindAction.findActionFromStepArgs(stepArgs));
|
|
129
162
|
}
|
|
130
163
|
}
|
|
131
164
|
else if (stepArgs.selector) {
|
|
@@ -148,15 +181,14 @@ class IfConditionStep extends MablStep_1.MablStep {
|
|
|
148
181
|
actions.push(new ExtractAction_1.ExtractAction('extract_attribute', extractArgs));
|
|
149
182
|
}
|
|
150
183
|
if (stepArgs.variableName) {
|
|
151
|
-
actions.push(
|
|
152
|
-
`{{@${stepArgs.variableName}}}`,
|
|
153
|
-
]));
|
|
184
|
+
actions.push(GetVariableValue_1.GetVariableValue.buildAction(stepArgs.variableName));
|
|
154
185
|
}
|
|
155
186
|
if (stepArgs.snippet) {
|
|
156
187
|
actions.push(JavaScriptAction_1.JavaScriptAction.fromYaml(stepArgs.snippet));
|
|
157
188
|
}
|
|
158
189
|
if (stepArgs.condition) {
|
|
159
|
-
const
|
|
190
|
+
const conditionStepName = stepArgs.condition;
|
|
191
|
+
const conditionType = ConditionDescriptor_1.AssertionStepNameToField[conditionStepName];
|
|
160
192
|
if (conditionType === 'ai_prompt') {
|
|
161
193
|
actions.push(new ConditionAction_1.ConditionAction(this.getConditionActionNameForConditionType(conditionType), [
|
|
162
194
|
stepArgs.aiPrompt?.userPrompt ?? stepArgs.userPrompt,
|
|
@@ -167,11 +199,7 @@ class IfConditionStep extends MablStep_1.MablStep {
|
|
|
167
199
|
]));
|
|
168
200
|
}
|
|
169
201
|
else {
|
|
170
|
-
actions.push(new ConditionAction_1.ConditionAction(this.getConditionActionNameForConditionType(conditionType), [
|
|
171
|
-
ConditionDescriptor_1.AssertionStepNameToField[stepArgs.condition],
|
|
172
|
-
stepArgs.conditionValue,
|
|
173
|
-
stepArgs.conditionOptions,
|
|
174
|
-
]));
|
|
202
|
+
actions.push(new ConditionAction_1.ConditionAction(this.getConditionActionNameForConditionType(conditionType), [conditionType, stepArgs.conditionValue, stepArgs.conditionOptions]));
|
|
175
203
|
}
|
|
176
204
|
}
|
|
177
205
|
return actions;
|
|
@@ -187,25 +215,37 @@ class IfConditionStep extends MablStep_1.MablStep {
|
|
|
187
215
|
}
|
|
188
216
|
static fromYaml(_stepName, stepArgs) {
|
|
189
217
|
const actions = IfConditionStep.getActionsFromYamlForCondition(stepArgs);
|
|
190
|
-
const
|
|
218
|
+
const validatedActions = IfConditionStep.validateAndParseActions(actions);
|
|
219
|
+
const stepDescriptor = IfConditionStep.buildDescriptor(validatedActions);
|
|
220
|
+
const step = new IfConditionStep(IfConditionStep.stepName, IfConditionStep.actionCode, stepDescriptor, validatedActions);
|
|
191
221
|
step.setStepId(stepArgs.id);
|
|
192
222
|
return step;
|
|
193
223
|
}
|
|
194
224
|
toMablscript() {
|
|
195
|
-
|
|
225
|
+
const actions = [
|
|
226
|
+
this.primaryAction,
|
|
227
|
+
this.extractAction,
|
|
228
|
+
this.conditionAction,
|
|
229
|
+
].filter(Boolean);
|
|
230
|
+
return `${actions.reduce((mablscript, action) => `${mablscript}${action?.toMablscript()}.`, '')}conditional_if()`;
|
|
196
231
|
}
|
|
197
232
|
getInputVariables() {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
]);
|
|
233
|
+
const actions = [
|
|
234
|
+
this.primaryAction,
|
|
235
|
+
this.extractAction,
|
|
236
|
+
this.conditionAction,
|
|
237
|
+
].filter(Boolean);
|
|
238
|
+
return (0, MablAction_1.distinctStrings)(actions.flatMap((action) => action?.getInputVariables() ?? []));
|
|
239
|
+
}
|
|
240
|
+
stepDescription() {
|
|
241
|
+
return 'IF condition';
|
|
203
242
|
}
|
|
204
243
|
}
|
|
205
244
|
exports.IfConditionStep = IfConditionStep;
|
|
206
|
-
IfConditionStep.stepName = '
|
|
207
|
-
IfConditionStep.
|
|
208
|
-
IfConditionStep.
|
|
245
|
+
IfConditionStep.stepName = 'If';
|
|
246
|
+
IfConditionStep.actionCode = 'conditional_if';
|
|
247
|
+
IfConditionStep.mablScriptStepNames = [IfConditionStep.actionCode];
|
|
248
|
+
IfConditionStep.yamlMablScriptNames = [IfConditionStep.stepName];
|
|
209
249
|
function isIfConditionStep(value) {
|
|
210
250
|
return (value?.getStepName &&
|
|
211
251
|
value?.getStepName() === IfConditionStep.yamlMablScriptNames[0]);
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NavigateStep = void 0;
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const MablStepV2_1 = require("../MablStepV2");
|
|
5
|
+
const MablAction_1 = require("../MablAction");
|
|
6
|
+
class NavigateStep extends MablStepV2_1.MablStepV2 {
|
|
7
|
+
constructor(descriptor) {
|
|
8
|
+
super(NavigateStep.stepName, descriptor, NavigateStep.actionCode);
|
|
9
|
+
this.navigation = descriptor.navigation;
|
|
9
10
|
}
|
|
10
11
|
getStepName() {
|
|
11
|
-
return
|
|
12
|
+
return NavigateStep.stepName;
|
|
12
13
|
}
|
|
13
14
|
toStepDescriptor() {
|
|
14
15
|
return {
|
|
@@ -17,14 +18,33 @@ class NavigateStep extends MablStep_1.MablStep {
|
|
|
17
18
|
};
|
|
18
19
|
}
|
|
19
20
|
static fromYaml(_stepName, stepArgs) {
|
|
20
|
-
const
|
|
21
|
+
const stepDescriptor = {
|
|
22
|
+
navigation: stepArgs.navigation,
|
|
23
|
+
actionCode: NavigateStep.actionCode,
|
|
24
|
+
};
|
|
25
|
+
const step = new NavigateStep(stepDescriptor);
|
|
21
26
|
step.setStepId(stepArgs.id);
|
|
22
27
|
return step;
|
|
23
28
|
}
|
|
29
|
+
static fromLegacyMablscript(args, _actions) {
|
|
30
|
+
const stepDescriptor = {
|
|
31
|
+
navigation: args[0],
|
|
32
|
+
actionCode: NavigateStep.actionCode,
|
|
33
|
+
};
|
|
34
|
+
return new NavigateStep(stepDescriptor);
|
|
35
|
+
}
|
|
24
36
|
toMablscript() {
|
|
25
37
|
return `navigate("${this.navigation}")`;
|
|
26
38
|
}
|
|
39
|
+
getInputVariables() {
|
|
40
|
+
return MablAction_1.MablAction.findUniqueVariableReferencesInValue(this.navigation);
|
|
41
|
+
}
|
|
42
|
+
stepDescription() {
|
|
43
|
+
return `Navigate to "${this.navigation}"`;
|
|
44
|
+
}
|
|
27
45
|
}
|
|
28
46
|
exports.NavigateStep = NavigateStep;
|
|
29
|
-
NavigateStep.
|
|
30
|
-
NavigateStep.
|
|
47
|
+
NavigateStep.stepName = 'Navigate';
|
|
48
|
+
NavigateStep.actionCode = 'navigate';
|
|
49
|
+
NavigateStep.mablScriptStepNames = [NavigateStep.actionCode];
|
|
50
|
+
NavigateStep.yamlMablScriptNames = [NavigateStep.stepName];
|