@mablhq/mabl-cli 2.72.0 → 2.72.3
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/core/execution/ApiTestUtils.js +12 -2
- package/execution/index.js +1 -1
- package/mablscript/MablStepV2.js +10 -40
- package/mablscript/MablStepWithFindAction.js +2 -126
- package/mablscript/actions/AwaitDownloadAction.js +3 -4
- package/mablscript/actions/AwaitPDFDownloadAction.js +5 -6
- package/mablscript/actions/ConditionAction.js +1 -2
- package/mablscript/actions/ExtractAction.js +13 -8
- package/mablscript/actions/FindAction.js +0 -20
- package/mablscript/actions/GetVariableValue.js +4 -15
- package/mablscript/actions/JavaScriptAction.js +39 -25
- package/mablscript/diffing/diffingUtil.js +5 -5
- package/mablscript/importer.js +59 -79
- package/mablscript/mobile/steps/CreateVariableMobileStep.js +1 -3
- package/mablscript/mobile/steps/stepUtil.js +2 -2
- package/mablscript/steps/AbstractAssertionsAndVariablesStep.js +8 -10
- package/mablscript/steps/AccessibilityCheck.js +36 -76
- package/mablscript/steps/AssertStep.js +86 -266
- package/mablscript/steps/AssertStepOld.js +139 -69
- package/mablscript/steps/AwaitTabStep.js +9 -30
- package/mablscript/steps/AwaitUploadsStep.js +8 -22
- package/mablscript/steps/ClearCookiesStep.js +8 -22
- package/mablscript/steps/ClickAndHoldStep.js +47 -45
- package/mablscript/steps/ClickStep.js +33 -36
- package/mablscript/steps/CreateVariableStep.js +137 -169
- package/mablscript/steps/DatabaseQueryStep.js +4 -14
- package/mablscript/steps/DoubleClickStep.js +40 -37
- package/mablscript/steps/DownloadStep.js +63 -79
- package/mablscript/steps/EchoStep.js +8 -26
- package/mablscript/steps/ElseIfConditionStep.js +12 -23
- package/mablscript/steps/ElseStep.js +9 -22
- package/mablscript/steps/EndStep.js +9 -22
- package/mablscript/steps/EnterAuthCodeStep.js +34 -36
- package/mablscript/steps/EnterTextStep.js +64 -51
- package/mablscript/steps/EvaluateFlowStep.js +18 -39
- package/mablscript/steps/EvaluateJavaScriptStep.js +19 -17
- package/mablscript/steps/HoverStep.js +39 -37
- package/mablscript/steps/IfConditionStep.js +99 -139
- package/mablscript/steps/NavigateStep.js +9 -29
- package/mablscript/steps/OpenEmailStep.js +21 -39
- package/mablscript/steps/ReleaseStep.js +38 -46
- package/mablscript/steps/RemoveCookieStep.js +9 -25
- package/mablscript/steps/RightClickStep.js +33 -36
- package/mablscript/steps/SelectStep.js +46 -69
- package/mablscript/steps/SendHttpRequestStep.js +4 -13
- package/mablscript/steps/SendKeyStep.js +50 -174
- package/mablscript/steps/SetCookieStep.js +23 -56
- package/mablscript/steps/SetFilesStep.js +43 -42
- package/mablscript/steps/SetViewportStep.js +13 -39
- package/mablscript/steps/SwitchContextStep.js +83 -89
- package/mablscript/steps/SyntheticStep.js +1 -1
- package/mablscript/steps/VisitUrlStep.js +22 -30
- package/mablscript/steps/WaitStep.js +9 -20
- package/mablscript/steps/WaitUntilStep.js +14 -31
- package/mablscript/types/ConditionDescriptor.js +5 -5
- package/mablscript/types/GetVariableDescriptor.js +8 -0
- package/package.json +1 -1
- package/mablscript/steps/StepGroupStep.js +0 -70
- package/mablscript/types/AssertStepDescriptor.js +0 -2
- package/mablscript/types/StepGroupStepDescriptor.js +0 -2
package/mablscript/importer.js
CHANGED
|
@@ -103,6 +103,7 @@ const ActionTypes = [
|
|
|
103
103
|
const StepTypes = [
|
|
104
104
|
AccessibilityCheck_1.AccessibilityCheckStep,
|
|
105
105
|
AssertStep_1.AssertStep,
|
|
106
|
+
AssertStepOld_1.AssertStepOld,
|
|
106
107
|
AwaitTabStep_1.AwaitTabStep,
|
|
107
108
|
AwaitUploadsStep_1.AwaitUploadsStep,
|
|
108
109
|
ClearCookiesStep_1.ClearCookiesStep,
|
|
@@ -155,6 +156,15 @@ const MobileStepTypes = [
|
|
|
155
156
|
PushFileStep_1.PushFileStep,
|
|
156
157
|
UninstallAppStep_1.UninstallAppStep,
|
|
157
158
|
];
|
|
159
|
+
const SyntheticActionCodes = [
|
|
160
|
+
'autologin',
|
|
161
|
+
'capture_application_state',
|
|
162
|
+
'root_page',
|
|
163
|
+
'verify_url',
|
|
164
|
+
'validate_links',
|
|
165
|
+
'validate_page',
|
|
166
|
+
];
|
|
167
|
+
const ACCESSIBILITY_CHECK_ACTION_NAME = 'accessibility_check';
|
|
158
168
|
function parseMablScript(mablscript) {
|
|
159
169
|
const ast = (0, esprima_1.parseScript)(mablscript, { loc: true });
|
|
160
170
|
const stepStack = {};
|
|
@@ -188,24 +198,16 @@ function parseMablScript(mablscript) {
|
|
|
188
198
|
}
|
|
189
199
|
const rawMablscriptToObjectsStepMap = {};
|
|
190
200
|
StepTypes.forEach((step) => {
|
|
191
|
-
step.mablScriptStepNames
|
|
192
|
-
.concat(step.yamlMablScriptNames)
|
|
193
|
-
.forEach((name) => (rawMablscriptToObjectsStepMap[name] = step));
|
|
201
|
+
step.mablScriptStepNames.forEach((name) => (rawMablscriptToObjectsStepMap[name] = step));
|
|
194
202
|
});
|
|
195
203
|
const rawMablscriptToObjectsActionsMap = {};
|
|
196
204
|
ActionTypes.forEach((step) => {
|
|
197
205
|
step.mablScriptStepNames.forEach((name) => (rawMablscriptToObjectsActionsMap[name] = step));
|
|
198
206
|
});
|
|
199
|
-
const legacyMablscriptStepGeneratorMap = {};
|
|
200
|
-
StepTypes.forEach((step) => {
|
|
201
|
-
step.mablScriptStepNames.forEach((name) => {
|
|
202
|
-
legacyMablscriptStepGeneratorMap[name] = step
|
|
203
|
-
.fromLegacyMablscript;
|
|
204
|
-
});
|
|
205
|
-
});
|
|
206
207
|
function loadMablScriptIntoSteps(parsedMablscript) {
|
|
207
208
|
return Object.entries(parsedMablscript).map(([stepIndexString, [...parsed]]) => {
|
|
208
209
|
const lastAction = parsed.pop();
|
|
210
|
+
const stepType = rawMablscriptToObjectsStepMap[lastAction.name];
|
|
209
211
|
const actions = parsed.map((parsedAction, actionIndex) => {
|
|
210
212
|
const actionType = rawMablscriptToObjectsActionsMap[parsedAction.name];
|
|
211
213
|
const action = actionType
|
|
@@ -214,33 +216,13 @@ function loadMablScriptIntoSteps(parsedMablscript) {
|
|
|
214
216
|
action.setActionSourceIndexInStep(actionIndex);
|
|
215
217
|
return action;
|
|
216
218
|
});
|
|
217
|
-
let step
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
step =
|
|
222
|
-
wasAssertStepOld = true;
|
|
223
|
-
}
|
|
224
|
-
else if (lastAction.name === 'assert') {
|
|
225
|
-
step = new AssertStep_1.AssertStep(lastAction.name, lastAction.arguments, actions);
|
|
226
|
-
}
|
|
227
|
-
else {
|
|
228
|
-
const stepGenerator = legacyMablscriptStepGeneratorMap[lastAction.name];
|
|
229
|
-
step = stepGenerator
|
|
230
|
-
? stepGenerator(lastAction.arguments, actions)
|
|
231
|
-
: new MablStep_1.MablStep(lastAction.name, lastAction.arguments, actions, lastAction.name);
|
|
232
|
-
}
|
|
233
|
-
if ((0, MablStepV2_1.isMablStepV2)(step)) {
|
|
234
|
-
if (wasAssertStepOld) {
|
|
235
|
-
step.setActionSourceIndexInStep(actions.length);
|
|
236
|
-
}
|
|
237
|
-
else {
|
|
238
|
-
step.setActionSourceIndexInStep(step.actions.length);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
else {
|
|
242
|
-
step.setActionSourceIndexInStep(actions.length);
|
|
219
|
+
let step = stepType
|
|
220
|
+
? new stepType(lastAction.name, lastAction.arguments, actions)
|
|
221
|
+
: new MablStep_1.MablStep(lastAction.name, lastAction.arguments, actions, lastAction.name);
|
|
222
|
+
if (step instanceof AssertStepOld_1.AssertStepOld) {
|
|
223
|
+
step = step.getNewAssertionStep();
|
|
243
224
|
}
|
|
225
|
+
step.setActionSourceIndexInStep(actions.length);
|
|
244
226
|
step.setStepSourceIndexInFlow(parseInt(stepIndexString));
|
|
245
227
|
return step;
|
|
246
228
|
});
|
|
@@ -251,9 +233,7 @@ function yamlifyTheLoadedSteps(translatedSteps, fullLocatorsOn = true) {
|
|
|
251
233
|
}
|
|
252
234
|
const yamlMablscriptToObjectsStepV1Map = {};
|
|
253
235
|
StepTypes.forEach((step) => {
|
|
254
|
-
step.yamlMablScriptNames.forEach((name) =>
|
|
255
|
-
yamlMablscriptToObjectsStepV1Map[name] = step.fromYaml;
|
|
256
|
-
});
|
|
236
|
+
step.yamlMablScriptNames.forEach((name) => (yamlMablscriptToObjectsStepV1Map[name] = step.fromYaml));
|
|
257
237
|
});
|
|
258
238
|
const yamlMablscriptToObjectsMobileStepMap = {};
|
|
259
239
|
MobileStepTypes.forEach((step) => {
|
|
@@ -265,38 +245,41 @@ function loadYamlSteps(yamlSteps, isMobile) {
|
|
|
265
245
|
}
|
|
266
246
|
function interpretStepsFromObjectsInFlow(flow, isMobile) {
|
|
267
247
|
const steps = interpretStepsFromObjects(flow.json_steps?.steps, isMobile);
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
function applyStepDescriptionsAndAnnotations(steps, flow) {
|
|
272
|
-
if (flow.script_description || flow.step_annotations) {
|
|
273
|
-
const flowDescriptions = flow.script_description?.split('\n') ?? [];
|
|
274
|
-
steps.forEach((step, index) => {
|
|
275
|
-
if (flowDescriptions[index]) {
|
|
276
|
-
step.setDescription(flowDescriptions[index]);
|
|
277
|
-
}
|
|
278
|
-
const stepAnnotation = flow?.step_annotations?.[index];
|
|
279
|
-
if (stepAnnotation) {
|
|
280
|
-
step.setAnnotation(stepAnnotation);
|
|
281
|
-
}
|
|
282
|
-
});
|
|
248
|
+
let flowDescriptions = [];
|
|
249
|
+
if (flow.script_description) {
|
|
250
|
+
flowDescriptions = flow.script_description?.split('\n') ?? [];
|
|
283
251
|
}
|
|
252
|
+
steps.forEach((step, index) => {
|
|
253
|
+
step.setDescription(flowDescriptions[index]);
|
|
254
|
+
if (flow?.step_annotations?.[index]) {
|
|
255
|
+
step.setAnnotation(flow.step_annotations[index]);
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
return steps;
|
|
284
259
|
}
|
|
285
260
|
function interpretStepsFromObjects(steps, isMobile) {
|
|
261
|
+
let cumulativeIndex = 0;
|
|
286
262
|
return steps.map((stepObject, index) => {
|
|
287
263
|
const stepName = Object.keys(stepObject)[0];
|
|
288
264
|
const stepArgs = stepObject[stepName];
|
|
289
265
|
const isStepDisabled = stepObject[stepName].disabled;
|
|
290
266
|
const step = stepFromObjectInfo(stepName, stepArgs, isMobile ?? false);
|
|
291
267
|
step.setStepSourceIndexInFlow(index);
|
|
268
|
+
const actionCount = step.actions.length;
|
|
292
269
|
step.actions?.forEach((action, actionIndex) => {
|
|
293
|
-
if ((0, MablStepV2_1.isMablStepV2)(step)) {
|
|
270
|
+
if ((0, MablStepV2_1.isMablStepV2)(step) && actionIndex + 1 !== actionCount) {
|
|
294
271
|
action.setActionSourceIndexInStep(actionIndex);
|
|
272
|
+
if (step.actionCode && SyntheticActionCodes.includes(step.actionCode)) {
|
|
273
|
+
step.cumulativeActionSourceIndexInFlow = steps.length;
|
|
274
|
+
}
|
|
275
|
+
else if (step.actionCode === ACCESSIBILITY_CHECK_ACTION_NAME) {
|
|
276
|
+
step.cumulativeActionSourceIndexInFlow = 1;
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
action.cumulativeActionSourceIndexInFlow = cumulativeIndex++;
|
|
280
|
+
}
|
|
295
281
|
}
|
|
296
282
|
});
|
|
297
|
-
if ((0, MablStepV2_1.isMablStepV2)(step)) {
|
|
298
|
-
step.setActionSourceIndexInStep(step.actions.length);
|
|
299
|
-
}
|
|
300
283
|
if (isStepDisabled) {
|
|
301
284
|
step.setDisabled(isStepDisabled);
|
|
302
285
|
}
|
|
@@ -304,9 +287,6 @@ function interpretStepsFromObjects(steps, isMobile) {
|
|
|
304
287
|
});
|
|
305
288
|
}
|
|
306
289
|
function stepFromObjectInfo(stepName, stepArgs, isMobile) {
|
|
307
|
-
if (stepName.startsWith('assert_') && stepName !== 'assert_download') {
|
|
308
|
-
return AssertStepOld_1.AssertStepOldConverter.convert(stepName, stepArgs, []);
|
|
309
|
-
}
|
|
310
290
|
if (isMobile &&
|
|
311
291
|
Object.keys(yamlMablscriptToObjectsMobileStepMap).includes(stepName)) {
|
|
312
292
|
return yamlMablscriptToObjectsMobileStepMap[stepName](stepName, stepArgs);
|
|
@@ -478,20 +458,23 @@ function removeCommentsAndGetDisabledIndices(mablscript) {
|
|
|
478
458
|
return { updatedScript, disabledIndices };
|
|
479
459
|
}
|
|
480
460
|
function parseMablScriptIntoSteps(flow) {
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
const isMobile = flow.flow_type === mablApi_1.TestTypeEnum.Mobile;
|
|
484
|
-
loadedSteps = interpretStepsFromObjects(flow.json_steps.steps, isMobile);
|
|
461
|
+
if (!flow.script) {
|
|
462
|
+
return [];
|
|
485
463
|
}
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
loadedSteps = loadMablScriptIntoSteps(parsed);
|
|
490
|
-
loadedSteps
|
|
491
|
-
.filter((_step, index) => disabledIndices.includes(index))
|
|
492
|
-
.forEach((step) => step.setDisabled(true));
|
|
464
|
+
let flowDescriptions = [];
|
|
465
|
+
if (flow.script_description) {
|
|
466
|
+
flowDescriptions = flow.script_description.split('\n');
|
|
493
467
|
}
|
|
494
|
-
|
|
468
|
+
const { updatedScript, disabledIndices } = removeCommentsAndGetDisabledIndices(flow.script);
|
|
469
|
+
const parsed = parseMablScript(updatedScript);
|
|
470
|
+
const loadedSteps = loadMablScriptIntoSteps(parsed);
|
|
471
|
+
loadedSteps.forEach((step, index) => {
|
|
472
|
+
step.setDescription(flowDescriptions[index]);
|
|
473
|
+
if (flow?.step_annotations?.[index]) {
|
|
474
|
+
step.setAnnotation(flow.step_annotations[index]);
|
|
475
|
+
}
|
|
476
|
+
step.setDisabled(disabledIndices.includes(index));
|
|
477
|
+
});
|
|
495
478
|
return loadedSteps;
|
|
496
479
|
}
|
|
497
480
|
function extractInputVariables(steps) {
|
|
@@ -508,10 +491,7 @@ function parseMablScriptIntoV2Step(script) {
|
|
|
508
491
|
script,
|
|
509
492
|
});
|
|
510
493
|
const stepAsObject = parsedMablscriptStep[0].getFormattedStep(true);
|
|
511
|
-
|
|
512
|
-
if (parsedStep.getStepName() === 'UnimplementedStep') {
|
|
513
|
-
[parsedStep] = interpretStepsFromObjects([stepAsObject], false);
|
|
514
|
-
}
|
|
494
|
+
const [parsedStep] = interpretStepsFromObjects([stepAsObject], true);
|
|
515
495
|
return parsedStep;
|
|
516
496
|
}
|
|
517
497
|
function getQueryIds(flows, testType) {
|
|
@@ -533,8 +513,8 @@ function getSnippetIdFromStep(step) {
|
|
|
533
513
|
}
|
|
534
514
|
else if ((0, CreateVariableStep_1.isCreateVariableStep)(step)) {
|
|
535
515
|
if (step.generationType === CreateVariableStepDescriptor_1.VariableGenerator.JAVASCRIPT &&
|
|
536
|
-
(0, JavaScriptAction_1.isJavaScriptActionDescriptor)(step.
|
|
537
|
-
jsDescriptor = step.
|
|
516
|
+
(0, JavaScriptAction_1.isJavaScriptActionDescriptor)(step.actions[0])) {
|
|
517
|
+
jsDescriptor = step.actions[0].javaScript;
|
|
538
518
|
}
|
|
539
519
|
}
|
|
540
520
|
else if ((0, DatabaseQueryStep_1.isDatabaseQueryStep)(step)) {
|
|
@@ -33,9 +33,7 @@ class CreateVariableMobileStep extends MablStepV2_1.MablStepV2 {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
static fromYaml(_stepName, stepDescriptor) {
|
|
36
|
-
if (stepDescriptor.
|
|
37
|
-
!stepDescriptor.find &&
|
|
38
|
-
stepDescriptor.generator.find) {
|
|
36
|
+
if (!stepDescriptor.find) {
|
|
39
37
|
stepDescriptor.find = stepDescriptor.generator.find;
|
|
40
38
|
delete stepDescriptor.generator.find;
|
|
41
39
|
delete stepDescriptor.selector;
|
|
@@ -53,7 +53,7 @@ function buildElementDescriptionForAndroid(findTarget) {
|
|
|
53
53
|
return `unknown android element`;
|
|
54
54
|
}
|
|
55
55
|
if (androidElementSelector.find_prompt) {
|
|
56
|
-
return `"${androidElementSelector.find_prompt}"`;
|
|
56
|
+
return `"${(0, domUtil_1.normalizeText)(androidElementSelector.find_prompt)}"`;
|
|
57
57
|
}
|
|
58
58
|
const description = `"${getSimpleAndroidElementName(androidElementSelector.class)}" element`;
|
|
59
59
|
if (androidElementSelector?.hint) {
|
|
@@ -74,7 +74,7 @@ function buildElementDescriptionForiOS(findTarget) {
|
|
|
74
74
|
return `unknown iOS element`;
|
|
75
75
|
}
|
|
76
76
|
if (iOSElementSelector.find_prompt) {
|
|
77
|
-
return `"${iOSElementSelector.find_prompt}"`;
|
|
77
|
+
return `"${(0, domUtil_1.normalizeText)(iOSElementSelector.find_prompt)}"`;
|
|
78
78
|
}
|
|
79
79
|
if (iOSElementSelector.name) {
|
|
80
80
|
return `"${iOSElementSelector.name}" element`;
|
|
@@ -3,18 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AbstractAssertionsAndVariablesStep = void 0;
|
|
4
4
|
const domUtil_1 = require("../../domUtil");
|
|
5
5
|
const MablAction_1 = require("../MablAction");
|
|
6
|
-
const
|
|
6
|
+
const MablStep_1 = require("../MablStep");
|
|
7
7
|
const ConditionDescriptor_1 = require("../types/ConditionDescriptor");
|
|
8
8
|
const AssertStep_1 = require("./AssertStep");
|
|
9
|
-
class AbstractAssertionsAndVariablesStep extends
|
|
10
|
-
constructor(name,
|
|
11
|
-
super(name,
|
|
9
|
+
class AbstractAssertionsAndVariablesStep extends MablStep_1.MablStep {
|
|
10
|
+
constructor(name, args, actions, mablScriptName, stepName, descriptor) {
|
|
11
|
+
super(name, args, actions, mablScriptName);
|
|
12
|
+
this.stepName = stepName;
|
|
13
|
+
this.descriptor = descriptor;
|
|
12
14
|
}
|
|
13
15
|
getStepName() {
|
|
14
|
-
return this.
|
|
15
|
-
}
|
|
16
|
-
stepDescription() {
|
|
17
|
-
return `Execute ${this.getStepName()}`;
|
|
16
|
+
return this.stepName;
|
|
18
17
|
}
|
|
19
18
|
toStepDescriptor() {
|
|
20
19
|
const formatted = JSON.parse(JSON.stringify(this.descriptor));
|
|
@@ -27,9 +26,8 @@ class AbstractAssertionsAndVariablesStep extends MablStepV2_1.MablStepV2 {
|
|
|
27
26
|
return formatted;
|
|
28
27
|
}
|
|
29
28
|
toMablscript() {
|
|
30
|
-
const { actionCode, description, ...params } = this.toStepDescriptor();
|
|
31
29
|
return `${this.getActionCode()}(${(0, domUtil_1.buildStepArgumentString)({
|
|
32
|
-
params,
|
|
30
|
+
params: { ...this.descriptor },
|
|
33
31
|
legacy: true,
|
|
34
32
|
})})`;
|
|
35
33
|
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AccessibilityCheckStep = exports.AccessibilityCheckSeverity = void 0;
|
|
4
4
|
const MablStep_1 = require("../MablStep");
|
|
5
|
-
const MablStepV2_1 = require("../MablStepV2");
|
|
6
5
|
const FindAction_1 = require("../actions/FindAction");
|
|
7
6
|
const ActionsUtils_1 = require("./ActionsUtils");
|
|
8
7
|
const domUtil_1 = require("../../domUtil");
|
|
@@ -13,39 +12,19 @@ var AccessibilityCheckSeverity;
|
|
|
13
12
|
AccessibilityCheckSeverity["Moderate"] = "moderate";
|
|
14
13
|
AccessibilityCheckSeverity["Serious"] = "serious";
|
|
15
14
|
})(AccessibilityCheckSeverity || (exports.AccessibilityCheckSeverity = AccessibilityCheckSeverity = {}));
|
|
16
|
-
class AccessibilityCheckStep extends
|
|
17
|
-
constructor(
|
|
18
|
-
super(
|
|
19
|
-
if (
|
|
20
|
-
this.findAction =
|
|
21
|
-
}
|
|
22
|
-
const maybeCheckConfig = {
|
|
23
|
-
...(descriptor.tags && { tags: descriptor.tags }),
|
|
24
|
-
...(descriptor.rules && { rules: descriptor.rules }),
|
|
25
|
-
...(descriptor.disabledRules && {
|
|
26
|
-
disabledRules: descriptor.disabledRules,
|
|
27
|
-
}),
|
|
28
|
-
...(descriptor.failOn && { failOn: descriptor.failOn }),
|
|
29
|
-
...(descriptor.runInMainFrame !== undefined && {
|
|
30
|
-
runInMainFrame: descriptor.runInMainFrame,
|
|
31
|
-
}),
|
|
32
|
-
...(descriptor.bypassCors !== undefined && {
|
|
33
|
-
bypassCors: descriptor.bypassCors,
|
|
34
|
-
}),
|
|
35
|
-
...(descriptor.disabledRulesOnIframes && {
|
|
36
|
-
disabledRulesOnIframes: descriptor.disabledRulesOnIframes,
|
|
37
|
-
}),
|
|
38
|
-
};
|
|
39
|
-
const hasCheckConfig = Object.values(maybeCheckConfig).filter((value) => !!value).length > 0;
|
|
40
|
-
if (hasCheckConfig) {
|
|
41
|
-
this.checkConfig = maybeCheckConfig;
|
|
15
|
+
class AccessibilityCheckStep extends MablStep_1.MablStep {
|
|
16
|
+
constructor(name, args, actions) {
|
|
17
|
+
super(name, args, actions, 'accessibility_check');
|
|
18
|
+
if (this.actions.length) {
|
|
19
|
+
this.findAction = ActionsUtils_1.ActionsUtils.validateSingleFindAction(this.actions);
|
|
42
20
|
}
|
|
21
|
+
this.checkConfig = this.getActionArgs()[0];
|
|
43
22
|
}
|
|
44
23
|
canContinueOnFailure() {
|
|
45
24
|
return true;
|
|
46
25
|
}
|
|
47
26
|
getStepName() {
|
|
48
|
-
return AccessibilityCheckStep.
|
|
27
|
+
return AccessibilityCheckStep.yamlMablScriptNames[0];
|
|
49
28
|
}
|
|
50
29
|
toStepDescriptor() {
|
|
51
30
|
if (this.findAction) {
|
|
@@ -58,7 +37,7 @@ class AccessibilityCheckStep extends MablStepV2_1.MablStepV2 {
|
|
|
58
37
|
return {
|
|
59
38
|
...this.checkConfig,
|
|
60
39
|
find,
|
|
61
|
-
descriptorToActionMap: new Map().set(find, this
|
|
40
|
+
descriptorToActionMap: new Map().set(find, this),
|
|
62
41
|
actionCode: this.actionCode,
|
|
63
42
|
};
|
|
64
43
|
default:
|
|
@@ -70,12 +49,33 @@ class AccessibilityCheckStep extends MablStepV2_1.MablStepV2 {
|
|
|
70
49
|
...this.checkConfig,
|
|
71
50
|
};
|
|
72
51
|
}
|
|
52
|
+
getFormattedStep(_fullLocatorsOn) {
|
|
53
|
+
let finalStep;
|
|
54
|
+
if (this.findAction) {
|
|
55
|
+
finalStep = {
|
|
56
|
+
AccessibilityCheck: {
|
|
57
|
+
...super.annotationsAsYml(),
|
|
58
|
+
...this.findAction.toYaml(),
|
|
59
|
+
...this.checkConfig,
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
finalStep = {
|
|
65
|
+
AccessibilityCheck: {
|
|
66
|
+
...super.annotationsAsYml(),
|
|
67
|
+
...this.checkConfig,
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
if (this.stepId()) {
|
|
72
|
+
finalStep.AccessibilityCheck.id = this.stepId();
|
|
73
|
+
}
|
|
74
|
+
return finalStep;
|
|
75
|
+
}
|
|
73
76
|
static fromYaml(_stepName, stepArgs) {
|
|
74
77
|
const actions = [];
|
|
75
|
-
if (stepArgs.
|
|
76
|
-
actions.push(FindAction_1.FindAction.findActionFromStepArgs(stepArgs));
|
|
77
|
-
}
|
|
78
|
-
else if (stepArgs.selector) {
|
|
78
|
+
if (stepArgs.selector) {
|
|
79
79
|
actions.push(FindAction_1.FindAction.findActionFromStepArgs(stepArgs));
|
|
80
80
|
}
|
|
81
81
|
const checkConfig = {
|
|
@@ -84,19 +84,10 @@ class AccessibilityCheckStep extends MablStepV2_1.MablStepV2 {
|
|
|
84
84
|
disabledRules: stepArgs.disabledRules,
|
|
85
85
|
failOn: stepArgs.failOn,
|
|
86
86
|
};
|
|
87
|
-
const
|
|
88
|
-
const step = new AccessibilityCheckStep(stepDescriptor);
|
|
87
|
+
const step = new AccessibilityCheckStep(AccessibilityCheckStep.mablScriptStepNames[0], [checkConfig], actions);
|
|
89
88
|
step.setStepId(stepArgs.id);
|
|
90
89
|
return step;
|
|
91
90
|
}
|
|
92
|
-
static fromLegacyMablscript(args, actions) {
|
|
93
|
-
const checkConfig = args[0];
|
|
94
|
-
const findAction = actions.length
|
|
95
|
-
? ActionsUtils_1.ActionsUtils.validateSingleFindAction(actions)
|
|
96
|
-
: undefined;
|
|
97
|
-
const stepDescriptor = buildStepDescriptor(findAction, checkConfig);
|
|
98
|
-
return new AccessibilityCheckStep(stepDescriptor);
|
|
99
|
-
}
|
|
100
91
|
toMablscript() {
|
|
101
92
|
let argString = '';
|
|
102
93
|
if (this.checkConfig?.tags ||
|
|
@@ -110,38 +101,7 @@ class AccessibilityCheckStep extends MablStepV2_1.MablStepV2 {
|
|
|
110
101
|
}
|
|
111
102
|
return `${findAction}${AccessibilityCheckStep.mablScriptStepNames[0]}(${argString})`;
|
|
112
103
|
}
|
|
113
|
-
getInputVariables() {
|
|
114
|
-
return this.findAction?.getInputVariables() ?? [];
|
|
115
|
-
}
|
|
116
|
-
stepDescription() {
|
|
117
|
-
return 'Check accessibility';
|
|
118
|
-
}
|
|
119
104
|
}
|
|
120
105
|
exports.AccessibilityCheckStep = AccessibilityCheckStep;
|
|
121
|
-
AccessibilityCheckStep.
|
|
122
|
-
AccessibilityCheckStep.
|
|
123
|
-
AccessibilityCheckStep.mablScriptStepNames = [AccessibilityCheckStep.actionCode];
|
|
124
|
-
AccessibilityCheckStep.yamlMablScriptNames = [AccessibilityCheckStep.stepName];
|
|
125
|
-
function buildStepDescriptor(findAction, checkConfig) {
|
|
126
|
-
if (findAction) {
|
|
127
|
-
const find = findAction.toDescriptor();
|
|
128
|
-
switch (find.findType) {
|
|
129
|
-
case domUtil_1.FindType.FIND_FIRST:
|
|
130
|
-
case domUtil_1.FindType.FIND_LAST:
|
|
131
|
-
case domUtil_1.FindType.FIND_ANY:
|
|
132
|
-
case domUtil_1.FindType.FIND_ONE:
|
|
133
|
-
return {
|
|
134
|
-
...checkConfig,
|
|
135
|
-
find,
|
|
136
|
-
descriptorToActionMap: new Map().set(find, findAction),
|
|
137
|
-
actionCode: AccessibilityCheckStep.actionCode,
|
|
138
|
-
};
|
|
139
|
-
default:
|
|
140
|
-
throw new Error(`Error generating step descriptor for ${AccessibilityCheckStep.stepName}: Unexpected find type ${find.findType}`);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
return {
|
|
144
|
-
actionCode: AccessibilityCheckStep.actionCode,
|
|
145
|
-
...checkConfig,
|
|
146
|
-
};
|
|
147
|
-
}
|
|
106
|
+
AccessibilityCheckStep.mablScriptStepNames = ['accessibility_check'];
|
|
107
|
+
AccessibilityCheckStep.yamlMablScriptNames = ['AccessibilityCheck'];
|