@mablhq/mabl-cli 1.58.25 → 1.58.28

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 (102) hide show
  1. package/api/basicApiClient.js +15 -21
  2. package/api/mablApiClient.js +48 -40
  3. package/api/mablApiClientFactory.js +1 -1
  4. package/auth/OktaClient.js +2 -1
  5. package/browserEngines/chromiumBrowserEngine.js +2 -1
  6. package/browserEngines/firefoxBrowserEngine.js +2 -2
  7. package/browserEngines/webkitBrowerEngine.js +2 -2
  8. package/browserLauncher/browserLauncherFactory.js +3 -2
  9. package/browserLauncher/elementHandle.js +2 -1
  10. package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumElementHandleDelegate.js +20 -12
  11. package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumFrameDelegate.js +1 -1
  12. package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumPageDelegate.js +10 -7
  13. package/browserLauncher/playwrightBrowserLauncher/firefox/firefoxFrameDelegate.js +4 -3
  14. package/browserLauncher/playwrightBrowserLauncher/nonChromium/nonChromiumAbstractElementHandleDelegate.js +5 -4
  15. package/browserLauncher/playwrightBrowserLauncher/nonChromium/nonChromiumAbstractPageDelegate.js +7 -4
  16. package/browserLauncher/playwrightBrowserLauncher/playwrightBrowser.js +1 -1
  17. package/browserLauncher/playwrightBrowserLauncher/playwrightBrowserLauncher.js +7 -6
  18. package/browserLauncher/playwrightBrowserLauncher/playwrightDom.js +37 -31
  19. package/browserLauncher/playwrightBrowserLauncher/playwrightFrame.js +9 -8
  20. package/browserLauncher/playwrightBrowserLauncher/playwrightHttpRequest.js +8 -4
  21. package/browserLauncher/playwrightBrowserLauncher/playwrightPage.js +5 -3
  22. package/browserLauncher/playwrightBrowserLauncher/webkit/webkitElementHandleDelegate.js +2 -1
  23. package/browserLauncher/playwrightBrowserLauncher/webkit/webkitFrameDelegate.js +1 -1
  24. package/browserTestMonitoring/metricsRecorder.js +6 -6
  25. package/commands/commandUtil/branches.js +3 -2
  26. package/commands/commandUtil/codeInsights.js +16 -13
  27. package/commands/commandUtil/fileUtil.js +1 -1
  28. package/commands/commandUtil/util.js +5 -3
  29. package/commands/commandUtil/versionUtil.js +5 -4
  30. package/commands/config/config_cmds/list.js +2 -2
  31. package/commands/datatables/datatables_cmds/create.js +3 -2
  32. package/commands/datatables/datatables_cmds/export.js +5 -3
  33. package/commands/datatables/datatables_cmds/list.js +2 -1
  34. package/commands/datatables/datatables_cmds/scenarios.js +2 -1
  35. package/commands/datatables/datatables_cmds/update.js +11 -11
  36. package/commands/datatables/utils.js +9 -9
  37. package/commands/deploy/deploy_cmds/awaitDeploymentCompletion.js +8 -6
  38. package/commands/deploy/deploy_cmds/create.js +13 -11
  39. package/commands/deploy/deploy_cmds/executionResultPresenter.js +11 -8
  40. package/commands/deploy/deploy_cmds/list.js +4 -3
  41. package/commands/deploy/deploy_cmds/watch.js +2 -1
  42. package/commands/environments/environments_cmds/create.js +2 -1
  43. package/commands/environments/environments_cmds/delete.js +2 -1
  44. package/commands/environments/environments_cmds/update.js +2 -1
  45. package/commands/environments/environments_cmds/urls_cmds/list.js +2 -1
  46. package/commands/flows/flows_cmds/export.js +2 -1
  47. package/commands/plans/plans_cmds/describe.js +2 -1
  48. package/commands/tests/mobileEmulationUtil.js +7 -5
  49. package/commands/tests/testsUtil.js +42 -40
  50. package/commands/tests/tests_cmds/export.js +2 -1
  51. package/commands/tests/tests_cmds/import.js +5 -4
  52. package/commands/tests/tests_cmds/run-cloud.js +13 -12
  53. package/commands/tests/tests_cmds/run.js +11 -9
  54. package/commands/users/users_cmds/list.js +2 -2
  55. package/commands/workspaces/workspace_cmds/copy.js +2 -1
  56. package/core/execution/ApiTestUtils.js +94 -82
  57. package/core/messaging/logLineMessaging.js +3 -2
  58. package/core/messaging/messaging.js +7 -6
  59. package/core/trainer/trainingSessions.js +15 -15
  60. package/coreWebVitals/index.js +18 -14
  61. package/execution/index.js +1 -1
  62. package/functions/apiTest/utils.js +5 -4
  63. package/http/MablHttpAgent.js +6 -4
  64. package/http/RequestSecurityError.js +1 -1
  65. package/http/axiosProxyConfig.js +5 -3
  66. package/http/httpUtil.js +3 -2
  67. package/http/requestInterceptor.js +15 -11
  68. package/mablscript/MablAction.js +3 -2
  69. package/mablscript/MablStep.js +4 -2
  70. package/mablscript/MablSymbol.js +1 -1
  71. package/mablscript/actions/ConditionAction.js +4 -2
  72. package/mablscript/actions/FindAction.js +4 -2
  73. package/mablscript/diffing/diffingUtil.js +7 -8
  74. package/mablscript/importer.js +2 -1
  75. package/mablscript/steps/AccessibilityCheck.js +9 -7
  76. package/mablscript/steps/AssertStep.js +16 -11
  77. package/mablscript/steps/ClickAndHoldStep.js +2 -1
  78. package/mablscript/steps/CreateVariableStep.js +2 -1
  79. package/mablscript/steps/DownloadStep.js +2 -1
  80. package/mablscript/steps/EnterTextStep.js +2 -1
  81. package/mablscript/steps/EvaluateFlowStep.js +1 -1
  82. package/mablscript/steps/IfConditionStep.js +6 -4
  83. package/mablscript/steps/ReleaseStep.js +2 -1
  84. package/mablscript/steps/SendHttpRequestStep.js +4 -2
  85. package/mablscript/steps/SendKeyStep.js +1 -1
  86. package/mablscript/steps/SetCookieStep.js +8 -7
  87. package/mablscript/steps/SetViewportStep.js +1 -1
  88. package/mablscript/steps/SwitchContextStep.js +6 -3
  89. package/mablscript/steps/SyntheticStep.js +2 -1
  90. package/middleware.js +2 -1
  91. package/package.json +1 -1
  92. package/popupDismissal/index.js +5 -4
  93. package/providers/authenticationProvider.js +6 -5
  94. package/providers/cliConfigProvider.js +12 -10
  95. package/providers/exportRequestProvider.js +5 -3
  96. package/providers/logging/loggingProvider.js +1 -1
  97. package/reporters/mochAwesome/mochAwesomeReporter.js +14 -12
  98. package/util/TestOutputWriter.js +12 -8
  99. package/util/actionabilityUtil.js +1 -1
  100. package/util/analytics.js +9 -6
  101. package/util/browserTestUtils.js +2 -1
  102. package/util/markdownUtil.js +11 -9
@@ -8,13 +8,14 @@ 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;
11
12
  try {
12
13
  const planId = parsed.id;
13
14
  const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
14
15
  const plan = await apiClient.getPlan(planId);
15
16
  delete plan.journeys_ddt_migration_backup;
16
17
  (0, describe_1.outputEntity)(plan, parsed.output);
17
- return plan.id ?? '';
18
+ return (_a = plan.id) !== null && _a !== void 0 ? _a : '';
18
19
  }
19
20
  catch (error) {
20
21
  throw new Error(`Error getting plan: ${error}`);
@@ -3,30 +3,32 @@ 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;
6
7
  switch (emulationConfig.orientation) {
7
8
  case mablApi_1.DeviceEmulation.OrientationEnum.LandscapePrimary:
8
9
  case mablApi_1.DeviceEmulation.OrientationEnum.LandscapeSecondary:
9
- return emulationConfig.device_config?.screen?.horizontal;
10
+ return (_b = (_a = emulationConfig.device_config) === null || _a === void 0 ? void 0 : _a.screen) === null || _b === void 0 ? void 0 : _b.horizontal;
10
11
  case mablApi_1.DeviceEmulation.OrientationEnum.PortraitPrimary:
11
12
  case mablApi_1.DeviceEmulation.OrientationEnum.PortraitSecondary:
12
- return emulationConfig.device_config?.screen?.vertical;
13
+ return (_d = (_c = emulationConfig.device_config) === null || _c === void 0 ? void 0 : _c.screen) === null || _d === void 0 ? void 0 : _d.vertical;
13
14
  default:
14
15
  throw new Error(`Unhandled mobile orientation type [${emulationConfig.orientation}]`);
15
16
  }
16
17
  }
17
18
  exports.getProperScreenConfig = getProperScreenConfig;
18
19
  function getDeviceDescriptorForEmulation(emulationConfig) {
20
+ var _a, _b, _c, _d, _e;
19
21
  if (emulationConfig) {
20
22
  const screenConfig = getProperScreenConfig(emulationConfig);
21
- if (!screenConfig?.height && !screenConfig?.width) {
23
+ if (!(screenConfig === null || screenConfig === void 0 ? void 0 : screenConfig.height) && !(screenConfig === null || screenConfig === void 0 ? void 0 : screenConfig.width)) {
22
24
  throw new Error('Could not get viewport settings - invalid emulation config supplied with missing height or width');
23
25
  }
24
26
  return {
25
27
  width: screenConfig.width,
26
28
  height: screenConfig.height,
27
- deviceScaleFactor: emulationConfig.device_config?.screen?.device_pixel_ratio ?? 1,
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,
28
30
  isMobile: isMobile(emulationConfig),
29
- hasTouch: emulationConfig.device_config?.capabilities?.includes(mablApi_1.DeviceEmulationConfiguration.CapabilitiesEnum.Touch),
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),
30
32
  isLandscape: emulationConfig.orientation ===
31
33
  mablApi_1.DeviceEmulation.OrientationEnum.LandscapePrimary ||
32
34
  emulationConfig.orientation ===
@@ -55,6 +55,7 @@ function getFinalUrl(test, parsedUrl) {
55
55
  }
56
56
  exports.getFinalUrl = getFinalUrl;
57
57
  async function launchBrowserInstance(options) {
58
+ var _a;
58
59
  const optionsProxy = await maybeGetProxyOptions(options);
59
60
  if (optionsProxy) {
60
61
  options = {
@@ -68,7 +69,7 @@ async function launchBrowserInstance(options) {
68
69
  }
69
70
  catch (error) {
70
71
  if (error.message.includes('Running as root without --no-sandbox is not supported')) {
71
- options.commandLineArgs?.push('--no-sandbox');
72
+ (_a = options.commandLineArgs) === null || _a === void 0 ? void 0 : _a.push('--no-sandbox');
72
73
  messaging_1.mablEventEmitter.log('Unable to initialize browser with standard settings, attempting to run with --no-sandbox setting', Date.now(), logLineMessaging_1.LogLineColor.yellow);
73
74
  return maybeLaunchBrowser(options).catch((error) => {
74
75
  messaging_1.mablEventEmitter.log('Browser launch failed', Date.now(), logLineMessaging_1.LogLineColor.red);
@@ -84,7 +85,7 @@ async function maybeGetProxyOptions(options) {
84
85
  const proxyServer = (await cliConfigProvider_1.CliConfigProvider.getCliConfig()).http.test
85
86
  .proxyHost;
86
87
  let optionsProxy;
87
- if (options?.proxy) {
88
+ if (options === null || options === void 0 ? void 0 : options.proxy) {
88
89
  optionsProxy = {
89
90
  server: options.proxy.server,
90
91
  username: options.proxy.username,
@@ -101,7 +102,7 @@ async function maybeGetProxyOptions(options) {
101
102
  return optionsProxy;
102
103
  }
103
104
  function maybeLaunchBrowser(options) {
104
- return browserLauncher_1.BrowserLauncherFactory.createRunner(options?.runnerType, options?.loggerFunc).launch(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);
105
106
  }
106
107
  function removeTempBrowserPreferencesDirectory(tempDirPath) {
107
108
  try {
@@ -367,8 +368,8 @@ function validateRunCommandWithLabels(testId, suppliedLabelsInclude, suppliedLab
367
368
  .forEach((label) => distinctLabels.add(label));
368
369
  return [...distinctLabels];
369
370
  }
370
- const labelsInclude = cleanLabels(suppliedLabelsInclude ?? []);
371
- const labelsExclude = cleanLabels(suppliedLabelsExclude ?? []);
371
+ const labelsInclude = cleanLabels(suppliedLabelsInclude !== null && suppliedLabelsInclude !== void 0 ? suppliedLabelsInclude : []);
372
+ const labelsExclude = cleanLabels(suppliedLabelsExclude !== null && suppliedLabelsExclude !== void 0 ? suppliedLabelsExclude : []);
372
373
  if (labelsInclude.length > 0 && labelsExclude.length > 0) {
373
374
  const intersection = labelsInclude.filter((label) => labelsExclude.includes(label));
374
375
  if (intersection.length > 0) {
@@ -395,58 +396,58 @@ function validateRunCommandWithLabels(testId, suppliedLabelsInclude, suppliedLab
395
396
  }
396
397
  exports.validateRunCommandWithLabels = validateRunCommandWithLabels;
397
398
  async function pullDownTestRunConfig(testRunId, apiClient) {
399
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
398
400
  const journeyRun = await apiClient.getTestRun(testRunId);
399
401
  const planRun = await apiClient.getPlanRun(journeyRun.parent_execution);
400
- const testDatatablevariables = journeyRun?.journey_parameters?.user_variables &&
401
- (0, utils_1.variableRowAsScenario)(journeyRun?.journey_parameters?.user_variables);
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);
402
404
  return {
403
- basicAuthCredentialsId: planRun?.run_policy?.http_auth_credentials_required
404
- ? planRun?.run_policy?.http_auth_credentials_id
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
405
407
  : undefined,
406
- branchName: journeyRun.journey_parameters?.source_control_tag,
407
- credentialsId: planRun.run_policy?.credentials_required
408
- ? planRun.run_policy?.credentials_id
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
409
411
  : undefined,
410
412
  dataTableVariables: testDatatablevariables,
411
- deviceEmulation: journeyRun.journey_parameters?.device_emulation,
412
- environmentId: journeyRun.journey_parameters?.deployment?.environment_id,
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,
413
415
  filterHttpRequests: false,
414
- importedVariables: journeyRun.journey_parameters?.imported_variables,
415
- pageLoadWait: journeyRun.journey_parameters?.page_load_wait,
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,
416
418
  runId: journeyRun.id,
417
- testId: journeyRun.journey?.invariant_id,
418
- url: journeyRun.journey_parameters?.deployment?.uri,
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,
419
421
  };
420
422
  }
421
423
  exports.pullDownTestRunConfig = pullDownTestRunConfig;
422
424
  async function extractTestRunConfig(executionMessage, apiClient) {
423
- const journeyRun = executionMessage.journey_run ??
424
- (await apiClient.getTestRun(executionMessage.journey_run_id));
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));
425
427
  const planRun = executionMessage.plan_run;
426
- const maybeRunnerType = planRun?.run_policy
427
- ?.nodejs_runtime_variant
428
+ const maybeRunnerType = ((_b = planRun === null || planRun === void 0 ? void 0 : planRun.run_policy) === null || _b === void 0 ? void 0 : _b.nodejs_runtime_variant)
428
429
  ?
429
- planRun?.run_policy?.nodejs_runtime_variant
430
+ (_c = planRun === null || planRun === void 0 ? void 0 : planRun.run_policy) === null || _c === void 0 ? void 0 : _c.nodejs_runtime_variant
430
431
  : undefined;
431
432
  return {
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
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
435
436
  : undefined,
436
- credentialsId: planRun?.run_policy?.credentials_required
437
- ? planRun?.run_policy?.credentials_id
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
438
439
  : undefined,
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,
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,
443
444
  filterHttpRequests: true,
444
- importedVariables: journeyRun.journey_parameters?.imported_variables,
445
- pageLoadWait: journeyRun.journey_parameters?.page_load_wait,
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,
446
447
  runId: journeyRun.id,
447
448
  runnerType: maybeRunnerType,
448
- testId: journeyRun?.journey?.invariant_id,
449
- url: journeyRun?.journey_parameters?.deployment?.uri,
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,
450
451
  };
451
452
  }
452
453
  exports.extractTestRunConfig = extractTestRunConfig;
@@ -455,7 +456,7 @@ function calculateTotalTimeSeconds(startTimeMillis, endTimeMillis) {
455
456
  }
456
457
  exports.calculateTotalTimeSeconds = calculateTotalTimeSeconds;
457
458
  function milliSecondsToSeconds(timeMs) {
458
- return Math.round((timeMs ?? 0) / 100) / 10;
459
+ return Math.round((timeMs !== null && timeMs !== void 0 ? timeMs : 0) / 100) / 10;
459
460
  }
460
461
  exports.milliSecondsToSeconds = milliSecondsToSeconds;
461
462
  function logTestInfoIfPresent(description, infoArg) {
@@ -468,13 +469,14 @@ function createDownloadDirectory() {
468
469
  return fs.mkdtempSync(path.join(os.tmpdir(), `mablTestRun-${Date.now()}-`));
469
470
  }
470
471
  function toBasicHttpAuthenticationCredentials(credentials) {
472
+ var _a, _b, _c, _d, _e;
471
473
  if (credentials === undefined ||
472
- credentials.properties?.username === undefined) {
474
+ ((_a = credentials.properties) === null || _a === void 0 ? void 0 : _a.username) === undefined) {
473
475
  return undefined;
474
476
  }
475
477
  return {
476
- username: credentials.properties?.username ?? '',
477
- password: credentials.properties?.password ?? '',
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 : '',
478
480
  };
479
481
  }
480
482
  exports.toBasicHttpAuthenticationCredentials = toBasicHttpAuthenticationCredentials;
@@ -56,13 +56,14 @@ exports.builder = (yargs) => {
56
56
  };
57
57
  exports.handler = (0, util_1.failWrapper)(exportTest);
58
58
  async function exportTest(parsed) {
59
+ var _a;
59
60
  const testId = parsed.id;
60
61
  const format = parsed.format;
61
62
  const environmentId = parsed[constants_1.CommandArgEnvironmentId];
62
63
  const detailLevel = parsed[constants_1.CommandArgDetailLevel];
63
64
  const fileName = parsed[constants_1.CommandArgOutputFilePath];
64
65
  const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
65
- const branchName = parsed['mabl-branch'] ?? constants_1.DefaultBranchName;
66
+ const branchName = (_a = parsed['mabl-branch']) !== null && _a !== void 0 ? _a : constants_1.DefaultBranchName;
66
67
  const journey = await apiClient.getJourney(testId, branchName, format);
67
68
  if (journey.test_type === mablApi_1.TestTypeEnum.Performance) {
68
69
  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?.length ? 'Name must not be empty' : true;
127
+ const nameValidator = (value) => !(value === null || value === void 0 ? void 0 : value.length) ? 'Name must not be empty' : true;
128
128
  return name
129
129
  ? Promise.resolve(name)
130
130
  : inquirer
@@ -242,8 +242,9 @@ function displayTestDescriptions(importedTests) {
242
242
  });
243
243
  }
244
244
  async function runTests(workspaceId, name, apiClient, importedTests) {
245
+ var _a, _b;
245
246
  const flows = importedTests.map((steps) => stepsToFlow(workspaceId, steps));
246
- const firstUrl = flows.find((flow) => flow.url)?.url;
247
+ const firstUrl = (_a = flows.find((flow) => flow.url)) === null || _a === void 0 ? void 0 : _a.url;
247
248
  const browserPath = await new chromiumBrowserEngine_1.ChromiumBrowserEngine().findBrowserExecutable();
248
249
  for (let flowIndex = 0; flowIndex < flows.length; flowIndex++) {
249
250
  loggingProvider_1.logger.info(`Running test ${flowIndex + 1} of ${flows.length}.`);
@@ -252,7 +253,7 @@ async function runTests(workspaceId, name, apiClient, importedTests) {
252
253
  organization_id: workspaceId,
253
254
  name,
254
255
  flows: [],
255
- url: flow.url ?? firstUrl,
256
+ url: (_b = flow.url) !== null && _b !== void 0 ? _b : firstUrl,
256
257
  };
257
258
  const testRunner = await createTestRunner(apiClient, journey, flow, journey.url, workspaceId, browserPath);
258
259
  const results = await testRunner.run();
@@ -268,7 +269,7 @@ function stepsToFlow(workspaceId, steps) {
268
269
  reusable: false,
269
270
  selectors: steps
270
271
  .map((step) => step.selector)
271
- .map((selector) => selector?.toMablscriptSelector())
272
+ .map((selector) => selector === null || selector === void 0 ? void 0 : selector.toMablscriptSelector())
272
273
  .filter((selector) => selector)
273
274
  .map((selector) => selector),
274
275
  script: steps.map((step) => step.mablscript).join('\n'),
@@ -133,6 +133,7 @@ exports.builder = (yargs) => {
133
133
  };
134
134
  exports.handler = (0, util_1.failWrapper)(runInCloud);
135
135
  async function runInCloud(parsed) {
136
+ var _a;
136
137
  const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClientFromOptionalApiKey(parsed['api-key']);
137
138
  const workspaceId = await (0, util_1.getWorkspaceId)(parsed);
138
139
  const prompt = parsed.prompt && !parsed[constants_1.CommandArgNoPrompt];
@@ -142,7 +143,7 @@ async function runInCloud(parsed) {
142
143
  const labelsInclude = parsed.labels || [];
143
144
  const labelsExclude = parsed['exclude-labels'] || [];
144
145
  const maybeDeploymentId = parsed['deployment-id'];
145
- const maybeUrlApp = parsed['app-url'] ?? parsed.url;
146
+ const maybeUrlApp = (_a = parsed['app-url']) !== null && _a !== void 0 ? _a : parsed.url;
146
147
  const maybeUrlApi = parsed['api-url'];
147
148
  const browsers = parsed.browsers;
148
149
  const credentialsId = parsed['credentials-id'];
@@ -199,14 +200,13 @@ async function runInCloud(parsed) {
199
200
  return outputUrl;
200
201
  }
201
202
  async function executeRunCloudTest(test, browsers, branchName, apiClient, maybeDeploymentId, appUrl, apiUrl, credentialsId, applicationId, environmentId, basicAuthCredentialsId) {
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);
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);
210
210
  const workspaceId = test.organization_id;
211
211
  const testId = test.invariant_id;
212
212
  let deploymentIds;
@@ -236,9 +236,10 @@ 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 testRunsQueryResult.test_script_executions ?? [];
239
+ return (_a = testRunsQueryResult.test_script_executions) !== null && _a !== void 0 ? _a : [];
240
240
  }
241
241
  async function getJourneysForLabels(workspaceId, branchName, branchChangesOnly, labelsInclude, labelsExclude, limit, prompt, apiClient) {
242
+ var _a;
242
243
  const journeys = await apiClient.getJourneys({
243
244
  limit,
244
245
  organization_id: workspaceId,
@@ -272,7 +273,7 @@ async function getJourneysForLabels(workspaceId, branchName, branchChangesOnly,
272
273
  default: journeyChoices.map((choice) => choice.value),
273
274
  },
274
275
  ]);
275
- const selectedJourneys = journeys.filter((journey) => testsToRun?.test_selection?.includes(journey.id)) ?? [];
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 : [];
276
277
  if (selectedJourneys.length === 0) {
277
278
  return [];
278
279
  }
@@ -288,7 +289,7 @@ async function getJourneysForLabels(workspaceId, branchName, branchChangesOnly,
288
289
  default: 'Yes',
289
290
  },
290
291
  ]);
291
- if (response?.do_continue) {
292
+ if (response === null || response === void 0 ? void 0 : response.do_continue) {
292
293
  return selectedJourneys;
293
294
  }
294
295
  return [];
@@ -206,6 +206,7 @@ exports.builder = (yargs) => {
206
206
  const exitCodeOnError = 1;
207
207
  exports.handler = (0, util_1.failWrapper)(run, exitCodeOnError);
208
208
  async function run(parsed) {
209
+ var _a;
209
210
  const commandStartTime = Date.now();
210
211
  let workspaceId;
211
212
  try {
@@ -214,7 +215,7 @@ async function run(parsed) {
214
215
  catch {
215
216
  }
216
217
  const extraHttpHeaders = {};
217
- (parsed['http-headers'] ?? []).forEach((header) => {
218
+ ((_a = parsed['http-headers']) !== null && _a !== void 0 ? _a : []).forEach((header) => {
218
219
  const headerParts = header.split(':');
219
220
  if (headerParts.length === 2 && headerParts[0] && headerParts[1]) {
220
221
  extraHttpHeaders[headerParts[0].toLowerCase()] = headerParts[1];
@@ -272,7 +273,7 @@ async function run(parsed) {
272
273
  loggingProvider_1.logger.info('Warming up test runner...');
273
274
  const mablTestsRunner = await execution.createMablTestRunner(testRunnerConfig);
274
275
  const results = await mablTestsRunner.run();
275
- if (mablTestsRunner?.mablTestRunners !== undefined) {
276
+ if ((mablTestsRunner === null || mablTestsRunner === void 0 ? void 0 : mablTestsRunner.mablTestRunners) !== undefined) {
276
277
  mablTestsRunner.mablTestRunners
277
278
  .filter((tr) => tr instanceof execution_1.MablTestRunner)
278
279
  .forEach((tr) => {
@@ -288,18 +289,19 @@ async function run(parsed) {
288
289
  }
289
290
  exports.run = run;
290
291
  function generateRunCommandTemplate(parsed, testResults) {
292
+ var _a, _b, _c, _d, _e, _f, _g;
291
293
  const testResult = testResults.testResults[0];
292
294
  let templateCommand = `${defaultEnv_1.SCRIPT_NAME} ${parsed._.join(' ')} \\\n`;
293
- if (testResult?.rerunConfig?.environmentId) {
294
- templateCommand = `${templateCommand} --${constants_1.CommandArgEnvironmentId} ${testResult?.rerunConfig?.environmentId} \\\n`;
295
+ if ((_a = testResult === null || testResult === void 0 ? void 0 : testResult.rerunConfig) === null || _a === void 0 ? void 0 : _a.environmentId) {
296
+ templateCommand = `${templateCommand} --${constants_1.CommandArgEnvironmentId} ${(_b = testResult === null || testResult === void 0 ? void 0 : testResult.rerunConfig) === null || _b === void 0 ? void 0 : _b.environmentId} \\\n`;
295
297
  }
296
- if (testResult?.rerunConfig?.credentialsId) {
297
- templateCommand = `${templateCommand} --${constants_1.CommandArgCredentials} ${testResult?.rerunConfig?.credentialsId} \\\n`;
298
+ if ((_c = testResult === null || testResult === void 0 ? void 0 : testResult.rerunConfig) === null || _c === void 0 ? void 0 : _c.credentialsId) {
299
+ templateCommand = `${templateCommand} --${constants_1.CommandArgCredentials} ${(_d = testResult === null || testResult === void 0 ? void 0 : testResult.rerunConfig) === null || _d === void 0 ? void 0 : _d.credentialsId} \\\n`;
298
300
  }
299
- if (testResult?.rerunConfig?.url) {
300
- templateCommand = `${templateCommand} --${constants_1.CommandArgUrl} ${testResult?.rerunConfig?.url} \\\n`;
301
+ if ((_e = testResult === null || testResult === void 0 ? void 0 : testResult.rerunConfig) === null || _e === void 0 ? void 0 : _e.url) {
302
+ templateCommand = `${templateCommand} --${constants_1.CommandArgUrl} ${(_f = testResult === null || testResult === void 0 ? void 0 : testResult.rerunConfig) === null || _f === void 0 ? void 0 : _f.url} \\\n`;
301
303
  }
302
- if (testResult?.rerunConfig?.branch) {
304
+ if ((_g = testResult === null || testResult === void 0 ? void 0 : testResult.rerunConfig) === null || _g === void 0 ? void 0 : _g.branch) {
303
305
  templateCommand = `${templateCommand} --${constants_1.CommandArgMablBranch} ${testResult.rerunConfig.branch} \\\n`;
304
306
  }
305
307
  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
- const userRole = user.roles?.find((role) => role.organization_id === workspaceId)
42
- ?.role ?? 'unknown';
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';
43
43
  table.push([
44
44
  { rowSpan: 1, content: user.id, vAlign: 'center' },
45
45
  { rowSpan: 1, content: user.name, vAlign: 'center' },
@@ -32,7 +32,8 @@ function getTimestamp() {
32
32
  return (0, moment_1.default)().format('HH:mm:ss');
33
33
  }
34
34
  function hasOwnerRoleInWorkspace(user, workspaceId) {
35
- const hasOwnerRole = user.roles?.some((role) => role.organization_id === workspaceId && role.role === mablApi_1.UserRoleEnum.Owner);
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);
36
37
  if (!hasOwnerRole) {
37
38
  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}`));
38
39
  }