@mablhq/mabl-cli 2.49.1 → 2.50.12

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 (33) hide show
  1. package/README.md +0 -13
  2. package/api/mablApiClient.js +12 -0
  3. package/browserLauncher/playwrightBrowserLauncher/firefox/firefoxBrowserDelegate.js +1 -1
  4. package/browserLauncher/playwrightBrowserLauncher/firefox/firefoxFrameDelegate.js +2 -12
  5. package/browserLauncher/playwrightBrowserLauncher/playwrightFrame.js +1 -1
  6. package/commands/databases/databases.js +5 -0
  7. package/commands/databases/databases_cmds/list.js +64 -0
  8. package/commands/tests/tests_cmds/export.js +3 -3
  9. package/commands/tests/tests_cmds/import_cmds/import_playwright.js +2 -2
  10. package/commands/tests/tests_cmds/import_cmds/import_selenium.js +2 -2
  11. package/commands/tests/tests_cmds/run.js +1 -3
  12. package/core/execution/ApiTestUtils.js +17 -13
  13. package/core/util.js +3 -0
  14. package/execution/index.js +3 -3
  15. package/index.d.ts +21 -0
  16. package/mablApi/index.js +1 -1
  17. package/mablscript/diffing/diffingUtil.js +7 -7
  18. package/package.json +3 -4
  19. package/proxy/index.js +1 -1
  20. package/upload/index.js +1 -1
  21. package/mablscript/mobile/tests/steps/CreateVariableMobileStep.mobiletest.js +0 -298
  22. package/mablscript/mobile/tests/steps/EnterTextStep.mobiletest.js +0 -79
  23. package/mablscript/mobile/tests/steps/GeneralHumanization.mobiletest.js +0 -304
  24. package/mablscript/mobile/tests/steps/HideKeyboardStep.mobiletest.js +0 -27
  25. package/mablscript/mobile/tests/steps/InstallAppStep.mobiletest.js +0 -20
  26. package/mablscript/mobile/tests/steps/NavigateBackStep.mobiletest.js +0 -27
  27. package/mablscript/mobile/tests/steps/NavigateHomeStep.mobiletest.js +0 -27
  28. package/mablscript/mobile/tests/steps/OpenLinkStep.mobiletest.js +0 -20
  29. package/mablscript/mobile/tests/steps/PushFileStep.mobiletest.js +0 -55
  30. package/mablscript/mobile/tests/steps/ScrollStep.mobiletest.js +0 -386
  31. package/mablscript/mobile/tests/steps/SetOrientationStep.mobiletest.js +0 -32
  32. package/mablscript/mobile/tests/steps/TapStep.mobiletest.js +0 -57
  33. package/mablscript/mobile/tests/steps/UninstallAppStep.mobiletest.js +0 -20
package/README.md CHANGED
@@ -242,19 +242,6 @@ Use the:
242
242
  **Note: pre v1.0.0 `run` behavior has been moved to `run-legacy`, and will be
243
243
  removed in a future release.**
244
244
 
245
- #### [DEPRECATED] Alpha run mode
246
-
247
- The alpha run command behavior, `run-alpha` has been promoted to GA as `run`.
248
-
249
- **`run-alpha` command is DEPRECATED and will be removed in a future release.
250
- Please migrate to `run` which has the identical behavior**
251
-
252
- Example:
253
-
254
- ```bash
255
- mabl tests run-alpha --run-id <test-run-id> --headless
256
- ```
257
-
258
245
  #### List mabl tests
259
246
 
260
247
  The `mabl tests list` command allows for listing all mabl tests in a workspace.
@@ -192,6 +192,18 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
192
192
  throw toApiError(`Failed to get credentials`, error);
193
193
  }
194
194
  }
195
+ async getDatabaseConnections(workspaceId, limit) {
196
+ try {
197
+ const query = query_string_1.default.stringify({
198
+ organization_id: workspaceId,
199
+ limit,
200
+ });
201
+ return await this.makeGetRequest(`${this.baseApiUrl}/database/connections?${query}`).then((result) => { var _a; return (_a = result.database_connections) !== null && _a !== void 0 ? _a : []; });
202
+ }
203
+ catch (error) {
204
+ throw toApiError(`Failed to get database connections`, error);
205
+ }
206
+ }
195
207
  async getCredential(credentialId, withSecrets, withComputedTotpCount) {
196
208
  const queryStringParams = query_string_1.default.stringify({
197
209
  with_secrets: withSecrets,
@@ -44,7 +44,7 @@ class FirefoxBrowserDelegate extends nonChromiumAbstractBrowserDelegate_1.NonChr
44
44
  return this._browser._connection.rootSession;
45
45
  }
46
46
  supportsExposeFunction() {
47
- return true;
47
+ return false;
48
48
  }
49
49
  }
50
50
  exports.FirefoxBrowserDelegate = FirefoxBrowserDelegate;
@@ -3,19 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FirefoxFrameDelegate = void 0;
4
4
  const types_1 = require("../../types");
5
5
  const nonChromiumAbstractFrameDelegate_1 = require("../nonChromium/nonChromiumAbstractFrameDelegate");
6
- const playwrightFrame_1 = require("../playwrightFrame");
7
6
  class FirefoxFrameDelegate extends nonChromiumAbstractFrameDelegate_1.NonChromiumAbstractFrameDelegate {
8
- async addBindingToSecondaryWorld(binding) {
9
- var _a;
10
- const pageImpl = this.parentPageDelegate.pageImpl;
11
- if (pageImpl) {
12
- await ((_a = pageImpl._delegate) === null || _a === void 0 ? void 0 : _a._session.send('Page.addBinding', {
13
- worldName: playwrightFrame_1.UTILITY_CONTEXT_NAME,
14
- name: binding.name,
15
- script: binding.source,
16
- }));
17
- }
18
- return;
7
+ addBindingToSecondaryWorld(_binding) {
8
+ return Promise.resolve();
19
9
  }
20
10
  async url() {
21
11
  let url = this.frame.url();
@@ -239,7 +239,7 @@ class PlaywrightFrame extends browserLauncher_1.Frame {
239
239
  return false;
240
240
  }
241
241
  await this.delegate.addBindingToSecondaryWorld(binding);
242
- await this.evaluateCodeInSecondaryWorld(binding.source, {});
242
+ await this.evaluateCodeInSecondaryWorld(binding.initScript.source, {});
243
243
  }
244
244
  catch (e) {
245
245
  return false;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = 'databases <command>';
4
+ exports.describe = 'Manage your testing databases';
5
+ exports.builder = (yargs) => yargs.commandDir('databases_cmds').demandCommand();
@@ -0,0 +1,64 @@
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
+ const js_yaml_1 = require("js-yaml");
7
+ const mablApiClientFactory_1 = require("../../../api/mablApiClientFactory");
8
+ const util_1 = require("../../commandUtil/util");
9
+ const cli_table3_1 = __importDefault(require("cli-table3"));
10
+ const moment = require("moment");
11
+ const list_1 = require("../../commandUtil/list");
12
+ const loggingProvider_1 = require("../../../providers/logging/loggingProvider");
13
+ const constants_1 = require("../../constants");
14
+ exports.command = 'list';
15
+ exports.describe = 'List your databases';
16
+ exports.builder = (0, list_1.getListBuilderOptions)('databases');
17
+ exports.handler = (0, util_1.failWrapper)(listDatabases);
18
+ async function listDatabases(parsed) {
19
+ const output = parsed.output;
20
+ const limit = parsed.limit;
21
+ const workspaceId = await (0, util_1.getWorkspaceId)(parsed);
22
+ const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
23
+ const databases = await apiClient.getDatabaseConnections(workspaceId, limit);
24
+ printConnections(databases, output);
25
+ return databases.length;
26
+ }
27
+ function printConnections(connections, output) {
28
+ switch (output) {
29
+ case 'json':
30
+ loggingProvider_1.logger.info(JSON.stringify(connections, null, 2));
31
+ break;
32
+ case 'yaml':
33
+ loggingProvider_1.logger.info((0, js_yaml_1.dump)(connections));
34
+ break;
35
+ default:
36
+ const table = new cli_table3_1.default({
37
+ head: ['ID', 'Name', 'DB Type', 'Description', 'Created time'],
38
+ wordWrap: true,
39
+ });
40
+ connections.forEach((connection) => {
41
+ table.push([
42
+ { rowSpan: 1, content: connection.id, vAlign: 'center' },
43
+ { rowSpan: 1, content: connection.name, vAlign: 'center' },
44
+ {
45
+ rowSpan: 1,
46
+ content: connection.database_type,
47
+ vAlign: 'center',
48
+ },
49
+ {
50
+ rowSpan: 1,
51
+ content: connection.description || '---',
52
+ vAlign: 'center',
53
+ },
54
+ {
55
+ rowSpan: 1,
56
+ content: moment.utc(connection.created_time).format(constants_1.ListTimeFormat),
57
+ vAlign: 'center',
58
+ },
59
+ ]);
60
+ });
61
+ loggingProvider_1.logger.info(table.toString());
62
+ break;
63
+ }
64
+ }
@@ -70,9 +70,9 @@ async function exportTest(parsed) {
70
70
  }
71
71
  const flowArray = await (0, util_1.getJourneyFlowArray)(journey, apiClient, branchName);
72
72
  if (flowArray
73
- .map((flow) => flow.flow_type === mablApi_1.Flow.FlowTypeEnum.Mablscript ||
74
- flow.flow_type === mablApi_1.Flow.FlowTypeEnum.Api ||
75
- flow.flow_type === mablApi_1.Flow.FlowTypeEnum.Mobile)
73
+ .map((flow) => flow.flow_type === mablApi_1.FlowTypeEnum.Mablscript ||
74
+ flow.flow_type === mablApi_1.FlowTypeEnum.Api ||
75
+ flow.flow_type === mablApi_1.FlowTypeEnum.Mobile)
76
76
  .includes(false)) {
77
77
  loggingProvider_1.logger.info(chalk.red(`Default mabl tests can not be exported`));
78
78
  return;
@@ -242,9 +242,9 @@ async function runTests(workspaceId, apiClient, importedTests) {
242
242
  }
243
243
  function stepsToFlow(workspaceId, steps) {
244
244
  const prototype = {
245
- import_source_id: mablApi_1.Flow.ImportSourceIdEnum.SeleniumNodeProxy,
245
+ import_source_id: mablApi_1.ImportSourceId.SeleniumNodeProxy,
246
246
  import_source_version: (0, pureUtil_1.getCliVersion)(),
247
- flow_type: mablApi_1.Flow.FlowTypeEnum.Mablscript,
247
+ flow_type: mablApi_1.FlowTypeEnum.Mablscript,
248
248
  organization_id: workspaceId,
249
249
  reusable: false,
250
250
  selectors: steps
@@ -258,9 +258,9 @@ async function runTests(workspaceId, name, apiClient, importedTests) {
258
258
  }
259
259
  function stepsToFlow(workspaceId, steps) {
260
260
  const prototype = {
261
- import_source_id: mablApi_1.Flow.ImportSourceIdEnum.SeleniumNodeProxy,
261
+ import_source_id: mablApi_1.ImportSourceId.SeleniumNodeProxy,
262
262
  import_source_version: (0, pureUtil_1.getCliVersion)(),
263
- flow_type: mablApi_1.Flow.FlowTypeEnum.Mablscript,
263
+ flow_type: mablApi_1.FlowTypeEnum.Mablscript,
264
264
  organization_id: workspaceId,
265
265
  reusable: false,
266
266
  selectors: steps
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.run = void 0;
4
3
  const util_1 = require("../../commandUtil/util");
5
4
  const testsUtil_1 = require("../testsUtil");
6
5
  const constants_1 = require("../../constants");
@@ -116,7 +115,7 @@ Note: Setting the environment does not override the default URL. Please use the
116
115
  })
117
116
  .option(constants_1.CommandArgBasicAuthCredentials, {
118
117
  alias: constants_1.CommandArgAliases.BasicAuthCredentials,
119
- describe: 'Basic Authentication credentials to run the test with',
118
+ describe: 'Basic Authentication credentials for adding basic auth headers to test run',
120
119
  nargs: 1,
121
120
  type: 'string',
122
121
  })
@@ -291,7 +290,6 @@ async function run(parsed) {
291
290
  }
292
291
  }
293
292
  }
294
- exports.run = run;
295
293
  function generateRunCommandTemplate(parsed, testResults) {
296
294
  var _a, _b, _c, _d, _e, _f, _g;
297
295
  const testResult = testResults.testResults[0];
@@ -218,7 +218,10 @@ function restoreFormDataFileMetadata(resultRequest, collectionRequest) {
218
218
  }
219
219
  }
220
220
  function findFirstMatchingEvent(eventDefinition, listen) {
221
- const eventIndex = lodash_1.default.findIndex(eventDefinition, { listen });
221
+ if (!eventDefinition) {
222
+ return { eventIndex: -1 };
223
+ }
224
+ const eventIndex = eventDefinition.findIndex((def) => def.listen === listen);
222
225
  let eventValue;
223
226
  if (eventIndex !== -1) {
224
227
  eventValue = eventDefinition === null || eventDefinition === void 0 ? void 0 : eventDefinition[eventIndex];
@@ -244,6 +247,7 @@ function createEmptyRequestEvent() {
244
247
  },
245
248
  ],
246
249
  mablVariables: [],
250
+ mablSnippets: [],
247
251
  };
248
252
  }
249
253
  exports.createEmptyRequestEvent = createEmptyRequestEvent;
@@ -256,7 +260,7 @@ function removeMablGeneratedScriptsFromLines(lines) {
256
260
  }
257
261
  function removeMablGeneratedScripts(eventDefinition) {
258
262
  var _a, _b;
259
- lodash_1.default.set(eventDefinition, 'script.exec', removeMablGeneratedScriptsFromLines((_b = (_a = eventDefinition.script) === null || _a === void 0 ? void 0 : _a.exec) !== null && _b !== void 0 ? _b : []));
263
+ eventDefinition.script.exec = removeMablGeneratedScriptsFromLines((_b = (_a = eventDefinition.script) === null || _a === void 0 ? void 0 : _a.exec) !== null && _b !== void 0 ? _b : []);
260
264
  }
261
265
  exports.removeMablGeneratedScripts = removeMablGeneratedScripts;
262
266
  function isValidMablVariableAssignment(variable) {
@@ -635,21 +639,21 @@ function readBody(body, contentType) {
635
639
  }
636
640
  exports.readBody = readBody;
637
641
  function getActualValue(assertion, apiStepExecutionResult, variables) {
638
- var _a, _b, _c, _d;
642
+ var _a, _b, _c, _d, _e;
639
643
  const { assertTarget, bodyPath, headerName } = assertion;
640
644
  switch (assertTarget) {
641
645
  case newman_types_1.AssertionTarget.Header:
642
- return lodash_1.default.find((_a = apiStepExecutionResult.response) === null || _a === void 0 ? void 0 : _a.header, (header) => caseInsensitiveEquals(header.key, headerName));
646
+ return ((_b = (_a = apiStepExecutionResult.response) === null || _a === void 0 ? void 0 : _a.header) !== null && _b !== void 0 ? _b : []).find((header) => caseInsensitiveEquals(header.key, headerName));
643
647
  case newman_types_1.AssertionTarget.JSONBody:
644
648
  const contentType = getResponseContentType(apiStepExecutionResult.response);
645
- const content = readBody((_b = apiStepExecutionResult.response) === null || _b === void 0 ? void 0 : _b.stream, contentType);
649
+ const content = readBody((_c = apiStepExecutionResult.response) === null || _c === void 0 ? void 0 : _c.stream, contentType);
646
650
  return bodyPath
647
651
  ? lodash_1.default.get(content, replaceVariables(bodyPath, variables))
648
652
  : content;
649
653
  case newman_types_1.AssertionTarget.Size:
650
- return (_c = apiStepExecutionResult.response) === null || _c === void 0 ? void 0 : _c.responseSize;
654
+ return (_d = apiStepExecutionResult.response) === null || _d === void 0 ? void 0 : _d.responseSize;
651
655
  case newman_types_1.AssertionTarget.Status:
652
- return (_d = apiStepExecutionResult.response) === null || _d === void 0 ? void 0 : _d.code;
656
+ return (_e = apiStepExecutionResult.response) === null || _e === void 0 ? void 0 : _e.code;
653
657
  }
654
658
  return null;
655
659
  }
@@ -710,7 +714,7 @@ function convertMablAssertionsToExecArray(event) {
710
714
  exports.convertMablAssertionsToExecArray = convertMablAssertionsToExecArray;
711
715
  exports.PRE_REQUEST_LISTEN = 'prerequest';
712
716
  function splitLines(value) {
713
- return value.length ? lodash_1.default.split(value, /\r?\n/) : [];
717
+ return value.length ? value.split(/\r?\n/) : [];
714
718
  }
715
719
  exports.splitLines = splitLines;
716
720
  function createEmptyRequestEventArray() {
@@ -740,7 +744,7 @@ const createEmptyRequest = (id = (0, uuid_1.v4)()) => ({
740
744
  });
741
745
  exports.createEmptyRequest = createEmptyRequest;
742
746
  function processPostmanItems(items, handleItem, handleFolder) {
743
- lodash_1.default.forEach(items, (item) => {
747
+ items === null || items === void 0 ? void 0 : items.forEach((item) => {
744
748
  if (isItemGroupDefinition(item)) {
745
749
  handleFolder === null || handleFolder === void 0 ? void 0 : handleFolder(item);
746
750
  processPostmanItems(item.item, handleItem, handleFolder);
@@ -753,7 +757,7 @@ function processPostmanItems(items, handleItem, handleFolder) {
753
757
  exports.processPostmanItems = processPostmanItems;
754
758
  function generateRawScriptField(eventValue) {
755
759
  if (eventValue.script) {
756
- eventValue.script.raw = lodash_1.default.join(eventValue.script.exec, '\n');
760
+ eventValue.script.raw = eventValue.script.exec.join('\n');
757
761
  }
758
762
  }
759
763
  exports.generateRawScriptField = generateRawScriptField;
@@ -839,7 +843,7 @@ function processMablProtocolProfileBehavior(item) {
839
843
  delete item.protocolProfileBehavior;
840
844
  return;
841
845
  }
842
- lodash_1.default.set(item, 'protocolProfileBehavior', {});
846
+ item.protocolProfileBehavior = {};
843
847
  mablProtocolProfileBehavior === null || mablProtocolProfileBehavior === void 0 ? void 0 : mablProtocolProfileBehavior.forEach((setting) => {
844
848
  if (setting.key && setting.value) {
845
849
  let valueToSet;
@@ -849,7 +853,7 @@ function processMablProtocolProfileBehavior(item) {
849
853
  catch (error) {
850
854
  valueToSet = setting.value;
851
855
  }
852
- lodash_1.default.set(item, ['protocolProfileBehavior', setting.key], valueToSet);
856
+ item.protocolProfileBehavior[setting.key] = valueToSet;
853
857
  }
854
858
  });
855
859
  }
@@ -954,7 +958,7 @@ function processItemAuth(item) {
954
958
  var _a, _b;
955
959
  const itemAuth = mablAuthToPostman((_a = item.mablTemporaryStorage) === null || _a === void 0 ? void 0 : _a.mablAuth, exports.INHERIT_AUTH_FROM_PARENT_VALUE);
956
960
  if (itemAuth) {
957
- lodash_1.default.set(item, 'request.auth', itemAuth);
961
+ item.request.auth = itemAuth;
958
962
  }
959
963
  else if ((_b = item.request) === null || _b === void 0 ? void 0 : _b.auth) {
960
964
  item.request.auth = {};
package/core/util.js CHANGED
@@ -47,6 +47,9 @@ async function validateAuthentication(apiClient, authConfig) {
47
47
  }
48
48
  exports.validateAuthentication = validateAuthentication;
49
49
  function jsonCloneDeep(value) {
50
+ if (value === undefined) {
51
+ return undefined;
52
+ }
50
53
  return JSON.parse(JSON.stringify(value));
51
54
  }
52
55
  exports.jsonCloneDeep = jsonCloneDeep;