@mablhq/mabl-cli 2.52.6 → 2.53.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/types.js +6 -1
- package/browserLauncher/index.js +1 -1
- package/commands/config/config_cmds/configKeys.js +1 -6
- package/commands/config/config_cmds/set.js +3 -2
- package/commands/tests/tests_cmds/import_cmds/import_playwright.js +37 -21
- package/commands/tests/tests_cmds/run.js +1 -0
- package/core/execution/ApiTestUtils.js +1 -1
- package/execution/index.js +2 -2
- package/mablscript/MablStepWithFindAction.js +11 -0
- package/mablscript/steps/ClickAndHoldStep.js +2 -2
- package/mablscript/steps/ClickStep.js +2 -2
- package/mablscript/steps/DoubleClickStep.js +2 -2
- package/mablscript/steps/EnterAuthCodeStep.js +2 -2
- package/mablscript/steps/EnterTextStep.js +2 -2
- package/mablscript/steps/HoverStep.js +2 -2
- package/mablscript/steps/OpenEmailStep.js +2 -2
- package/mablscript/steps/ReleaseStep.js +2 -2
- package/mablscript/steps/RightClickStep.js +2 -2
- package/mablscript/steps/SelectStep.js +2 -2
- package/mablscript/steps/SendKeyStep.js +2 -2
- package/mablscript/steps/SetFilesStep.js +2 -2
- package/mablscript/steps/WaitUntilStep.js +2 -2
- package/package.json +3 -3
- package/providers/cliConfigProvider.js +1 -1
- package/proxy/index.js +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isValidProxyMode = exports.proxyModes = exports.validConfigKeyChoices = exports.configKeys = void 0;
|
|
4
4
|
exports.configKeys = Object.freeze({
|
|
5
5
|
browserPath: 'browser.path',
|
|
6
6
|
enableSourceControlMetadataCollection: 'alpha.scm_metadata.enable',
|
|
@@ -17,12 +17,7 @@ exports.proxyModes = [
|
|
|
17
17
|
'all',
|
|
18
18
|
'none',
|
|
19
19
|
];
|
|
20
|
-
exports.proxyTypes = ['legacy', 'current'];
|
|
21
20
|
function isValidProxyMode(value) {
|
|
22
21
|
return exports.proxyModes.indexOf(value) !== -1;
|
|
23
22
|
}
|
|
24
23
|
exports.isValidProxyMode = isValidProxyMode;
|
|
25
|
-
function isValidProxyType(value) {
|
|
26
|
-
return exports.proxyTypes.indexOf(value) !== -1;
|
|
27
|
-
}
|
|
28
|
-
exports.isValidProxyType = isValidProxyType;
|
|
@@ -6,6 +6,7 @@ const mablApiClientFactory_1 = require("../../../api/mablApiClientFactory");
|
|
|
6
6
|
const list_1 = require("./list");
|
|
7
7
|
const loggingProvider_1 = require("../../../providers/logging/loggingProvider");
|
|
8
8
|
const configKeys_1 = require("./configKeys");
|
|
9
|
+
const types_1 = require("../../../api/types");
|
|
9
10
|
exports.configKeyCommandArg = 'config-key';
|
|
10
11
|
const configValue = 'config-value';
|
|
11
12
|
exports.command = `set <${exports.configKeyCommandArg}> <${configValue}>`;
|
|
@@ -56,8 +57,8 @@ async function setConfig(parsed) {
|
|
|
56
57
|
await cliConfigProvider_1.CliConfigProvider.setConfigProperty(key, value);
|
|
57
58
|
break;
|
|
58
59
|
case configKeys_1.configKeys.proxyType:
|
|
59
|
-
if (!(0,
|
|
60
|
-
throw new Error(`Invalid proxy type. The value must be one of ${JSON.stringify(
|
|
60
|
+
if (!(0, types_1.isValidProxyType)(value)) {
|
|
61
|
+
throw new Error(`Invalid proxy type. The value must be one of ${JSON.stringify(types_1.proxyTypes)}`);
|
|
61
62
|
}
|
|
62
63
|
await cliConfigProvider_1.CliConfigProvider.setConfigProperty(key, value);
|
|
63
64
|
break;
|
|
@@ -48,7 +48,7 @@ import { test } from "@playwright/test";
|
|
|
48
48
|
test("mablImportInfo", async ({baseURL, trace}) => {
|
|
49
49
|
console.log('@mabl project info',
|
|
50
50
|
JSON.stringify({
|
|
51
|
-
|
|
51
|
+
baseUrl: baseURL,
|
|
52
52
|
})
|
|
53
53
|
);
|
|
54
54
|
});
|
|
@@ -56,7 +56,7 @@ test("mablImportInfo", async ({baseURL, trace}) => {
|
|
|
56
56
|
var PostImportActions;
|
|
57
57
|
(function (PostImportActions) {
|
|
58
58
|
PostImportActions["Discard"] = "Discard the test";
|
|
59
|
-
PostImportActions["Run"] = "Run
|
|
59
|
+
PostImportActions["Run"] = "Run test to activate auto-heal";
|
|
60
60
|
PostImportActions["Save"] = "Save the test";
|
|
61
61
|
PostImportActions["View"] = "View the test description";
|
|
62
62
|
})(PostImportActions || (PostImportActions = {}));
|
|
@@ -127,7 +127,7 @@ exports.handler = (0, util_1.failWrapper)(processCommand);
|
|
|
127
127
|
async function processCommand(parsed) {
|
|
128
128
|
const workspaceId = await (0, util_1.getWorkspaceId)(parsed);
|
|
129
129
|
const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
|
|
130
|
-
const importedTests = await importTests(parsed);
|
|
130
|
+
const { importedTests, playwrightProject } = await importTests(parsed);
|
|
131
131
|
if (!importedTests.length) {
|
|
132
132
|
return Promise.reject(new Error(`No tests were imported.`));
|
|
133
133
|
}
|
|
@@ -137,7 +137,7 @@ async function processCommand(parsed) {
|
|
|
137
137
|
else {
|
|
138
138
|
loggingProvider_1.logger.info(`Imported ${(0, pluralize_1.default)('step', importedTests[0].steps.length, true)}.\n`);
|
|
139
139
|
}
|
|
140
|
-
return handlePostImportActions(workspaceId, apiClient, importedTests, parsed[constants_1.CommandArgAuto]);
|
|
140
|
+
return handlePostImportActions(workspaceId, apiClient, importedTests, playwrightProject, parsed[constants_1.CommandArgAuto]);
|
|
141
141
|
}
|
|
142
142
|
async function importTests(args) {
|
|
143
143
|
var _a, _b;
|
|
@@ -158,23 +158,23 @@ async function importTests(args) {
|
|
|
158
158
|
importedTests = processTracesPath(tracesPath, playwrightProject, converter);
|
|
159
159
|
}
|
|
160
160
|
converter.printMissingApis(loggingProvider_1.logger);
|
|
161
|
-
return importedTests;
|
|
161
|
+
return { importedTests, playwrightProject };
|
|
162
162
|
}
|
|
163
|
-
async function handlePostImportActions(workspaceId, apiClient, importedTests, autoSave) {
|
|
163
|
+
async function handlePostImportActions(workspaceId, apiClient, importedTests, playwrightProject, autoSave) {
|
|
164
164
|
let nextAction;
|
|
165
165
|
do {
|
|
166
166
|
nextAction = await getNextAction(autoSave);
|
|
167
167
|
loggingProvider_1.logger.logNewLine();
|
|
168
168
|
switch (nextAction) {
|
|
169
169
|
case PostImportActions.Save:
|
|
170
|
-
return saveTests(workspaceId, apiClient, importedTests).then(() => {
|
|
170
|
+
return saveTests(workspaceId, apiClient, importedTests, playwrightProject).then(() => {
|
|
171
171
|
loggingProvider_1.logger.info('Import complete.');
|
|
172
172
|
});
|
|
173
173
|
case PostImportActions.View:
|
|
174
174
|
displayTestDescriptions(importedTests);
|
|
175
175
|
break;
|
|
176
176
|
case PostImportActions.Run:
|
|
177
|
-
await runTests(workspaceId, apiClient, importedTests);
|
|
177
|
+
await runTests(workspaceId, apiClient, importedTests, playwrightProject);
|
|
178
178
|
break;
|
|
179
179
|
case PostImportActions.Discard:
|
|
180
180
|
loggingProvider_1.logger.info('Exiting without saving.');
|
|
@@ -198,10 +198,10 @@ async function getNextAction(autoSave) {
|
|
|
198
198
|
]);
|
|
199
199
|
return answer.action;
|
|
200
200
|
}
|
|
201
|
-
function saveTests(workspaceId, apiClient, importedTests) {
|
|
201
|
+
function saveTests(workspaceId, apiClient, importedTests, playwrightProject) {
|
|
202
202
|
loggingProvider_1.logger.info(`Saving ${(0, pluralize_1.default)('test', importedTests.length, true)}...`);
|
|
203
203
|
const savePromises = importedTests.map((test) => apiClient
|
|
204
|
-
.createFlow(stepsToFlow(workspaceId, test
|
|
204
|
+
.createFlow(stepsToFlow(workspaceId, test, playwrightProject))
|
|
205
205
|
.then((flow) => apiClient.createJourney(flowToJourney(test.testName, flow)))
|
|
206
206
|
.then((journey) => {
|
|
207
207
|
loggingProvider_1.logger.info(`Saved test ${journey.invariant_id} : ${env_1.BASE_APP_URL}/workspaces/${journey.organization_id}/train/tests/${journey.invariant_id}/current`);
|
|
@@ -218,13 +218,13 @@ function displayTestDescriptions(importedTests) {
|
|
|
218
218
|
loggingProvider_1.logger.logNewLine();
|
|
219
219
|
});
|
|
220
220
|
}
|
|
221
|
-
async function runTests(workspaceId, apiClient, importedTests) {
|
|
222
|
-
var _a, _b, _c;
|
|
221
|
+
async function runTests(workspaceId, apiClient, importedTests, playwrightProject) {
|
|
222
|
+
var _a, _b, _c, _d;
|
|
223
223
|
const tests = importedTests.map((test) => ({
|
|
224
224
|
test,
|
|
225
|
-
flow: stepsToFlow(workspaceId, test
|
|
225
|
+
flow: stepsToFlow(workspaceId, test, playwrightProject),
|
|
226
226
|
}));
|
|
227
|
-
const firstUrl = (
|
|
227
|
+
const firstUrl = (_a = playwrightProject.baseUrl) !== null && _a !== void 0 ? _a : (_c = (_b = tests.find((test) => test.flow.url)) === null || _b === void 0 ? void 0 : _b.flow) === null || _c === void 0 ? void 0 : _c.url;
|
|
228
228
|
const browserPath = await new chromiumBrowserEngine_1.ChromiumBrowserEngine().findBrowserExecutable();
|
|
229
229
|
for (let testIndex = 0; testIndex < tests.length; testIndex++) {
|
|
230
230
|
const testToRun = tests[testIndex];
|
|
@@ -233,14 +233,25 @@ async function runTests(workspaceId, apiClient, importedTests) {
|
|
|
233
233
|
organization_id: workspaceId,
|
|
234
234
|
name: testToRun.test.testName,
|
|
235
235
|
flows: [],
|
|
236
|
-
url: (
|
|
236
|
+
url: (_d = testToRun.flow.url) !== null && _d !== void 0 ? _d : firstUrl,
|
|
237
237
|
};
|
|
238
238
|
const testRunner = await createTestRunner(apiClient, journey, testToRun.flow, journey.url, workspaceId, browserPath);
|
|
239
239
|
const results = await testRunner.run();
|
|
240
240
|
loggingProvider_1.logger.info(`Test result: ${results.status}`);
|
|
241
|
+
updateMablscript(testRunner, testToRun.test);
|
|
241
242
|
}
|
|
242
243
|
}
|
|
243
|
-
function
|
|
244
|
+
function updateMablscript(testRunner, test) {
|
|
245
|
+
var _a;
|
|
246
|
+
let mablscript = '';
|
|
247
|
+
for (const step of (_a = testRunner.steps) !== null && _a !== void 0 ? _a : []) {
|
|
248
|
+
mablscript += step.toMablscript() + '\n';
|
|
249
|
+
}
|
|
250
|
+
test.updatedMablscript = mablscript;
|
|
251
|
+
}
|
|
252
|
+
function stepsToFlow(workspaceId, test, playwrightProject) {
|
|
253
|
+
var _a, _b;
|
|
254
|
+
const steps = test.steps;
|
|
244
255
|
const prototype = {
|
|
245
256
|
import_source_id: mablApi_1.ImportSourceId.SeleniumNodeProxy,
|
|
246
257
|
import_source_version: (0, pureUtil_1.getCliVersion)(),
|
|
@@ -252,9 +263,9 @@ function stepsToFlow(workspaceId, steps) {
|
|
|
252
263
|
.map((selector) => selector === null || selector === void 0 ? void 0 : selector.toMablscriptSelector())
|
|
253
264
|
.filter((selector) => selector)
|
|
254
265
|
.map((selector) => selector),
|
|
255
|
-
script: steps.map((step) => step.mablscript).join('\n'),
|
|
266
|
+
script: (_a = test.updatedMablscript) !== null && _a !== void 0 ? _a : steps.map((step) => step.mablscript).join('\n'),
|
|
256
267
|
script_description: steps.map((step) => step.description).join('\n'),
|
|
257
|
-
url: steps.map((step) => step.url).find((url) => url),
|
|
268
|
+
url: (_b = playwrightProject.baseUrl) !== null && _b !== void 0 ? _b : steps.map((step) => step.url).find((url) => url),
|
|
258
269
|
};
|
|
259
270
|
return prototype;
|
|
260
271
|
}
|
|
@@ -278,7 +289,10 @@ async function createTestRunner(apiClient, test, flow, url, workspaceId, browser
|
|
|
278
289
|
},
|
|
279
290
|
mablApiClient: apiClient,
|
|
280
291
|
});
|
|
281
|
-
await runner.initializeTestRunner(test, [flow], 'master', apiClient, false, browserPath, {
|
|
292
|
+
await runner.initializeTestRunner(test, [flow], 'master', apiClient, false, browserPath, {
|
|
293
|
+
enableCustomFindConversions: true,
|
|
294
|
+
url,
|
|
295
|
+
});
|
|
282
296
|
return runner;
|
|
283
297
|
}
|
|
284
298
|
function processSingleTraceFile(traceFile, playwrightProject, converter) {
|
|
@@ -372,11 +386,13 @@ async function getProjectInfo(args) {
|
|
|
372
386
|
const processClosedPromise = new RichPromise_1.default();
|
|
373
387
|
const playwrightProcess = spawn('npx', commandArgs, options);
|
|
374
388
|
playwrightProcess.stdout.on('data', (data) => {
|
|
389
|
+
const lineHint = '@mabl project info';
|
|
375
390
|
consoleLines.push(data.toString());
|
|
376
|
-
if (data.toString().includes(
|
|
391
|
+
if (data.toString().includes(lineHint) &&
|
|
377
392
|
processClosedPromise.isPending()) {
|
|
378
393
|
try {
|
|
379
|
-
const
|
|
394
|
+
const line = data.toString().split(lineHint)[1].split('\n')[0].trim();
|
|
395
|
+
const info = JSON.parse(line);
|
|
380
396
|
processClosedPromise.resolve(info);
|
|
381
397
|
}
|
|
382
398
|
catch {
|
|
@@ -243,6 +243,7 @@ async function run(parsed) {
|
|
|
243
243
|
_cliCreated: true,
|
|
244
244
|
basicAuthCredentialsId: parsed[constants_1.CommandArgBasicAuthCredentials],
|
|
245
245
|
branchName: parsed['mabl-branch'],
|
|
246
|
+
branchChangesOnly: parsed['branch-changes-only'],
|
|
246
247
|
browserType,
|
|
247
248
|
credentialsId: parsed['credentials-id'],
|
|
248
249
|
dataTableVariables: scenario,
|
|
@@ -33,7 +33,7 @@ const RESPONSE_PROPERTIES = {
|
|
|
33
33
|
exports.ASSERT_TARGETS = [
|
|
34
34
|
{ label: 'Header', value: newman_types_1.AssertionTarget.Header },
|
|
35
35
|
{ label: 'Status', value: newman_types_1.AssertionTarget.Status },
|
|
36
|
-
{ label: 'Size', value: newman_types_1.AssertionTarget.Size },
|
|
36
|
+
{ label: 'Size (bytes)', value: newman_types_1.AssertionTarget.Size },
|
|
37
37
|
{ label: 'JSON Body', value: newman_types_1.AssertionTarget.JSONBody },
|
|
38
38
|
{ label: 'Text Body', value: newman_types_1.AssertionTarget.TextBody },
|
|
39
39
|
];
|