@mablhq/mabl-cli 1.58.25 → 1.59.5
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 +15 -21
- package/api/mablApiClient.js +54 -43
- package/api/mablApiClientFactory.js +1 -1
- package/auth/OktaClient.js +2 -1
- package/browserEngines/chromiumBrowserEngine.js +2 -2
- package/browserEngines/firefoxBrowserEngine.js +2 -2
- package/browserEngines/webkitBrowerEngine.js +2 -2
- package/browserLauncher/browserLauncherFactory.js +3 -2
- package/browserLauncher/elementHandle.js +2 -1
- package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumElementHandleDelegate.js +20 -12
- package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumFrameDelegate.js +1 -1
- package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumPageDelegate.js +10 -7
- package/browserLauncher/playwrightBrowserLauncher/firefox/firefoxFrameDelegate.js +4 -3
- package/browserLauncher/playwrightBrowserLauncher/nonChromium/nonChromiumAbstractElementHandleDelegate.js +5 -4
- package/browserLauncher/playwrightBrowserLauncher/nonChromium/nonChromiumAbstractPageDelegate.js +7 -4
- package/browserLauncher/playwrightBrowserLauncher/playwrightBrowser.js +1 -1
- package/browserLauncher/playwrightBrowserLauncher/playwrightBrowserLauncher.js +7 -6
- package/browserLauncher/playwrightBrowserLauncher/playwrightDom.js +37 -31
- package/browserLauncher/playwrightBrowserLauncher/playwrightFrame.js +9 -8
- package/browserLauncher/playwrightBrowserLauncher/playwrightHttpRequest.js +8 -4
- package/browserLauncher/playwrightBrowserLauncher/playwrightPage.js +5 -3
- package/browserLauncher/playwrightBrowserLauncher/webkit/webkitElementHandleDelegate.js +2 -1
- package/browserLauncher/playwrightBrowserLauncher/webkit/webkitFrameDelegate.js +1 -1
- package/browserTestMonitoring/cloudMonitoringPerformanceMetrics.js +28 -56
- package/browserTestMonitoring/distributions.js +1 -6
- package/browserTestMonitoring/metricsRecorder.js +47 -30
- package/commands/commandUtil/branches.js +3 -2
- package/commands/commandUtil/codeInsights.js +16 -13
- package/commands/commandUtil/fileUtil.js +1 -1
- package/commands/commandUtil/util.js +5 -3
- package/commands/commandUtil/versionUtil.js +5 -4
- package/commands/config/config_cmds/list.js +2 -2
- package/commands/datatables/datatables_cmds/create.js +3 -2
- package/commands/datatables/datatables_cmds/export.js +5 -3
- package/commands/datatables/datatables_cmds/list.js +2 -1
- package/commands/datatables/datatables_cmds/scenarios.js +2 -1
- package/commands/datatables/datatables_cmds/update.js +11 -11
- package/commands/datatables/utils.js +9 -9
- package/commands/deploy/deploy_cmds/awaitDeploymentCompletion.js +8 -6
- package/commands/deploy/deploy_cmds/create.js +13 -11
- package/commands/deploy/deploy_cmds/executionResultPresenter.js +11 -8
- package/commands/deploy/deploy_cmds/list.js +4 -3
- package/commands/deploy/deploy_cmds/watch.js +2 -1
- package/commands/environments/environments_cmds/create.js +2 -1
- package/commands/environments/environments_cmds/delete.js +2 -1
- package/commands/environments/environments_cmds/update.js +2 -1
- package/commands/environments/environments_cmds/urls_cmds/list.js +2 -1
- package/commands/flows/flows_cmds/export.js +5 -4
- package/commands/plans/plans_cmds/describe.js +2 -1
- package/commands/tests/mobileEmulationUtil.js +7 -5
- package/commands/tests/testsUtil.js +46 -42
- package/commands/tests/tests_cmds/export.js +2 -1
- package/commands/tests/tests_cmds/import.js +5 -4
- package/commands/tests/tests_cmds/run-cloud.js +34 -15
- package/commands/tests/tests_cmds/run.js +11 -11
- package/commands/users/users_cmds/list.js +2 -2
- package/commands/workspaces/workspace_cmds/copy.js +2 -1
- package/core/execution/ApiTestUtils.js +94 -82
- package/core/messaging/logLineMessaging.js +3 -2
- package/core/messaging/messaging.js +7 -6
- package/core/trainer/trainingSessions.js +32 -16
- package/coreWebVitals/index.js +18 -14
- package/execution/index.js +1 -1
- package/functions/apiTest/utils.js +5 -4
- package/http/MablHttpAgent.js +6 -4
- package/http/RequestSecurityError.js +1 -1
- package/http/axiosProxyConfig.js +5 -3
- package/http/httpUtil.js +3 -2
- package/http/requestInterceptor.js +15 -11
- package/mablApi/index.js +1 -1
- package/mablscript/MablAction.js +3 -2
- package/mablscript/MablStep.js +4 -2
- package/mablscript/MablSymbol.js +1 -1
- package/mablscript/actions/ConditionAction.js +4 -2
- package/mablscript/actions/FindAction.js +4 -2
- package/mablscript/diffing/diffingUtil.js +7 -8
- package/mablscript/importer.js +2 -1
- package/mablscript/steps/AccessibilityCheck.js +9 -7
- package/mablscript/steps/AssertStep.js +16 -11
- package/mablscript/steps/ClickAndHoldStep.js +2 -1
- package/mablscript/steps/CreateVariableStep.js +2 -1
- package/mablscript/steps/DownloadStep.js +2 -1
- package/mablscript/steps/EnterTextStep.js +2 -1
- package/mablscript/steps/EvaluateFlowStep.js +1 -1
- package/mablscript/steps/IfConditionStep.js +6 -4
- package/mablscript/steps/ReleaseStep.js +2 -1
- package/mablscript/steps/SendHttpRequestStep.js +4 -2
- package/mablscript/steps/SendKeyStep.js +1 -1
- package/mablscript/steps/SetCookieStep.js +8 -7
- package/mablscript/steps/SetViewportStep.js +1 -1
- package/mablscript/steps/SwitchContextStep.js +6 -3
- package/mablscript/steps/SyntheticStep.js +2 -1
- package/middleware.js +2 -1
- package/package.json +3 -3
- package/popupDismissal/index.js +5 -4
- package/providers/authenticationProvider.js +6 -5
- package/providers/cliConfigProvider.js +12 -10
- package/providers/exportRequestProvider.js +5 -3
- package/providers/logging/loggingProvider.js +1 -1
- package/reporters/mochAwesome/mochAwesomeReporter.js +14 -12
- package/util/TestOutputWriter.js +12 -8
- package/util/actionabilityUtil.js +1 -1
- package/util/analytics.js +9 -6
- package/util/browserTestUtils.js +2 -1
- package/util/markdownUtil.js +11 -9
package/api/basicApiClient.js
CHANGED
|
@@ -56,8 +56,9 @@ const RETRYABLE_NODEJS_ERRORS = [
|
|
|
56
56
|
const DEFAULT_SSL_VERIFY = false;
|
|
57
57
|
class BasicApiClient {
|
|
58
58
|
constructor(options) {
|
|
59
|
+
var _a, _b, _c, _d, _e;
|
|
59
60
|
const config = (0, axiosProxyConfig_1.axiosProxyConfig)({
|
|
60
|
-
sslVerify: options.sslVerify
|
|
61
|
+
sslVerify: (_a = options.sslVerify) !== null && _a !== void 0 ? _a : DEFAULT_SSL_VERIFY,
|
|
61
62
|
proxyHost: options.proxyUrl,
|
|
62
63
|
proxyType: options.proxyType,
|
|
63
64
|
});
|
|
@@ -65,9 +66,7 @@ class BasicApiClient {
|
|
|
65
66
|
config.headers = {};
|
|
66
67
|
}
|
|
67
68
|
config.timeout =
|
|
68
|
-
options.requestTimeoutMillis
|
|
69
|
-
options.retryConfig?.requestTimeoutMillis ??
|
|
70
|
-
DEFAULT_RETRYABLE_REQUEST_TIMEOUT_MILLISECONDS;
|
|
69
|
+
(_d = (_b = options.requestTimeoutMillis) !== null && _b !== void 0 ? _b : (_c = options.retryConfig) === null || _c === void 0 ? void 0 : _c.requestTimeoutMillis) !== null && _d !== void 0 ? _d : DEFAULT_RETRYABLE_REQUEST_TIMEOUT_MILLISECONDS;
|
|
71
70
|
config.maxBodyLength = Infinity;
|
|
72
71
|
config.maxContentLength = Infinity;
|
|
73
72
|
switch (options.authType) {
|
|
@@ -106,7 +105,7 @@ class BasicApiClient {
|
|
|
106
105
|
this.httpClient = axios_1.default.create(config);
|
|
107
106
|
this.httpClient.defaults.headers.common = { ...config.headers };
|
|
108
107
|
this.retryConfig = options.retryConfig;
|
|
109
|
-
this.debugLogger = options.debugLogger
|
|
108
|
+
this.debugLogger = (_e = options.debugLogger) !== null && _e !== void 0 ? _e : logUtils_1.logInternal;
|
|
110
109
|
}
|
|
111
110
|
static async create() {
|
|
112
111
|
const httpConfig = (await cliConfigProvider_1.CliConfigProvider.getCliConfig()).http.mabl;
|
|
@@ -119,7 +118,7 @@ class BasicApiClient {
|
|
|
119
118
|
});
|
|
120
119
|
}
|
|
121
120
|
getNonRetryableRequestConfig(override) {
|
|
122
|
-
const overrideWithTimeout = { ...(override
|
|
121
|
+
const overrideWithTimeout = { ...(override !== null && override !== void 0 ? override : {}) };
|
|
123
122
|
if (!overrideWithTimeout.timeout) {
|
|
124
123
|
overrideWithTimeout.timeout =
|
|
125
124
|
DEFAULT_NONRETRYABLE_REQUEST_TIMEOUT_MILLISECONDS;
|
|
@@ -127,8 +126,9 @@ class BasicApiClient {
|
|
|
127
126
|
return { ...this.httpRequestConfig, ...overrideWithTimeout };
|
|
128
127
|
}
|
|
129
128
|
getRetryableRequestConfig(retryConfig) {
|
|
129
|
+
var _a;
|
|
130
130
|
return this.getNonRetryableRequestConfig({
|
|
131
|
-
timeout: retryConfig
|
|
131
|
+
timeout: (_a = retryConfig === null || retryConfig === void 0 ? void 0 : retryConfig.requestTimeoutMillis) !== null && _a !== void 0 ? _a : this.httpRequestConfig.timeout,
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
134
|
makeGetRequest(path, retryConfig, axiosConfig) {
|
|
@@ -146,11 +146,12 @@ class BasicApiClient {
|
|
|
146
146
|
return this.retryWrappedRequest(`makeGetRequestWithETag('${path}')`, () => this.getRequestWithETag(path, this.getRetryableRequestConfig(retryConfig)), retryConfig);
|
|
147
147
|
}
|
|
148
148
|
async getRequestWithETag(path, config) {
|
|
149
|
+
var _a;
|
|
149
150
|
const response = await this.debugRequest('GET', path, () => this.httpClient.get(path, config));
|
|
150
151
|
BasicApiClient.checkResponseStatusCode(response);
|
|
151
152
|
const headers = response.headers;
|
|
152
153
|
const result = response.data;
|
|
153
|
-
const versionHeader = headers[MABL_ENTITY_VERSION_HEADER]
|
|
154
|
+
const versionHeader = (_a = headers[MABL_ENTITY_VERSION_HEADER]) === null || _a === void 0 ? void 0 : _a.toString();
|
|
154
155
|
if (!versionHeader) {
|
|
155
156
|
throw new Error(`Missing ${MABL_ENTITY_VERSION_HEADER} header`);
|
|
156
157
|
}
|
|
@@ -207,7 +208,7 @@ class BasicApiClient {
|
|
|
207
208
|
throw e;
|
|
208
209
|
}
|
|
209
210
|
finally {
|
|
210
|
-
this.debugLogger(`API Client: ${method} ${path} ${error ? 'failed' : 'completed'} in ${Date.now() - startTimeMillis}ms with ${responseCode
|
|
211
|
+
this.debugLogger(`API Client: ${method} ${path} ${error ? 'failed' : 'completed'} in ${Date.now() - startTimeMillis}ms with ${responseCode !== null && responseCode !== void 0 ? responseCode : error}`);
|
|
211
212
|
}
|
|
212
213
|
}
|
|
213
214
|
static checkResponseStatusCode(response) {
|
|
@@ -217,19 +218,12 @@ class BasicApiClient {
|
|
|
217
218
|
}
|
|
218
219
|
}
|
|
219
220
|
retryWrappedRequest(description, requestFunc, retryConfigOverride) {
|
|
221
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
220
222
|
const retryOptions = {
|
|
221
|
-
retries: retryConfigOverride
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
this.retryConfig?.minRetryIntervalMillis ??
|
|
226
|
-
DEFAULT_MIN_RETRY_INTERVAL_MILLISECONDS,
|
|
227
|
-
maxTimeout: retryConfigOverride?.maxRetryIntervalMillis ??
|
|
228
|
-
this.retryConfig?.maxRetryIntervalMillis ??
|
|
229
|
-
DEFAULT_MAX_RETRY_INTERVAL_MILLISECONDS,
|
|
230
|
-
maxRetryTime: retryConfigOverride?.maxRetryTimeMillis ??
|
|
231
|
-
this.retryConfig?.maxRetryTimeMillis ??
|
|
232
|
-
DEFAULT_MAX_TOTAL_RETRY_TIME_MILLISECONDS,
|
|
223
|
+
retries: (_c = (_a = retryConfigOverride === null || retryConfigOverride === void 0 ? void 0 : retryConfigOverride.retryCount) !== null && _a !== void 0 ? _a : (_b = this.retryConfig) === null || _b === void 0 ? void 0 : _b.retryCount) !== null && _c !== void 0 ? _c : DEFAULT_RETRIES,
|
|
224
|
+
minTimeout: (_f = (_d = retryConfigOverride === null || retryConfigOverride === void 0 ? void 0 : retryConfigOverride.minRetryIntervalMillis) !== null && _d !== void 0 ? _d : (_e = this.retryConfig) === null || _e === void 0 ? void 0 : _e.minRetryIntervalMillis) !== null && _f !== void 0 ? _f : DEFAULT_MIN_RETRY_INTERVAL_MILLISECONDS,
|
|
225
|
+
maxTimeout: (_j = (_g = retryConfigOverride === null || retryConfigOverride === void 0 ? void 0 : retryConfigOverride.maxRetryIntervalMillis) !== null && _g !== void 0 ? _g : (_h = this.retryConfig) === null || _h === void 0 ? void 0 : _h.maxRetryIntervalMillis) !== null && _j !== void 0 ? _j : DEFAULT_MAX_RETRY_INTERVAL_MILLISECONDS,
|
|
226
|
+
maxRetryTime: (_m = (_k = retryConfigOverride === null || retryConfigOverride === void 0 ? void 0 : retryConfigOverride.maxRetryTimeMillis) !== null && _k !== void 0 ? _k : (_l = this.retryConfig) === null || _l === void 0 ? void 0 : _l.maxRetryTimeMillis) !== null && _m !== void 0 ? _m : DEFAULT_MAX_TOTAL_RETRY_TIME_MILLISECONDS,
|
|
233
227
|
onRetry: (error) => {
|
|
234
228
|
this.debugLogger(`Retrying failed API request "${description}"`, error);
|
|
235
229
|
},
|
package/api/mablApiClient.js
CHANGED
|
@@ -13,8 +13,9 @@ const query_string_1 = __importDefault(require("query-string"));
|
|
|
13
13
|
const featureSet_1 = require("./featureSet");
|
|
14
14
|
class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
15
15
|
constructor(options) {
|
|
16
|
+
var _a;
|
|
16
17
|
super(options);
|
|
17
|
-
this.baseApiUrl = options.apiUrl
|
|
18
|
+
this.baseApiUrl = (_a = options.apiUrl) !== null && _a !== void 0 ? _a : env_1.BASE_API_URL;
|
|
18
19
|
}
|
|
19
20
|
async getPlan(planId) {
|
|
20
21
|
try {
|
|
@@ -25,11 +26,12 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
28
|
async getPlans(options) {
|
|
29
|
+
var _a, _b;
|
|
28
30
|
try {
|
|
29
31
|
const queryArg = query_string_1.default.stringify(options);
|
|
30
32
|
const plans = await this.makeGetRequest(`${this.baseApiUrl}/schedule/runPolicy/?${queryArg}`);
|
|
31
|
-
sortTemporallyAscending(plans.run_policies
|
|
32
|
-
return plans.run_policies
|
|
33
|
+
sortTemporallyAscending((_a = plans.run_policies) !== null && _a !== void 0 ? _a : []);
|
|
34
|
+
return (_b = plans.run_policies) !== null && _b !== void 0 ? _b : [];
|
|
33
35
|
}
|
|
34
36
|
catch (error) {
|
|
35
37
|
throw toApiError(`Failed to get plans (workspace: ${options.organization_id})`, error);
|
|
@@ -49,7 +51,7 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
|
49
51
|
organization_id: workspaceId,
|
|
50
52
|
limit,
|
|
51
53
|
});
|
|
52
|
-
const applications = await this.makeGetRequest(`${this.baseApiUrl}/applications?${applicationQueryString}`).then((result) => result.applications
|
|
54
|
+
const applications = await this.makeGetRequest(`${this.baseApiUrl}/applications?${applicationQueryString}`).then((result) => { var _a; return (_a = result.applications) !== null && _a !== void 0 ? _a : []; });
|
|
53
55
|
sortTemporallyAscending(applications);
|
|
54
56
|
return applications;
|
|
55
57
|
}
|
|
@@ -99,7 +101,7 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
|
99
101
|
organization_id: workspaceId,
|
|
100
102
|
limit,
|
|
101
103
|
});
|
|
102
|
-
const environments = await this.makeGetRequest(`${this.baseApiUrl}/v1/environments/?${environmentQueryString}`).then((result) => result.environments
|
|
104
|
+
const environments = await this.makeGetRequest(`${this.baseApiUrl}/v1/environments/?${environmentQueryString}`).then((result) => { var _a; return (_a = result.environments) !== null && _a !== void 0 ? _a : []; });
|
|
103
105
|
sortTemporallyAscending(environments);
|
|
104
106
|
return environments;
|
|
105
107
|
}
|
|
@@ -136,8 +138,9 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
|
136
138
|
}
|
|
137
139
|
}
|
|
138
140
|
async getLinkAgentsWithRecentHeartbeats(workspaceId, limit, maxHeartbeatAgeSeconds) {
|
|
141
|
+
var _a;
|
|
139
142
|
try {
|
|
140
|
-
return ((await this.makeGetRequest(`${env_1.BASE_API_URL}/link/agents?workspace_id=${workspaceId}&limit=${limit}&max_heartbeat_age_sec=${maxHeartbeatAgeSeconds}`)).link_agents
|
|
143
|
+
return ((_a = (await this.makeGetRequest(`${env_1.BASE_API_URL}/link/agents?workspace_id=${workspaceId}&limit=${limit}&max_heartbeat_age_sec=${maxHeartbeatAgeSeconds}`)).link_agents) !== null && _a !== void 0 ? _a : []);
|
|
141
144
|
}
|
|
142
145
|
catch (error) {
|
|
143
146
|
throw toApiError(`Failed to get active link agents`, error);
|
|
@@ -168,7 +171,7 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
|
168
171
|
organization_id: workspaceId,
|
|
169
172
|
limit,
|
|
170
173
|
});
|
|
171
|
-
return await this.makeGetRequest(`${this.baseApiUrl}/credentials?${credentialsQueryString}`).then((result) => result.credentials
|
|
174
|
+
return await this.makeGetRequest(`${this.baseApiUrl}/credentials?${credentialsQueryString}`).then((result) => { var _a; return (_a = result.credentials) !== null && _a !== void 0 ? _a : []; });
|
|
172
175
|
}
|
|
173
176
|
catch (error) {
|
|
174
177
|
throw toApiError(`Failed to get credentials`, error);
|
|
@@ -192,7 +195,7 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
|
192
195
|
workspace_id: workspaceId,
|
|
193
196
|
limit,
|
|
194
197
|
});
|
|
195
|
-
return await this.makeGetRequest(`${this.baseApiUrl}/events/deployment?${deploymentQueryString}`).then((result) => result.deployments
|
|
198
|
+
return await this.makeGetRequest(`${this.baseApiUrl}/events/deployment?${deploymentQueryString}`).then((result) => { var _a; return (_a = result.deployments) !== null && _a !== void 0 ? _a : []; });
|
|
196
199
|
}
|
|
197
200
|
catch (error) {
|
|
198
201
|
throw toApiError(`Failed to get deployment events`, error);
|
|
@@ -239,7 +242,7 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
|
239
242
|
}
|
|
240
243
|
async getTestFindSummaries(testId, environmentId) {
|
|
241
244
|
try {
|
|
242
|
-
return await this.makeGetRequest(`${this.baseApiUrl}/findSummary?journey_id=${testId}&environment_id=${environmentId}`).then((result) => result.findsummaries
|
|
245
|
+
return await this.makeGetRequest(`${this.baseApiUrl}/findSummary?journey_id=${testId}&environment_id=${environmentId}`).then((result) => { var _a; return (_a = result.findsummaries) !== null && _a !== void 0 ? _a : []; });
|
|
243
246
|
}
|
|
244
247
|
catch (error) {
|
|
245
248
|
throw toApiError(`Failed to get test find summaries results`, error);
|
|
@@ -247,7 +250,7 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
|
247
250
|
}
|
|
248
251
|
async getTestFindModels(testId, environmentId) {
|
|
249
252
|
try {
|
|
250
|
-
return await this.makeGetRequest(`${this.baseApiUrl}/findModel/test/${testId}?environment_id=${environmentId}`).then((result) => result.findModels
|
|
253
|
+
return await this.makeGetRequest(`${this.baseApiUrl}/findModel/test/${testId}?environment_id=${environmentId}`).then((result) => { var _a; return (_a = result.findModels) !== null && _a !== void 0 ? _a : []; });
|
|
251
254
|
}
|
|
252
255
|
catch (error) {
|
|
253
256
|
throw toApiError(`Failed to get test find model results`, error);
|
|
@@ -255,7 +258,7 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
|
255
258
|
}
|
|
256
259
|
async getTestOverrides(testId, environmentId, selectorOverrideLimit = 10) {
|
|
257
260
|
try {
|
|
258
|
-
return await this.makeGetRequest(`${this.baseApiUrl}/tests/testScripts/${testId}/overrides?environment_id=${environmentId}&selector_override_limit=${selectorOverrideLimit}`).then((result) => result.overrides
|
|
261
|
+
return await this.makeGetRequest(`${this.baseApiUrl}/tests/testScripts/${testId}/overrides?environment_id=${environmentId}&selector_override_limit=${selectorOverrideLimit}`).then((result) => { var _a; return (_a = result.overrides) !== null && _a !== void 0 ? _a : []; });
|
|
259
262
|
}
|
|
260
263
|
catch (error) {
|
|
261
264
|
throw toApiError(`Failed to get selector overrides`, error);
|
|
@@ -278,11 +281,10 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
|
278
281
|
}
|
|
279
282
|
}
|
|
280
283
|
async getWorkspaces(limit) {
|
|
284
|
+
var _a, _b;
|
|
281
285
|
try {
|
|
282
286
|
const userInfo = await this.getSelf();
|
|
283
|
-
const requests = userInfo.roles
|
|
284
|
-
?.slice(0, limit)
|
|
285
|
-
.map((role) => this.getWorkspace(role.organization_id)) ?? [];
|
|
287
|
+
const requests = (_b = (_a = userInfo.roles) === null || _a === void 0 ? void 0 : _a.slice(0, limit).map((role) => this.getWorkspace(role.organization_id))) !== null && _b !== void 0 ? _b : [];
|
|
286
288
|
const workspaces = await Promise.all(requests);
|
|
287
289
|
sortTemporallyAscending(workspaces);
|
|
288
290
|
return workspaces;
|
|
@@ -324,14 +326,15 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
|
324
326
|
}
|
|
325
327
|
}
|
|
326
328
|
async getSelf() {
|
|
329
|
+
var _a, _b;
|
|
327
330
|
try {
|
|
328
331
|
const selfInfo = await this.makeGetRequest(`${this.baseApiUrl}/self`);
|
|
329
|
-
if (selfInfo.preferences
|
|
332
|
+
if (((_a = selfInfo.preferences) === null || _a === void 0 ? void 0 : _a.default_workspace_id) &&
|
|
330
333
|
!(await cliConfigProvider_1.CliConfigProvider.getWorkspace())) {
|
|
331
334
|
const workspace = await this.getWorkspace(selfInfo.preferences.default_workspace_id);
|
|
332
335
|
await cliConfigProvider_1.CliConfigProvider.setWorkspace(workspace);
|
|
333
336
|
}
|
|
334
|
-
else if (selfInfo.roles
|
|
337
|
+
else if (((_b = selfInfo.roles) === null || _b === void 0 ? void 0 : _b.length) === 1) {
|
|
335
338
|
const workspace = await this.getWorkspace(selfInfo.roles[0].organization_id);
|
|
336
339
|
await cliConfigProvider_1.CliConfigProvider.setWorkspace(workspace);
|
|
337
340
|
}
|
|
@@ -355,9 +358,10 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
|
355
358
|
}
|
|
356
359
|
}
|
|
357
360
|
async getJourneys(options) {
|
|
361
|
+
var _a;
|
|
358
362
|
try {
|
|
359
363
|
const queryArg = query_string_1.default.stringify(options);
|
|
360
|
-
const journeys = (await this.makeGetRequest(`${this.baseApiUrl}/test/journeys?${queryArg}`)).journeys
|
|
364
|
+
const journeys = (_a = (await this.makeGetRequest(`${this.baseApiUrl}/test/journeys?${queryArg}`)).journeys) !== null && _a !== void 0 ? _a : [];
|
|
361
365
|
sortTemporallyAscending(journeys);
|
|
362
366
|
return journeys;
|
|
363
367
|
}
|
|
@@ -378,9 +382,10 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
|
378
382
|
}
|
|
379
383
|
}
|
|
380
384
|
async getFlows(options) {
|
|
385
|
+
var _a;
|
|
381
386
|
try {
|
|
382
387
|
const queryArg = query_string_1.default.stringify(options);
|
|
383
|
-
const flows = (await this.makeGetRequest(`${this.baseApiUrl}/flows?${queryArg}`)).flows
|
|
388
|
+
const flows = (_a = (await this.makeGetRequest(`${this.baseApiUrl}/flows?${queryArg}`)).flows) !== null && _a !== void 0 ? _a : [];
|
|
384
389
|
sortTemporallyAscending(flows);
|
|
385
390
|
return flows;
|
|
386
391
|
}
|
|
@@ -422,7 +427,7 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
|
422
427
|
limit,
|
|
423
428
|
status: statusFilter,
|
|
424
429
|
});
|
|
425
|
-
return await this.makeGetRequest(`${this.baseApiUrl}/branch?${branchQueryString}`).then((result) => result.branches
|
|
430
|
+
return await this.makeGetRequest(`${this.baseApiUrl}/branch?${branchQueryString}`).then((result) => { var _a; return (_a = result.branches) !== null && _a !== void 0 ? _a : []; });
|
|
426
431
|
}
|
|
427
432
|
catch (error) {
|
|
428
433
|
throw toApiError(`Failed to get Branches`, error);
|
|
@@ -497,7 +502,7 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
|
497
502
|
async getSessionEmails(sessionId) {
|
|
498
503
|
try {
|
|
499
504
|
const emailQueryString = query_string_1.default.stringify({
|
|
500
|
-
context_id: sessionId
|
|
505
|
+
context_id: sessionId === null || sessionId === void 0 ? void 0 : sessionId.slice(0, 8),
|
|
501
506
|
});
|
|
502
507
|
return await this.makeGetRequest(`${this.baseApiUrl}/execution/inputs?${emailQueryString}`);
|
|
503
508
|
}
|
|
@@ -518,7 +523,7 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
|
518
523
|
}
|
|
519
524
|
}
|
|
520
525
|
async createMailboxAddress(workspaceId, sessionId) {
|
|
521
|
-
const contextId = sessionId
|
|
526
|
+
const contextId = sessionId === null || sessionId === void 0 ? void 0 : sessionId.slice(0, 8);
|
|
522
527
|
try {
|
|
523
528
|
const body = {
|
|
524
529
|
context_id: contextId,
|
|
@@ -595,6 +600,7 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
|
595
600
|
}
|
|
596
601
|
}
|
|
597
602
|
buildDeploymentRequestBody(options) {
|
|
603
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
598
604
|
const requestBody = { properties: {} };
|
|
599
605
|
if (options.environmentId) {
|
|
600
606
|
requestBody.environment_id = options.environmentId;
|
|
@@ -602,26 +608,26 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
|
602
608
|
if (options.applicationId) {
|
|
603
609
|
requestBody.application_id = options.applicationId;
|
|
604
610
|
}
|
|
605
|
-
requestBody.revision = options.sourceControlMetadata
|
|
611
|
+
requestBody.revision = (_a = options.sourceControlMetadata) === null || _a === void 0 ? void 0 : _a.revision;
|
|
606
612
|
if (options.mablBranch) {
|
|
607
613
|
requestBody.source_control_tag = options.mablBranch;
|
|
608
614
|
}
|
|
609
615
|
requestBody.properties.repository_branch_name =
|
|
610
|
-
options.sourceControlMetadata
|
|
616
|
+
(_b = options.sourceControlMetadata) === null || _b === void 0 ? void 0 : _b.branchName;
|
|
611
617
|
requestBody.properties.repository_tag_name =
|
|
612
|
-
options.sourceControlMetadata
|
|
618
|
+
(_c = options.sourceControlMetadata) === null || _c === void 0 ? void 0 : _c.branchName;
|
|
613
619
|
requestBody.properties.repository_url =
|
|
614
|
-
options.sourceControlMetadata
|
|
620
|
+
(_d = options.sourceControlMetadata) === null || _d === void 0 ? void 0 : _d.repoUrl;
|
|
615
621
|
requestBody.properties.repository_name =
|
|
616
|
-
options.sourceControlMetadata
|
|
622
|
+
(_e = options.sourceControlMetadata) === null || _e === void 0 ? void 0 : _e.repoName;
|
|
617
623
|
const planOverrides = {};
|
|
618
|
-
if (options.browserTypes
|
|
624
|
+
if ((_f = options.browserTypes) === null || _f === void 0 ? void 0 : _f.length) {
|
|
619
625
|
planOverrides.browser_types = options.browserTypes;
|
|
620
626
|
}
|
|
621
627
|
if (options.runnerType) {
|
|
622
628
|
planOverrides.nodejs_runtime_variant = options.runnerType;
|
|
623
629
|
}
|
|
624
|
-
if (options.labels
|
|
630
|
+
if ((_g = options.labels) === null || _g === void 0 ? void 0 : _g.length) {
|
|
625
631
|
requestBody.plan_labels = options.labels;
|
|
626
632
|
}
|
|
627
633
|
if (options.uri) {
|
|
@@ -636,7 +642,7 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
|
636
642
|
if (options.deploymentIds) {
|
|
637
643
|
planOverrides.deployment_ids = options.deploymentIds;
|
|
638
644
|
}
|
|
639
|
-
if (options.httpHeaders
|
|
645
|
+
if ((_h = options.httpHeaders) === null || _h === void 0 ? void 0 : _h.length) {
|
|
640
646
|
planOverrides.http_headers = options.httpHeaders.map((header) => {
|
|
641
647
|
const parts = header.split(':', 2);
|
|
642
648
|
return {
|
|
@@ -672,16 +678,16 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
|
672
678
|
throw toApiError(`Failed to retrieve tests for plan`, error);
|
|
673
679
|
}
|
|
674
680
|
}
|
|
675
|
-
async postPlanRun(organizationId, testId, branchName, browserTypes, appUrl, apiUrl, deploymentId, credentialsId, deploymentIds, basicAuthCredentialsId) {
|
|
681
|
+
async postPlanRun(organizationId, testId, branchName, browserTypes, appUrl, apiUrl, deploymentId, credentialsId, deploymentIds, basicAuthCredentialsId, localizationOptions) {
|
|
676
682
|
try {
|
|
677
|
-
const requestBody = this.buildAdHocPlanRunRequestBody(organizationId, testId, browserTypes, branchName, appUrl, apiUrl, deploymentId, credentialsId, deploymentIds, basicAuthCredentialsId);
|
|
683
|
+
const requestBody = this.buildAdHocPlanRunRequestBody(organizationId, testId, browserTypes, branchName, appUrl, apiUrl, deploymentId, credentialsId, deploymentIds, basicAuthCredentialsId, localizationOptions);
|
|
678
684
|
return await this.makePostRequest(`${this.baseApiUrl}/planRuns/`, requestBody);
|
|
679
685
|
}
|
|
680
686
|
catch (error) {
|
|
681
687
|
throw toApiError(`Failed to create planRun`, error);
|
|
682
688
|
}
|
|
683
689
|
}
|
|
684
|
-
buildAdHocPlanRunRequestBody(organizationId, testId, browserTypes, branchName, appUrl, apiUrl, deploymentId, credentialsId, deploymentIds, basicAuthCredentialsId) {
|
|
690
|
+
buildAdHocPlanRunRequestBody(organizationId, testId, browserTypes, branchName, appUrl, apiUrl, deploymentId, credentialsId, deploymentIds, basicAuthCredentialsId, localizationOptions) {
|
|
685
691
|
const requestBody = {
|
|
686
692
|
ad_hoc_run_info: {
|
|
687
693
|
is_ad_hoc_run: true,
|
|
@@ -694,7 +700,7 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
|
694
700
|
if (deploymentId) {
|
|
695
701
|
planOverrides.deployment_id = deploymentId;
|
|
696
702
|
}
|
|
697
|
-
if (browserTypes
|
|
703
|
+
if (browserTypes === null || browserTypes === void 0 ? void 0 : browserTypes.length) {
|
|
698
704
|
planOverrides.browser_types = browserTypes;
|
|
699
705
|
}
|
|
700
706
|
if (appUrl) {
|
|
@@ -711,6 +717,9 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
|
711
717
|
planOverrides.http_auth_credentials_id = basicAuthCredentialsId;
|
|
712
718
|
planOverrides.http_auth_credentials_required = true;
|
|
713
719
|
}
|
|
720
|
+
if (localizationOptions) {
|
|
721
|
+
planOverrides.localization_options = [localizationOptions];
|
|
722
|
+
}
|
|
714
723
|
if (testId) {
|
|
715
724
|
planOverrides.journeys = [{ journey_id: testId }];
|
|
716
725
|
planOverrides.execution_stages = [
|
|
@@ -799,18 +808,20 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
|
799
808
|
});
|
|
800
809
|
}
|
|
801
810
|
async getEffectiveFeaturesByWorkspaceId(workspaceId) {
|
|
811
|
+
var _a;
|
|
802
812
|
try {
|
|
803
813
|
const account = await this.getAccountByWorkspaceId(workspaceId);
|
|
804
|
-
return new featureSet_1.FeatureSet(new Set(account.effective_features
|
|
814
|
+
return new featureSet_1.FeatureSet(new Set((_a = account.effective_features) !== null && _a !== void 0 ? _a : []));
|
|
805
815
|
}
|
|
806
816
|
catch (error) {
|
|
807
817
|
throw toApiError(`Failed to get feature flags for workspace ${workspaceId}`, error);
|
|
808
818
|
}
|
|
809
819
|
}
|
|
810
820
|
async getEnabledLabsFeaturesForWorkspace(workspaceId) {
|
|
821
|
+
var _a;
|
|
811
822
|
try {
|
|
812
823
|
const workspace = await this.getWorkspace(workspaceId);
|
|
813
|
-
return new featureSet_1.FeatureSet(new Set(workspace.labs_features
|
|
824
|
+
return new featureSet_1.FeatureSet(new Set((_a = workspace.labs_features) !== null && _a !== void 0 ? _a : []));
|
|
814
825
|
}
|
|
815
826
|
catch (error) {
|
|
816
827
|
throw toApiError(`Failed to get labs features for workspace ${workspaceId}`, error);
|
|
@@ -822,7 +833,7 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
|
822
833
|
organization_id: workspaceId,
|
|
823
834
|
limit,
|
|
824
835
|
});
|
|
825
|
-
const users = await this.makeGetRequest(`${this.baseApiUrl}/users/?${userQueryString}`).then((result) => result.users
|
|
836
|
+
const users = await this.makeGetRequest(`${this.baseApiUrl}/users/?${userQueryString}`).then((result) => { var _a; return (_a = result.users) !== null && _a !== void 0 ? _a : []; });
|
|
826
837
|
sortTemporallyAscending(users);
|
|
827
838
|
return users;
|
|
828
839
|
}
|
|
@@ -835,7 +846,7 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
|
835
846
|
const stepIdsQueryString = query_string_1.default.stringify({
|
|
836
847
|
flow_variant_ids: [flowIds],
|
|
837
848
|
});
|
|
838
|
-
return await this.makeGetRequest(`${this.baseApiUrl}/test/journey/${journeyInvariantId}/stepIdsByFlow?${stepIdsQueryString}`).then((result) => result
|
|
849
|
+
return await this.makeGetRequest(`${this.baseApiUrl}/test/journey/${journeyInvariantId}/stepIdsByFlow?${stepIdsQueryString}`).then((result) => result !== null && result !== void 0 ? result : []);
|
|
839
850
|
}
|
|
840
851
|
catch (error) {
|
|
841
852
|
throw toApiError(`Failed to get step ids in journey by flow`, error);
|
|
@@ -850,7 +861,7 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
|
850
861
|
}
|
|
851
862
|
}
|
|
852
863
|
async recordWorkspaceTimeSeriesMetricMeasurement(type, value, workspaceId, options) {
|
|
853
|
-
const labels = { ...options
|
|
864
|
+
const labels = { ...options === null || options === void 0 ? void 0 : options.labels, workspaceId };
|
|
854
865
|
return this.recordTimeSeriesMetricMeasurement(type, value, {
|
|
855
866
|
...options,
|
|
856
867
|
labels,
|
|
@@ -862,9 +873,9 @@ function sortTemporallyAscending(entities) {
|
|
|
862
873
|
entities.sort((a, b) => (a.created_time >= b.created_time ? 1 : -1));
|
|
863
874
|
}
|
|
864
875
|
function toApiError(summary, cause) {
|
|
865
|
-
const errorResponse = cause
|
|
866
|
-
const code = errorResponse
|
|
867
|
-
const mablError = errorResponse
|
|
876
|
+
const errorResponse = cause === null || cause === void 0 ? void 0 : cause.response;
|
|
877
|
+
const code = errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.status;
|
|
878
|
+
const mablError = errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.data;
|
|
868
879
|
const message = `${summary}: ${mablError
|
|
869
880
|
? `${mablError.code}: ${mablError.message} (${mablError.id})`
|
|
870
881
|
: cause.toString()}`;
|
|
@@ -872,8 +883,8 @@ function toApiError(summary, cause) {
|
|
|
872
883
|
}
|
|
873
884
|
function createTimeSeriesMetricMeasurement(type, numberValue, options) {
|
|
874
885
|
return {
|
|
875
|
-
labels: options
|
|
876
|
-
event_time: options
|
|
886
|
+
labels: options === null || options === void 0 ? void 0 : options.labels,
|
|
887
|
+
event_time: options === null || options === void 0 ? void 0 : options.event_time,
|
|
877
888
|
type,
|
|
878
889
|
value: Number.isInteger(numberValue)
|
|
879
890
|
? { int64_value: numberValue }
|
|
@@ -47,7 +47,7 @@ class MablApiClientFactory {
|
|
|
47
47
|
}
|
|
48
48
|
const authProvider = new authenticationProvider_1.AuthenticationProvider();
|
|
49
49
|
const authConfig = await authProvider.getAuthConfigWithAutoRenew();
|
|
50
|
-
if (authConfig
|
|
50
|
+
if (authConfig === null || authConfig === void 0 ? void 0 : authConfig.accessToken) {
|
|
51
51
|
return new mablApiClient_1.MablApiClient({
|
|
52
52
|
...optsFromCliHttpConfig,
|
|
53
53
|
authType: authConfig.authType,
|
package/auth/OktaClient.js
CHANGED
|
@@ -64,6 +64,7 @@ class OktaClient extends AuthClient_1.AuthClient {
|
|
|
64
64
|
return authInfo;
|
|
65
65
|
}
|
|
66
66
|
exchangeRefreshTokenForAccessToken(refreshToken) {
|
|
67
|
+
var _a;
|
|
67
68
|
try {
|
|
68
69
|
return this.getBearerAuthInfo(queryString.stringify({
|
|
69
70
|
grant_type: 'refresh_token',
|
|
@@ -76,7 +77,7 @@ class OktaClient extends AuthClient_1.AuthClient {
|
|
|
76
77
|
if (!axios_1.default.isAxiosError(error)) {
|
|
77
78
|
throw error;
|
|
78
79
|
}
|
|
79
|
-
const data = error.response
|
|
80
|
+
const data = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data;
|
|
80
81
|
if (!(0, authenticationProvider_1.isOidcError)(data)) {
|
|
81
82
|
throw error;
|
|
82
83
|
}
|
|
@@ -102,12 +102,12 @@ class ChromiumBrowserEngine {
|
|
|
102
102
|
return { commandLineArgs, defaultDeviceDescriptor };
|
|
103
103
|
}
|
|
104
104
|
addBasicLaunchArgs(launchArgs, browserWidth, browserHeight, fakeMicrophoneMediaPath, fakeWebcamMediaPath, ignoreCertificateErrors, deviceDescriptor) {
|
|
105
|
-
|
|
105
|
+
var _a, _b;
|
|
106
|
+
launchArgs.push(`--window-size=${(_a = deviceDescriptor === null || deviceDescriptor === void 0 ? void 0 : deviceDescriptor.width) !== null && _a !== void 0 ? _a : browserWidth},${(_b = deviceDescriptor === null || deviceDescriptor === void 0 ? void 0 : deviceDescriptor.height) !== null && _b !== void 0 ? _b : browserHeight}`);
|
|
106
107
|
launchArgs.push('--use-fake-ui-for-media-stream');
|
|
107
108
|
launchArgs.push('--use-fake-device-for-media-stream');
|
|
108
109
|
launchArgs.push(`--use-file-for-fake-audio-capture=${fakeMicrophoneMediaPath}`);
|
|
109
110
|
launchArgs.push(`--use-file-for-fake-video-capture=${fakeWebcamMediaPath}`);
|
|
110
|
-
launchArgs.push('--disable-notifications');
|
|
111
111
|
if (ignoreCertificateErrors) {
|
|
112
112
|
launchArgs.push('--ignore-certificate-errors');
|
|
113
113
|
}
|
|
@@ -52,11 +52,11 @@ class FirefoxBrowserEngine {
|
|
|
52
52
|
}
|
|
53
53
|
prepareBrowserPreferencesDirectory(_windowPlacement, proxyInfo) {
|
|
54
54
|
const customPreferences = {};
|
|
55
|
-
if (proxyInfo
|
|
55
|
+
if (proxyInfo === null || proxyInfo === void 0 ? void 0 : proxyInfo.pacProxy) {
|
|
56
56
|
customPreferences['network.proxy.autoconfig_url'] = proxyInfo.pacProxy;
|
|
57
57
|
customPreferences['network.proxy.type'] = 2;
|
|
58
58
|
}
|
|
59
|
-
else if (proxyInfo
|
|
59
|
+
else if (proxyInfo === null || proxyInfo === void 0 ? void 0 : proxyInfo.socksProxy) {
|
|
60
60
|
const socksUrl = new URL(proxyInfo.socksProxy);
|
|
61
61
|
customPreferences['network.proxy.socks'] = socksUrl.hostname;
|
|
62
62
|
customPreferences['network.proxy.socks_port'] = Number.parseInt(socksUrl.port);
|
|
@@ -37,11 +37,11 @@ class WebkitBrowserEngine {
|
|
|
37
37
|
}
|
|
38
38
|
getProxySpec(proxyInfo) {
|
|
39
39
|
const { httpProxy, socksProxy, excludeFromProxy } = proxyInfo;
|
|
40
|
-
const server = httpProxy
|
|
40
|
+
const server = httpProxy !== null && httpProxy !== void 0 ? httpProxy : socksProxy;
|
|
41
41
|
if (!server) {
|
|
42
42
|
throw new Error('no proxy provided for cloud run');
|
|
43
43
|
}
|
|
44
|
-
const bypass = excludeFromProxy
|
|
44
|
+
const bypass = (excludeFromProxy === null || excludeFromProxy === void 0 ? void 0 : excludeFromProxy.length)
|
|
45
45
|
? excludeFromProxy.join(',')
|
|
46
46
|
: undefined;
|
|
47
47
|
return { server, bypass };
|
|
@@ -11,13 +11,14 @@ const loggingProvider_1 = require("../providers/logging/loggingProvider");
|
|
|
11
11
|
const chalk_1 = __importDefault(require("chalk"));
|
|
12
12
|
class BrowserLauncherFactory {
|
|
13
13
|
static getRunnerFromEnvironment() {
|
|
14
|
-
|
|
14
|
+
var _a;
|
|
15
|
+
return (_a = process.env.MABL_RUNNER) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
15
16
|
}
|
|
16
17
|
static createRunner(runnerType = types_1.RunnerType.Playwright, loggerFunc) {
|
|
17
18
|
const runnerFromEnv = BrowserLauncherFactory.getRunnerFromEnvironment();
|
|
18
19
|
const runner = runnerFromEnv ? runnerFromEnv : runnerType;
|
|
19
20
|
loggerFunc =
|
|
20
|
-
loggerFunc
|
|
21
|
+
loggerFunc !== null && loggerFunc !== void 0 ? loggerFunc : ((line) => (0, logUtils_1.logCliOutput)(loggingProvider_1.LogLevel.Info, line));
|
|
21
22
|
if (runner === types_1.RunnerType.Playwright) {
|
|
22
23
|
loggerFunc(chalk_1.default.cyan(`Browser launcher:`, chalk_1.default.magenta('Playwright')));
|
|
23
24
|
return new playwrightBrowserLauncher_1.PlaywrightBrowserLauncher();
|
|
@@ -11,8 +11,9 @@ const getHighlightColor = (transparency) => ({
|
|
|
11
11
|
exports.getHighlightColor = getHighlightColor;
|
|
12
12
|
function commonFocusAndSelect(element) {
|
|
13
13
|
return element.evaluate((element) => {
|
|
14
|
+
var _a;
|
|
14
15
|
element.focus();
|
|
15
|
-
element.select
|
|
16
|
+
(_a = element.select) === null || _a === void 0 ? void 0 : _a.call(element);
|
|
16
17
|
return element.value;
|
|
17
18
|
});
|
|
18
19
|
}
|
|
@@ -48,13 +48,14 @@ class ChromiumElementHandleDelegate {
|
|
|
48
48
|
return this.elementImpl;
|
|
49
49
|
}
|
|
50
50
|
checkCDPSession() {
|
|
51
|
+
var _a, _b, _c;
|
|
51
52
|
if (this.elementImpl === undefined) {
|
|
52
53
|
(0, logUtils_1.logInternal)(`Unable to get the Element's internal implementation. Some functionality, such as getting the clickable point or element highlighting might not work.`);
|
|
53
54
|
}
|
|
54
55
|
else if (this.getInternalCDPSession() === undefined) {
|
|
55
|
-
const undefinedField = this.elementImpl
|
|
56
|
+
const undefinedField = ((_b = (_a = this.elementImpl) === null || _a === void 0 ? void 0 : _a._context) === null || _b === void 0 ? void 0 : _b._delegate) !== undefined
|
|
56
57
|
? '_client'
|
|
57
|
-
: this.elementImpl
|
|
58
|
+
: ((_c = this.elementImpl) === null || _c === void 0 ? void 0 : _c._context) !== undefined
|
|
58
59
|
? '_delegate'
|
|
59
60
|
: '_context';
|
|
60
61
|
(0, logUtils_1.logInternal)(`Unable to get the CDP Session of the element handle. ${undefinedField} is undefined. Some functionality, such as element highlighting will not work.`);
|
|
@@ -65,13 +66,14 @@ class ChromiumElementHandleDelegate {
|
|
|
65
66
|
return this.getInternalCDPSession();
|
|
66
67
|
}
|
|
67
68
|
async highlight(highlightDurationMillis, highlightPhases) {
|
|
69
|
+
var _a;
|
|
68
70
|
await this.enableDom();
|
|
69
71
|
await this.enableOverlay();
|
|
70
|
-
const nodeInfo = await this.getInternalCDPSession()
|
|
72
|
+
const nodeInfo = await ((_a = this.getInternalCDPSession()) === null || _a === void 0 ? void 0 : _a.send('DOM.describeNode', {
|
|
71
73
|
objectId: this.getRemoteObjectId(),
|
|
72
74
|
depth: -1,
|
|
73
75
|
pierce: true,
|
|
74
|
-
});
|
|
76
|
+
}));
|
|
75
77
|
if (!nodeInfo) {
|
|
76
78
|
return;
|
|
77
79
|
}
|
|
@@ -87,37 +89,43 @@ class ChromiumElementHandleDelegate {
|
|
|
87
89
|
await this.hideHighlight();
|
|
88
90
|
}
|
|
89
91
|
async fadeInOutHighlight(highlightConfig, highlightDurationMillis, highlightPhases) {
|
|
92
|
+
var _a, _b;
|
|
90
93
|
if (highlightPhases <= 0) {
|
|
91
94
|
throw new Error('Highlight phases must be greater than 0');
|
|
92
95
|
}
|
|
93
96
|
const phaseIntervalMilliseconds = highlightDurationMillis / highlightPhases;
|
|
94
97
|
for (let iteration = 0; iteration < highlightPhases; iteration++) {
|
|
95
|
-
if (highlightConfig.highlightConfig.contentColor
|
|
98
|
+
if (((_a = highlightConfig.highlightConfig.contentColor) === null || _a === void 0 ? void 0 : _a.a) !== undefined) {
|
|
96
99
|
const x = iteration / highlightPhases;
|
|
97
100
|
highlightConfig.highlightConfig.contentColor.a =
|
|
98
101
|
x * (1 - x) * 4 * elementHandle_1.MAX_HIGHLIGHT_OPACITY;
|
|
99
102
|
}
|
|
100
|
-
await this.getInternalCDPSession()
|
|
103
|
+
await ((_b = this.getInternalCDPSession()) === null || _b === void 0 ? void 0 : _b.send('Overlay.highlightNode', highlightConfig));
|
|
101
104
|
await (0, testsUtil_1.sleep)(phaseIntervalMilliseconds);
|
|
102
105
|
}
|
|
103
106
|
}
|
|
104
107
|
async enableDom() {
|
|
105
|
-
|
|
108
|
+
var _a;
|
|
109
|
+
await ((_a = this.getInternalCDPSession()) === null || _a === void 0 ? void 0 : _a.send('DOM.enable'));
|
|
106
110
|
}
|
|
107
111
|
async enableOverlay() {
|
|
108
|
-
|
|
112
|
+
var _a;
|
|
113
|
+
await ((_a = this.getInternalCDPSession()) === null || _a === void 0 ? void 0 : _a.send('Overlay.enable'));
|
|
109
114
|
}
|
|
110
115
|
async hideHighlight() {
|
|
111
|
-
|
|
116
|
+
var _a;
|
|
117
|
+
await ((_a = this.getInternalCDPSession()) === null || _a === void 0 ? void 0 : _a.send('Overlay.hideHighlight'));
|
|
112
118
|
}
|
|
113
119
|
getRemoteObjectId() {
|
|
114
|
-
|
|
120
|
+
var _a, _b, _c;
|
|
121
|
+
if (((_a = this.getElementImpl()) === null || _a === void 0 ? void 0 : _a._objectId) === undefined) {
|
|
115
122
|
(0, logUtils_1.logInternal)('ObjectId of an element handle was not found.');
|
|
116
123
|
}
|
|
117
|
-
return this.getElementImpl()
|
|
124
|
+
return (_c = (_b = this.getElementImpl()) === null || _b === void 0 ? void 0 : _b._objectId) !== null && _c !== void 0 ? _c : '';
|
|
118
125
|
}
|
|
119
126
|
getInternalCDPSession() {
|
|
120
|
-
|
|
127
|
+
var _a, _b, _c;
|
|
128
|
+
return (_c = (_b = (_a = this.elementImpl) === null || _a === void 0 ? void 0 : _a._context) === null || _b === void 0 ? void 0 : _b._delegate) === null || _c === void 0 ? void 0 : _c._client;
|
|
121
129
|
}
|
|
122
130
|
}
|
|
123
131
|
exports.ChromiumElementHandleDelegate = ChromiumElementHandleDelegate;
|
|
@@ -14,7 +14,7 @@ class ChromiumFrameDelegate {
|
|
|
14
14
|
}
|
|
15
15
|
getLifecycleEventStrategy(value) {
|
|
16
16
|
const waitForNetworkIdle = value === types_1.LifecycleEvent.NetworkIdle;
|
|
17
|
-
let waitUntil = value
|
|
17
|
+
let waitUntil = value !== null && value !== void 0 ? value : types_1.LifecycleEvent.Load;
|
|
18
18
|
if (waitForNetworkIdle) {
|
|
19
19
|
waitUntil = types_1.LifecycleEvent.Load;
|
|
20
20
|
}
|