@mablhq/playwright-tools 2.49.1 → 2.51.4
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/featureSet.js +2 -2
- package/api/mablApiClient.js +12 -0
- package/browserLauncher/index.js +8 -0
- package/browserLauncher/index.js.LICENSE.txt +28 -0
- package/cli.js +1 -0
- package/commands/databases/databases.js +5 -0
- package/commands/databases/databases_cmds/list.js +64 -0
- package/commands/environments/environments_cmds/urls_cmds/add.js +5 -5
- package/commands/tests/testsUtil.js +1 -1
- package/commands/tests/tests_cmds/export.js +3 -3
- package/commands/tests/tests_cmds/import_cmds/import_playwright.js +9 -3
- 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 +236 -20
- package/core/util.js +3 -0
- package/execution/index.js +3 -3
- package/index.d.ts +21 -0
- package/mablApi/index.js +1 -1
- package/mablscript/diffing/diffingUtil.js +7 -7
- package/package.json +1 -2
- package/proxy/index.js +1 -1
- package/upload/index.js +1 -1
- package/browserLauncher/browser.js +0 -2
- package/browserLauncher/browserEvent.js +0 -11
- package/browserLauncher/browserLauncher.js +0 -17
- package/browserLauncher/browserLauncherEventEmitter.js +0 -2
- package/browserLauncher/browserLauncherFactory.js +0 -30
- package/browserLauncher/elementHandle.js +0 -30
- package/browserLauncher/errors.js +0 -26
- package/browserLauncher/frame.js +0 -17
- package/browserLauncher/frameBase.js +0 -10
- package/browserLauncher/httpRequest.js +0 -2
- package/browserLauncher/httpResponse.js +0 -2
- package/browserLauncher/jsHandle.js +0 -2
- package/browserLauncher/page.js +0 -2
- package/browserLauncher/pageEvent.js +0 -17
- package/browserLauncher/playwrightBrowserLauncher/browserDelegate.js +0 -2
- package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumBrowserDelegate.js +0 -61
- package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumElementHandleDelegate.js +0 -129
- package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumFrameDelegate.js +0 -24
- package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumPageDelegate.js +0 -145
- package/browserLauncher/playwrightBrowserLauncher/elementHandleDelegate.js +0 -2
- package/browserLauncher/playwrightBrowserLauncher/firefox/firefoxBrowserDelegate.js +0 -50
- package/browserLauncher/playwrightBrowserLauncher/firefox/firefoxElementHandleDelegate.js +0 -11
- package/browserLauncher/playwrightBrowserLauncher/firefox/firefoxFrameDelegate.js +0 -36
- package/browserLauncher/playwrightBrowserLauncher/firefox/firefoxPageDelegate.js +0 -15
- package/browserLauncher/playwrightBrowserLauncher/frameDelegate.js +0 -2
- package/browserLauncher/playwrightBrowserLauncher/internals.js +0 -2
- package/browserLauncher/playwrightBrowserLauncher/nonChromium/nonChromiumAbstractBrowserDelegate.js +0 -15
- package/browserLauncher/playwrightBrowserLauncher/nonChromium/nonChromiumAbstractElementHandleDelegate.js +0 -73
- package/browserLauncher/playwrightBrowserLauncher/nonChromium/nonChromiumAbstractFrameDelegate.js +0 -13
- package/browserLauncher/playwrightBrowserLauncher/nonChromium/nonChromiumAbstractPageDelegate.js +0 -81
- package/browserLauncher/playwrightBrowserLauncher/pageDelegate.js +0 -2
- package/browserLauncher/playwrightBrowserLauncher/playwrightApiResponse.js +0 -18
- package/browserLauncher/playwrightBrowserLauncher/playwrightBrowser.js +0 -259
- package/browserLauncher/playwrightBrowserLauncher/playwrightBrowserLauncher.js +0 -97
- package/browserLauncher/playwrightBrowserLauncher/playwrightDom.js +0 -319
- package/browserLauncher/playwrightBrowserLauncher/playwrightFrame.js +0 -265
- package/browserLauncher/playwrightBrowserLauncher/playwrightHttpRequest.js +0 -76
- package/browserLauncher/playwrightBrowserLauncher/playwrightHttpResponse.js +0 -26
- package/browserLauncher/playwrightBrowserLauncher/playwrightPage.js +0 -377
- package/browserLauncher/playwrightBrowserLauncher/simplePlaywrightLogger.js +0 -36
- package/browserLauncher/playwrightBrowserLauncher/webkit/webkitBrowserDelegate.js +0 -50
- package/browserLauncher/playwrightBrowserLauncher/webkit/webkitElementHandleDelegate.js +0 -16
- package/browserLauncher/playwrightBrowserLauncher/webkit/webkitFrameDelegate.js +0 -19
- package/browserLauncher/playwrightBrowserLauncher/webkit/webkitPageDelegate.js +0 -15
- package/browserLauncher/playwrightBrowserLauncher/wrappers.js +0 -25
- package/browserLauncher/types.js +0 -28
- package/browserLauncher/utils.js +0 -9
- package/mablscript/mobile/tests/steps/CreateVariableMobileStep.mobiletest.js +0 -298
- package/mablscript/mobile/tests/steps/EnterTextStep.mobiletest.js +0 -79
- package/mablscript/mobile/tests/steps/GeneralHumanization.mobiletest.js +0 -304
- package/mablscript/mobile/tests/steps/HideKeyboardStep.mobiletest.js +0 -27
- package/mablscript/mobile/tests/steps/InstallAppStep.mobiletest.js +0 -20
- package/mablscript/mobile/tests/steps/NavigateBackStep.mobiletest.js +0 -27
- package/mablscript/mobile/tests/steps/NavigateHomeStep.mobiletest.js +0 -27
- package/mablscript/mobile/tests/steps/OpenLinkStep.mobiletest.js +0 -20
- package/mablscript/mobile/tests/steps/PushFileStep.mobiletest.js +0 -55
- package/mablscript/mobile/tests/steps/ScrollStep.mobiletest.js +0 -386
- package/mablscript/mobile/tests/steps/SetOrientationStep.mobiletest.js +0 -32
- package/mablscript/mobile/tests/steps/TapStep.mobiletest.js +0 -57
- package/mablscript/mobile/tests/steps/UninstallAppStep.mobiletest.js +0 -20
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Tmp
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2011-2017 KARASZI Istvan <github@spam.raszi.hu>
|
|
5
|
+
*
|
|
6
|
+
* MIT Licensed
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/*!
|
|
10
|
+
* mime-db
|
|
11
|
+
* Copyright(c) 2014 Jonathan Ong
|
|
12
|
+
* MIT Licensed
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/*!
|
|
16
|
+
* mime-types
|
|
17
|
+
* Copyright(c) 2014 Jonathan Ong
|
|
18
|
+
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
19
|
+
* MIT Licensed
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
23
|
+
|
|
24
|
+
/** @license URI.js v4.4.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js */
|
|
25
|
+
|
|
26
|
+
//! moment.js
|
|
27
|
+
|
|
28
|
+
//! moment.js locale configuration
|
package/cli.js
CHANGED
|
@@ -43,6 +43,7 @@ yargs
|
|
|
43
43
|
.commandDir('./commands/branches')
|
|
44
44
|
.commandDir('./commands/config')
|
|
45
45
|
.commandDir('./commands/credentials')
|
|
46
|
+
.commandDir('./commands/databases')
|
|
46
47
|
.commandDir('./commands/datatables')
|
|
47
48
|
.commandDir('./commands/deploy')
|
|
48
49
|
.commandDir('./commands/environments')
|
|
@@ -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
|
+
}
|
|
@@ -10,12 +10,12 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
10
10
|
const loggingProvider_1 = require("../../../../providers/logging/loggingProvider");
|
|
11
11
|
const mablApi_1 = require("../../../../mablApi");
|
|
12
12
|
const mablApiClientFactory_1 = require("../../../../api/mablApiClientFactory");
|
|
13
|
-
exports.command = `add
|
|
14
|
-
exports.describe = 'Associate
|
|
13
|
+
exports.command = `add <${constants_1.CommandArgId}>`;
|
|
14
|
+
exports.describe = 'Associate URLs with an environment';
|
|
15
15
|
exports.builder = (yargs) => {
|
|
16
16
|
addEnvironmentUrlOptions(yargs)
|
|
17
17
|
.positional(constants_1.CommandArgId, {
|
|
18
|
-
describe: 'Id of environment to add
|
|
18
|
+
describe: 'Id of environment to add URL associations to',
|
|
19
19
|
type: 'string',
|
|
20
20
|
})
|
|
21
21
|
.demandOption(constants_1.CommandArgApplicationId);
|
|
@@ -29,11 +29,11 @@ function addEnvironmentUrlOptions(yargs) {
|
|
|
29
29
|
type: 'string',
|
|
30
30
|
})
|
|
31
31
|
.option(constants_1.CommandArgUrlApp, {
|
|
32
|
-
describe: 'web application
|
|
32
|
+
describe: 'web application URLs to associate with the application-environment pair',
|
|
33
33
|
type: 'array',
|
|
34
34
|
})
|
|
35
35
|
.option(constants_1.CommandArgUrlApi, {
|
|
36
|
-
describe: '
|
|
36
|
+
describe: 'API URLs to associate with the application-environment pair',
|
|
37
37
|
type: 'array',
|
|
38
38
|
})
|
|
39
39
|
.check((argv) => {
|
|
@@ -31,7 +31,7 @@ const cli_table3_1 = __importDefault(require("cli-table3"));
|
|
|
31
31
|
const fs = __importStar(require("fs"));
|
|
32
32
|
const os = __importStar(require("os"));
|
|
33
33
|
const path = __importStar(require("path"));
|
|
34
|
-
const browserLauncher_1 = require("../../browserLauncher
|
|
34
|
+
const browserLauncher_1 = require("../../browserLauncher");
|
|
35
35
|
const trainingSessionActions_1 = require("../../core/messaging/actions/trainingSessionActions");
|
|
36
36
|
const logLineMessaging_1 = require("../../core/messaging/logLineMessaging");
|
|
37
37
|
const messaging_1 = require("../../core/messaging/messaging");
|
|
@@ -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
|
|
@@ -366,6 +366,9 @@ async function getProjectInfo(args) {
|
|
|
366
366
|
...process.env,
|
|
367
367
|
},
|
|
368
368
|
};
|
|
369
|
+
if (process.platform === 'win32') {
|
|
370
|
+
options.shell = true;
|
|
371
|
+
}
|
|
369
372
|
const processClosedPromise = new RichPromise_1.default();
|
|
370
373
|
const playwrightProcess = spawn('npx', commandArgs, options);
|
|
371
374
|
playwrightProcess.stdout.on('data', (data) => {
|
|
@@ -411,8 +414,11 @@ async function runPlaywrightProject(args, tracesPath, cwd) {
|
|
|
411
414
|
...process.env,
|
|
412
415
|
},
|
|
413
416
|
};
|
|
417
|
+
if (process.platform === 'win32') {
|
|
418
|
+
options.shell = true;
|
|
419
|
+
}
|
|
414
420
|
loggingProvider_1.logger.info('Checking playwright project...');
|
|
415
|
-
const playwrightProjectFile = path_1.default.join(options.cwd, 'playwright.config.ts');
|
|
421
|
+
const playwrightProjectFile = path_1.default.join(options.cwd.toString(), 'playwright.config.ts');
|
|
416
422
|
if (!fs_1.default.existsSync(playwrightProjectFile)) {
|
|
417
423
|
throw new Error('No playwright project found. Please ensure you are in the root directory of a playwright project.');
|
|
418
424
|
}
|
|
@@ -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];
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.PRE_REQUEST_LISTEN = exports.convertMablAssertionsToExecArray = exports.convertMablVariableAssignmentsToExecArray = exports.createMablGeneratedScripts = exports.insertMablAssertionScripts = exports.toPostmanScript = exports.replaceVariables = exports.getActualValue = exports.readBody = exports.getResponseContentType = exports.valueToUnquotedString = exports.assertionTypeSupportsCaseSensitivity = exports.assertionTargetSupportsCaseSensitivity = exports.humanizeAssertion = exports.getAssertionTargetArgument = exports.assertionHasTest = exports.isValidMablAssertion = exports.normalizeRegExpExpectedValue = exports.normalizeExpectedValue = exports.normalizeAssertionValue = exports.assertionRequiresValue = exports.filterValidMablAssertions = exports.filterValidMablVariableAssignments = exports.isValidMablVariableAssignment = exports.removeMablGeneratedScripts = exports.createEmptyRequestEvent = exports.findFirstMatchingEvent = exports.restoreCustomRequestFields = exports.deduplicateApiTestExecutionResults = exports.createEmptyVariable = exports.createEmptyAssertion = exports.humanizeAssertionType = exports.getAssertionTypesForTarget = exports.caseInsensitiveEquals = exports.compareStringsCaseInsensitive = exports.ASSERT_TYPES = exports.ASSERT_TARGETS = exports.COLLECTION_WITH_FOLDERS_ERROR = exports.HMAC_SHA1_SIGNATURE = exports.DEFAULT_ADD_OAUTH1_TO_HEADER_VALUE = exports.DEFAULT_OAUTH1_VERSION = exports.OAUTH1_AUTH = exports.NO_AUTH = exports.BEARER_TOKEN_AUTH = exports.BASIC_AUTH = exports.API_KEY_AUTH = exports.INHERIT_AUTH_FROM_PARENT_VALUE = exports.MABL_GENERATED_COMMENT = exports.MABL_GENERATED_ASSERTION_TOKEN = exports.TEST_LISTEN = void 0;
|
|
7
|
-
exports.uuid = exports.createCommentForApiTestSnippet = exports.convertMablSnippetsToExecArray = exports.createPostmanScript = exports.insertMablScriptsIntoCollection = exports.processPostmanItem = exports.replaceRawScriptWithExecArray = exports.removeInvalidHeaders = exports.processItemAuth = exports.mablAuthToPostman = exports.formatContent = exports.getRequestMode = exports.getFormDataArray = exports.isText = exports.isXML = exports.isJson = exports.isSupportedAuthType = exports.isItemDefinition = exports.isCollectionDefinition = exports.isItemGroupDefinition = exports.isFolder = exports.validateCollectionFeaturesForApiTestEditor = exports.generateRawScriptField = exports.processPostmanItems = exports.createEmptyRequest = exports.createEmptyRequestEventArray = exports.splitLines = void 0;
|
|
7
|
+
exports.uuid = exports.postmanEventToExecutableSnippets = exports.postmanAuthToApiTestAuth = exports.getValueFromAuthVariables = exports.insertTestConfigurationIntoFlow = exports.createCommentForApiTestSnippet = exports.convertMablSnippetsToExecArray = exports.createPostmanScript = exports.insertMablScriptsIntoCollection = exports.processPostmanItem = exports.replaceRawScriptWithExecArray = exports.removeInvalidHeaders = exports.processItemAuth = exports.mablAuthToPostman = exports.formatContent = exports.getRequestMode = exports.getFormDataArray = exports.isText = exports.isXML = exports.isJson = exports.isSupportedAuthType = exports.isItemDefinition = exports.isCollectionDefinition = exports.isItemGroupDefinition = exports.isFolder = exports.validateCollectionFeaturesForApiTestEditor = exports.generateRawScriptField = exports.processPostmanItems = exports.createEmptyRequest = exports.createEmptyRequestEventArray = exports.splitLines = void 0;
|
|
8
8
|
const newman_types_1 = require("./newman-types");
|
|
9
9
|
const lodash_1 = __importDefault(require("lodash"));
|
|
10
10
|
const uuid_1 = require("uuid");
|
|
@@ -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];
|
|
@@ -244,6 +247,7 @@ function createEmptyRequestEvent() {
|
|
|
244
247
|
},
|
|
245
248
|
],
|
|
246
249
|
mablVariables: [],
|
|
250
|
+
mablSnippets: [],
|
|
247
251
|
};
|
|
248
252
|
}
|
|
249
253
|
exports.createEmptyRequestEvent = createEmptyRequestEvent;
|
|
@@ -256,7 +260,7 @@ function removeMablGeneratedScriptsFromLines(lines) {
|
|
|
256
260
|
}
|
|
257
261
|
function removeMablGeneratedScripts(eventDefinition) {
|
|
258
262
|
var _a, _b;
|
|
259
|
-
|
|
263
|
+
eventDefinition.script.exec = removeMablGeneratedScriptsFromLines((_b = (_a = eventDefinition.script) === null || _a === void 0 ? void 0 : _a.exec) !== null && _b !== void 0 ? _b : []);
|
|
260
264
|
}
|
|
261
265
|
exports.removeMablGeneratedScripts = removeMablGeneratedScripts;
|
|
262
266
|
function isValidMablVariableAssignment(variable) {
|
|
@@ -635,21 +639,21 @@ function readBody(body, contentType) {
|
|
|
635
639
|
}
|
|
636
640
|
exports.readBody = readBody;
|
|
637
641
|
function getActualValue(assertion, apiStepExecutionResult, variables) {
|
|
638
|
-
var _a, _b, _c, _d;
|
|
642
|
+
var _a, _b, _c, _d, _e;
|
|
639
643
|
const { assertTarget, bodyPath, headerName } = assertion;
|
|
640
644
|
switch (assertTarget) {
|
|
641
645
|
case newman_types_1.AssertionTarget.Header:
|
|
642
|
-
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));
|
|
643
647
|
case newman_types_1.AssertionTarget.JSONBody:
|
|
644
648
|
const contentType = getResponseContentType(apiStepExecutionResult.response);
|
|
645
|
-
const content = readBody((
|
|
649
|
+
const content = readBody((_c = apiStepExecutionResult.response) === null || _c === void 0 ? void 0 : _c.stream, contentType);
|
|
646
650
|
return bodyPath
|
|
647
651
|
? lodash_1.default.get(content, replaceVariables(bodyPath, variables))
|
|
648
652
|
: content;
|
|
649
653
|
case newman_types_1.AssertionTarget.Size:
|
|
650
|
-
return (
|
|
654
|
+
return (_d = apiStepExecutionResult.response) === null || _d === void 0 ? void 0 : _d.responseSize;
|
|
651
655
|
case newman_types_1.AssertionTarget.Status:
|
|
652
|
-
return (
|
|
656
|
+
return (_e = apiStepExecutionResult.response) === null || _e === void 0 ? void 0 : _e.code;
|
|
653
657
|
}
|
|
654
658
|
return null;
|
|
655
659
|
}
|
|
@@ -710,7 +714,7 @@ function convertMablAssertionsToExecArray(event) {
|
|
|
710
714
|
exports.convertMablAssertionsToExecArray = convertMablAssertionsToExecArray;
|
|
711
715
|
exports.PRE_REQUEST_LISTEN = 'prerequest';
|
|
712
716
|
function splitLines(value) {
|
|
713
|
-
return value.length ?
|
|
717
|
+
return value.length ? value.split(/\r?\n/) : [];
|
|
714
718
|
}
|
|
715
719
|
exports.splitLines = splitLines;
|
|
716
720
|
function createEmptyRequestEventArray() {
|
|
@@ -740,7 +744,7 @@ const createEmptyRequest = (id = (0, uuid_1.v4)()) => ({
|
|
|
740
744
|
});
|
|
741
745
|
exports.createEmptyRequest = createEmptyRequest;
|
|
742
746
|
function processPostmanItems(items, handleItem, handleFolder) {
|
|
743
|
-
|
|
747
|
+
items === null || items === void 0 ? void 0 : items.forEach((item) => {
|
|
744
748
|
if (isItemGroupDefinition(item)) {
|
|
745
749
|
handleFolder === null || handleFolder === void 0 ? void 0 : handleFolder(item);
|
|
746
750
|
processPostmanItems(item.item, handleItem, handleFolder);
|
|
@@ -753,7 +757,7 @@ function processPostmanItems(items, handleItem, handleFolder) {
|
|
|
753
757
|
exports.processPostmanItems = processPostmanItems;
|
|
754
758
|
function generateRawScriptField(eventValue) {
|
|
755
759
|
if (eventValue.script) {
|
|
756
|
-
eventValue.script.raw =
|
|
760
|
+
eventValue.script.raw = eventValue.script.exec.join('\n');
|
|
757
761
|
}
|
|
758
762
|
}
|
|
759
763
|
exports.generateRawScriptField = generateRawScriptField;
|
|
@@ -839,7 +843,7 @@ function processMablProtocolProfileBehavior(item) {
|
|
|
839
843
|
delete item.protocolProfileBehavior;
|
|
840
844
|
return;
|
|
841
845
|
}
|
|
842
|
-
|
|
846
|
+
item.protocolProfileBehavior = {};
|
|
843
847
|
mablProtocolProfileBehavior === null || mablProtocolProfileBehavior === void 0 ? void 0 : mablProtocolProfileBehavior.forEach((setting) => {
|
|
844
848
|
if (setting.key && setting.value) {
|
|
845
849
|
let valueToSet;
|
|
@@ -849,7 +853,7 @@ function processMablProtocolProfileBehavior(item) {
|
|
|
849
853
|
catch (error) {
|
|
850
854
|
valueToSet = setting.value;
|
|
851
855
|
}
|
|
852
|
-
|
|
856
|
+
item.protocolProfileBehavior[setting.key] = valueToSet;
|
|
853
857
|
}
|
|
854
858
|
});
|
|
855
859
|
}
|
|
@@ -954,7 +958,7 @@ function processItemAuth(item) {
|
|
|
954
958
|
var _a, _b;
|
|
955
959
|
const itemAuth = mablAuthToPostman((_a = item.mablTemporaryStorage) === null || _a === void 0 ? void 0 : _a.mablAuth, exports.INHERIT_AUTH_FROM_PARENT_VALUE);
|
|
956
960
|
if (itemAuth) {
|
|
957
|
-
|
|
961
|
+
item.request.auth = itemAuth;
|
|
958
962
|
}
|
|
959
963
|
else if ((_b = item.request) === null || _b === void 0 ? void 0 : _b.auth) {
|
|
960
964
|
item.request.auth = {};
|
|
@@ -993,13 +997,10 @@ function processPostmanItem(item) {
|
|
|
993
997
|
removeInvalidHeaders(item);
|
|
994
998
|
}
|
|
995
999
|
exports.processPostmanItem = processPostmanItem;
|
|
996
|
-
function insertMablScriptsIntoCollection(
|
|
1000
|
+
function insertMablScriptsIntoCollection(itemGroup, getSnippet) {
|
|
997
1001
|
var _a, _b;
|
|
998
|
-
(_a =
|
|
999
|
-
(_b =
|
|
1000
|
-
var _a;
|
|
1001
|
-
return (_a = item.event) === null || _a === void 0 ? void 0 : _a.forEach((event) => insertMablScriptsIntoEvent(event, getSnippet));
|
|
1002
|
-
});
|
|
1002
|
+
(_a = itemGroup.event) === null || _a === void 0 ? void 0 : _a.forEach((event) => insertMablScriptsIntoEvent(event, getSnippet));
|
|
1003
|
+
(_b = itemGroup.item) === null || _b === void 0 ? void 0 : _b.forEach((item) => insertMablScriptsIntoCollection(item, getSnippet));
|
|
1003
1004
|
}
|
|
1004
1005
|
exports.insertMablScriptsIntoCollection = insertMablScriptsIntoCollection;
|
|
1005
1006
|
function insertMablScriptsIntoEvent(event, getSnippet) {
|
|
@@ -1056,5 +1057,220 @@ function createCommentForApiTestSnippet(snippet, position) {
|
|
|
1056
1057
|
return `// ${position} of one-time snippet "${(_b = snippet.name) !== null && _b !== void 0 ? _b : snippet.id}"`;
|
|
1057
1058
|
}
|
|
1058
1059
|
exports.createCommentForApiTestSnippet = createCommentForApiTestSnippet;
|
|
1060
|
+
function insertTestConfigurationIntoFlow(test, flow) {
|
|
1061
|
+
var _a;
|
|
1062
|
+
const collection = flow.api_steps;
|
|
1063
|
+
const testConfiguration = test.api_configuration;
|
|
1064
|
+
if (!testConfiguration) {
|
|
1065
|
+
return;
|
|
1066
|
+
}
|
|
1067
|
+
const { authentication, pre_request_snippets: preRequestSnippets, post_request_snippets: postRequestSnippets, } = testConfiguration;
|
|
1068
|
+
if (!authentication &&
|
|
1069
|
+
!(preRequestSnippets === null || preRequestSnippets === void 0 ? void 0 : preRequestSnippets.length) &&
|
|
1070
|
+
!(postRequestSnippets === null || postRequestSnippets === void 0 ? void 0 : postRequestSnippets.length)) {
|
|
1071
|
+
return;
|
|
1072
|
+
}
|
|
1073
|
+
const folder = {
|
|
1074
|
+
name: (_a = flow.id) !== null && _a !== void 0 ? _a : 'Flow',
|
|
1075
|
+
item: collection.item,
|
|
1076
|
+
};
|
|
1077
|
+
folder.auth = collection.auth;
|
|
1078
|
+
folder.event = collection.event;
|
|
1079
|
+
delete collection.auth;
|
|
1080
|
+
delete collection.event;
|
|
1081
|
+
collection.item = [folder];
|
|
1082
|
+
if (authentication) {
|
|
1083
|
+
collection.auth = apiTestAuthToPostmanAuth(authentication);
|
|
1084
|
+
}
|
|
1085
|
+
const event = [];
|
|
1086
|
+
if (preRequestSnippets === null || preRequestSnippets === void 0 ? void 0 : preRequestSnippets.length) {
|
|
1087
|
+
event.push(executableSnippetsToPostmanEvent(preRequestSnippets, 'prerequest'));
|
|
1088
|
+
}
|
|
1089
|
+
if (postRequestSnippets === null || postRequestSnippets === void 0 ? void 0 : postRequestSnippets.length) {
|
|
1090
|
+
event.push(executableSnippetsToPostmanEvent(postRequestSnippets, 'test'));
|
|
1091
|
+
}
|
|
1092
|
+
if (event.length) {
|
|
1093
|
+
collection.event = event;
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
exports.insertTestConfigurationIntoFlow = insertTestConfigurationIntoFlow;
|
|
1097
|
+
function apiTestAuthToPostmanAuth(apiTestAuth) {
|
|
1098
|
+
const postmanAuth = {
|
|
1099
|
+
type: `${apiTestAuth.type}`,
|
|
1100
|
+
};
|
|
1101
|
+
switch (apiTestAuth.type) {
|
|
1102
|
+
case 'apikey':
|
|
1103
|
+
postmanAuth.apikey = apiKeyAuthenticationToPostman(apiTestAuth.api_key);
|
|
1104
|
+
break;
|
|
1105
|
+
case 'basic':
|
|
1106
|
+
postmanAuth.basic = basicAuthenticationToPostman(apiTestAuth.basic);
|
|
1107
|
+
break;
|
|
1108
|
+
case 'bearer':
|
|
1109
|
+
postmanAuth.bearer = bearerAuthenticationToPostman(apiTestAuth.bearer);
|
|
1110
|
+
break;
|
|
1111
|
+
case 'oauth1':
|
|
1112
|
+
postmanAuth.oauth1 = oauth1AuthenticationToPostman(apiTestAuth.oauth1);
|
|
1113
|
+
break;
|
|
1114
|
+
}
|
|
1115
|
+
return postmanAuth;
|
|
1116
|
+
}
|
|
1117
|
+
function apiKeyAuthenticationToPostman(auth) {
|
|
1118
|
+
return removeUndefinedValues([
|
|
1119
|
+
toPostmanConfigurationValue('key', auth === null || auth === void 0 ? void 0 : auth.key),
|
|
1120
|
+
toPostmanConfigurationValue('value', auth === null || auth === void 0 ? void 0 : auth.value),
|
|
1121
|
+
toPostmanConfigurationValue('in', auth === null || auth === void 0 ? void 0 : auth.location),
|
|
1122
|
+
]);
|
|
1123
|
+
}
|
|
1124
|
+
function basicAuthenticationToPostman(auth) {
|
|
1125
|
+
return removeUndefinedValues([
|
|
1126
|
+
toPostmanConfigurationValue('username', auth === null || auth === void 0 ? void 0 : auth.username),
|
|
1127
|
+
toPostmanConfigurationValue('password', auth === null || auth === void 0 ? void 0 : auth.password),
|
|
1128
|
+
]);
|
|
1129
|
+
}
|
|
1130
|
+
function bearerAuthenticationToPostman(auth) {
|
|
1131
|
+
return removeUndefinedValues([
|
|
1132
|
+
toPostmanConfigurationValue('token', auth === null || auth === void 0 ? void 0 : auth.token),
|
|
1133
|
+
]);
|
|
1134
|
+
}
|
|
1135
|
+
function oauth1AuthenticationToPostman(auth) {
|
|
1136
|
+
return removeUndefinedValues([
|
|
1137
|
+
toPostmanConfigurationValue('addParamsToHeader', auth === null || auth === void 0 ? void 0 : auth.add_parameters_to_header, 'boolean'),
|
|
1138
|
+
toPostmanConfigurationValue('addEmptyParamsToSign', auth === null || auth === void 0 ? void 0 : auth.add_empty_parameters_to_signature, 'boolean'),
|
|
1139
|
+
toPostmanConfigurationValue('callback', auth === null || auth === void 0 ? void 0 : auth.callback_url),
|
|
1140
|
+
toPostmanConfigurationValue('consumerKey', auth === null || auth === void 0 ? void 0 : auth.consumer_key),
|
|
1141
|
+
toPostmanConfigurationValue('consumerSecret', auth === null || auth === void 0 ? void 0 : auth.consumer_secret),
|
|
1142
|
+
toPostmanConfigurationValue('includeBodyHash', auth === null || auth === void 0 ? void 0 : auth.include_body_hash, 'boolean'),
|
|
1143
|
+
toPostmanConfigurationValue('nonce', auth === null || auth === void 0 ? void 0 : auth.nonce),
|
|
1144
|
+
toPostmanConfigurationValue('realm', auth === null || auth === void 0 ? void 0 : auth.realm),
|
|
1145
|
+
toPostmanConfigurationValue('signatureMethod', auth === null || auth === void 0 ? void 0 : auth.signature_method),
|
|
1146
|
+
toPostmanConfigurationValue('timestamp', auth === null || auth === void 0 ? void 0 : auth.timestamp),
|
|
1147
|
+
toPostmanConfigurationValue('token', auth === null || auth === void 0 ? void 0 : auth.token),
|
|
1148
|
+
toPostmanConfigurationValue('tokenSecret', auth === null || auth === void 0 ? void 0 : auth.token_secret),
|
|
1149
|
+
toPostmanConfigurationValue('verifier', auth === null || auth === void 0 ? void 0 : auth.verifier),
|
|
1150
|
+
toPostmanConfigurationValue('version', auth === null || auth === void 0 ? void 0 : auth.version),
|
|
1151
|
+
]);
|
|
1152
|
+
}
|
|
1153
|
+
const removeUndefinedValues = (values) => values.filter((value) => value !== undefined);
|
|
1154
|
+
function toPostmanConfigurationValue(key, value, type = 'string') {
|
|
1155
|
+
if (!value) {
|
|
1156
|
+
return;
|
|
1157
|
+
}
|
|
1158
|
+
if (type === 'string') {
|
|
1159
|
+
value = `${value}`;
|
|
1160
|
+
}
|
|
1161
|
+
if (type === 'boolean') {
|
|
1162
|
+
value = `${value}`.toLowerCase() === 'true';
|
|
1163
|
+
}
|
|
1164
|
+
return {
|
|
1165
|
+
key,
|
|
1166
|
+
value,
|
|
1167
|
+
type,
|
|
1168
|
+
};
|
|
1169
|
+
}
|
|
1170
|
+
function executableSnippetsToPostmanEvent(snippets, type) {
|
|
1171
|
+
return {
|
|
1172
|
+
id: (0, exports.uuid)(),
|
|
1173
|
+
listen: type,
|
|
1174
|
+
mablSnippets: snippets.map((snippet) => executableSnippetToApiTestSnippet(snippet)),
|
|
1175
|
+
script: {
|
|
1176
|
+
exec: [],
|
|
1177
|
+
id: (0, exports.uuid)(),
|
|
1178
|
+
type: 'text/javascript',
|
|
1179
|
+
},
|
|
1180
|
+
};
|
|
1181
|
+
}
|
|
1182
|
+
function executableSnippetToApiTestSnippet(executableSnippet) {
|
|
1183
|
+
const { invariant_id: invariantId, ...snippet } = { ...executableSnippet };
|
|
1184
|
+
if (executableSnippet.reusable) {
|
|
1185
|
+
return {
|
|
1186
|
+
invariantId: invariantId,
|
|
1187
|
+
reusable: true,
|
|
1188
|
+
};
|
|
1189
|
+
}
|
|
1190
|
+
return {
|
|
1191
|
+
...snippet,
|
|
1192
|
+
reusable: false,
|
|
1193
|
+
};
|
|
1194
|
+
}
|
|
1195
|
+
function getValueFromAuthVariables(authVariables, variableName) {
|
|
1196
|
+
var _a;
|
|
1197
|
+
return (_a = authVariables === null || authVariables === void 0 ? void 0 : authVariables.find((variable) => variable.key === variableName)) === null || _a === void 0 ? void 0 : _a.value;
|
|
1198
|
+
}
|
|
1199
|
+
exports.getValueFromAuthVariables = getValueFromAuthVariables;
|
|
1200
|
+
function postmanAuthToApiTestAuth(auth) {
|
|
1201
|
+
const { type: authType } = auth || {};
|
|
1202
|
+
if (!authType || authType === 'noauth') {
|
|
1203
|
+
return undefined;
|
|
1204
|
+
}
|
|
1205
|
+
const apiTestAuth = {
|
|
1206
|
+
type: authType,
|
|
1207
|
+
};
|
|
1208
|
+
const getValueFromVariablesForAuthType = (variableName) => getValueFromAuthVariables(auth[authType], variableName);
|
|
1209
|
+
switch (authType) {
|
|
1210
|
+
case 'apikey':
|
|
1211
|
+
apiTestAuth.api_key = {
|
|
1212
|
+
location: getValueFromVariablesForAuthType('in'),
|
|
1213
|
+
key: getValueFromVariablesForAuthType('key'),
|
|
1214
|
+
value: getValueFromVariablesForAuthType('value'),
|
|
1215
|
+
};
|
|
1216
|
+
break;
|
|
1217
|
+
case 'basic':
|
|
1218
|
+
apiTestAuth.basic = {
|
|
1219
|
+
username: getValueFromVariablesForAuthType('username'),
|
|
1220
|
+
password: getValueFromVariablesForAuthType('password'),
|
|
1221
|
+
};
|
|
1222
|
+
break;
|
|
1223
|
+
case 'bearer':
|
|
1224
|
+
apiTestAuth.bearer = {
|
|
1225
|
+
token: getValueFromVariablesForAuthType('token'),
|
|
1226
|
+
};
|
|
1227
|
+
break;
|
|
1228
|
+
case 'oauth1':
|
|
1229
|
+
apiTestAuth.oauth1 = {
|
|
1230
|
+
consumer_key: getValueFromVariablesForAuthType('consumerKey'),
|
|
1231
|
+
consumer_secret: getValueFromVariablesForAuthType('consumerSecret'),
|
|
1232
|
+
token: getValueFromVariablesForAuthType('token'),
|
|
1233
|
+
token_secret: getValueFromVariablesForAuthType('tokenSecret'),
|
|
1234
|
+
signature_method: getValueFromVariablesForAuthType('signatureMethod'),
|
|
1235
|
+
nonce: getValueFromVariablesForAuthType('nonce'),
|
|
1236
|
+
timestamp: getValueFromVariablesForAuthType('timestamp'),
|
|
1237
|
+
version: getValueFromVariablesForAuthType('version'),
|
|
1238
|
+
realm: getValueFromVariablesForAuthType('realm'),
|
|
1239
|
+
add_parameters_to_header: getValueFromVariablesForAuthType('addParamsToHeader'),
|
|
1240
|
+
add_empty_parameters_to_signature: getValueFromVariablesForAuthType('addEmptyParamsToSignature'),
|
|
1241
|
+
callback_url: getValueFromVariablesForAuthType('callbackUrl'),
|
|
1242
|
+
include_body_hash: getValueFromVariablesForAuthType('includeBodyHash'),
|
|
1243
|
+
verifier: getValueFromVariablesForAuthType('verifier'),
|
|
1244
|
+
};
|
|
1245
|
+
break;
|
|
1246
|
+
}
|
|
1247
|
+
return apiTestAuth;
|
|
1248
|
+
}
|
|
1249
|
+
exports.postmanAuthToApiTestAuth = postmanAuthToApiTestAuth;
|
|
1250
|
+
function postmanEventToExecutableSnippets(event) {
|
|
1251
|
+
var _a, _b;
|
|
1252
|
+
if (!event) {
|
|
1253
|
+
return [];
|
|
1254
|
+
}
|
|
1255
|
+
return ((_b = (_a = event.mablSnippets) === null || _a === void 0 ? void 0 : _a.map((snippet) => {
|
|
1256
|
+
if (snippet.reusable) {
|
|
1257
|
+
const executableSnippet = {
|
|
1258
|
+
invariant_id: snippet.invariantId,
|
|
1259
|
+
reusable: true,
|
|
1260
|
+
};
|
|
1261
|
+
return executableSnippet;
|
|
1262
|
+
}
|
|
1263
|
+
const executableSnippet = {
|
|
1264
|
+
reusable: false,
|
|
1265
|
+
body: snippet.body,
|
|
1266
|
+
description: snippet.description,
|
|
1267
|
+
name: snippet.name,
|
|
1268
|
+
snippet_type: snippet.snippet_type,
|
|
1269
|
+
workspace_id: snippet.workspace_id,
|
|
1270
|
+
};
|
|
1271
|
+
return executableSnippet;
|
|
1272
|
+
})) !== null && _b !== void 0 ? _b : []);
|
|
1273
|
+
}
|
|
1274
|
+
exports.postmanEventToExecutableSnippets = postmanEventToExecutableSnippets;
|
|
1059
1275
|
const uuid = () => (0, uuid_1.v4)();
|
|
1060
1276
|
exports.uuid = uuid;
|
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;
|