@mablhq/mabl-cli 1.58.20 → 1.58.25

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.
Files changed (108) hide show
  1. package/api/basicApiClient.js +21 -15
  2. package/api/mablApiClient.js +40 -48
  3. package/api/mablApiClientFactory.js +1 -1
  4. package/auth/OktaClient.js +1 -2
  5. package/browserEngines/chromiumBrowserEngine.js +1 -2
  6. package/browserEngines/firefoxBrowserEngine.js +2 -2
  7. package/browserEngines/webkitBrowerEngine.js +2 -2
  8. package/browserLauncher/browserLauncherFactory.js +2 -3
  9. package/browserLauncher/elementHandle.js +1 -2
  10. package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumElementHandleDelegate.js +12 -20
  11. package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumFrameDelegate.js +1 -1
  12. package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumPageDelegate.js +7 -10
  13. package/browserLauncher/playwrightBrowserLauncher/firefox/firefoxFrameDelegate.js +3 -4
  14. package/browserLauncher/playwrightBrowserLauncher/nonChromium/nonChromiumAbstractElementHandleDelegate.js +4 -5
  15. package/browserLauncher/playwrightBrowserLauncher/nonChromium/nonChromiumAbstractPageDelegate.js +4 -7
  16. package/browserLauncher/playwrightBrowserLauncher/playwrightBrowser.js +1 -1
  17. package/browserLauncher/playwrightBrowserLauncher/playwrightBrowserLauncher.js +6 -5
  18. package/browserLauncher/playwrightBrowserLauncher/playwrightDom.js +31 -37
  19. package/browserLauncher/playwrightBrowserLauncher/playwrightFrame.js +8 -9
  20. package/browserLauncher/playwrightBrowserLauncher/playwrightHttpRequest.js +4 -8
  21. package/browserLauncher/playwrightBrowserLauncher/playwrightPage.js +4 -6
  22. package/browserLauncher/playwrightBrowserLauncher/webkit/webkitElementHandleDelegate.js +1 -2
  23. package/browserLauncher/playwrightBrowserLauncher/webkit/webkitFrameDelegate.js +1 -1
  24. package/browserTestMonitoring/metricsRecorder.js +6 -6
  25. package/commands/commandUtil/branches.js +2 -3
  26. package/commands/commandUtil/codeInsights.js +13 -16
  27. package/commands/commandUtil/fileUtil.js +1 -1
  28. package/commands/commandUtil/util.js +3 -4
  29. package/commands/commandUtil/versionUtil.js +4 -5
  30. package/commands/config/config_cmds/list.js +2 -2
  31. package/commands/constants.js +3 -1
  32. package/commands/datatables/datatables_cmds/create.js +2 -3
  33. package/commands/datatables/datatables_cmds/export.js +3 -5
  34. package/commands/datatables/datatables_cmds/list.js +1 -2
  35. package/commands/datatables/datatables_cmds/scenarios.js +1 -2
  36. package/commands/datatables/datatables_cmds/update.js +11 -11
  37. package/commands/datatables/utils.js +9 -9
  38. package/commands/deploy/deploy_cmds/awaitDeploymentCompletion.js +6 -8
  39. package/commands/deploy/deploy_cmds/create.js +11 -13
  40. package/commands/deploy/deploy_cmds/executionResultPresenter.js +8 -11
  41. package/commands/deploy/deploy_cmds/list.js +3 -4
  42. package/commands/deploy/deploy_cmds/watch.js +1 -2
  43. package/commands/environments/environments_cmds/create.js +1 -2
  44. package/commands/environments/environments_cmds/delete.js +1 -2
  45. package/commands/environments/environments_cmds/update.js +1 -2
  46. package/commands/environments/environments_cmds/urls_cmds/list.js +1 -2
  47. package/commands/flows/flows_cmds/export.js +1 -2
  48. package/commands/plans/plans_cmds/describe.js +1 -2
  49. package/commands/tests/mobileEmulationUtil.js +5 -7
  50. package/commands/tests/testsUtil.js +40 -42
  51. package/commands/tests/tests_cmds/export.js +1 -2
  52. package/commands/tests/tests_cmds/import.js +4 -5
  53. package/commands/tests/tests_cmds/run-cloud.js +12 -13
  54. package/commands/tests/tests_cmds/run.js +30 -11
  55. package/commands/users/users_cmds/list.js +2 -2
  56. package/commands/workspaces/workspace_cmds/copy.js +1 -2
  57. package/core/execution/ApiTestUtils.js +82 -94
  58. package/core/execution/LocalizationOptionsLists.js +1253 -0
  59. package/core/messaging/logLineMessaging.js +2 -3
  60. package/core/messaging/messaging.js +6 -7
  61. package/core/trainer/trainingSessions.js +15 -15
  62. package/coreWebVitals/index.js +14 -18
  63. package/domUtil/index.js +1 -1
  64. package/execution/index.js +1 -1
  65. package/functions/apiTest/utils.js +4 -5
  66. package/http/MablHttpAgent.js +4 -6
  67. package/http/RequestSecurityError.js +1 -1
  68. package/http/axiosProxyConfig.js +3 -5
  69. package/http/httpUtil.js +2 -3
  70. package/http/requestInterceptor.js +11 -15
  71. package/mablApi/index.js +1 -1
  72. package/mablscript/MablAction.js +2 -3
  73. package/mablscript/MablStep.js +2 -4
  74. package/mablscript/MablSymbol.js +1 -1
  75. package/mablscript/actions/ConditionAction.js +2 -4
  76. package/mablscript/actions/FindAction.js +2 -4
  77. package/mablscript/diffing/diffingUtil.js +8 -7
  78. package/mablscript/importer.js +1 -2
  79. package/mablscript/steps/AccessibilityCheck.js +7 -9
  80. package/mablscript/steps/AssertStep.js +11 -16
  81. package/mablscript/steps/ClickAndHoldStep.js +1 -2
  82. package/mablscript/steps/CookieUtils.js +40 -7
  83. package/mablscript/steps/CreateVariableStep.js +1 -2
  84. package/mablscript/steps/DownloadStep.js +1 -2
  85. package/mablscript/steps/EnterTextStep.js +1 -2
  86. package/mablscript/steps/EvaluateFlowStep.js +1 -1
  87. package/mablscript/steps/IfConditionStep.js +4 -6
  88. package/mablscript/steps/ReleaseStep.js +1 -2
  89. package/mablscript/steps/SendHttpRequestStep.js +2 -4
  90. package/mablscript/steps/SendKeyStep.js +1 -1
  91. package/mablscript/steps/SetCookieStep.js +35 -20
  92. package/mablscript/steps/SetViewportStep.js +1 -1
  93. package/mablscript/steps/SwitchContextStep.js +3 -6
  94. package/mablscript/steps/SyntheticStep.js +1 -2
  95. package/mablscriptFind/index.js +1 -1
  96. package/middleware.js +1 -2
  97. package/package.json +2 -2
  98. package/popupDismissal/index.js +4 -5
  99. package/providers/authenticationProvider.js +5 -6
  100. package/providers/cliConfigProvider.js +10 -12
  101. package/providers/exportRequestProvider.js +3 -5
  102. package/providers/logging/loggingProvider.js +1 -1
  103. package/reporters/mochAwesome/mochAwesomeReporter.js +12 -14
  104. package/resources/mablFind.js +1 -1
  105. package/util/actionabilityUtil.js +1 -1
  106. package/util/analytics.js +6 -9
  107. package/util/browserTestUtils.js +1 -2
  108. package/util/markdownUtil.js +9 -11
@@ -17,27 +17,26 @@ function createFileUploadDirectory(testContext) {
17
17
  }
18
18
  exports.createFileUploadDirectory = createFileUploadDirectory;
19
19
  function validateApiTestMessage(request, response) {
20
- var _a, _b, _c;
21
20
  const authorizationHeader = request.get('authorization');
22
21
  if (authorizationHeader === undefined) {
23
22
  (0, utils_1.handleExecutionFailure)(response, 'Illegal authorization');
24
23
  return false;
25
24
  }
26
25
  const contentType = request.get('content-type');
27
- if ((contentType === null || contentType === void 0 ? void 0 : contentType.toLowerCase()) !== 'application/json') {
26
+ if (contentType?.toLowerCase() !== 'application/json') {
28
27
  (0, utils_1.handleExecutionFailure)(response, 'Illegal content type. Must be application/json');
29
28
  return false;
30
29
  }
31
30
  const pubsubMessage = request.body;
32
- if (typeof ((_a = pubsubMessage === null || pubsubMessage === void 0 ? void 0 : pubsubMessage.message) === null || _a === void 0 ? void 0 : _a.data) !== 'string') {
31
+ if (typeof pubsubMessage?.message?.data !== 'string') {
33
32
  (0, utils_1.handleExecutionFailure)(response, 'Illegal message data format');
34
33
  return false;
35
34
  }
36
- if (typeof (pubsubMessage === null || pubsubMessage === void 0 ? void 0 : pubsubMessage.subscription) !== 'string') {
35
+ if (typeof pubsubMessage?.subscription !== 'string') {
37
36
  (0, utils_1.handleExecutionFailure)(response, 'Illegal message subscription format');
38
37
  return false;
39
38
  }
40
- if (((_c = (_b = pubsubMessage === null || pubsubMessage === void 0 ? void 0 : pubsubMessage.message) === null || _b === void 0 ? void 0 : _b.attributes) === null || _c === void 0 ? void 0 : _c.test_type) !==
39
+ if (pubsubMessage?.message?.attributes?.test_type !==
41
40
  mablApi_1.TestTypeEnum.Api.toString()) {
42
41
  (0, utils_1.handleExecutionFailure)(response, 'Illegal test type');
43
42
  return false;
@@ -48,16 +48,14 @@ class MablHttpAgent extends agent_base_1.Agent {
48
48
  return new MablHttpAgent(constructorParameters.httpAgent, constructorParameters.httpsAgent);
49
49
  }
50
50
  static async getConstructorParameters(httpAgent, httpsAgent) {
51
- var _a, _b;
52
51
  const proxyConfig = await (0, axiosProxyConfig_1.currentProxyConfig)('test');
53
52
  return {
54
- httpAgent: (_a = httpAgent !== null && httpAgent !== void 0 ? httpAgent : proxyConfig.httpAgent) !== null && _a !== void 0 ? _a : http_1.default.globalAgent,
55
- httpsAgent: (_b = httpsAgent !== null && httpsAgent !== void 0 ? httpsAgent : proxyConfig.httpsAgent) !== null && _b !== void 0 ? _b : https.globalAgent,
53
+ httpAgent: httpAgent ?? proxyConfig.httpAgent ?? http_1.default.globalAgent,
54
+ httpsAgent: httpsAgent ?? proxyConfig.httpsAgent ?? https.globalAgent,
56
55
  };
57
56
  }
58
57
  callback(req, opts) {
59
- var _a;
60
- if ((_a = this.maybeGetFirstStringHeader(req, httpUtil_1.USER_AGENT_HEADER)) === null || _a === void 0 ? void 0 : _a.startsWith('PostmanRuntime/')) {
58
+ if (this.maybeGetFirstStringHeader(req, httpUtil_1.USER_AGENT_HEADER)?.startsWith('PostmanRuntime/')) {
61
59
  req.setHeader(httpUtil_1.USER_AGENT_HEADER, httpUtil_1.USER_AGENT);
62
60
  }
63
61
  return Promise.resolve(opts.secureEndpoint ? this.httpsAgent : this.httpAgent);
@@ -67,7 +65,7 @@ class MablHttpAgent extends agent_base_1.Agent {
67
65
  if (Array.isArray(value)) {
68
66
  return value[0].toString();
69
67
  }
70
- return value === null || value === void 0 ? void 0 : value.toString();
68
+ return value?.toString();
71
69
  }
72
70
  }
73
71
  exports.MablHttpAgent = MablHttpAgent;
@@ -7,7 +7,7 @@ class RequestSecurityError extends Error {
7
7
  this.isRequestSecurityError = true;
8
8
  }
9
9
  static isInstance(error) {
10
- return (error === null || error === void 0 ? void 0 : error.isRequestSecurityError) || false;
10
+ return error?.isRequestSecurityError || false;
11
11
  }
12
12
  }
13
13
  exports.RequestSecurityError = RequestSecurityError;
@@ -31,11 +31,10 @@ const hpagent_1 = require("hpagent");
31
31
  const httpUtil_1 = require("./httpUtil");
32
32
  async function currentProxyConfig(mode = 'mabl') {
33
33
  const httpConfig = (await cliConfigProvider_1.CliConfigProvider.getCliConfig()).http;
34
- return axiosProxyConfig(mode === 'test' ? httpConfig === null || httpConfig === void 0 ? void 0 : httpConfig.test : httpConfig === null || httpConfig === void 0 ? void 0 : httpConfig.mabl);
34
+ return axiosProxyConfig(mode === 'test' ? httpConfig?.test : httpConfig?.mabl);
35
35
  }
36
36
  exports.currentProxyConfig = currentProxyConfig;
37
37
  function axiosProxyConfig(httpConfig) {
38
- var _a;
39
38
  const config = {
40
39
  headers: {
41
40
  [httpUtil_1.USER_AGENT_HEADER]: httpUtil_1.USER_AGENT,
@@ -46,7 +45,7 @@ function axiosProxyConfig(httpConfig) {
46
45
  rejectUnauthorized: false,
47
46
  });
48
47
  }
49
- if ((_a = httpConfig.proxyHost) === null || _a === void 0 ? void 0 : _a.href) {
48
+ if (httpConfig.proxyHost?.href) {
50
49
  config.proxy = proxyUrlToPortConfig(httpConfig.proxyHost);
51
50
  }
52
51
  return maybeGetModifiedAxiosConfigForHttpProxy(config, httpConfig.sslVerify, httpConfig.proxyType);
@@ -79,9 +78,8 @@ function proxyUrlToPortConfig(proxyUrl) {
79
78
  }
80
79
  exports.proxyUrlToPortConfig = proxyUrlToPortConfig;
81
80
  function maybeGetModifiedAxiosConfigForHttpProxy(config, sslVerify, proxyType) {
82
- var _a, _b;
83
81
  if (config.proxy &&
84
- (((_a = config.proxy) === null || _a === void 0 ? void 0 : _a.protocol) === 'http:' || ((_b = config.proxy) === null || _b === void 0 ? void 0 : _b.protocol) === 'http')) {
82
+ (config.proxy?.protocol === 'http:' || config.proxy?.protocol === 'http')) {
85
83
  const newConfig = {
86
84
  ...config,
87
85
  };
package/http/httpUtil.js CHANGED
@@ -39,14 +39,13 @@ function maybeGetSocksAgent(linkServer) {
39
39
  return new socks_proxy_agent_1.SocksProxyAgent(agentOptions);
40
40
  }
41
41
  function postProcessHeaders(response) {
42
- var _a, _b, _c;
43
42
  const parsed = {};
44
- const rawHeaders = (_b = (_a = response.request) === null || _a === void 0 ? void 0 : _a.res) === null || _b === void 0 ? void 0 : _b.rawHeaders;
43
+ const rawHeaders = response.request?.res?.rawHeaders;
45
44
  if (rawHeaders) {
46
45
  for (let i = 0; i + 1 < rawHeaders.length; i += 2) {
47
46
  const headerName = rawHeaders[i].toLowerCase();
48
47
  const headerValue = rawHeaders[i + 1];
49
- parsed[headerName] = ((_c = parsed[headerName]) !== null && _c !== void 0 ? _c : []).concat(headerValue);
48
+ parsed[headerName] = (parsed[headerName] ?? []).concat(headerValue);
50
49
  }
51
50
  }
52
51
  return parsed;
@@ -22,10 +22,9 @@ function headerStringToHeaders(rawHeader) {
22
22
  .filter((value) => HEADER_EXTRACT_REGEXP.test(value))
23
23
  .map((value) => value.match(HEADER_EXTRACT_REGEXP).groups)
24
24
  .forEach(({ rawKey, value }) => {
25
- var _a;
26
25
  const normalizedHeader = rawKey.toLowerCase().trim();
27
- const values = (_a = headers[normalizedHeader]) !== null && _a !== void 0 ? _a : [];
28
- if (value === null || value === void 0 ? void 0 : value.trim()) {
26
+ const values = headers[normalizedHeader] ?? [];
27
+ if (value?.trim()) {
29
28
  values.push(value.trim());
30
29
  }
31
30
  headers[normalizedHeader] = values;
@@ -34,12 +33,11 @@ function headerStringToHeaders(rawHeader) {
34
33
  }
35
34
  exports.headerStringToHeaders = headerStringToHeaders;
36
35
  function headerStringToProtocol(rawHeader) {
37
- var _a, _b, _c;
38
36
  if (!rawHeader) {
39
37
  return;
40
38
  }
41
- const firstRowTrimmed = (_b = (_a = rawHeader.split(/\r?\n/, 2)) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.trim();
42
- return (_c = firstRowTrimmed === null || firstRowTrimmed === void 0 ? void 0 : firstRowTrimmed.match(/\s(\S+)$/)) === null || _c === void 0 ? void 0 : _c[1];
39
+ const firstRowTrimmed = rawHeader.split(/\r?\n/, 2)?.[0]?.trim();
40
+ return firstRowTrimmed?.match(/\s(\S+)$/)?.[1];
43
41
  }
44
42
  exports.headerStringToProtocol = headerStringToProtocol;
45
43
  function headerRecordToHeaderMultiMap(input) {
@@ -50,7 +48,7 @@ function headerRecordToHeaderMultiMap(input) {
50
48
  return result;
51
49
  }
52
50
  function handleRawResponseBody(body) {
53
- body = body !== null && body !== void 0 ? body : '';
51
+ body = body ?? '';
54
52
  switch (typeof body) {
55
53
  case 'number':
56
54
  return { body: body.toString(), responseSize: 8 };
@@ -114,16 +112,15 @@ class RequestInterceptor {
114
112
  }
115
113
  }
116
114
  handleRequest(config) {
117
- var _a, _b, _c;
118
115
  try {
119
116
  const requestId = (0, uuid_1.v4)();
120
117
  config.mablRequestId = requestId;
121
118
  const requestResponseChain = {
122
119
  requestId,
123
120
  request: {
124
- headers: (_a = config.headers) !== null && _a !== void 0 ? _a : {},
125
- url: (_b = config === null || config === void 0 ? void 0 : config.url) !== null && _b !== void 0 ? _b : '<Unknown URL>',
126
- method: (_c = config.method) === null || _c === void 0 ? void 0 : _c.toUpperCase(),
121
+ headers: config.headers ?? {},
122
+ url: config?.url ?? '<Unknown URL>',
123
+ method: config.method?.toUpperCase(),
127
124
  request_sent_time: Date.now(),
128
125
  },
129
126
  };
@@ -144,7 +141,7 @@ class RequestInterceptor {
144
141
  const request = response.request;
145
142
  if (request) {
146
143
  chainEntry.request.headers = headerStringToHeaders(request._header);
147
- chainEntry.request.protocol = (request === null || request === void 0 ? void 0 : request._header)
144
+ chainEntry.request.protocol = request?._header
148
145
  ? headerStringToProtocol(request._header)
149
146
  : '<Unknown protocol>';
150
147
  }
@@ -154,7 +151,7 @@ class RequestInterceptor {
154
151
  headers: headerRecordToHeaderMultiMap(response.headers),
155
152
  status: response.status,
156
153
  response_received_time: responseReceivedTime,
157
- response_size: contentLength !== null && contentLength !== void 0 ? contentLength : responseSize,
154
+ response_size: contentLength ?? responseSize,
158
155
  body,
159
156
  };
160
157
  }
@@ -164,7 +161,6 @@ class RequestInterceptor {
164
161
  return response;
165
162
  }
166
163
  handleError(error) {
167
- var _a;
168
164
  try {
169
165
  const config = error.config;
170
166
  let chainEntry;
@@ -177,7 +173,7 @@ class RequestInterceptor {
177
173
  }
178
174
  if (chainEntry) {
179
175
  chainEntry.error = {
180
- code: (_a = error.code) !== null && _a !== void 0 ? _a : httpUtil_1.GENERAL_API_STEP_EXECUTION_ERROR_CODE,
176
+ code: error.code ?? httpUtil_1.GENERAL_API_STEP_EXECUTION_ERROR_CODE,
181
177
  message: error.message,
182
178
  error_received_time: Date.now(),
183
179
  };