@mablhq/mabl-cli 2.50.0 → 2.50.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/README.md +0 -13
- package/api/mablApiClient.js +12 -0
- package/browserLauncher/playwrightBrowserLauncher/firefox/firefoxBrowserDelegate.js +1 -1
- package/browserLauncher/playwrightBrowserLauncher/firefox/firefoxFrameDelegate.js +2 -12
- package/browserLauncher/playwrightBrowserLauncher/playwrightFrame.js +1 -1
- package/commands/databases/databases.js +5 -0
- package/commands/databases/databases_cmds/list.js +64 -0
- package/commands/tests/tests_cmds/export.js +3 -3
- package/commands/tests/tests_cmds/import_cmds/import_playwright.js +2 -2
- package/commands/tests/tests_cmds/import_cmds/import_selenium.js +2 -2
- package/commands/tests/tests_cmds/run.js +1 -3
- package/core/execution/ApiTestUtils.js +16 -13
- package/core/util.js +3 -0
- package/execution/index.js +3 -3
- package/mablApi/index.js +1 -1
- package/mablscript/diffing/diffingUtil.js +7 -7
- package/package.json +3 -3
- package/upload/index.js +1 -1
package/README.md
CHANGED
|
@@ -242,19 +242,6 @@ Use the:
|
|
|
242
242
|
**Note: pre v1.0.0 `run` behavior has been moved to `run-legacy`, and will be
|
|
243
243
|
removed in a future release.**
|
|
244
244
|
|
|
245
|
-
#### [DEPRECATED] Alpha run mode
|
|
246
|
-
|
|
247
|
-
The alpha run command behavior, `run-alpha` has been promoted to GA as `run`.
|
|
248
|
-
|
|
249
|
-
**`run-alpha` command is DEPRECATED and will be removed in a future release.
|
|
250
|
-
Please migrate to `run` which has the identical behavior**
|
|
251
|
-
|
|
252
|
-
Example:
|
|
253
|
-
|
|
254
|
-
```bash
|
|
255
|
-
mabl tests run-alpha --run-id <test-run-id> --headless
|
|
256
|
-
```
|
|
257
|
-
|
|
258
245
|
#### List mabl tests
|
|
259
246
|
|
|
260
247
|
The `mabl tests list` command allows for listing all mabl tests in a workspace.
|
package/api/mablApiClient.js
CHANGED
|
@@ -192,6 +192,18 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
|
192
192
|
throw toApiError(`Failed to get credentials`, error);
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
|
+
async getDatabaseConnections(workspaceId, limit) {
|
|
196
|
+
try {
|
|
197
|
+
const query = query_string_1.default.stringify({
|
|
198
|
+
organization_id: workspaceId,
|
|
199
|
+
limit,
|
|
200
|
+
});
|
|
201
|
+
return await this.makeGetRequest(`${this.baseApiUrl}/database/connections?${query}`).then((result) => { var _a; return (_a = result.database_connections) !== null && _a !== void 0 ? _a : []; });
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
throw toApiError(`Failed to get database connections`, error);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
195
207
|
async getCredential(credentialId, withSecrets, withComputedTotpCount) {
|
|
196
208
|
const queryStringParams = query_string_1.default.stringify({
|
|
197
209
|
with_secrets: withSecrets,
|
|
@@ -44,7 +44,7 @@ class FirefoxBrowserDelegate extends nonChromiumAbstractBrowserDelegate_1.NonChr
|
|
|
44
44
|
return this._browser._connection.rootSession;
|
|
45
45
|
}
|
|
46
46
|
supportsExposeFunction() {
|
|
47
|
-
return
|
|
47
|
+
return false;
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
exports.FirefoxBrowserDelegate = FirefoxBrowserDelegate;
|
|
@@ -3,19 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.FirefoxFrameDelegate = void 0;
|
|
4
4
|
const types_1 = require("../../types");
|
|
5
5
|
const nonChromiumAbstractFrameDelegate_1 = require("../nonChromium/nonChromiumAbstractFrameDelegate");
|
|
6
|
-
const playwrightFrame_1 = require("../playwrightFrame");
|
|
7
6
|
class FirefoxFrameDelegate extends nonChromiumAbstractFrameDelegate_1.NonChromiumAbstractFrameDelegate {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const pageImpl = this.parentPageDelegate.pageImpl;
|
|
11
|
-
if (pageImpl) {
|
|
12
|
-
await ((_a = pageImpl._delegate) === null || _a === void 0 ? void 0 : _a._session.send('Page.addBinding', {
|
|
13
|
-
worldName: playwrightFrame_1.UTILITY_CONTEXT_NAME,
|
|
14
|
-
name: binding.name,
|
|
15
|
-
script: binding.source,
|
|
16
|
-
}));
|
|
17
|
-
}
|
|
18
|
-
return;
|
|
7
|
+
addBindingToSecondaryWorld(_binding) {
|
|
8
|
+
return Promise.resolve();
|
|
19
9
|
}
|
|
20
10
|
async url() {
|
|
21
11
|
let url = this.frame.url();
|
|
@@ -239,7 +239,7 @@ class PlaywrightFrame extends browserLauncher_1.Frame {
|
|
|
239
239
|
return false;
|
|
240
240
|
}
|
|
241
241
|
await this.delegate.addBindingToSecondaryWorld(binding);
|
|
242
|
-
await this.evaluateCodeInSecondaryWorld(binding.source, {});
|
|
242
|
+
await this.evaluateCodeInSecondaryWorld(binding.initScript.source, {});
|
|
243
243
|
}
|
|
244
244
|
catch (e) {
|
|
245
245
|
return false;
|
|
@@ -0,0 +1,64 @@
|
|
|
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
|
+
const js_yaml_1 = require("js-yaml");
|
|
7
|
+
const mablApiClientFactory_1 = require("../../../api/mablApiClientFactory");
|
|
8
|
+
const util_1 = require("../../commandUtil/util");
|
|
9
|
+
const cli_table3_1 = __importDefault(require("cli-table3"));
|
|
10
|
+
const moment = require("moment");
|
|
11
|
+
const list_1 = require("../../commandUtil/list");
|
|
12
|
+
const loggingProvider_1 = require("../../../providers/logging/loggingProvider");
|
|
13
|
+
const constants_1 = require("../../constants");
|
|
14
|
+
exports.command = 'list';
|
|
15
|
+
exports.describe = 'List your databases';
|
|
16
|
+
exports.builder = (0, list_1.getListBuilderOptions)('databases');
|
|
17
|
+
exports.handler = (0, util_1.failWrapper)(listDatabases);
|
|
18
|
+
async function listDatabases(parsed) {
|
|
19
|
+
const output = parsed.output;
|
|
20
|
+
const limit = parsed.limit;
|
|
21
|
+
const workspaceId = await (0, util_1.getWorkspaceId)(parsed);
|
|
22
|
+
const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
|
|
23
|
+
const databases = await apiClient.getDatabaseConnections(workspaceId, limit);
|
|
24
|
+
printConnections(databases, output);
|
|
25
|
+
return databases.length;
|
|
26
|
+
}
|
|
27
|
+
function printConnections(connections, output) {
|
|
28
|
+
switch (output) {
|
|
29
|
+
case 'json':
|
|
30
|
+
loggingProvider_1.logger.info(JSON.stringify(connections, null, 2));
|
|
31
|
+
break;
|
|
32
|
+
case 'yaml':
|
|
33
|
+
loggingProvider_1.logger.info((0, js_yaml_1.dump)(connections));
|
|
34
|
+
break;
|
|
35
|
+
default:
|
|
36
|
+
const table = new cli_table3_1.default({
|
|
37
|
+
head: ['ID', 'Name', 'DB Type', 'Description', 'Created time'],
|
|
38
|
+
wordWrap: true,
|
|
39
|
+
});
|
|
40
|
+
connections.forEach((connection) => {
|
|
41
|
+
table.push([
|
|
42
|
+
{ rowSpan: 1, content: connection.id, vAlign: 'center' },
|
|
43
|
+
{ rowSpan: 1, content: connection.name, vAlign: 'center' },
|
|
44
|
+
{
|
|
45
|
+
rowSpan: 1,
|
|
46
|
+
content: connection.database_type,
|
|
47
|
+
vAlign: 'center',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
rowSpan: 1,
|
|
51
|
+
content: connection.description || '---',
|
|
52
|
+
vAlign: 'center',
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
rowSpan: 1,
|
|
56
|
+
content: moment.utc(connection.created_time).format(constants_1.ListTimeFormat),
|
|
57
|
+
vAlign: 'center',
|
|
58
|
+
},
|
|
59
|
+
]);
|
|
60
|
+
});
|
|
61
|
+
loggingProvider_1.logger.info(table.toString());
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -70,9 +70,9 @@ async function exportTest(parsed) {
|
|
|
70
70
|
}
|
|
71
71
|
const flowArray = await (0, util_1.getJourneyFlowArray)(journey, apiClient, branchName);
|
|
72
72
|
if (flowArray
|
|
73
|
-
.map((flow) => flow.flow_type === mablApi_1.
|
|
74
|
-
flow.flow_type === mablApi_1.
|
|
75
|
-
flow.flow_type === mablApi_1.
|
|
73
|
+
.map((flow) => flow.flow_type === mablApi_1.FlowTypeEnum.Mablscript ||
|
|
74
|
+
flow.flow_type === mablApi_1.FlowTypeEnum.Api ||
|
|
75
|
+
flow.flow_type === mablApi_1.FlowTypeEnum.Mobile)
|
|
76
76
|
.includes(false)) {
|
|
77
77
|
loggingProvider_1.logger.info(chalk.red(`Default mabl tests can not be exported`));
|
|
78
78
|
return;
|
|
@@ -242,9 +242,9 @@ async function runTests(workspaceId, apiClient, importedTests) {
|
|
|
242
242
|
}
|
|
243
243
|
function stepsToFlow(workspaceId, steps) {
|
|
244
244
|
const prototype = {
|
|
245
|
-
import_source_id: mablApi_1.
|
|
245
|
+
import_source_id: mablApi_1.ImportSourceId.SeleniumNodeProxy,
|
|
246
246
|
import_source_version: (0, pureUtil_1.getCliVersion)(),
|
|
247
|
-
flow_type: mablApi_1.
|
|
247
|
+
flow_type: mablApi_1.FlowTypeEnum.Mablscript,
|
|
248
248
|
organization_id: workspaceId,
|
|
249
249
|
reusable: false,
|
|
250
250
|
selectors: steps
|
|
@@ -258,9 +258,9 @@ async function runTests(workspaceId, name, apiClient, importedTests) {
|
|
|
258
258
|
}
|
|
259
259
|
function stepsToFlow(workspaceId, steps) {
|
|
260
260
|
const prototype = {
|
|
261
|
-
import_source_id: mablApi_1.
|
|
261
|
+
import_source_id: mablApi_1.ImportSourceId.SeleniumNodeProxy,
|
|
262
262
|
import_source_version: (0, pureUtil_1.getCliVersion)(),
|
|
263
|
-
flow_type: mablApi_1.
|
|
263
|
+
flow_type: mablApi_1.FlowTypeEnum.Mablscript,
|
|
264
264
|
organization_id: workspaceId,
|
|
265
265
|
reusable: false,
|
|
266
266
|
selectors: steps
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.run = void 0;
|
|
4
3
|
const util_1 = require("../../commandUtil/util");
|
|
5
4
|
const testsUtil_1 = require("../testsUtil");
|
|
6
5
|
const constants_1 = require("../../constants");
|
|
@@ -116,7 +115,7 @@ Note: Setting the environment does not override the default URL. Please use the
|
|
|
116
115
|
})
|
|
117
116
|
.option(constants_1.CommandArgBasicAuthCredentials, {
|
|
118
117
|
alias: constants_1.CommandArgAliases.BasicAuthCredentials,
|
|
119
|
-
describe: 'Basic Authentication credentials
|
|
118
|
+
describe: 'Basic Authentication credentials for adding basic auth headers to test run',
|
|
120
119
|
nargs: 1,
|
|
121
120
|
type: 'string',
|
|
122
121
|
})
|
|
@@ -291,7 +290,6 @@ async function run(parsed) {
|
|
|
291
290
|
}
|
|
292
291
|
}
|
|
293
292
|
}
|
|
294
|
-
exports.run = run;
|
|
295
293
|
function generateRunCommandTemplate(parsed, testResults) {
|
|
296
294
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
297
295
|
const testResult = testResults.testResults[0];
|
|
@@ -218,7 +218,10 @@ function restoreFormDataFileMetadata(resultRequest, collectionRequest) {
|
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
220
|
function findFirstMatchingEvent(eventDefinition, listen) {
|
|
221
|
-
|
|
221
|
+
if (!eventDefinition) {
|
|
222
|
+
return { eventIndex: -1 };
|
|
223
|
+
}
|
|
224
|
+
const eventIndex = eventDefinition.findIndex((def) => def.listen === listen);
|
|
222
225
|
let eventValue;
|
|
223
226
|
if (eventIndex !== -1) {
|
|
224
227
|
eventValue = eventDefinition === null || eventDefinition === void 0 ? void 0 : eventDefinition[eventIndex];
|
|
@@ -257,7 +260,7 @@ function removeMablGeneratedScriptsFromLines(lines) {
|
|
|
257
260
|
}
|
|
258
261
|
function removeMablGeneratedScripts(eventDefinition) {
|
|
259
262
|
var _a, _b;
|
|
260
|
-
|
|
263
|
+
eventDefinition.script.exec = removeMablGeneratedScriptsFromLines((_b = (_a = eventDefinition.script) === null || _a === void 0 ? void 0 : _a.exec) !== null && _b !== void 0 ? _b : []);
|
|
261
264
|
}
|
|
262
265
|
exports.removeMablGeneratedScripts = removeMablGeneratedScripts;
|
|
263
266
|
function isValidMablVariableAssignment(variable) {
|
|
@@ -636,21 +639,21 @@ function readBody(body, contentType) {
|
|
|
636
639
|
}
|
|
637
640
|
exports.readBody = readBody;
|
|
638
641
|
function getActualValue(assertion, apiStepExecutionResult, variables) {
|
|
639
|
-
var _a, _b, _c, _d;
|
|
642
|
+
var _a, _b, _c, _d, _e;
|
|
640
643
|
const { assertTarget, bodyPath, headerName } = assertion;
|
|
641
644
|
switch (assertTarget) {
|
|
642
645
|
case newman_types_1.AssertionTarget.Header:
|
|
643
|
-
return
|
|
646
|
+
return ((_b = (_a = apiStepExecutionResult.response) === null || _a === void 0 ? void 0 : _a.header) !== null && _b !== void 0 ? _b : []).find((header) => caseInsensitiveEquals(header.key, headerName));
|
|
644
647
|
case newman_types_1.AssertionTarget.JSONBody:
|
|
645
648
|
const contentType = getResponseContentType(apiStepExecutionResult.response);
|
|
646
|
-
const content = readBody((
|
|
649
|
+
const content = readBody((_c = apiStepExecutionResult.response) === null || _c === void 0 ? void 0 : _c.stream, contentType);
|
|
647
650
|
return bodyPath
|
|
648
651
|
? lodash_1.default.get(content, replaceVariables(bodyPath, variables))
|
|
649
652
|
: content;
|
|
650
653
|
case newman_types_1.AssertionTarget.Size:
|
|
651
|
-
return (
|
|
654
|
+
return (_d = apiStepExecutionResult.response) === null || _d === void 0 ? void 0 : _d.responseSize;
|
|
652
655
|
case newman_types_1.AssertionTarget.Status:
|
|
653
|
-
return (
|
|
656
|
+
return (_e = apiStepExecutionResult.response) === null || _e === void 0 ? void 0 : _e.code;
|
|
654
657
|
}
|
|
655
658
|
return null;
|
|
656
659
|
}
|
|
@@ -711,7 +714,7 @@ function convertMablAssertionsToExecArray(event) {
|
|
|
711
714
|
exports.convertMablAssertionsToExecArray = convertMablAssertionsToExecArray;
|
|
712
715
|
exports.PRE_REQUEST_LISTEN = 'prerequest';
|
|
713
716
|
function splitLines(value) {
|
|
714
|
-
return value.length ?
|
|
717
|
+
return value.length ? value.split(/\r?\n/) : [];
|
|
715
718
|
}
|
|
716
719
|
exports.splitLines = splitLines;
|
|
717
720
|
function createEmptyRequestEventArray() {
|
|
@@ -741,7 +744,7 @@ const createEmptyRequest = (id = (0, uuid_1.v4)()) => ({
|
|
|
741
744
|
});
|
|
742
745
|
exports.createEmptyRequest = createEmptyRequest;
|
|
743
746
|
function processPostmanItems(items, handleItem, handleFolder) {
|
|
744
|
-
|
|
747
|
+
items === null || items === void 0 ? void 0 : items.forEach((item) => {
|
|
745
748
|
if (isItemGroupDefinition(item)) {
|
|
746
749
|
handleFolder === null || handleFolder === void 0 ? void 0 : handleFolder(item);
|
|
747
750
|
processPostmanItems(item.item, handleItem, handleFolder);
|
|
@@ -754,7 +757,7 @@ function processPostmanItems(items, handleItem, handleFolder) {
|
|
|
754
757
|
exports.processPostmanItems = processPostmanItems;
|
|
755
758
|
function generateRawScriptField(eventValue) {
|
|
756
759
|
if (eventValue.script) {
|
|
757
|
-
eventValue.script.raw =
|
|
760
|
+
eventValue.script.raw = eventValue.script.exec.join('\n');
|
|
758
761
|
}
|
|
759
762
|
}
|
|
760
763
|
exports.generateRawScriptField = generateRawScriptField;
|
|
@@ -840,7 +843,7 @@ function processMablProtocolProfileBehavior(item) {
|
|
|
840
843
|
delete item.protocolProfileBehavior;
|
|
841
844
|
return;
|
|
842
845
|
}
|
|
843
|
-
|
|
846
|
+
item.protocolProfileBehavior = {};
|
|
844
847
|
mablProtocolProfileBehavior === null || mablProtocolProfileBehavior === void 0 ? void 0 : mablProtocolProfileBehavior.forEach((setting) => {
|
|
845
848
|
if (setting.key && setting.value) {
|
|
846
849
|
let valueToSet;
|
|
@@ -850,7 +853,7 @@ function processMablProtocolProfileBehavior(item) {
|
|
|
850
853
|
catch (error) {
|
|
851
854
|
valueToSet = setting.value;
|
|
852
855
|
}
|
|
853
|
-
|
|
856
|
+
item.protocolProfileBehavior[setting.key] = valueToSet;
|
|
854
857
|
}
|
|
855
858
|
});
|
|
856
859
|
}
|
|
@@ -955,7 +958,7 @@ function processItemAuth(item) {
|
|
|
955
958
|
var _a, _b;
|
|
956
959
|
const itemAuth = mablAuthToPostman((_a = item.mablTemporaryStorage) === null || _a === void 0 ? void 0 : _a.mablAuth, exports.INHERIT_AUTH_FROM_PARENT_VALUE);
|
|
957
960
|
if (itemAuth) {
|
|
958
|
-
|
|
961
|
+
item.request.auth = itemAuth;
|
|
959
962
|
}
|
|
960
963
|
else if ((_b = item.request) === null || _b === void 0 ? void 0 : _b.auth) {
|
|
961
964
|
item.request.auth = {};
|
package/core/util.js
CHANGED
|
@@ -47,6 +47,9 @@ async function validateAuthentication(apiClient, authConfig) {
|
|
|
47
47
|
}
|
|
48
48
|
exports.validateAuthentication = validateAuthentication;
|
|
49
49
|
function jsonCloneDeep(value) {
|
|
50
|
+
if (value === undefined) {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
50
53
|
return JSON.parse(JSON.stringify(value));
|
|
51
54
|
}
|
|
52
55
|
exports.jsonCloneDeep = jsonCloneDeep;
|