@mablhq/mabl-cli 1.29.19 → 1.32.2

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.
@@ -9,9 +9,7 @@ class VisitUrlStep extends MablStep_1.MablStep {
9
9
  constructor(name, args, actions) {
10
10
  super(name, args, actions);
11
11
  const arg = this.getActionArgs()[0];
12
- this.url = VisitUrlStep.isInProduction()
13
- ? VisitUrlStep.normalizeUrlCloudSafe(arg)
14
- : VisitUrlStep.normalizeUrlWithFileAccess(arg);
12
+ this.url = VisitUrlStep.normalizeUrl(arg);
15
13
  }
16
14
  getStepName() {
17
15
  return 'VisitUrl';
@@ -31,7 +29,7 @@ class VisitUrlStep extends MablStep_1.MablStep {
31
29
  }
32
30
  toMablscript() {
33
31
  const resolvedUrl = this.substituteMablscriptVariable((0, domUtil_1.escapeMablscriptString)(this.url.toString()));
34
- if (VisitUrlStep.isInProduction() && VisitUrlStep.isFileUrl(resolvedUrl)) {
32
+ if (VisitUrlStep.isFileUrl(resolvedUrl) && !VisitUrlStep.isTestOverride()) {
35
33
  throw new Error('Access to local files is not permitted');
36
34
  }
37
35
  return `visit_url(${resolvedUrl})`;
@@ -39,13 +37,7 @@ class VisitUrlStep extends MablStep_1.MablStep {
39
37
  getInputVariables() {
40
38
  return MablAction_1.MablAction.findUniqueVariableReferencesInValue(this.url);
41
39
  }
42
- static normalizeUrlCloudSafe(param) {
43
- return VisitUrlStep.normalizeUrl(param, true);
44
- }
45
- static normalizeUrlWithFileAccess(param) {
46
- return VisitUrlStep.normalizeUrl(param, false);
47
- }
48
- static normalizeUrl(param, cloudSafe) {
40
+ static normalizeUrl(param) {
49
41
  const trimmed = param.trim();
50
42
  if (param === '') {
51
43
  throw new Error('Missing URL');
@@ -60,19 +52,18 @@ class VisitUrlStep extends MablStep_1.MablStep {
60
52
  return trimmed;
61
53
  }
62
54
  if (VisitUrlStep.isFileUrl(trimmed)) {
63
- if (cloudSafe) {
64
- throw new Error('Access to local files is not permitted');
55
+ if (VisitUrlStep.isTestOverride()) {
56
+ return trimmed;
65
57
  }
66
- return trimmed;
58
+ throw new Error('Access to local files is not permitted');
67
59
  }
68
60
  return `http://${trimmed}`;
69
61
  }
70
- static isInProduction() {
71
- return (process.env.NODE_ENV === 'production' ||
72
- process.env.MABL_SIMULATION === 'prod');
62
+ static isTestOverride() {
63
+ return process.env.MABL_SIMULATION === 'mabl-local-testing';
73
64
  }
74
65
  static isFileUrl(param) {
75
- return /^file:\/\//.test(param) || /^\\\\/.test(param);
66
+ return (/^file:\/\//.test(param) || /^\\\\/.test(param) || /^\/+/.test(param));
76
67
  }
77
68
  }
78
69
  exports.VisitUrlStep = VisitUrlStep;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mablhq/mabl-cli",
3
- "version": "1.29.19",
3
+ "version": "1.32.2",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "The official mabl command line interface tool",
6
6
  "main": "index.js",
@@ -25,7 +25,8 @@
25
25
  "postinstall": "node ./util/postInstallMessage.js"
26
26
  },
27
27
  "dependencies": {
28
- "@playwright/test": "1.24.1",
28
+ "@mablhq/newman-reporter-mabl-console": "0.1.0",
29
+ "@playwright/test": "1.25.1",
29
30
  "@types/fs-extra": "8.1.1",
30
31
  "@types/serve-handler": "6.1.0",
31
32
  "@types/tmp": "0.2.0",
@@ -70,7 +71,7 @@
70
71
  "newman": "5.3.2",
71
72
  "open": "6.4.0",
72
73
  "ora": "4.0.4",
73
- "playwright-core": "1.24.1",
74
+ "playwright-core": "1.25.1",
74
75
  "pluralize": "8.0.0",
75
76
  "pngjs": "6.0.0",
76
77
  "portfinder": "1.0.28",
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.elementsInFrontCount = exports.detectAndDismissPopupCandidates = exports.getAllElementsAbove = exports.elementsAtCoordinate = exports.elementsByHigherZIndex = void 0;
3
+ exports.elementsInFrontCount = exports.detectAndDismissPopupCandidates = exports.getAllElementsAbove = exports.elementsAtCoordinate = exports.fireClickEvent = exports.fireDoubleClickEvent = exports.elementsByHigherZIndex = void 0;
4
4
  const DISMISSAL_WAIT_TIME_MS = 750;
5
5
  const ZINDEX_AUTO = 'auto';
6
6
  const MINIMUM_POPUP_DISPLAY_COVERAGE_PX = 0.95;
@@ -113,11 +113,11 @@ function developCloseCandidates(candidates) {
113
113
  });
114
114
  return candidatesByZIndex;
115
115
  }
116
- function fireClickEvent(targetElement, leftEdgeClick) {
116
+ function dispatchMouseEvent(targetElement, eventType, leftEdgeClick = false) {
117
117
  const boundingBox = targetElement.getBoundingClientRect();
118
118
  const halfHeight = boundingBox.height / 2;
119
119
  const xDistance = leftEdgeClick ? 1 : boundingBox.width / 2;
120
- const mouseEvent = new MouseEvent('click', {
120
+ const mouseEvent = new MouseEvent(eventType, {
121
121
  bubbles: true,
122
122
  cancelable: true,
123
123
  view: window,
@@ -135,6 +135,16 @@ function fireClickEvent(targetElement, leftEdgeClick) {
135
135
  });
136
136
  targetElement.dispatchEvent(mouseEvent);
137
137
  }
138
+ function fireDoubleClickEvent(targetElement) {
139
+ fireClickEvent(targetElement, false);
140
+ fireClickEvent(targetElement, false);
141
+ dispatchMouseEvent(targetElement, 'dblclick');
142
+ }
143
+ exports.fireDoubleClickEvent = fireDoubleClickEvent;
144
+ function fireClickEvent(targetElement, leftEdgeClick = false) {
145
+ dispatchMouseEvent(targetElement, 'click', leftEdgeClick);
146
+ }
147
+ exports.fireClickEvent = fireClickEvent;
138
148
  function elementsAtCoordinate(element, pointX, pointY) {
139
149
  const x = pointX !== undefined ? pointX : getBoundingClientRectWithXY(element).x;
140
150
  const y = pointY !== undefined ? pointY : getBoundingClientRectWithXY(element).y;
@@ -0,0 +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,i){this.PDFEmbeddedViewerBaseUrl=e,this.createElement=t||document.createElement,this.shouldHandle=n||(()=>!0),this.cMapUrl=i,this.handle=this.handle.bind(this),this.register=this.register.bind(this),this.updateElement=this.updateElement.bind(this),this.createViewerElement=this.createViewerElement.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;let t=e.target;"about:blank"!==t.src&&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=e.src||e.data;return t&&"application/pdf"===t.toLowerCase()||!t&&n&&/\.pdf($|[?#])/i.test(n)||!!e["__mabl-processed-pdf"]}canHandleEvent(e){const t=e.target;return this.shouldHandle(e)&&this.checkAnimationEvent(e)&&this.checkElement(t)&&this.checkMimeType(t)}updateElement(e){if("text/html"===e.type&&0===e.src.lastIndexOf(this.PDFEmbeddedViewerBaseUrl,0))return;let t=e.parentNode,n=e.nextSibling,i=this.createViewerElement(e);t&&(t.removeChild(e),t.insertBefore(i,n))}createViewerElement(e){let t=this.createElement.call(document,"iframe"),n=e.src||e.data||e.getAttribute("mabl-pdf-url");return"about:blank"===n&&(n=window.location.href),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,"_")}}