@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
@@ -36,12 +36,11 @@ exports.builder = (yargs) => {
36
36
  };
37
37
  exports.handler = (0, util_1.failWrapper)(pullFlow);
38
38
  async function pullFlow(parsed) {
39
- var _a;
40
39
  const flowId = parsed.id;
41
40
  const format = parsed.format;
42
41
  const detailLevel = parsed[constants_1.CommandArgDetailLevel];
43
42
  const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
44
- const branchName = (_a = parsed['mabl-branch']) !== null && _a !== void 0 ? _a : constants_1.DefaultBranchName;
43
+ const branchName = parsed['mabl-branch'] ?? constants_1.DefaultBranchName;
45
44
  const flow = await apiClient.getFlow(flowId, branchName);
46
45
  switch (format) {
47
46
  case constants_1.OutputFormats.Csv:
@@ -8,14 +8,13 @@ exports.describe = (0, util_1.getDescribeDescriptions)('plan');
8
8
  exports.builder = (0, describe_1.getDescribeBuilderOptions)();
9
9
  exports.handler = (0, util_1.failWrapper)(getPlan);
10
10
  async function getPlan(parsed) {
11
- var _a;
12
11
  try {
13
12
  const planId = parsed.id;
14
13
  const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
15
14
  const plan = await apiClient.getPlan(planId);
16
15
  delete plan.journeys_ddt_migration_backup;
17
16
  (0, describe_1.outputEntity)(plan, parsed.output);
18
- return (_a = plan.id) !== null && _a !== void 0 ? _a : '';
17
+ return plan.id ?? '';
19
18
  }
20
19
  catch (error) {
21
20
  throw new Error(`Error getting plan: ${error}`);
@@ -3,32 +3,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getDeviceDescriptorForEmulation = exports.getProperScreenConfig = void 0;
4
4
  const mablApi_1 = require("../../mablApi");
5
5
  function getProperScreenConfig(emulationConfig) {
6
- var _a, _b, _c, _d;
7
6
  switch (emulationConfig.orientation) {
8
7
  case mablApi_1.DeviceEmulation.OrientationEnum.LandscapePrimary:
9
8
  case mablApi_1.DeviceEmulation.OrientationEnum.LandscapeSecondary:
10
- return (_b = (_a = emulationConfig.device_config) === null || _a === void 0 ? void 0 : _a.screen) === null || _b === void 0 ? void 0 : _b.horizontal;
9
+ return emulationConfig.device_config?.screen?.horizontal;
11
10
  case mablApi_1.DeviceEmulation.OrientationEnum.PortraitPrimary:
12
11
  case mablApi_1.DeviceEmulation.OrientationEnum.PortraitSecondary:
13
- return (_d = (_c = emulationConfig.device_config) === null || _c === void 0 ? void 0 : _c.screen) === null || _d === void 0 ? void 0 : _d.vertical;
12
+ return emulationConfig.device_config?.screen?.vertical;
14
13
  default:
15
14
  throw new Error(`Unhandled mobile orientation type [${emulationConfig.orientation}]`);
16
15
  }
17
16
  }
18
17
  exports.getProperScreenConfig = getProperScreenConfig;
19
18
  function getDeviceDescriptorForEmulation(emulationConfig) {
20
- var _a, _b, _c, _d, _e;
21
19
  if (emulationConfig) {
22
20
  const screenConfig = getProperScreenConfig(emulationConfig);
23
- if (!(screenConfig === null || screenConfig === void 0 ? void 0 : screenConfig.height) && !(screenConfig === null || screenConfig === void 0 ? void 0 : screenConfig.width)) {
21
+ if (!screenConfig?.height && !screenConfig?.width) {
24
22
  throw new Error('Could not get viewport settings - invalid emulation config supplied with missing height or width');
25
23
  }
26
24
  return {
27
25
  width: screenConfig.width,
28
26
  height: screenConfig.height,
29
- deviceScaleFactor: (_c = (_b = (_a = emulationConfig.device_config) === null || _a === void 0 ? void 0 : _a.screen) === null || _b === void 0 ? void 0 : _b.device_pixel_ratio) !== null && _c !== void 0 ? _c : 1,
27
+ deviceScaleFactor: emulationConfig.device_config?.screen?.device_pixel_ratio ?? 1,
30
28
  isMobile: isMobile(emulationConfig),
31
- hasTouch: (_e = (_d = emulationConfig.device_config) === null || _d === void 0 ? void 0 : _d.capabilities) === null || _e === void 0 ? void 0 : _e.includes(mablApi_1.DeviceEmulationConfiguration.CapabilitiesEnum.Touch),
29
+ hasTouch: emulationConfig.device_config?.capabilities?.includes(mablApi_1.DeviceEmulationConfiguration.CapabilitiesEnum.Touch),
32
30
  isLandscape: emulationConfig.orientation ===
33
31
  mablApi_1.DeviceEmulation.OrientationEnum.LandscapePrimary ||
34
32
  emulationConfig.orientation ===
@@ -55,7 +55,6 @@ function getFinalUrl(test, parsedUrl) {
55
55
  }
56
56
  exports.getFinalUrl = getFinalUrl;
57
57
  async function launchBrowserInstance(options) {
58
- var _a;
59
58
  const optionsProxy = await maybeGetProxyOptions(options);
60
59
  if (optionsProxy) {
61
60
  options = {
@@ -69,7 +68,7 @@ async function launchBrowserInstance(options) {
69
68
  }
70
69
  catch (error) {
71
70
  if (error.message.includes('Running as root without --no-sandbox is not supported')) {
72
- (_a = options.commandLineArgs) === null || _a === void 0 ? void 0 : _a.push('--no-sandbox');
71
+ options.commandLineArgs?.push('--no-sandbox');
73
72
  messaging_1.mablEventEmitter.log('Unable to initialize browser with standard settings, attempting to run with --no-sandbox setting', Date.now(), logLineMessaging_1.LogLineColor.yellow);
74
73
  return maybeLaunchBrowser(options).catch((error) => {
75
74
  messaging_1.mablEventEmitter.log('Browser launch failed', Date.now(), logLineMessaging_1.LogLineColor.red);
@@ -85,7 +84,7 @@ async function maybeGetProxyOptions(options) {
85
84
  const proxyServer = (await cliConfigProvider_1.CliConfigProvider.getCliConfig()).http.test
86
85
  .proxyHost;
87
86
  let optionsProxy;
88
- if (options === null || options === void 0 ? void 0 : options.proxy) {
87
+ if (options?.proxy) {
89
88
  optionsProxy = {
90
89
  server: options.proxy.server,
91
90
  username: options.proxy.username,
@@ -102,7 +101,7 @@ async function maybeGetProxyOptions(options) {
102
101
  return optionsProxy;
103
102
  }
104
103
  function maybeLaunchBrowser(options) {
105
- return browserLauncher_1.BrowserLauncherFactory.createRunner(options === null || options === void 0 ? void 0 : options.runnerType, options === null || options === void 0 ? void 0 : options.loggerFunc).launch(options);
104
+ return browserLauncher_1.BrowserLauncherFactory.createRunner(options?.runnerType, options?.loggerFunc).launch(options);
106
105
  }
107
106
  function removeTempBrowserPreferencesDirectory(tempDirPath) {
108
107
  try {
@@ -368,8 +367,8 @@ function validateRunCommandWithLabels(testId, suppliedLabelsInclude, suppliedLab
368
367
  .forEach((label) => distinctLabels.add(label));
369
368
  return [...distinctLabels];
370
369
  }
371
- const labelsInclude = cleanLabels(suppliedLabelsInclude !== null && suppliedLabelsInclude !== void 0 ? suppliedLabelsInclude : []);
372
- const labelsExclude = cleanLabels(suppliedLabelsExclude !== null && suppliedLabelsExclude !== void 0 ? suppliedLabelsExclude : []);
370
+ const labelsInclude = cleanLabels(suppliedLabelsInclude ?? []);
371
+ const labelsExclude = cleanLabels(suppliedLabelsExclude ?? []);
373
372
  if (labelsInclude.length > 0 && labelsExclude.length > 0) {
374
373
  const intersection = labelsInclude.filter((label) => labelsExclude.includes(label));
375
374
  if (intersection.length > 0) {
@@ -396,58 +395,58 @@ function validateRunCommandWithLabels(testId, suppliedLabelsInclude, suppliedLab
396
395
  }
397
396
  exports.validateRunCommandWithLabels = validateRunCommandWithLabels;
398
397
  async function pullDownTestRunConfig(testRunId, apiClient) {
399
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
400
398
  const journeyRun = await apiClient.getTestRun(testRunId);
401
399
  const planRun = await apiClient.getPlanRun(journeyRun.parent_execution);
402
- const testDatatablevariables = ((_a = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _a === void 0 ? void 0 : _a.user_variables) &&
403
- (0, utils_1.variableRowAsScenario)((_b = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _b === void 0 ? void 0 : _b.user_variables);
400
+ const testDatatablevariables = journeyRun?.journey_parameters?.user_variables &&
401
+ (0, utils_1.variableRowAsScenario)(journeyRun?.journey_parameters?.user_variables);
404
402
  return {
405
- basicAuthCredentialsId: ((_c = planRun === null || planRun === void 0 ? void 0 : planRun.run_policy) === null || _c === void 0 ? void 0 : _c.http_auth_credentials_required)
406
- ? (_d = planRun === null || planRun === void 0 ? void 0 : planRun.run_policy) === null || _d === void 0 ? void 0 : _d.http_auth_credentials_id
403
+ basicAuthCredentialsId: planRun?.run_policy?.http_auth_credentials_required
404
+ ? planRun?.run_policy?.http_auth_credentials_id
407
405
  : undefined,
408
- branchName: (_e = journeyRun.journey_parameters) === null || _e === void 0 ? void 0 : _e.source_control_tag,
409
- credentialsId: ((_f = planRun.run_policy) === null || _f === void 0 ? void 0 : _f.credentials_required)
410
- ? (_g = planRun.run_policy) === null || _g === void 0 ? void 0 : _g.credentials_id
406
+ branchName: journeyRun.journey_parameters?.source_control_tag,
407
+ credentialsId: planRun.run_policy?.credentials_required
408
+ ? planRun.run_policy?.credentials_id
411
409
  : undefined,
412
410
  dataTableVariables: testDatatablevariables,
413
- deviceEmulation: (_h = journeyRun.journey_parameters) === null || _h === void 0 ? void 0 : _h.device_emulation,
414
- environmentId: (_k = (_j = journeyRun.journey_parameters) === null || _j === void 0 ? void 0 : _j.deployment) === null || _k === void 0 ? void 0 : _k.environment_id,
411
+ deviceEmulation: journeyRun.journey_parameters?.device_emulation,
412
+ environmentId: journeyRun.journey_parameters?.deployment?.environment_id,
415
413
  filterHttpRequests: false,
416
- importedVariables: (_l = journeyRun.journey_parameters) === null || _l === void 0 ? void 0 : _l.imported_variables,
417
- pageLoadWait: (_m = journeyRun.journey_parameters) === null || _m === void 0 ? void 0 : _m.page_load_wait,
414
+ importedVariables: journeyRun.journey_parameters?.imported_variables,
415
+ pageLoadWait: journeyRun.journey_parameters?.page_load_wait,
418
416
  runId: journeyRun.id,
419
- testId: (_o = journeyRun.journey) === null || _o === void 0 ? void 0 : _o.invariant_id,
420
- url: (_q = (_p = journeyRun.journey_parameters) === null || _p === void 0 ? void 0 : _p.deployment) === null || _q === void 0 ? void 0 : _q.uri,
417
+ testId: journeyRun.journey?.invariant_id,
418
+ url: journeyRun.journey_parameters?.deployment?.uri,
421
419
  };
422
420
  }
423
421
  exports.pullDownTestRunConfig = pullDownTestRunConfig;
424
422
  async function extractTestRunConfig(executionMessage, apiClient) {
425
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
426
- const journeyRun = (_a = executionMessage.journey_run) !== null && _a !== void 0 ? _a : (await apiClient.getTestRun(executionMessage.journey_run_id));
423
+ const journeyRun = executionMessage.journey_run ??
424
+ (await apiClient.getTestRun(executionMessage.journey_run_id));
427
425
  const planRun = executionMessage.plan_run;
428
- const maybeRunnerType = ((_b = planRun === null || planRun === void 0 ? void 0 : planRun.run_policy) === null || _b === void 0 ? void 0 : _b.nodejs_runtime_variant)
426
+ const maybeRunnerType = planRun?.run_policy
427
+ ?.nodejs_runtime_variant
429
428
  ?
430
- (_c = planRun === null || planRun === void 0 ? void 0 : planRun.run_policy) === null || _c === void 0 ? void 0 : _c.nodejs_runtime_variant
429
+ planRun?.run_policy?.nodejs_runtime_variant
431
430
  : undefined;
432
431
  return {
433
- branchName: (_d = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _d === void 0 ? void 0 : _d.source_control_tag,
434
- basicAuthCredentialsId: ((_e = planRun === null || planRun === void 0 ? void 0 : planRun.run_policy) === null || _e === void 0 ? void 0 : _e.http_auth_credentials_required)
435
- ? (_f = planRun === null || planRun === void 0 ? void 0 : planRun.run_policy) === null || _f === void 0 ? void 0 : _f.http_auth_credentials_id
432
+ branchName: journeyRun?.journey_parameters?.source_control_tag,
433
+ basicAuthCredentialsId: planRun?.run_policy?.http_auth_credentials_required
434
+ ? planRun?.run_policy?.http_auth_credentials_id
436
435
  : undefined,
437
- credentialsId: ((_g = planRun === null || planRun === void 0 ? void 0 : planRun.run_policy) === null || _g === void 0 ? void 0 : _g.credentials_required)
438
- ? (_h = planRun === null || planRun === void 0 ? void 0 : planRun.run_policy) === null || _h === void 0 ? void 0 : _h.credentials_id
436
+ credentialsId: planRun?.run_policy?.credentials_required
437
+ ? planRun?.run_policy?.credentials_id
439
438
  : undefined,
440
- dataTableVariables: ((_j = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _j === void 0 ? void 0 : _j.user_variables) &&
441
- (0, utils_1.variableRowAsScenario)((_k = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _k === void 0 ? void 0 : _k.user_variables),
442
- deviceEmulation: (_l = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _l === void 0 ? void 0 : _l.device_emulation,
443
- environmentId: (_o = (_m = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _m === void 0 ? void 0 : _m.deployment) === null || _o === void 0 ? void 0 : _o.environment_id,
439
+ dataTableVariables: journeyRun?.journey_parameters?.user_variables &&
440
+ (0, utils_1.variableRowAsScenario)(journeyRun?.journey_parameters?.user_variables),
441
+ deviceEmulation: journeyRun?.journey_parameters?.device_emulation,
442
+ environmentId: journeyRun?.journey_parameters?.deployment?.environment_id,
444
443
  filterHttpRequests: true,
445
- importedVariables: (_p = journeyRun.journey_parameters) === null || _p === void 0 ? void 0 : _p.imported_variables,
446
- pageLoadWait: (_q = journeyRun.journey_parameters) === null || _q === void 0 ? void 0 : _q.page_load_wait,
444
+ importedVariables: journeyRun.journey_parameters?.imported_variables,
445
+ pageLoadWait: journeyRun.journey_parameters?.page_load_wait,
447
446
  runId: journeyRun.id,
448
447
  runnerType: maybeRunnerType,
449
- testId: (_r = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey) === null || _r === void 0 ? void 0 : _r.invariant_id,
450
- url: (_t = (_s = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _s === void 0 ? void 0 : _s.deployment) === null || _t === void 0 ? void 0 : _t.uri,
448
+ testId: journeyRun?.journey?.invariant_id,
449
+ url: journeyRun?.journey_parameters?.deployment?.uri,
451
450
  };
452
451
  }
453
452
  exports.extractTestRunConfig = extractTestRunConfig;
@@ -456,7 +455,7 @@ function calculateTotalTimeSeconds(startTimeMillis, endTimeMillis) {
456
455
  }
457
456
  exports.calculateTotalTimeSeconds = calculateTotalTimeSeconds;
458
457
  function milliSecondsToSeconds(timeMs) {
459
- return Math.round((timeMs !== null && timeMs !== void 0 ? timeMs : 0) / 100) / 10;
458
+ return Math.round((timeMs ?? 0) / 100) / 10;
460
459
  }
461
460
  exports.milliSecondsToSeconds = milliSecondsToSeconds;
462
461
  function logTestInfoIfPresent(description, infoArg) {
@@ -469,14 +468,13 @@ function createDownloadDirectory() {
469
468
  return fs.mkdtempSync(path.join(os.tmpdir(), `mablTestRun-${Date.now()}-`));
470
469
  }
471
470
  function toBasicHttpAuthenticationCredentials(credentials) {
472
- var _a, _b, _c, _d, _e;
473
471
  if (credentials === undefined ||
474
- ((_a = credentials.properties) === null || _a === void 0 ? void 0 : _a.username) === undefined) {
472
+ credentials.properties?.username === undefined) {
475
473
  return undefined;
476
474
  }
477
475
  return {
478
- username: (_c = (_b = credentials.properties) === null || _b === void 0 ? void 0 : _b.username) !== null && _c !== void 0 ? _c : '',
479
- password: (_e = (_d = credentials.properties) === null || _d === void 0 ? void 0 : _d.password) !== null && _e !== void 0 ? _e : '',
476
+ username: credentials.properties?.username ?? '',
477
+ password: credentials.properties?.password ?? '',
480
478
  };
481
479
  }
482
480
  exports.toBasicHttpAuthenticationCredentials = toBasicHttpAuthenticationCredentials;
@@ -56,14 +56,13 @@ exports.builder = (yargs) => {
56
56
  };
57
57
  exports.handler = (0, util_1.failWrapper)(exportTest);
58
58
  async function exportTest(parsed) {
59
- var _a;
60
59
  const testId = parsed.id;
61
60
  const format = parsed.format;
62
61
  const environmentId = parsed[constants_1.CommandArgEnvironmentId];
63
62
  const detailLevel = parsed[constants_1.CommandArgDetailLevel];
64
63
  const fileName = parsed[constants_1.CommandArgOutputFilePath];
65
64
  const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
66
- const branchName = (_a = parsed['mabl-branch']) !== null && _a !== void 0 ? _a : constants_1.DefaultBranchName;
65
+ const branchName = parsed['mabl-branch'] ?? constants_1.DefaultBranchName;
67
66
  const journey = await apiClient.getJourney(testId, branchName, format);
68
67
  if (journey.test_type === mablApi_1.TestTypeEnum.Performance) {
69
68
  throw new Error('Export functionality is not yet available for performance tests.');
@@ -124,7 +124,7 @@ async function importTest(parsed) {
124
124
  return handlePostImportActions(workspaceId, name, apiClient, importedTests, parsed.autoSave);
125
125
  }
126
126
  function getTestName(name) {
127
- const nameValidator = (value) => !(value === null || value === void 0 ? void 0 : value.length) ? 'Name must not be empty' : true;
127
+ const nameValidator = (value) => !value?.length ? 'Name must not be empty' : true;
128
128
  return name
129
129
  ? Promise.resolve(name)
130
130
  : inquirer
@@ -242,9 +242,8 @@ function displayTestDescriptions(importedTests) {
242
242
  });
243
243
  }
244
244
  async function runTests(workspaceId, name, apiClient, importedTests) {
245
- var _a, _b;
246
245
  const flows = importedTests.map((steps) => stepsToFlow(workspaceId, steps));
247
- const firstUrl = (_a = flows.find((flow) => flow.url)) === null || _a === void 0 ? void 0 : _a.url;
246
+ const firstUrl = flows.find((flow) => flow.url)?.url;
248
247
  const browserPath = await new chromiumBrowserEngine_1.ChromiumBrowserEngine().findBrowserExecutable();
249
248
  for (let flowIndex = 0; flowIndex < flows.length; flowIndex++) {
250
249
  loggingProvider_1.logger.info(`Running test ${flowIndex + 1} of ${flows.length}.`);
@@ -253,7 +252,7 @@ async function runTests(workspaceId, name, apiClient, importedTests) {
253
252
  organization_id: workspaceId,
254
253
  name,
255
254
  flows: [],
256
- url: (_b = flow.url) !== null && _b !== void 0 ? _b : firstUrl,
255
+ url: flow.url ?? firstUrl,
257
256
  };
258
257
  const testRunner = await createTestRunner(apiClient, journey, flow, journey.url, workspaceId, browserPath);
259
258
  const results = await testRunner.run();
@@ -269,7 +268,7 @@ function stepsToFlow(workspaceId, steps) {
269
268
  reusable: false,
270
269
  selectors: steps
271
270
  .map((step) => step.selector)
272
- .map((selector) => selector === null || selector === void 0 ? void 0 : selector.toMablscriptSelector())
271
+ .map((selector) => selector?.toMablscriptSelector())
273
272
  .filter((selector) => selector)
274
273
  .map((selector) => selector),
275
274
  script: steps.map((step) => step.mablscript).join('\n'),
@@ -133,7 +133,6 @@ exports.builder = (yargs) => {
133
133
  };
134
134
  exports.handler = (0, util_1.failWrapper)(runInCloud);
135
135
  async function runInCloud(parsed) {
136
- var _a;
137
136
  const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClientFromOptionalApiKey(parsed['api-key']);
138
137
  const workspaceId = await (0, util_1.getWorkspaceId)(parsed);
139
138
  const prompt = parsed.prompt && !parsed[constants_1.CommandArgNoPrompt];
@@ -143,7 +142,7 @@ async function runInCloud(parsed) {
143
142
  const labelsInclude = parsed.labels || [];
144
143
  const labelsExclude = parsed['exclude-labels'] || [];
145
144
  const maybeDeploymentId = parsed['deployment-id'];
146
- const maybeUrlApp = (_a = parsed['app-url']) !== null && _a !== void 0 ? _a : parsed.url;
145
+ const maybeUrlApp = parsed['app-url'] ?? parsed.url;
147
146
  const maybeUrlApi = parsed['api-url'];
148
147
  const browsers = parsed.browsers;
149
148
  const credentialsId = parsed['credentials-id'];
@@ -200,13 +199,14 @@ async function runInCloud(parsed) {
200
199
  return outputUrl;
201
200
  }
202
201
  async function executeRunCloudTest(test, browsers, branchName, apiClient, maybeDeploymentId, appUrl, apiUrl, credentialsId, applicationId, environmentId, basicAuthCredentialsId) {
203
- var _a;
204
- const effectiveAppUrl = appUrl !== null && appUrl !== void 0 ? appUrl : (test.test_type === undefined || test.test_type === mablApi_1.TestTypeEnum.Browser
205
- ? test === null || test === void 0 ? void 0 : test.url
206
- : undefined);
207
- const effectiveApiUrl = apiUrl !== null && apiUrl !== void 0 ? apiUrl : (test.test_type && test.test_type !== mablApi_1.TestTypeEnum.Browser
208
- ? test === null || test === void 0 ? void 0 : test.url
209
- : undefined);
202
+ const effectiveAppUrl = appUrl ??
203
+ (test.test_type === undefined || test.test_type === mablApi_1.TestTypeEnum.Browser
204
+ ? test?.url
205
+ : undefined);
206
+ const effectiveApiUrl = apiUrl ??
207
+ (test.test_type && test.test_type !== mablApi_1.TestTypeEnum.Browser
208
+ ? test?.url
209
+ : undefined);
210
210
  const workspaceId = test.organization_id;
211
211
  const testId = test.invariant_id;
212
212
  let deploymentIds;
@@ -236,10 +236,9 @@ async function executeRunCloudTest(test, browsers, branchName, apiClient, maybeD
236
236
  }
237
237
  const planRun = await apiClient.postPlanRun(workspaceId, testId, branchName, browsers, effectiveAppUrl, effectiveApiUrl, maybeDeploymentId, credentialsId, deploymentIds, basicAuthCredentialsId);
238
238
  const testRunsQueryResult = await apiClient.getTestRunsForPlan(planRun.id);
239
- return (_a = testRunsQueryResult.test_script_executions) !== null && _a !== void 0 ? _a : [];
239
+ return testRunsQueryResult.test_script_executions ?? [];
240
240
  }
241
241
  async function getJourneysForLabels(workspaceId, branchName, branchChangesOnly, labelsInclude, labelsExclude, limit, prompt, apiClient) {
242
- var _a;
243
242
  const journeys = await apiClient.getJourneys({
244
243
  limit,
245
244
  organization_id: workspaceId,
@@ -273,7 +272,7 @@ async function getJourneysForLabels(workspaceId, branchName, branchChangesOnly,
273
272
  default: journeyChoices.map((choice) => choice.value),
274
273
  },
275
274
  ]);
276
- const selectedJourneys = (_a = journeys.filter((journey) => { var _a; return (_a = testsToRun === null || testsToRun === void 0 ? void 0 : testsToRun.test_selection) === null || _a === void 0 ? void 0 : _a.includes(journey.id); })) !== null && _a !== void 0 ? _a : [];
275
+ const selectedJourneys = journeys.filter((journey) => testsToRun?.test_selection?.includes(journey.id)) ?? [];
277
276
  if (selectedJourneys.length === 0) {
278
277
  return [];
279
278
  }
@@ -289,7 +288,7 @@ async function getJourneysForLabels(workspaceId, branchName, branchChangesOnly,
289
288
  default: 'Yes',
290
289
  },
291
290
  ]);
292
- if (response === null || response === void 0 ? void 0 : response.do_continue) {
291
+ if (response?.do_continue) {
293
292
  return selectedJourneys;
294
293
  }
295
294
  return [];
@@ -72,6 +72,18 @@ exports.builder = (yargs) => {
72
72
  describe: 'Mabl environment to run under. Specify to ensure the test runs with environment variables and the latest find information.',
73
73
  nargs: 1,
74
74
  type: 'string',
75
+ })
76
+ .option(constants_1.CommandArgLocale, {
77
+ describe: 'Locale to run the test in, e.g. en-US',
78
+ nargs: 1,
79
+ type: 'string',
80
+ hidden: true,
81
+ })
82
+ .option(constants_1.CommandArgTimezoneID, {
83
+ describe: 'Identifier of the timezone to run the test in, e.g. America/Buenos_Aires',
84
+ nargs: 1,
85
+ type: 'string',
86
+ hidden: true,
75
87
  })
76
88
  .option('width', {
77
89
  describe: 'Set the browser width in pixels',
@@ -194,7 +206,6 @@ exports.builder = (yargs) => {
194
206
  const exitCodeOnError = 1;
195
207
  exports.handler = (0, util_1.failWrapper)(run, exitCodeOnError);
196
208
  async function run(parsed) {
197
- var _a;
198
209
  const commandStartTime = Date.now();
199
210
  let workspaceId;
200
211
  try {
@@ -203,7 +214,7 @@ async function run(parsed) {
203
214
  catch {
204
215
  }
205
216
  const extraHttpHeaders = {};
206
- ((_a = parsed['http-headers']) !== null && _a !== void 0 ? _a : []).forEach((header) => {
217
+ (parsed['http-headers'] ?? []).forEach((header) => {
207
218
  const headerParts = header.split(':');
208
219
  if (headerParts.length === 2 && headerParts[0] && headerParts[1]) {
209
220
  extraHttpHeaders[headerParts[0].toLowerCase()] = headerParts[1];
@@ -218,6 +229,14 @@ async function run(parsed) {
218
229
  throw new Error(`Scenario with ID ${parsed[constants_1.CommandArgScenarioId]} not found`);
219
230
  }
220
231
  }
232
+ const parsedLocale = parsed[constants_1.CommandArgLocale];
233
+ const parsedTimezone = parsed[constants_1.CommandArgTimezoneID];
234
+ const localizationOptions = parsedLocale || parsedTimezone
235
+ ? {
236
+ locale: parsedLocale,
237
+ timezone_identifier: parsedTimezone,
238
+ }
239
+ : undefined;
221
240
  const testRunnerConfig = {
222
241
  _cliCreated: true,
223
242
  basicAuthCredentialsId: parsed[constants_1.CommandArgBasicAuthCredentials],
@@ -240,6 +259,7 @@ async function run(parsed) {
240
259
  keepBrowserOpen: parsed['keep-browser-open'],
241
260
  labelsExclude: parsed['exclude-labels'],
242
261
  labelsInclude: parsed.labels,
262
+ localizationOptions,
243
263
  runId: parsed['run-id'],
244
264
  testFile: parsed[constants_1.CommandArgTestFile],
245
265
  testId: parsed.id,
@@ -252,7 +272,7 @@ async function run(parsed) {
252
272
  loggingProvider_1.logger.info('Warming up test runner...');
253
273
  const mablTestsRunner = await execution.createMablTestRunner(testRunnerConfig);
254
274
  const results = await mablTestsRunner.run();
255
- if ((mablTestsRunner === null || mablTestsRunner === void 0 ? void 0 : mablTestsRunner.mablTestRunners) !== undefined) {
275
+ if (mablTestsRunner?.mablTestRunners !== undefined) {
256
276
  mablTestsRunner.mablTestRunners
257
277
  .filter((tr) => tr instanceof execution_1.MablTestRunner)
258
278
  .forEach((tr) => {
@@ -268,19 +288,18 @@ async function run(parsed) {
268
288
  }
269
289
  exports.run = run;
270
290
  function generateRunCommandTemplate(parsed, testResults) {
271
- var _a, _b, _c, _d, _e, _f, _g;
272
291
  const testResult = testResults.testResults[0];
273
292
  let templateCommand = `${defaultEnv_1.SCRIPT_NAME} ${parsed._.join(' ')} \\\n`;
274
- if ((_a = testResult === null || testResult === void 0 ? void 0 : testResult.rerunConfig) === null || _a === void 0 ? void 0 : _a.environmentId) {
275
- templateCommand = `${templateCommand} --${constants_1.CommandArgEnvironmentId} ${(_b = testResult === null || testResult === void 0 ? void 0 : testResult.rerunConfig) === null || _b === void 0 ? void 0 : _b.environmentId} \\\n`;
293
+ if (testResult?.rerunConfig?.environmentId) {
294
+ templateCommand = `${templateCommand} --${constants_1.CommandArgEnvironmentId} ${testResult?.rerunConfig?.environmentId} \\\n`;
276
295
  }
277
- if ((_c = testResult === null || testResult === void 0 ? void 0 : testResult.rerunConfig) === null || _c === void 0 ? void 0 : _c.credentialsId) {
278
- templateCommand = `${templateCommand} --${constants_1.CommandArgCredentials} ${(_d = testResult === null || testResult === void 0 ? void 0 : testResult.rerunConfig) === null || _d === void 0 ? void 0 : _d.credentialsId} \\\n`;
296
+ if (testResult?.rerunConfig?.credentialsId) {
297
+ templateCommand = `${templateCommand} --${constants_1.CommandArgCredentials} ${testResult?.rerunConfig?.credentialsId} \\\n`;
279
298
  }
280
- if ((_e = testResult === null || testResult === void 0 ? void 0 : testResult.rerunConfig) === null || _e === void 0 ? void 0 : _e.url) {
281
- templateCommand = `${templateCommand} --${constants_1.CommandArgUrl} ${(_f = testResult === null || testResult === void 0 ? void 0 : testResult.rerunConfig) === null || _f === void 0 ? void 0 : _f.url} \\\n`;
299
+ if (testResult?.rerunConfig?.url) {
300
+ templateCommand = `${templateCommand} --${constants_1.CommandArgUrl} ${testResult?.rerunConfig?.url} \\\n`;
282
301
  }
283
- if ((_g = testResult === null || testResult === void 0 ? void 0 : testResult.rerunConfig) === null || _g === void 0 ? void 0 : _g.branch) {
302
+ if (testResult?.rerunConfig?.branch) {
284
303
  templateCommand = `${templateCommand} --${constants_1.CommandArgMablBranch} ${testResult.rerunConfig.branch} \\\n`;
285
304
  }
286
305
  const testIdVal = parsed.id ? parsed.id : '<TEST-ID>';
@@ -38,8 +38,8 @@ function printUsers(users, outputFormat, workspaceId) {
38
38
  wordWrap: true,
39
39
  });
40
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';
41
+ const userRole = user.roles?.find((role) => role.organization_id === workspaceId)
42
+ ?.role ?? 'unknown';
43
43
  table.push([
44
44
  { rowSpan: 1, content: user.id, vAlign: 'center' },
45
45
  { rowSpan: 1, content: user.name, vAlign: 'center' },
@@ -32,8 +32,7 @@ function getTimestamp() {
32
32
  return (0, moment_1.default)().format('HH:mm:ss');
33
33
  }
34
34
  function hasOwnerRoleInWorkspace(user, workspaceId) {
35
- var _a;
36
- const hasOwnerRole = (_a = user.roles) === null || _a === void 0 ? void 0 : _a.some((role) => role.organization_id === workspaceId && role.role === mablApi_1.UserRoleEnum.Owner);
35
+ const hasOwnerRole = user.roles?.some((role) => role.organization_id === workspaceId && role.role === mablApi_1.UserRoleEnum.Owner);
37
36
  if (!hasOwnerRole) {
38
37
  loggingProvider_1.logger.warn(chalk_1.default.yellow(`You must be an owner in both workspaces to copy. You do not have owner permissions in workspace: ${workspaceId}`));
39
38
  }