@mablhq/mabl-cli 1.48.47 → 1.50.4

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 (30) hide show
  1. package/api/mablApiClient.js +30 -19
  2. package/commands/commandUtil/fileUtil.js +11 -3
  3. package/commands/constants.js +3 -1
  4. package/commands/datatables/datatables.js +1 -1
  5. package/commands/datatables/datatables_cmds/create.js +18 -105
  6. package/commands/datatables/datatables_cmds/describe.js +6 -6
  7. package/commands/datatables/datatables_cmds/export.js +36 -27
  8. package/commands/datatables/datatables_cmds/list.js +6 -6
  9. package/commands/datatables/datatables_cmds/update.js +120 -0
  10. package/commands/datatables/utils.js +138 -0
  11. package/commands/flows/flows_cmds/export.js +1 -1
  12. package/commands/tests/testsUtil.js +25 -21
  13. package/commands/tests/tests_cmds/export.js +53 -22
  14. package/core/trainer/trainingSessions.js +1 -1
  15. package/domUtil/index.js +1 -1
  16. package/execution/index.js +1 -1
  17. package/functions/apiTest/utils.js +1 -1
  18. package/index.d.ts +3 -3
  19. package/mablApi/index.js +1 -1
  20. package/mablscriptFind/index.js +1 -1
  21. package/package.json +1 -1
  22. package/resources/mablFind.js +1 -1
  23. package/resources/pdf-viewer/EmbeddedPdfHandler.js +1 -1
  24. package/resources/pdf-viewer/libEmbeddedPdfHandler.js +62 -16
  25. package/codeGenerators/seleniumConfigGenerators/SeleniumIdeStep.js +0 -40
  26. package/codeGenerators/seleniumConfigGenerators/flowConfigGenerator.js +0 -86
  27. package/codeGenerators/seleniumConfigGenerators/selIdeGenerator.js +0 -63
  28. package/codeGenerators/seleniumConfigGenerators/stepConverters.js +0 -380
  29. package/codeGenerators/seleniumConfigGenerators/testConfigGenerator.js +0 -77
  30. package/util/csvUtil.js +0 -13
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.variableRowAsScenario = exports.scenarioAsVariableRow = exports.dataTableAsVariableTable = exports.isScenarioArray = exports.inferFileFormat = exports.jsonToScenarios = exports.parseJsonScenarios = exports.csvScenarioFormatToScenarios = exports.parseCsvScenarios = exports.sanitizeCsvCellInput = void 0;
7
+ const constants_1 = require("../constants");
8
+ const path_1 = require("path");
9
+ const fs_1 = __importDefault(require("fs"));
10
+ const csv_parser_1 = __importDefault(require("csv-parser"));
11
+ const MALICIOUS_LINE_PREFIX_MATCHER = /^([+\-@=])/;
12
+ const SANITIZED_LINE_PREFIX_MATCHER = /^(`[+\-@=])/;
13
+ function sanitizeCsvCellInput(input) {
14
+ return MALICIOUS_LINE_PREFIX_MATCHER.test(input)
15
+ ? `\`${input}`.trim()
16
+ : input.trim();
17
+ }
18
+ exports.sanitizeCsvCellInput = sanitizeCsvCellInput;
19
+ function desanitizeCsvCellOutput(input) {
20
+ return SANITIZED_LINE_PREFIX_MATCHER.test(input)
21
+ ? input.slice(1).trim()
22
+ : input.trim();
23
+ }
24
+ var AllowedInputExtensions;
25
+ (function (AllowedInputExtensions) {
26
+ AllowedInputExtensions["Csv"] = ".csv";
27
+ AllowedInputExtensions["Json"] = ".json";
28
+ })(AllowedInputExtensions || (AllowedInputExtensions = {}));
29
+ async function parseCsvScenarios(fileName) {
30
+ const readCsv = await fileToCsvScenarioFormat(fileName);
31
+ return csvScenarioFormatToScenarios(readCsv);
32
+ }
33
+ exports.parseCsvScenarios = parseCsvScenarios;
34
+ async function fileToCsvScenarioFormat(fileName) {
35
+ const csvInput = [];
36
+ await new Promise((resolve) => {
37
+ fs_1.default.createReadStream(fileName)
38
+ .pipe((0, csv_parser_1.default)())
39
+ .on('data', (data) => csvInput.push(data))
40
+ .on('end', () => resolve());
41
+ });
42
+ return csvInput;
43
+ }
44
+ function csvScenarioFormatToScenarios(input) {
45
+ if (input.length === 0) {
46
+ return [];
47
+ }
48
+ return input.map((rowItem) => ({
49
+ id: rowItem[constants_1.SCENARIO_ID_HEADER] || undefined,
50
+ name: desanitizeCsvCellOutput(rowItem[constants_1.SCENARIO_NAME_HEADER]),
51
+ variables: Object.entries(rowItem)
52
+ .filter(([key, _]) => key !== constants_1.SCENARIO_NAME_HEADER && key !== constants_1.SCENARIO_ID_HEADER)
53
+ .map(([key, value]) => ({
54
+ name: desanitizeCsvCellOutput(key),
55
+ value: desanitizeCsvCellOutput(value),
56
+ })),
57
+ }));
58
+ }
59
+ exports.csvScenarioFormatToScenarios = csvScenarioFormatToScenarios;
60
+ function parseJsonScenarios(fileName) {
61
+ const readJson = fs_1.default.readFileSync(fileName, 'utf-8');
62
+ return jsonToScenarios(readJson);
63
+ }
64
+ exports.parseJsonScenarios = parseJsonScenarios;
65
+ function jsonToScenarios(input) {
66
+ const parsedJson = JSON.parse(input);
67
+ if (isScenarioArray(parsedJson)) {
68
+ return parsedJson;
69
+ }
70
+ throw Error('Json input was not formatted correctly');
71
+ }
72
+ exports.jsonToScenarios = jsonToScenarios;
73
+ function inferFileFormat(fileName) {
74
+ const extension = (0, path_1.extname)(fileName);
75
+ switch (extension) {
76
+ case AllowedInputExtensions.Csv:
77
+ return constants_1.OutputFormats.Csv;
78
+ case AllowedInputExtensions.Json:
79
+ return constants_1.OutputFormats.Json;
80
+ default:
81
+ throw new Error('The file format could be inferred from the extension, please specify a format for your input data.');
82
+ }
83
+ }
84
+ exports.inferFileFormat = inferFileFormat;
85
+ function isScenario(arg) {
86
+ return ((typeof arg.id === 'string' || arg.id === undefined) &&
87
+ typeof arg.name === 'string' &&
88
+ Array.isArray(arg.variables) &&
89
+ arg.variables.every((col) => typeof col.name === 'string' && typeof col.value === 'string'));
90
+ }
91
+ function isScenarioArray(arg) {
92
+ return Array.isArray(arg) && arg.every((scenario) => isScenario(scenario));
93
+ }
94
+ exports.isScenarioArray = isScenarioArray;
95
+ function dataTableAsVariableTable(dataTable) {
96
+ return {
97
+ id: dataTable.id,
98
+ organization_id: dataTable.workspace_id,
99
+ name: dataTable.name,
100
+ created_time: dataTable.created_time,
101
+ created_by_id: dataTable.created_by_id,
102
+ last_updated_time: dataTable.last_updated_time,
103
+ last_updated_by_id: dataTable.last_updated_by_id,
104
+ row_ids: dataTable.scenario_ids,
105
+ };
106
+ }
107
+ exports.dataTableAsVariableTable = dataTableAsVariableTable;
108
+ function scenarioAsVariableRow(scenario) {
109
+ return {
110
+ id: scenario === null || scenario === void 0 ? void 0 : scenario.id,
111
+ table_id: scenario === null || scenario === void 0 ? void 0 : scenario.table_id,
112
+ created_time: scenario === null || scenario === void 0 ? void 0 : scenario.created_time,
113
+ created_by_id: scenario === null || scenario === void 0 ? void 0 : scenario.created_by_id,
114
+ last_updated_time: scenario === null || scenario === void 0 ? void 0 : scenario.last_updated_time,
115
+ last_updated_by_id: scenario === null || scenario === void 0 ? void 0 : scenario.last_updated_by_id,
116
+ organization_id: scenario === null || scenario === void 0 ? void 0 : scenario.workspace_id,
117
+ scenario_id: scenario === null || scenario === void 0 ? void 0 : scenario.name,
118
+ row: scenario === null || scenario === void 0 ? void 0 : scenario.variables,
119
+ };
120
+ }
121
+ exports.scenarioAsVariableRow = scenarioAsVariableRow;
122
+ function variableRowAsScenario(variableRow) {
123
+ if (isScenario(variableRow)) {
124
+ return variableRow;
125
+ }
126
+ return {
127
+ id: variableRow.id,
128
+ table_id: variableRow.table_id,
129
+ created_time: variableRow.created_time,
130
+ created_by_id: variableRow.created_by_id,
131
+ last_updated_time: variableRow.last_updated_time,
132
+ last_updated_by_id: variableRow.last_updated_by_id,
133
+ workspace_id: variableRow.organization_id,
134
+ name: variableRow.scenario_id,
135
+ variables: variableRow.row,
136
+ };
137
+ }
138
+ exports.variableRowAsScenario = variableRowAsScenario;
@@ -4,7 +4,7 @@ const mablApiClientFactory_1 = require("../../../api/mablApiClientFactory");
4
4
  const util_1 = require("../../commandUtil/util");
5
5
  const js_yaml_1 = require("js-yaml");
6
6
  const constants_1 = require("../../constants");
7
- const flowConfigGenerator_1 = require("../../../codeGenerators/seleniumConfigGenerators/flowConfigGenerator");
7
+ const flowConfigGenerator_1 = require("../../../execution/codeGenerators/seleniumConfigGenerators/flowConfigGenerator");
8
8
  const fileUtil_1 = require("../../commandUtil/fileUtil");
9
9
  const os = require('os');
10
10
  const JSON_REPLACER = null;
@@ -42,6 +42,7 @@ const logUtils_1 = require("../../util/logUtils");
42
42
  const browserTypes_1 = require("../browserTypes");
43
43
  const constants_1 = require("../constants");
44
44
  const trainerUtil_1 = require("./tests_cmds/trainerUtil");
45
+ const utils_1 = require("../datatables/utils");
45
46
  const chalk = require('chalk');
46
47
  let RUNNING_TEST = false;
47
48
  function getFinalUrl(test, parsedUrl) {
@@ -394,31 +395,33 @@ function validateRunCommandWithLabels(testId, suppliedLabelsInclude, suppliedLab
394
395
  }
395
396
  exports.validateRunCommandWithLabels = validateRunCommandWithLabels;
396
397
  async function pullDownTestRunConfig(testRunId, apiClient) {
397
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
398
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
398
399
  const journeyRun = await apiClient.getTestRun(testRunId);
399
400
  const planRun = await apiClient.getPlanRun(journeyRun.parent_execution);
401
+ const testDatatablevariables = ((_a = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _a === void 0 ? void 0 : _a.user_variables) &&
402
+ (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
403
  return {
401
- basicAuthCredentialsId: ((_a = planRun === null || planRun === void 0 ? void 0 : planRun.run_policy) === null || _a === void 0 ? void 0 : _a.http_auth_credentials_required)
402
- ? (_b = planRun === null || planRun === void 0 ? void 0 : planRun.run_policy) === null || _b === void 0 ? void 0 : _b.http_auth_credentials_id
404
+ basicAuthCredentialsId: ((_c = planRun === null || planRun === void 0 ? void 0 : planRun.run_policy) === null || _c === void 0 ? void 0 : _c.http_auth_credentials_required)
405
+ ? (_d = planRun === null || planRun === void 0 ? void 0 : planRun.run_policy) === null || _d === void 0 ? void 0 : _d.http_auth_credentials_id
403
406
  : undefined,
404
- branchName: (_c = journeyRun.journey_parameters) === null || _c === void 0 ? void 0 : _c.source_control_tag,
405
- credentialsId: ((_d = planRun.run_policy) === null || _d === void 0 ? void 0 : _d.credentials_required)
406
- ? (_e = planRun.run_policy) === null || _e === void 0 ? void 0 : _e.credentials_id
407
+ branchName: (_e = journeyRun.journey_parameters) === null || _e === void 0 ? void 0 : _e.source_control_tag,
408
+ credentialsId: ((_f = planRun.run_policy) === null || _f === void 0 ? void 0 : _f.credentials_required)
409
+ ? (_g = planRun.run_policy) === null || _g === void 0 ? void 0 : _g.credentials_id
407
410
  : undefined,
408
- dataTableVariables: (_f = journeyRun.journey_parameters) === null || _f === void 0 ? void 0 : _f.user_variables,
409
- deviceEmulation: (_g = journeyRun.journey_parameters) === null || _g === void 0 ? void 0 : _g.device_emulation,
410
- environmentId: (_j = (_h = journeyRun.journey_parameters) === null || _h === void 0 ? void 0 : _h.deployment) === null || _j === void 0 ? void 0 : _j.environment_id,
411
+ dataTableVariables: testDatatablevariables,
412
+ deviceEmulation: (_h = journeyRun.journey_parameters) === null || _h === void 0 ? void 0 : _h.device_emulation,
413
+ environmentId: (_k = (_j = journeyRun.journey_parameters) === null || _j === void 0 ? void 0 : _j.deployment) === null || _k === void 0 ? void 0 : _k.environment_id,
411
414
  filterHttpRequests: false,
412
- importedVariables: (_k = journeyRun.journey_parameters) === null || _k === void 0 ? void 0 : _k.imported_variables,
413
- pageLoadWait: (_l = journeyRun.journey_parameters) === null || _l === void 0 ? void 0 : _l.page_load_wait,
415
+ importedVariables: (_l = journeyRun.journey_parameters) === null || _l === void 0 ? void 0 : _l.imported_variables,
416
+ pageLoadWait: (_m = journeyRun.journey_parameters) === null || _m === void 0 ? void 0 : _m.page_load_wait,
414
417
  runId: journeyRun.id,
415
- testId: (_m = journeyRun.journey) === null || _m === void 0 ? void 0 : _m.invariant_id,
416
- url: (_p = (_o = journeyRun.journey_parameters) === null || _o === void 0 ? void 0 : _o.deployment) === null || _p === void 0 ? void 0 : _p.uri,
418
+ testId: (_o = journeyRun.journey) === null || _o === void 0 ? void 0 : _o.invariant_id,
419
+ url: (_q = (_p = journeyRun.journey_parameters) === null || _p === void 0 ? void 0 : _p.deployment) === null || _q === void 0 ? void 0 : _q.uri,
417
420
  };
418
421
  }
419
422
  exports.pullDownTestRunConfig = pullDownTestRunConfig;
420
423
  async function extractTestRunConfig(executionMessage, apiClient) {
421
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
424
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
422
425
  const journeyRun = (_a = executionMessage.journey_run) !== null && _a !== void 0 ? _a : (await apiClient.getTestRun(executionMessage.journey_run_id));
423
426
  const planRun = executionMessage.plan_run;
424
427
  const maybeRunnerType = ((_b = planRun === null || planRun === void 0 ? void 0 : planRun.run_policy) === null || _b === void 0 ? void 0 : _b.nodejs_runtime_variant)
@@ -430,16 +433,17 @@ async function extractTestRunConfig(executionMessage, apiClient) {
430
433
  credentialsId: ((_e = planRun === null || planRun === void 0 ? void 0 : planRun.run_policy) === null || _e === void 0 ? void 0 : _e.credentials_required)
431
434
  ? (_f = planRun === null || planRun === void 0 ? void 0 : planRun.run_policy) === null || _f === void 0 ? void 0 : _f.credentials_id
432
435
  : undefined,
433
- dataTableVariables: (_g = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _g === void 0 ? void 0 : _g.user_variables,
434
- deviceEmulation: (_h = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _h === void 0 ? void 0 : _h.device_emulation,
435
- environmentId: (_k = (_j = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _j === void 0 ? void 0 : _j.deployment) === null || _k === void 0 ? void 0 : _k.environment_id,
436
+ dataTableVariables: ((_g = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _g === void 0 ? void 0 : _g.user_variables) &&
437
+ (0, utils_1.variableRowAsScenario)((_h = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _h === void 0 ? void 0 : _h.user_variables),
438
+ deviceEmulation: (_j = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _j === void 0 ? void 0 : _j.device_emulation,
439
+ environmentId: (_l = (_k = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _k === void 0 ? void 0 : _k.deployment) === null || _l === void 0 ? void 0 : _l.environment_id,
436
440
  filterHttpRequests: true,
437
- importedVariables: (_l = journeyRun.journey_parameters) === null || _l === void 0 ? void 0 : _l.imported_variables,
438
- pageLoadWait: (_m = journeyRun.journey_parameters) === null || _m === void 0 ? void 0 : _m.page_load_wait,
441
+ importedVariables: (_m = journeyRun.journey_parameters) === null || _m === void 0 ? void 0 : _m.imported_variables,
442
+ pageLoadWait: (_o = journeyRun.journey_parameters) === null || _o === void 0 ? void 0 : _o.page_load_wait,
439
443
  runId: journeyRun.id,
440
444
  runnerType: maybeRunnerType,
441
- testId: (_o = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey) === null || _o === void 0 ? void 0 : _o.invariant_id,
442
- url: (_q = (_p = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _p === void 0 ? void 0 : _p.deployment) === null || _q === void 0 ? void 0 : _q.uri,
445
+ testId: (_p = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey) === null || _p === void 0 ? void 0 : _p.invariant_id,
446
+ url: (_r = (_q = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _q === void 0 ? void 0 : _q.deployment) === null || _r === void 0 ? void 0 : _r.uri,
443
447
  };
444
448
  }
445
449
  exports.extractTestRunConfig = extractTestRunConfig;
@@ -2,13 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const mablApi_1 = require("../../../mablApi");
4
4
  const mablApiClientFactory_1 = require("../../../api/mablApiClientFactory");
5
- const selIdeGenerator_1 = require("../../../codeGenerators/seleniumConfigGenerators/selIdeGenerator");
6
5
  const util_1 = require("../../commandUtil/util");
7
- const testConfigGenerator_1 = require("../../../codeGenerators/seleniumConfigGenerators/testConfigGenerator");
8
6
  const js_yaml_1 = require("js-yaml");
9
7
  const constants_1 = require("../../constants");
10
8
  const loggingProvider_1 = require("../../../providers/logging/loggingProvider");
11
9
  const fileUtil_1 = require("../../commandUtil/fileUtil");
10
+ const execution_1 = require("../../../execution");
12
11
  const chalk = require('chalk');
13
12
  const os = require('os');
14
13
  const JSON_REPLACER = null;
@@ -28,6 +27,7 @@ exports.builder = (yargs) => {
28
27
  constants_1.OutputFormats.Json,
29
28
  constants_1.OutputFormats.Yaml,
30
29
  constants_1.OutputFormats.Csv,
30
+ constants_1.OutputFormats.Playwright,
31
31
  constants_1.OutputFormats.SeleniumIde,
32
32
  ],
33
33
  })
@@ -41,14 +41,27 @@ exports.builder = (yargs) => {
41
41
  describe: 'Which branch of the test to export',
42
42
  nargs: 1,
43
43
  type: 'string',
44
+ })
45
+ .option(constants_1.CommandArgEnvironmentId, {
46
+ alias: 'e',
47
+ describe: 'Generate selectors based on the find information learned in this environment (Playwright only)',
48
+ nargs: 1,
49
+ type: 'string',
50
+ })
51
+ .option(constants_1.CommandArgOutputFilePath, {
52
+ describe: 'Export to specific file, default: local path/export name',
53
+ nargs: 1,
54
+ type: 'string',
44
55
  });
45
56
  };
46
- exports.handler = (0, util_1.failWrapper)(pullJourney);
47
- async function pullJourney(parsed) {
57
+ exports.handler = (0, util_1.failWrapper)(exportTest);
58
+ async function exportTest(parsed) {
48
59
  var _a;
49
60
  const testId = parsed.id;
50
61
  const format = parsed.format;
62
+ const environmentId = parsed[constants_1.CommandArgEnvironmentId];
51
63
  const detailLevel = parsed[constants_1.CommandArgDetailLevel];
64
+ const fileName = parsed[constants_1.CommandArgOutputFilePath];
52
65
  const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
53
66
  const branchName = (_a = parsed['mabl-branch']) !== null && _a !== void 0 ? _a : constants_1.DefaultBranchName;
54
67
  const journey = await apiClient.getJourney(testId, branchName, format);
@@ -62,43 +75,61 @@ async function pullJourney(parsed) {
62
75
  }
63
76
  switch (format) {
64
77
  case constants_1.OutputFormats.Csv:
65
- dumpToCsv(journey, flowArray);
66
- break;
78
+ return dumpToCsv(journey, flowArray, fileName);
67
79
  case constants_1.OutputFormats.SeleniumIde:
68
- dumpToSeleniumIde(journey, flowArray);
69
- break;
80
+ return dumpToSeleniumIde(journey, flowArray, fileName);
81
+ case constants_1.OutputFormats.Playwright:
82
+ return dumpToPlaywrightTest(journey, flowArray, apiClient, fileName, environmentId);
70
83
  case constants_1.OutputFormats.Json:
71
84
  case constants_1.OutputFormats.Yaml:
72
85
  default:
73
- dumpYamlOrJsonToFile(format, journey, flowArray, detailLevel);
74
- break;
86
+ return dumpYamlOrJsonToFile(format, journey, flowArray, detailLevel, fileName);
75
87
  }
76
88
  }
77
- function dumpToSeleniumIde(journey, flows) {
78
- const selIdeConfig = new selIdeGenerator_1.SelIdeConfig(journey, flows);
89
+ function dumpToSeleniumIde(journey, flows, fileName) {
90
+ const selIdeConfig = new execution_1.SelIdeConfigGenerator(journey, flows);
79
91
  const configGenerated = selIdeConfig.generateConfigFile();
80
92
  const jsonified = JSON.stringify(configGenerated, JSON_REPLACER, 2);
81
- (0, fileUtil_1.writeExportedEntityToFile)(jsonified, 'side', journey.id);
93
+ return (0, fileUtil_1.writeExportedEntityToFile)(jsonified, 'side', journey.id, fileName);
94
+ }
95
+ async function dumpToPlaywrightTest(journey, flows, apiClient, fileName, environmentId) {
96
+ let findModel = [];
97
+ let findOverrides = [];
98
+ if (journey.test_type !== mablApi_1.TestTypeEnum.Browser) {
99
+ throw new Error('Playwright tests can only be generated for browser tests.');
100
+ }
101
+ if (!environmentId) {
102
+ loggingProvider_1.logger.warn(chalk.yellow('Warning: No', chalk.underline(constants_1.CommandArgEnvironmentId), `specified. XPath selectors will be generated.
103
+ You can take advantage of the find information learned in a specific environment by specifying the environment id with the --${constants_1.CommandArgEnvironmentId} flag.`));
104
+ }
105
+ else {
106
+ findModel = await apiClient.getTestFindModels(journey.invariant_id, environmentId);
107
+ if (!findModel.length) {
108
+ loggingProvider_1.logger.warn(chalk.yellow('Warning: No find information was found on the environment', chalk.underline(environmentId), `XPath selectors will be generated.`));
109
+ }
110
+ findOverrides = await apiClient.getTestOverrides(journey.invariant_id, environmentId);
111
+ }
112
+ const generator = new execution_1.PlaywrightTestGenerator(journey, flows, findModel, findOverrides);
113
+ const test = generator.generateTest();
114
+ return (0, fileUtil_1.writeExportedEntityToFile)(test, 'spec.ts', journey.id, fileName);
82
115
  }
83
- function dumpYamlOrJsonToFile(type, journey, flows, detailLevel) {
84
- const journeyConfig = new testConfigGenerator_1.JourneyConfig(journey, flows, false);
116
+ function dumpYamlOrJsonToFile(type, journey, flows, detailLevel, fileName) {
117
+ const journeyConfig = new execution_1.JourneyConfig(journey, flows, false);
85
118
  const configGenerated = detailLevel === constants_1.DetailLevelFormats.Full
86
119
  ? journeyConfig.generateConfigFile()
87
120
  : journeyConfig.generateSimpleFormat();
88
121
  switch (type) {
89
122
  case constants_1.OutputFormats.Yaml:
90
123
  const yaml = (0, js_yaml_1.dump)(configGenerated, { skipInvalid: false });
91
- (0, fileUtil_1.writeExportedEntityToFile)(yaml, 'yml', journey.id);
92
- break;
124
+ return (0, fileUtil_1.writeExportedEntityToFile)(yaml, 'yml', journey.id, fileName);
93
125
  case constants_1.OutputFormats.Json:
94
- (0, fileUtil_1.writeExportedEntityToFile)(JSON.stringify(configGenerated, JSON_REPLACER, 2), 'json', journey.id);
95
- break;
126
+ return (0, fileUtil_1.writeExportedEntityToFile)(JSON.stringify(configGenerated, JSON_REPLACER, 2), 'json', journey.id, fileName);
96
127
  default:
97
128
  throw new Error(`Invalid Type supplied for exporting: ${type}`);
98
129
  }
99
130
  }
100
- function dumpToCsv(journey, flows) {
101
- const journeyConfig = new testConfigGenerator_1.JourneyConfig(journey, flows, false);
131
+ function dumpToCsv(journey, flows, fileName) {
132
+ const journeyConfig = new execution_1.JourneyConfig(journey, flows, false);
102
133
  const output = journeyConfig.generateSimpleCsv();
103
- (0, fileUtil_1.writeExportedEntityToFile)(output.join(os.EOL), 'csv', journey.id);
134
+ return (0, fileUtil_1.writeExportedEntityToFile)(output.join(os.EOL), 'csv', journey.id, fileName);
104
135
  }
@@ -109,7 +109,7 @@ async function editTest(trainingSessionOptions) {
109
109
  planId: testRunIdConfig.fromPlanId,
110
110
  sender: exports.SENDER,
111
111
  testId,
112
- testType: (_j = test.test_type) !== null && _j !== void 0 ? _j : mablApi_1.Journey.TestTypeEnum.Browser,
112
+ testType: (_j = test.test_type) !== null && _j !== void 0 ? _j : mablApi_1.TestTypeEnum.Browser,
113
113
  url: finalUrl,
114
114
  width: (_k = trainingSessionOptions.width) !== null && _k !== void 0 ? _k : exports.DEFAULT_WIDTH,
115
115
  workspaceId,