@mablhq/mabl-cli 1.61.3 → 1.61.8
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/browserLauncher/playwrightBrowserLauncher/playwrightApiResponse.js +18 -0
- package/browserLauncher/playwrightBrowserLauncher/playwrightBrowser.js +48 -0
- package/browserLauncher/types.js +7 -1
- package/commands/constants.js +0 -2
- package/commands/tests/testsUtil.js +2 -0
- package/commands/tests/tests_cmds/run.js +4 -2
- package/execution/index.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PlaywrightApiResponse = void 0;
|
|
4
|
+
class PlaywrightApiResponse {
|
|
5
|
+
constructor(response) {
|
|
6
|
+
this.response = response;
|
|
7
|
+
}
|
|
8
|
+
headers() {
|
|
9
|
+
return this.response.headersArray();
|
|
10
|
+
}
|
|
11
|
+
status() {
|
|
12
|
+
return this.response.status();
|
|
13
|
+
}
|
|
14
|
+
url() {
|
|
15
|
+
return this.response.url();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.PlaywrightApiResponse = PlaywrightApiResponse;
|
|
@@ -37,6 +37,9 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
|
37
37
|
const firefoxBrowserDelegate_1 = require("./firefox/firefoxBrowserDelegate");
|
|
38
38
|
const chromiumBrowserDelegate_1 = require("./chromium/chromiumBrowserDelegate");
|
|
39
39
|
const webkitBrowserDelegate_1 = require("./webkit/webkitBrowserDelegate");
|
|
40
|
+
const loggingProvider_1 = require("../../providers/logging/loggingProvider");
|
|
41
|
+
const playwrightApiResponse_1 = require("./playwrightApiResponse");
|
|
42
|
+
const httpUtil_1 = require("../../http/httpUtil");
|
|
40
43
|
class PlaywrightBrowser extends events_1.default {
|
|
41
44
|
constructor(defaultContext, downloadDirectory, browserWSEndpoint, browserDelegate, preferenceDirectory, disableFocusEmulation) {
|
|
42
45
|
super();
|
|
@@ -173,6 +176,51 @@ class PlaywrightBrowser extends events_1.default {
|
|
|
173
176
|
this.defaultViewportSize = viewport;
|
|
174
177
|
}
|
|
175
178
|
}
|
|
179
|
+
async makeApiRequest(url, options) {
|
|
180
|
+
const { discardRequestBody, method, maxRedirects, runInNewContext, timeout } = options !== null && options !== void 0 ? options : {};
|
|
181
|
+
try {
|
|
182
|
+
const requestContext = runInNewContext
|
|
183
|
+
? await this.createNewRequestContext()
|
|
184
|
+
: this.defaultContext.request;
|
|
185
|
+
const response = await requestContext.fetch(url, {
|
|
186
|
+
method,
|
|
187
|
+
ignoreHTTPSErrors: true,
|
|
188
|
+
maxRedirects: maxRedirects !== null && maxRedirects !== void 0 ? maxRedirects : types_1.DefaultApiRequestSettings.defaultMaxRedirects,
|
|
189
|
+
timeout: timeout !== null && timeout !== void 0 ? timeout : types_1.DefaultApiRequestSettings.defaultApiRequestTimeout,
|
|
190
|
+
});
|
|
191
|
+
return new playwrightApiResponse_1.PlaywrightApiResponse(response);
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
loggingProvider_1.logger.error(`Failed to make API request against ${url}`, error);
|
|
195
|
+
throw error;
|
|
196
|
+
}
|
|
197
|
+
finally {
|
|
198
|
+
if (discardRequestBody) {
|
|
199
|
+
try {
|
|
200
|
+
await this.defaultContext.request.dispose();
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
loggingProvider_1.logger.warn(`Error caught while attempting to dispose of API requests stored in memory: ${error === null || error === void 0 ? void 0 : error.message}`, error);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
setApiProxy(httpProxy) {
|
|
209
|
+
this.apiProxy = httpProxy;
|
|
210
|
+
}
|
|
211
|
+
async createNewRequestContext() {
|
|
212
|
+
const proxy = this.apiProxy ? { server: this.apiProxy } : undefined;
|
|
213
|
+
const headers = {
|
|
214
|
+
'Content-Type': 'text/plain;charset=UTF-8',
|
|
215
|
+
[httpUtil_1.USER_AGENT_HEADER]: httpUtil_1.USER_AGENT,
|
|
216
|
+
};
|
|
217
|
+
return playwright.request.newContext({
|
|
218
|
+
ignoreHTTPSErrors: true,
|
|
219
|
+
extraHTTPHeaders: headers,
|
|
220
|
+
timeout: types_1.DefaultApiRequestSettings.defaultApiRequestTimeout,
|
|
221
|
+
proxy,
|
|
222
|
+
});
|
|
223
|
+
}
|
|
176
224
|
}
|
|
177
225
|
exports.PlaywrightBrowser = PlaywrightBrowser;
|
|
178
226
|
function getBrowserDelegate(browserType, browserContext) {
|
package/browserLauncher/types.js
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WaitForOptions = exports.LifecycleEvent = exports.RunnerType = exports.DefaultTimeouts = void 0;
|
|
3
|
+
exports.WaitForOptions = exports.LifecycleEvent = exports.RunnerType = exports.DefaultApiRequestSettings = exports.DefaultTimeouts = void 0;
|
|
4
4
|
class DefaultTimeouts {
|
|
5
5
|
}
|
|
6
6
|
exports.DefaultTimeouts = DefaultTimeouts;
|
|
7
7
|
DefaultTimeouts.defaultTrialTimeoutMs = 5000;
|
|
8
8
|
DefaultTimeouts.defaultWaitTimeoutMs = 5000;
|
|
9
9
|
DefaultTimeouts.defaultActionTimeoutMs = 0;
|
|
10
|
+
class DefaultApiRequestSettings {
|
|
11
|
+
}
|
|
12
|
+
exports.DefaultApiRequestSettings = DefaultApiRequestSettings;
|
|
13
|
+
DefaultApiRequestSettings.defaultApiRequestTimeout = 2 * 60 * 1000;
|
|
14
|
+
DefaultApiRequestSettings.defaultMaxRedirects = 5;
|
|
15
|
+
DefaultApiRequestSettings.verifyUrlBatchSize = 20;
|
|
10
16
|
var RunnerType;
|
|
11
17
|
(function (RunnerType) {
|
|
12
18
|
RunnerType["Playwright"] = "playwright";
|
package/commands/constants.js
CHANGED
|
@@ -124,8 +124,6 @@ exports.BrowserTypeSelections = [
|
|
|
124
124
|
browserTypes_1.BrowserType.Chrome,
|
|
125
125
|
browserTypes_1.BrowserType.Edge,
|
|
126
126
|
browserTypes_1.BrowserType.Firefox,
|
|
127
|
-
'internet_explorer',
|
|
128
|
-
'safari',
|
|
129
127
|
browserTypes_1.BrowserType.Webkit,
|
|
130
128
|
].map((browser) => browser.toString());
|
|
131
129
|
exports.ValidBrowserTypesForLocalRuns = [
|
|
@@ -141,6 +141,8 @@ async function createBrowserForExecutionEngine(engine, proxyInfo, options) {
|
|
|
141
141
|
if (!maybeBrowser) {
|
|
142
142
|
throw new Error('Unable to start browser session');
|
|
143
143
|
}
|
|
144
|
+
(0, logUtils_1.logCliOutput)(loggingProvider_1.LogLevel.Info, `Setting apiProxy server [${proxyInfo.httpProxy}]`);
|
|
145
|
+
maybeBrowser.setApiProxy(proxyInfo.httpProxy);
|
|
144
146
|
return maybeBrowser;
|
|
145
147
|
}
|
|
146
148
|
exports.createBrowserForExecutionEngine = createBrowserForExecutionEngine;
|
|
@@ -189,8 +189,10 @@ exports.builder = (yargs) => {
|
|
|
189
189
|
})
|
|
190
190
|
.check((argv) => {
|
|
191
191
|
(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]);
|
|
192
|
-
if (argv[constants_1.CommandArgDataTableId] &&
|
|
193
|
-
|
|
192
|
+
if (argv[constants_1.CommandArgDataTableId] &&
|
|
193
|
+
!argv[constants_1.CommandArgId] &&
|
|
194
|
+
!argv[constants_1.CommandArgFromPlanId]) {
|
|
195
|
+
throw new Error(`The ${constants_1.CommandArgDataTableId} option can only be used with the ${constants_1.CommandArgId} or the ${constants_1.CommandArgFromPlanId} option`);
|
|
194
196
|
}
|
|
195
197
|
if (argv[constants_1.CommandArgDataTableId] && argv[constants_1.CommandArgScenarioId]) {
|
|
196
198
|
throw new Error(`The ${constants_1.CommandArgScenarioId} option cannot be used with the ${constants_1.CommandArgDataTableId} option`);
|