@mablhq/mabl-cli 2.72.4 → 2.72.12
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/browserEngines/chromiumBrowserEngine.js +17 -0
- package/browserLauncher/index.js +3 -3
- package/commands/mcp/mcp_cmds/tools/createTest.js +10 -0
- package/commands/mcp/mcp_cmds/tools/getApplications.js +69 -0
- package/commands/mcp/mcp_cmds/tools/{getPlanResults.js → getLatestPlanRuns.js} +6 -6
- package/commands/mcp/mcp_cmds/tools/{getPlanRun.js → getPlanRunResult.js} +5 -5
- package/commands/mcp/mcp_cmds/tools/index.js +6 -4
- package/core/execution/ApiTestUtils.js +3 -1
- package/execution/index.js +1 -1
- package/http/requestInterceptor.js +10 -5
- package/index.d.ts +2 -0
- 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 +78 -36
- package/mablscript/steps/AssertStep.js +267 -86
- package/mablscript/steps/AssertStepOld.js +69 -139
- package/mablscript/steps/AwaitTabStep.js +32 -9
- package/mablscript/steps/AwaitUploadsStep.js +24 -8
- package/mablscript/steps/ClearCookiesStep.js +24 -8
- package/mablscript/steps/ClickAndHoldStep.js +47 -47
- package/mablscript/steps/ClickStep.js +38 -33
- package/mablscript/steps/CreateVariableStep.js +169 -137
- package/mablscript/steps/DatabaseQueryStep.js +16 -4
- package/mablscript/steps/DoubleClickStep.js +39 -40
- package/mablscript/steps/DownloadStep.js +81 -63
- package/mablscript/steps/EchoStep.js +28 -8
- package/mablscript/steps/ElseIfConditionStep.js +25 -12
- package/mablscript/steps/ElseStep.js +24 -9
- package/mablscript/steps/EndStep.js +24 -9
- package/mablscript/steps/EnterAuthCodeStep.js +38 -34
- package/mablscript/steps/EnterTextStep.js +53 -64
- package/mablscript/steps/EvaluateFlowStep.js +41 -18
- package/mablscript/steps/EvaluateJavaScriptStep.js +19 -19
- package/mablscript/steps/HoverStep.js +39 -39
- package/mablscript/steps/IfConditionStep.js +141 -99
- package/mablscript/steps/NavigateStep.js +31 -9
- package/mablscript/steps/OpenEmailStep.js +41 -21
- package/mablscript/steps/ReleaseStep.js +48 -38
- package/mablscript/steps/RemoveCookieStep.js +27 -9
- package/mablscript/steps/RightClickStep.js +38 -33
- package/mablscript/steps/SelectStep.js +71 -46
- package/mablscript/steps/SendHttpRequestStep.js +11 -4
- package/mablscript/steps/SendKeyStep.js +175 -49
- package/mablscript/steps/SetCookieStep.js +58 -23
- package/mablscript/steps/SetFilesStep.js +44 -43
- package/mablscript/steps/SetViewportStep.js +40 -12
- package/mablscript/steps/StepGroupStep.js +70 -0
- package/mablscript/steps/SwitchContextStep.js +93 -83
- package/mablscript/steps/SyntheticStep.js +1 -1
- package/mablscript/steps/VisitUrlStep.js +31 -21
- package/mablscript/steps/WaitStep.js +21 -8
- package/mablscript/steps/WaitUntilStep.js +32 -13
- 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 +4 -4
- package/proxy/index.js +1 -1
- package/upload/index.js +1 -1
|
@@ -3,35 +3,48 @@ 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
|
+
const step = new EvaluateFlowStep(stepDescriptor);
|
|
45
|
+
step.actions = _actions;
|
|
46
|
+
return step;
|
|
47
|
+
}
|
|
35
48
|
toMablscript() {
|
|
36
49
|
const flowReference = (0, domUtil_1.buildStepArgumentString)({
|
|
37
50
|
params: { ...this.flowDescriptor },
|
|
@@ -42,10 +55,20 @@ class EvaluateFlowStep extends MablStep_1.MablStep {
|
|
|
42
55
|
: '';
|
|
43
56
|
return `${EvaluateFlowStep.mablScriptStepNames[0]}(${flowReference}${flowConfig})`;
|
|
44
57
|
}
|
|
58
|
+
getInputVariables() {
|
|
59
|
+
return (0, MablAction_1.distinctStrings)([
|
|
60
|
+
...MablAction_1.MablAction.findUniqueVariableReferencesInValue(this.flowDescriptor),
|
|
61
|
+
...(this.config
|
|
62
|
+
? MablAction_1.MablAction.findUniqueVariableReferencesInValue(this.config)
|
|
63
|
+
: []),
|
|
64
|
+
]);
|
|
65
|
+
}
|
|
45
66
|
}
|
|
46
67
|
exports.EvaluateFlowStep = EvaluateFlowStep;
|
|
47
|
-
EvaluateFlowStep.
|
|
48
|
-
EvaluateFlowStep.
|
|
68
|
+
EvaluateFlowStep.stepName = exports.EVALUATE_FLOW_STEP_NAME;
|
|
69
|
+
EvaluateFlowStep.actionCode = 'evaluate_flow';
|
|
70
|
+
EvaluateFlowStep.mablScriptStepNames = [EvaluateFlowStep.actionCode];
|
|
71
|
+
EvaluateFlowStep.yamlMablScriptNames = [EvaluateFlowStep.stepName];
|
|
49
72
|
function isEvaluateFlowStep(step) {
|
|
50
73
|
return step?.getStepName() === exports.EVALUATE_FLOW_STEP_NAME;
|
|
51
74
|
}
|
|
@@ -2,47 +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 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
|
+
const step = new EvaluateJavaScriptStep(stepDescriptor);
|
|
30
|
+
step.actions = _actions;
|
|
31
|
+
return step;
|
|
32
|
+
}
|
|
37
33
|
toMablscript() {
|
|
38
34
|
return this.evaluateJsAction.toMablscript();
|
|
39
35
|
}
|
|
40
36
|
getInputVariables() {
|
|
41
37
|
return this.evaluateJsAction.getInputVariables();
|
|
42
38
|
}
|
|
39
|
+
stepDescription() {
|
|
40
|
+
return 'Evaluate JavaScript';
|
|
41
|
+
}
|
|
43
42
|
}
|
|
44
43
|
exports.EvaluateJavaScriptStep = EvaluateJavaScriptStep;
|
|
45
44
|
EvaluateJavaScriptStep.stepName = STEP_NAME;
|
|
45
|
+
EvaluateJavaScriptStep.actionCode = 'evaluate_js';
|
|
46
46
|
EvaluateJavaScriptStep.mablScriptStepNames = [JavaScriptAction_1.JavaScriptAction.mablscriptName];
|
|
47
47
|
EvaluateJavaScriptStep.yamlMablScriptNames = [STEP_NAME];
|
|
48
48
|
function isEvaluateJavaScriptStep(value) {
|
|
@@ -4,60 +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");
|
|
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
|
+
const step = new HoverStep(stepDescriptor, findAction);
|
|
29
|
+
step.actions = actions;
|
|
30
|
+
return step;
|
|
31
|
+
}
|
|
54
32
|
toMablscript() {
|
|
55
33
|
return `${this.findAction.toMablscript()}.hover()`;
|
|
56
34
|
}
|
|
57
35
|
getInputVariables() {
|
|
58
36
|
return this.findAction.getInputVariables();
|
|
59
37
|
}
|
|
38
|
+
stepDescription() {
|
|
39
|
+
const elementDescription = this.humanizeFind();
|
|
40
|
+
return `Hover over ${elementDescription}`;
|
|
41
|
+
}
|
|
60
42
|
}
|
|
61
43
|
exports.HoverStep = HoverStep;
|
|
62
|
-
HoverStep.
|
|
63
|
-
HoverStep.
|
|
44
|
+
HoverStep.stepName = 'Hover';
|
|
45
|
+
HoverStep.actionCode = 'hover';
|
|
46
|
+
HoverStep.mablScriptStepNames = [HoverStep.actionCode];
|
|
47
|
+
HoverStep.yamlMablScriptNames = [HoverStep.stepName];
|
|
48
|
+
function buildStepDescriptor(findAction) {
|
|
49
|
+
const find = findAction.toDescriptor();
|
|
50
|
+
switch (find.findType) {
|
|
51
|
+
case domUtil_1.FindType.FIND_FIRST:
|
|
52
|
+
case domUtil_1.FindType.FIND_LAST:
|
|
53
|
+
case domUtil_1.FindType.FIND_ANY:
|
|
54
|
+
case domUtil_1.FindType.FIND_ONE:
|
|
55
|
+
return {
|
|
56
|
+
find,
|
|
57
|
+
descriptorToActionMap: new Map().set(find, findAction),
|
|
58
|
+
actionCode: HoverStep.actionCode,
|
|
59
|
+
};
|
|
60
|
+
default:
|
|
61
|
+
throw new Error(`Error generating step descriptor for ${HoverStep.stepName}: Unexpected find type ${find.findType}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -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,23 @@ 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
|
+
const step = new IfConditionStep(IfConditionStep.stepName, IfConditionStep.actionCode, stepDescriptor, validatedActions);
|
|
31
|
+
step.actions = actions;
|
|
32
|
+
return step;
|
|
33
|
+
}
|
|
34
|
+
static validateAndParseActions(actions) {
|
|
21
35
|
const candidatePrimaryActions = actions.filter((action) => action instanceof FindAction_1.FindAction ||
|
|
22
36
|
action instanceof MobileFindAction_1.MobileFindAction ||
|
|
23
37
|
action instanceof GetVariableValue_1.GetVariableValue ||
|
|
@@ -26,106 +40,127 @@ class IfConditionStep extends MablStep_1.MablStep {
|
|
|
26
40
|
if (candidatePrimaryActions.length > 1) {
|
|
27
41
|
throw new Error(`Too many primary actions. Only one primary action is allowed of: Find, Get Url, Get Variable, or Javascript actions`);
|
|
28
42
|
}
|
|
29
|
-
|
|
30
|
-
|
|
43
|
+
const conditionAction = actions.find((action) => action instanceof ConditionAction_1.ConditionAction);
|
|
44
|
+
const extractAction = actions.find((action) => action instanceof ExtractAction_1.ExtractAction);
|
|
45
|
+
const countAction = actions.find((action) => action instanceof CountAction_1.CountAction);
|
|
46
|
+
let primaryAction;
|
|
31
47
|
if (candidatePrimaryActions[0] === undefined) {
|
|
32
|
-
if (
|
|
33
|
-
(0, ConditionDescriptor_1.isAIPromptCondition)(
|
|
34
|
-
|
|
48
|
+
if (conditionAction !== undefined &&
|
|
49
|
+
(0, ConditionDescriptor_1.isAIPromptCondition)(conditionAction.conditionDescriptor)) {
|
|
50
|
+
primaryAction = new GetViewportAction_1.GetViewportAction();
|
|
35
51
|
}
|
|
36
52
|
else {
|
|
37
53
|
throw new Error(`At least one primary action is required: Find, Get Url, Get Variable, or Javascript action.`);
|
|
38
54
|
}
|
|
39
55
|
}
|
|
40
56
|
else {
|
|
41
|
-
|
|
57
|
+
primaryAction = candidatePrimaryActions[0];
|
|
42
58
|
}
|
|
59
|
+
return { primaryAction, conditionAction, extractAction, countAction };
|
|
43
60
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
toStepDescriptor() {
|
|
48
|
-
const conditionDescriptor = this.conditionAction !== undefined
|
|
49
|
-
? this.conditionAction?.conditionDescriptor
|
|
61
|
+
static buildDescriptor(validatedActions) {
|
|
62
|
+
const conditionDescriptor = validatedActions.conditionAction !== undefined
|
|
63
|
+
? validatedActions.conditionAction?.conditionDescriptor
|
|
50
64
|
: { conditionType: ConditionDescriptor_1.ConditionType.Truthy };
|
|
51
|
-
const
|
|
65
|
+
const target = validatedActions.primaryAction.toDescriptor();
|
|
66
|
+
const count = validatedActions.countAction?.countDescriptor;
|
|
67
|
+
const extract = validatedActions.extractAction?.toDescriptor();
|
|
52
68
|
return {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
conditionDescriptor,
|
|
69
|
+
target,
|
|
70
|
+
extract,
|
|
71
|
+
condition: conditionDescriptor,
|
|
72
|
+
count,
|
|
56
73
|
onFailure: AssertStep_1.OnFailure.FailImmediately,
|
|
57
|
-
descriptorToActionMap: new Map().set(
|
|
58
|
-
actionCode:
|
|
74
|
+
descriptorToActionMap: new Map().set(target, validatedActions.primaryAction),
|
|
75
|
+
actionCode: IfConditionStep.actionCode,
|
|
59
76
|
};
|
|
60
77
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
result[this.getStepName()] = this.toYamlConditionDetails();
|
|
64
|
-
if (this.stepId()) {
|
|
65
|
-
result[this.getStepName()].id = this.stepId();
|
|
66
|
-
}
|
|
67
|
-
return result;
|
|
78
|
+
getStepName() {
|
|
79
|
+
return IfConditionStep.stepName;
|
|
68
80
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
81
|
+
toStepDescriptor() {
|
|
82
|
+
return IfConditionStep.buildDescriptor({
|
|
83
|
+
primaryAction: this.primaryAction,
|
|
84
|
+
conditionAction: this.conditionAction,
|
|
85
|
+
extractAction: this.extractAction,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
static getActionsFromYamlForCondition(stepArgs) {
|
|
89
|
+
const actions = [];
|
|
90
|
+
const isNewFormat = stepArgs.target && typeof stepArgs.condition === 'object';
|
|
91
|
+
if (isNewFormat) {
|
|
92
|
+
if (stepArgs.target) {
|
|
93
|
+
if (stepArgs.target.findType) {
|
|
94
|
+
if ((0, domUtil_1.isMobileFindDescriptor)(stepArgs.target)) {
|
|
95
|
+
actions.push(MobileFindAction_1.MobileFindAction.fromDescriptor(stepArgs.target));
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
if (stepArgs.target.findType === domUtil_1.FindType.FIND_ONE) {
|
|
99
|
+
actions.push(FindAction_1.FindAction.findActionFromStepArgs({
|
|
100
|
+
selector: stepArgs.target.findTarget.selector,
|
|
101
|
+
findOptions: stepArgs.target.findOptions,
|
|
102
|
+
}));
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
actions.push(FindAction_1.FindAction.findActionFromStepArgs(stepArgs.target.findTarget));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
else if (stepArgs.target.kind === 'GetVariable') {
|
|
110
|
+
actions.push(GetVariableValue_1.GetVariableValue.buildAction(stepArgs.target.variable));
|
|
111
|
+
}
|
|
112
|
+
else if (stepArgs.target.javaScript) {
|
|
113
|
+
actions.push(JavaScriptAction_1.JavaScriptAction.fromDescriptor(stepArgs.target));
|
|
114
|
+
}
|
|
88
115
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
details.snippet = jsYaml.snippet;
|
|
97
|
-
details.snippet.parameterOverrides = jsYaml.parameterOverrides;
|
|
116
|
+
if (stepArgs.extract) {
|
|
117
|
+
if (stepArgs.extract.extractType === 'extract_attribute') {
|
|
118
|
+
const extractArgs = stepArgs.extract.metadata
|
|
119
|
+
? [stepArgs.extract.attributeName, stepArgs.extract.metadata]
|
|
120
|
+
: [stepArgs.extract.attributeName];
|
|
121
|
+
actions.push(new ExtractAction_1.ExtractAction('extract_attribute', extractArgs));
|
|
122
|
+
}
|
|
98
123
|
}
|
|
99
|
-
|
|
100
|
-
|
|
124
|
+
if (stepArgs.condition) {
|
|
125
|
+
if (stepArgs.condition.conditionType === 'comparison') {
|
|
126
|
+
const comparisonType = stepArgs.condition
|
|
127
|
+
.comparisonType;
|
|
128
|
+
const stepName = ConditionDescriptor_1.AssertionConditionFieldToStepName[comparisonType];
|
|
129
|
+
const conditionType = ConditionDescriptor_1.AssertionStepNameToField[stepName];
|
|
130
|
+
actions.push(new ConditionAction_1.ConditionAction(this.getConditionActionNameForConditionType(conditionType), [
|
|
131
|
+
comparisonType,
|
|
132
|
+
stepArgs.condition.comparatorValue,
|
|
133
|
+
{
|
|
134
|
+
caseInsensitive: stepArgs.condition.caseInsensitive,
|
|
135
|
+
},
|
|
136
|
+
]));
|
|
137
|
+
}
|
|
138
|
+
else if (stepArgs.condition.conditionType === 'presence') {
|
|
139
|
+
const conditionType = stepArgs.condition.presenceType === 'present'
|
|
140
|
+
? 'present'
|
|
141
|
+
: 'not_present';
|
|
142
|
+
actions.push(new ConditionAction_1.ConditionAction(this.getConditionActionNameForConditionType(conditionType), [conditionType]));
|
|
143
|
+
}
|
|
144
|
+
else if (stepArgs.condition.conditionType === 'truthy') {
|
|
145
|
+
}
|
|
146
|
+
else if (stepArgs.condition.conditionType === 'ai_prompt') {
|
|
147
|
+
actions.push(new ConditionAction_1.ConditionAction(this.getConditionActionNameForConditionType('ai_prompt'), [
|
|
148
|
+
stepArgs.condition.userPrompt,
|
|
149
|
+
{
|
|
150
|
+
metaPrompt: stepArgs.condition.metaPrompt,
|
|
151
|
+
criteria: stepArgs.condition.criteria,
|
|
152
|
+
},
|
|
153
|
+
]));
|
|
154
|
+
}
|
|
101
155
|
}
|
|
156
|
+
return actions;
|
|
102
157
|
}
|
|
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
158
|
if (stepArgs.find) {
|
|
116
159
|
if ((0, domUtil_1.isMobileFindDescriptor)(stepArgs.find)) {
|
|
117
160
|
actions.push(MobileFindAction_1.MobileFindAction.fromDescriptor(stepArgs.find));
|
|
118
161
|
}
|
|
119
162
|
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
|
-
}
|
|
163
|
+
actions.push(FindAction_1.FindAction.findActionFromStepArgs(stepArgs));
|
|
129
164
|
}
|
|
130
165
|
}
|
|
131
166
|
else if (stepArgs.selector) {
|
|
@@ -148,15 +183,14 @@ class IfConditionStep extends MablStep_1.MablStep {
|
|
|
148
183
|
actions.push(new ExtractAction_1.ExtractAction('extract_attribute', extractArgs));
|
|
149
184
|
}
|
|
150
185
|
if (stepArgs.variableName) {
|
|
151
|
-
actions.push(
|
|
152
|
-
`{{@${stepArgs.variableName}}}`,
|
|
153
|
-
]));
|
|
186
|
+
actions.push(GetVariableValue_1.GetVariableValue.buildAction(stepArgs.variableName));
|
|
154
187
|
}
|
|
155
188
|
if (stepArgs.snippet) {
|
|
156
189
|
actions.push(JavaScriptAction_1.JavaScriptAction.fromYaml(stepArgs.snippet));
|
|
157
190
|
}
|
|
158
191
|
if (stepArgs.condition) {
|
|
159
|
-
const
|
|
192
|
+
const conditionStepName = stepArgs.condition;
|
|
193
|
+
const conditionType = ConditionDescriptor_1.AssertionStepNameToField[conditionStepName];
|
|
160
194
|
if (conditionType === 'ai_prompt') {
|
|
161
195
|
actions.push(new ConditionAction_1.ConditionAction(this.getConditionActionNameForConditionType(conditionType), [
|
|
162
196
|
stepArgs.aiPrompt?.userPrompt ?? stepArgs.userPrompt,
|
|
@@ -167,11 +201,7 @@ class IfConditionStep extends MablStep_1.MablStep {
|
|
|
167
201
|
]));
|
|
168
202
|
}
|
|
169
203
|
else {
|
|
170
|
-
actions.push(new ConditionAction_1.ConditionAction(this.getConditionActionNameForConditionType(conditionType), [
|
|
171
|
-
ConditionDescriptor_1.AssertionStepNameToField[stepArgs.condition],
|
|
172
|
-
stepArgs.conditionValue,
|
|
173
|
-
stepArgs.conditionOptions,
|
|
174
|
-
]));
|
|
204
|
+
actions.push(new ConditionAction_1.ConditionAction(this.getConditionActionNameForConditionType(conditionType), [conditionType, stepArgs.conditionValue, stepArgs.conditionOptions]));
|
|
175
205
|
}
|
|
176
206
|
}
|
|
177
207
|
return actions;
|
|
@@ -187,25 +217,37 @@ class IfConditionStep extends MablStep_1.MablStep {
|
|
|
187
217
|
}
|
|
188
218
|
static fromYaml(_stepName, stepArgs) {
|
|
189
219
|
const actions = IfConditionStep.getActionsFromYamlForCondition(stepArgs);
|
|
190
|
-
const
|
|
220
|
+
const validatedActions = IfConditionStep.validateAndParseActions(actions);
|
|
221
|
+
const stepDescriptor = IfConditionStep.buildDescriptor(validatedActions);
|
|
222
|
+
const step = new IfConditionStep(IfConditionStep.stepName, IfConditionStep.actionCode, stepDescriptor, validatedActions);
|
|
191
223
|
step.setStepId(stepArgs.id);
|
|
192
224
|
return step;
|
|
193
225
|
}
|
|
194
226
|
toMablscript() {
|
|
195
|
-
|
|
227
|
+
const actions = [
|
|
228
|
+
this.primaryAction,
|
|
229
|
+
this.extractAction,
|
|
230
|
+
this.conditionAction,
|
|
231
|
+
].filter(Boolean);
|
|
232
|
+
return `${actions.reduce((mablscript, action) => `${mablscript}${action?.toMablscript()}.`, '')}conditional_if()`;
|
|
196
233
|
}
|
|
197
234
|
getInputVariables() {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
]);
|
|
235
|
+
const actions = [
|
|
236
|
+
this.primaryAction,
|
|
237
|
+
this.extractAction,
|
|
238
|
+
this.conditionAction,
|
|
239
|
+
].filter(Boolean);
|
|
240
|
+
return (0, MablAction_1.distinctStrings)(actions.flatMap((action) => action?.getInputVariables() ?? []));
|
|
241
|
+
}
|
|
242
|
+
stepDescription() {
|
|
243
|
+
return 'IF condition';
|
|
203
244
|
}
|
|
204
245
|
}
|
|
205
246
|
exports.IfConditionStep = IfConditionStep;
|
|
206
|
-
IfConditionStep.stepName = '
|
|
207
|
-
IfConditionStep.
|
|
208
|
-
IfConditionStep.
|
|
247
|
+
IfConditionStep.stepName = 'If';
|
|
248
|
+
IfConditionStep.actionCode = 'conditional_if';
|
|
249
|
+
IfConditionStep.mablScriptStepNames = [IfConditionStep.actionCode];
|
|
250
|
+
IfConditionStep.yamlMablScriptNames = [IfConditionStep.stepName];
|
|
209
251
|
function isIfConditionStep(value) {
|
|
210
252
|
return (value?.getStepName &&
|
|
211
253
|
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,35 @@ 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
|
+
const step = new NavigateStep(stepDescriptor);
|
|
35
|
+
step.actions = _actions;
|
|
36
|
+
return step;
|
|
37
|
+
}
|
|
24
38
|
toMablscript() {
|
|
25
39
|
return `navigate("${this.navigation}")`;
|
|
26
40
|
}
|
|
41
|
+
getInputVariables() {
|
|
42
|
+
return MablAction_1.MablAction.findUniqueVariableReferencesInValue(this.navigation);
|
|
43
|
+
}
|
|
44
|
+
stepDescription() {
|
|
45
|
+
return `Navigate to "${this.navigation}"`;
|
|
46
|
+
}
|
|
27
47
|
}
|
|
28
48
|
exports.NavigateStep = NavigateStep;
|
|
29
|
-
NavigateStep.
|
|
30
|
-
NavigateStep.
|
|
49
|
+
NavigateStep.stepName = 'Navigate';
|
|
50
|
+
NavigateStep.actionCode = 'navigate';
|
|
51
|
+
NavigateStep.mablScriptStepNames = [NavigateStep.actionCode];
|
|
52
|
+
NavigateStep.yamlMablScriptNames = [NavigateStep.stepName];
|