@mablhq/mabl-cli 2.41.1 → 2.44.1
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/mablApiClient.js +1 -1
- package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumElementHandleDelegate.js +0 -2
- package/cli.js +0 -1
- package/commands/config/config_cmds/install.js +2 -2
- package/core/execution/ApiTestUtils.js +149 -45
- package/core/execution/newman-types.js +7 -0
- package/core/messaging/messaging.js +2 -1
- package/execution/index.js +3 -3
- package/mablApi/index.js +1 -1
- package/mobile/types.js +6 -0
- package/package.json +3 -4
- package/upload/index.js +1 -1
package/api/mablApiClient.js
CHANGED
|
@@ -428,7 +428,7 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
|
428
428
|
catch (error) {
|
|
429
429
|
throw toApiError(`Failed to get Snippet [${snippetId}]. ${workspaceId
|
|
430
430
|
? `The Snippet was likely deleted. To recover this snippet, visit the activity feed [workspaces/${workspaceId}/settings/activity-log?activityLogEntity=snippet&activityLogEvent=delete]`
|
|
431
|
-
: ''}`, error);
|
|
431
|
+
: 'The Snippet was likely deleted. To recover this snippet, visit the activity feed.'}`, error);
|
|
432
432
|
}
|
|
433
433
|
}
|
|
434
434
|
async getBranchById(branchId) {
|
|
@@ -71,8 +71,6 @@ class ChromiumElementHandleDelegate {
|
|
|
71
71
|
await this.enableOverlay();
|
|
72
72
|
const nodeInfo = await ((_a = this.getInternalCDPSession()) === null || _a === void 0 ? void 0 : _a.send('DOM.describeNode', {
|
|
73
73
|
objectId: this.getRemoteObjectId(),
|
|
74
|
-
depth: -1,
|
|
75
|
-
pierce: true,
|
|
76
74
|
}));
|
|
77
75
|
if (!nodeInfo) {
|
|
78
76
|
return;
|
package/cli.js
CHANGED
|
@@ -33,7 +33,6 @@ const constants_1 = require("./commands/constants");
|
|
|
33
33
|
const middleware_1 = require("./middleware");
|
|
34
34
|
const path_1 = __importDefault(require("path"));
|
|
35
35
|
const fs_1 = __importDefault(require("fs"));
|
|
36
|
-
require('v8-compile-cache');
|
|
37
36
|
require('yargonaut').style('cyan').helpStyle('magenta').errorsStyle('red');
|
|
38
37
|
const hasInternalDirectory = fs_1.default.existsSync(path_1.default.resolve(__dirname, 'commands', 'internal', 'internal_cmds'));
|
|
39
38
|
const excludeInternal = !hasInternalDirectory ? { exclude: /.*/gm } : undefined;
|
|
@@ -30,8 +30,8 @@ const fs = __importStar(require("fs"));
|
|
|
30
30
|
const path = __importStar(require("path"));
|
|
31
31
|
const resourceUtil_1 = require("../../../util/resourceUtil");
|
|
32
32
|
const OperatingSystemDescriptor_1 = require("../../../mablscript/types/OperatingSystemDescriptor");
|
|
33
|
-
const UI_AUTOMATOR_VERSION = '
|
|
34
|
-
const XCUITEST_VERSION = '
|
|
33
|
+
const UI_AUTOMATOR_VERSION = '3.7.6';
|
|
34
|
+
const XCUITEST_VERSION = '7.24.15';
|
|
35
35
|
const addOnConfigKey = 'add-on';
|
|
36
36
|
var AddOnOptions;
|
|
37
37
|
(function (AddOnOptions) {
|
|
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
exports.uuid = exports.createCommentForApiTestSnippet = exports.convertMablSnippetsToExecArray = exports.createPostmanScript = 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 = void 0;
|
|
6
|
+
exports.createEmptyRequestEventArray = exports.splitLines = 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.normalizeExpectedValue = 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.createCommentForApiTestSnippet = exports.convertMablSnippetsToExecArray = exports.createPostmanScript = 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 = 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");
|
|
@@ -41,18 +41,36 @@ exports.ASSERT_TYPES = [
|
|
|
41
41
|
{ label: 'Not contains', value: newman_types_1.AssertionType.DoesNotContain },
|
|
42
42
|
{ label: 'Is present', value: newman_types_1.AssertionType.Present },
|
|
43
43
|
{ label: 'Not present', value: newman_types_1.AssertionType.NotPresent },
|
|
44
|
+
{ label: 'Greater than', value: newman_types_1.AssertionType.GreaterThan },
|
|
45
|
+
{
|
|
46
|
+
label: 'Greater than or equal to',
|
|
47
|
+
value: newman_types_1.AssertionType.GreaterThanOrEqualTo,
|
|
48
|
+
},
|
|
49
|
+
{ label: 'Less than', value: newman_types_1.AssertionType.LessThan },
|
|
50
|
+
{ label: 'Less than or equal to', value: newman_types_1.AssertionType.LessThanOrEqualTo },
|
|
51
|
+
{ label: 'Starts with', value: newman_types_1.AssertionType.StartsWith },
|
|
52
|
+
{ label: 'Ends with', value: newman_types_1.AssertionType.EndsWith },
|
|
53
|
+
{ label: 'Matches regular expression', value: newman_types_1.AssertionType.MatchesRegExp },
|
|
44
54
|
];
|
|
55
|
+
const EXPECTED_VALUE_TOKEN = '!!EXPECTED_VALUE!!';
|
|
45
56
|
const EXPECT_FUNCTIONS = {
|
|
46
|
-
Equals:
|
|
47
|
-
NotEquals:
|
|
48
|
-
Contains:
|
|
49
|
-
DoesNotContain:
|
|
50
|
-
Present:
|
|
51
|
-
NotPresent:
|
|
57
|
+
Equals: `eql(${EXPECTED_VALUE_TOKEN})`,
|
|
58
|
+
NotEquals: `not.eql(${EXPECTED_VALUE_TOKEN})`,
|
|
59
|
+
Contains: `include(${EXPECTED_VALUE_TOKEN})`,
|
|
60
|
+
DoesNotContain: `not.include(${EXPECTED_VALUE_TOKEN})`,
|
|
61
|
+
Present: `not.be.undefined`,
|
|
62
|
+
NotPresent: `be.undefined`,
|
|
63
|
+
GreaterThan: `be.above(${EXPECTED_VALUE_TOKEN})`,
|
|
64
|
+
GreaterThanOrEqualTo: `be.at.least(${EXPECTED_VALUE_TOKEN})`,
|
|
65
|
+
LessThan: `be.below(${EXPECTED_VALUE_TOKEN})`,
|
|
66
|
+
LessThanOrEqualTo: `be.at.most(${EXPECTED_VALUE_TOKEN})`,
|
|
67
|
+
StartsWith: `satisfy(value => value.startsWith(${EXPECTED_VALUE_TOKEN}))`,
|
|
68
|
+
EndsWith: `satisfy(value => value.endsWith(${EXPECTED_VALUE_TOKEN}))`,
|
|
69
|
+
MatchesRegExp: `match(${EXPECTED_VALUE_TOKEN})`,
|
|
52
70
|
};
|
|
53
71
|
function compareStringsCaseInsensitive(a, b) {
|
|
54
|
-
a = a === null || a === void 0 ? void 0 : a.toLowerCase();
|
|
55
|
-
b = b === null || b === void 0 ? void 0 : b.toLowerCase();
|
|
72
|
+
a = a === null || a === void 0 ? void 0 : a.toUpperCase().toLowerCase();
|
|
73
|
+
b = b === null || b === void 0 ? void 0 : b.toUpperCase().toLowerCase();
|
|
56
74
|
if (!a) {
|
|
57
75
|
return -1;
|
|
58
76
|
}
|
|
@@ -70,8 +88,14 @@ function getAssertionTypesForTarget(target) {
|
|
|
70
88
|
switch (target) {
|
|
71
89
|
case newman_types_1.AssertionTarget.Size:
|
|
72
90
|
case newman_types_1.AssertionTarget.Status:
|
|
73
|
-
return exports.ASSERT_TYPES.filter((assertType) =>
|
|
74
|
-
|
|
91
|
+
return exports.ASSERT_TYPES.filter((assertType) => [
|
|
92
|
+
newman_types_1.AssertionType.Equals,
|
|
93
|
+
newman_types_1.AssertionType.NotEquals,
|
|
94
|
+
newman_types_1.AssertionType.GreaterThan,
|
|
95
|
+
newman_types_1.AssertionType.GreaterThanOrEqualTo,
|
|
96
|
+
newman_types_1.AssertionType.LessThan,
|
|
97
|
+
newman_types_1.AssertionType.LessThanOrEqualTo,
|
|
98
|
+
].includes(assertType.value));
|
|
75
99
|
default:
|
|
76
100
|
return exports.ASSERT_TYPES;
|
|
77
101
|
}
|
|
@@ -87,6 +111,20 @@ function humanizeAssertionType(assertionType) {
|
|
|
87
111
|
return 'is present';
|
|
88
112
|
case 'NotPresent':
|
|
89
113
|
return 'is not present';
|
|
114
|
+
case 'GreaterThan':
|
|
115
|
+
return 'greater than';
|
|
116
|
+
case 'GreaterThanOrEqualTo':
|
|
117
|
+
return 'greater than or equal to';
|
|
118
|
+
case 'LessThan':
|
|
119
|
+
return 'less than';
|
|
120
|
+
case 'LessThanOrEqualTo':
|
|
121
|
+
return 'less than or equal to';
|
|
122
|
+
case 'StartsWith':
|
|
123
|
+
return 'starts with';
|
|
124
|
+
case 'EndsWith':
|
|
125
|
+
return 'ends with';
|
|
126
|
+
case 'MatchesRegExp':
|
|
127
|
+
return 'matches regular expression';
|
|
90
128
|
default:
|
|
91
129
|
return assertionType.toString().toLowerCase();
|
|
92
130
|
}
|
|
@@ -236,7 +274,7 @@ function normalizeExpectedValue(value) {
|
|
|
236
274
|
if (value.match(/".*"/)) {
|
|
237
275
|
return `pm.variables.replaceIn(${value})`;
|
|
238
276
|
}
|
|
239
|
-
const lower = value.toLowerCase();
|
|
277
|
+
const lower = value.toUpperCase().toLowerCase();
|
|
240
278
|
if (lower === 'true' || lower === 'false' || !Number.isNaN(Number(value))) {
|
|
241
279
|
return JSON.stringify(value);
|
|
242
280
|
}
|
|
@@ -244,14 +282,15 @@ function normalizeExpectedValue(value) {
|
|
|
244
282
|
}
|
|
245
283
|
exports.normalizeExpectedValue = normalizeExpectedValue;
|
|
246
284
|
function isValidMablAssertion(assertion) {
|
|
247
|
-
var _a, _b, _c, _d, _e, _f
|
|
285
|
+
var _a, _b, _c, _d, _e, _f;
|
|
248
286
|
if (!assertion.assertType) {
|
|
249
287
|
return false;
|
|
250
288
|
}
|
|
251
289
|
const assertTarget = assertion.assertTarget;
|
|
252
290
|
const requiresValue = assertionRequiresValue(assertion);
|
|
253
291
|
const expectedValue = normalizeExpectedValue(assertion.value);
|
|
254
|
-
const
|
|
292
|
+
const hasExpectedValue = ((_a = expectedValue === null || expectedValue === void 0 ? void 0 : expectedValue.length) !== null && _a !== void 0 ? _a : 0) > 0;
|
|
293
|
+
const hasRequiredValue = !requiresValue || hasExpectedValue;
|
|
255
294
|
let valid = false;
|
|
256
295
|
switch (assertTarget) {
|
|
257
296
|
case 'JSONBody':
|
|
@@ -259,19 +298,32 @@ function isValidMablAssertion(assertion) {
|
|
|
259
298
|
valid = hasBodyPath && hasRequiredValue;
|
|
260
299
|
break;
|
|
261
300
|
case 'Status':
|
|
262
|
-
valid =
|
|
301
|
+
valid = hasExpectedValue;
|
|
263
302
|
break;
|
|
264
303
|
case 'Header':
|
|
265
|
-
const hasHeaderName = ((
|
|
304
|
+
const hasHeaderName = ((_f = (_e = assertion.headerName) === null || _e === void 0 ? void 0 : _e.length) !== null && _f !== void 0 ? _f : 0) > 0;
|
|
266
305
|
valid = hasHeaderName && hasRequiredValue;
|
|
267
306
|
break;
|
|
268
307
|
case 'Size':
|
|
269
|
-
valid =
|
|
308
|
+
valid =
|
|
309
|
+
isValidSizeAssertionType(assertion.assertType) && hasExpectedValue;
|
|
270
310
|
break;
|
|
271
311
|
}
|
|
272
312
|
return valid;
|
|
273
313
|
}
|
|
274
314
|
exports.isValidMablAssertion = isValidMablAssertion;
|
|
315
|
+
function isValidSizeAssertionType(assertType) {
|
|
316
|
+
switch (assertType) {
|
|
317
|
+
case newman_types_1.AssertionType.Equals:
|
|
318
|
+
case newman_types_1.AssertionType.NotEquals:
|
|
319
|
+
case newman_types_1.AssertionType.GreaterThan:
|
|
320
|
+
case newman_types_1.AssertionType.GreaterThanOrEqualTo:
|
|
321
|
+
case newman_types_1.AssertionType.LessThan:
|
|
322
|
+
case newman_types_1.AssertionType.LessThanOrEqualTo:
|
|
323
|
+
return true;
|
|
324
|
+
}
|
|
325
|
+
return false;
|
|
326
|
+
}
|
|
275
327
|
function assertionHasTest(assertion) {
|
|
276
328
|
if (!assertion.assertTarget || !assertion.assertType) {
|
|
277
329
|
return false;
|
|
@@ -321,13 +373,14 @@ function generateAssertionScript(assertion) {
|
|
|
321
373
|
const description = humanizeAssertion(assertion);
|
|
322
374
|
const requiresValue = assertionRequiresValue(assertion);
|
|
323
375
|
const expectedValue = normalizeExpectedValue(assertion.value);
|
|
376
|
+
const caseSensitive = assertion.caseSensitive !== false;
|
|
324
377
|
switch (assertTarget) {
|
|
325
378
|
case 'JSONBody':
|
|
326
|
-
return generateJsonBodyAssertion(description, assertType, requiresValue, assertion.bodyPath, expectedValue);
|
|
379
|
+
return generateJsonBodyAssertion(description, assertType, requiresValue, assertion.bodyPath, expectedValue, caseSensitive);
|
|
327
380
|
case 'Status':
|
|
328
381
|
return generateStatusAssertion(description, assertType, expectedValue);
|
|
329
382
|
case 'Header':
|
|
330
|
-
return generateHeaderAssertion(description, assertType, assertion.headerName, expectedValue);
|
|
383
|
+
return generateHeaderAssertion(description, assertType, assertion.headerName, expectedValue, caseSensitive);
|
|
331
384
|
case 'Size':
|
|
332
385
|
return generateSizeAssertion(description, assertTarget, assertType, expectedValue);
|
|
333
386
|
}
|
|
@@ -347,7 +400,7 @@ function generateVariableAssignmentScript(variable) {
|
|
|
347
400
|
return generateSimpleVariableAssignment(variable.variableName, assertTarget);
|
|
348
401
|
}
|
|
349
402
|
}
|
|
350
|
-
function generateJsonBodyAssertion(description, assertType, requiresValues, path, expectedValue) {
|
|
403
|
+
function generateJsonBodyAssertion(description, assertType, requiresValues, path, expectedValue, caseSensitive) {
|
|
351
404
|
if (!(path === null || path === void 0 ? void 0 : path.trim().length) || (requiresValues && !(expectedValue === null || expectedValue === void 0 ? void 0 : expectedValue.length))) {
|
|
352
405
|
return;
|
|
353
406
|
}
|
|
@@ -355,12 +408,10 @@ function generateJsonBodyAssertion(description, assertType, requiresValues, path
|
|
|
355
408
|
if (requiresValues) {
|
|
356
409
|
propertyAccessor = valueToUnquotedString(propertyAccessor);
|
|
357
410
|
}
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
if (requiresValues) {
|
|
361
|
-
test += `(${expectedValue})`;
|
|
411
|
+
if (assertType === newman_types_1.AssertionType.MatchesRegExp) {
|
|
412
|
+
expectedValue = `new RegExp(${expectedValue})`;
|
|
362
413
|
}
|
|
363
|
-
return
|
|
414
|
+
return generatePostmanAssertion(description, propertyAccessor, assertType, expectedValue, caseSensitive);
|
|
364
415
|
}
|
|
365
416
|
function generateJsonBodyVariableAssignment(variableName, path) {
|
|
366
417
|
return generatePostmanVariableAssignment(variableName, getJsonBodyProperty(path));
|
|
@@ -385,34 +436,41 @@ function generateStatusAssertion(description, assertType, expectedValue) {
|
|
|
385
436
|
return;
|
|
386
437
|
}
|
|
387
438
|
let expect;
|
|
388
|
-
let
|
|
439
|
+
let target = 'pm.response.code';
|
|
389
440
|
switch (assertType) {
|
|
390
441
|
case 'Equals':
|
|
391
|
-
expect =
|
|
442
|
+
expect = `pm.response.to.have.status(parseInt(${expectedValue}))`;
|
|
392
443
|
break;
|
|
393
444
|
case 'NotEquals':
|
|
394
|
-
expect =
|
|
445
|
+
expect = `pm.response.to.not.have.status(parseInt(${expectedValue}))`;
|
|
395
446
|
break;
|
|
396
447
|
case 'Contains':
|
|
397
|
-
expect = 'to.include';
|
|
398
|
-
test = `pm.expect(pm.response.code.toString()).${expect}(${expectedValue})`;
|
|
399
|
-
break;
|
|
400
448
|
case 'DoesNotContain':
|
|
401
|
-
|
|
402
|
-
|
|
449
|
+
case 'StartsWith':
|
|
450
|
+
case 'EndsWith':
|
|
451
|
+
target += '.toString()';
|
|
452
|
+
break;
|
|
453
|
+
case 'GreaterThan':
|
|
454
|
+
case 'GreaterThanOrEqualTo':
|
|
455
|
+
case 'LessThan':
|
|
456
|
+
case 'LessThanOrEqualTo':
|
|
457
|
+
expectedValue = `parseInt(${expectedValue})`;
|
|
458
|
+
break;
|
|
459
|
+
case 'MatchesRegExp':
|
|
460
|
+
target += '.toString()';
|
|
461
|
+
expectedValue = `new RegExp(${expectedValue})`;
|
|
403
462
|
break;
|
|
404
463
|
default:
|
|
405
464
|
throw new Error(`Unexpected status assert type: ${assertType}`);
|
|
406
465
|
}
|
|
407
|
-
return generatePostmanTest(description,
|
|
466
|
+
return generatePostmanTest(description, expect !== null && expect !== void 0 ? expect : generatePostmanExpect(target, assertType, expectedValue));
|
|
408
467
|
}
|
|
409
|
-
function generateHeaderAssertion(description, assertType, headerName, expectedValue) {
|
|
468
|
+
function generateHeaderAssertion(description, assertType, headerName, expectedValue, caseSensitive) {
|
|
410
469
|
if (!headerName) {
|
|
411
470
|
return;
|
|
412
471
|
}
|
|
413
472
|
const normalizedHeaderName = JSON.stringify(headerName);
|
|
414
473
|
let test;
|
|
415
|
-
const expect = EXPECT_FUNCTIONS[assertType];
|
|
416
474
|
switch (assertType) {
|
|
417
475
|
case 'Present':
|
|
418
476
|
test = `pm.response.to.have.header(${normalizedHeaderName})`;
|
|
@@ -421,27 +479,39 @@ function generateHeaderAssertion(description, assertType, headerName, expectedVa
|
|
|
421
479
|
test = `pm.response.to.not.have.header(${normalizedHeaderName})`;
|
|
422
480
|
break;
|
|
423
481
|
case 'Equals':
|
|
424
|
-
break;
|
|
425
482
|
case 'NotEquals':
|
|
426
|
-
break;
|
|
427
483
|
case 'Contains':
|
|
428
|
-
break;
|
|
429
484
|
case 'DoesNotContain':
|
|
485
|
+
case 'StartsWith':
|
|
486
|
+
case 'EndsWith':
|
|
430
487
|
break;
|
|
488
|
+
case 'MatchesRegExp':
|
|
489
|
+
expectedValue = `new RegExp(${expectedValue})`;
|
|
490
|
+
break;
|
|
491
|
+
case 'GreaterThan':
|
|
492
|
+
case 'GreaterThanOrEqualTo':
|
|
493
|
+
case 'LessThan':
|
|
494
|
+
case 'LessThanOrEqualTo':
|
|
495
|
+
return;
|
|
431
496
|
default:
|
|
432
497
|
throw new Error(`Unexpected header assert type: ${assertType}`);
|
|
433
498
|
}
|
|
434
|
-
return generatePostmanTest(description, test !== null && test !== void 0 ? test : `pm.
|
|
499
|
+
return generatePostmanTest(description, test !== null && test !== void 0 ? test : generatePostmanExpect(`pm.response.headers.get(${normalizedHeaderName})`, assertType, expectedValue, caseSensitive));
|
|
435
500
|
}
|
|
436
501
|
function generateSizeAssertion(description, target, type, expectedValue) {
|
|
437
502
|
if (!(expectedValue === null || expectedValue === void 0 ? void 0 : expectedValue.length)) {
|
|
438
503
|
return;
|
|
439
504
|
}
|
|
440
|
-
|
|
505
|
+
if (type === newman_types_1.AssertionType.MatchesRegExp) {
|
|
506
|
+
expectedValue = `new RegExp(${expectedValue})`;
|
|
507
|
+
}
|
|
508
|
+
else {
|
|
509
|
+
expectedValue = `parseInt(${expectedValue})`;
|
|
510
|
+
}
|
|
511
|
+
return generateSimpleAssertion(description, target, type, expectedValue);
|
|
441
512
|
}
|
|
442
|
-
function generateSimpleAssertion(description, target, type, expectedValue) {
|
|
443
|
-
|
|
444
|
-
return generatePostmanTest(description, `pm.expect(${getResponseProperty(target)}).to.${expect}(${expectedValue})`);
|
|
513
|
+
function generateSimpleAssertion(description, target, type, expectedValue, caseSensitive = true) {
|
|
514
|
+
return generatePostmanTest(description, generatePostmanExpect(getResponseProperty(target), type, expectedValue, caseSensitive));
|
|
445
515
|
}
|
|
446
516
|
function generateSimpleVariableAssignment(name, target) {
|
|
447
517
|
return generatePostmanVariableAssignment(name, getResponseProperty(target));
|
|
@@ -453,6 +523,40 @@ function getResponseProperty(target) {
|
|
|
453
523
|
}
|
|
454
524
|
return `pm.response.${property}`;
|
|
455
525
|
}
|
|
526
|
+
function generatePostmanAssertion(description, target, assertType, expectedValue, caseSensitive) {
|
|
527
|
+
return generatePostmanTest(description, generatePostmanExpect(target, assertType, expectedValue, caseSensitive));
|
|
528
|
+
}
|
|
529
|
+
function generatePostmanExpect(target, assertType, expectedValue, caseSensitive = true) {
|
|
530
|
+
if (!caseSensitive && assertionTypeSupportsCaseSensitivity(assertType)) {
|
|
531
|
+
target += '?.toUpperCase().toLowerCase()';
|
|
532
|
+
expectedValue = `${expectedValue !== null && expectedValue !== void 0 ? expectedValue : ''}.toUpperCase().toLowerCase()`;
|
|
533
|
+
}
|
|
534
|
+
return `pm.expect(${target}).to.${EXPECT_FUNCTIONS[assertType].replace(new RegExp(EXPECTED_VALUE_TOKEN, 'g'), expectedValue !== null && expectedValue !== void 0 ? expectedValue : '')}`;
|
|
535
|
+
}
|
|
536
|
+
function assertionTargetSupportsCaseSensitivity(assertTarget) {
|
|
537
|
+
switch (assertTarget) {
|
|
538
|
+
case 'Header':
|
|
539
|
+
case 'JSONBody':
|
|
540
|
+
return true;
|
|
541
|
+
default:
|
|
542
|
+
return false;
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
exports.assertionTargetSupportsCaseSensitivity = assertionTargetSupportsCaseSensitivity;
|
|
546
|
+
function assertionTypeSupportsCaseSensitivity(assertionType) {
|
|
547
|
+
switch (assertionType) {
|
|
548
|
+
case 'Contains':
|
|
549
|
+
case 'DoesNotContain':
|
|
550
|
+
case 'StartsWith':
|
|
551
|
+
case 'EndsWith':
|
|
552
|
+
case 'Equals':
|
|
553
|
+
case 'NotEquals':
|
|
554
|
+
return true;
|
|
555
|
+
default:
|
|
556
|
+
return false;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
exports.assertionTypeSupportsCaseSensitivity = assertionTypeSupportsCaseSensitivity;
|
|
456
560
|
function generatePostmanTest(description, test) {
|
|
457
561
|
return `pm.test(${JSON.stringify(description)}, function () { ${test}; });`;
|
|
458
562
|
}
|
|
@@ -12,10 +12,17 @@ var AssertionType;
|
|
|
12
12
|
(function (AssertionType) {
|
|
13
13
|
AssertionType["Contains"] = "Contains";
|
|
14
14
|
AssertionType["DoesNotContain"] = "DoesNotContain";
|
|
15
|
+
AssertionType["EndsWith"] = "EndsWith";
|
|
15
16
|
AssertionType["Equals"] = "Equals";
|
|
17
|
+
AssertionType["GreaterThan"] = "GreaterThan";
|
|
18
|
+
AssertionType["GreaterThanOrEqualTo"] = "GreaterThanOrEqualTo";
|
|
19
|
+
AssertionType["LessThan"] = "LessThan";
|
|
20
|
+
AssertionType["LessThanOrEqualTo"] = "LessThanOrEqualTo";
|
|
21
|
+
AssertionType["MatchesRegExp"] = "MatchesRegExp";
|
|
16
22
|
AssertionType["NotEquals"] = "NotEquals";
|
|
17
23
|
AssertionType["NotPresent"] = "NotPresent";
|
|
18
24
|
AssertionType["Present"] = "Present";
|
|
25
|
+
AssertionType["StartsWith"] = "StartsWith";
|
|
19
26
|
})(AssertionType || (exports.AssertionType = AssertionType = {}));
|
|
20
27
|
exports.SUPPORTED_COLLECTION_SCHEMA = 'https://schema.getpostman.com/json/collection/v2.1.0/collection.json';
|
|
21
28
|
exports.MablSupportedPostmanAuthTypes = [
|
|
@@ -118,9 +118,10 @@ function createAssertFailureMessage(assertFailure) {
|
|
|
118
118
|
exports.createAssertFailureMessage = createAssertFailureMessage;
|
|
119
119
|
function createAssertResultMessage(assertResult) {
|
|
120
120
|
if (assertResult) {
|
|
121
|
-
const { success } = assertResult;
|
|
121
|
+
const { success, assertionCriteria } = assertResult;
|
|
122
122
|
return {
|
|
123
123
|
success,
|
|
124
|
+
assertionCriteria,
|
|
124
125
|
...createAssertFailureMessage(assertResult),
|
|
125
126
|
};
|
|
126
127
|
}
|