@mablhq/mabl-cli 1.12.20 → 1.13.14
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 +21 -11
- package/api/mablApiClient.js +9 -9
- package/api/mablApiClientFactory.js +1 -0
- package/auth/AuthClient.js +1 -4
- package/browserLauncher/browserLauncherFactory.js +7 -3
- package/browserLauncher/playwrightBrowserLauncher/playwrightBrowser.js +6 -2
- package/browserLauncher/playwrightBrowserLauncher/playwrightBrowserLauncher.js +1 -0
- package/browserLauncher/playwrightBrowserLauncher/playwrightDom.js +61 -21
- package/browserLauncher/playwrightBrowserLauncher/playwrightFrame.js +24 -17
- package/browserLauncher/playwrightBrowserLauncher/playwrightHttpResponse.js +3 -0
- package/browserLauncher/playwrightBrowserLauncher/playwrightPage.js +72 -68
- package/browserLauncher/playwrightBrowserLauncher/wrappers.js +1 -1
- package/browserLauncher/puppeteerBrowserLauncher/puppeteerBrowser.js +7 -3
- package/browserLauncher/puppeteerBrowserLauncher/puppeteerElementHandle.js +13 -7
- package/browserLauncher/puppeteerBrowserLauncher/puppeteerFrame.js +7 -7
- package/browserLauncher/puppeteerBrowserLauncher/puppeteerHttpRequest.js +1 -1
- package/browserLauncher/puppeteerBrowserLauncher/puppeteerHttpResponse.js +4 -1
- package/browserLauncher/puppeteerBrowserLauncher/puppeteerJsHandle.js +3 -3
- package/browserLauncher/puppeteerBrowserLauncher/puppeteerPage.js +23 -16
- package/browserLauncher/puppeteerBrowserLauncher/wrappers.js +1 -1
- package/browserLauncher/types.js +6 -1
- package/cli.js +6 -4
- package/commands/applications/applications_cmds/list.js +1 -1
- package/commands/branches/branches_cmds/create.js +1 -1
- package/commands/branches/branches_cmds/list.js +1 -1
- package/commands/branches/branches_cmds/merge.js +1 -1
- package/commands/commandUtil/awaitCompletion.js +2 -2
- package/commands/commandUtil/codeInsights.js +6 -6
- package/commands/commandUtil/fileUtil.js +1 -1
- package/commands/commandUtil/util.js +12 -12
- package/commands/config/config_cmds/list.js +1 -1
- package/commands/constants.js +1 -1
- package/commands/credentials/credentials_cmds/list.js +1 -1
- package/commands/deploy/deploy_cmds/create.js +2 -2
- package/commands/deploy/deploy_cmds/executionResultPresenter.js +7 -7
- package/commands/deploy/deploy_cmds/list.js +1 -1
- package/commands/environments/environments_cmds/create.js +3 -3
- package/commands/environments/environments_cmds/list.js +1 -1
- package/commands/environments/environments_cmds/urls_cmds/add.js +1 -1
- package/commands/flows/flows_cmds/list.js +1 -1
- package/commands/plans/plans_cmds/list.js +1 -1
- package/commands/test-runs/test-runs_cmds/export.js +1 -1
- package/commands/tests/executionUtil.js +1 -1
- package/commands/tests/testsUtil.js +16 -20
- package/commands/tests/tests_cmds/edit.js +1 -1
- package/commands/tests/tests_cmds/export.js +1 -1
- package/commands/tests/tests_cmds/import.js +13 -13
- package/commands/tests/tests_cmds/list.js +2 -2
- package/commands/tests/tests_cmds/run-alpha.js +1 -1
- package/commands/tests/tests_cmds/run-cloud.js +7 -7
- package/commands/tests/tests_cmds/run-legacy.js +2 -2
- package/commands/tests/tests_cmds/run.js +25 -7
- package/commands/workspaces/workspace_cmds/copy.js +1 -1
- package/commands/workspaces/workspace_cmds/list.js +1 -1
- package/configGenerators/flowConfigGenerator.js +3 -3
- package/configGenerators/selIdeGenerator.js +1 -1
- package/configGenerators/testConfigGenerator.js +7 -8
- package/core/execution/ApiTestUtils.js +2 -2
- package/core/trainer/openUtils.js +47 -0
- package/core/trainer/trainingSessions.js +36 -61
- package/env/defaultEnv.js +2 -1
- package/env/dev.js +2 -1
- package/env/env.js +3 -1
- package/env/local.js +2 -1
- package/env/prod.js +2 -1
- package/execution/index.js +1 -1
- package/execution/index.js.LICENSE.txt +12 -0
- package/index.d.ts +7 -0
- package/mablApi/index.js +1 -1
- package/mablscript/MablStep.js +11 -7
- package/mablscript/actions/ConditionAction.js +2 -4
- package/mablscript/actions/FindAction.js +4 -4
- package/mablscript/importer.js +16 -14
- package/mablscript/steps/AccessibilityCheck.js +88 -0
- package/mablscript/steps/AssertStep.js +6 -5
- package/mablscript/steps/CreateVariableStep.js +2 -3
- package/mablscript/steps/DownloadStep.js +1 -2
- package/mablscript/steps/EnterTextStep.js +2 -1
- package/mablscript/steps/IfConditionStep.js +3 -3
- package/mablscript/steps/SendHttpRequestStep.js +11 -3
- package/mablscript/steps/SendKeyStep.js +2 -2
- package/mablscript/steps/SetFilesStep.js +1 -1
- package/mablscript/steps/SwitchContextStep.js +2 -1
- package/mablscript/types/AccessibilityCheckStepDescriptor.js +2 -0
- package/mablscript/types/AccessibilityCheckTypes.js +9 -0
- package/mablscript/types/VariableDataType.js +1 -8
- package/mablscript/types/VariableNamespace.js +1 -1
- package/mablscriptFind/index.js +1 -1
- package/package.json +8 -5
- package/popupDismissal/index.js +16 -17
- package/providers/authenticationProvider.js +2 -3
- package/providers/cliConfigProvider.js +1 -1
- package/providers/exportRequestProvider.js +1 -1
- package/providers/logging/loggingProvider.js +2 -2
- package/providers/scmContextProvider.js +1 -1
- package/reporters/mochAwesome/mochAwesomeReporter.js +10 -6
- package/reporters/reporter.js +1 -1
- package/resources/mablFind.js +1 -1
- package/resources/popupDismissal.js +1 -1
- package/util/RichPromise.js +2 -2
- package/util/actionabilityUtil.js +36 -7
- package/util/asyncUtil.js +45 -0
- package/util/downloadUtil.js +1 -1
- package/util/logUtils.js +20 -1
- package/util/markdownUtil.js +3 -3
- package/util/pureUtil.js +6 -6
- package/util/resourceUtil.js +18 -1
- package/core/trainer/trainerBrowserUtil.js +0 -33
|
@@ -60,7 +60,7 @@ exports.builder = (yargs) => {
|
|
|
60
60
|
nargs: 1,
|
|
61
61
|
type: 'string',
|
|
62
62
|
})
|
|
63
|
-
.check(argv => testsUtil_1.validateRunEditCommand(argv[constants_1.CommandArgId], argv[constants_1.CommandArgTestRunId]));
|
|
63
|
+
.check((argv) => testsUtil_1.validateRunEditCommand(argv[constants_1.CommandArgId], argv[constants_1.CommandArgTestRunId]));
|
|
64
64
|
};
|
|
65
65
|
exports.handler = util_1.failWrapper(runLegacy);
|
|
66
66
|
async function runLegacy(parsed) {
|
|
@@ -87,7 +87,7 @@ async function runLegacy(parsed) {
|
|
|
87
87
|
const flowArray = await util_1.getJourneyFlowArray(test, apiClient, branchName);
|
|
88
88
|
const finalUrl = testsUtil_1.getFinalUrl(test, url);
|
|
89
89
|
if (flowArray
|
|
90
|
-
.map(flow => flow.flow_type === mablApi_1.Flow.FlowTypeEnum.Mablscript)
|
|
90
|
+
.map((flow) => flow.flow_type === mablApi_1.Flow.FlowTypeEnum.Mablscript)
|
|
91
91
|
.includes(false)) {
|
|
92
92
|
loggingProvider_1.logger.info(chalk_1.default.red('Default mabl tests are not supported for local runs yet including any test with an auto login flow'));
|
|
93
93
|
return 'error';
|
|
@@ -145,20 +145,37 @@ exports.builder = (yargs) => {
|
|
|
145
145
|
describe: 'Enable browser extensions on [Chrome]',
|
|
146
146
|
default: false,
|
|
147
147
|
type: 'boolean',
|
|
148
|
+
})
|
|
149
|
+
.option(constants_1.CommandArgHttpHeaders, {
|
|
150
|
+
describe: 'Space delimited HTTP headers added to browser requests (e.g. "x-header:foo")',
|
|
151
|
+
type: 'array',
|
|
148
152
|
})
|
|
149
153
|
.option(constants_1.CommandArgTestInteractionSpeed, {
|
|
150
154
|
describe: 'Set the speed that mabl interacts with webpages. Overrides test run settings if specified.',
|
|
151
155
|
type: 'string',
|
|
152
|
-
choices: Object.keys(mablApi_1.JourneyParameters.PageLoadWaitEnum).map(pageLoadWait => pageLoadWait.toLowerCase()),
|
|
153
|
-
})
|
|
154
|
-
.check((argv) =>
|
|
156
|
+
choices: Object.keys(mablApi_1.JourneyParameters.PageLoadWaitEnum).map((pageLoadWait) => pageLoadWait.toLowerCase()),
|
|
157
|
+
})
|
|
158
|
+
.check((argv) => {
|
|
159
|
+
testsUtil_1.validateRunCommandWithLabels(argv[constants_1.CommandArgId], argv[constants_1.CommandArgLabelsInclude], argv[constants_1.CommandArgLabelsExclude], argv[constants_1.CommandArgTestRunId], argv[constants_1.CommandArgFromPlanId], true, argv[constants_1.CommandArgTestFile]);
|
|
160
|
+
const httpHeaders = argv[constants_1.CommandArgHttpHeaders];
|
|
161
|
+
util_1.validateArrayInputs(httpHeaders, 'HTTP headers must be SPACE delimited, e.g. "--http-headers "foo:bar" "baz:qux"');
|
|
162
|
+
argv[constants_1.CommandArgHttpHeaders] = util_1.validateValuePairInputs('HTTP header', httpHeaders);
|
|
163
|
+
return true;
|
|
164
|
+
});
|
|
155
165
|
};
|
|
156
166
|
const exitCodeOnError = 1;
|
|
157
167
|
exports.handler = util_1.failWrapper(run, exitCodeOnError);
|
|
158
168
|
async function run(parsed) {
|
|
159
|
-
var _a, _b;
|
|
169
|
+
var _a, _b, _c;
|
|
160
170
|
const commandStartTime = Date.now();
|
|
161
171
|
const workspaceId = (_a = parsed['workspace-id']) !== null && _a !== void 0 ? _a : (_b = cliConfigProvider_1.CliConfigProvider.getWorkspace()) === null || _b === void 0 ? void 0 : _b.id;
|
|
172
|
+
const extraHttpHeaders = {};
|
|
173
|
+
((_c = parsed['http-headers']) !== null && _c !== void 0 ? _c : []).forEach((header) => {
|
|
174
|
+
const headerParts = header.split(':');
|
|
175
|
+
if (headerParts.length === 2 && headerParts[0] && headerParts[1]) {
|
|
176
|
+
extraHttpHeaders[headerParts[0].toLowerCase()] = headerParts[1];
|
|
177
|
+
}
|
|
178
|
+
});
|
|
162
179
|
const testRunnerConfig = {
|
|
163
180
|
_cliCreated: true,
|
|
164
181
|
branchName: parsed['mabl-branch'],
|
|
@@ -174,6 +191,7 @@ async function run(parsed) {
|
|
|
174
191
|
ignoreCertificateErrors: parsed[constants_1.CommandArgBrowserIgnoreCertificateErrors],
|
|
175
192
|
interactionSpeed: parsed[constants_1.CommandArgTestInteractionSpeed],
|
|
176
193
|
enableExtensions: parsed[constants_1.CommandArgBrowserEnableExtensions],
|
|
194
|
+
extraHttpHeaders,
|
|
177
195
|
keepBrowserOpen: parsed['keep-browser-open'],
|
|
178
196
|
labelsExclude: parsed['exclude-labels'],
|
|
179
197
|
labelsInclude: parsed.labels,
|
|
@@ -192,7 +210,7 @@ async function run(parsed) {
|
|
|
192
210
|
loggingProvider_1.logger.info(`Test count: ${results.numTotalTests}`);
|
|
193
211
|
loggingProvider_1.logger.info(`Passed: ${results.numPassedTests}`);
|
|
194
212
|
if (results.numPassedTests) {
|
|
195
|
-
results.testResults.forEach(result => {
|
|
213
|
+
results.testResults.forEach((result) => {
|
|
196
214
|
if (result.status === 'passed') {
|
|
197
215
|
loggingProvider_1.logger.info(` - ${result.testName} (${testsUtil_1.calculateTotalTimeSeconds(result.startTime, result.endTime)}s)`);
|
|
198
216
|
}
|
|
@@ -200,7 +218,7 @@ async function run(parsed) {
|
|
|
200
218
|
}
|
|
201
219
|
loggingProvider_1.logger.info(`Skipped: ${results.numSkippedTests}`);
|
|
202
220
|
if (results.numSkippedTests) {
|
|
203
|
-
results.testResults.forEach(result => {
|
|
221
|
+
results.testResults.forEach((result) => {
|
|
204
222
|
if (result.status === 'skipped') {
|
|
205
223
|
loggingProvider_1.logger.info(chalk.yellow(` - ${result.testName}`));
|
|
206
224
|
}
|
|
@@ -208,7 +226,7 @@ async function run(parsed) {
|
|
|
208
226
|
}
|
|
209
227
|
loggingProvider_1.logger.info(`Failed: ${results.numFailedTests}`);
|
|
210
228
|
if (results.numFailedTests) {
|
|
211
|
-
results.testResults.forEach(result => {
|
|
229
|
+
results.testResults.forEach((result) => {
|
|
212
230
|
if (result.status === 'failed') {
|
|
213
231
|
loggingProvider_1.logger.info(chalk.red(` - ${result.testName} (${testsUtil_1.calculateTotalTimeSeconds(result.startTime, result.endTime)}s)`));
|
|
214
232
|
}
|
|
@@ -33,7 +33,7 @@ function getTimestamp() {
|
|
|
33
33
|
}
|
|
34
34
|
function hasOwnerRoleInWorkspace(user, workspaceId) {
|
|
35
35
|
var _a;
|
|
36
|
-
const hasOwnerRole = (_a = user.roles) === null || _a === void 0 ? void 0 : _a.some(role => role.organization_id === workspaceId &&
|
|
36
|
+
const hasOwnerRole = (_a = user.roles) === null || _a === void 0 ? void 0 : _a.some((role) => role.organization_id === workspaceId &&
|
|
37
37
|
role.role === mablApi_1.UserRole.RoleEnum.Owner);
|
|
38
38
|
if (!hasOwnerRole) {
|
|
39
39
|
loggingProvider_1.logger.warn(chalk_1.default.yellow(`You must be an owner in both workspaces to copy. You do not have owner permissions in workspace: ${workspaceId}`));
|
|
@@ -47,7 +47,7 @@ function printWorkspaces(workspaces, output) {
|
|
|
47
47
|
head: ['ID', 'Name', 'Created time'],
|
|
48
48
|
wordWrap: true,
|
|
49
49
|
});
|
|
50
|
-
workspaces.forEach(workspace => {
|
|
50
|
+
workspaces.forEach((workspace) => {
|
|
51
51
|
table.push([
|
|
52
52
|
{ rowSpan: 1, content: workspace.id, vAlign: 'center' },
|
|
53
53
|
{ rowSpan: 1, content: workspace.name, vAlign: 'center' },
|
|
@@ -19,7 +19,7 @@ class FlowConfig {
|
|
|
19
19
|
flowConfig.workspaceId = this.flow.organization_id;
|
|
20
20
|
flowConfig.reusable = this.flow.reusable;
|
|
21
21
|
const loadedSteps = importer_1.parseMablScriptIntoSteps(this.flow);
|
|
22
|
-
flowConfig.steps = loadedSteps.map(step => step.getFormattedStep(this.includeLocatorInfo));
|
|
22
|
+
flowConfig.steps = loadedSteps.map((step) => step.getFormattedStep(this.includeLocatorInfo));
|
|
23
23
|
return flowConfig;
|
|
24
24
|
}
|
|
25
25
|
generateSimpleFormat() {
|
|
@@ -42,7 +42,7 @@ class FlowConfig {
|
|
|
42
42
|
}
|
|
43
43
|
static generateStepsSimpleFormat(suppliedSteps) {
|
|
44
44
|
const steps = [];
|
|
45
|
-
suppliedSteps.forEach(step => {
|
|
45
|
+
suppliedSteps.forEach((step) => {
|
|
46
46
|
var _a, _b, _c, _d;
|
|
47
47
|
const stepName = Object.keys(step)[0];
|
|
48
48
|
const stepObj = step;
|
|
@@ -72,7 +72,7 @@ class FlowConfig {
|
|
|
72
72
|
' ,Step Number, Step Type, Description, Annotation, Note',
|
|
73
73
|
];
|
|
74
74
|
let count = 0;
|
|
75
|
-
flowConfig.steps.forEach(step => {
|
|
75
|
+
flowConfig.steps.forEach((step) => {
|
|
76
76
|
var _a, _b;
|
|
77
77
|
const stepName = Object.keys(step)[0];
|
|
78
78
|
const stepObj = step;
|
|
@@ -15,7 +15,7 @@ class SelIdeConfig {
|
|
|
15
15
|
selIdeTest.id = SeleniumIdeStep_1.generateIdForSeleniumEntity(this.journey.id + 'test');
|
|
16
16
|
selIdeTest.name = (_a = this.journey.name) !== null && _a !== void 0 ? _a : '';
|
|
17
17
|
let steps = [];
|
|
18
|
-
this.flows.forEach(flow => {
|
|
18
|
+
this.flows.forEach((flow) => {
|
|
19
19
|
const loadedSteps = importer_1.parseMablScriptIntoSteps(flow);
|
|
20
20
|
steps = steps.concat(loadedSteps);
|
|
21
21
|
});
|
|
@@ -18,9 +18,9 @@ class JourneyConfig {
|
|
|
18
18
|
journeyConfig.name = this.journey.name;
|
|
19
19
|
journeyConfig.description = this.journey.description;
|
|
20
20
|
journeyConfig.tags = this.journey.tags;
|
|
21
|
-
journeyConfig.labels = (_a = this.journey.labels) === null || _a === void 0 ? void 0 : _a.map(label => label.name);
|
|
21
|
+
journeyConfig.labels = (_a = this.journey.labels) === null || _a === void 0 ? void 0 : _a.map((label) => label.name);
|
|
22
22
|
journeyConfig.dataTables = this.journey.datatables;
|
|
23
|
-
journeyConfig.flows = this.flows.map(flow => {
|
|
23
|
+
journeyConfig.flows = this.flows.map((flow) => {
|
|
24
24
|
const flowConfigGenerator = new flowConfigGenerator_1.FlowConfig(flow, this.includeLocatorInfo);
|
|
25
25
|
return flowConfigGenerator.generateConfigFile();
|
|
26
26
|
});
|
|
@@ -31,7 +31,7 @@ class JourneyConfig {
|
|
|
31
31
|
const config = this.generateConfigFile();
|
|
32
32
|
let steps = [];
|
|
33
33
|
let apiSteps;
|
|
34
|
-
config.flows.forEach(flow => {
|
|
34
|
+
config.flows.forEach((flow) => {
|
|
35
35
|
if (flow.api_steps) {
|
|
36
36
|
apiSteps = flow.api_steps;
|
|
37
37
|
}
|
|
@@ -54,14 +54,13 @@ class JourneyConfig {
|
|
|
54
54
|
' ,Step Number, Step Type, Description, Annotation, Note',
|
|
55
55
|
];
|
|
56
56
|
let count = 0;
|
|
57
|
-
config.flows.forEach(flow => {
|
|
58
|
-
flow.steps.forEach(step => {
|
|
57
|
+
config.flows.forEach((flow) => {
|
|
58
|
+
flow.steps.forEach((step) => {
|
|
59
59
|
var _a, _b;
|
|
60
60
|
const stepName = Object.keys(step)[0];
|
|
61
61
|
const stepObj = step;
|
|
62
62
|
const mablStep = stepObj[stepName];
|
|
63
|
-
output.push(`${count}, ${stepName}, ${mablStep.description}, ${((_a = mablStep === null || mablStep === void 0 ? void 0 : mablStep.annotation) === null || _a === void 0 ? void 0 : _a.note) || '-'}, ${((_b = mablStep === null || mablStep === void 0 ? void 0 : mablStep.annotation) === null || _b === void 0 ? void 0 : _b.description) ||
|
|
64
|
-
'-'}`);
|
|
63
|
+
output.push(`${count}, ${stepName}, ${mablStep.description}, ${((_a = mablStep === null || mablStep === void 0 ? void 0 : mablStep.annotation) === null || _a === void 0 ? void 0 : _a.note) || '-'}, ${((_b = mablStep === null || mablStep === void 0 ? void 0 : mablStep.annotation) === null || _b === void 0 ? void 0 : _b.description) || '-'}`);
|
|
65
64
|
count += 1;
|
|
66
65
|
});
|
|
67
66
|
});
|
|
@@ -70,7 +69,7 @@ class JourneyConfig {
|
|
|
70
69
|
}
|
|
71
70
|
exports.JourneyConfig = JourneyConfig;
|
|
72
71
|
function convertUndefined(mablObjectConfigFile) {
|
|
73
|
-
Object.keys(mablObjectConfigFile).forEach(key => {
|
|
72
|
+
Object.keys(mablObjectConfigFile).forEach((key) => {
|
|
74
73
|
if (mablObjectConfigFile[key] === undefined) {
|
|
75
74
|
mablObjectConfigFile[key] = null;
|
|
76
75
|
}
|
|
@@ -5,14 +5,14 @@ function deduplicateApiTestExecutionResults(postmanResult) {
|
|
|
5
5
|
var _a;
|
|
6
6
|
const executionsById = {};
|
|
7
7
|
const orderedExecutionIds = [];
|
|
8
|
-
(_a = postmanResult.run.executions) === null || _a === void 0 ? void 0 : _a.forEach(execution => {
|
|
8
|
+
(_a = postmanResult.run.executions) === null || _a === void 0 ? void 0 : _a.forEach((execution) => {
|
|
9
9
|
const executionId = execution.id;
|
|
10
10
|
if (!executionsById[executionId]) {
|
|
11
11
|
orderedExecutionIds.push(executionId);
|
|
12
12
|
}
|
|
13
13
|
executionsById[executionId] = execution;
|
|
14
14
|
});
|
|
15
|
-
postmanResult.run.executions = orderedExecutionIds.map(executionId => executionsById[executionId]);
|
|
15
|
+
postmanResult.run.executions = orderedExecutionIds.map((executionId) => executionsById[executionId]);
|
|
16
16
|
return postmanResult;
|
|
17
17
|
}
|
|
18
18
|
exports.deduplicateApiTestExecutionResults = deduplicateApiTestExecutionResults;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.logSessionStarted = exports.openUrlInDesktopApp = void 0;
|
|
7
|
+
const querystring_1 = __importDefault(require("querystring"));
|
|
8
|
+
const open_1 = __importDefault(require("open"));
|
|
9
|
+
const env_1 = require("../../env/env");
|
|
10
|
+
const timers_1 = require("timers");
|
|
11
|
+
const messaging_1 = require("../messaging/messaging");
|
|
12
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
13
|
+
async function openUrlInDesktopApp(url, trainingSessionOptions) {
|
|
14
|
+
const params = querystring_1.default.stringify({ ...trainingSessionOptions });
|
|
15
|
+
const childProcess = await open_1.default(`${env_1.ELECTRON_PROTOCOL}://${url}/${params}`);
|
|
16
|
+
let childProcessExited = false;
|
|
17
|
+
const keepAliveUntilExited = () => {
|
|
18
|
+
if (!childProcessExited) {
|
|
19
|
+
timers_1.setTimeout(keepAliveUntilExited, 1000);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
keepAliveUntilExited();
|
|
23
|
+
const exitCode = await new Promise((resolve) => {
|
|
24
|
+
childProcess.on('error', () => {
|
|
25
|
+
childProcessExited = true;
|
|
26
|
+
resolve(1);
|
|
27
|
+
});
|
|
28
|
+
childProcess.on('exit', function () {
|
|
29
|
+
childProcessExited = true;
|
|
30
|
+
resolve(childProcess.exitCode);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
if (exitCode === 0) {
|
|
34
|
+
logSessionStarted();
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
logInstallDesktopApp();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.openUrlInDesktopApp = openUrlInDesktopApp;
|
|
41
|
+
function logSessionStarted() {
|
|
42
|
+
messaging_1.mablEventEmitter.log(chalk_1.default.yellowBright('Session started in the desktop app'));
|
|
43
|
+
}
|
|
44
|
+
exports.logSessionStarted = logSessionStarted;
|
|
45
|
+
function logInstallDesktopApp() {
|
|
46
|
+
messaging_1.mablEventEmitter.log(chalk_1.default.red(`\nFailed to launch mabl desktop app!`, chalk_1.default.cyan(`\nPlease check your installation or download and install it from`), chalk_1.default.magenta('https://www.mabl.com/desktop-app')));
|
|
47
|
+
}
|
|
@@ -1,50 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.editTest = exports.trainNewTest = void 0;
|
|
4
|
-
const authenticationProvider_1 = require("../../providers/authenticationProvider");
|
|
3
|
+
exports.editTest = exports.trainNewTest = exports.ElectronProtocolUrl = void 0;
|
|
5
4
|
const branches_1 = require("../../commands/commandUtil/branches");
|
|
6
5
|
const testsUtil_1 = require("../../commands/tests/testsUtil");
|
|
7
|
-
const trainerBrowserUtil_1 = require("./trainerBrowserUtil");
|
|
8
|
-
const util_1 = require("../../commands/commandUtil/util");
|
|
9
6
|
const constants_1 = require("../../commands/constants");
|
|
10
|
-
const
|
|
11
|
-
const
|
|
7
|
+
const util_1 = require("../util");
|
|
8
|
+
const openUtils_1 = require("./openUtils");
|
|
9
|
+
const util_2 = require("../../commands/commandUtil/util");
|
|
10
|
+
var ElectronProtocolUrl;
|
|
11
|
+
(function (ElectronProtocolUrl) {
|
|
12
|
+
ElectronProtocolUrl["EDIT_TEST"] = "editTest";
|
|
13
|
+
ElectronProtocolUrl["TRAIN_NEW_TEST"] = "trainNewTest";
|
|
14
|
+
})(ElectronProtocolUrl = exports.ElectronProtocolUrl || (exports.ElectronProtocolUrl = {}));
|
|
12
15
|
async function trainNewTest(trainingSessionOptions) {
|
|
13
|
-
var _a
|
|
14
|
-
|
|
15
|
-
const authConfig = await new authenticationProvider_1.AuthenticationProvider().getAuthConfigWithAutoRenew();
|
|
16
|
-
const apiClient = await util_2.getApiClientFromOptions(trainingSessionOptions, true);
|
|
16
|
+
var _a;
|
|
17
|
+
const apiClient = await util_1.getApiClientFromOptions(trainingSessionOptions, true);
|
|
17
18
|
if (!trainingSessionOptions.branchName) {
|
|
18
19
|
trainingSessionOptions.branchName = constants_1.DefaultBranchName;
|
|
19
20
|
}
|
|
20
21
|
if (trainingSessionOptions.branchName !== 'master') {
|
|
21
22
|
await branches_1.checkBranchNameAndAutoBranchMaybe(trainingSessionOptions.workspaceId, apiClient, trainingSessionOptions.branchName, trainingSessionOptions.autoBranch);
|
|
22
23
|
}
|
|
23
|
-
let environment;
|
|
24
24
|
if (trainingSessionOptions.environmentId) {
|
|
25
|
-
|
|
25
|
+
await apiClient.getEnvironment(trainingSessionOptions.environmentId);
|
|
26
26
|
}
|
|
27
|
-
let plan;
|
|
28
27
|
if (trainingSessionOptions.planId) {
|
|
29
|
-
|
|
28
|
+
await apiClient.getPlan(trainingSessionOptions.planId);
|
|
30
29
|
}
|
|
31
|
-
let deployment;
|
|
32
30
|
if (trainingSessionOptions.deploymentId) {
|
|
33
|
-
|
|
31
|
+
await apiClient.getDeploymentEntity(trainingSessionOptions.deploymentId);
|
|
34
32
|
}
|
|
35
|
-
let application;
|
|
36
33
|
if (trainingSessionOptions.applicationId) {
|
|
37
|
-
|
|
34
|
+
await apiClient.getApplication(trainingSessionOptions.applicationId);
|
|
38
35
|
}
|
|
39
|
-
|
|
40
|
-
if (trainingSessionOptions.autoLogin) {
|
|
41
|
-
autoLoginFlows = await apiClient.getFlows({
|
|
42
|
-
organization_id: trainingSessionOptions.workspaceId,
|
|
43
|
-
flow_type: 'login',
|
|
44
|
-
limit: 1,
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
testsUtil_1.logTestInfoIfPresent(`Creating test: `, trainingSessionOptions.testName);
|
|
36
|
+
testsUtil_1.logTestInfoIfPresent(`Creating test in desktop app: `, trainingSessionOptions.testName);
|
|
48
37
|
testsUtil_1.logTestInfoIfPresent(`Add auto login flow: `, trainingSessionOptions.autoLogin);
|
|
49
38
|
testsUtil_1.logTestInfoIfPresent(`URL: `, trainingSessionOptions.url);
|
|
50
39
|
testsUtil_1.logTestInfoIfPresent(`Workspace: `, trainingSessionOptions.workspaceId);
|
|
@@ -55,26 +44,12 @@ async function trainNewTest(trainingSessionOptions) {
|
|
|
55
44
|
testsUtil_1.logTestInfoIfPresent(`Credentials ID: `, trainingSessionOptions.credentialsId);
|
|
56
45
|
testsUtil_1.logTestInfoIfPresent(`Datatable ID(s): `, (_a = trainingSessionOptions.dataTableIds) === null || _a === void 0 ? void 0 : _a.join(', '));
|
|
57
46
|
testsUtil_1.logTestInfoIfPresent(`Test description: `, trainingSessionOptions.testDescription);
|
|
58
|
-
|
|
59
|
-
const browserPreferencesDirectory = await testsUtil_1.prepareChromePreferencesDirectory(browserPreferences);
|
|
60
|
-
const runnerType = await apiClient.getRunnerTypeFromFeatureFlag(trainingSessionOptions.workspaceId);
|
|
61
|
-
const trainingBrowser = await testsUtil_1.createBrowserWithAuthedExtension((_b = trainingSessionOptions.authToken) !== null && _b !== void 0 ? _b : authConfig.accessToken, trainingSessionOptions.width, trainingSessionOptions.height, browserPreferencesDirectory, {
|
|
62
|
-
runnerType,
|
|
63
|
-
});
|
|
64
|
-
trainerBrowserUtil_1.addManualCloseEventWatch(trainingBrowser, trainingSessionActions_1.TrainingEventEmitter.sessionClosed);
|
|
65
|
-
trainerBrowserUtil_1.addClosedAllWindowsEventWatch(trainingBrowser, trainingSessionActions_1.TrainingEventEmitter.sessionClosed);
|
|
66
|
-
const backgroundPage = await testsUtil_1.getExtensionBackgroundPageWithCliTool(trainingBrowser);
|
|
67
|
-
await testsUtil_1.createTrainingSession(backgroundPage, trainingSessionOptions, environment, plan, deployment, application, autoLoginFlows ? autoLoginFlows[0] : undefined);
|
|
68
|
-
trainingSessionActions_1.TrainingEventEmitter.sessionStarted();
|
|
69
|
-
await testsUtil_1.cleanUpInitialPages(trainingBrowser);
|
|
70
|
-
testsUtil_1.logCtlCLine();
|
|
47
|
+
await openUtils_1.openUrlInDesktopApp(ElectronProtocolUrl.TRAIN_NEW_TEST, trainingSessionOptions);
|
|
71
48
|
}
|
|
72
49
|
exports.trainNewTest = trainNewTest;
|
|
73
50
|
async function editTest(trainingSessionOptions) {
|
|
74
51
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
75
|
-
|
|
76
|
-
const authConfig = await new authenticationProvider_1.AuthenticationProvider().getAuthConfigWithAutoRenew();
|
|
77
|
-
const apiClient = await util_2.getApiClientFromOptions(trainingSessionOptions, true);
|
|
52
|
+
const apiClient = await util_1.getApiClientFromOptions(trainingSessionOptions, true);
|
|
78
53
|
let testRunIdConfig = { testId: '', filterHttpRequests: false };
|
|
79
54
|
if (trainingSessionOptions.testRunId) {
|
|
80
55
|
testRunIdConfig = await testsUtil_1.pullDownTestRunConfig(trainingSessionOptions.testRunId, apiClient);
|
|
@@ -91,35 +66,35 @@ async function editTest(trainingSessionOptions) {
|
|
|
91
66
|
if (test.default) {
|
|
92
67
|
throw new Error('Editing of the mabl default supplied tests is not supported');
|
|
93
68
|
}
|
|
69
|
+
if (!((_g = test.flows) === null || _g === void 0 ? void 0 : _g.length)) {
|
|
70
|
+
throw new Error(util_2.TEST_INFO_NOT_FOUND);
|
|
71
|
+
}
|
|
94
72
|
if (branchName !== 'master') {
|
|
95
73
|
await branches_1.checkBranchNameAndAutoBranchMaybe(test.organization_id, apiClient, branchName, trainingSessionOptions.autoBranch);
|
|
96
74
|
}
|
|
97
75
|
const finalUrl = testsUtil_1.getFinalUrl(test, url);
|
|
98
|
-
const flowArray = await util_1.getJourneyFlowArray(test, apiClient, branchName);
|
|
99
|
-
let environment;
|
|
100
76
|
if (environmentId) {
|
|
101
|
-
|
|
77
|
+
await apiClient.getEnvironment(environmentId);
|
|
102
78
|
}
|
|
103
|
-
testsUtil_1.logTestInfoIfPresent(`Editing test: `, `${test.name} - ${test.invariant_id}`);
|
|
79
|
+
testsUtil_1.logTestInfoIfPresent(`Editing test in desktop app: `, `${test.name} - ${test.invariant_id}`);
|
|
104
80
|
testsUtil_1.logTestInfoIfPresent(`Test description: `, test.description);
|
|
105
81
|
testsUtil_1.logTestInfoIfPresent(`URL: `, finalUrl);
|
|
106
82
|
testsUtil_1.logTestInfoIfPresent(`Workspace: `, test.organization_id);
|
|
107
83
|
testsUtil_1.logTestInfoIfPresent(`Branch: `, branchName);
|
|
108
84
|
testsUtil_1.logTestInfoIfPresent(`Environment ID: `, environmentId);
|
|
109
85
|
testsUtil_1.logTestInfoIfPresent(`Credentials ID: `, credentialsId);
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
testsUtil_1.logCtlCLine();
|
|
86
|
+
const scriptConfig = {
|
|
87
|
+
applicationId: trainingSessionOptions.applicationId,
|
|
88
|
+
branchName,
|
|
89
|
+
credentialsId,
|
|
90
|
+
deploymentId: trainingSessionOptions.deploymentId,
|
|
91
|
+
environmentId,
|
|
92
|
+
testId,
|
|
93
|
+
testType: test.test_type,
|
|
94
|
+
workspaceId: test.organization_id,
|
|
95
|
+
planId: testRunIdConfig.fromPlanId,
|
|
96
|
+
url: finalUrl,
|
|
97
|
+
};
|
|
98
|
+
await openUtils_1.openUrlInDesktopApp(ElectronProtocolUrl.EDIT_TEST, scriptConfig);
|
|
124
99
|
}
|
|
125
100
|
exports.editTest = editTest;
|
package/env/defaultEnv.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SCRIPT_NAME = exports.OKTA_URL = exports.OKTA_CLIENT_ID = exports.LOCAL_TRAINER_PATH = exports.EXTENSION_ID = exports.ENV = exports.DEBUG_EVENT_EMITTER = exports.CONSOLE_LOGGING_LEVEL = exports.CONF_FILE_VERSION = exports.CONF_FILE_PROJECT_NAME = exports.BASE_APP_URL = exports.BASE_API_URL = void 0;
|
|
3
|
+
exports.ELECTRON_PROTOCOL = exports.SCRIPT_NAME = exports.OKTA_URL = exports.OKTA_CLIENT_ID = exports.LOCAL_TRAINER_PATH = exports.EXTENSION_ID = exports.ENV = exports.DEBUG_EVENT_EMITTER = exports.CONSOLE_LOGGING_LEVEL = exports.CONF_FILE_VERSION = exports.CONF_FILE_PROJECT_NAME = exports.BASE_APP_URL = exports.BASE_API_URL = void 0;
|
|
4
4
|
exports.BASE_API_URL = 'https://api.mabl.com';
|
|
5
5
|
exports.BASE_APP_URL = 'https://app.mabl.com';
|
|
6
6
|
exports.CONF_FILE_PROJECT_NAME = 'mabl-cli';
|
|
@@ -13,3 +13,4 @@ exports.LOCAL_TRAINER_PATH = '';
|
|
|
13
13
|
exports.OKTA_CLIENT_ID = '0oa1fte4dlVvEr5bb5d7';
|
|
14
14
|
exports.OKTA_URL = 'https://auth2.mabl.com';
|
|
15
15
|
exports.SCRIPT_NAME = 'mabl';
|
|
16
|
+
exports.ELECTRON_PROTOCOL = 'mabl-app';
|
package/env/dev.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SCRIPT_NAME = exports.OKTA_URL = exports.OKTA_CLIENT_ID = exports.LOCAL_TRAINER_PATH = exports.EXTENSION_ID = exports.ENV = exports.DEBUG_EVENT_EMITTER = exports.CONSOLE_LOGGING_LEVEL = exports.CONF_FILE_VERSION = exports.CONF_FILE_PROJECT_NAME = exports.BASE_APP_URL = exports.BASE_API_URL = void 0;
|
|
3
|
+
exports.ELECTRON_PROTOCOL = exports.SCRIPT_NAME = exports.OKTA_URL = exports.OKTA_CLIENT_ID = exports.LOCAL_TRAINER_PATH = exports.EXTENSION_ID = exports.ENV = exports.DEBUG_EVENT_EMITTER = exports.CONSOLE_LOGGING_LEVEL = exports.CONF_FILE_VERSION = exports.CONF_FILE_PROJECT_NAME = exports.BASE_APP_URL = exports.BASE_API_URL = void 0;
|
|
4
4
|
exports.BASE_API_URL = 'https://api-dev.mabl.com';
|
|
5
5
|
exports.BASE_APP_URL = 'https://app-dev.mabl.com';
|
|
6
6
|
exports.CONF_FILE_PROJECT_NAME = 'mabl-cli-dev';
|
|
@@ -13,3 +13,4 @@ exports.LOCAL_TRAINER_PATH = '';
|
|
|
13
13
|
exports.OKTA_CLIENT_ID = '0oamuehnyLZhBbKh91d6';
|
|
14
14
|
exports.OKTA_URL = 'https://auth2-dev.mabl.com';
|
|
15
15
|
exports.SCRIPT_NAME = 'mabl-dev';
|
|
16
|
+
exports.ELECTRON_PROTOCOL = 'mabl-app-dev';
|
package/env/env.js
CHANGED
|
@@ -19,7 +19,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.setConfigFileProjectName = exports.setGlobalConfigEnv = exports.EnvOption = exports.SCRIPT_NAME = exports.OKTA_URL = exports.OKTA_CLIENT_ID = exports.LOCAL_TRAINER_PATH = exports.EXTENSION_ID = exports.ENV = exports.DEBUG_EVENT_EMITTER = exports.CONSOLE_LOGGING_LEVEL = exports.CONF_FILE_VERSION = exports.CONF_FILE_PROJECT_NAME = exports.BASE_APP_URL = exports.BASE_API_URL = void 0;
|
|
22
|
+
exports.setConfigFileProjectName = exports.setGlobalConfigEnv = exports.EnvOption = exports.ELECTRON_PROTOCOL = exports.SCRIPT_NAME = exports.OKTA_URL = exports.OKTA_CLIENT_ID = exports.LOCAL_TRAINER_PATH = exports.EXTENSION_ID = exports.ENV = exports.DEBUG_EVENT_EMITTER = exports.CONSOLE_LOGGING_LEVEL = exports.CONF_FILE_VERSION = exports.CONF_FILE_PROJECT_NAME = exports.BASE_APP_URL = exports.BASE_API_URL = void 0;
|
|
23
23
|
const localEnv = __importStar(require("./local"));
|
|
24
24
|
const devEnv = __importStar(require("./dev"));
|
|
25
25
|
const prodEnv = __importStar(require("./prod"));
|
|
@@ -36,6 +36,7 @@ exports.LOCAL_TRAINER_PATH = defaultEnv.LOCAL_TRAINER_PATH;
|
|
|
36
36
|
exports.OKTA_CLIENT_ID = defaultEnv.OKTA_CLIENT_ID;
|
|
37
37
|
exports.OKTA_URL = defaultEnv.OKTA_URL;
|
|
38
38
|
exports.SCRIPT_NAME = defaultEnv.SCRIPT_NAME;
|
|
39
|
+
exports.ELECTRON_PROTOCOL = defaultEnv.ELECTRON_PROTOCOL;
|
|
39
40
|
var EnvOption;
|
|
40
41
|
(function (EnvOption) {
|
|
41
42
|
EnvOption["dev"] = "dev";
|
|
@@ -60,6 +61,7 @@ function setGlobalConfigEnv(env) {
|
|
|
60
61
|
exports.OKTA_CLIENT_ID = envMap[env].OKTA_CLIENT_ID;
|
|
61
62
|
exports.OKTA_URL = envMap[env].OKTA_URL;
|
|
62
63
|
exports.SCRIPT_NAME = envMap[env].SCRIPT_NAME;
|
|
64
|
+
exports.ELECTRON_PROTOCOL = envMap[env].ELECTRON_PROTOCOL;
|
|
63
65
|
}
|
|
64
66
|
exports.setGlobalConfigEnv = setGlobalConfigEnv;
|
|
65
67
|
function setConfigFileProjectName(projectName) {
|
package/env/local.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SCRIPT_NAME = exports.OKTA_URL = exports.OKTA_CLIENT_ID = exports.LOCAL_TRAINER_PATH = exports.EXTENSION_ID = exports.ENV = exports.DEBUG_EVENT_EMITTER = exports.CONSOLE_LOGGING_LEVEL = exports.CONF_FILE_VERSION = exports.CONF_FILE_PROJECT_NAME = exports.BASE_APP_URL = exports.BASE_API_URL = void 0;
|
|
3
|
+
exports.ELECTRON_PROTOCOL = exports.SCRIPT_NAME = exports.OKTA_URL = exports.OKTA_CLIENT_ID = exports.LOCAL_TRAINER_PATH = exports.EXTENSION_ID = exports.ENV = exports.DEBUG_EVENT_EMITTER = exports.CONSOLE_LOGGING_LEVEL = exports.CONF_FILE_VERSION = exports.CONF_FILE_PROJECT_NAME = exports.BASE_APP_URL = exports.BASE_API_URL = void 0;
|
|
4
4
|
exports.BASE_API_URL = 'http://localhost:8080';
|
|
5
5
|
exports.BASE_APP_URL = 'https://app-local.mabl.com:3000';
|
|
6
6
|
exports.CONF_FILE_PROJECT_NAME = 'mabl-cli-local';
|
|
@@ -13,3 +13,4 @@ exports.LOCAL_TRAINER_PATH = process.env.LOCAL_TRAINER_PATH;
|
|
|
13
13
|
exports.OKTA_CLIENT_ID = '0oamuehnyLZhBbKh91d6';
|
|
14
14
|
exports.OKTA_URL = 'https://auth2-dev.mabl.com';
|
|
15
15
|
exports.SCRIPT_NAME = 'mabl-local';
|
|
16
|
+
exports.ELECTRON_PROTOCOL = 'mabl-app-local';
|
package/env/prod.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SCRIPT_NAME = exports.OKTA_URL = exports.OKTA_CLIENT_ID = exports.LOCAL_TRAINER_PATH = exports.EXTENSION_ID = exports.ENV = exports.DEBUG_EVENT_EMITTER = exports.CONSOLE_LOGGING_LEVEL = exports.CONF_FILE_VERSION = exports.CONF_FILE_PROJECT_NAME = exports.BASE_APP_URL = exports.BASE_API_URL = void 0;
|
|
3
|
+
exports.ELECTRON_PROTOCOL = exports.SCRIPT_NAME = exports.OKTA_URL = exports.OKTA_CLIENT_ID = exports.LOCAL_TRAINER_PATH = exports.EXTENSION_ID = exports.ENV = exports.DEBUG_EVENT_EMITTER = exports.CONSOLE_LOGGING_LEVEL = exports.CONF_FILE_VERSION = exports.CONF_FILE_PROJECT_NAME = exports.BASE_APP_URL = exports.BASE_API_URL = void 0;
|
|
4
4
|
exports.BASE_API_URL = 'https://api.mabl.com';
|
|
5
5
|
exports.BASE_APP_URL = 'https://app.mabl.com';
|
|
6
6
|
exports.CONF_FILE_PROJECT_NAME = 'mabl-cli';
|
|
@@ -13,3 +13,4 @@ exports.LOCAL_TRAINER_PATH = '';
|
|
|
13
13
|
exports.OKTA_CLIENT_ID = '0oa1fte4dlVvEr5bb5d7';
|
|
14
14
|
exports.OKTA_URL = 'https://auth2.mabl.com';
|
|
15
15
|
exports.SCRIPT_NAME = 'mabl';
|
|
16
|
+
exports.ELECTRON_PROTOCOL = 'mabl-app';
|