@mablhq/mabl-cli 1.48.41 → 1.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/basicApiClient.js +8 -2
- package/api/mablApiClient.js +6 -8
- package/api/mablApiClientFactory.js +2 -1
- package/browserLauncher/playwrightBrowserLauncher/playwrightDom.js +4 -0
- package/commands/commandUtil/fileUtil.js +11 -3
- package/commands/constants.js +1 -0
- package/commands/flows/flows_cmds/export.js +1 -1
- package/commands/tests/tests_cmds/export.js +53 -22
- package/core/trainer/trainingSessions.js +1 -1
- package/domUtil/index.js +1 -1
- package/execution/index.js +1 -1
- package/functions/apiTest/utils.js +1 -1
- package/mablApi/index.js +1 -1
- package/mablscript/MablStep.js +0 -14
- package/mablscript/actions/ExtractAction.js +23 -4
- package/mablscript/actions/FindAction.js +0 -16
- package/mablscript/importer.js +1 -6
- package/mablscript/steps/AssertStep.js +4 -109
- package/mablscript/steps/ClickStep.js +0 -6
- package/mablscript/steps/CreateVariableStep.js +4 -47
- package/mablscript/steps/DoubleClickStep.js +0 -6
- package/mablscript/steps/EchoStep.js +0 -6
- package/mablscript/steps/EnterTextStep.js +0 -7
- package/mablscript/steps/HoverStep.js +0 -6
- package/mablscript/steps/IfConditionStep.js +4 -1
- package/mablscript/steps/NavigateStep.js +0 -6
- package/mablscript/steps/RightClickStep.js +0 -6
- package/mablscript/steps/SendKeyStep.js +0 -36
- package/mablscript/steps/SetViewportStep.js +0 -8
- package/mablscript/steps/SwitchContextStep.js +0 -21
- package/mablscript/steps/VisitUrlStep.js +0 -6
- package/mablscript/steps/WaitStep.js +0 -6
- package/mablscript/types/ExtractDescriptor.js +1 -0
- package/mablscriptFind/index.js +1 -1
- package/package.json +1 -1
- package/resources/mablFind.js +1 -1
- package/resources/pdf-viewer/EmbeddedPdfHandler.js +1 -1
- package/resources/pdf-viewer/libEmbeddedPdfHandler.js +62 -16
- package/configGenerators/flowConfigGenerator.js +0 -86
- package/configGenerators/selIdeGenerator.js +0 -47
- package/configGenerators/testConfigGenerator.js +0 -77
- package/mablscript/steps/SeleniumIdeStep.js +0 -32
|
@@ -1 +1 @@
|
|
|
1
|
-
export const MABL_PROCESSED_PDF_ATTRIBUTE="__mabl-processed-pdf";export const MABL_PDF_DETECTOR_STYLE_ID="__mabl-pdf-detector";export const MABL_PDF_DETECTOR_ANIMATION_NAME="__mabl-trainer-object-embed-detector";const MABL_PDF_SRC_ATTRIBUTE="data-mabl-pdf-src";export const PDFEventType="animationstart";export class EmbeddedPdfHandler{constructor(e,t,n,
|
|
1
|
+
export const MABL_PROCESSED_PDF_ATTRIBUTE="__mabl-processed-pdf";export const MABL_PDF_DETECTOR_STYLE_ID="__mabl-pdf-detector";export const MABL_PDF_DETECTOR_ANIMATION_NAME="__mabl-trainer-object-embed-detector";const MABL_PDF_SRC_ATTRIBUTE="data-mabl-pdf-src";export const PDFEventType="animationstart";export class EmbeddedPdfHandler{constructor(e,t,n,r){this.PDFEmbeddedViewerBaseUrl=e,this.createElement=t||document.createElement,this.shouldHandle=n||(()=>!0),this.cMapUrl=r,this.handle=this.handle.bind(this),this.register=this.register.bind(this),this.updateElement=this.updateElement.bind(this),this.createViewerElement=this.createViewerElement.bind(this),this.checkUrlProtocol=this.checkUrlProtocol.bind(this)}register(){if(!document.doctype||!document.doctype.name||-1!==document.doctype.name.indexOf("html")){if(!document.getElementById("__mabl-pdf-detector")){let e=this.createElement.call(document,"style");if(e.innerHTML=`\n @keyframes ${MABL_PDF_DETECTOR_ANIMATION_NAME} { from {} }\n object, embed {\n animation-delay: 0s !important;\n animation-name: ${MABL_PDF_DETECTOR_ANIMATION_NAME} !important;\n animation-play-state: running !important;\n }`,e.id="__mabl-pdf-detector",this.pdfDetectorStyleElem=e,document.head)document.head.appendChild(e);else{if(!document.body)return;document.body.appendChild(e)}}window.addEventListener(PDFEventType,this.handle,!0)}}unregister(){window.removeEventListener(PDFEventType,this.handle,!0),this.pdfDetectorStyleElem&&this.pdfDetectorStyleElem.parentNode&&this.pdfDetectorStyleElem.parentNode.removeChild(this.pdfDetectorStyleElem)}handle(e){if(!this.canHandleEvent(e))return;const t=e.target;this.updateElement(t)}checkAnimationEvent(e){return e.animationName===MABL_PDF_DETECTOR_ANIMATION_NAME}checkElement(e){return"EMBED"===e.tagName||"OBJECT"===e.tagName}checkMimeType(e){let t=e.type,n=this.getPdfUrlFromElement(e);return t&&"application/pdf"===t.toLowerCase()||!t&&n&&/\.pdf($|[?#])/i.test(n)||!!e["__mabl-processed-pdf"]}checkUrlProtocol(e){if("about:blank"===e.src)return!1;const t=this.getPdfUrlFromElement(e);try{const e=new URL(t),n=["http:","https:","data:"];if(!n.includes(e?.protocol))return console.warn(`PDF Handler ignoring element with URL ${t} because protocol ${e?.protocol} does not match one of the allowed protocols ${n}`),!1;if("data:"===e?.protocol&&!/^data:application\/pdf[,;]/.test(e?.href??""))return console.warn(`PDF Handler ignoring element with URL ${t} because it does not use application/pdf MIME type`),!1}catch(e){return console.warn(`PDF Handler ignoring element with URL ${t}; error ${e} was thrown while converting to URL`),!1}return!0}canHandleEvent(e){const t=e.target;return this.shouldHandle(e)&&this.checkAnimationEvent(e)&&this.checkElement(t)&&this.checkMimeType(t)&&this.checkUrlProtocol(t)}updateElement(e){if("text/html"===e.type&&0===e.src.lastIndexOf(this.PDFEmbeddedViewerBaseUrl,0))return;let t=e.parentNode,n=e.nextSibling,r=this.createViewerElement(e);t&&(t.removeChild(e),t.insertBefore(r,n))}getPdfUrlFromElement(e){let t=e.src||e.data||e.getAttribute("mabl-pdf-url")||void 0;return"about:blank"===t&&(t=window.location.href),t}createViewerElement(e){let t=this.createElement.call(document,"iframe");const n=this.getPdfUrlFromElement(e);return e.offsetHeight&&e.offsetWidth?(t.height=e.offsetHeight,t.width=e.offsetWidth):e.height&&e.width&&(t.height=e.height,t.width=e.width),t.id="__mabl_pdf_viewer_"+this.idSanitize(this.getPdfFilenameFromUrl(n)),t.src=this.getEmbeddedViewerURL(n),t.setAttribute("__mabl-processed-pdf","true"),t.setAttribute("data-mabl-pdf-src",n),t}getEmbeddedViewerURL(e){var t=/^([^#]*)(#.*)?$/.exec(e);e=t[1],t=t[2]||"";var n=document.createElement("a");return n.href=document.baseURI,n.href=e,e=n.href,this.getViewerURL(e)+t}getPdfFilenameFromUrl(e){let t=new URL(e).pathname.split("/").slice(-1)[0]||"mablPdf";return e.startsWith("blob:")&&(t="blob_pdf"),t}getViewerURL(e){let t=this.getPdfFilenameFromUrl(e);return this.PDFEmbeddedViewerBaseUrl+"?file="+encodeURIComponent(e)+"&name="+t}idSanitize(e){return e&&e.replace(/[^a-zA-Z0-9.-]/g,"_")}}
|
|
@@ -65,6 +65,7 @@ class EmbeddedPdfHandler {
|
|
|
65
65
|
this.register = this.register.bind(this);
|
|
66
66
|
this.updateElement = this.updateElement.bind(this);
|
|
67
67
|
this.createViewerElement = this.createViewerElement.bind(this);
|
|
68
|
+
this.checkUrlProtocol = this.checkUrlProtocol.bind(this);
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
register() {
|
|
@@ -108,14 +109,6 @@ class EmbeddedPdfHandler {
|
|
|
108
109
|
}
|
|
109
110
|
|
|
110
111
|
var pdfElement = event.target;
|
|
111
|
-
|
|
112
|
-
if (pdfElement.src === 'about:blank') {
|
|
113
|
-
// this is likely the chrome viewer for a POST
|
|
114
|
-
// don't do anything, we might get a manual update later
|
|
115
|
-
// if the trainer finds a PDF
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
112
|
this.updateElement(pdfElement);
|
|
120
113
|
}
|
|
121
114
|
|
|
@@ -129,18 +122,58 @@ class EmbeddedPdfHandler {
|
|
|
129
122
|
|
|
130
123
|
checkMimeType(element) {
|
|
131
124
|
var mimeType = element.type;
|
|
132
|
-
var path =
|
|
133
|
-
|
|
125
|
+
var path = this.getPdfUrlFromElement(element);
|
|
134
126
|
var isAPdf = mimeType && mimeType.toLowerCase() === 'application/pdf' || // mime type is PDF
|
|
135
127
|
!mimeType && path && /\.pdf($|[?#])/i.test(path) || // or if we don't have a mime type test the path up to query or hash
|
|
136
128
|
!!element[MABL_PROCESSED_PDF_ATTRIBUTE]; // it's an element we've already identified
|
|
137
129
|
|
|
138
130
|
return isAPdf;
|
|
139
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* Checks that the URL embedding the PDF leads to a valid location and/or
|
|
134
|
+
* has a valid protocol
|
|
135
|
+
* @param {HTMLElement} element The element on the page whose URL to check
|
|
136
|
+
* @returns {boolean} Whether or not the element is valid
|
|
137
|
+
*/
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
checkUrlProtocol(element) {
|
|
141
|
+
if (element.src === 'about:blank') {
|
|
142
|
+
// this is likely the chrome viewer for a POST
|
|
143
|
+
// don't do anything, we might get a manual update later
|
|
144
|
+
// if the trainer finds a PDF
|
|
145
|
+
return false;
|
|
146
|
+
} // Validate that the URL is an allowed protocol to prevent XSS, see IST-561
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
var pdfUrlString = this.getPdfUrlFromElement(element);
|
|
150
|
+
|
|
151
|
+
try {
|
|
152
|
+
var _pdfUrl$href;
|
|
153
|
+
|
|
154
|
+
var pdfUrl = new URL(pdfUrlString); // data: is allowed to support embedding the PDF inline using a data URI scheme
|
|
155
|
+
|
|
156
|
+
var allowedProtocols = ['http:', 'https:', 'data:'];
|
|
157
|
+
|
|
158
|
+
if (!allowedProtocols.includes(pdfUrl === null || pdfUrl === void 0 ? void 0 : pdfUrl.protocol)) {
|
|
159
|
+
console.warn("PDF Handler ignoring element with URL ".concat(pdfUrlString, " because protocol ").concat(pdfUrl === null || pdfUrl === void 0 ? void 0 : pdfUrl.protocol, " does not match one of the allowed protocols ").concat(allowedProtocols));
|
|
160
|
+
return false;
|
|
161
|
+
} else if ((pdfUrl === null || pdfUrl === void 0 ? void 0 : pdfUrl.protocol) === 'data:' && !/^data:application\/pdf[,;]/.test((_pdfUrl$href = pdfUrl === null || pdfUrl === void 0 ? void 0 : pdfUrl.href) !== null && _pdfUrl$href !== void 0 ? _pdfUrl$href : '') // starts with data:application/pdf and either , or ; separator
|
|
162
|
+
) {
|
|
163
|
+
console.warn("PDF Handler ignoring element with URL ".concat(pdfUrlString, " because it does not use application/pdf MIME type"));
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
} catch (e) {
|
|
167
|
+
console.warn("PDF Handler ignoring element with URL ".concat(pdfUrlString, "; error ").concat(e, " was thrown while converting to URL"));
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
140
173
|
|
|
141
174
|
canHandleEvent(event) {
|
|
142
175
|
var element = event.target;
|
|
143
|
-
return this.shouldHandle(event) && this.checkAnimationEvent(event) && this.checkElement(element) && this.checkMimeType(element);
|
|
176
|
+
return this.shouldHandle(event) && this.checkAnimationEvent(event) && this.checkElement(element) && this.checkMimeType(element) && this.checkUrlProtocol(element);
|
|
144
177
|
} // adapted from PDF.js
|
|
145
178
|
// Display the PDF Viewer in an <embed>.
|
|
146
179
|
|
|
@@ -161,19 +194,32 @@ class EmbeddedPdfHandler {
|
|
|
161
194
|
parentNode.insertBefore(viewerElem, nextSibling);
|
|
162
195
|
}
|
|
163
196
|
}
|
|
197
|
+
/**
|
|
198
|
+
* Returns the URL string of the element which should in some way be embedding a PDF.
|
|
199
|
+
* @param {HTMLElement} originalPdfElement The element embedding the PDF, should have embed tag, object tag,
|
|
200
|
+
* or have the mabl-pdf-url attribute
|
|
201
|
+
* @returns {(string|undefined)} The URL which should host the PDF, or undefined if none was found
|
|
202
|
+
*/
|
|
164
203
|
|
|
165
|
-
|
|
166
|
-
|
|
204
|
+
|
|
205
|
+
getPdfUrlFromElement(originalPdfElement) {
|
|
167
206
|
var pdfUrl = originalPdfElement.src || originalPdfElement.data || // embed has @src, object has @data
|
|
168
|
-
originalPdfElement.getAttribute('mabl-pdf-url')
|
|
207
|
+
originalPdfElement.getAttribute('mabl-pdf-url') || // special case for embedded blob urls
|
|
208
|
+
undefined; // getAttribute can return null or '', would prefer to return undefined
|
|
169
209
|
|
|
170
210
|
if (pdfUrl === 'about:blank') {
|
|
171
211
|
// we're likely in the chrome viewer, so window.location actually has
|
|
172
212
|
// the right URL
|
|
173
213
|
pdfUrl = window.location.href;
|
|
174
|
-
}
|
|
175
|
-
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
return pdfUrl;
|
|
217
|
+
}
|
|
176
218
|
|
|
219
|
+
createViewerElement(originalPdfElement) {
|
|
220
|
+
var viewerElem = this.createElement.call(document, 'iframe');
|
|
221
|
+
var pdfUrl = this.getPdfUrlFromElement(originalPdfElement); // Firefox does not always get the correct offsetHeight and offsetWidth
|
|
222
|
+
// so if the value returned is 0, then just leave the size to the default size
|
|
177
223
|
|
|
178
224
|
if (originalPdfElement.offsetHeight && originalPdfElement.offsetWidth) {
|
|
179
225
|
viewerElem.height = originalPdfElement.offsetHeight;
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FlowConfig = void 0;
|
|
4
|
-
const importer_1 = require("../mablscript/importer");
|
|
5
|
-
class FlowConfig {
|
|
6
|
-
constructor(flow, includeLocatorInfo) {
|
|
7
|
-
this.flow = flow;
|
|
8
|
-
this.includeLocatorInfo = includeLocatorInfo;
|
|
9
|
-
this.flow = flow;
|
|
10
|
-
this.includeLocatorInfo = includeLocatorInfo;
|
|
11
|
-
}
|
|
12
|
-
generateConfigFile() {
|
|
13
|
-
const flowConfig = {};
|
|
14
|
-
flowConfig.flowId = this.flow.id;
|
|
15
|
-
flowConfig.flowVersion = this.flow.version;
|
|
16
|
-
flowConfig.description = this.flow.description;
|
|
17
|
-
flowConfig.configVersion = 1;
|
|
18
|
-
flowConfig.flowType = this.flow.flow_type;
|
|
19
|
-
flowConfig.workspaceId = this.flow.organization_id;
|
|
20
|
-
flowConfig.reusable = this.flow.reusable;
|
|
21
|
-
const loadedSteps = (0, importer_1.parseMablScriptIntoSteps)(this.flow);
|
|
22
|
-
flowConfig.steps = loadedSteps.map((step) => step.getFormattedStep(this.includeLocatorInfo));
|
|
23
|
-
return flowConfig;
|
|
24
|
-
}
|
|
25
|
-
generateSimpleFormat() {
|
|
26
|
-
const flow = this.generateConfigFile();
|
|
27
|
-
let apiSteps;
|
|
28
|
-
if (flow.api_steps) {
|
|
29
|
-
apiSteps = flow.api_steps;
|
|
30
|
-
}
|
|
31
|
-
const steps = FlowConfig.generateStepsSimpleFormat(flow.steps);
|
|
32
|
-
const output = {
|
|
33
|
-
id: this.flow.id,
|
|
34
|
-
name: this.flow.id,
|
|
35
|
-
description: this.flow.description || '',
|
|
36
|
-
steps,
|
|
37
|
-
};
|
|
38
|
-
if (apiSteps) {
|
|
39
|
-
output.api_steps = apiSteps;
|
|
40
|
-
}
|
|
41
|
-
return output;
|
|
42
|
-
}
|
|
43
|
-
static generateStepsSimpleFormat(suppliedSteps) {
|
|
44
|
-
const steps = [];
|
|
45
|
-
suppliedSteps.forEach((step) => {
|
|
46
|
-
var _a, _b, _c, _d;
|
|
47
|
-
const stepName = Object.keys(step)[0];
|
|
48
|
-
const stepObj = step;
|
|
49
|
-
const mablStep = stepObj[stepName];
|
|
50
|
-
const newStep = {};
|
|
51
|
-
const newStepCreated = {
|
|
52
|
-
description: mablStep.description,
|
|
53
|
-
};
|
|
54
|
-
if (((_a = mablStep.annotation) === null || _a === void 0 ? void 0 : _a.note) || ((_b = mablStep.annotation) === null || _b === void 0 ? void 0 : _b.description)) {
|
|
55
|
-
newStepCreated.annotation = {};
|
|
56
|
-
if ((_c = mablStep.annotation) === null || _c === void 0 ? void 0 : _c.note) {
|
|
57
|
-
newStepCreated.annotation.note = mablStep.annotation.note;
|
|
58
|
-
}
|
|
59
|
-
if ((_d = mablStep.annotation) === null || _d === void 0 ? void 0 : _d.description) {
|
|
60
|
-
newStepCreated.annotation.description =
|
|
61
|
-
mablStep.annotation.description;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
newStep[stepName] = newStepCreated;
|
|
65
|
-
steps.push(newStep);
|
|
66
|
-
});
|
|
67
|
-
return steps;
|
|
68
|
-
}
|
|
69
|
-
generateSimpleCsv() {
|
|
70
|
-
const flowConfig = this.generateConfigFile();
|
|
71
|
-
const output = [
|
|
72
|
-
' ,Step Number, Step Type, Description, Annotation, Note',
|
|
73
|
-
];
|
|
74
|
-
let count = 0;
|
|
75
|
-
flowConfig.steps.forEach((step) => {
|
|
76
|
-
var _a, _b;
|
|
77
|
-
const stepName = Object.keys(step)[0];
|
|
78
|
-
const stepObj = step;
|
|
79
|
-
const mablStep = stepObj[stepName];
|
|
80
|
-
output.push(`${count}, ${stepName}, ${mablStep.description}, ${((_a = mablStep === null || mablStep === void 0 ? void 0 : mablStep.annotation) === null || _a === void 0 ? void 0 : _a.note) || '-'}, ${((_b = mablStep === null || mablStep === void 0 ? void 0 : mablStep.annotation) === null || _b === void 0 ? void 0 : _b.description) || '-'}`);
|
|
81
|
-
count += 1;
|
|
82
|
-
});
|
|
83
|
-
return output;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
exports.FlowConfig = FlowConfig;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SelIdeConfig = void 0;
|
|
4
|
-
const SeleniumIdeStep_1 = require("../mablscript/steps/SeleniumIdeStep");
|
|
5
|
-
const importer_1 = require("../mablscript/importer");
|
|
6
|
-
class SelIdeConfig {
|
|
7
|
-
constructor(journey, flows) {
|
|
8
|
-
this.journey = journey;
|
|
9
|
-
this.flows = flows;
|
|
10
|
-
}
|
|
11
|
-
generateConfigFile() {
|
|
12
|
-
var _a;
|
|
13
|
-
const selIdeConfig = {};
|
|
14
|
-
const selIdeTest = {};
|
|
15
|
-
selIdeTest.id = (0, SeleniumIdeStep_1.generateIdForSeleniumEntity)(this.journey.id + 'test');
|
|
16
|
-
selIdeTest.name = (_a = this.journey.name) !== null && _a !== void 0 ? _a : '';
|
|
17
|
-
let steps = [];
|
|
18
|
-
this.flows.forEach((flow) => {
|
|
19
|
-
const loadedSteps = (0, importer_1.parseMablScriptIntoSteps)(flow);
|
|
20
|
-
steps = steps.concat(loadedSteps);
|
|
21
|
-
});
|
|
22
|
-
selIdeTest.commands = (0, importer_1.seleniumIdeTheLoadedSteps)(steps);
|
|
23
|
-
const storeDefaultUrl = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('store');
|
|
24
|
-
if (this.journey.url) {
|
|
25
|
-
storeDefaultUrl.target = this.journey.url;
|
|
26
|
-
selIdeConfig.url = this.journey.url;
|
|
27
|
-
}
|
|
28
|
-
storeDefaultUrl.value = 'web.defaults.url';
|
|
29
|
-
selIdeTest.commands.unshift(storeDefaultUrl);
|
|
30
|
-
selIdeConfig.version = '2.0';
|
|
31
|
-
selIdeConfig.name = selIdeTest.name;
|
|
32
|
-
selIdeConfig.tests = [selIdeTest];
|
|
33
|
-
selIdeConfig.suites = [
|
|
34
|
-
{
|
|
35
|
-
id: (0, SeleniumIdeStep_1.generateIdForSeleniumEntity)(this.journey.id + 'suite'),
|
|
36
|
-
name: this.journey.name,
|
|
37
|
-
persistSession: false,
|
|
38
|
-
parallel: false,
|
|
39
|
-
timeout: 300,
|
|
40
|
-
tests: [selIdeTest.id],
|
|
41
|
-
},
|
|
42
|
-
];
|
|
43
|
-
selIdeConfig.id = (0, SeleniumIdeStep_1.generateIdForSeleniumEntity)(this.journey.id + 'config');
|
|
44
|
-
return selIdeConfig;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
exports.SelIdeConfig = SelIdeConfig;
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.JourneyConfig = void 0;
|
|
4
|
-
const flowConfigGenerator_1 = require("./flowConfigGenerator");
|
|
5
|
-
class JourneyConfig {
|
|
6
|
-
constructor(journey, flows, includeLocatorInfo) {
|
|
7
|
-
this.journey = journey;
|
|
8
|
-
this.flows = flows;
|
|
9
|
-
this.includeLocatorInfo = includeLocatorInfo;
|
|
10
|
-
}
|
|
11
|
-
generateConfigFile() {
|
|
12
|
-
var _a;
|
|
13
|
-
const journeyConfig = {};
|
|
14
|
-
journeyConfig.configVersion = 1;
|
|
15
|
-
journeyConfig.journeyId = this.journey.id;
|
|
16
|
-
journeyConfig.journeyVersion = this.journey.version;
|
|
17
|
-
journeyConfig.workspaceId = this.journey.organization_id;
|
|
18
|
-
journeyConfig.name = this.journey.name;
|
|
19
|
-
journeyConfig.description = this.journey.description;
|
|
20
|
-
journeyConfig.tags = this.journey.tags;
|
|
21
|
-
journeyConfig.labels = (_a = this.journey.labels) === null || _a === void 0 ? void 0 : _a.map((label) => label.name);
|
|
22
|
-
journeyConfig.dataTables = this.journey.datatables;
|
|
23
|
-
journeyConfig.flows = this.flows.map((flow) => {
|
|
24
|
-
const flowConfigGenerator = new flowConfigGenerator_1.FlowConfig(flow, this.includeLocatorInfo);
|
|
25
|
-
return flowConfigGenerator.generateConfigFile();
|
|
26
|
-
});
|
|
27
|
-
convertUndefined(journeyConfig);
|
|
28
|
-
return journeyConfig;
|
|
29
|
-
}
|
|
30
|
-
generateSimpleFormat() {
|
|
31
|
-
const config = this.generateConfigFile();
|
|
32
|
-
let steps = [];
|
|
33
|
-
let apiSteps;
|
|
34
|
-
config.flows.forEach((flow) => {
|
|
35
|
-
if (flow.api_steps) {
|
|
36
|
-
apiSteps = flow.api_steps;
|
|
37
|
-
}
|
|
38
|
-
steps = steps.concat(flowConfigGenerator_1.FlowConfig.generateStepsSimpleFormat(flow.steps));
|
|
39
|
-
});
|
|
40
|
-
const output = {
|
|
41
|
-
id: this.journey.id,
|
|
42
|
-
name: this.journey.name,
|
|
43
|
-
description: this.journey.description || '',
|
|
44
|
-
steps,
|
|
45
|
-
};
|
|
46
|
-
if (apiSteps) {
|
|
47
|
-
output.api_steps = apiSteps;
|
|
48
|
-
}
|
|
49
|
-
return output;
|
|
50
|
-
}
|
|
51
|
-
generateSimpleCsv() {
|
|
52
|
-
const config = this.generateConfigFile();
|
|
53
|
-
const output = [
|
|
54
|
-
' ,Step Number, Step Type, Description, Annotation, Note',
|
|
55
|
-
];
|
|
56
|
-
let count = 0;
|
|
57
|
-
config.flows.forEach((flow) => {
|
|
58
|
-
flow.steps.forEach((step) => {
|
|
59
|
-
var _a, _b;
|
|
60
|
-
const stepName = Object.keys(step)[0];
|
|
61
|
-
const stepObj = step;
|
|
62
|
-
const mablStep = stepObj[stepName];
|
|
63
|
-
output.push(`${count}, ${stepName}, ${mablStep.description}, ${((_a = mablStep === null || mablStep === void 0 ? void 0 : mablStep.annotation) === null || _a === void 0 ? void 0 : _a.note) || '-'}, ${((_b = mablStep === null || mablStep === void 0 ? void 0 : mablStep.annotation) === null || _b === void 0 ? void 0 : _b.description) || '-'}`);
|
|
64
|
-
count += 1;
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
return output;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
exports.JourneyConfig = JourneyConfig;
|
|
71
|
-
function convertUndefined(mablObjectConfigFile) {
|
|
72
|
-
Object.keys(mablObjectConfigFile).forEach((key) => {
|
|
73
|
-
if (mablObjectConfigFile[key] === undefined) {
|
|
74
|
-
mablObjectConfigFile[key] = null;
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateIdForSeleniumEntity = exports.buildSeleniumIdeStep = void 0;
|
|
4
|
-
const crypto = require('crypto');
|
|
5
|
-
function buildSeleniumIdeStep(commandName, mablscriptStep) {
|
|
6
|
-
let description = '';
|
|
7
|
-
if (mablscriptStep === null || mablscriptStep === void 0 ? void 0 : mablscriptStep.description) {
|
|
8
|
-
description = mablscriptStep.description;
|
|
9
|
-
}
|
|
10
|
-
else if (mablscriptStep === null || mablscriptStep === void 0 ? void 0 : mablscriptStep.annotation) {
|
|
11
|
-
description =
|
|
12
|
-
mablscriptStep.annotation.note || mablscriptStep.annotation.description;
|
|
13
|
-
}
|
|
14
|
-
const finalStep = {
|
|
15
|
-
id: '',
|
|
16
|
-
comment: description,
|
|
17
|
-
command: commandName,
|
|
18
|
-
target: '',
|
|
19
|
-
targets: [],
|
|
20
|
-
value: '',
|
|
21
|
-
};
|
|
22
|
-
finalStep.id = generateIdForSeleniumEntity(JSON.stringify(finalStep));
|
|
23
|
-
return finalStep;
|
|
24
|
-
}
|
|
25
|
-
exports.buildSeleniumIdeStep = buildSeleniumIdeStep;
|
|
26
|
-
function generateIdForSeleniumEntity(genValue) {
|
|
27
|
-
return crypto
|
|
28
|
-
.createHash('md5')
|
|
29
|
-
.update(JSON.stringify(genValue))
|
|
30
|
-
.digest('hex');
|
|
31
|
-
}
|
|
32
|
-
exports.generateIdForSeleniumEntity = generateIdForSeleniumEntity;
|