@mablhq/mabl-cli 1.21.4 → 1.21.15
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/mablApiClientFactory.js +3 -3
- package/browserLauncher/playwrightBrowserLauncher/playwrightBrowser.js +4 -3
- package/browserLauncher/playwrightBrowserLauncher/playwrightBrowserLauncher.js +2 -1
- package/browserLauncher/playwrightBrowserLauncher/playwrightFrame.js +4 -0
- package/browserLauncher/playwrightBrowserLauncher/playwrightPage.js +5 -0
- package/commands/config/config_cmds/configKeys.js +12 -1
- package/commands/config/config_cmds/set.js +6 -0
- package/commands/flows/flows_cmds/export.js +1 -1
- package/commands/tests/testsUtil.js +19 -3
- package/commands/tests/tests_cmds/export.js +1 -1
- package/execution/index.js +1 -1
- package/mablscriptFind/index.js +1 -1
- package/package.json +1 -1
- package/providers/authenticationProvider.js +1 -1
- package/providers/cliConfigProvider.js +20 -8
- package/resources/mablFind.js +1 -1
- package/util/asyncUtil.js +10 -1
- package/util/httpUtil.js +3 -2
|
@@ -32,8 +32,8 @@ class MablApiClientFactory {
|
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
static async createApiClient(opts) {
|
|
35
|
-
const { proxyHost, sslVerify } = (await cliConfigProvider_1.CliConfigProvider.getCliConfig())
|
|
36
|
-
.
|
|
35
|
+
const { proxyHost, sslVerify } = (await cliConfigProvider_1.CliConfigProvider.getCliConfig()).http
|
|
36
|
+
.mabl;
|
|
37
37
|
const optsFromCliHttpConfig = {
|
|
38
38
|
proxyUrl: proxyHost,
|
|
39
39
|
sslVerify,
|
|
@@ -62,7 +62,7 @@ class MablApiClientFactory {
|
|
|
62
62
|
return MablApiClientFactory.createApiClient();
|
|
63
63
|
}
|
|
64
64
|
static async createApiClientForAccessToken(accessToken) {
|
|
65
|
-
const httpConfig = (await cliConfigProvider_1.CliConfigProvider.getCliConfig()).http;
|
|
65
|
+
const httpConfig = (await cliConfigProvider_1.CliConfigProvider.getCliConfig()).http.mabl;
|
|
66
66
|
return new mablApiClient_1.MablApiClient({
|
|
67
67
|
authType: types_1.AuthType.Bearer,
|
|
68
68
|
token: accessToken,
|
|
@@ -35,11 +35,12 @@ const path_1 = __importDefault(require("path"));
|
|
|
35
35
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
36
36
|
const runnerType_1 = require("../runnerType");
|
|
37
37
|
class PlaywrightBrowser extends events_1.default {
|
|
38
|
-
constructor(defaultContext, downloadDirectory, browserWSEndpoint) {
|
|
38
|
+
constructor(defaultContext, downloadDirectory, browserWSEndpoint, disableFocusEmulation) {
|
|
39
39
|
super();
|
|
40
40
|
this.defaultContext = defaultContext;
|
|
41
41
|
this.downloadDirectory = downloadDirectory;
|
|
42
42
|
this.browserWSEndpoint = browserWSEndpoint;
|
|
43
|
+
this.disableFocusEmulation = disableFocusEmulation;
|
|
43
44
|
this.playwrightPages = new Map();
|
|
44
45
|
const contextImpl = playwright._toImpl(defaultContext);
|
|
45
46
|
this.browser = contextImpl._browser;
|
|
@@ -54,8 +55,8 @@ class PlaywrightBrowser extends events_1.default {
|
|
|
54
55
|
fs_extra_1.default.mkdirSync(path_1.default.join(this.downloadDirectory));
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
|
-
static async create(defaultContext, downloadDirectory, browserWSEndpoint) {
|
|
58
|
-
const browser = new PlaywrightBrowser(defaultContext, downloadDirectory, browserWSEndpoint);
|
|
58
|
+
static async create(defaultContext, downloadDirectory, browserWSEndpoint, disableFocusEmulation) {
|
|
59
|
+
const browser = new PlaywrightBrowser(defaultContext, downloadDirectory, browserWSEndpoint, disableFocusEmulation);
|
|
59
60
|
await browser.setDownloadBehavior();
|
|
60
61
|
return browser;
|
|
61
62
|
}
|
|
@@ -32,11 +32,12 @@ class PlaywrightBrowserLauncher {
|
|
|
32
32
|
ignoreDefaultArgs: options.ignoreDefaultArgs,
|
|
33
33
|
ignoreHTTPSErrors: true,
|
|
34
34
|
isMobile: (_c = options.defaultDeviceDescriptor) === null || _c === void 0 ? void 0 : _c.isMobile,
|
|
35
|
+
proxy: options.proxy,
|
|
35
36
|
timeout: BROWSER_LAUNCH_TIMEOUT_MS,
|
|
36
37
|
userAgent: options.userAgent,
|
|
37
38
|
viewport,
|
|
38
39
|
});
|
|
39
|
-
return playwrightBrowser_1.PlaywrightBrowser.create(defaultContext, options.downloadPath, '');
|
|
40
|
+
return playwrightBrowser_1.PlaywrightBrowser.create(defaultContext, options.downloadPath, '', options.disableFocusEmulation);
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
43
|
exports.PlaywrightBrowserLauncher = PlaywrightBrowserLauncher;
|
|
@@ -196,5 +196,9 @@ class PlaywrightFrame extends browserLauncher_1.Frame {
|
|
|
196
196
|
}
|
|
197
197
|
return true;
|
|
198
198
|
}
|
|
199
|
+
async getInjectedScriptInSecondaryWorld() {
|
|
200
|
+
const context = await this.getFrameImpl()._utilityContext();
|
|
201
|
+
return new playwrightDom_1.PlaywrightJsHandle(await context.injectedScript(), this.page());
|
|
202
|
+
}
|
|
199
203
|
}
|
|
200
204
|
exports.PlaywrightFrame = PlaywrightFrame;
|
|
@@ -72,6 +72,11 @@ class PlaywrightPage extends events_1.default {
|
|
|
72
72
|
async waitForInitialization() {
|
|
73
73
|
this.openerPage = await (0, utils_1.mapIfNotNull)(await this.page.opener(), (page) => this.browser.getOrCreatePage(page));
|
|
74
74
|
this.fallbackCdpSession = await this.createFallbackCdpSession();
|
|
75
|
+
if (this.browser.disableFocusEmulation) {
|
|
76
|
+
await this.makeCdpCall('Emulation.setFocusEmulationEnabled', {
|
|
77
|
+
enabled: false,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
75
80
|
}
|
|
76
81
|
on(event, listener) {
|
|
77
82
|
this.wireEvents(event);
|
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validConfigKeyChoices = exports.configKeys = void 0;
|
|
3
|
+
exports.isValidProxyMode = exports.proxyModes = exports.validConfigKeyChoices = exports.configKeys = void 0;
|
|
4
4
|
exports.configKeys = Object.freeze({
|
|
5
5
|
browserPath: 'browser.path',
|
|
6
6
|
enableSourceControlMetadataCollection: 'alpha.scm_metadata.enable',
|
|
7
7
|
defaultWorkspaceId: 'workspace',
|
|
8
8
|
proxy: 'http.proxy',
|
|
9
9
|
sslVerify: 'http.sslVerify',
|
|
10
|
+
proxyMode: 'http.proxyMode',
|
|
10
11
|
});
|
|
11
12
|
exports.validConfigKeyChoices = Object.values(exports.configKeys);
|
|
13
|
+
exports.proxyModes = [
|
|
14
|
+
'mabl',
|
|
15
|
+
'test',
|
|
16
|
+
'all',
|
|
17
|
+
'none',
|
|
18
|
+
];
|
|
19
|
+
function isValidProxyMode(value) {
|
|
20
|
+
return exports.proxyModes.indexOf(value) !== -1;
|
|
21
|
+
}
|
|
22
|
+
exports.isValidProxyMode = isValidProxyMode;
|
|
@@ -49,6 +49,12 @@ async function setConfig(parsed) {
|
|
|
49
49
|
}
|
|
50
50
|
await cliConfigProvider_1.CliConfigProvider.setConfigProperty(key, value);
|
|
51
51
|
break;
|
|
52
|
+
case configKeys_1.configKeys.proxyMode:
|
|
53
|
+
if (!(0, configKeys_1.isValidProxyMode)(value)) {
|
|
54
|
+
throw new Error(`Invalid proxy mode. The value must be one of ${JSON.stringify(configKeys_1.proxyModes)}`);
|
|
55
|
+
}
|
|
56
|
+
await cliConfigProvider_1.CliConfigProvider.setConfigProperty(key, value);
|
|
57
|
+
break;
|
|
52
58
|
default:
|
|
53
59
|
throw new Error(`<${exports.configKeyCommandArg}> value not one of supported types: ${JSON.stringify(configKeys_1.validConfigKeyChoices)}`);
|
|
54
60
|
}
|
|
@@ -40,7 +40,7 @@ async function pullFlow(parsed) {
|
|
|
40
40
|
const flowId = parsed.id;
|
|
41
41
|
const format = parsed.format;
|
|
42
42
|
const detailLevel = parsed[constants_1.CommandArgDetailLevel];
|
|
43
|
-
const apiClient = await mablApiClientFactory_1.MablApiClientFactory.
|
|
43
|
+
const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
|
|
44
44
|
const branchName = (_a = parsed['mabl-branch']) !== null && _a !== void 0 ? _a : constants_1.DefaultBranchName;
|
|
45
45
|
const flow = await apiClient.getFlow(flowId, branchName);
|
|
46
46
|
switch (format) {
|
|
@@ -138,16 +138,27 @@ async function createBrowserWithAuthedExtension(accessToken, browserWidth, brows
|
|
|
138
138
|
}
|
|
139
139
|
exports.createBrowserWithAuthedExtension = createBrowserWithAuthedExtension;
|
|
140
140
|
async function launchBrowserInstance(chromePath, launchArgs, userDataDir, headless, credentials, options) {
|
|
141
|
-
|
|
141
|
+
var _a;
|
|
142
|
+
const { bypassContentSecurityPolicy, defaultDeviceDescriptor, disableFocusEmulation, extraHttpHeaders, ignoreDefaultArgs, runnerType, loggerFunc, userAgent, } = options || {};
|
|
142
143
|
let browser;
|
|
144
|
+
const proxyServer = (_a = (await cliConfigProvider_1.CliConfigProvider.getCliConfig()).http.test
|
|
145
|
+
.proxyHost) === null || _a === void 0 ? void 0 : _a.href;
|
|
146
|
+
let proxy;
|
|
147
|
+
if (proxyServer) {
|
|
148
|
+
proxy = {
|
|
149
|
+
server: proxyServer,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
143
152
|
try {
|
|
144
153
|
browser = await maybeLaunchBrowser(chromePath, launchArgs, userDataDir, headless, credentials, {
|
|
145
154
|
bypassContentSecurityPolicy,
|
|
146
155
|
defaultDeviceDescriptor,
|
|
156
|
+
disableFocusEmulation,
|
|
147
157
|
extraHttpHeaders,
|
|
148
158
|
ignoreDefaultArgs,
|
|
149
159
|
runnerType,
|
|
150
160
|
loggerFunc,
|
|
161
|
+
proxy,
|
|
151
162
|
userAgent,
|
|
152
163
|
});
|
|
153
164
|
}
|
|
@@ -159,6 +170,7 @@ async function launchBrowserInstance(chromePath, launchArgs, userDataDir, headle
|
|
|
159
170
|
bypassContentSecurityPolicy,
|
|
160
171
|
defaultDeviceDescriptor,
|
|
161
172
|
ignoreDefaultArgs,
|
|
173
|
+
proxy,
|
|
162
174
|
runnerType,
|
|
163
175
|
}).catch((error) => {
|
|
164
176
|
messaging_1.mablEventEmitter.log('Browser launch failed', Date.now(), logLineMessaging_1.LogLineColor.red);
|
|
@@ -171,10 +183,11 @@ async function launchBrowserInstance(chromePath, launchArgs, userDataDir, headle
|
|
|
171
183
|
return browser;
|
|
172
184
|
}
|
|
173
185
|
function maybeLaunchBrowser(chromePath, launchArgs, userDataDir, headless, credentials, options) {
|
|
174
|
-
const { bypassContentSecurityPolicy, defaultDeviceDescriptor, extraHttpHeaders, ignoreDefaultArgs, runnerType, loggerFunc, userAgent, } = options || {};
|
|
186
|
+
const { bypassContentSecurityPolicy, defaultDeviceDescriptor, disableFocusEmulation, extraHttpHeaders, ignoreDefaultArgs, runnerType, loggerFunc, proxy, userAgent, } = options || {};
|
|
175
187
|
return browserLauncher_1.BrowserLauncherFactory.createRunner(runnerType, loggerFunc).launch({
|
|
176
188
|
bypassContentSecurityPolicy,
|
|
177
189
|
defaultDeviceDescriptor,
|
|
190
|
+
disableFocusEmulation,
|
|
178
191
|
executablePath: chromePath,
|
|
179
192
|
extraHttpHeaders,
|
|
180
193
|
headless,
|
|
@@ -183,6 +196,7 @@ function maybeLaunchBrowser(chromePath, launchArgs, userDataDir, headless, crede
|
|
|
183
196
|
userDataDir,
|
|
184
197
|
downloadPath: createDownloadDirectory(),
|
|
185
198
|
credentials,
|
|
199
|
+
proxy,
|
|
186
200
|
userAgent,
|
|
187
201
|
});
|
|
188
202
|
}
|
|
@@ -208,7 +222,7 @@ function removeTempBrowserPreferencesDirectory(tempDirPath) {
|
|
|
208
222
|
}
|
|
209
223
|
}
|
|
210
224
|
async function createBrowser(browserWidth, browserHeight, headless, containerTesting, tempBrowserPreferencesDirectory, options) {
|
|
211
|
-
const { bypassContentSecurityPolicy, credentials, browserPath, disableIsolation, extraHttpHeaders, ignoreCertificateErrors, emulationConfig, enableExtensions, runnerType, loggerFunc, resourcesDirectoryOverride, userAgent, } = options || {};
|
|
225
|
+
const { bypassContentSecurityPolicy, credentials, browserPath, disableFocusEmulation, disableIsolation, extraHttpHeaders, ignoreCertificateErrors, emulationConfig, enableExtensions, runnerType, loggerFunc, resourcesDirectoryOverride, proxy, userAgent, } = options || {};
|
|
212
226
|
const chromePath = browserPath !== null && browserPath !== void 0 ? browserPath : (await findChrome());
|
|
213
227
|
if (!chromePath.length) {
|
|
214
228
|
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'));
|
|
@@ -234,10 +248,12 @@ async function createBrowser(browserWidth, browserHeight, headless, containerTes
|
|
|
234
248
|
const maybeBrowser = await launchBrowserInstance(chromePath, launchArgs, tempBrowserPreferencesDirectory, headless, credentials, {
|
|
235
249
|
bypassContentSecurityPolicy,
|
|
236
250
|
defaultDeviceDescriptor,
|
|
251
|
+
disableFocusEmulation,
|
|
237
252
|
extraHttpHeaders,
|
|
238
253
|
ignoreDefaultArgs,
|
|
239
254
|
runnerType,
|
|
240
255
|
loggerFunc,
|
|
256
|
+
proxy,
|
|
241
257
|
userAgent: userAgent !== null && userAgent !== void 0 ? userAgent : emulationConfig === null || emulationConfig === void 0 ? void 0 : emulationConfig.device_config.user_agent,
|
|
242
258
|
});
|
|
243
259
|
if (!maybeBrowser) {
|
|
@@ -49,7 +49,7 @@ async function pullJourney(parsed) {
|
|
|
49
49
|
const testId = parsed.id;
|
|
50
50
|
const format = parsed.format;
|
|
51
51
|
const detailLevel = parsed[constants_1.CommandArgDetailLevel];
|
|
52
|
-
const apiClient = await mablApiClientFactory_1.MablApiClientFactory.
|
|
52
|
+
const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
|
|
53
53
|
const branchName = (_a = parsed['mabl-branch']) !== null && _a !== void 0 ? _a : constants_1.DefaultBranchName;
|
|
54
54
|
const journey = await apiClient.getJourney(testId, branchName, format);
|
|
55
55
|
const flowArray = await (0, util_1.getJourneyFlowArray)(journey, apiClient, branchName);
|