@mablhq/mabl-cli 2.61.18 → 2.63.3
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/browserEngines/chromiumBrowserEngine.js +5 -0
- package/browserEngines/firefoxBrowserEngine.js +25 -9
- package/browserLauncher/index.js +1 -1
- package/commands/constants.js +9 -3
- package/commands/flows/flows_cmds/export.js +18 -1
- package/commands/tests/testsUtil.js +7 -7
- package/commands/tests/tests_cmds/create.js +12 -8
- package/commands/tests/tests_cmds/export.js +12 -1
- package/core/execution/ApiTestUtils.js +72 -0
- package/core/trainer/trainingSessions.js +2 -1
- package/execution/index.js +1 -1
- package/package.json +1 -1
package/commands/constants.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
5
|
-
exports.SCENARIO_ID_HEADER = exports.SCENARIO_NAME_HEADER = exports.ValidBrowserTypesForLocalRuns = exports.BrowserTypeSelections = exports.DefaultBrowserType = void 0;
|
|
3
|
+
exports.CommandArgMablBranch = exports.CommandArgMablAutoLogin = exports.CommandArgMablAutoBranch = exports.CommandArgLinkBypass = exports.CommandArgLinkLabel = exports.CommandArgLimitOutput = exports.CommandArgLabels = exports.CommandArgLabelsInclude = exports.CommandArgLabelsExclude = exports.CommandArgTestInteractionSpeed = exports.CommandArgTestRunId = exports.CommandArgTestFile = exports.CommandArgKeepBrowserOpen = exports.CommandArgInput = exports.CommandArgIncludedTests = exports.CommandArgIncludeDefaults = exports.CommandArgId = exports.CommandArgUserAgent = exports.CommandArgHttpHeaders = exports.CommandArgHelp = exports.CommandArgHeadless = exports.CommandArgFromPlanId = exports.CommandArgFrom = exports.CommandArgFormat = exports.CommandArgFindPath = exports.CommandArgFastFailure = exports.CommandArgOverrideEnvironmentId = exports.CommandArgHeight = exports.CommandArgGrep = exports.CommandArgExtraArguments = exports.CommandArgExistingReport = exports.CommandArgExcludedTests = exports.CommandArgEnvironmentId = exports.CommandArgDetailLevel = exports.CommandArgDestination = exports.CommandArgDescription = exports.CommandArgDeploymentId = exports.CommandArgDecrypt = exports.CommandArgDebug = exports.CommandArgDataTables = exports.CommandArgDataTableId = exports.CommandArgCredentials = exports.CommandArgBasicAuthCredentials = exports.CommandArgBrowsers = exports.CommandArgBrowser = exports.CommandArgBranch = exports.CommandArgAuto = exports.CommandArgApplicationId = exports.CommandArgApiKey = exports.CommandArgABConfigFile = void 0;
|
|
4
|
+
exports.CommandArgAliases = exports.CommandArgBrowserEnableExtensions = exports.CommandArgBrowserIgnoreCertificateErrors = exports.CommandArgBrowserDisableIsolation = exports.ListTimeFormat = exports.CommandArgWidth = exports.CommandArgVerbose = exports.CommandArgTimezoneID = exports.CommandArgTestDescription = exports.CommandArgTestName = exports.CommandArgLocale = exports.CommandArgUseTestExecutionProxy = exports.CommandArgScenarioId = exports.CommandArgReporterOptions = exports.CommandArgReporter = exports.CommandArgWorkspaceId = exports.CommandArgVersion = exports.CommandArgVariables = exports.CommandArgUrlApi = exports.CommandArgUrlApp = exports.CommandArgUrl = exports.CommandArgTo = exports.CommandArgTrainerVersion = exports.CommandArgTraceFile = exports.CommandArgTracesPath = exports.CommandArgTestPath = exports.CommandArgIntent = exports.CommandArgSilent = exports.CommandArgRevision = exports.CommandArgRecordVideoPath = exports.CommandArgMaxHeartbeatAge = exports.CommandArgPlanId = exports.CommandArgContentTypes = exports.CommandArgPreview = exports.CommandArgPath = exports.CommandArgOutputFilePath = exports.CommandArgOutput = exports.CommandArgNoPrompt = exports.CommandArgPrompt = exports.CommandArgProject = exports.CommandArgPortNumber = exports.CommandArgName = exports.CommandArgMobileDeviceName = exports.CommandArgMobilePlatform = exports.CommandArgMobileBuildFileId = exports.CommandArgMobileBuildFilePath = exports.CommandArgiOSdMobileAppFileId = exports.CommandArgAndroidMobileAppFileId = exports.CommandArgMulti = exports.CommandArgMablBranchChangesOnly = void 0;
|
|
5
|
+
exports.SCENARIO_ID_HEADER = exports.SCENARIO_NAME_HEADER = exports.ValidBrowserTypesForLocalRuns = exports.BrowserTypeSelections = exports.DefaultBrowserType = exports.DefaultBranchName = exports.DefaultOutputFormatChoices = exports.DetailLevelFormats = exports.Reporter = exports.OutputFormats = void 0;
|
|
6
6
|
const browserTypes_1 = require("./browserTypes");
|
|
7
7
|
exports.CommandArgABConfigFile = 'ab-config-file';
|
|
8
8
|
exports.CommandArgApiKey = 'api-key';
|
|
@@ -26,6 +26,7 @@ exports.CommandArgExcludedTests = 'excluded-tests';
|
|
|
26
26
|
exports.CommandArgExistingReport = 'existing-report';
|
|
27
27
|
exports.CommandArgExtraArguments = 'extra-arguments';
|
|
28
28
|
exports.CommandArgGrep = 'grep';
|
|
29
|
+
exports.CommandArgHeight = 'height';
|
|
29
30
|
exports.CommandArgOverrideEnvironmentId = 'override-environment-id';
|
|
30
31
|
exports.CommandArgFastFailure = 'fast-failure';
|
|
31
32
|
exports.CommandArgFindPath = 'find-path';
|
|
@@ -76,6 +77,7 @@ exports.CommandArgMaxHeartbeatAge = 'max-heartbeat-age';
|
|
|
76
77
|
exports.CommandArgRecordVideoPath = 'video-path';
|
|
77
78
|
exports.CommandArgRevision = 'revision';
|
|
78
79
|
exports.CommandArgSilent = 'silent';
|
|
80
|
+
exports.CommandArgIntent = 'intent';
|
|
79
81
|
exports.CommandArgTestPath = 'tests-path';
|
|
80
82
|
exports.CommandArgTracesPath = 'traces-path';
|
|
81
83
|
exports.CommandArgTraceFile = 'trace-file';
|
|
@@ -92,8 +94,11 @@ exports.CommandArgReporterOptions = 'reporter-options';
|
|
|
92
94
|
exports.CommandArgScenarioId = 'scenario-id';
|
|
93
95
|
exports.CommandArgUseTestExecutionProxy = 'use-test-execution-proxy';
|
|
94
96
|
exports.CommandArgLocale = 'locale';
|
|
97
|
+
exports.CommandArgTestName = 'test-name';
|
|
98
|
+
exports.CommandArgTestDescription = 'test-description';
|
|
95
99
|
exports.CommandArgTimezoneID = 'timezone-id';
|
|
96
100
|
exports.CommandArgVerbose = 'verbose';
|
|
101
|
+
exports.CommandArgWidth = 'width';
|
|
97
102
|
exports.ListTimeFormat = 'MMM Do YYYY, HH:mm:ss';
|
|
98
103
|
exports.CommandArgBrowserDisableIsolation = 'browser-disable-isolation';
|
|
99
104
|
exports.CommandArgBrowserIgnoreCertificateErrors = 'browser-ignore-certificate-errors';
|
|
@@ -127,6 +132,7 @@ var OutputFormats;
|
|
|
127
132
|
OutputFormats["Json"] = "json";
|
|
128
133
|
OutputFormats["Markdown"] = "markdown";
|
|
129
134
|
OutputFormats["Playwright"] = "playwright";
|
|
135
|
+
OutputFormats["Postman"] = "postman";
|
|
130
136
|
OutputFormats["SeleniumIde"] = "side";
|
|
131
137
|
OutputFormats["Table"] = "table";
|
|
132
138
|
OutputFormats["Yaml"] = "yaml";
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const mablApi_1 = require("../../../mablApi");
|
|
3
4
|
const mablApiClientFactory_1 = require("../../../api/mablApiClientFactory");
|
|
4
5
|
const util_1 = require("../../commandUtil/util");
|
|
5
6
|
const js_yaml_1 = require("js-yaml");
|
|
6
7
|
const constants_1 = require("../../constants");
|
|
7
8
|
const execution_1 = require("../../../execution");
|
|
8
9
|
const fileUtil_1 = require("../../commandUtil/fileUtil");
|
|
10
|
+
const ApiTestUtils_1 = require("../../../core/execution/ApiTestUtils");
|
|
9
11
|
const os = require('os');
|
|
10
12
|
const JSON_REPLACER = null;
|
|
11
13
|
exports.command = `export <${constants_1.CommandArgId}>`;
|
|
@@ -20,7 +22,12 @@ exports.builder = (yargs) => {
|
|
|
20
22
|
alias: 'fmt',
|
|
21
23
|
default: 'yaml',
|
|
22
24
|
describe: `Specify a format for the flow export`,
|
|
23
|
-
choices: [
|
|
25
|
+
choices: [
|
|
26
|
+
constants_1.OutputFormats.Json,
|
|
27
|
+
constants_1.OutputFormats.Yaml,
|
|
28
|
+
constants_1.OutputFormats.Csv,
|
|
29
|
+
constants_1.OutputFormats.Postman,
|
|
30
|
+
],
|
|
24
31
|
})
|
|
25
32
|
.option(constants_1.CommandArgDetailLevel, {
|
|
26
33
|
default: 'simple',
|
|
@@ -46,6 +53,12 @@ async function pullFlow(parsed) {
|
|
|
46
53
|
case constants_1.OutputFormats.Csv:
|
|
47
54
|
dumpToCsv(flow);
|
|
48
55
|
break;
|
|
56
|
+
case constants_1.OutputFormats.Postman:
|
|
57
|
+
if (flow.flow_type !== mablApi_1.FlowTypeEnum.Api) {
|
|
58
|
+
throw new Error('Only API flows can be exported as Postman collections.');
|
|
59
|
+
}
|
|
60
|
+
await dumpToPostmanCollection(flow, apiClient);
|
|
61
|
+
break;
|
|
49
62
|
case constants_1.OutputFormats.Json:
|
|
50
63
|
case constants_1.OutputFormats.Yaml:
|
|
51
64
|
default:
|
|
@@ -75,3 +88,7 @@ function dumpToCsv(flow) {
|
|
|
75
88
|
const output = flowConfig.generateSimpleCsv();
|
|
76
89
|
(0, fileUtil_1.writeExportedEntityToFile)(output.join(os.EOL), 'csv', flow.id);
|
|
77
90
|
}
|
|
91
|
+
async function dumpToPostmanCollection(flow, apiClient) {
|
|
92
|
+
const collection = await (0, ApiTestUtils_1.exportPostmanFlowAsCollection)(flow, (snippetInvariantId) => apiClient.getSnippet(snippetInvariantId));
|
|
93
|
+
(0, fileUtil_1.writeExportedEntityToFile)(JSON.stringify(collection, JSON_REPLACER, 2), 'json', flow.id);
|
|
94
|
+
}
|
|
@@ -111,24 +111,23 @@ async function launchBrowserInstance(options) {
|
|
|
111
111
|
return browser;
|
|
112
112
|
}
|
|
113
113
|
async function maybeGetProxyOptions(options) {
|
|
114
|
-
const proxyServer = (await cliConfigProvider_1.CliConfigProvider.getCliConfig()).http.test
|
|
115
|
-
.proxyHost;
|
|
116
|
-
let optionsProxy;
|
|
117
114
|
if (options?.proxy) {
|
|
118
|
-
|
|
115
|
+
return {
|
|
119
116
|
server: options.proxy.server,
|
|
120
117
|
username: options.proxy.username,
|
|
121
118
|
password: options.proxy.password,
|
|
122
119
|
};
|
|
123
120
|
}
|
|
124
|
-
|
|
125
|
-
|
|
121
|
+
const proxyServer = (await cliConfigProvider_1.CliConfigProvider.getCliConfig()).http.test
|
|
122
|
+
.proxyHost;
|
|
123
|
+
if (proxyServer) {
|
|
124
|
+
return {
|
|
126
125
|
server: proxyServer.href,
|
|
127
126
|
username: proxyServer.username,
|
|
128
127
|
password: proxyServer.password,
|
|
129
128
|
};
|
|
130
129
|
}
|
|
131
|
-
return
|
|
130
|
+
return;
|
|
132
131
|
}
|
|
133
132
|
function maybeLaunchBrowser(options) {
|
|
134
133
|
return browserLauncher_1.BrowserLauncherFactory.createRunner(options?.runnerType, options?.loggerFunc).launch(options);
|
|
@@ -152,6 +151,7 @@ async function createBrowserForExecutionEngine(engine, proxyInfo, options) {
|
|
|
152
151
|
const userDataDir = await engine.prepareBrowserPreferencesDirectory(undefined, proxyInfo);
|
|
153
152
|
const launchOptions = engine.getExecutionEngineBrowserLaunchOptions(options, proxyInfo);
|
|
154
153
|
const proxy = engine.getProxySpec(proxyInfo);
|
|
154
|
+
(0, logUtils_1.logCliOutput)(loggingProvider_1.LogLevel.Info, `Launching browser with proxy spec: ${proxy ? JSON.stringify(proxy) : '<none>'}`);
|
|
155
155
|
const maybeBrowser = await maybeLaunchBrowser({
|
|
156
156
|
...options,
|
|
157
157
|
...launchOptions,
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createTestDescriptionKey = exports.createTestNameKey = void 0;
|
|
4
3
|
exports.launchTrainingSession = launchTrainingSession;
|
|
5
4
|
const util_1 = require("../../commandUtil/util");
|
|
6
5
|
const constants_1 = require("../../constants");
|
|
7
6
|
const trainingSessions_1 = require("../../../core/trainer/trainingSessions");
|
|
8
|
-
exports.
|
|
9
|
-
exports.createTestDescriptionKey = 'test-description';
|
|
10
|
-
exports.command = `create <${constants_1.CommandArgUrl}> <${exports.createTestNameKey}>`;
|
|
7
|
+
exports.command = `create <${constants_1.CommandArgUrl}> <${constants_1.CommandArgTestName}>`;
|
|
11
8
|
exports.describe = 'Create a browser test using the mabl Trainer';
|
|
12
9
|
exports.builder = (yargs) => {
|
|
13
10
|
yargs
|
|
@@ -15,24 +12,24 @@ exports.builder = (yargs) => {
|
|
|
15
12
|
describe: 'The url to test',
|
|
16
13
|
type: 'string',
|
|
17
14
|
})
|
|
18
|
-
.positional(
|
|
15
|
+
.positional(constants_1.CommandArgTestName, {
|
|
19
16
|
describe: 'The name of the test',
|
|
20
17
|
type: 'string',
|
|
21
18
|
})
|
|
22
19
|
.option('desc', {
|
|
23
|
-
alias:
|
|
20
|
+
alias: constants_1.CommandArgTestDescription,
|
|
24
21
|
describe: 'Description for the test',
|
|
25
22
|
default: '',
|
|
26
23
|
nargs: 1,
|
|
27
24
|
type: 'string',
|
|
28
25
|
})
|
|
29
|
-
.option(
|
|
26
|
+
.option(constants_1.CommandArgWidth, {
|
|
30
27
|
describe: 'Set the browser width in pixels',
|
|
31
28
|
default: 1366,
|
|
32
29
|
nargs: 1,
|
|
33
30
|
type: 'number',
|
|
34
31
|
})
|
|
35
|
-
.option(
|
|
32
|
+
.option(constants_1.CommandArgHeight, {
|
|
36
33
|
describe: 'Set the browser height in pixels',
|
|
37
34
|
default: 768,
|
|
38
35
|
nargs: 1,
|
|
@@ -89,6 +86,11 @@ exports.builder = (yargs) => {
|
|
|
89
86
|
describe: 'Credentials ID to run the test with',
|
|
90
87
|
nargs: 1,
|
|
91
88
|
type: 'string',
|
|
89
|
+
})
|
|
90
|
+
.option(constants_1.CommandArgIntent, {
|
|
91
|
+
describe: 'Intent for the test, e.g. "smoke", "regression"',
|
|
92
|
+
nargs: 1,
|
|
93
|
+
type: 'string',
|
|
92
94
|
});
|
|
93
95
|
};
|
|
94
96
|
exports.handler = (0, util_1.failWrapper)(launchTrainingSession);
|
|
@@ -108,6 +110,7 @@ async function launchTrainingSession(parsed) {
|
|
|
108
110
|
const planId = parsed[constants_1.CommandArgPlanId];
|
|
109
111
|
const labels = parsed[constants_1.CommandArgLabels];
|
|
110
112
|
const dataTableIds = parsed[constants_1.CommandArgDataTables];
|
|
113
|
+
const intent = parsed[constants_1.CommandArgIntent];
|
|
111
114
|
const trainingSessionOptions = {
|
|
112
115
|
applicationId,
|
|
113
116
|
autoBranch,
|
|
@@ -117,6 +120,7 @@ async function launchTrainingSession(parsed) {
|
|
|
117
120
|
dataTableIds,
|
|
118
121
|
environmentId,
|
|
119
122
|
height,
|
|
123
|
+
intent,
|
|
120
124
|
labels,
|
|
121
125
|
planId,
|
|
122
126
|
testDescription,
|
|
@@ -8,6 +8,7 @@ const constants_1 = require("../../constants");
|
|
|
8
8
|
const loggingProvider_1 = require("../../../providers/logging/loggingProvider");
|
|
9
9
|
const fileUtil_1 = require("../../commandUtil/fileUtil");
|
|
10
10
|
const execution_1 = require("../../../execution");
|
|
11
|
+
const ApiTestUtils_1 = require("../../../core/execution/ApiTestUtils");
|
|
11
12
|
const chalk = require('chalk');
|
|
12
13
|
const os = require('os');
|
|
13
14
|
const JSON_REPLACER = null;
|
|
@@ -28,6 +29,7 @@ exports.builder = (yargs) => {
|
|
|
28
29
|
constants_1.OutputFormats.Yaml,
|
|
29
30
|
constants_1.OutputFormats.Csv,
|
|
30
31
|
constants_1.OutputFormats.Playwright,
|
|
32
|
+
constants_1.OutputFormats.Postman,
|
|
31
33
|
constants_1.OutputFormats.SeleniumIde,
|
|
32
34
|
],
|
|
33
35
|
})
|
|
@@ -65,7 +67,7 @@ async function exportTest(parsed) {
|
|
|
65
67
|
const branchName = parsed['mabl-branch'] ?? constants_1.DefaultBranchName;
|
|
66
68
|
const journey = await apiClient.getJourney(testId, branchName, format);
|
|
67
69
|
if (journey.test_type === mablApi_1.TestTypeEnum.Performance) {
|
|
68
|
-
throw new Error('Export functionality is not
|
|
70
|
+
throw new Error('Export functionality is not available for performance tests.');
|
|
69
71
|
}
|
|
70
72
|
const flowArray = await (0, util_1.getJourneyFlowArray)(journey, apiClient, branchName);
|
|
71
73
|
if (flowArray
|
|
@@ -89,6 +91,11 @@ async function exportTest(parsed) {
|
|
|
89
91
|
throw new Error('Playwright tests can only be exported for browser tests.');
|
|
90
92
|
}
|
|
91
93
|
return dumpToPlaywrightTest(journey, flowArray, apiClient, fileName, environmentId);
|
|
94
|
+
case constants_1.OutputFormats.Postman:
|
|
95
|
+
if (journey.test_type !== mablApi_1.TestTypeEnum.Api) {
|
|
96
|
+
throw new Error('Only API tests can be exported as Postman collections.');
|
|
97
|
+
}
|
|
98
|
+
return dumpToPostmanCollection(journey, flowArray, apiClient);
|
|
92
99
|
case constants_1.OutputFormats.Json:
|
|
93
100
|
case constants_1.OutputFormats.Yaml:
|
|
94
101
|
default:
|
|
@@ -122,6 +129,10 @@ async function dumpToPlaywrightTest(journey, flows, apiClient, fileName, environ
|
|
|
122
129
|
const test = generator.generateTest();
|
|
123
130
|
return (0, fileUtil_1.writeExportedEntityToFile)(test, 'spec.ts', journey.id, fileName);
|
|
124
131
|
}
|
|
132
|
+
async function dumpToPostmanCollection(test, flows, apiClient, fileName) {
|
|
133
|
+
const collection = await (0, ApiTestUtils_1.exportPostmanTestAsCollection)(test, flows, (snippetInvariantId) => apiClient.getSnippet(snippetInvariantId));
|
|
134
|
+
return (0, fileUtil_1.writeExportedEntityToFile)(JSON.stringify(collection, JSON_REPLACER, 2), 'json', test.id, fileName);
|
|
135
|
+
}
|
|
125
136
|
function dumpYamlOrJsonToFile(type, journey, flows, detailLevel, fileName) {
|
|
126
137
|
const journeyConfig = new execution_1.JourneyConfig(journey, flows, false);
|
|
127
138
|
const configGenerated = detailLevel === constants_1.DetailLevelFormats.Full
|
|
@@ -72,6 +72,10 @@ exports.postmanAuthToApiTestAuth = postmanAuthToApiTestAuth;
|
|
|
72
72
|
exports.postmanEventToExecutableSnippets = postmanEventToExecutableSnippets;
|
|
73
73
|
exports.getSnippetReferencesInCollection = getSnippetReferencesInCollection;
|
|
74
74
|
exports.getSnippetReferencesInTest = getSnippetReferencesInTest;
|
|
75
|
+
exports.fetchSnippetsForApiTestAndFlows = fetchSnippetsForApiTestAndFlows;
|
|
76
|
+
exports.exportPostmanTestAsCollection = exportPostmanTestAsCollection;
|
|
77
|
+
exports.exportPostmanFlowAsCollection = exportPostmanFlowAsCollection;
|
|
78
|
+
exports.insertTestVariablesIntoFlow = insertTestVariablesIntoFlow;
|
|
75
79
|
const newman_types_1 = require("./newman-types");
|
|
76
80
|
const uuid_1 = require("uuid");
|
|
77
81
|
const mablApi_1 = require("../../mablApi");
|
|
@@ -1338,3 +1342,71 @@ function getSnippetReferencesInTest(test) {
|
|
|
1338
1342
|
snippetType: mablApi_1.SnippetTypeEnum.Postman,
|
|
1339
1343
|
}));
|
|
1340
1344
|
}
|
|
1345
|
+
async function fetchSnippetsForApiTestAndFlows(test, flows, getSnippet) {
|
|
1346
|
+
const snippetReferencesInFlows = flows
|
|
1347
|
+
.flatMap((flow) => flow.snippet_references)
|
|
1348
|
+
.filter((reference) => reference)
|
|
1349
|
+
.map((reference) => reference);
|
|
1350
|
+
const snippetReferencesInTest = getSnippetReferencesInTest(test);
|
|
1351
|
+
const snippetReferences = snippetReferencesInFlows.concat(snippetReferencesInTest);
|
|
1352
|
+
const snippetPromises = snippetReferences.map(async ({ id }) => getSnippet(id));
|
|
1353
|
+
const snippets = (await Promise.all(snippetPromises)).reduce((snippetsById, snippet) => {
|
|
1354
|
+
snippetsById[snippet.invariant_id] = snippet;
|
|
1355
|
+
return snippetsById;
|
|
1356
|
+
}, {});
|
|
1357
|
+
return snippets;
|
|
1358
|
+
}
|
|
1359
|
+
async function exportPostmanTestAsCollection(test, flows, getSnippet) {
|
|
1360
|
+
const flowInvariantIdToFlow = flows.reduce((mappings, flow) => {
|
|
1361
|
+
mappings[flow.invariant_id] = flow;
|
|
1362
|
+
return mappings;
|
|
1363
|
+
}, {});
|
|
1364
|
+
const collection = wrapItemsInCollection(test.name ?? test.invariant_id ?? test.id ?? 'mabl API Test', await Promise.all(test.flows
|
|
1365
|
+
?.map((id) => id.split(':')[0])
|
|
1366
|
+
.map((invariant) => flowInvariantIdToFlow[invariant])
|
|
1367
|
+
.map((flow) => exportPostmanFlow(flow, getSnippet, test)) ?? []));
|
|
1368
|
+
return collection;
|
|
1369
|
+
}
|
|
1370
|
+
async function exportPostmanFlowAsCollection(flow, getSnippet, test) {
|
|
1371
|
+
const collection = wrapItemsInCollection(flow.description ?? flow.invariant_id ?? flow.id ?? 'mabl API Flow', [await exportPostmanFlow(flow, getSnippet, test)]);
|
|
1372
|
+
return collection;
|
|
1373
|
+
}
|
|
1374
|
+
async function exportPostmanFlow(flow, getSnippet, test) {
|
|
1375
|
+
const apiSteps = flow.api_steps;
|
|
1376
|
+
processPostmanItems(apiSteps?.item, (item) => {
|
|
1377
|
+
processPostmanItem(item);
|
|
1378
|
+
if (!item.name) {
|
|
1379
|
+
item.name = `${item.request?.method} ${item.request?.url?.host.join('.')}/${item.request?.url?.path.join('/')}`;
|
|
1380
|
+
}
|
|
1381
|
+
});
|
|
1382
|
+
if (test) {
|
|
1383
|
+
insertTestConfigurationIntoFlow(test, flow);
|
|
1384
|
+
insertTestVariablesIntoFlow(test, flow);
|
|
1385
|
+
}
|
|
1386
|
+
const snippets = await fetchSnippetsForApiTestAndFlows(test ?? {}, [flow], getSnippet);
|
|
1387
|
+
const idToSnippet = (id) => snippets[id];
|
|
1388
|
+
insertMablScriptsIntoCollection(apiSteps, idToSnippet);
|
|
1389
|
+
return apiSteps.item;
|
|
1390
|
+
}
|
|
1391
|
+
function insertTestVariablesIntoFlow(test, flow) {
|
|
1392
|
+
const testVariables = test.variables?.inputs ?? [];
|
|
1393
|
+
flow.api_steps.variable = testVariables.map(convertTestVariableToCollectionVariable);
|
|
1394
|
+
}
|
|
1395
|
+
function convertTestVariableToCollectionVariable(variable) {
|
|
1396
|
+
return {
|
|
1397
|
+
key: variable.name,
|
|
1398
|
+
value: variable.default_value,
|
|
1399
|
+
};
|
|
1400
|
+
}
|
|
1401
|
+
function wrapItemsInCollection(name, items) {
|
|
1402
|
+
const flattenedItems = items
|
|
1403
|
+
.flatMap((item) => item.item ?? item)
|
|
1404
|
+
.filter((item) => item);
|
|
1405
|
+
return {
|
|
1406
|
+
info: {
|
|
1407
|
+
name,
|
|
1408
|
+
schema: 'https://schema.getpostman.com/json/collection/v2.1.0/collection.json',
|
|
1409
|
+
},
|
|
1410
|
+
item: flattenedItems,
|
|
1411
|
+
};
|
|
1412
|
+
}
|
|
@@ -25,7 +25,7 @@ var ElectronProtocolUrl;
|
|
|
25
25
|
async function trainNewTest(trainingSessionOptions) {
|
|
26
26
|
const apiClient = await (0, util_1.getApiClientFromOptions)(trainingSessionOptions, true);
|
|
27
27
|
const branchName = trainingSessionOptions.branchName ?? constants_1.DefaultBranchName;
|
|
28
|
-
const { authToken, autoBranch, dataTableIds, ...passThroughFields } = trainingSessionOptions;
|
|
28
|
+
const { authToken, autoBranch, dataTableIds, intent: testIntent, ...passThroughFields } = trainingSessionOptions;
|
|
29
29
|
const { applicationId, autoLogin, credentialsId, environmentId, height, planId, testDescription, testName, url, width, workspaceId, } = passThroughFields;
|
|
30
30
|
if (branchName !== 'master') {
|
|
31
31
|
await (0, branches_1.checkBranchNameAndAutoBranchMaybe)(workspaceId, apiClient, branchName, autoBranch);
|
|
@@ -68,6 +68,7 @@ async function trainNewTest(trainingSessionOptions) {
|
|
|
68
68
|
dataTables: dataTableIds,
|
|
69
69
|
flows,
|
|
70
70
|
height: height ?? exports.DEFAULT_HEIGHT,
|
|
71
|
+
testIntent,
|
|
71
72
|
sender: exports.SENDER,
|
|
72
73
|
width: width ?? exports.DEFAULT_WIDTH,
|
|
73
74
|
};
|