@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
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.RequestInterceptor = exports.MAX_SERIALIZED_BODY_SIZE_BYTES = void 0;
|
|
7
4
|
exports.headerStringToHeaders = headerStringToHeaders;
|
|
8
5
|
exports.headerStringToProtocol = headerStringToProtocol;
|
|
9
|
-
const axios_1 = __importDefault(require("axios"));
|
|
10
6
|
const loggingProvider_1 = require("../providers/logging/loggingProvider");
|
|
11
7
|
const uuid_1 = require("uuid");
|
|
12
8
|
const httpUtil_1 = require("./httpUtil");
|
|
@@ -91,7 +87,7 @@ class RequestInterceptor {
|
|
|
91
87
|
}
|
|
92
88
|
registerInterceptors(axiosInstance) {
|
|
93
89
|
this.requestInterceptorId = axiosInstance.interceptors.request.use(this.handleRequest, this.handleError);
|
|
94
|
-
this.responseInterceptorId =
|
|
90
|
+
this.responseInterceptorId = axiosInstance.interceptors.response.use(this.handleResponse, this.handleError);
|
|
95
91
|
}
|
|
96
92
|
ejectInterceptors(axiosInstance) {
|
|
97
93
|
try {
|
|
@@ -171,6 +167,15 @@ class RequestInterceptor {
|
|
|
171
167
|
chainEntry =
|
|
172
168
|
this.interceptedRequests[this.interceptedRequests.length - 1];
|
|
173
169
|
}
|
|
170
|
+
const anyError = error;
|
|
171
|
+
if (anyError?.name === 'AggregateError' &&
|
|
172
|
+
(!error.message || error.message.trim() === '') &&
|
|
173
|
+
Array.isArray(anyError.errors)) {
|
|
174
|
+
const underlying = anyError.errors.find((e) => e?.message);
|
|
175
|
+
if (underlying?.message) {
|
|
176
|
+
anyError.message = underlying.message;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
174
179
|
if (chainEntry) {
|
|
175
180
|
chainEntry.error = {
|
|
176
181
|
code: error.code ?? httpUtil_1.GENERAL_API_STEP_EXECUTION_ERROR_CODE,
|
package/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import {BrowserContext, Locator, Page, Frame} from 'playwright-core';
|
|
|
2
2
|
import {TestType} from '@playwright/test';
|
|
3
3
|
|
|
4
4
|
declare module '@mablhq/mabl-cli' {
|
|
5
|
+
export type AuthServerPolicy = 'off' | 'none' | 'all';
|
|
5
6
|
export enum TestResultStatus {
|
|
6
7
|
passed = 'passed',
|
|
7
8
|
skipped = 'skipped',
|
|
@@ -38,6 +39,7 @@ declare module '@mablhq/mabl-cli' {
|
|
|
38
39
|
}
|
|
39
40
|
export interface TestRunConfig {
|
|
40
41
|
authToken?: string;
|
|
42
|
+
authServerPolicy?: AuthServerPolicy;
|
|
41
43
|
basicAuthCredentialsId?: string;
|
|
42
44
|
branchName?: string;
|
|
43
45
|
branchChangesOnly?: boolean;
|
package/mablscript/MablStepV2.js
CHANGED
|
@@ -10,43 +10,73 @@ 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;
|
|
13
16
|
}
|
|
14
17
|
stepId() {
|
|
15
|
-
return this.descriptor.id;
|
|
18
|
+
return this.descriptor.id ?? super.stepId();
|
|
16
19
|
}
|
|
17
20
|
setStepId(id) {
|
|
21
|
+
super.setStepId(id);
|
|
18
22
|
this.descriptor.id = id;
|
|
19
23
|
}
|
|
20
24
|
static fromYaml(stepName, stepDescriptor, actionCode) {
|
|
21
25
|
return new MablStepV2(stepName, stepDescriptor, actionCode);
|
|
22
26
|
}
|
|
27
|
+
static fromLegacyMablscript(_args, _actions) {
|
|
28
|
+
throw new Error('Legacy mablscript conversion not supported for MablStepV2 base class');
|
|
29
|
+
}
|
|
23
30
|
getStepName() {
|
|
24
31
|
return this.name;
|
|
25
32
|
}
|
|
33
|
+
getActionName() {
|
|
34
|
+
return this.actionCode ?? super.getActionName();
|
|
35
|
+
}
|
|
26
36
|
toStepDescriptor() {
|
|
27
37
|
return this.descriptor;
|
|
28
38
|
}
|
|
29
39
|
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
|
+
}
|
|
30
51
|
return {
|
|
31
|
-
[this.getStepName()]:
|
|
32
|
-
description: this.stepDescription(),
|
|
33
|
-
...this.descriptor,
|
|
34
|
-
},
|
|
52
|
+
[this.getStepName()]: result,
|
|
35
53
|
};
|
|
36
54
|
}
|
|
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
|
+
}
|
|
37
62
|
stepDescription() {
|
|
38
63
|
throw new Error('Step description not implemented');
|
|
39
64
|
}
|
|
40
65
|
isDisabled() {
|
|
41
|
-
return !!this.
|
|
66
|
+
return !!this.disabled;
|
|
42
67
|
}
|
|
43
68
|
setDisabled(disabled) {
|
|
69
|
+
this.disabled = disabled;
|
|
44
70
|
this.descriptor.disabled = disabled;
|
|
45
71
|
}
|
|
72
|
+
canContinueOnFailure() {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
canFailAtEnd() {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
46
78
|
getDescriptionForLogging() {
|
|
47
|
-
return
|
|
48
|
-
this.stepDescription() ||
|
|
49
|
-
this.getStepName());
|
|
79
|
+
return this.annotation?.description ?? this.getDescription();
|
|
50
80
|
}
|
|
51
81
|
toLineDiffFormat() {
|
|
52
82
|
const lineDiffProperties = {
|
|
@@ -61,7 +91,7 @@ exports.MablStepV2 = MablStepV2;
|
|
|
61
91
|
MablStepV2.mablScriptStepNames = [];
|
|
62
92
|
MablStepV2.yamlMablScriptNames = ['MablStepV2'];
|
|
63
93
|
function isMablStepV2(value) {
|
|
64
|
-
if (value
|
|
94
|
+
if (!value) {
|
|
65
95
|
return false;
|
|
66
96
|
}
|
|
67
97
|
const mablStep = value;
|
|
@@ -2,10 +2,134 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MablStepWithFindAction = void 0;
|
|
4
4
|
exports.isStepWithFindAction = isStepWithFindAction;
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
exports.humanizeFindDescriptor = humanizeFindDescriptor;
|
|
6
|
+
exports.humanizeCustomFind = humanizeCustomFind;
|
|
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
|
+
}
|
|
7
29
|
}
|
|
8
30
|
exports.MablStepWithFindAction = MablStepWithFindAction;
|
|
9
31
|
function isStepWithFindAction(step) {
|
|
10
32
|
return step instanceof MablStepWithFindAction || 'findAction' in step;
|
|
11
33
|
}
|
|
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,12 +3,13 @@ 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(AwaitDownloadAction.actionCode, AwaitDownloadAction.actionCode, args);
|
|
8
8
|
}
|
|
9
9
|
toMablscript() {
|
|
10
10
|
return 'await_download()';
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
exports.AwaitDownloadAction = AwaitDownloadAction;
|
|
14
|
-
AwaitDownloadAction.
|
|
14
|
+
AwaitDownloadAction.actionCode = 'await_download';
|
|
15
|
+
AwaitDownloadAction.mablScriptStepNames = [AwaitDownloadAction.actionCode];
|
|
@@ -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 MablAction_1 = require("../MablAction");
|
|
5
5
|
const domUtil_1 = require("../../domUtil");
|
|
6
|
-
class AwaitPDFDownloadAction extends
|
|
7
|
-
constructor(
|
|
8
|
-
super(
|
|
6
|
+
class AwaitPDFDownloadAction extends MablAction_1.MablAction {
|
|
7
|
+
constructor(_name, args) {
|
|
8
|
+
super(AwaitPDFDownloadAction.actionCode, AwaitPDFDownloadAction.actionCode, args);
|
|
9
9
|
this.pdfUUID = this.getActionArgs()[0].uuid;
|
|
10
10
|
}
|
|
11
11
|
toMablscript() {
|
|
@@ -16,4 +16,5 @@ class AwaitPDFDownloadAction extends AwaitDownloadAction_1.AwaitDownloadAction {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
exports.AwaitPDFDownloadAction = AwaitPDFDownloadAction;
|
|
19
|
-
AwaitPDFDownloadAction.
|
|
19
|
+
AwaitPDFDownloadAction.actionCode = 'await_pdf';
|
|
20
|
+
AwaitPDFDownloadAction.mablScriptStepNames = [AwaitPDFDownloadAction.actionCode];
|
|
@@ -40,7 +40,8 @@ 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
|
|
43
|
+
if (options &&
|
|
44
|
+
Object.values(options).some((value) => value !== undefined)) {
|
|
44
45
|
this.hasOptionsAtInstantiation = true;
|
|
45
46
|
}
|
|
46
47
|
return {
|
|
@@ -21,30 +21,25 @@ class ExtractAction extends MablAction_1.MablAction {
|
|
|
21
21
|
else {
|
|
22
22
|
this.extractionAttribute = this.getActionArgs()[0];
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
const actionArgs = this.getActionArgs();
|
|
25
|
+
if (this.name === ExtractDescriptor_1.ExtractType.EXTRACT_ATTRIBUTE && actionArgs.length > 1) {
|
|
26
|
+
const extractionOptions = actionArgs[1];
|
|
26
27
|
const metaExtractionType = extractionOptions.extraction_type;
|
|
27
28
|
if (metaExtractionType?.toLowerCase() === exports.CSS_EXTRACTION_VALUE) {
|
|
28
|
-
this.
|
|
29
|
+
this.name = ExtractDescriptor_1.ExtractType.EXTRACT_CSS_PROPERTIES;
|
|
29
30
|
}
|
|
30
|
-
else {
|
|
31
|
-
this.extractionType = this.name;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
this.extractionType = this.name;
|
|
36
31
|
}
|
|
37
|
-
this.
|
|
38
|
-
}
|
|
39
|
-
getExtractDescriptor() {
|
|
32
|
+
this.extractionType = ExtractDescriptor_1.ExtractType.fromString(this.name);
|
|
40
33
|
if (!this.extractionAttribute) {
|
|
41
34
|
throw new Error(`Attribute name is required for extract attribute action.`);
|
|
42
35
|
}
|
|
43
36
|
if (typeof this.extractionAttribute !== 'string') {
|
|
44
37
|
throw new Error(`Invalid attribute provided for extract attribute extractor: ${this.extractionAttribute}`);
|
|
45
38
|
}
|
|
39
|
+
}
|
|
40
|
+
toDescriptor() {
|
|
46
41
|
return {
|
|
47
|
-
extractType:
|
|
42
|
+
extractType: this.extractionType,
|
|
48
43
|
attributeName: this.extractionAttribute,
|
|
49
44
|
};
|
|
50
45
|
}
|
|
@@ -112,6 +112,26 @@ 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
|
+
}
|
|
115
135
|
if (stepArgs.selector) {
|
|
116
136
|
if (suppliedFindType) {
|
|
117
137
|
findType = suppliedFindType;
|
|
@@ -11,13 +11,23 @@ class GetVariableValue extends MablAction_1.MablAction {
|
|
|
11
11
|
if (typeof arg !== 'string') {
|
|
12
12
|
throw new Error('Expected string argument');
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
const legacyPatternMatches = arg.match(MablSymbol_1.SINGLE_VARIABLE_PATTERN_REGEX);
|
|
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]);
|
|
15
25
|
}
|
|
16
26
|
toMablscript() {
|
|
17
27
|
return `get_variable_value(${this.subVariable(this.variable.toString())})`;
|
|
18
28
|
}
|
|
19
29
|
toDescriptor() {
|
|
20
|
-
return
|
|
30
|
+
return { kind: GetVariableDescriptor_1.GET_VARIABLE_VALUE, variable: this.variable.name };
|
|
21
31
|
}
|
|
22
32
|
generateFindMablscript() {
|
|
23
33
|
return `get_variable_value(${this.variable.name})`;
|
|
@@ -27,5 +37,6 @@ class GetVariableValue extends MablAction_1.MablAction {
|
|
|
27
37
|
}
|
|
28
38
|
}
|
|
29
39
|
exports.GetVariableValue = GetVariableValue;
|
|
30
|
-
GetVariableValue.
|
|
31
|
-
GetVariableValue.
|
|
40
|
+
GetVariableValue.actionCode = 'get_variable_value';
|
|
41
|
+
GetVariableValue.mablScriptStepNames = [GetVariableValue.actionCode];
|
|
42
|
+
GetVariableValue.yamlMablScriptNames = [GetVariableDescriptor_1.GET_VARIABLE_VALUE];
|
|
@@ -109,58 +109,44 @@ 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
|
-
}
|
|
137
112
|
static fromYaml(formatted) {
|
|
113
|
+
const jsDescriptor = formatted.javaScript ?? formatted;
|
|
138
114
|
let snippetOptions;
|
|
139
|
-
if (
|
|
115
|
+
if (jsDescriptor.parameterOverrides) {
|
|
140
116
|
snippetOptions = {
|
|
141
|
-
parameter_overrides:
|
|
117
|
+
parameter_overrides: jsDescriptor.parameterOverrides,
|
|
142
118
|
};
|
|
143
119
|
}
|
|
144
120
|
const args = [];
|
|
145
|
-
if (
|
|
146
|
-
args.push(
|
|
121
|
+
if (jsDescriptor.code) {
|
|
122
|
+
args.push(jsDescriptor.code);
|
|
123
|
+
}
|
|
124
|
+
else if (jsDescriptor.encodedJS) {
|
|
125
|
+
args.push(jsDescriptor.encodedJS);
|
|
147
126
|
}
|
|
148
|
-
else if (
|
|
149
|
-
|
|
150
|
-
args.push(formatted);
|
|
127
|
+
else if (jsDescriptor.body) {
|
|
128
|
+
args.push(jsDescriptor.body);
|
|
151
129
|
}
|
|
152
|
-
else if (
|
|
153
|
-
args.push(
|
|
130
|
+
else if (jsDescriptor.inlineSnippet) {
|
|
131
|
+
args.push(jsDescriptor.inlineSnippet);
|
|
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
|
+
});
|
|
154
141
|
}
|
|
155
|
-
else if (
|
|
142
|
+
else if (jsDescriptor.snippetInvariantId) {
|
|
156
143
|
args.push({
|
|
157
|
-
id:
|
|
158
|
-
invariant_id: formatted.snippetInvariantId,
|
|
144
|
+
id: jsDescriptor.snippetInvariantId,
|
|
159
145
|
});
|
|
160
146
|
}
|
|
161
|
-
else if (
|
|
147
|
+
else if (jsDescriptor.snippetId) {
|
|
162
148
|
args.push({
|
|
163
|
-
id:
|
|
149
|
+
id: jsDescriptor.snippetId,
|
|
164
150
|
});
|
|
165
151
|
}
|
|
166
152
|
else {
|
|
@@ -62,7 +62,10 @@ 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(
|
|
65
|
+
const evaluateFlowStep = new EvaluateFlowStep_1.EvaluateFlowStep({
|
|
66
|
+
flow: { invariant_id: flow?.invariant_id ?? '' },
|
|
67
|
+
config: flowConfig,
|
|
68
|
+
});
|
|
66
69
|
if (flow.description) {
|
|
67
70
|
evaluateFlowStep.setDescription(flow.description);
|
|
68
71
|
}
|
|
@@ -91,12 +94,9 @@ function convertStepListToFlow(steps, flowType = mablApi_1.FlowTypeEnum.Mablscri
|
|
|
91
94
|
return annotations;
|
|
92
95
|
}, {});
|
|
93
96
|
const flow = {
|
|
94
|
-
json_steps: flowType === mablApi_1.FlowTypeEnum.Mobile
|
|
97
|
+
json_steps: flowType === mablApi_1.FlowTypeEnum.Mablscript || flowType === mablApi_1.FlowTypeEnum.Mobile
|
|
95
98
|
? { steps: steps.map((step) => step.getFormattedStep(true)) }
|
|
96
99
|
: 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
|
};
|