@mablhq/mabl-cli 1.45.1 → 1.47.12
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 +6 -0
- package/api/featureSet.js +0 -4
- package/api/mablApiClient.js +8 -0
- package/browserEngines/browserEngine.js +40 -0
- package/browserEngines/browserEngines.js +14 -0
- package/browserEngines/chromiumBrowserEngine.js +176 -0
- package/browserEngines/firefoxBrowserEngine.js +84 -0
- package/browserEngines/unsupportedBrowserEngine.js +27 -0
- package/browserLauncher/frameBase.js +5 -1
- package/browserLauncher/pageEvent.js +1 -0
- package/browserLauncher/playwrightBrowserLauncher/browserDelegate.js +2 -0
- package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumBrowserDelegate.js +55 -0
- package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumElementHandleDelegate.js +62 -0
- package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumFrameDelegate.js +12 -0
- package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumPageDelegate.js +117 -0
- package/browserLauncher/playwrightBrowserLauncher/elementHandleDelegate.js +2 -0
- package/browserLauncher/playwrightBrowserLauncher/firefox/firefoxBrowserDelegate.js +51 -0
- package/browserLauncher/playwrightBrowserLauncher/firefox/firefoxElementHandleDelegate.js +61 -0
- package/browserLauncher/playwrightBrowserLauncher/firefox/firefoxFrameDelegate.js +23 -0
- package/browserLauncher/playwrightBrowserLauncher/firefox/firefoxPageDelegate.js +83 -0
- package/browserLauncher/playwrightBrowserLauncher/frameDelegate.js +2 -0
- package/browserLauncher/playwrightBrowserLauncher/pageDelegate.js +2 -0
- package/browserLauncher/playwrightBrowserLauncher/playwrightBrowser.js +41 -35
- package/browserLauncher/playwrightBrowserLauncher/playwrightBrowserLauncher.js +28 -3
- package/browserLauncher/playwrightBrowserLauncher/playwrightDom.js +32 -63
- package/browserLauncher/playwrightBrowserLauncher/playwrightFrame.js +35 -11
- package/browserLauncher/playwrightBrowserLauncher/playwrightHttpRequest.js +1 -25
- package/browserLauncher/playwrightBrowserLauncher/playwrightPage.js +28 -50
- package/commands/constants.js +6 -1
- package/commands/tests/testsUtil.js +14 -153
- package/commands/tests/tests_cmds/import.js +2 -2
- package/commands/tests/tests_cmds/run.js +35 -10
- package/commands/workspaces/workspace_cmds/copy.js +1 -2
- package/core/messaging/messaging.js +15 -1
- package/domUtil/index.js +1 -1
- package/execution/index.js +1 -1
- package/functions/apiTest/utils.js +47 -0
- package/functions/types.js +2 -0
- package/functions/utils.js +12 -0
- package/http/requestInterceptor.js +23 -8
- package/mablApi/index.js +1 -1
- package/mablscript/types/VariableNamespace.js +3 -3
- package/mablscriptFind/index.js +1 -1
- package/package.json +4 -3
- package/popupDismissal/index.js +7 -20
- package/resources/mablFind.js +1 -1
- package/resources/popupDismissal.js +1 -1
- package/util/actionabilityUtil.js +4 -4
- package/util/clickUtil.js +2 -2
- package/util/fileUploadUtil.js +1 -1
- package/util/jestUtil.js +21 -0
- package/util/pureUtil.js +8 -1
- package/mablscript/types/VariableDataType.js +0 -28
|
@@ -0,0 +1,47 @@
|
|
|
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.validateApiTestMessage = exports.createFileUploadDirectory = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const Globals_1 = require("../../Globals");
|
|
9
|
+
const mablApi_1 = require("../../mablApi");
|
|
10
|
+
const utils_1 = require("../utils");
|
|
11
|
+
function createFileUploadDirectory(testContext) {
|
|
12
|
+
const dir = Globals_1.Globals.getUploadDirectory();
|
|
13
|
+
const prefix = Globals_1.Globals.getUploadDirectoryPrefix();
|
|
14
|
+
const uploadDirectoryName = `${dir}/${prefix}${Date.now()}-`;
|
|
15
|
+
testContext.addFileUploadDir(uploadDirectoryName);
|
|
16
|
+
return fs_1.default.mkdtempSync(uploadDirectoryName);
|
|
17
|
+
}
|
|
18
|
+
exports.createFileUploadDirectory = createFileUploadDirectory;
|
|
19
|
+
function validateApiTestMessage(request, response) {
|
|
20
|
+
var _a, _b, _c;
|
|
21
|
+
const authorizationHeader = request.get('authorization');
|
|
22
|
+
if (authorizationHeader === undefined) {
|
|
23
|
+
(0, utils_1.handleExecutionFailure)(response, 'Illegal authorization');
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
const contentType = request.get('content-type');
|
|
27
|
+
if ((contentType === null || contentType === void 0 ? void 0 : contentType.toLowerCase()) !== 'application/json') {
|
|
28
|
+
(0, utils_1.handleExecutionFailure)(response, 'Illegal content type. Must be application/json');
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
const pubsubMessage = request.body;
|
|
32
|
+
if (typeof ((_a = pubsubMessage === null || pubsubMessage === void 0 ? void 0 : pubsubMessage.message) === null || _a === void 0 ? void 0 : _a.data) !== 'string') {
|
|
33
|
+
(0, utils_1.handleExecutionFailure)(response, 'Illegal message data format');
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
if (typeof (pubsubMessage === null || pubsubMessage === void 0 ? void 0 : pubsubMessage.subscription) !== 'string') {
|
|
37
|
+
(0, utils_1.handleExecutionFailure)(response, 'Illegal message subscription format');
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
if (((_c = (_b = pubsubMessage === null || pubsubMessage === void 0 ? void 0 : pubsubMessage.message) === null || _b === void 0 ? void 0 : _b.attributes) === null || _c === void 0 ? void 0 : _c.test_type) !==
|
|
41
|
+
mablApi_1.Journey.TestTypeEnum.Api.toString()) {
|
|
42
|
+
(0, utils_1.handleExecutionFailure)(response, 'Illegal test type');
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
exports.validateApiTestMessage = validateApiTestMessage;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleExecutionFailure = exports.base64Decode = void 0;
|
|
4
|
+
function base64Decode(encoded) {
|
|
5
|
+
return Buffer.from(encoded, 'base64').toString();
|
|
6
|
+
}
|
|
7
|
+
exports.base64Decode = base64Decode;
|
|
8
|
+
function handleExecutionFailure(response, message) {
|
|
9
|
+
console.error(new Error(message));
|
|
10
|
+
response.status(200).send(message);
|
|
11
|
+
}
|
|
12
|
+
exports.handleExecutionFailure = handleExecutionFailure;
|
|
@@ -3,12 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.RequestInterceptor = exports.headerStringToProtocol = exports.headerStringToHeaders = void 0;
|
|
6
|
+
exports.RequestInterceptor = exports.headerStringToProtocol = exports.headerStringToHeaders = exports.MAX_SERIALIZED_BODY_SIZE_BYTES = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
const loggingProvider_1 = require("../providers/logging/loggingProvider");
|
|
9
9
|
const uuid_1 = require("uuid");
|
|
10
10
|
const httpUtil_1 = require("./httpUtil");
|
|
11
|
-
const
|
|
11
|
+
const pureUtil_1 = require("../util/pureUtil");
|
|
12
|
+
exports.MAX_SERIALIZED_BODY_SIZE_BYTES = 1024 * 1024;
|
|
12
13
|
const HEADER_EXTRACT_REGEXP = /^(?<rawKey>[^:]+)(:)(?<value>.*)$/;
|
|
13
14
|
function headerStringToHeaders(rawHeader) {
|
|
14
15
|
const headers = {};
|
|
@@ -52,20 +53,31 @@ function handleRawResponseBody(body) {
|
|
|
52
53
|
body = body !== null && body !== void 0 ? body : '';
|
|
53
54
|
switch (typeof body) {
|
|
54
55
|
case 'number':
|
|
56
|
+
return { body: body.toString(), responseSize: 8 };
|
|
55
57
|
case 'boolean':
|
|
56
|
-
return body.toString();
|
|
58
|
+
return { body: body.toString(), responseSize: 4 };
|
|
57
59
|
case 'string':
|
|
58
|
-
return
|
|
60
|
+
return {
|
|
61
|
+
body: body.substring(0, exports.MAX_SERIALIZED_BODY_SIZE_BYTES),
|
|
62
|
+
responseSize: body.length,
|
|
63
|
+
};
|
|
59
64
|
case 'object':
|
|
60
65
|
const serializedBody = JSON.stringify(body);
|
|
61
|
-
if (serializedBody.length <= MAX_SERIALIZED_BODY_SIZE_BYTES) {
|
|
62
|
-
return body;
|
|
66
|
+
if (serializedBody.length <= exports.MAX_SERIALIZED_BODY_SIZE_BYTES) {
|
|
67
|
+
return { body, responseSize: serializedBody.length };
|
|
63
68
|
}
|
|
64
|
-
return
|
|
69
|
+
return {
|
|
70
|
+
body: serializedBody.substring(0, exports.MAX_SERIALIZED_BODY_SIZE_BYTES),
|
|
71
|
+
responseSize: serializedBody.length,
|
|
72
|
+
};
|
|
65
73
|
default:
|
|
66
74
|
throw new Error(`Unhandled request intercept body type: [${typeof body}]`);
|
|
67
75
|
}
|
|
68
76
|
}
|
|
77
|
+
function getContentLength(headers) {
|
|
78
|
+
const contentLengthAsString = (0, pureUtil_1.getCaseInsensitiveProperty)(headers, 'content-length');
|
|
79
|
+
return contentLengthAsString ? Number(contentLengthAsString) : undefined;
|
|
80
|
+
}
|
|
69
81
|
class RequestInterceptor {
|
|
70
82
|
constructor() {
|
|
71
83
|
this.interceptedRequests = [];
|
|
@@ -132,11 +144,14 @@ class RequestInterceptor {
|
|
|
132
144
|
? headerStringToProtocol(request._header)
|
|
133
145
|
: '<Unknown protocol>';
|
|
134
146
|
}
|
|
147
|
+
const { body, responseSize } = handleRawResponseBody(response.data);
|
|
148
|
+
const contentLength = getContentLength(response.headers);
|
|
135
149
|
chainEntry.response = {
|
|
136
150
|
headers: headerRecordToHeaderMultiMap(response.headers),
|
|
137
151
|
status: response.status,
|
|
138
152
|
response_received_time: responseReceivedTime,
|
|
139
|
-
|
|
153
|
+
response_size: contentLength !== null && contentLength !== void 0 ? contentLength : responseSize,
|
|
154
|
+
body,
|
|
140
155
|
};
|
|
141
156
|
}
|
|
142
157
|
catch (e) {
|