@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.
@@ -1 +1 @@
1
- window.popupDismissal=function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";n.r(e),n.d(e,"elementsByHigherZIndex",(function(){return i})),n.d(e,"elementsAtCoordinate",(function(){return d})),n.d(e,"getAllElementsAbove",(function(){return h})),n.d(e,"detectAndDismissPopupCandidates",(function(){return g})),n.d(e,"elementsInFrontCount",(function(){return p}));const r=["close","dismiss","exit","not at this time","no thanks","no, thanks","i, agree","i agree"],o=[{attributeName:"className",matchFunction:a},{attributeName:"name",matchFunction:a},{attributeName:"id",matchFunction:a},{attributeName:"href",matchFunction:a},{attributeName:"innerText",matchFunction:function(t,e){const n=new RegExp(`\\b${e}\\b`);return!!t.toLowerCase().match(n)}}];function i(t){return Array.from(document.querySelectorAll("body *")).reduce((e,n)=>{const r=parseFloat(window.getComputedStyle(n).zIndex);return!Number.isNaN(r)&&r>=t&&(e.has(r)?e.get(r).push(n):e.set(r,[n])),e},new Map)}function u(t){const e=t=>void 0===t||"html"===t.tagName.toLowerCase();let n=t;for(;!e(n);){const t=window.getComputedStyle(n).zIndex;if(t&&"auto"!==t)return parseInt(t,10);n=(null==n?void 0:n.parentElement)?n.parentElement:void 0}return 0}function s(t){let e=[t];return Array.from(t.children).forEach(t=>{e=e.concat(s(t))}),e}function a(t,e){return t.toLowerCase().includes(e)}function c(t){const e=[];return t.forEach(t=>{const n=[],i=[];t.elements.forEach(t=>{var e;(null==t?void 0:t.offsetParent)&&(["BUTTON","A","DIV"].includes(null===(e=t.tagName)||void 0===e?void 0:e.toUpperCase())&&function(t){let e=0;return o.forEach(n=>{r.forEach(r=>{t.getAttribute(n.attributeName)&&n.matchFunction(t.getAttribute(n.attributeName),r)&&(e+=1)})}),e}(t)&&!i.includes(t)?i.push(t):function(t){if(t.getBoundingClientRect){const e=t.getBoundingClientRect(),n=e.width/window.innerWidth,r=e.height/window.innerHeight;return n>.95&&r>.95}return!1}(t)&&n.push(t))}),e.push({zIndex:t.zIndex,actionableElements:i,domCovering:n,dismissedStatus:!1,elementsInFront:0})}),e}function l(t,e){const n=t.getBoundingClientRect(),r=n.height/2,o=e?1:n.width/2,i=new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window,detail:0,screenX:n.left+o,screenY:n.top+r,clientX:t.clientLeft+o,clientY:t.clientTop+r,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,button:0,relatedTarget:void 0});t.dispatchEvent(i)}function d(t,e,n){const r=void 0!==e?e:m(t).x,o=void 0!==n?n:m(t).y,i=document.elementsFromPoint(r,o),u=i.findIndex(e=>e===t);return u?i.slice(0,u):[]}function f(t){return new Promise(e=>setTimeout(e,t))}function m(t){const e=t.getBoundingClientRect();return{x:Math.floor(e.x),y:Math.floor(e.y),top:Math.floor(e.top),bottom:Math.ceil(e.bottom),left:Math.floor(e.left),right:Math.ceil(e.right),height:Math.floor(e.bottom)-Math.ceil(e.top),width:Math.floor(e.right)-Math.ceil(e.left)}}function h(t,e){if(0===e.length)return[];const n=u(t),r=Math.min(...null==e?void 0:e.map(t=>u(t)));if(r<=n)return[];const o=i(r),a=Array.from(o).map(([t,e])=>({zIndex:t,elements:e.flatMap(s).reverse()}));return a.sort((t,e)=>e.zIndex-t.zIndex),a}async function g(t){const e=m(t);try{let n=d(t,e.x,e.y);const r=n.length;if(0===r)return{elementsInFront:0,dismissedStatus:!1};const o=async function(n,o){for(const i of n)if(l(i,o),await f(750),d(t,e.x,e.y).length<r)return!0;return!1};let i=h(t,n);const u=c(i);for(const t of u){let e=await o(t.domCovering,!0);if(e||(e=await o(t.actionableElements,!1)),e)return{dismissedStatus:!0,elementsInFront:0}}n=d(t,e.x,e.y),i=h(t,n);const s=c(i),a=s.length?s[0]:{zIndex:0,elementsInFront:0,dismissedStatus:!1,domCovering:[],actionableElements:[]};return a.elementsInFront=n.length,a.dismissedStatus=!1,{dismissedStatus:a.dismissedStatus,elementsInFront:a.elementsInFront}}catch(t){return{elementsInFront:0,dismissedStatus:!1,error:t.toString()}}}function p(t){return d(t).length}}]);
1
+ window.popupDismissal=function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";n.r(e),n.d(e,"elementsByHigherZIndex",(function(){return i})),n.d(e,"fireDoubleClickEvent",(function(){return d})),n.d(e,"fireClickEvent",(function(){return f})),n.d(e,"elementsAtCoordinate",(function(){return m})),n.d(e,"getAllElementsAbove",(function(){return p})),n.d(e,"detectAndDismissPopupCandidates",(function(){return b})),n.d(e,"elementsInFrontCount",(function(){return y}));const r=["close","dismiss","exit","not at this time","no thanks","no, thanks","i, agree","i agree"],o=[{attributeName:"className",matchFunction:s},{attributeName:"name",matchFunction:s},{attributeName:"id",matchFunction:s},{attributeName:"href",matchFunction:s},{attributeName:"innerText",matchFunction:function(t,e){const n=new RegExp(`\\b${e}\\b`);return!!t.toLowerCase().match(n)}}];function i(t){return Array.from(document.querySelectorAll("body *")).reduce((e,n)=>{const r=parseFloat(window.getComputedStyle(n).zIndex);return!Number.isNaN(r)&&r>=t&&(e.has(r)?e.get(r).push(n):e.set(r,[n])),e},new Map)}function u(t){const e=t=>void 0===t||"html"===t.tagName.toLowerCase();let n=t;for(;!e(n);){const t=window.getComputedStyle(n).zIndex;if(t&&"auto"!==t)return parseInt(t,10);n=(null==n?void 0:n.parentElement)?n.parentElement:void 0}return 0}function c(t){let e=[t];return Array.from(t.children).forEach(t=>{e=e.concat(c(t))}),e}function s(t,e){return t.toLowerCase().includes(e)}function a(t){const e=[];return t.forEach(t=>{const n=[],i=[];t.elements.forEach(t=>{var e;(null==t?void 0:t.offsetParent)&&(["BUTTON","A","DIV"].includes(null===(e=t.tagName)||void 0===e?void 0:e.toUpperCase())&&function(t){let e=0;return o.forEach(n=>{r.forEach(r=>{t.getAttribute(n.attributeName)&&n.matchFunction(t.getAttribute(n.attributeName),r)&&(e+=1)})}),e}(t)&&!i.includes(t)?i.push(t):function(t){if(t.getBoundingClientRect){const e=t.getBoundingClientRect(),n=e.width/window.innerWidth,r=e.height/window.innerHeight;return n>.95&&r>.95}return!1}(t)&&n.push(t))}),e.push({zIndex:t.zIndex,actionableElements:i,domCovering:n,dismissedStatus:!1,elementsInFront:0})}),e}function l(t,e,n=!1){const r=t.getBoundingClientRect(),o=r.height/2,i=n?1:r.width/2,u=new MouseEvent(e,{bubbles:!0,cancelable:!0,view:window,detail:0,screenX:r.left+i,screenY:r.top+o,clientX:t.clientLeft+i,clientY:t.clientTop+o,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,button:0,relatedTarget:void 0});t.dispatchEvent(u)}function d(t){f(t,!1),f(t,!1),l(t,"dblclick")}function f(t,e=!1){l(t,"click",e)}function m(t,e,n){const r=void 0!==e?e:g(t).x,o=void 0!==n?n:g(t).y,i=document.elementsFromPoint(r,o),u=i.findIndex(e=>e===t);return u?i.slice(0,u):[]}function h(t){return new Promise(e=>setTimeout(e,t))}function g(t){const e=t.getBoundingClientRect();return{x:Math.floor(e.x),y:Math.floor(e.y),top:Math.floor(e.top),bottom:Math.ceil(e.bottom),left:Math.floor(e.left),right:Math.ceil(e.right),height:Math.floor(e.bottom)-Math.ceil(e.top),width:Math.floor(e.right)-Math.ceil(e.left)}}function p(t,e){if(0===e.length)return[];const n=u(t),r=Math.min(...null==e?void 0:e.map(t=>u(t)));if(r<=n)return[];const o=i(r),s=Array.from(o).map(([t,e])=>({zIndex:t,elements:e.flatMap(c).reverse()}));return s.sort((t,e)=>e.zIndex-t.zIndex),s}async function b(t){const e=g(t);try{let n=m(t,e.x,e.y);const r=n.length;if(0===r)return{elementsInFront:0,dismissedStatus:!1};const o=async function(n,o){for(const i of n)if(f(i,o),await h(750),m(t,e.x,e.y).length<r)return!0;return!1};let i=p(t,n);const u=a(i);for(const t of u){let e=await o(t.domCovering,!0);if(e||(e=await o(t.actionableElements,!1)),e)return{dismissedStatus:!0,elementsInFront:0}}n=m(t,e.x,e.y),i=p(t,n);const c=a(i),s=c.length?c[0]:{zIndex:0,elementsInFront:0,dismissedStatus:!1,domCovering:[],actionableElements:[]};return s.elementsInFront=n.length,s.dismissedStatus=!1,{dismissedStatus:s.dismissedStatus,elementsInFront:s.elementsInFront}}catch(t){return{elementsInFront:0,dismissedStatus:!1,error:t.toString()}}}function y(t){return m(t).length}}]);
@@ -43,7 +43,7 @@ async function checkPopupDismissalOnAction(elementHandle, action, executionConte
43
43
  if (error.message.includes(POPUP_ERROR_MESSAGE_HINT)) {
44
44
  const hasPopup = await isElementWithPopup(elementHandle);
45
45
  if (hasPopup) {
46
- return;
46
+ return true;
47
47
  }
48
48
  const dismissalResult = await attemptPopupDismissal(elementHandle, executionContext);
49
49
  if (recheckOnFail) {
@@ -55,8 +55,10 @@ async function checkPopupDismissalOnAction(elementHandle, action, executionConte
55
55
  });
56
56
  (0, logUtils_1.logInternal)(`Found element might not be actionable. ${error.toString()}`);
57
57
  }
58
+ return dismissalResult;
58
59
  }
59
60
  }
61
+ return true;
60
62
  }
61
63
  exports.checkPopupDismissalOnAction = checkPopupDismissalOnAction;
62
64
  async function checkActionabilityAt(elementHandle, executionContext, recheckOnFail = true) {
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.removeUploadDirs = exports.cleanupOldFiles = exports.downloadFileUpload = void 0;
30
+ const axios_1 = __importDefault(require("axios"));
31
+ const httpUtil_1 = require("./httpUtil");
32
+ const path_1 = __importDefault(require("path"));
33
+ const fs = __importStar(require("fs-extra"));
34
+ const stream_1 = require("stream");
35
+ const loggingProvider_1 = require("../providers/logging/loggingProvider");
36
+ const chalk_1 = __importDefault(require("chalk"));
37
+ const Globals_1 = require("../Globals");
38
+ const logUtils_1 = require("./logUtils");
39
+ async function downloadFileUpload(fileUploadUrl, fileUpload, downloadDirectory, mablApiClient) {
40
+ let client;
41
+ if (mablApiClient) {
42
+ client = mablApiClient.httpClient;
43
+ }
44
+ else {
45
+ client = axios_1.default.create(await (0, httpUtil_1.currentProxyConfig)());
46
+ }
47
+ try {
48
+ const finalDirectory = path_1.default.normalize(`${downloadDirectory}/${fileUpload.id}`);
49
+ try {
50
+ fs.mkdirSync(finalDirectory);
51
+ }
52
+ catch (error) {
53
+ if (!error.message.includes('file already exists')) {
54
+ throw error;
55
+ }
56
+ }
57
+ const finalPath = path_1.default.normalize(`${finalDirectory}/${fileUpload.name}`);
58
+ const writer = fs.createWriteStream(finalPath);
59
+ const response = await client.get(fileUploadUrl, {
60
+ responseType: 'stream',
61
+ });
62
+ if (response.data.pipe) {
63
+ response.data.pipe(writer);
64
+ }
65
+ else if (!(response.status >= 400)) {
66
+ stream_1.Readable.from(response.data).pipe(writer);
67
+ }
68
+ return new Promise((resolve, reject) => {
69
+ writer.on('finish', () => resolve(finalPath));
70
+ writer.on('error', reject);
71
+ });
72
+ }
73
+ catch (error) {
74
+ loggingProvider_1.logger.error(chalk_1.default.red.bold('Error encountered downloading file for File Upload Step replay'));
75
+ throw error;
76
+ }
77
+ }
78
+ exports.downloadFileUpload = downloadFileUpload;
79
+ function cleanupOldFiles(ageInMs) {
80
+ try {
81
+ const dir = Globals_1.Globals.getUploadDirectory();
82
+ const prefix = Globals_1.Globals.getUploadDirectoryPrefix();
83
+ fs.readdirSync(dir)
84
+ .filter((file) => file.startsWith(prefix) && uploadDirTooOld(file, ageInMs))
85
+ .forEach((file) => fs.rmSync(`${dir}/${file}`, { recursive: true, force: true }));
86
+ }
87
+ catch (e) {
88
+ const msg = `WARNING: error received when cleaning up old files from a previous test`;
89
+ (0, logUtils_1.logCliOutput)(loggingProvider_1.LogLevel.Warn, msg);
90
+ }
91
+ }
92
+ exports.cleanupOldFiles = cleanupOldFiles;
93
+ function uploadDirTooOld(dirFullPath, ageInMs) {
94
+ const now = Date.now();
95
+ const parts = dirFullPath.split('-');
96
+ return (parts.length === 3 &&
97
+ !Number.isNaN(parseInt(parts[1])) &&
98
+ (ageInMs === 0 || now - parseInt(parts[1]) > ageInMs));
99
+ }
100
+ function removeUploadDirs(dirFullPath) {
101
+ const MAX_RETRIES = 5;
102
+ const rmOpts = {
103
+ recursive: true,
104
+ maxRetries: MAX_RETRIES,
105
+ force: true,
106
+ };
107
+ fs.rmSync(dirFullPath, rmOpts);
108
+ }
109
+ exports.removeUploadDirs = removeUploadDirs;