@mablhq/mabl-cli 1.16.32 → 1.18.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.
Files changed (152) hide show
  1. package/api/basicApiClient.js +9 -4
  2. package/api/featureSet.js +1 -4
  3. package/api/mablApiClient.js +16 -9
  4. package/browserLauncher/browserLauncherFactory.js +4 -4
  5. package/browserLauncher/elementHandle.js +2 -1
  6. package/browserLauncher/playwrightBrowserLauncher/playwrightBrowser.js +8 -1
  7. package/browserLauncher/playwrightBrowserLauncher/playwrightBrowserLauncher.js +11 -9
  8. package/browserLauncher/playwrightBrowserLauncher/playwrightDom.js +23 -29
  9. package/browserLauncher/playwrightBrowserLauncher/playwrightFrame.js +28 -6
  10. package/browserLauncher/playwrightBrowserLauncher/playwrightHttpRequest.js +5 -1
  11. package/browserLauncher/playwrightBrowserLauncher/playwrightPage.js +13 -9
  12. package/browserLauncher/runnerType.js +0 -1
  13. package/cli.js +12 -8
  14. package/commands/applications/applications_cmds/describe.js +4 -4
  15. package/commands/applications/applications_cmds/list.js +4 -4
  16. package/commands/auth/auth_cmds/activate-key.js +1 -1
  17. package/commands/branches/branches_cmds/create.js +4 -4
  18. package/commands/branches/branches_cmds/describe.js +3 -3
  19. package/commands/branches/branches_cmds/list.js +3 -3
  20. package/commands/branches/branches_cmds/merge.js +4 -4
  21. package/commands/commandUtil/codeInsights.js +4 -2
  22. package/commands/commandUtil/describe.js +1 -1
  23. package/commands/commandUtil/fileUtil.js +5 -1
  24. package/commands/commandUtil/util.js +2 -2
  25. package/commands/config/config_cmds/delete.js +1 -1
  26. package/commands/config/config_cmds/set.js +1 -1
  27. package/commands/constants.js +3 -1
  28. package/commands/credentials/credentials_cmds/list.js +4 -4
  29. package/commands/deploy/deploy_cmds/create.js +18 -13
  30. package/commands/deploy/deploy_cmds/describe.js +5 -5
  31. package/commands/deploy/deploy_cmds/executionResultPresenter.js +1 -1
  32. package/commands/deploy/deploy_cmds/list.js +4 -4
  33. package/commands/deploy/deploy_cmds/watch.js +2 -2
  34. package/commands/environments/environments_cmds/create.js +7 -7
  35. package/commands/environments/environments_cmds/delete.js +1 -1
  36. package/commands/environments/environments_cmds/describe.js +4 -4
  37. package/commands/environments/environments_cmds/list.js +4 -4
  38. package/commands/environments/environments_cmds/update.js +2 -2
  39. package/commands/environments/environments_cmds/urls_cmds/add.js +3 -3
  40. package/commands/environments/environments_cmds/urls_cmds/list.js +2 -2
  41. package/commands/flows/flows_cmds/export.js +5 -5
  42. package/commands/flows/flows_cmds/list.js +2 -2
  43. package/commands/link-agents/link-agents_cmds/delete.js +1 -1
  44. package/commands/plans/plans_cmds/describe.js +4 -4
  45. package/commands/plans/plans_cmds/list.js +2 -2
  46. package/commands/test-runs/test-runs_cmds/export.js +2 -2
  47. package/commands/tests/executionUtil.js +5 -5
  48. package/commands/tests/testsUtil.js +30 -18
  49. package/commands/tests/tests_cmds/create.js +3 -3
  50. package/commands/tests/tests_cmds/edit.js +3 -3
  51. package/commands/tests/tests_cmds/export.js +7 -7
  52. package/commands/tests/tests_cmds/import.js +35 -14
  53. package/commands/tests/tests_cmds/list.js +3 -3
  54. package/commands/tests/tests_cmds/run-alpha.js +3 -3
  55. package/commands/tests/tests_cmds/run-cloud.js +4 -4
  56. package/commands/tests/tests_cmds/run-legacy.js +8 -8
  57. package/commands/tests/tests_cmds/run.js +13 -8
  58. package/commands/tests/tests_cmds/trainer_cmds/trainerUtil.js +2 -2
  59. package/commands/tests/tests_cmds/trainer_cmds/update.js +1 -1
  60. package/commands/tests/tests_cmds/trainer_cmds/version.js +2 -2
  61. package/commands/workspaces/workspace_cmds/copy.js +2 -2
  62. package/commands/workspaces/workspace_cmds/describe.js +4 -4
  63. package/commands/workspaces/workspace_cmds/list.js +2 -2
  64. package/configGenerators/flowConfigGenerator.js +1 -1
  65. package/configGenerators/selIdeGenerator.js +6 -6
  66. package/core/messaging/actions/runnerActions.js +2 -2
  67. package/core/trainer/openUtils.js +2 -2
  68. package/core/trainer/trainingSessions.js +26 -26
  69. package/domUtil/index.js +1 -1
  70. package/domUtil/index.js.LICENSE.txt +5 -5
  71. package/env/env.js +5 -1
  72. package/execution/index.js +1 -1
  73. package/execution/index.js.LICENSE.txt +7 -5
  74. package/index.d.ts +0 -1
  75. package/mablApi/index.js +1 -1
  76. package/mablscript/AttributesConstants.js +2 -1
  77. package/mablscript/MablAction.js +1 -1
  78. package/mablscript/MablStep.js +26 -14
  79. package/mablscript/actions/AwaitPDFDownloadAction.js +2 -1
  80. package/mablscript/actions/ConditionAction.js +12 -4
  81. package/mablscript/actions/ExtractAction.js +16 -7
  82. package/mablscript/actions/FindAction.js +105 -80
  83. package/mablscript/actions/GenerateRandomStringAction.js +2 -1
  84. package/mablscript/actions/GetUrlAction.js +2 -2
  85. package/mablscript/actions/GetVariableValue.js +3 -3
  86. package/mablscript/actions/JavaScriptAction.js +16 -16
  87. package/mablscript/diffing/diffingUtil.js +146 -0
  88. package/mablscript/importer.js +26 -8
  89. package/mablscript/steps/AccessibilityCheck.js +9 -7
  90. package/mablscript/steps/AssertStep.js +60 -46
  91. package/mablscript/steps/AssertStepOld.js +41 -23
  92. package/mablscript/steps/AwaitTabStep.js +7 -6
  93. package/mablscript/steps/ClickAndHoldStep.js +6 -6
  94. package/mablscript/steps/ClickStep.js +6 -6
  95. package/mablscript/steps/CreateVariableStep.js +8 -8
  96. package/mablscript/steps/DoubleClickStep.js +7 -7
  97. package/mablscript/steps/DownloadStep.js +3 -2
  98. package/mablscript/steps/EchoStep.js +5 -3
  99. package/mablscript/steps/ElseIfConditionStep.js +5 -2
  100. package/mablscript/steps/EnterTextStep.js +13 -10
  101. package/mablscript/steps/EvaluateFlowStep.js +40 -0
  102. package/mablscript/steps/HoverStep.js +6 -6
  103. package/mablscript/steps/IfConditionStep.js +8 -7
  104. package/mablscript/steps/NavigateStep.js +1 -1
  105. package/mablscript/steps/ReleaseStep.js +7 -6
  106. package/mablscript/steps/RemoveCookieStep.js +2 -3
  107. package/mablscript/steps/SelectStep.js +5 -5
  108. package/mablscript/steps/SendHttpRequestStep.js +3 -3
  109. package/mablscript/steps/SendKeyStep.js +9 -9
  110. package/mablscript/steps/SetCookieStep.js +2 -4
  111. package/mablscript/steps/SetFilesStep.js +5 -5
  112. package/mablscript/steps/SetViewportStep.js +2 -2
  113. package/mablscript/steps/SwitchContextStep.js +12 -12
  114. package/mablscript/steps/VisitUrlStep.js +3 -2
  115. package/mablscript/steps/WaitStep.js +2 -5
  116. package/mablscript/steps/WaitUntilStep.js +3 -3
  117. package/{browserLauncher/puppeteerBrowserLauncher/internals.js → mablscript/types/EvaluateFlowStepDescriptor.js} +0 -0
  118. package/mablscript/types/GetCurrentLocationDescriptor.js +4 -3
  119. package/mablscript/types/OperatingSystemDescriptor.js +5 -1
  120. package/mablscript/types/VariableNamespace.js +1 -1
  121. package/mablscriptFind/index.js +1 -1
  122. package/mablscriptFind/index.js.LICENSE.txt +5 -5
  123. package/observers/mockObserver.js +4 -2
  124. package/package.json +55 -56
  125. package/popupDismissal/index.js +3 -3
  126. package/providers/authenticationProvider.js +3 -3
  127. package/providers/logging/loggingProvider.js +5 -1
  128. package/proxy/index.js +2 -1
  129. package/proxy/index.js.LICENSE.txt +5 -0
  130. package/reporters/mochAwesome/mochAwesomeReporter.js +11 -7
  131. package/reporters/reporter.js +1 -1
  132. package/resources/mablFind.js +1 -1
  133. package/resources/pdf-viewer/index.js +1 -1
  134. package/resources/pdf-viewer/libEmbeddedPdfHandler.js +11 -2
  135. package/resources/popupDismissal.js +1 -1
  136. package/util/RichPromise.js +1 -0
  137. package/util/actionabilityUtil.js +16 -35
  138. package/util/analytics.js +7 -3
  139. package/util/downloadUtil.js +6 -2
  140. package/util/httpUtil.js +6 -2
  141. package/util/markdownUtil.js +1 -1
  142. package/util/pureUtil.js +5 -1
  143. package/util/resourceUtil.js +5 -1
  144. package/browserLauncher/puppeteerBrowserLauncher/puppeteerBrowser.js +0 -134
  145. package/browserLauncher/puppeteerBrowserLauncher/puppeteerBrowserLauncher.js +0 -45
  146. package/browserLauncher/puppeteerBrowserLauncher/puppeteerElementHandle.js +0 -139
  147. package/browserLauncher/puppeteerBrowserLauncher/puppeteerFrame.js +0 -115
  148. package/browserLauncher/puppeteerBrowserLauncher/puppeteerHttpRequest.js +0 -38
  149. package/browserLauncher/puppeteerBrowserLauncher/puppeteerHttpResponse.js +0 -27
  150. package/browserLauncher/puppeteerBrowserLauncher/puppeteerJsHandle.js +0 -36
  151. package/browserLauncher/puppeteerBrowserLauncher/puppeteerPage.js +0 -331
  152. package/browserLauncher/puppeteerBrowserLauncher/wrappers.js +0 -25
@@ -75,7 +75,7 @@ class JavaScriptAction extends MablAction_1.MablAction {
75
75
  }
76
76
  static fromDescriptor(descriptor) {
77
77
  const { javaScript } = descriptor;
78
- if (JavaScriptDescriptor_1.isReusableSnippetDescriptor(javaScript)) {
78
+ if ((0, JavaScriptDescriptor_1.isReusableSnippetDescriptor)(javaScript)) {
79
79
  return new JavaScriptAction(JavaScriptAction.mablscriptName, [
80
80
  {
81
81
  id: javaScript.snippetId,
@@ -84,20 +84,20 @@ class JavaScriptAction extends MablAction_1.MablAction {
84
84
  { parameter_overrides: javaScript.parameterOverrides },
85
85
  ]);
86
86
  }
87
- else if (JavaScriptDescriptor_1.isInlineSnippetDescriptor(javaScript)) {
87
+ else if ((0, JavaScriptDescriptor_1.isInlineSnippetDescriptor)(javaScript)) {
88
88
  return new JavaScriptAction(JavaScriptAction.mablscriptName, [
89
89
  javaScript.inlineSnippet,
90
90
  { parameter_overrides: javaScript.parameterOverrides },
91
91
  ]);
92
92
  }
93
- else if (JavaScriptDescriptor_1.isLegacyReusableSnippetDescriptor(javaScript)) {
93
+ else if ((0, JavaScriptDescriptor_1.isLegacyReusableSnippetDescriptor)(javaScript)) {
94
94
  return new JavaScriptAction(JavaScriptAction.mablscriptName, [
95
95
  {
96
96
  id: javaScript.snippetInvariantId,
97
97
  },
98
98
  ]);
99
99
  }
100
- else if (JavaScriptDescriptor_1.isLegacyInlineJavaScriptDescriptor(javaScript)) {
100
+ else if ((0, JavaScriptDescriptor_1.isLegacyInlineJavaScriptDescriptor)(javaScript)) {
101
101
  return new JavaScriptAction(JavaScriptAction.mablscriptName, [
102
102
  javaScript.encodedJS,
103
103
  ]);
@@ -106,19 +106,19 @@ class JavaScriptAction extends MablAction_1.MablAction {
106
106
  }
107
107
  toYaml() {
108
108
  const actionYaml = {};
109
- if (JavaScriptDescriptor_1.isReusableSnippetDescriptor(this.javaScript)) {
109
+ if ((0, JavaScriptDescriptor_1.isReusableSnippetDescriptor)(this.javaScript)) {
110
110
  actionYaml.snippetId = this.javaScript.snippetId;
111
111
  actionYaml.snippetInvariantId = this.javaScript.snippetInvariantId;
112
112
  actionYaml.parameterOverrides = this.javaScript.parameterOverrides;
113
113
  }
114
- else if (JavaScriptDescriptor_1.isInlineSnippetDescriptor(this.javaScript)) {
114
+ else if ((0, JavaScriptDescriptor_1.isInlineSnippetDescriptor)(this.javaScript)) {
115
115
  actionYaml.snippet = this.javaScript.inlineSnippet;
116
116
  actionYaml.parameterOverrides = this.javaScript.parameterOverrides;
117
117
  }
118
- else if (JavaScriptDescriptor_1.isLegacyReusableSnippetDescriptor(this.javaScript)) {
118
+ else if ((0, JavaScriptDescriptor_1.isLegacyReusableSnippetDescriptor)(this.javaScript)) {
119
119
  actionYaml.snippetId = this.javaScript.snippetInvariantId;
120
120
  }
121
- else if (JavaScriptDescriptor_1.isLegacyInlineJavaScriptDescriptor(this.javaScript)) {
121
+ else if ((0, JavaScriptDescriptor_1.isLegacyInlineJavaScriptDescriptor)(this.javaScript)) {
122
122
  actionYaml.code = this.javaScript.encodedJS;
123
123
  }
124
124
  else {
@@ -160,27 +160,27 @@ class JavaScriptAction extends MablAction_1.MablAction {
160
160
  return new JavaScriptAction(MABLSCRIPT_NAME, args);
161
161
  }
162
162
  toMablscript() {
163
- if (JavaScriptDescriptor_1.isReusableSnippetDescriptor(this.javaScript)) {
164
- const snippetReference = domUtil_1.buildStepArgumentString({
163
+ if ((0, JavaScriptDescriptor_1.isReusableSnippetDescriptor)(this.javaScript)) {
164
+ const snippetReference = (0, domUtil_1.buildStepArgumentString)({
165
165
  id: this.javaScript.snippetId,
166
166
  invariant_id: this.javaScript.snippetInvariantId,
167
167
  snippet_type: 'javascript',
168
168
  });
169
- const snippetOptions = `, {parameter_overrides: ${domUtil_1.buildStepArgumentString(this.javaScript.parameterOverrides)}}`;
169
+ const snippetOptions = `, {parameter_overrides: ${(0, domUtil_1.buildStepArgumentString)(this.javaScript.parameterOverrides)}}`;
170
170
  return `evaluate_js(${snippetReference}${snippetOptions})`;
171
171
  }
172
- if (JavaScriptDescriptor_1.isInlineSnippetDescriptor(this.javaScript)) {
173
- const snippetReference = domUtil_1.buildStepArgumentString({
172
+ if ((0, JavaScriptDescriptor_1.isInlineSnippetDescriptor)(this.javaScript)) {
173
+ const snippetReference = (0, domUtil_1.buildStepArgumentString)({
174
174
  ...this.javaScript.inlineSnippet,
175
175
  snippet_type: 'javascript',
176
176
  });
177
- const snippetOptions = `, {parameter_overrides: ${domUtil_1.buildStepArgumentString(this.javaScript.parameterOverrides)}}`;
177
+ const snippetOptions = `, {parameter_overrides: ${(0, domUtil_1.buildStepArgumentString)(this.javaScript.parameterOverrides)}}`;
178
178
  return `evaluate_js(${snippetReference}${snippetOptions})`;
179
179
  }
180
- if (JavaScriptDescriptor_1.isLegacyReusableSnippetDescriptor(this.javaScript)) {
180
+ if ((0, JavaScriptDescriptor_1.isLegacyReusableSnippetDescriptor)(this.javaScript)) {
181
181
  return `evaluate_js({id: "${this.javaScript.snippetInvariantId}", snippet_type: "javascript"})`;
182
182
  }
183
- if (JavaScriptDescriptor_1.isLegacyInlineJavaScriptDescriptor(this.javaScript)) {
183
+ if ((0, JavaScriptDescriptor_1.isLegacyInlineJavaScriptDescriptor)(this.javaScript)) {
184
184
  return `evaluate_js("${this.javaScript.encodedJS}")`;
185
185
  }
186
186
  throw new Error(`Cannot export action to mablscript: ${JSON.stringify(this.javaScript)}`);
@@ -0,0 +1,146 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.diffFlows = exports.diffTests = exports.convertDiffingFormatIntoDiffingSteps = exports.flattenTestFlowsIntoLineDiffingFormat = exports.convertFlowToStepList = exports.lineModeDiff = exports.DiffOperation = void 0;
7
+ const mablApi_1 = require("../../mablApi");
8
+ const importer_1 = require("../importer");
9
+ const EvaluateFlowStep_1 = require("../steps/EvaluateFlowStep");
10
+ const diffPatchMatch_1 = __importDefault(require("./diffPatchMatch"));
11
+ const fast_json_stable_stringify_1 = __importDefault(require("fast-json-stable-stringify"));
12
+ var DiffOperation;
13
+ (function (DiffOperation) {
14
+ DiffOperation["DELETE"] = "DELETE";
15
+ DiffOperation["EQUAL"] = "EQUAL";
16
+ DiffOperation["INSERT"] = "INSERT";
17
+ })(DiffOperation = exports.DiffOperation || (exports.DiffOperation = {}));
18
+ function lineModeDiff(text1, text2) {
19
+ const dmp = new diffPatchMatch_1.default();
20
+ const lineToCharDiff = dmp.diff_linesToChars(text1, text2);
21
+ const lineText1 = lineToCharDiff.chars1;
22
+ const lineText2 = lineToCharDiff.chars2;
23
+ const lineArray = lineToCharDiff.lineArray;
24
+ const diffs = dmp.diff_main(lineText1, lineText2, false);
25
+ dmp.diff_charsToLines(diffs, lineArray);
26
+ const typedDiff = diffs.map((diff) => ({
27
+ operation: convertOperationValue(diff[0]),
28
+ text: diff[1],
29
+ }));
30
+ return typedDiff;
31
+ }
32
+ exports.lineModeDiff = lineModeDiff;
33
+ function convertOperationValue(op) {
34
+ switch (op) {
35
+ case -1:
36
+ return DiffOperation.DELETE;
37
+ case 0:
38
+ return DiffOperation.EQUAL;
39
+ case 1:
40
+ return DiffOperation.INSERT;
41
+ default:
42
+ return DiffOperation.EQUAL;
43
+ }
44
+ }
45
+ function convertFlowToStepList(flow, flowConfig) {
46
+ if (!flow.reusable && flow.flow_type === mablApi_1.Flow.FlowTypeEnum.Mablscript) {
47
+ return (0, importer_1.parseMablScriptIntoSteps)(flow);
48
+ }
49
+ const evaluateFlowStep = new EvaluateFlowStep_1.EvaluateFlowStep(EvaluateFlowStep_1.EvaluateFlowStep.mablScriptStepNames[0], [
50
+ {
51
+ invariant_id: flow === null || flow === void 0 ? void 0 : flow.invariant_id,
52
+ },
53
+ flowConfig,
54
+ ], []);
55
+ if (flow.description) {
56
+ evaluateFlowStep.setDescription(flow.description);
57
+ }
58
+ return [evaluateFlowStep];
59
+ }
60
+ exports.convertFlowToStepList = convertFlowToStepList;
61
+ function flattenTestFlowsIntoSteps(flows, flowConfig) {
62
+ return flows.flatMap((flow, index) => convertFlowToStepList(flow, flowConfig === null || flowConfig === void 0 ? void 0 : flowConfig[index]));
63
+ }
64
+ function flattenTestFlowsIntoLineDiffingFormat(flows, flowConfig) {
65
+ const flattenedSteps = flattenTestFlowsIntoSteps(flows, flowConfig);
66
+ const diffingFormat = flattenedSteps
67
+ .map((step) => step.toLineDiffFormat())
68
+ .join('\n');
69
+ return { flattenedSteps, diffingFormat };
70
+ }
71
+ exports.flattenTestFlowsIntoLineDiffingFormat = flattenTestFlowsIntoLineDiffingFormat;
72
+ function convertDiffingFormatIntoDiffingSteps(diffs, sourceSteps, targetSteps) {
73
+ const leftSteps = [...sourceSteps];
74
+ const rightSteps = [...targetSteps];
75
+ leftSteps.forEach((step) => {
76
+ step.setStepSourceIndexInFlow(0);
77
+ });
78
+ rightSteps.forEach((step) => {
79
+ step.setStepSourceIndexInFlow(0);
80
+ });
81
+ const stepDiffs = diffs.map((diff) => {
82
+ const lineDiffs = diff.text.trim().split('\n');
83
+ const stepDiffCount = lineDiffs.length;
84
+ let steps = [];
85
+ switch (diff.operation) {
86
+ case DiffOperation.EQUAL:
87
+ steps = leftSteps.splice(0, stepDiffCount);
88
+ rightSteps.splice(0, stepDiffCount);
89
+ break;
90
+ case DiffOperation.INSERT:
91
+ steps = rightSteps.splice(0, stepDiffCount);
92
+ break;
93
+ case DiffOperation.DELETE:
94
+ steps = leftSteps.splice(0, stepDiffCount);
95
+ break;
96
+ }
97
+ return {
98
+ operation: diff.operation,
99
+ steps,
100
+ };
101
+ });
102
+ return stepDiffs;
103
+ }
104
+ exports.convertDiffingFormatIntoDiffingSteps = convertDiffingFormatIntoDiffingSteps;
105
+ function diffTests(test1Flows, test1FlowConfig, test2Flows, test2FlowConfig) {
106
+ const { flattenedSteps: flattenedTest1Steps, diffingFormat: test1DiffingFormat, } = flattenTestFlowsIntoLineDiffingFormat(test1Flows, test1FlowConfig);
107
+ const { flattenedSteps: flattenedTest2Steps, diffingFormat: test2DiffingFormat, } = flattenTestFlowsIntoLineDiffingFormat(test2Flows, test2FlowConfig);
108
+ const diffs = lineModeDiff(test1DiffingFormat, test2DiffingFormat);
109
+ return convertDiffingFormatIntoDiffingSteps(diffs, flattenedTest1Steps, flattenedTest2Steps);
110
+ }
111
+ exports.diffTests = diffTests;
112
+ function diffFlows(flow1, flow2) {
113
+ var _a, _b;
114
+ const flow1Steps = (0, importer_1.parseMablScriptIntoSteps)(flow1);
115
+ const formattedFlow1Steps = flow1Steps
116
+ .map((step) => step.toLineDiffFormat())
117
+ .join('\n');
118
+ const flow2Steps = (0, importer_1.parseMablScriptIntoSteps)(flow2);
119
+ const formattedFlow2Steps = flow2Steps
120
+ .map((step) => step.toLineDiffFormat())
121
+ .join('\n');
122
+ const flattenedDiffs = lineModeDiff(formattedFlow1Steps, formattedFlow2Steps);
123
+ const stepDiffs = convertDiffingFormatIntoDiffingSteps(flattenedDiffs, flow1Steps, flow2Steps);
124
+ const parametersDiff = diffFlowVariables(flow1.parameters, flow2.parameters);
125
+ const inputVariablesDiff = diffFlowVariables((_a = flow1.variables) === null || _a === void 0 ? void 0 : _a.inputs, (_b = flow2.variables) === null || _b === void 0 ? void 0 : _b.inputs);
126
+ return { stepDiff: stepDiffs, parametersDiff, inputVariablesDiff };
127
+ }
128
+ exports.diffFlows = diffFlows;
129
+ function diffFlowVariables(flow1Variables, flow2Variables) {
130
+ const flow1VariablesFlattened = flattenFlowVariables(flow1Variables);
131
+ const flow2VariablesFlattened = flattenFlowVariables(flow2Variables);
132
+ const diffs = lineModeDiff(flow1VariablesFlattened, flow2VariablesFlattened);
133
+ const flowVariablesDiff = diffs.map((diff) => {
134
+ const variablesStringified = diff.text.trim().split('\n');
135
+ const reassembledVariables = variablesStringified.map((variablesText) => JSON.parse(variablesText));
136
+ return {
137
+ operation: diff.operation,
138
+ variables: reassembledVariables,
139
+ };
140
+ });
141
+ return flowVariablesDiff;
142
+ }
143
+ function flattenFlowVariables(flowVariables) {
144
+ var _a;
145
+ return ((_a = flowVariables === null || flowVariables === void 0 ? void 0 : flowVariables.sort((a, b) => a.name.localeCompare(b.name)).map((parameter) => (0, fast_json_stable_stringify_1.default)(parameter)).join('\n')) !== null && _a !== void 0 ? _a : '');
146
+ }
@@ -51,6 +51,7 @@ const ReleaseStep_1 = require("./steps/ReleaseStep");
51
51
  const CountAction_1 = require("./actions/CountAction");
52
52
  const loggingProvider_1 = require("../providers/logging/loggingProvider");
53
53
  const AccessibilityCheck_1 = require("./steps/AccessibilityCheck");
54
+ const EvaluateFlowStep_1 = require("./steps/EvaluateFlowStep");
54
55
  const ActionTypes = [
55
56
  AwaitDownloadAction_1.AwaitDownloadAction,
56
57
  AwaitPDFDownloadAction_1.AwaitPDFDownloadAction,
@@ -81,6 +82,7 @@ const StepTypes = [
81
82
  ElseIfConditionStep_1.ElseIfConditionStep,
82
83
  EndStep_1.EndStep,
83
84
  EnterTextStep_1.EnterTextStep,
85
+ EvaluateFlowStep_1.EvaluateFlowStep,
84
86
  HoverStep_1.HoverStep,
85
87
  IfConditionStep_1.IfConditionStep,
86
88
  EvaluateJavaScriptStep_1.EvaluateJavaScriptStep,
@@ -99,10 +101,10 @@ const StepTypes = [
99
101
  WaitStep_1.WaitStep,
100
102
  ];
101
103
  function parseMablScript(mablscript) {
102
- const ast = esprima_1.parseScript(mablscript, { loc: true });
104
+ const ast = (0, esprima_1.parseScript)(mablscript, { loc: true });
103
105
  const stepStack = {};
104
106
  let stepLine = 0;
105
- estraverse_1.traverse(ast, {
107
+ (0, estraverse_1.traverse)(ast, {
106
108
  enter(node) {
107
109
  switch (node.type) {
108
110
  case 'ExpressionStatement':
@@ -150,9 +152,12 @@ function loadMablScriptIntoSteps(parsedMablscript) {
150
152
  action.setActionSourceIndexInStep(actionIndex);
151
153
  return action;
152
154
  });
153
- const step = stepType
155
+ let step = stepType
154
156
  ? new stepType(lastAction.name, lastAction.arguments, actions)
155
157
  : new MablStep_1.MablStep(lastAction.name, lastAction.arguments, actions);
158
+ if (step instanceof AssertStepOld_1.AssertStepOld) {
159
+ step = step.getNewAssertionStep();
160
+ }
156
161
  step.setActionSourceIndexInStep(actions.length);
157
162
  step.setStepSourceIndexInFlow(parseInt(stepIndexString));
158
163
  return step;
@@ -161,7 +166,7 @@ function loadMablScriptIntoSteps(parsedMablscript) {
161
166
  exports.loadMablScriptIntoSteps = loadMablScriptIntoSteps;
162
167
  function yamlifyTheLoadedSteps(translatedSteps, fullLocatorsOn = true) {
163
168
  const steps = translatedSteps.map((step) => step.getFormattedStep(fullLocatorsOn));
164
- return js_yaml_1.dump(steps);
169
+ return (0, js_yaml_1.dump)(steps);
165
170
  }
166
171
  exports.yamlifyTheLoadedSteps = yamlifyTheLoadedSteps;
167
172
  const yamlMablscriptToObjectsStepMap = {};
@@ -169,7 +174,7 @@ StepTypes.forEach((step) => {
169
174
  step.yamlMablScriptNames.forEach((name) => (yamlMablscriptToObjectsStepMap[name] = step.fromYaml));
170
175
  });
171
176
  function loadYamlSteps(yamlSteps) {
172
- const loadedStepData = js_yaml_1.safeLoad(yamlSteps);
177
+ const loadedStepData = (0, js_yaml_1.load)(yamlSteps);
173
178
  return loadedStepData.map((stepObject) => {
174
179
  const stepName = Object.keys(stepObject)[0];
175
180
  const stepArgs = stepObject[stepName];
@@ -239,19 +244,19 @@ function getArgumentsFromCallExpressionArgs(expressionArguments) {
239
244
  break;
240
245
  case 'Identifier':
241
246
  const singleIdentifier = expressionArg;
242
- expressionArgs.push(MablSymbol_1.formatSymbol(singleIdentifier.name));
247
+ expressionArgs.push((0, MablSymbol_1.formatSymbol)(singleIdentifier.name));
243
248
  break;
244
249
  case 'MemberExpression':
245
250
  const memberExpression = expressionArg;
246
251
  if (expressionArg.object.type === 'MemberExpression') {
247
252
  const chainedVariableExpression = memberExpressionChainBuilder(memberExpression);
248
253
  const property = memberExpression.property;
249
- expressionArgs.push(MablSymbol_1.formatSymbol(`${chainedVariableExpression}.${property.name}`));
254
+ expressionArgs.push((0, MablSymbol_1.formatSymbol)(`${chainedVariableExpression}.${property.name}`));
250
255
  }
251
256
  else {
252
257
  const identifier = memberExpression.object;
253
258
  const property = memberExpression.property;
254
- expressionArgs.push(MablSymbol_1.formatSymbol(`${identifier.name}.${property.name}`));
259
+ expressionArgs.push((0, MablSymbol_1.formatSymbol)(`${identifier.name}.${property.name}`));
255
260
  }
256
261
  break;
257
262
  case 'ObjectExpression':
@@ -280,6 +285,19 @@ function parseObjectExpression(expression) {
280
285
  let key;
281
286
  let value;
282
287
  switch (property.value.type) {
288
+ case 'UnaryExpression':
289
+ key = property.key;
290
+ value = property.value;
291
+ const operator = value.operator;
292
+ const rawValue = Number(value.argument.raw);
293
+ if (operator === '-') {
294
+ value = -Math.abs(rawValue);
295
+ }
296
+ else {
297
+ throw Error(`Cannot parse UnaryExpression ${property}`);
298
+ }
299
+ finalObj[key.name] = value;
300
+ break;
283
301
  case 'Literal':
284
302
  key =
285
303
  property.key.type === 'Identifier'
@@ -4,7 +4,7 @@ exports.AccessibilityCheckStep = exports.AccessibilityCheckSeverity = void 0;
4
4
  const MablStep_1 = require("../MablStep");
5
5
  const FindAction_1 = require("../actions/FindAction");
6
6
  const ActionsUtils_1 = require("./ActionsUtils");
7
- const mablscriptFind_1 = require("../../mablscriptFind");
7
+ const domUtil_1 = require("../../domUtil");
8
8
  var AccessibilityCheckSeverity;
9
9
  (function (AccessibilityCheckSeverity) {
10
10
  AccessibilityCheckSeverity["Critical"] = "critical";
@@ -32,10 +32,10 @@ class AccessibilityCheckStep extends MablStep_1.MablStep {
32
32
  if (this.findAction) {
33
33
  const find = this.findAction.toDescriptor();
34
34
  switch (find.findType) {
35
- case mablscriptFind_1.FindType.FIND_FIRST:
36
- case mablscriptFind_1.FindType.FIND_LAST:
37
- case mablscriptFind_1.FindType.FIND_ANY:
38
- case mablscriptFind_1.FindType.FIND_ONE:
35
+ case domUtil_1.FindType.FIND_FIRST:
36
+ case domUtil_1.FindType.FIND_LAST:
37
+ case domUtil_1.FindType.FIND_ANY:
38
+ case domUtil_1.FindType.FIND_ONE:
39
39
  return {
40
40
  ...this.checkConfig,
41
41
  find,
@@ -85,8 +85,10 @@ class AccessibilityCheckStep extends MablStep_1.MablStep {
85
85
  toMablscript() {
86
86
  var _a, _b, _c;
87
87
  let argString = '';
88
- if (((_a = this.checkConfig) === null || _a === void 0 ? void 0 : _a.tags) || ((_b = this.checkConfig) === null || _b === void 0 ? void 0 : _b.disabledRules) || ((_c = this.checkConfig) === null || _c === void 0 ? void 0 : _c.rules)) {
89
- argString = `{${MablStep_1.buildObjectString(this.checkConfig)}}`;
88
+ if (((_a = this.checkConfig) === null || _a === void 0 ? void 0 : _a.tags) ||
89
+ ((_b = this.checkConfig) === null || _b === void 0 ? void 0 : _b.disabledRules) ||
90
+ ((_c = this.checkConfig) === null || _c === void 0 ? void 0 : _c.rules)) {
91
+ argString = `{${(0, MablStep_1.buildObjectString)(this.checkConfig)}}`;
90
92
  }
91
93
  let findAction = '';
92
94
  if (this.findAction) {
@@ -6,7 +6,7 @@ const SeleniumIdeStep_1 = require("./SeleniumIdeStep");
6
6
  const FindAction_1 = require("../actions/FindAction");
7
7
  const MablStep_1 = require("../MablStep");
8
8
  const ExtractAction_1 = require("../actions/ExtractAction");
9
- const mablscriptFind_1 = require("../../mablscriptFind");
9
+ const domUtil_1 = require("../../domUtil");
10
10
  const GetUrlAction_1 = require("../actions/GetUrlAction");
11
11
  const GetCurrentLocationDescriptor_1 = require("../types/GetCurrentLocationDescriptor");
12
12
  const GetVariableValue_1 = require("../actions/GetVariableValue");
@@ -37,6 +37,7 @@ exports.fieldToAssertionStep = {};
37
37
  Object.entries(exports.assertionStepToField).forEach(([stepType, field]) => (exports.fieldToAssertionStep[field] = stepType));
38
38
  class AssertStep extends MablStep_1.MablStep {
39
39
  constructor(name, args, actions) {
40
+ var _a, _b;
40
41
  super(name, args, actions);
41
42
  const firstAction = actions[0];
42
43
  if (firstAction instanceof FindAction_1.FindAction ||
@@ -62,11 +63,12 @@ class AssertStep extends MablStep_1.MablStep {
62
63
  this.assertionType = this.conditionAction.conditionAttribute;
63
64
  this.assertionValue = this.conditionAction.conditionValueAttribute;
64
65
  this.isWaitUntilStep = this.determineIfWaitUntilStep();
65
- const assertArguments = args[0] && typeof args[0] === 'object'
66
- ? args[0]
67
- : undefined;
68
- this.continueOnFailure = (assertArguments === null || assertArguments === void 0 ? void 0 : assertArguments.onFailure) === 'continue';
69
- this.observationScope = assertArguments === null || assertArguments === void 0 ? void 0 : assertArguments.observationScope;
66
+ this.assertArguments =
67
+ args[0] && typeof args[0] === 'object'
68
+ ? args[0]
69
+ : undefined;
70
+ this.continueOnFailure = ((_a = this.assertArguments) === null || _a === void 0 ? void 0 : _a.onFailure) === 'continue';
71
+ this.observationScope = (_b = this.assertArguments) === null || _b === void 0 ? void 0 : _b.observationScope;
70
72
  }
71
73
  validate() {
72
74
  if (!(this.actions.length === 2 || this.actions.length === 3) &&
@@ -78,7 +80,7 @@ class AssertStep extends MablStep_1.MablStep {
78
80
  determineIfWaitUntilStep() {
79
81
  var _a, _b;
80
82
  const find = this.primaryAction.toDescriptor();
81
- if (mablscriptFind_1.isFindElementDescriptor(find)) {
83
+ if ((0, domUtil_1.isFindElementDescriptor)(find)) {
82
84
  if ((_b = (_a = find.findOptions) === null || _a === void 0 ? void 0 : _a.waitUntil) === null || _b === void 0 ? void 0 : _b.timeoutSeconds) {
83
85
  return true;
84
86
  }
@@ -129,23 +131,23 @@ class AssertStep extends MablStep_1.MablStep {
129
131
  formatted.assertionValue = this.assertionValue;
130
132
  }
131
133
  const find = this.primaryAction.toDescriptor();
132
- if (GetCurrentLocationDescriptor_1.isGetCurrentLocationDescriptor(find) || GetVariableDescriptor_1.isGetVariableDescriptor(find)) {
134
+ if ((0, GetCurrentLocationDescriptor_1.isGetCurrentLocationDescriptor)(find) || (0, GetVariableDescriptor_1.isGetVariableDescriptor)(find)) {
133
135
  }
134
136
  else {
135
137
  switch (find.findType) {
136
- case mablscriptFind_1.FindType.FIND_COOKIE:
137
- case mablscriptFind_1.FindType.FIND_EMAIL:
138
+ case domUtil_1.FindType.FIND_COOKIE:
139
+ case domUtil_1.FindType.FIND_EMAIL:
138
140
  formatted.findType = FindAction_1.findTypesToFormattedType[find.findType];
139
141
  formatted.selector = find.findTarget;
140
142
  break;
141
- case mablscriptFind_1.FindType.FIND_FIRST:
142
- case mablscriptFind_1.FindType.FIND_LAST:
143
- case mablscriptFind_1.FindType.FIND_ANY:
144
- case mablscriptFind_1.FindType.FIND_ALL:
143
+ case domUtil_1.FindType.FIND_FIRST:
144
+ case domUtil_1.FindType.FIND_LAST:
145
+ case domUtil_1.FindType.FIND_ANY:
146
+ case domUtil_1.FindType.FIND_ALL:
145
147
  formatted.findType = FindAction_1.findTypesToFormattedType[find.findType];
146
148
  formatted.selector = find.findTarget;
147
149
  break;
148
- case mablscriptFind_1.FindType.FIND_ONE:
150
+ case domUtil_1.FindType.FIND_ONE:
149
151
  formatted.selector = find.findTarget.selector;
150
152
  if (find.findOptions) {
151
153
  formatted.findOptions = find.findOptions;
@@ -161,8 +163,14 @@ class AssertStep extends MablStep_1.MablStep {
161
163
  const actions = [];
162
164
  const assertionType = exports.assertionStepToField[stepName];
163
165
  const assertionValue = stepArgs.assertionValue;
164
- const findAction = FindAction_1.FindAction.findActionFromStepArgs(stepArgs);
165
- actions.push(findAction);
166
+ let primaryAction;
167
+ if (stepArgs.kind === GetCurrentLocationDescriptor_1.GET_CURRENT_LOCATION_KIND) {
168
+ primaryAction = new GetUrlAction_1.GetUrlAction(GetUrlAction_1.GetUrlAction.mablScriptStepNames[0], []);
169
+ }
170
+ else {
171
+ primaryAction = FindAction_1.FindAction.findActionFromStepArgs(stepArgs);
172
+ }
173
+ actions.push(primaryAction);
166
174
  if (assertionType === 'present' || assertionType === 'not_present') {
167
175
  actions.push(new ConditionAction_1.ConditionAction('evaluate_presence', [assertionType]));
168
176
  }
@@ -181,14 +189,19 @@ class AssertStep extends MablStep_1.MablStep {
181
189
  assertionValue,
182
190
  ]));
183
191
  }
184
- return new AssertStep('assert', [], actions);
192
+ return new AssertStep('assert', [
193
+ {
194
+ onFailure: stepArgs.continueOnFailure ? 'continue' : undefined,
195
+ observationScope: stepArgs.observationScope,
196
+ },
197
+ ], actions);
185
198
  }
186
199
  produceSelIdeFormattedSteps(stepIndex) {
187
200
  const find = this.primaryAction.toDescriptor();
188
- if (!GetCurrentLocationDescriptor_1.isGetCurrentLocationDescriptor(find) &&
189
- !GetVariableDescriptor_1.isGetVariableDescriptor(find) &&
190
- (find.findType === mablscriptFind_1.FindType.FIND_EMAIL ||
191
- find.findType === mablscriptFind_1.FindType.FIND_COOKIE)) {
201
+ if (!(0, GetCurrentLocationDescriptor_1.isGetCurrentLocationDescriptor)(find) &&
202
+ !(0, GetVariableDescriptor_1.isGetVariableDescriptor)(find) &&
203
+ (find.findType === domUtil_1.FindType.FIND_EMAIL ||
204
+ find.findType === domUtil_1.FindType.FIND_COOKIE)) {
192
205
  return [this.unsupportedSelIdeExportStep()];
193
206
  }
194
207
  if (this.assertionType === 'present') {
@@ -198,7 +211,7 @@ class AssertStep extends MablStep_1.MablStep {
198
211
  if (this.primaryAction instanceof GetVariableValue_1.GetVariableValue) {
199
212
  throw new Error('Invalid state. You cannot assert presence against variable properties.');
200
213
  }
201
- const assertPresentStep = SeleniumIdeStep_1.buildSeleniumIdeStep('assertElementPresent', this);
214
+ const assertPresentStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('assertElementPresent', this);
202
215
  assertPresentStep.target = this.primaryAction.getSelIdeTarget();
203
216
  return [assertPresentStep];
204
217
  }
@@ -209,41 +222,42 @@ class AssertStep extends MablStep_1.MablStep {
209
222
  if (this.primaryAction instanceof GetVariableValue_1.GetVariableValue) {
210
223
  throw new Error('Invalid state. You cannot assert presence against variable properties.');
211
224
  }
212
- const assertNotPresentStep = SeleniumIdeStep_1.buildSeleniumIdeStep('assertElementNotPresent', this);
225
+ const assertNotPresentStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('assertElementNotPresent', this);
213
226
  assertNotPresentStep.target = this.primaryAction.getSelIdeTarget();
214
227
  return [assertNotPresentStep];
215
228
  }
216
- return buildSeleniumIdeJsAssertion(stepIndex, (!GetCurrentLocationDescriptor_1.isGetCurrentLocationDescriptor(find) &&
217
- !GetVariableDescriptor_1.isGetVariableDescriptor(find) &&
218
- find.findType === mablscriptFind_1.FindType.FIND_ONE &&
229
+ return buildSeleniumIdeJsAssertion(stepIndex, (!(0, GetCurrentLocationDescriptor_1.isGetCurrentLocationDescriptor)(find) &&
230
+ !(0, GetVariableDescriptor_1.isGetVariableDescriptor)(find) &&
231
+ find.findType === domUtil_1.FindType.FIND_ONE &&
219
232
  find.findTarget.selector.xpath) ||
220
233
  '', this.extractAction ? this.extractAction.extractionAttribute : '', this.substituteSeleniumVariable(this.conditionAction.conditionValueAttribute || ''), this.assertionType, this);
221
234
  }
222
235
  unsupportedSelIdeExportStep() {
223
- const seleniumStep = SeleniumIdeStep_1.buildSeleniumIdeStep('echo', this);
236
+ const seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('echo', this);
224
237
  const findDescriptor = this.primaryAction.toDescriptor();
225
- seleniumStep.value = `[${this.getStepName()}] step with find type [${FindAction_1.findTypesToFormattedType[(!GetCurrentLocationDescriptor_1.isGetCurrentLocationDescriptor(findDescriptor) &&
226
- !GetVariableDescriptor_1.isGetVariableDescriptor(findDescriptor) &&
238
+ seleniumStep.value = `[${this.getStepName()}] step with find type [${FindAction_1.findTypesToFormattedType[(!(0, GetCurrentLocationDescriptor_1.isGetCurrentLocationDescriptor)(findDescriptor) &&
239
+ !(0, GetVariableDescriptor_1.isGetVariableDescriptor)(findDescriptor) &&
227
240
  findDescriptor.findType) ||
228
241
  'unknown']} is not supported for Selenium IDE export`;
229
242
  return seleniumStep;
230
243
  }
231
244
  toMablscript() {
232
- if (this.assertionType === 'present' ||
233
- this.assertionType === 'not_present' ||
234
- this.isWaitUntilStep) {
235
- const finalAssertionType = this.isWaitUntilStep
236
- ? 'present'
237
- : this.assertionType;
238
- return `${this.primaryAction.generateMablscriptFindOne()}.evaluate_presence("${finalAssertionType}").assert()`;
239
- }
245
+ var _a, _b;
246
+ const assertAction = `.assert(${!!(((_a = this.assertArguments) === null || _a === void 0 ? void 0 : _a.onFailure) ||
247
+ ((_b = this.assertArguments) === null || _b === void 0 ? void 0 : _b.observationScope))
248
+ ? this.convertObjectToMablscriptArgs(this.assertArguments)
249
+ : ''})`;
240
250
  if (this.countAction) {
241
- return `${this.primaryAction.toMablscript()}.${this.countAction.toMablscript()}.${this.conditionAction.toMablscript()}.assert()`;
251
+ return `${this.primaryAction.toMablscript()}.${this.countAction.toMablscript()}.${this.conditionAction.toMablscript()}${assertAction}`;
242
252
  }
243
253
  if (this.extractAction) {
244
- return `${this.primaryAction.toMablscript()}.${this.extractAction.toMablscript()}.${this.conditionAction.toMablscript()}.assert()`;
254
+ return `${this.primaryAction.toMablscript()}.${this.extractAction.toMablscript()}.${this.conditionAction.toMablscript()}${assertAction}`;
255
+ }
256
+ if (this.assertionType === 'present' ||
257
+ this.assertionType === 'not_present') {
258
+ return `${this.primaryAction.generateFindMablscript()}.evaluate_presence("${this.assertionType}")${assertAction}`;
245
259
  }
246
- return `${this.primaryAction.toMablscript()}.${this.conditionAction.toMablscript()}.assert()`;
260
+ return `${this.primaryAction.toMablscript()}.${this.conditionAction.toMablscript()}${assertAction}`;
247
261
  }
248
262
  }
249
263
  exports.AssertStep = AssertStep;
@@ -253,11 +267,11 @@ function buildSeleniumIdeJsAssertion(stepIndex, xpath, assertionAttribute, asser
253
267
  const variableName = `assertVariable-${stepIndex}`;
254
268
  let storeAttribute;
255
269
  if (assertionAttribute !== 'innerText') {
256
- storeAttribute = SeleniumIdeStep_1.buildSeleniumIdeStep('executeScript', step);
270
+ storeAttribute = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('executeScript', step);
257
271
  storeAttribute.target = `return document.evaluate('${xpath}', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue['${assertionAttribute}']`;
258
272
  }
259
273
  else {
260
- storeAttribute = SeleniumIdeStep_1.buildSeleniumIdeStep('storeText', step);
274
+ storeAttribute = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('storeText', step);
261
275
  storeAttribute.target = `xpath=${xpath}`;
262
276
  }
263
277
  storeAttribute.value = variableName;
@@ -300,10 +314,10 @@ function buildSeleniumIdeJsAssertion(stepIndex, xpath, assertionAttribute, asser
300
314
  condition = `!\${${variableName}} <= '${assertAgainst}'`;
301
315
  break;
302
316
  }
303
- const ifStep = SeleniumIdeStep_1.buildSeleniumIdeStep('if', step);
317
+ const ifStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('if', step);
304
318
  ifStep.target = condition;
305
- const throwError = SeleniumIdeStep_1.buildSeleniumIdeStep('executeScript', step);
319
+ const throwError = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('executeScript', step);
306
320
  throwError.target = `throw new Error('${exports.fieldToAssertionStep[assertionType]} step failure')`;
307
- const endStep = SeleniumIdeStep_1.buildSeleniumIdeStep('end', step);
321
+ const endStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('end', step);
308
322
  return [storeAttribute, ifStep, throwError, endStep];
309
323
  }