@mablhq/mabl-cli 1.17.6 → 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 (55) hide show
  1. package/api/featureSet.js +1 -4
  2. package/api/mablApiClient.js +2 -2
  3. package/browserLauncher/browserLauncherFactory.js +2 -3
  4. package/browserLauncher/playwrightBrowserLauncher/playwrightBrowser.js +3 -0
  5. package/browserLauncher/playwrightBrowserLauncher/playwrightDom.js +1 -11
  6. package/browserLauncher/playwrightBrowserLauncher/playwrightFrame.js +18 -0
  7. package/browserLauncher/runnerType.js +0 -1
  8. package/execution/index.js +1 -1
  9. package/execution/index.js.LICENSE.txt +2 -0
  10. package/index.d.ts +0 -1
  11. package/mablscript/MablAction.js +1 -1
  12. package/mablscript/MablStep.js +21 -3
  13. package/mablscript/actions/AwaitPDFDownloadAction.js +2 -1
  14. package/mablscript/actions/ConditionAction.js +11 -3
  15. package/mablscript/actions/ExtractAction.js +16 -7
  16. package/mablscript/actions/FindAction.js +71 -40
  17. package/mablscript/actions/GenerateRandomStringAction.js +2 -1
  18. package/mablscript/actions/GetUrlAction.js +1 -1
  19. package/mablscript/actions/GetVariableValue.js +2 -2
  20. package/mablscript/diffing/diffingUtil.js +146 -0
  21. package/mablscript/importer.js +20 -2
  22. package/mablscript/steps/AssertStep.js +33 -19
  23. package/mablscript/steps/AssertStepOld.js +38 -20
  24. package/mablscript/steps/AwaitTabStep.js +7 -6
  25. package/mablscript/steps/ClickAndHoldStep.js +1 -1
  26. package/mablscript/steps/DownloadStep.js +3 -2
  27. package/mablscript/steps/EchoStep.js +3 -1
  28. package/mablscript/steps/ElseIfConditionStep.js +5 -2
  29. package/mablscript/steps/EnterTextStep.js +4 -1
  30. package/mablscript/steps/EvaluateFlowStep.js +40 -0
  31. package/mablscript/steps/ReleaseStep.js +2 -1
  32. package/mablscript/steps/RemoveCookieStep.js +2 -3
  33. package/mablscript/steps/SendHttpRequestStep.js +3 -3
  34. package/mablscript/steps/SendKeyStep.js +2 -2
  35. package/mablscript/steps/SetCookieStep.js +2 -4
  36. package/mablscript/steps/SetViewportStep.js +1 -1
  37. package/mablscript/steps/VisitUrlStep.js +2 -1
  38. package/mablscript/steps/WaitStep.js +1 -4
  39. package/{browserLauncher/puppeteerBrowserLauncher/internals.js → mablscript/types/EvaluateFlowStepDescriptor.js} +0 -0
  40. package/mablscript/types/GetCurrentLocationDescriptor.js +4 -3
  41. package/mablscriptFind/index.js +1 -1
  42. package/package.json +3 -3
  43. package/resources/mablFind.js +1 -1
  44. package/resources/pdf-viewer/index.js +1 -1
  45. package/resources/pdf-viewer/libEmbeddedPdfHandler.js +11 -2
  46. package/util/actionabilityUtil.js +1 -24
  47. package/browserLauncher/puppeteerBrowserLauncher/puppeteerBrowser.js +0 -135
  48. package/browserLauncher/puppeteerBrowserLauncher/puppeteerBrowserLauncher.js +0 -45
  49. package/browserLauncher/puppeteerBrowserLauncher/puppeteerElementHandle.js +0 -139
  50. package/browserLauncher/puppeteerBrowserLauncher/puppeteerFrame.js +0 -115
  51. package/browserLauncher/puppeteerBrowserLauncher/puppeteerHttpRequest.js +0 -38
  52. package/browserLauncher/puppeteerBrowserLauncher/puppeteerHttpResponse.js +0 -27
  53. package/browserLauncher/puppeteerBrowserLauncher/puppeteerJsHandle.js +0 -36
  54. package/browserLauncher/puppeteerBrowserLauncher/puppeteerPage.js +0 -335
  55. package/browserLauncher/puppeteerBrowserLauncher/wrappers.js +0 -25
@@ -168,6 +168,8 @@ PERFORMANCE OF THIS SOFTWARE.
168
168
  * code.
169
169
  */
170
170
 
171
+ /*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */
172
+
171
173
  /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
172
174
 
173
175
  /**
package/index.d.ts CHANGED
@@ -24,7 +24,6 @@ declare module '@mablhq/mabl-cli' {
24
24
  }
25
25
  export enum RunnerType {
26
26
  Playwright = 'playwright',
27
- Puppeteer = 'puppeteer',
28
27
  }
29
28
  export interface HttpHeadersType {
30
29
  [key: string]: string;
@@ -23,7 +23,7 @@ class MablAction {
23
23
  return matches[1];
24
24
  }
25
25
  }
26
- return `"${argument}"`;
26
+ return `${argument}`;
27
27
  }
28
28
  getActionName() {
29
29
  return this.name;
@@ -1,10 +1,14 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.buildObjectString = exports.buildSourceRepresentationOfObject = exports.MablStep = void 0;
7
+ const domUtil_1 = require("../domUtil");
4
8
  const MablAction_1 = require("./MablAction");
5
- const SeleniumIdeStep_1 = require("./steps/SeleniumIdeStep");
6
9
  const MablSymbol_1 = require("./MablSymbol");
7
- const domUtil_1 = require("../domUtil");
10
+ const SeleniumIdeStep_1 = require("./steps/SeleniumIdeStep");
11
+ const fast_json_stable_stringify_1 = __importDefault(require("fast-json-stable-stringify"));
8
12
  class MablStep extends MablAction_1.MablAction {
9
13
  constructor(name, args, actions) {
10
14
  super(name, args);
@@ -25,9 +29,15 @@ class MablStep extends MablAction_1.MablAction {
25
29
  setAnnotation(annotation) {
26
30
  this.annotation = annotation;
27
31
  }
32
+ getAnnotation() {
33
+ return this.annotation;
34
+ }
28
35
  setDescription(description) {
29
36
  this.description = description;
30
37
  }
38
+ getDescription() {
39
+ return this.description;
40
+ }
31
41
  setStepSourceIndexInFlow(index) {
32
42
  this.stepSourceIndexInFlow = index;
33
43
  }
@@ -102,7 +112,7 @@ class MablStep extends MablAction_1.MablAction {
102
112
  case 'number':
103
113
  return `${key}: ${objectArgs[key]}`;
104
114
  default:
105
- return `${key}: "${objectArgs[key]}"`;
115
+ return `${key}: "${(0, domUtil_1.escapeMablscriptString)(objectArgs[key])}"`;
106
116
  }
107
117
  });
108
118
  return `{${mablArgs.join(', ')}}`;
@@ -110,6 +120,14 @@ class MablStep extends MablAction_1.MablAction {
110
120
  toMablscript() {
111
121
  return '';
112
122
  }
123
+ toLineDiffFormat() {
124
+ const lineDiffProperties = {
125
+ annotation: this.annotation,
126
+ disabled: this.isDisabled(),
127
+ mablscript: this.toMablscript(),
128
+ };
129
+ return (0, fast_json_stable_stringify_1.default)(lineDiffProperties);
130
+ }
113
131
  }
114
132
  exports.MablStep = MablStep;
115
133
  MablStep.mablScriptStepNames = ['mablStep'];
@@ -2,13 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AwaitPDFDownloadAction = void 0;
4
4
  const AwaitDownloadAction_1 = require("./AwaitDownloadAction");
5
+ const domUtil_1 = require("../../domUtil");
5
6
  class AwaitPDFDownloadAction extends AwaitDownloadAction_1.AwaitDownloadAction {
6
7
  constructor(name, args) {
7
8
  super(name, args);
8
9
  this.pdfUUID = this.getActionArgs()[0].uuid;
9
10
  }
10
11
  toMablscript() {
11
- return `await_pdf({uuid: \"${this.pdfUUID}\"})`;
12
+ return `await_pdf(${(0, domUtil_1.buildStepArgumentString)({ uuid: this.pdfUUID })})`;
12
13
  }
13
14
  }
14
15
  exports.AwaitPDFDownloadAction = AwaitPDFDownloadAction;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ConditionAction = void 0;
4
+ const domUtil_1 = require("../../domUtil");
4
5
  const MablAction_1 = require("../MablAction");
5
6
  const ConditionDescriptor_1 = require("../types/ConditionDescriptor");
6
7
  class ConditionAction extends MablAction_1.MablAction {
@@ -48,9 +49,16 @@ class ConditionAction extends MablAction_1.MablAction {
48
49
  };
49
50
  }
50
51
  generateEvaluateConditionMablscript() {
51
- return `${this.name}("${this.conditionAttribute}"${this.conditionValueAttribute !== undefined
52
- ? `, ${this.subVariable(this.conditionValueAttribute)}`
53
- : ''})`;
52
+ let value = '';
53
+ if (this.conditionValueAttribute !== undefined) {
54
+ if (!(0, MablAction_1.argumentIsMablVariable)(this.conditionValueAttribute)) {
55
+ value = `, "${(0, domUtil_1.escapeMablscriptString)(this.conditionValueAttribute)}"`;
56
+ }
57
+ else {
58
+ value = `, ${this.subVariable(this.conditionValueAttribute)}`;
59
+ }
60
+ }
61
+ return `${this.name}("${this.conditionAttribute}"${value})`;
54
62
  }
55
63
  toMablscript() {
56
64
  return `${this.generateEvaluateConditionMablscript()}`;
@@ -6,21 +6,26 @@ const ExtractDescriptor_1 = require("../types/ExtractDescriptor");
6
6
  class ExtractAction extends MablAction_1.MablAction {
7
7
  constructor(name, args) {
8
8
  super(name, args);
9
+ if (this.name === ExtractDescriptor_1.ExtractType.EXTRACT_INNER_TEXT) {
10
+ this.name = 'extract_attribute';
11
+ this.extractionAttribute = 'innerText';
12
+ }
13
+ else {
14
+ this.extractionAttribute = this.getActionArgs()[0];
15
+ }
9
16
  this.extractionType = this.name;
10
- this.extractionAttribute = this.getActionArgs()[0];
11
17
  this.extractDescriptor = this.getExtractDescriptor();
12
18
  }
13
19
  getExtractDescriptor() {
14
- const attributeName = this.args[0];
15
- if (!attributeName) {
20
+ if (!this.extractionAttribute) {
16
21
  throw new Error(`Attribute name is required for extract attribute action.`);
17
22
  }
18
- if (typeof attributeName !== 'string') {
19
- throw new Error(`Invalid attribute provided for extract attribute extractor: ${attributeName}`);
23
+ if (typeof this.extractionAttribute !== 'string') {
24
+ throw new Error(`Invalid attribute provided for extract attribute extractor: ${this.extractionAttribute}`);
20
25
  }
21
26
  return {
22
27
  extractType: ExtractDescriptor_1.ExtractType.fromString(this.name),
23
- attributeName,
28
+ attributeName: this.extractionAttribute,
24
29
  };
25
30
  }
26
31
  toMablscript() {
@@ -31,7 +36,11 @@ class ExtractAction extends MablAction_1.MablAction {
31
36
  }
32
37
  }
33
38
  exports.ExtractAction = ExtractAction;
34
- ExtractAction.mablScriptStepNames = ['extract_attribute', 'extract_email_attribute'];
39
+ ExtractAction.mablScriptStepNames = [
40
+ 'extract_attribute',
41
+ 'extract_email_attribute',
42
+ 'extract_inner_text',
43
+ ];
35
44
  ExtractAction.mablscriptToYamlType = {
36
45
  extract_attribute: 'ElementAttribute',
37
46
  extract_email_attribute: 'EmailAttribute',
@@ -2,9 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalize = exports.isElementSelector = exports.FindAction = exports.findTypesToFormattedType = void 0;
4
4
  const domUtil_1 = require("../../domUtil");
5
- const MablAction_1 = require("../MablAction");
6
5
  const mablscriptFind_1 = require("../../mablscriptFind");
7
- const MablStep_1 = require("../MablStep");
6
+ const MablAction_1 = require("../MablAction");
8
7
  exports.findTypesToFormattedType = {
9
8
  find_all: 'FindAll',
10
9
  find_any: 'FindFirst',
@@ -13,6 +12,7 @@ exports.findTypesToFormattedType = {
13
12
  find_one: 'FindOne',
14
13
  find_email: 'FindEmail',
15
14
  find_tab: 'FindTab',
15
+ find_last: 'FindLast',
16
16
  };
17
17
  const formattedFindTypeToMablscript = {};
18
18
  Object.entries(exports.findTypesToFormattedType).forEach(([findType, field]) => (formattedFindTypeToMablscript[field] = findType));
@@ -24,10 +24,10 @@ class FindAction extends MablAction_1.MablAction {
24
24
  throw new Error(`Unknown find type for action: ${actionName}`);
25
25
  }
26
26
  const findType = domUtil_1.FindType.fromString(actionName);
27
- const [selectors, options] = this.getActionArgs();
28
27
  this.isValid = true;
29
28
  switch (findType) {
30
- case domUtil_1.FindType.FIND_ONE:
29
+ case domUtil_1.FindType.FIND_ONE: {
30
+ const [selectors, options] = this.getActionArgs();
31
31
  if (!isElementSelector(selectors)) {
32
32
  this.isValid = false;
33
33
  }
@@ -46,19 +46,30 @@ class FindAction extends MablAction_1.MablAction {
46
46
  this.findDescriptor.findOptions = options;
47
47
  }
48
48
  break;
49
+ }
49
50
  case domUtil_1.FindType.FIND_FIRST:
50
51
  case domUtil_1.FindType.FIND_LAST:
51
52
  case domUtil_1.FindType.FIND_ANY:
52
- case domUtil_1.FindType.FIND_ALL:
53
- if (!(0, domUtil_1.isCssSelector)(selectors) && !(0, domUtil_1.isXPathSelector)(selectors)) {
53
+ case domUtil_1.FindType.FIND_ALL: {
54
+ const [primarySelector, foundSelector, findOptions] = this.getActionArgs();
55
+ if (!(0, domUtil_1.isCssSelector)(primarySelector) &&
56
+ !(0, domUtil_1.isXPathSelector)(primarySelector)) {
54
57
  this.isValid = false;
55
58
  }
56
59
  this.findDescriptor = {
57
60
  findType,
58
- findTarget: selectors,
61
+ findTarget: primarySelector,
62
+ foundElementSelectors: foundSelector,
63
+ primarySelectors: {
64
+ ...primarySelector,
65
+ uuid: primarySelector.uuid,
66
+ },
67
+ hints: findOptions === null || findOptions === void 0 ? void 0 : findOptions.hints,
59
68
  };
60
69
  break;
61
- case domUtil_1.FindType.FIND_COOKIE:
70
+ }
71
+ case domUtil_1.FindType.FIND_COOKIE: {
72
+ const [selectors] = this.getActionArgs();
62
73
  if (!(0, domUtil_1.isCookieSelector)(selectors)) {
63
74
  this.isValid = false;
64
75
  }
@@ -67,7 +78,9 @@ class FindAction extends MablAction_1.MablAction {
67
78
  findTarget: selectors,
68
79
  };
69
80
  break;
81
+ }
70
82
  case domUtil_1.FindType.FIND_EMAIL:
83
+ const [selectors] = this.getActionArgs();
71
84
  if (!(0, domUtil_1.isEmailSelector)(selectors)) {
72
85
  this.isValid = false;
73
86
  }
@@ -76,7 +89,8 @@ class FindAction extends MablAction_1.MablAction {
76
89
  findTarget: selectors,
77
90
  };
78
91
  break;
79
- case domUtil_1.FindType.FIND_TAB:
92
+ case domUtil_1.FindType.FIND_TAB: {
93
+ const [selectors] = this.getActionArgs();
80
94
  if (selectors !== 'initial' && !(0, domUtil_1.isTabSelector)(selectors)) {
81
95
  this.isValid = false;
82
96
  }
@@ -84,6 +98,7 @@ class FindAction extends MablAction_1.MablAction {
84
98
  findType,
85
99
  findTarget: selectors,
86
100
  };
101
+ }
87
102
  }
88
103
  Object.freeze(this.findDescriptor);
89
104
  }
@@ -155,47 +170,71 @@ class FindAction extends MablAction_1.MablAction {
155
170
  }
156
171
  }
157
172
  toMablscript() {
158
- return this.generateMablscriptFindOne();
173
+ return this.generateFindMablscript();
159
174
  }
160
- generateMablscriptFindOne() {
175
+ generateFindMablscript() {
161
176
  var _a;
177
+ let action = this.findDescriptor.findType;
178
+ let args = '';
162
179
  switch (this.findDescriptor.findType) {
163
- case domUtil_1.FindType.FIND_ONE: {
180
+ case domUtil_1.FindType.FIND_ONE:
164
181
  const find = this.findDescriptor;
165
- const action = find.findType;
166
182
  const selectors = ((_a = find.findTarget.auxiliaryDescriptors) === null || _a === void 0 ? void 0 : _a.length)
167
183
  ? '[' +
168
- [
169
- find.findTarget.selector,
170
- ...find.findTarget.auxiliaryDescriptors.map((descriptor) => descriptor.selector),
171
- ]
172
- .map(mablscriptFind_1.buildElementSelectorString)
184
+ [find.findTarget, ...find.findTarget.auxiliaryDescriptors]
185
+ .map(mablscriptFind_1.buildFindDescriptorString)
186
+ .filter(Boolean)
173
187
  .join(', ') +
174
188
  ']'
175
- : (0, mablscriptFind_1.buildElementSelectorString)(find.findTarget.selector);
189
+ : (0, mablscriptFind_1.buildFindDescriptorString)(find.findTarget);
176
190
  const options = buildFindOptionsString(find.findOptions);
177
- const args = [selectors, options].filter((str) => str).join(', ');
178
- return `${action}(${args})`;
179
- }
180
- case domUtil_1.FindType.FIND_FIRST:
191
+ args = [selectors, options].filter(Boolean).join(', ');
192
+ break;
181
193
  case domUtil_1.FindType.FIND_LAST:
182
194
  case domUtil_1.FindType.FIND_ANY:
183
195
  case domUtil_1.FindType.FIND_ALL:
196
+ case domUtil_1.FindType.FIND_FIRST: {
197
+ const find = this.findDescriptor;
198
+ const selector = (0, mablscriptFind_1.buildElementSelectorString)(find.findTarget);
199
+ let foundElementSelectors;
200
+ if (find.foundElementSelectors) {
201
+ if (Array.isArray(find.foundElementSelectors)) {
202
+ foundElementSelectors = find.foundElementSelectors
203
+ .map((selector) => (0, mablscriptFind_1.buildFindDescriptorString)({ selector }))
204
+ .join(', ');
205
+ }
206
+ else {
207
+ foundElementSelectors = (0, mablscriptFind_1.buildFindDescriptorString)({
208
+ selector: find.foundElementSelectors,
209
+ });
210
+ }
211
+ }
212
+ else {
213
+ foundElementSelectors = '{selector_type: "element"}';
214
+ }
215
+ args = [selector, foundElementSelectors].join(', ');
216
+ if (find.hints) {
217
+ args += `, ${(0, mablscriptFind_1.buildFindHintsString)(find.hints)}`;
218
+ }
219
+ if (find.findType === domUtil_1.FindType.FIND_ANY) {
220
+ action = domUtil_1.FindType.FIND_FIRST;
221
+ }
222
+ break;
223
+ }
184
224
  case domUtil_1.FindType.FIND_COOKIE:
225
+ args = (0, mablscriptFind_1.buildCookieSelectorString)(this.findDescriptor.findTarget);
226
+ break;
185
227
  case domUtil_1.FindType.FIND_EMAIL: {
186
- const find = this.findDescriptor;
187
- const action = find.findType;
188
- const args = (0, mablscriptFind_1.buildElementSelectorString)(find.findTarget);
189
- return `${action}(${args})`;
228
+ args = (0, mablscriptFind_1.buildEmailSelectorString)(this.findDescriptor.findTarget);
229
+ break;
190
230
  }
191
231
  case domUtil_1.FindType.FIND_TAB:
192
- if (this.findDescriptor.findTarget === 'initial') {
193
- return `${this.findDescriptor.findType}("${this.findDescriptor.findTarget}")`;
194
- }
195
- return `${this.findDescriptor.findType}(${(0, mablscriptFind_1.buildElementSelectorString)(this.findDescriptor.findTarget)})`;
232
+ args = (0, mablscriptFind_1.buildTabSelectorString)(this.findDescriptor.findTarget);
233
+ break;
196
234
  default:
197
235
  throw new Error(`Error generating mablscript: Unexpected find type in ${JSON.stringify(this.findDescriptor)}`);
198
236
  }
237
+ return `${action}(${args})`;
199
238
  }
200
239
  isValidDescriptor() {
201
240
  return this.isValid;
@@ -226,15 +265,7 @@ function buildFindOptionsString(findOptions) {
226
265
  if (!findOptions) {
227
266
  return '';
228
267
  }
229
- let findOptionsFinal = '{';
230
- if (findOptions.hints) {
231
- findOptionsFinal += `hints: {${(0, MablStep_1.buildObjectString)(findOptions.hints).join(', ')}}`;
232
- }
233
- if (findOptions.waitUntil) {
234
- findOptionsFinal += `waitUntil: {${(0, MablStep_1.buildObjectString)(findOptions.waitUntil)}}`;
235
- }
236
- findOptionsFinal += '}';
237
- return findOptionsFinal;
268
+ return JSON.stringify(findOptions);
238
269
  }
239
270
  function isElementSelector(maybeSelectors) {
240
271
  const [target, ancestor] = Array.isArray(maybeSelectors)
@@ -2,13 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GenerateRandomStringAction = void 0;
4
4
  const MablAction_1 = require("../MablAction");
5
+ const domUtil_1 = require("../../domUtil");
5
6
  class GenerateRandomStringAction extends MablAction_1.MablAction {
6
7
  constructor(name, args) {
7
8
  super(name, args);
8
9
  this.generateString = this.getActionArgs()[0];
9
10
  }
10
11
  toMablscript() {
11
- return `generate_random_string(\"${this.generateString}\")`;
12
+ return `generate_random_string(\"${(0, domUtil_1.escapeMablscriptString)(this.generateString)}\")`;
12
13
  }
13
14
  }
14
15
  exports.GenerateRandomStringAction = GenerateRandomStringAction;
@@ -13,7 +13,7 @@ class GetUrlAction extends MablAction_1.MablAction {
13
13
  toDescriptor() {
14
14
  return (0, GetCurrentLocationDescriptor_1.newGetCurrentLocationDescriptor)();
15
15
  }
16
- generateMablscriptFindOne() {
16
+ generateFindMablscript() {
17
17
  return 'get_current_location()';
18
18
  }
19
19
  }
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GetVariableValue = void 0;
4
4
  const MablAction_1 = require("../MablAction");
5
- const GetVariableDescriptor_1 = require("../types/GetVariableDescriptor");
6
5
  const MablSymbol_1 = require("../MablSymbol");
6
+ const GetVariableDescriptor_1 = require("../types/GetVariableDescriptor");
7
7
  class GetVariableValue extends MablAction_1.MablAction {
8
8
  constructor(name, args) {
9
9
  super(name, args);
@@ -19,7 +19,7 @@ class GetVariableValue extends MablAction_1.MablAction {
19
19
  toDescriptor() {
20
20
  return (0, GetVariableDescriptor_1.newGetVariableDescriptor)(this.variable);
21
21
  }
22
- generateMablscriptFindOne() {
22
+ generateFindMablscript() {
23
23
  return `get_variable_value(${this.variable.name})`;
24
24
  }
25
25
  }
@@ -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,
@@ -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;
@@ -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 = (0, 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];
@@ -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'