@mablhq/mabl-cli 2.46.12 → 2.49.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 +8 -7
- package/commands/test-runs/test-runs_cmds/export.js +1 -0
- package/core/execution/ApiTestUtils.js +13 -0
- package/domUtil/index.js +1 -1
- package/execution/index.js +3 -3
- package/http/httpUtil.js +26 -7
- package/mablApi/index.js +1 -1
- package/mablscript/actions/ConditionAction.js +9 -1
- package/mablscript/actions/GetViewportAction.js +17 -0
- package/mablscript/steps/AssertStep.js +27 -6
- package/mablscript/steps/AssertStepOld.js +4 -1
- package/mablscript/types/GetViewportDescriptor.js +12 -0
- package/mablscriptFind/index.js +1 -1
- package/package.json +1 -1
- package/resources/mablFind.js +1 -1
- package/upload/index.js +1 -1
|
@@ -103,7 +103,15 @@ class ConditionAction extends MablAction_1.MablAction {
|
|
|
103
103
|
}
|
|
104
104
|
getInputVariables() {
|
|
105
105
|
var _a;
|
|
106
|
-
|
|
106
|
+
const fields = [];
|
|
107
|
+
fields.push((_a = (0, ConditionDescriptor_1.getOptionalComparatorValue)(this.conditionDescriptor)) !== null && _a !== void 0 ? _a : '');
|
|
108
|
+
if ((0, ConditionDescriptor_1.isAIPromptCondition)(this.conditionDescriptor)) {
|
|
109
|
+
if (this.conditionDescriptor.criteria) {
|
|
110
|
+
fields.push(...this.conditionDescriptor.criteria);
|
|
111
|
+
}
|
|
112
|
+
fields.push(this.conditionDescriptor.userPrompt);
|
|
113
|
+
}
|
|
114
|
+
return MablAction_1.MablAction.findUniqueVariableReferencesInValue(fields);
|
|
107
115
|
}
|
|
108
116
|
}
|
|
109
117
|
exports.ConditionAction = ConditionAction;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetViewportAction = void 0;
|
|
4
|
+
const MablAction_1 = require("../MablAction");
|
|
5
|
+
const GetViewportDescriptor_1 = require("../types/GetViewportDescriptor");
|
|
6
|
+
class GetViewportAction extends MablAction_1.MablAction {
|
|
7
|
+
constructor() {
|
|
8
|
+
super('get_viewport', 'get_viewport', []);
|
|
9
|
+
}
|
|
10
|
+
toDescriptor() {
|
|
11
|
+
return (0, GetViewportDescriptor_1.newGetViewportDescriptor)();
|
|
12
|
+
}
|
|
13
|
+
generateFindMablscript() {
|
|
14
|
+
return '';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.GetViewportAction = GetViewportAction;
|
|
@@ -14,6 +14,8 @@ const GetVariableValue_1 = require("../actions/GetVariableValue");
|
|
|
14
14
|
const GetVariableDescriptor_1 = require("../types/GetVariableDescriptor");
|
|
15
15
|
const CountAction_1 = require("../actions/CountAction");
|
|
16
16
|
const MobileFindAction_1 = require("../mobile/steps/actions/MobileFindAction");
|
|
17
|
+
const GetViewportDescriptor_1 = require("../types/GetViewportDescriptor");
|
|
18
|
+
const GetViewportAction_1 = require("../actions/GetViewportAction");
|
|
17
19
|
var OnFailure;
|
|
18
20
|
(function (OnFailure) {
|
|
19
21
|
OnFailure["ContinueWithWarning"] = "continue";
|
|
@@ -34,9 +36,14 @@ class AssertStep extends MablStep_1.MablStep {
|
|
|
34
36
|
if (firstAction instanceof FindAction_1.FindAction ||
|
|
35
37
|
firstAction instanceof MobileFindAction_1.MobileFindAction ||
|
|
36
38
|
firstAction instanceof GetUrlAction_1.GetUrlAction ||
|
|
37
|
-
firstAction instanceof GetVariableValue_1.GetVariableValue
|
|
39
|
+
firstAction instanceof GetVariableValue_1.GetVariableValue ||
|
|
40
|
+
firstAction instanceof GetViewportAction_1.GetViewportAction) {
|
|
38
41
|
this.primaryAction = firstAction;
|
|
39
42
|
}
|
|
43
|
+
else if (firstAction instanceof ConditionAction_1.ConditionAction &&
|
|
44
|
+
(0, ConditionDescriptor_1.isAIPromptCondition)(firstAction.conditionDescriptor)) {
|
|
45
|
+
this.primaryAction = new GetViewportAction_1.GetViewportAction();
|
|
46
|
+
}
|
|
40
47
|
else {
|
|
41
48
|
throw new Error(`Unexpected action type. Expected FindAction|MobileFindAction|GetUrlAction|GetVariableValue but got: ${firstAction.constructor.name}`);
|
|
42
49
|
}
|
|
@@ -49,6 +56,9 @@ class AssertStep extends MablStep_1.MablStep {
|
|
|
49
56
|
}
|
|
50
57
|
this.conditionAction = actions[2];
|
|
51
58
|
}
|
|
59
|
+
else if (firstAction instanceof ConditionAction_1.ConditionAction) {
|
|
60
|
+
this.conditionAction = firstAction;
|
|
61
|
+
}
|
|
52
62
|
else {
|
|
53
63
|
this.conditionAction = actions[1];
|
|
54
64
|
}
|
|
@@ -178,6 +188,9 @@ class AssertStep extends MablStep_1.MablStep {
|
|
|
178
188
|
else if (((_b = stepArgs.target) === null || _b === void 0 ? void 0 : _b.kind) === GetVariableDescriptor_1.GET_VARIABLE_VALUE) {
|
|
179
189
|
primaryAction = new GetVariableValue_1.GetVariableValue(GetVariableValue_1.GetVariableValue.mablScriptStepNames[0], [(_c = stepArgs.target) === null || _c === void 0 ? void 0 : _c.variable]);
|
|
180
190
|
}
|
|
191
|
+
else if ((0, GetViewportDescriptor_1.isGetViewportDescriptor)(stepArgs.target)) {
|
|
192
|
+
primaryAction = new GetViewportAction_1.GetViewportAction();
|
|
193
|
+
}
|
|
181
194
|
else if ((0, domUtil_1.isNormalizedFindEmailDescriptor)((_d = stepArgs.target) === null || _d === void 0 ? void 0 : _d.findTarget) ||
|
|
182
195
|
(0, domUtil_1.isCookieSelector)((_e = stepArgs.target) === null || _e === void 0 ? void 0 : _e.findTarget) ||
|
|
183
196
|
(0, domUtil_1.isTabSelector)((_f = stepArgs.target) === null || _f === void 0 ? void 0 : _f.findTarget)) {
|
|
@@ -240,6 +253,14 @@ class AssertStep extends MablStep_1.MablStep {
|
|
|
240
253
|
if (this.primaryAction instanceof MobileFindAction_1.MobileFindAction) {
|
|
241
254
|
throw new Error('Mobile steps do not generate mablscript');
|
|
242
255
|
}
|
|
256
|
+
let primaryActionMablscriptPrefix = this.primaryAction.toMablscript();
|
|
257
|
+
if (primaryActionMablscriptPrefix.length > 0) {
|
|
258
|
+
primaryActionMablscriptPrefix += '.';
|
|
259
|
+
}
|
|
260
|
+
let primaryActionFindMablscriptPrefix = this.primaryAction.generateFindMablscript();
|
|
261
|
+
if (primaryActionFindMablscriptPrefix.length > 0) {
|
|
262
|
+
primaryActionFindMablscriptPrefix += '.';
|
|
263
|
+
}
|
|
243
264
|
const assertAction = `.assert(${!!(((_a = this.assertArguments) === null || _a === void 0 ? void 0 : _a.onFailure) ||
|
|
244
265
|
((_b = this.assertArguments) === null || _b === void 0 ? void 0 : _b.observationScope))
|
|
245
266
|
? (0, MablAction_1.convertObjectToMablscriptArgs)({
|
|
@@ -250,14 +271,14 @@ class AssertStep extends MablStep_1.MablStep {
|
|
|
250
271
|
})
|
|
251
272
|
: ''})`;
|
|
252
273
|
if (this.countAction) {
|
|
253
|
-
return `${
|
|
274
|
+
return `${primaryActionMablscriptPrefix}${this.countAction.toMablscript()}.${this.conditionAction.toMablscript()}${assertAction}`;
|
|
254
275
|
}
|
|
255
276
|
if (this.extractAction) {
|
|
256
|
-
return `${
|
|
277
|
+
return `${primaryActionMablscriptPrefix}${this.extractAction.toMablscript()}.${this.conditionAction.toMablscript()}${assertAction}`;
|
|
257
278
|
}
|
|
258
279
|
if (this.assertionType === 'present' ||
|
|
259
280
|
this.assertionType === 'not_present') {
|
|
260
|
-
return `${
|
|
281
|
+
return `${primaryActionFindMablscriptPrefix}evaluate_presence("${this.assertionType}")${assertAction}`;
|
|
261
282
|
}
|
|
262
283
|
if (this.assertionType === 'ai_prompt') {
|
|
263
284
|
const aiOptions = {};
|
|
@@ -267,9 +288,9 @@ class AssertStep extends MablStep_1.MablStep {
|
|
|
267
288
|
if (((_f = this.aiPrompt) === null || _f === void 0 ? void 0 : _f.criteria) && this.aiPrompt.criteria.length > 0) {
|
|
268
289
|
aiOptions.criteria = (_g = this.aiPrompt) === null || _g === void 0 ? void 0 : _g.criteria;
|
|
269
290
|
}
|
|
270
|
-
return `${
|
|
291
|
+
return `${primaryActionFindMablscriptPrefix}evaluate_ai_prompt("${(_h = this.aiPrompt) === null || _h === void 0 ? void 0 : _h.userPrompt}", ${JSON.stringify(aiOptions)})${assertAction}`;
|
|
271
292
|
}
|
|
272
|
-
return `${
|
|
293
|
+
return `${primaryActionMablscriptPrefix}${this.conditionAction.toMablscript()}${assertAction}`;
|
|
273
294
|
}
|
|
274
295
|
toLineDiffFormat() {
|
|
275
296
|
if (this.primaryAction instanceof MobileFindAction_1.MobileFindAction) {
|
|
@@ -8,6 +8,7 @@ const domUtil_1 = require("../../domUtil");
|
|
|
8
8
|
const importer_1 = require("../importer");
|
|
9
9
|
const GetCurrentLocationDescriptor_1 = require("../types/GetCurrentLocationDescriptor");
|
|
10
10
|
const GetVariableDescriptor_1 = require("../types/GetVariableDescriptor");
|
|
11
|
+
const GetViewportDescriptor_1 = require("../types/GetViewportDescriptor");
|
|
11
12
|
const oldToNewAssertionTypes = {
|
|
12
13
|
assert_contains: 'AssertContains',
|
|
13
14
|
assert_does_not_contain: 'AssertDoesNotContain',
|
|
@@ -73,7 +74,9 @@ class AssertStepOld extends MablStep_1.MablStep {
|
|
|
73
74
|
}
|
|
74
75
|
const find = this.primaryAction.toDescriptor();
|
|
75
76
|
formatted.findOptions = find.selectorFindOption;
|
|
76
|
-
if ((0, GetCurrentLocationDescriptor_1.isGetCurrentLocationDescriptor)(find) ||
|
|
77
|
+
if ((0, GetCurrentLocationDescriptor_1.isGetCurrentLocationDescriptor)(find) ||
|
|
78
|
+
(0, GetVariableDescriptor_1.isGetVariableDescriptor)(find) ||
|
|
79
|
+
(0, GetViewportDescriptor_1.isGetViewportDescriptor)(find)) {
|
|
77
80
|
formatted.kind = find.kind;
|
|
78
81
|
}
|
|
79
82
|
else {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.newGetViewportDescriptor = exports.isGetViewportDescriptor = exports.GET_VIEWPORT_KIND = void 0;
|
|
4
|
+
exports.GET_VIEWPORT_KIND = 'Viewport';
|
|
5
|
+
function isGetViewportDescriptor(value) {
|
|
6
|
+
return value.kind === exports.GET_VIEWPORT_KIND;
|
|
7
|
+
}
|
|
8
|
+
exports.isGetViewportDescriptor = isGetViewportDescriptor;
|
|
9
|
+
function newGetViewportDescriptor() {
|
|
10
|
+
return { kind: exports.GET_VIEWPORT_KIND };
|
|
11
|
+
}
|
|
12
|
+
exports.newGetViewportDescriptor = newGetViewportDescriptor;
|