@mablhq/mabl-cli 1.40.12 → 1.42.7
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 +3 -2
- package/cli.js +0 -0
- package/commands/tests/tests_cmds/create.js +1 -1
- package/core/execution/ApiTestUtils.js +41 -1
- package/core/trainer/openUtils.js +2 -2
- package/core/trainer/trainingSessions-types.js +35 -0
- package/core/trainer/trainingSessions.js +52 -34
- package/execution/index.js +1 -1
- package/http/MablHttpAgent.js +73 -0
- package/http/RequestFilteringHttpAgent.js +119 -0
- package/http/RequestSecurityError.js +9 -0
- package/{util/httpUtil.js → http/axiosProxyConfig.js} +3 -6
- package/http/httpUtil.js +54 -0
- package/http/requestInterceptor.js +187 -0
- package/mablscript/MablAction.js +19 -1
- package/mablscript/MablStep.js +0 -17
- package/mablscript/actions/ConditionAction.js +7 -2
- package/mablscript/steps/AssertStep.js +24 -15
- package/mablscript/steps/IfConditionStep.js +8 -1
- package/mablscript/steps/ReleaseStep.js +2 -1
- package/mablscript/steps/SelectStep.js +1 -1
- package/mablscript/steps/SetFilesStep.js +2 -1
- package/mablscript/steps/SyntheticStep.js +1 -1
- package/package.json +3 -3
- package/providers/authenticationProvider.js +2 -2
- package/providers/cliConfigProvider.js +1 -1
- package/util/encodingUtil.js +37 -0
- package/util/fileUploadUtil.js +2 -2
package/api/basicApiClient.js
CHANGED
|
@@ -28,13 +28,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.BasicApiClient = void 0;
|
|
30
30
|
const ApiError_1 = require("./ApiError");
|
|
31
|
-
const
|
|
31
|
+
const axiosProxyConfig_1 = require("../http/axiosProxyConfig");
|
|
32
32
|
const axios_1 = __importDefault(require("axios"));
|
|
33
33
|
const os = __importStar(require("os"));
|
|
34
34
|
const async_retry_1 = __importDefault(require("async-retry"));
|
|
35
35
|
const logUtils_1 = require("../util/logUtils");
|
|
36
36
|
const asyncUtil_1 = require("../util/asyncUtil");
|
|
37
37
|
const types_1 = require("./types");
|
|
38
|
+
const httpUtil_1 = require("../http/httpUtil");
|
|
38
39
|
const MABL_ENTITY_VERSION_HEADER = 'x-mabl-entity-version';
|
|
39
40
|
const DEFAULT_RETRYABLE_REQUEST_TIMEOUT_MILLISECONDS = 60000;
|
|
40
41
|
const DEFAULT_RETRIES = 10;
|
|
@@ -55,7 +56,7 @@ const DEFAULT_SSL_VERIFY = false;
|
|
|
55
56
|
class BasicApiClient {
|
|
56
57
|
constructor(options) {
|
|
57
58
|
var _a, _b, _c, _d, _e;
|
|
58
|
-
const config = (0,
|
|
59
|
+
const config = (0, axiosProxyConfig_1.axiosProxyConfig)({
|
|
59
60
|
sslVerify: (_a = options.sslVerify) !== null && _a !== void 0 ? _a : DEFAULT_SSL_VERIFY,
|
|
60
61
|
proxyHost: options.proxyUrl,
|
|
61
62
|
proxyType: options.proxyType,
|
package/cli.js
CHANGED
|
File without changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deduplicateApiTestExecutionResults = void 0;
|
|
3
|
+
exports.restoreCustomRequestFields = exports.deduplicateApiTestExecutionResults = void 0;
|
|
4
4
|
function deduplicateApiTestExecutionResults(postmanResult) {
|
|
5
5
|
var _a;
|
|
6
6
|
const executionsById = {};
|
|
@@ -16,3 +16,43 @@ function deduplicateApiTestExecutionResults(postmanResult) {
|
|
|
16
16
|
return postmanResult;
|
|
17
17
|
}
|
|
18
18
|
exports.deduplicateApiTestExecutionResults = deduplicateApiTestExecutionResults;
|
|
19
|
+
function restoreCustomRequestFields(postmanResult, collection) {
|
|
20
|
+
const requestItemsById = collection.item.reduce((collectionSet, itemDefinition) => {
|
|
21
|
+
collectionSet[itemDefinition.id] = itemDefinition;
|
|
22
|
+
return collectionSet;
|
|
23
|
+
}, {});
|
|
24
|
+
postmanResult.run.executions.forEach((execution) => {
|
|
25
|
+
var _a;
|
|
26
|
+
const requestItemDefinition = requestItemsById[execution.id];
|
|
27
|
+
if (((_a = execution.request.body) === null || _a === void 0 ? void 0 : _a.mode) === 'formdata' &&
|
|
28
|
+
(requestItemDefinition === null || requestItemDefinition === void 0 ? void 0 : requestItemDefinition.request)) {
|
|
29
|
+
restoreFormDataFileMetadata(execution.request, requestItemDefinition.request);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
return postmanResult;
|
|
33
|
+
}
|
|
34
|
+
exports.restoreCustomRequestFields = restoreCustomRequestFields;
|
|
35
|
+
function restoreFormDataFileMetadata(resultRequest, collectionRequest) {
|
|
36
|
+
var _a, _b, _c, _d, _e;
|
|
37
|
+
if ((_a = resultRequest.body) === null || _a === void 0 ? void 0 : _a.formdata) {
|
|
38
|
+
const requestFormDataBySrc = (_c = (_b = collectionRequest === null || collectionRequest === void 0 ? void 0 : collectionRequest.body) === null || _b === void 0 ? void 0 : _b.formdata) === null || _c === void 0 ? void 0 : _c.reduce((set, formData) => {
|
|
39
|
+
if (formData.src) {
|
|
40
|
+
set[formData.src] = formData;
|
|
41
|
+
}
|
|
42
|
+
return set;
|
|
43
|
+
}, {});
|
|
44
|
+
if (!Array.isArray((_d = resultRequest.body) === null || _d === void 0 ? void 0 : _d.formdata)) {
|
|
45
|
+
resultRequest.body.formdata = resultRequest.body.formdata
|
|
46
|
+
.all()
|
|
47
|
+
.map((formParam) => formParam);
|
|
48
|
+
}
|
|
49
|
+
for (const resultFormParam of resultRequest.body.formdata) {
|
|
50
|
+
if (resultFormParam.type === 'file' &&
|
|
51
|
+
resultFormParam.src &&
|
|
52
|
+
!resultFormParam.mablFile) {
|
|
53
|
+
resultFormParam.mablFile =
|
|
54
|
+
(_e = requestFormDataBySrc[resultFormParam.src]) === null || _e === void 0 ? void 0 : _e.mablFile;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -4,14 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.logSessionStarted = exports.openUrlInDesktopApp = void 0;
|
|
7
|
-
const querystring_1 = __importDefault(require("querystring"));
|
|
8
7
|
const open_1 = __importDefault(require("open"));
|
|
9
8
|
const env_1 = require("../../env/env");
|
|
10
9
|
const timers_1 = require("timers");
|
|
11
10
|
const messaging_1 = require("../messaging/messaging");
|
|
12
11
|
const chalk_1 = __importDefault(require("chalk"));
|
|
12
|
+
const encodingUtil_1 = require("../../util/encodingUtil");
|
|
13
13
|
async function openUrlInDesktopApp(url, trainingSessionOptions) {
|
|
14
|
-
const params =
|
|
14
|
+
const params = (0, encodingUtil_1.encodeTestConfigAsParamsForParsedUrlProtocol)(trainingSessionOptions, encodingUtil_1.b64EncodeUnicodeInNode);
|
|
15
15
|
const childProcess = await (0, open_1.default)(`${env_1.ELECTRON_PROTOCOL}://${url}/${params}`);
|
|
16
16
|
let childProcessExited = false;
|
|
17
17
|
const keepAliveUntilExited = () => {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isEditTestPayloadFromCli = exports.isNewTestPayloadFromCli = exports.isEditTestPayloadFromDesktopApp = exports.isNewTestPayloadFromDesktopApp = exports.isEditTestPayloadFromWebApp = exports.isNewTestPayloadFromWebApp = exports.isPayloadFromCli = exports.isPayloadFromUi = void 0;
|
|
4
|
+
function isPayloadFromUi(payload) {
|
|
5
|
+
return payload.sender === 'webapp' || payload.sender === 'mabltron';
|
|
6
|
+
}
|
|
7
|
+
exports.isPayloadFromUi = isPayloadFromUi;
|
|
8
|
+
function isPayloadFromCli(payload) {
|
|
9
|
+
return payload.sender === 'cli' || !isPayloadFromUi(payload);
|
|
10
|
+
}
|
|
11
|
+
exports.isPayloadFromCli = isPayloadFromCli;
|
|
12
|
+
function isNewTestPayloadFromWebApp(payload) {
|
|
13
|
+
return payload.sender === 'webapp' && payload.testId === undefined;
|
|
14
|
+
}
|
|
15
|
+
exports.isNewTestPayloadFromWebApp = isNewTestPayloadFromWebApp;
|
|
16
|
+
function isEditTestPayloadFromWebApp(payload) {
|
|
17
|
+
return payload.sender === 'webapp' && payload.testId !== undefined;
|
|
18
|
+
}
|
|
19
|
+
exports.isEditTestPayloadFromWebApp = isEditTestPayloadFromWebApp;
|
|
20
|
+
function isNewTestPayloadFromDesktopApp(payload) {
|
|
21
|
+
return payload.sender === 'mabltron' && payload.testId === undefined;
|
|
22
|
+
}
|
|
23
|
+
exports.isNewTestPayloadFromDesktopApp = isNewTestPayloadFromDesktopApp;
|
|
24
|
+
function isEditTestPayloadFromDesktopApp(payload) {
|
|
25
|
+
return payload.sender === 'mabltron' && payload.testId !== undefined;
|
|
26
|
+
}
|
|
27
|
+
exports.isEditTestPayloadFromDesktopApp = isEditTestPayloadFromDesktopApp;
|
|
28
|
+
function isNewTestPayloadFromCli(payload) {
|
|
29
|
+
return isPayloadFromCli(payload) && payload.testName !== undefined;
|
|
30
|
+
}
|
|
31
|
+
exports.isNewTestPayloadFromCli = isNewTestPayloadFromCli;
|
|
32
|
+
function isEditTestPayloadFromCli(payload) {
|
|
33
|
+
return isPayloadFromCli(payload) && payload.testId !== undefined;
|
|
34
|
+
}
|
|
35
|
+
exports.isEditTestPayloadFromCli = isEditTestPayloadFromCli;
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.editTest = exports.trainNewTest = exports.ElectronProtocolUrl = void 0;
|
|
3
|
+
exports.editTest = exports.trainNewTest = exports.ElectronProtocolUrl = exports.SENDER = exports.DEFAULT_WIDTH = exports.DEFAULT_HEIGHT = void 0;
|
|
4
4
|
const branches_1 = require("../../commands/commandUtil/branches");
|
|
5
5
|
const testsUtil_1 = require("../../commands/tests/testsUtil");
|
|
6
|
+
const mablApi_1 = require("../../mablApi");
|
|
6
7
|
const constants_1 = require("../../commands/constants");
|
|
7
8
|
const util_1 = require("../util");
|
|
8
9
|
const openUtils_1 = require("./openUtils");
|
|
9
10
|
const util_2 = require("../../commands/commandUtil/util");
|
|
11
|
+
exports.DEFAULT_HEIGHT = 800;
|
|
12
|
+
exports.DEFAULT_WIDTH = 1000;
|
|
13
|
+
exports.SENDER = 'cli';
|
|
10
14
|
var ElectronProtocolUrl;
|
|
11
15
|
(function (ElectronProtocolUrl) {
|
|
12
16
|
ElectronProtocolUrl["EDIT_TEST"] = "editTest";
|
|
@@ -15,40 +19,47 @@ var ElectronProtocolUrl;
|
|
|
15
19
|
async function trainNewTest(trainingSessionOptions) {
|
|
16
20
|
var _a;
|
|
17
21
|
const apiClient = await (0, util_1.getApiClientFromOptions)(trainingSessionOptions, true);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
if (
|
|
22
|
-
await (0, branches_1.checkBranchNameAndAutoBranchMaybe)(
|
|
23
|
-
}
|
|
24
|
-
if (trainingSessionOptions.environmentId) {
|
|
25
|
-
await apiClient.getEnvironment(trainingSessionOptions.environmentId);
|
|
22
|
+
const branchName = (_a = trainingSessionOptions.branchName) !== null && _a !== void 0 ? _a : constants_1.DefaultBranchName;
|
|
23
|
+
const { authToken, autoBranch, ...passThroughFields } = trainingSessionOptions;
|
|
24
|
+
const { applicationId, autoLogin, credentialsId, dataTableIds, environmentId, height, planId, testDescription, testName, url, width, workspaceId, } = passThroughFields;
|
|
25
|
+
if (branchName !== 'master') {
|
|
26
|
+
await (0, branches_1.checkBranchNameAndAutoBranchMaybe)(workspaceId, apiClient, branchName, autoBranch);
|
|
26
27
|
}
|
|
27
|
-
if (
|
|
28
|
-
await apiClient.
|
|
28
|
+
if (environmentId) {
|
|
29
|
+
await apiClient.getEnvironment(environmentId);
|
|
29
30
|
}
|
|
30
|
-
if (
|
|
31
|
-
await apiClient.
|
|
31
|
+
if (planId) {
|
|
32
|
+
await apiClient.getPlan(planId);
|
|
32
33
|
}
|
|
33
|
-
if (
|
|
34
|
-
await apiClient.getApplication(
|
|
34
|
+
if (applicationId) {
|
|
35
|
+
await apiClient.getApplication(applicationId);
|
|
35
36
|
}
|
|
36
|
-
|
|
37
|
-
(0, testsUtil_1.logTestInfoIfPresent)(`
|
|
38
|
-
(0, testsUtil_1.logTestInfoIfPresent)(`
|
|
39
|
-
(0, testsUtil_1.logTestInfoIfPresent)(`
|
|
40
|
-
(0, testsUtil_1.logTestInfoIfPresent)(`
|
|
41
|
-
(0, testsUtil_1.logTestInfoIfPresent)(`
|
|
42
|
-
(0, testsUtil_1.logTestInfoIfPresent)(`
|
|
43
|
-
(0, testsUtil_1.logTestInfoIfPresent)(`
|
|
44
|
-
(0, testsUtil_1.logTestInfoIfPresent)(`
|
|
45
|
-
(0, testsUtil_1.logTestInfoIfPresent)(`
|
|
46
|
-
(0, testsUtil_1.logTestInfoIfPresent)(`
|
|
47
|
-
|
|
37
|
+
const account = await apiClient.getAccountByWorkspaceId(workspaceId);
|
|
38
|
+
(0, testsUtil_1.logTestInfoIfPresent)(`Creating test in desktop app: `, testName);
|
|
39
|
+
(0, testsUtil_1.logTestInfoIfPresent)(`Add auto login flow: `, autoLogin);
|
|
40
|
+
(0, testsUtil_1.logTestInfoIfPresent)(`URL: `, url);
|
|
41
|
+
(0, testsUtil_1.logTestInfoIfPresent)(`Workspace: `, workspaceId);
|
|
42
|
+
(0, testsUtil_1.logTestInfoIfPresent)(`Account ID: `, account.id);
|
|
43
|
+
(0, testsUtil_1.logTestInfoIfPresent)(`Branch: `, branchName);
|
|
44
|
+
(0, testsUtil_1.logTestInfoIfPresent)(`Plan ID: `, planId);
|
|
45
|
+
(0, testsUtil_1.logTestInfoIfPresent)(`Application ID: `, applicationId);
|
|
46
|
+
(0, testsUtil_1.logTestInfoIfPresent)(`Environment ID: `, environmentId);
|
|
47
|
+
(0, testsUtil_1.logTestInfoIfPresent)(`Credentials ID: `, credentialsId);
|
|
48
|
+
(0, testsUtil_1.logTestInfoIfPresent)(`Datatable ID(s): `, dataTableIds === null || dataTableIds === void 0 ? void 0 : dataTableIds.join(', '));
|
|
49
|
+
(0, testsUtil_1.logTestInfoIfPresent)(`Test description: `, testDescription);
|
|
50
|
+
const scriptConfig = {
|
|
51
|
+
...passThroughFields,
|
|
52
|
+
accountId: account.id,
|
|
53
|
+
branchName,
|
|
54
|
+
height: height !== null && height !== void 0 ? height : exports.DEFAULT_HEIGHT,
|
|
55
|
+
sender: exports.SENDER,
|
|
56
|
+
width: width !== null && width !== void 0 ? width : exports.DEFAULT_WIDTH,
|
|
57
|
+
};
|
|
58
|
+
await (0, openUtils_1.openUrlInDesktopApp)(ElectronProtocolUrl.TRAIN_NEW_TEST, scriptConfig);
|
|
48
59
|
}
|
|
49
60
|
exports.trainNewTest = trainNewTest;
|
|
50
61
|
async function editTest(trainingSessionOptions) {
|
|
51
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
62
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
52
63
|
const apiClient = await (0, util_1.getApiClientFromOptions)(trainingSessionOptions, true);
|
|
53
64
|
let testRunIdConfig = { testId: '', filterHttpRequests: false };
|
|
54
65
|
if (trainingSessionOptions.testRunId) {
|
|
@@ -69,31 +80,38 @@ async function editTest(trainingSessionOptions) {
|
|
|
69
80
|
if (!((_g = test.flows) === null || _g === void 0 ? void 0 : _g.length)) {
|
|
70
81
|
throw new Error(util_2.TEST_INFO_NOT_FOUND);
|
|
71
82
|
}
|
|
83
|
+
const workspaceId = test.organization_id;
|
|
72
84
|
if (branchName !== 'master') {
|
|
73
|
-
await (0, branches_1.checkBranchNameAndAutoBranchMaybe)(
|
|
85
|
+
await (0, branches_1.checkBranchNameAndAutoBranchMaybe)(workspaceId, apiClient, branchName, trainingSessionOptions.autoBranch);
|
|
74
86
|
}
|
|
75
87
|
const finalUrl = (0, testsUtil_1.getFinalUrl)(test, url);
|
|
76
88
|
if (environmentId) {
|
|
77
89
|
await apiClient.getEnvironment(environmentId);
|
|
78
90
|
}
|
|
91
|
+
const account = await apiClient.getAccountByWorkspaceId(workspaceId);
|
|
79
92
|
(0, testsUtil_1.logTestInfoIfPresent)(`Editing test in desktop app: `, `${test.name} - ${test.invariant_id}`);
|
|
80
93
|
(0, testsUtil_1.logTestInfoIfPresent)(`Test description: `, test.description);
|
|
81
94
|
(0, testsUtil_1.logTestInfoIfPresent)(`URL: `, finalUrl);
|
|
82
|
-
(0, testsUtil_1.logTestInfoIfPresent)(`Workspace: `,
|
|
95
|
+
(0, testsUtil_1.logTestInfoIfPresent)(`Workspace: `, workspaceId);
|
|
83
96
|
(0, testsUtil_1.logTestInfoIfPresent)(`Branch: `, branchName);
|
|
84
97
|
(0, testsUtil_1.logTestInfoIfPresent)(`Environment ID: `, environmentId);
|
|
85
98
|
(0, testsUtil_1.logTestInfoIfPresent)(`Credentials ID: `, credentialsId);
|
|
86
99
|
const scriptConfig = {
|
|
100
|
+
accountId: account.id,
|
|
87
101
|
applicationId: trainingSessionOptions.applicationId,
|
|
88
102
|
branchName,
|
|
89
103
|
credentialsId,
|
|
90
|
-
|
|
104
|
+
disableIsolation: trainingSessionOptions.disableIsolation,
|
|
91
105
|
environmentId,
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
workspaceId: test.organization_id,
|
|
106
|
+
height: (_h = trainingSessionOptions.height) !== null && _h !== void 0 ? _h : exports.DEFAULT_HEIGHT,
|
|
107
|
+
ignoreCertificateErrors: trainingSessionOptions.ignoreCertificateErrors,
|
|
95
108
|
planId: testRunIdConfig.fromPlanId,
|
|
109
|
+
sender: exports.SENDER,
|
|
110
|
+
testId,
|
|
111
|
+
testType: (_j = test.test_type) !== null && _j !== void 0 ? _j : mablApi_1.Journey.TestTypeEnum.Browser,
|
|
96
112
|
url: finalUrl,
|
|
113
|
+
width: (_k = trainingSessionOptions.width) !== null && _k !== void 0 ? _k : exports.DEFAULT_WIDTH,
|
|
114
|
+
workspaceId,
|
|
97
115
|
};
|
|
98
116
|
await (0, openUtils_1.openUrlInDesktopApp)(ElectronProtocolUrl.EDIT_TEST, scriptConfig);
|
|
99
117
|
}
|