@mablhq/mabl-cli 2.51.1 → 2.51.10

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 (55) hide show
  1. package/api/featureSet.js +2 -2
  2. package/browserLauncher/index.js +8 -0
  3. package/browserLauncher/index.js.LICENSE.txt +28 -0
  4. package/commands/tests/testsUtil.js +1 -1
  5. package/commands/tests/tests_cmds/import_cmds/import_playwright.js +7 -1
  6. package/core/execution/ApiTestUtils.js +107 -14
  7. package/execution/index.js +1 -1
  8. package/package.json +3 -3
  9. package/browserLauncher/browser.js +0 -2
  10. package/browserLauncher/browserEvent.js +0 -11
  11. package/browserLauncher/browserLauncher.js +0 -17
  12. package/browserLauncher/browserLauncherEventEmitter.js +0 -2
  13. package/browserLauncher/browserLauncherFactory.js +0 -30
  14. package/browserLauncher/elementHandle.js +0 -30
  15. package/browserLauncher/errors.js +0 -26
  16. package/browserLauncher/frame.js +0 -17
  17. package/browserLauncher/frameBase.js +0 -10
  18. package/browserLauncher/httpRequest.js +0 -2
  19. package/browserLauncher/httpResponse.js +0 -2
  20. package/browserLauncher/jsHandle.js +0 -2
  21. package/browserLauncher/page.js +0 -2
  22. package/browserLauncher/pageEvent.js +0 -17
  23. package/browserLauncher/playwrightBrowserLauncher/browserDelegate.js +0 -2
  24. package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumBrowserDelegate.js +0 -61
  25. package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumElementHandleDelegate.js +0 -129
  26. package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumFrameDelegate.js +0 -24
  27. package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumPageDelegate.js +0 -145
  28. package/browserLauncher/playwrightBrowserLauncher/elementHandleDelegate.js +0 -2
  29. package/browserLauncher/playwrightBrowserLauncher/firefox/firefoxBrowserDelegate.js +0 -50
  30. package/browserLauncher/playwrightBrowserLauncher/firefox/firefoxElementHandleDelegate.js +0 -11
  31. package/browserLauncher/playwrightBrowserLauncher/firefox/firefoxFrameDelegate.js +0 -26
  32. package/browserLauncher/playwrightBrowserLauncher/firefox/firefoxPageDelegate.js +0 -15
  33. package/browserLauncher/playwrightBrowserLauncher/frameDelegate.js +0 -2
  34. package/browserLauncher/playwrightBrowserLauncher/internals.js +0 -2
  35. package/browserLauncher/playwrightBrowserLauncher/nonChromium/nonChromiumAbstractBrowserDelegate.js +0 -15
  36. package/browserLauncher/playwrightBrowserLauncher/nonChromium/nonChromiumAbstractElementHandleDelegate.js +0 -73
  37. package/browserLauncher/playwrightBrowserLauncher/nonChromium/nonChromiumAbstractFrameDelegate.js +0 -13
  38. package/browserLauncher/playwrightBrowserLauncher/nonChromium/nonChromiumAbstractPageDelegate.js +0 -81
  39. package/browserLauncher/playwrightBrowserLauncher/pageDelegate.js +0 -2
  40. package/browserLauncher/playwrightBrowserLauncher/playwrightApiResponse.js +0 -18
  41. package/browserLauncher/playwrightBrowserLauncher/playwrightBrowser.js +0 -259
  42. package/browserLauncher/playwrightBrowserLauncher/playwrightBrowserLauncher.js +0 -97
  43. package/browserLauncher/playwrightBrowserLauncher/playwrightDom.js +0 -319
  44. package/browserLauncher/playwrightBrowserLauncher/playwrightFrame.js +0 -265
  45. package/browserLauncher/playwrightBrowserLauncher/playwrightHttpRequest.js +0 -76
  46. package/browserLauncher/playwrightBrowserLauncher/playwrightHttpResponse.js +0 -26
  47. package/browserLauncher/playwrightBrowserLauncher/playwrightPage.js +0 -377
  48. package/browserLauncher/playwrightBrowserLauncher/simplePlaywrightLogger.js +0 -36
  49. package/browserLauncher/playwrightBrowserLauncher/webkit/webkitBrowserDelegate.js +0 -50
  50. package/browserLauncher/playwrightBrowserLauncher/webkit/webkitElementHandleDelegate.js +0 -16
  51. package/browserLauncher/playwrightBrowserLauncher/webkit/webkitFrameDelegate.js +0 -19
  52. package/browserLauncher/playwrightBrowserLauncher/webkit/webkitPageDelegate.js +0 -15
  53. package/browserLauncher/playwrightBrowserLauncher/wrappers.js +0 -25
  54. package/browserLauncher/types.js +0 -28
  55. package/browserLauncher/utils.js +0 -9
@@ -0,0 +1,28 @@
1
+ /*!
2
+ * Tmp
3
+ *
4
+ * Copyright (c) 2011-2017 KARASZI Istvan <github@spam.raszi.hu>
5
+ *
6
+ * MIT Licensed
7
+ */
8
+
9
+ /*!
10
+ * mime-db
11
+ * Copyright(c) 2014 Jonathan Ong
12
+ * MIT Licensed
13
+ */
14
+
15
+ /*!
16
+ * mime-types
17
+ * Copyright(c) 2014 Jonathan Ong
18
+ * Copyright(c) 2015 Douglas Christopher Wilson
19
+ * MIT Licensed
20
+ */
21
+
22
+ /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
23
+
24
+ /** @license URI.js v4.4.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js */
25
+
26
+ //! moment.js
27
+
28
+ //! moment.js locale configuration
@@ -31,7 +31,7 @@ const cli_table3_1 = __importDefault(require("cli-table3"));
31
31
  const fs = __importStar(require("fs"));
32
32
  const os = __importStar(require("os"));
33
33
  const path = __importStar(require("path"));
34
- const browserLauncher_1 = require("../../browserLauncher/browserLauncher");
34
+ const browserLauncher_1 = require("../../browserLauncher");
35
35
  const trainingSessionActions_1 = require("../../core/messaging/actions/trainingSessionActions");
36
36
  const logLineMessaging_1 = require("../../core/messaging/logLineMessaging");
37
37
  const messaging_1 = require("../../core/messaging/messaging");
@@ -366,6 +366,9 @@ async function getProjectInfo(args) {
366
366
  ...process.env,
367
367
  },
368
368
  };
369
+ if (process.platform === 'win32') {
370
+ options.shell = true;
371
+ }
369
372
  const processClosedPromise = new RichPromise_1.default();
370
373
  const playwrightProcess = spawn('npx', commandArgs, options);
371
374
  playwrightProcess.stdout.on('data', (data) => {
@@ -411,8 +414,11 @@ async function runPlaywrightProject(args, tracesPath, cwd) {
411
414
  ...process.env,
412
415
  },
413
416
  };
417
+ if (process.platform === 'win32') {
418
+ options.shell = true;
419
+ }
414
420
  loggingProvider_1.logger.info('Checking playwright project...');
415
- const playwrightProjectFile = path_1.default.join(options.cwd, 'playwright.config.ts');
421
+ const playwrightProjectFile = path_1.default.join(options.cwd.toString(), 'playwright.config.ts');
416
422
  if (!fs_1.default.existsSync(playwrightProjectFile)) {
417
423
  throw new Error('No playwright project found. Please ensure you are in the root directory of a playwright project.');
418
424
  }
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.PRE_REQUEST_LISTEN = exports.convertMablAssertionsToExecArray = exports.convertMablVariableAssignmentsToExecArray = exports.createMablGeneratedScripts = exports.insertMablAssertionScripts = exports.toPostmanScript = exports.replaceVariables = exports.getActualValue = exports.readBody = exports.getResponseContentType = exports.valueToUnquotedString = exports.assertionTypeSupportsCaseSensitivity = exports.assertionTargetSupportsCaseSensitivity = exports.humanizeAssertion = exports.getAssertionTargetArgument = exports.assertionHasTest = exports.isValidMablAssertion = exports.normalizeRegExpExpectedValue = exports.normalizeExpectedValue = exports.normalizeAssertionValue = exports.assertionRequiresValue = exports.filterValidMablAssertions = exports.filterValidMablVariableAssignments = exports.isValidMablVariableAssignment = exports.removeMablGeneratedScripts = exports.createEmptyRequestEvent = exports.findFirstMatchingEvent = exports.restoreCustomRequestFields = exports.deduplicateApiTestExecutionResults = exports.createEmptyVariable = exports.createEmptyAssertion = exports.humanizeAssertionType = exports.getAssertionTypesForTarget = exports.caseInsensitiveEquals = exports.compareStringsCaseInsensitive = exports.ASSERT_TYPES = exports.ASSERT_TARGETS = exports.COLLECTION_WITH_FOLDERS_ERROR = exports.HMAC_SHA1_SIGNATURE = exports.DEFAULT_ADD_OAUTH1_TO_HEADER_VALUE = exports.DEFAULT_OAUTH1_VERSION = exports.OAUTH1_AUTH = exports.NO_AUTH = exports.BEARER_TOKEN_AUTH = exports.BASIC_AUTH = exports.API_KEY_AUTH = exports.INHERIT_AUTH_FROM_PARENT_VALUE = exports.MABL_GENERATED_COMMENT = exports.MABL_GENERATED_ASSERTION_TOKEN = exports.TEST_LISTEN = void 0;
7
- exports.uuid = exports.insertTestConfigurationIntoFlow = exports.createCommentForApiTestSnippet = exports.convertMablSnippetsToExecArray = exports.createPostmanScript = exports.insertMablScriptsIntoCollection = exports.processPostmanItem = exports.replaceRawScriptWithExecArray = exports.removeInvalidHeaders = exports.processItemAuth = exports.mablAuthToPostman = exports.formatContent = exports.getRequestMode = exports.getFormDataArray = exports.isText = exports.isXML = exports.isJson = exports.isSupportedAuthType = exports.isItemDefinition = exports.isCollectionDefinition = exports.isItemGroupDefinition = exports.isFolder = exports.validateCollectionFeaturesForApiTestEditor = exports.generateRawScriptField = exports.processPostmanItems = exports.createEmptyRequest = exports.createEmptyRequestEventArray = exports.splitLines = void 0;
7
+ exports.uuid = exports.postmanEventToExecutableSnippets = exports.postmanAuthToApiTestAuth = exports.getValueFromAuthVariables = exports.insertTestConfigurationIntoFlow = exports.createCommentForApiTestSnippet = exports.convertMablSnippetsToExecArray = exports.createPostmanScript = exports.insertMablScriptsIntoCollection = exports.processPostmanItem = exports.replaceRawScriptWithExecArray = exports.removeInvalidHeaders = exports.processItemAuth = exports.mablAuthToPostman = exports.formatContent = exports.getRequestMode = exports.getFormDataArray = exports.isText = exports.isXML = exports.isJson = exports.isSupportedAuthType = exports.isItemDefinition = exports.isCollectionDefinition = exports.isItemGroupDefinition = exports.isFolder = exports.validateCollectionFeaturesForApiTestEditor = exports.generateRawScriptField = exports.processPostmanItems = exports.createEmptyRequest = exports.createEmptyRequestEventArray = exports.splitLines = void 0;
8
8
  const newman_types_1 = require("./newman-types");
9
9
  const lodash_1 = __importDefault(require("lodash"));
10
10
  const uuid_1 = require("uuid");
@@ -99,17 +99,6 @@ function getAssertionTypesForTarget(target) {
99
99
  ].includes(assertType.value));
100
100
  case newman_types_1.AssertionTarget.Header:
101
101
  case newman_types_1.AssertionTarget.JSONBody:
102
- return exports.ASSERT_TYPES.filter((assertType) => [
103
- newman_types_1.AssertionType.Contains,
104
- newman_types_1.AssertionType.DoesNotContain,
105
- newman_types_1.AssertionType.EndsWith,
106
- newman_types_1.AssertionType.Equals,
107
- newman_types_1.AssertionType.MatchesRegExp,
108
- newman_types_1.AssertionType.NotEquals,
109
- newman_types_1.AssertionType.NotPresent,
110
- newman_types_1.AssertionType.Present,
111
- newman_types_1.AssertionType.StartsWith,
112
- ].includes(assertType.value));
113
102
  default:
114
103
  return exports.ASSERT_TYPES;
115
104
  }
@@ -447,6 +436,27 @@ function generateJsonBodyAssertion(description, assertType, requiresValues, path
447
436
  if (requiresValues) {
448
437
  propertyAccessor = valueToUnquotedString(propertyAccessor);
449
438
  }
439
+ switch (assertType) {
440
+ case 'Present':
441
+ case 'NotPresent':
442
+ case 'Equals':
443
+ case 'NotEquals':
444
+ case 'Contains':
445
+ case 'DoesNotContain':
446
+ case 'StartsWith':
447
+ case 'EndsWith':
448
+ case 'MatchesRegExp':
449
+ break;
450
+ case 'GreaterThan':
451
+ case 'GreaterThanOrEqualTo':
452
+ case 'LessThan':
453
+ case 'LessThanOrEqualTo':
454
+ propertyAccessor = `parseFloat(${propertyAccessor})`;
455
+ expectedValue = `parseFloat(${expectedValue})`;
456
+ break;
457
+ default:
458
+ throw new Error(`Unexpected header assert type: ${assertType}`);
459
+ }
450
460
  return generatePostmanAssertion(description, propertyAccessor, assertType, expectedValue, caseSensitive);
451
461
  }
452
462
  function generateJsonBodyVariableAssignment(variableName, path) {
@@ -504,6 +514,7 @@ function generateHeaderAssertion(description, assertType, headerName, expectedVa
504
514
  }
505
515
  const normalizedHeaderName = JSON.stringify(headerName);
506
516
  let test;
517
+ let target = `pm.response.headers.get(${normalizedHeaderName})`;
507
518
  switch (assertType) {
508
519
  case 'Present':
509
520
  test = `pm.response.to.have.header(${normalizedHeaderName})`;
@@ -523,11 +534,13 @@ function generateHeaderAssertion(description, assertType, headerName, expectedVa
523
534
  case 'GreaterThanOrEqualTo':
524
535
  case 'LessThan':
525
536
  case 'LessThanOrEqualTo':
526
- return;
537
+ target = `parseFloat(${target})`;
538
+ expectedValue = `parseFloat(${expectedValue})`;
539
+ break;
527
540
  default:
528
541
  throw new Error(`Unexpected header assert type: ${assertType}`);
529
542
  }
530
- return generatePostmanTest(description, test !== null && test !== void 0 ? test : generatePostmanExpect(`pm.response.headers.get(${normalizedHeaderName})`, assertType, expectedValue, caseSensitive));
543
+ return generatePostmanTest(description, test !== null && test !== void 0 ? test : generatePostmanExpect(target, assertType, expectedValue, caseSensitive));
531
544
  }
532
545
  function generateSizeAssertion(description, target, type, expectedValue) {
533
546
  if (!(expectedValue === null || expectedValue === void 0 ? void 0 : expectedValue.length)) {
@@ -1192,5 +1205,85 @@ function executableSnippetToApiTestSnippet(executableSnippet) {
1192
1205
  reusable: false,
1193
1206
  };
1194
1207
  }
1208
+ function getValueFromAuthVariables(authVariables, variableName) {
1209
+ var _a;
1210
+ return (_a = authVariables === null || authVariables === void 0 ? void 0 : authVariables.find((variable) => variable.key === variableName)) === null || _a === void 0 ? void 0 : _a.value;
1211
+ }
1212
+ exports.getValueFromAuthVariables = getValueFromAuthVariables;
1213
+ function postmanAuthToApiTestAuth(auth) {
1214
+ const { type: authType } = auth || {};
1215
+ if (!authType || authType === 'noauth') {
1216
+ return undefined;
1217
+ }
1218
+ const apiTestAuth = {
1219
+ type: authType,
1220
+ };
1221
+ const getValueFromVariablesForAuthType = (variableName) => getValueFromAuthVariables(auth[authType], variableName);
1222
+ switch (authType) {
1223
+ case 'apikey':
1224
+ apiTestAuth.api_key = {
1225
+ location: getValueFromVariablesForAuthType('in'),
1226
+ key: getValueFromVariablesForAuthType('key'),
1227
+ value: getValueFromVariablesForAuthType('value'),
1228
+ };
1229
+ break;
1230
+ case 'basic':
1231
+ apiTestAuth.basic = {
1232
+ username: getValueFromVariablesForAuthType('username'),
1233
+ password: getValueFromVariablesForAuthType('password'),
1234
+ };
1235
+ break;
1236
+ case 'bearer':
1237
+ apiTestAuth.bearer = {
1238
+ token: getValueFromVariablesForAuthType('token'),
1239
+ };
1240
+ break;
1241
+ case 'oauth1':
1242
+ apiTestAuth.oauth1 = {
1243
+ consumer_key: getValueFromVariablesForAuthType('consumerKey'),
1244
+ consumer_secret: getValueFromVariablesForAuthType('consumerSecret'),
1245
+ token: getValueFromVariablesForAuthType('token'),
1246
+ token_secret: getValueFromVariablesForAuthType('tokenSecret'),
1247
+ signature_method: getValueFromVariablesForAuthType('signatureMethod'),
1248
+ nonce: getValueFromVariablesForAuthType('nonce'),
1249
+ timestamp: getValueFromVariablesForAuthType('timestamp'),
1250
+ version: getValueFromVariablesForAuthType('version'),
1251
+ realm: getValueFromVariablesForAuthType('realm'),
1252
+ add_parameters_to_header: getValueFromVariablesForAuthType('addParamsToHeader'),
1253
+ add_empty_parameters_to_signature: getValueFromVariablesForAuthType('addEmptyParamsToSignature'),
1254
+ callback_url: getValueFromVariablesForAuthType('callbackUrl'),
1255
+ include_body_hash: getValueFromVariablesForAuthType('includeBodyHash'),
1256
+ verifier: getValueFromVariablesForAuthType('verifier'),
1257
+ };
1258
+ break;
1259
+ }
1260
+ return apiTestAuth;
1261
+ }
1262
+ exports.postmanAuthToApiTestAuth = postmanAuthToApiTestAuth;
1263
+ function postmanEventToExecutableSnippets(event) {
1264
+ var _a, _b;
1265
+ if (!event) {
1266
+ return [];
1267
+ }
1268
+ return ((_b = (_a = event.mablSnippets) === null || _a === void 0 ? void 0 : _a.map((snippet) => {
1269
+ if (snippet.reusable) {
1270
+ const executableSnippet = {
1271
+ invariant_id: snippet.invariantId,
1272
+ reusable: true,
1273
+ };
1274
+ return executableSnippet;
1275
+ }
1276
+ const executableSnippet = {
1277
+ reusable: false,
1278
+ body: snippet.body,
1279
+ description: snippet.description,
1280
+ name: snippet.name,
1281
+ snippet_type: snippet.snippet_type,
1282
+ workspace_id: snippet.workspace_id,
1283
+ };
1284
+ return executableSnippet;
1285
+ })) !== null && _b !== void 0 ? _b : []);
1286
+ }
1287
+ exports.postmanEventToExecutableSnippets = postmanEventToExecutableSnippets;
1195
1288
  const uuid = () => (0, uuid_1.v4)();
1196
1289
  exports.uuid = uuid;