@mablhq/mabl-cli 1.25.19 → 1.29.0
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 +1 -0
- package/api/entities/Browser.js +1 -0
- package/api/featureSet.js +2 -2
- package/api/mablApiClient.js +14 -0
- package/api/mablApiClientFactory.js +5 -4
- package/browserLauncher/browserLauncherFactory.js +3 -3
- package/browserLauncher/playwrightBrowserLauncher/playwrightBrowser.js +2 -2
- package/browserLauncher/playwrightBrowserLauncher/playwrightBrowserLauncher.js +20 -3
- package/browserLauncher/playwrightBrowserLauncher/playwrightDom.js +18 -15
- package/browserLauncher/playwrightBrowserLauncher/simplePlaywrightLogger.js +36 -0
- package/browserLauncher/types.js +5 -1
- package/cli.js +1 -0
- package/commands/browserTypes.js +19 -8
- package/commands/config/config_cmds/configKeys.js +7 -1
- package/commands/config/config_cmds/set.js +6 -0
- package/commands/constants.js +9 -7
- package/commands/tests/testsUtil.js +71 -85
- package/commands/tests/tests_cmds/run-cloud.js +2 -2
- package/commands/tests/tests_cmds/run.js +24 -1
- package/commands/users/users.js +5 -0
- package/commands/users/users_cmds/list.js +58 -0
- package/domUtil/index.js +1 -2
- package/execution/index.js +1 -1
- package/index.d.ts +2 -0
- package/mablscript/MablAction.js +31 -1
- package/mablscript/actions/ConditionAction.js +4 -0
- package/mablscript/actions/FindAction.js +3 -0
- package/mablscript/actions/GenerateRandomStringAction.js +3 -0
- package/mablscript/actions/GetVariableValue.js +3 -0
- package/mablscript/actions/JavaScriptAction.js +7 -0
- package/mablscript/importer.js +10 -3
- package/mablscript/steps/AssertStep.js +10 -0
- package/mablscript/steps/ClickAndHoldStep.js +3 -0
- package/mablscript/steps/ClickStep.js +3 -0
- package/mablscript/steps/CreateVariableStep.js +6 -0
- package/mablscript/steps/DoubleClickStep.js +3 -0
- package/mablscript/steps/DownloadStep.js +4 -0
- package/mablscript/steps/EchoStep.js +3 -0
- package/mablscript/steps/EnterTextStep.js +6 -0
- package/mablscript/steps/EvaluateJavaScriptStep.js +3 -0
- package/mablscript/steps/HoverStep.js +3 -0
- package/mablscript/steps/IfConditionStep.js +9 -0
- package/mablscript/steps/OpenEmailStep.js +3 -0
- package/mablscript/steps/ReleaseStep.js +3 -0
- package/mablscript/steps/RemoveCookieStep.js +4 -0
- package/mablscript/steps/SelectStep.js +7 -0
- package/mablscript/steps/SendHttpRequestStep.js +8 -0
- package/mablscript/steps/SendKeyStep.js +3 -0
- package/mablscript/steps/SetCookieStep.js +7 -0
- package/mablscript/steps/SetFilesStep.js +3 -0
- package/mablscript/steps/SwitchContextStep.js +4 -0
- package/mablscript/steps/VisitUrlStep.js +4 -0
- package/mablscript/steps/WaitUntilStep.js +3 -0
- package/mablscriptFind/index.js +1 -1
- package/package.json +5 -4
- package/providers/cliConfigProvider.js +6 -0
- package/resources/mablFind.js +1 -1
- package/util/asyncUtil.js +9 -5
- package/util/httpUtil.js +32 -12
- package/browserLauncher/runnerType.js +0 -7
- package/domUtil/index.js.LICENSE.txt +0 -14
- package/mablscript/AttributesConstants.js +0 -115
|
@@ -27,25 +27,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.toBasicHttpAuthenticationCredentials = exports.generateChromiumPreferencesFile = exports.logTestInfoIfPresent = exports.milliSecondsToSeconds = exports.calculateTotalTimeSeconds = exports.extractTestRunConfig = exports.pullDownTestRunConfig = exports.validateRunCommandWithLabels = exports.validateRunEditCommand = exports.downloadUploadFile = exports.sleep = exports.editTheTest = exports.runTheTest = exports.prepareTrainerForSplitPlayback = exports.createTrainingSession = exports.cleanUpInitialPages = exports.getExtensionBackgroundPageWithCliTool = exports.createBrowserForExecutionEngine = exports.addExecutionEngineLaunchArgs = exports.createBrowser = exports.prepareChromePreferencesDirectory = exports.findChrome = exports.searchForChrome = exports.getFinalUrl = exports.getTempChromePrefDirectory = void 0;
|
|
30
|
-
const
|
|
30
|
+
const async_retry_1 = __importDefault(require("async-retry"));
|
|
31
|
+
const axios_1 = __importDefault(require("axios"));
|
|
32
|
+
const cli_table3_1 = __importDefault(require("cli-table3"));
|
|
31
33
|
const fs = __importStar(require("fs-extra"));
|
|
34
|
+
const os = __importStar(require("os"));
|
|
32
35
|
const path = __importStar(require("path"));
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const cliConfigProvider_1 = require("../../providers/cliConfigProvider");
|
|
36
|
-
const configKeys_1 = require("../config/config_cmds/configKeys");
|
|
36
|
+
const stream_1 = require("stream");
|
|
37
|
+
const browserLauncher_1 = require("../../browserLauncher/browserLauncher");
|
|
37
38
|
const trainingSessionActions_1 = require("../../core/messaging/actions/trainingSessionActions");
|
|
38
|
-
const
|
|
39
|
+
const logLineMessaging_1 = require("../../core/messaging/logLineMessaging");
|
|
40
|
+
const messaging_1 = require("../../core/messaging/messaging");
|
|
39
41
|
const env_1 = require("../../env/env");
|
|
40
|
-
const
|
|
41
|
-
const httpUtil_1 = require("../../util/httpUtil");
|
|
42
|
+
const cliConfigProvider_1 = require("../../providers/cliConfigProvider");
|
|
42
43
|
const loggingProvider_1 = require("../../providers/logging/loggingProvider");
|
|
43
|
-
const
|
|
44
|
-
const logLineMessaging_1 = require("../../core/messaging/logLineMessaging");
|
|
44
|
+
const httpUtil_1 = require("../../util/httpUtil");
|
|
45
45
|
const resourceUtil_1 = require("../../util/resourceUtil");
|
|
46
|
+
const configKeys_1 = require("../config/config_cmds/configKeys");
|
|
47
|
+
const constants_1 = require("../constants");
|
|
46
48
|
const mobileEmulationUtil_1 = require("./mobileEmulationUtil");
|
|
47
|
-
const browserLauncher_1 = require("../../browserLauncher/browserLauncher");
|
|
48
|
-
const stream_1 = require("stream");
|
|
49
49
|
const trainerUtil_1 = require("./tests_cmds/trainerUtil");
|
|
50
50
|
const chalk = require('chalk');
|
|
51
51
|
const chromeFinder = require('chrome-launcher/dist/chrome-finder');
|
|
@@ -106,42 +106,23 @@ async function findChrome() {
|
|
|
106
106
|
return chromePath;
|
|
107
107
|
}
|
|
108
108
|
exports.findChrome = findChrome;
|
|
109
|
-
async function launchBrowserInstance(
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
let proxy;
|
|
116
|
-
if (proxyServer) {
|
|
117
|
-
proxy = {
|
|
118
|
-
server: proxyServer,
|
|
109
|
+
async function launchBrowserInstance(launchArgs, userDataDir, headless, credentials, options) {
|
|
110
|
+
const optionsProxy = await maybeGetProxyOptions(options);
|
|
111
|
+
if (optionsProxy) {
|
|
112
|
+
options = {
|
|
113
|
+
...options,
|
|
114
|
+
proxy: optionsProxy,
|
|
119
115
|
};
|
|
120
116
|
}
|
|
117
|
+
let browser;
|
|
121
118
|
try {
|
|
122
|
-
browser = await maybeLaunchBrowser(
|
|
123
|
-
bypassContentSecurityPolicy,
|
|
124
|
-
defaultDeviceDescriptor,
|
|
125
|
-
disableFocusEmulation,
|
|
126
|
-
extraHttpHeaders,
|
|
127
|
-
ignoreDefaultArgs,
|
|
128
|
-
runnerType,
|
|
129
|
-
loggerFunc,
|
|
130
|
-
proxy,
|
|
131
|
-
userAgent,
|
|
132
|
-
});
|
|
119
|
+
browser = await maybeLaunchBrowser(launchArgs, userDataDir, headless, credentials, options);
|
|
133
120
|
}
|
|
134
121
|
catch (error) {
|
|
135
122
|
if (error.message.includes('Running as root without --no-sandbox is not supported')) {
|
|
136
123
|
launchArgs.push('--no-sandbox');
|
|
137
124
|
messaging_1.mablEventEmitter.log('Unable to initialize browser with standard settings, attempting to run with --no-sandbox setting', Date.now(), logLineMessaging_1.LogLineColor.yellow);
|
|
138
|
-
return maybeLaunchBrowser(
|
|
139
|
-
bypassContentSecurityPolicy,
|
|
140
|
-
defaultDeviceDescriptor,
|
|
141
|
-
ignoreDefaultArgs,
|
|
142
|
-
proxy,
|
|
143
|
-
runnerType,
|
|
144
|
-
}).catch((error) => {
|
|
125
|
+
return maybeLaunchBrowser(launchArgs, userDataDir, headless, credentials, options).catch((error) => {
|
|
145
126
|
messaging_1.mablEventEmitter.log('Browser launch failed', Date.now(), logLineMessaging_1.LogLineColor.red);
|
|
146
127
|
messaging_1.mablEventEmitter.log(error.message);
|
|
147
128
|
});
|
|
@@ -151,22 +132,34 @@ async function launchBrowserInstance(chromePath, launchArgs, userDataDir, headle
|
|
|
151
132
|
}
|
|
152
133
|
return browser;
|
|
153
134
|
}
|
|
154
|
-
function
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
135
|
+
async function maybeGetProxyOptions(options) {
|
|
136
|
+
const proxyServer = (await cliConfigProvider_1.CliConfigProvider.getCliConfig()).http.test
|
|
137
|
+
.proxyHost;
|
|
138
|
+
let optionsProxy;
|
|
139
|
+
if (options === null || options === void 0 ? void 0 : options.proxy) {
|
|
140
|
+
optionsProxy = {
|
|
141
|
+
server: options.proxy.server,
|
|
142
|
+
username: options.proxy.username,
|
|
143
|
+
password: options.proxy.password,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
else if (proxyServer) {
|
|
147
|
+
optionsProxy = {
|
|
148
|
+
server: proxyServer.href,
|
|
149
|
+
username: proxyServer.username,
|
|
150
|
+
password: proxyServer.password,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
return optionsProxy;
|
|
154
|
+
}
|
|
155
|
+
function maybeLaunchBrowser(launchArgs, userDataDir, headless, credentials, options) {
|
|
156
|
+
return browserLauncher_1.BrowserLauncherFactory.createRunner(options === null || options === void 0 ? void 0 : options.runnerType, options === null || options === void 0 ? void 0 : options.loggerFunc).launch({
|
|
157
|
+
...options,
|
|
162
158
|
headless,
|
|
163
159
|
args: launchArgs,
|
|
164
|
-
ignoreDefaultArgs,
|
|
165
160
|
userDataDir,
|
|
166
161
|
downloadPath: createDownloadDirectory(),
|
|
167
162
|
credentials,
|
|
168
|
-
proxy,
|
|
169
|
-
userAgent,
|
|
170
163
|
});
|
|
171
164
|
}
|
|
172
165
|
async function prepareChromePreferencesDirectory(browserPreferences) {
|
|
@@ -191,12 +184,8 @@ function removeTempBrowserPreferencesDirectory(tempDirPath) {
|
|
|
191
184
|
}
|
|
192
185
|
}
|
|
193
186
|
async function createBrowser(browserWidth, browserHeight, headless, containerTesting, tempBrowserPreferencesDirectory, options) {
|
|
194
|
-
|
|
195
|
-
const
|
|
196
|
-
if (!chromePath.length) {
|
|
197
|
-
messaging_1.mablEventEmitter.log(chalk.yellow('Could not find a local install of Chrome to use, please ensure you have it installed and try again'));
|
|
198
|
-
throw new Error('Chrome not found error');
|
|
199
|
-
}
|
|
187
|
+
var _a;
|
|
188
|
+
const { credentials, disableIsolation, ignoreCertificateErrors, emulationConfig, enableExtensions, resourcesDirectoryOverride, } = options || {};
|
|
200
189
|
const disableFeaturesFlags = [];
|
|
201
190
|
const launchArgs = [];
|
|
202
191
|
if (containerTesting) {
|
|
@@ -217,16 +206,12 @@ async function createBrowser(browserWidth, browserHeight, headless, containerTes
|
|
|
217
206
|
if (enableExtensions) {
|
|
218
207
|
ignoreDefaultArgs = ['--disable-extensions'];
|
|
219
208
|
}
|
|
220
|
-
const maybeBrowser = await launchBrowserInstance(
|
|
221
|
-
|
|
209
|
+
const maybeBrowser = await launchBrowserInstance(launchArgs, tempBrowserPreferencesDirectory, headless, credentials, {
|
|
210
|
+
...options,
|
|
222
211
|
defaultDeviceDescriptor,
|
|
223
|
-
disableFocusEmulation,
|
|
224
|
-
extraHttpHeaders,
|
|
225
212
|
ignoreDefaultArgs,
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
proxy,
|
|
229
|
-
userAgent: userAgent !== null && userAgent !== void 0 ? userAgent : emulationConfig === null || emulationConfig === void 0 ? void 0 : emulationConfig.device_config.user_agent,
|
|
213
|
+
userAgent: (_a = options === null || options === void 0 ? void 0 : options.userAgent) !== null && _a !== void 0 ? _a : emulationConfig === null || emulationConfig === void 0 ? void 0 : emulationConfig.device_config.user_agent,
|
|
214
|
+
defaultUserAgent: options === null || options === void 0 ? void 0 : options.defaultUserAgent,
|
|
230
215
|
});
|
|
231
216
|
if (!maybeBrowser) {
|
|
232
217
|
throw new Error('Unable to start Chrome session');
|
|
@@ -266,15 +251,18 @@ function addExecutionEngineLaunchArgs(browserWidth, browserHeight, proxyInfo, em
|
|
|
266
251
|
}
|
|
267
252
|
exports.addExecutionEngineLaunchArgs = addExecutionEngineLaunchArgs;
|
|
268
253
|
async function createBrowserForExecutionEngine(browserWidth, browserHeight, headless, tempBrowserPreferencesDirectory, proxyInfo, options) {
|
|
269
|
-
const { credentials,
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
254
|
+
const { credentials, deviceEmulationConfig, userAgent } = options;
|
|
255
|
+
if (deviceEmulationConfig && !userAgent) {
|
|
256
|
+
options = {
|
|
257
|
+
...options,
|
|
258
|
+
userAgent: deviceEmulationConfig.device_config.user_agent,
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
const { launchArgs, defaultDeviceDescriptor } = addExecutionEngineLaunchArgs(browserWidth, browserHeight, proxyInfo, deviceEmulationConfig);
|
|
262
|
+
if (defaultDeviceDescriptor) {
|
|
263
|
+
options = { ...options, defaultDeviceDescriptor };
|
|
264
|
+
}
|
|
265
|
+
const maybeBrowser = await maybeLaunchBrowser(launchArgs, tempBrowserPreferencesDirectory, headless, credentials, options);
|
|
278
266
|
if (!maybeBrowser) {
|
|
279
267
|
throw new Error('Unable to start Chrome session');
|
|
280
268
|
}
|
|
@@ -594,7 +582,7 @@ function validateRunCommandWithLabels(testId, suppliedLabelsInclude, suppliedLab
|
|
|
594
582
|
}
|
|
595
583
|
exports.validateRunCommandWithLabels = validateRunCommandWithLabels;
|
|
596
584
|
async function pullDownTestRunConfig(testRunId, apiClient) {
|
|
597
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p
|
|
585
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
598
586
|
const journeyRun = await apiClient.getTestRun(testRunId);
|
|
599
587
|
const planRun = await apiClient.getPlanRun(journeyRun.parent_execution);
|
|
600
588
|
return {
|
|
@@ -609,16 +597,15 @@ async function pullDownTestRunConfig(testRunId, apiClient) {
|
|
|
609
597
|
deviceEmulation: (_g = journeyRun.journey_parameters) === null || _g === void 0 ? void 0 : _g.device_emulation,
|
|
610
598
|
environmentId: (_j = (_h = journeyRun.journey_parameters) === null || _h === void 0 ? void 0 : _h.deployment) === null || _j === void 0 ? void 0 : _j.environment_id,
|
|
611
599
|
filterHttpRequests: false,
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
url: (_r = (_q = journeyRun.journey_parameters) === null || _q === void 0 ? void 0 : _q.deployment) === null || _r === void 0 ? void 0 : _r.uri,
|
|
600
|
+
importedVariables: (_k = journeyRun.journey_parameters) === null || _k === void 0 ? void 0 : _k.imported_variables,
|
|
601
|
+
pageLoadWait: (_l = journeyRun.journey_parameters) === null || _l === void 0 ? void 0 : _l.page_load_wait,
|
|
602
|
+
testId: (_m = journeyRun.journey) === null || _m === void 0 ? void 0 : _m.invariant_id,
|
|
603
|
+
url: (_p = (_o = journeyRun.journey_parameters) === null || _o === void 0 ? void 0 : _o.deployment) === null || _p === void 0 ? void 0 : _p.uri,
|
|
617
604
|
};
|
|
618
605
|
}
|
|
619
606
|
exports.pullDownTestRunConfig = pullDownTestRunConfig;
|
|
620
607
|
async function extractTestRunConfig(executionMessage, apiClient) {
|
|
621
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q
|
|
608
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
622
609
|
const journeyRun = (_a = executionMessage.journey_run) !== null && _a !== void 0 ? _a : (await apiClient.getTestRun(executionMessage.journey_run_id));
|
|
623
610
|
const planRun = executionMessage.plan_run;
|
|
624
611
|
const maybeRunnerType = ((_b = planRun === null || planRun === void 0 ? void 0 : planRun.run_policy) === null || _b === void 0 ? void 0 : _b.nodejs_runtime_variant)
|
|
@@ -635,11 +622,10 @@ async function extractTestRunConfig(executionMessage, apiClient) {
|
|
|
635
622
|
environmentId: (_k = (_j = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _j === void 0 ? void 0 : _j.deployment) === null || _k === void 0 ? void 0 : _k.environment_id,
|
|
636
623
|
filterHttpRequests: true,
|
|
637
624
|
importedVariables: (_l = journeyRun.journey_parameters) === null || _l === void 0 ? void 0 : _l.imported_variables,
|
|
638
|
-
|
|
639
|
-
pageLoadWait: (_p = journeyRun.journey_parameters) === null || _p === void 0 ? void 0 : _p.page_load_wait,
|
|
625
|
+
pageLoadWait: (_m = journeyRun.journey_parameters) === null || _m === void 0 ? void 0 : _m.page_load_wait,
|
|
640
626
|
runnerType: maybeRunnerType,
|
|
641
|
-
testId: (
|
|
642
|
-
url: (
|
|
627
|
+
testId: (_o = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey) === null || _o === void 0 ? void 0 : _o.invariant_id,
|
|
628
|
+
url: (_q = (_p = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _p === void 0 ? void 0 : _p.deployment) === null || _q === void 0 ? void 0 : _q.uri,
|
|
643
629
|
};
|
|
644
630
|
}
|
|
645
631
|
exports.extractTestRunConfig = extractTestRunConfig;
|
|
@@ -56,9 +56,9 @@ exports.builder = (yargs) => {
|
|
|
56
56
|
})
|
|
57
57
|
.option(constants_1.CommandArgBrowsers, {
|
|
58
58
|
alias: constants_1.CommandArgAliases.Browsers,
|
|
59
|
-
describe: 'Space delimited browsers to test against (e.g. "chrome firefox")',
|
|
59
|
+
describe: 'Space delimited browsers to test against (e.g. "chrome edge firefox")',
|
|
60
60
|
type: 'array',
|
|
61
|
-
default: constants_1.DefaultBrowserType
|
|
61
|
+
default: constants_1.DefaultBrowserType,
|
|
62
62
|
choices: constants_1.BrowserTypeSelections,
|
|
63
63
|
demand: 'Choose at least one browser to run on',
|
|
64
64
|
})
|
|
@@ -7,6 +7,7 @@ const constants_1 = require("../../constants");
|
|
|
7
7
|
const loggingProvider_1 = require("../../../providers/logging/loggingProvider");
|
|
8
8
|
const mablApi_1 = require("../../../mablApi");
|
|
9
9
|
const reporter_1 = require("../../../reporters/reporter");
|
|
10
|
+
const browserTypes_1 = require("../../browserTypes");
|
|
10
11
|
const chalk = require('chalk');
|
|
11
12
|
const execution = require('../../../execution/index');
|
|
12
13
|
exports.command = `run`;
|
|
@@ -141,7 +142,7 @@ exports.builder = (yargs) => {
|
|
|
141
142
|
type: 'boolean',
|
|
142
143
|
})
|
|
143
144
|
.option(constants_1.CommandArgBrowserEnableExtensions, {
|
|
144
|
-
describe: 'Enable browser extensions on [Chrome]',
|
|
145
|
+
describe: 'Enable browser extensions on [Chrome] and [Edge]',
|
|
145
146
|
default: false,
|
|
146
147
|
type: 'boolean',
|
|
147
148
|
})
|
|
@@ -157,14 +158,27 @@ exports.builder = (yargs) => {
|
|
|
157
158
|
describe: 'Set the speed that mabl interacts with webpages. Overrides test run settings if specified.',
|
|
158
159
|
type: 'string',
|
|
159
160
|
choices: Object.keys(mablApi_1.JourneyParameters.PageLoadWaitEnum).map((pageLoadWait) => pageLoadWait.toLowerCase()),
|
|
161
|
+
})
|
|
162
|
+
.option(constants_1.CommandArgBrowser, {
|
|
163
|
+
describe: 'Target browser to execute the test against [chrome,edge]',
|
|
164
|
+
type: 'string',
|
|
165
|
+
nargs: 1,
|
|
166
|
+
choices: [browserTypes_1.BrowserType.Chrome, browserTypes_1.BrowserType.Edge],
|
|
167
|
+
hidden: true,
|
|
160
168
|
})
|
|
161
169
|
.check((argv) => {
|
|
162
170
|
(0, 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]);
|
|
171
|
+
validateBrowserInput(argv[constants_1.CommandArgBrowser]);
|
|
163
172
|
const httpHeaders = argv[constants_1.CommandArgHttpHeaders];
|
|
164
173
|
(0, util_1.validateArrayInputs)(httpHeaders, 'HTTP headers must be SPACE delimited, e.g. "--http-headers "foo:bar" "baz:qux"');
|
|
165
174
|
argv[constants_1.CommandArgHttpHeaders] = (0, util_1.validateValuePairInputs)('HTTP header', httpHeaders);
|
|
166
175
|
return true;
|
|
167
176
|
});
|
|
177
|
+
function validateBrowserInput(browser) {
|
|
178
|
+
if (browser && !['chrome', 'edge'].includes(browser)) {
|
|
179
|
+
throw new Error('invalid browser type, valid browser types are [chrome,edge]');
|
|
180
|
+
}
|
|
181
|
+
}
|
|
168
182
|
};
|
|
169
183
|
const exitCodeOnError = 1;
|
|
170
184
|
exports.handler = (0, util_1.failWrapper)(run, exitCodeOnError);
|
|
@@ -184,10 +198,19 @@ async function run(parsed) {
|
|
|
184
198
|
extraHttpHeaders[headerParts[0].toLowerCase()] = headerParts[1];
|
|
185
199
|
}
|
|
186
200
|
});
|
|
201
|
+
let browserType;
|
|
202
|
+
switch (parsed[constants_1.CommandArgBrowser]) {
|
|
203
|
+
case 'edge':
|
|
204
|
+
browserType = browserTypes_1.BrowserType.Edge;
|
|
205
|
+
break;
|
|
206
|
+
default:
|
|
207
|
+
browserType = browserTypes_1.BrowserType.Chrome;
|
|
208
|
+
}
|
|
187
209
|
const testRunnerConfig = {
|
|
188
210
|
_cliCreated: true,
|
|
189
211
|
basicAuthCredentialsId: parsed[constants_1.CommandArgBasicAuthCredentials],
|
|
190
212
|
branchName: parsed['mabl-branch'],
|
|
213
|
+
browserType,
|
|
191
214
|
credentialsId: parsed['credentials-id'],
|
|
192
215
|
disableIsolation: parsed[constants_1.CommandArgBrowserDisableIsolation],
|
|
193
216
|
enableExtensions: parsed[constants_1.CommandArgBrowserEnableExtensions],
|
|
@@ -0,0 +1,58 @@
|
|
|
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 cli_table3_1 = __importDefault(require("cli-table3"));
|
|
9
|
+
const moment = require("moment");
|
|
10
|
+
const util_1 = require("../../commandUtil/util");
|
|
11
|
+
const constants_1 = require("../../constants");
|
|
12
|
+
const loggingProvider_1 = require("../../../providers/logging/loggingProvider");
|
|
13
|
+
const list_1 = require("../../commandUtil/list");
|
|
14
|
+
exports.command = 'list';
|
|
15
|
+
exports.describe = 'List users from a workspace';
|
|
16
|
+
exports.builder = (0, list_1.getListBuilderOptions)('users');
|
|
17
|
+
exports.handler = (0, util_1.failWrapper)(listUsers);
|
|
18
|
+
async function listUsers(parsed) {
|
|
19
|
+
const output = parsed.output;
|
|
20
|
+
const workspaceId = await (0, util_1.getWorkspaceId)(parsed);
|
|
21
|
+
const limit = parsed.limit;
|
|
22
|
+
const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
|
|
23
|
+
const users = await apiClient.getUsers(workspaceId, limit);
|
|
24
|
+
printUsers(users, output, workspaceId);
|
|
25
|
+
return users.length;
|
|
26
|
+
}
|
|
27
|
+
function printUsers(users, outputFormat, workspaceId) {
|
|
28
|
+
switch (outputFormat) {
|
|
29
|
+
case 'json':
|
|
30
|
+
loggingProvider_1.logger.info(JSON.stringify(users, null, 2));
|
|
31
|
+
break;
|
|
32
|
+
case 'yaml':
|
|
33
|
+
loggingProvider_1.logger.info((0, js_yaml_1.dump)(users));
|
|
34
|
+
break;
|
|
35
|
+
default:
|
|
36
|
+
const table = new cli_table3_1.default({
|
|
37
|
+
head: ['ID', 'Name', 'Role', 'Email', 'Created time'],
|
|
38
|
+
wordWrap: true,
|
|
39
|
+
});
|
|
40
|
+
users.forEach((user) => {
|
|
41
|
+
var _a, _b, _c;
|
|
42
|
+
const userRole = (_c = (_b = (_a = user.roles) === null || _a === void 0 ? void 0 : _a.find((role) => role.organization_id === workspaceId)) === null || _b === void 0 ? void 0 : _b.role) !== null && _c !== void 0 ? _c : 'unknown';
|
|
43
|
+
table.push([
|
|
44
|
+
{ rowSpan: 1, content: user.id, vAlign: 'center' },
|
|
45
|
+
{ rowSpan: 1, content: user.name, vAlign: 'center' },
|
|
46
|
+
{ rowSpan: 1, content: userRole, vAlign: 'center' },
|
|
47
|
+
{ rowSpan: 1, content: user.email, vAlign: 'center' },
|
|
48
|
+
{
|
|
49
|
+
rowSpan: 1,
|
|
50
|
+
content: moment.utc(user.created_time).format(constants_1.ListTimeFormat),
|
|
51
|
+
vAlign: 'center',
|
|
52
|
+
},
|
|
53
|
+
]);
|
|
54
|
+
});
|
|
55
|
+
loggingProvider_1.logger.info(table.toString());
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
}
|