@mablhq/mabl-cli 2.51.4 → 2.51.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.
|
@@ -69,6 +69,7 @@ const EXPECT_FUNCTIONS = {
|
|
|
69
69
|
EndsWith: `satisfy(value => value.endsWith(${EXPECTED_VALUE_TOKEN}))`,
|
|
70
70
|
MatchesRegExp: `match(${EXPECTED_VALUE_TOKEN})`,
|
|
71
71
|
};
|
|
72
|
+
const MEDIA_TYPE_TOKEN = "[0-9A-Za-z!#$%&'*+.^_`|~-]+";
|
|
72
73
|
function compareStringsCaseInsensitive(a, b) {
|
|
73
74
|
a = a === null || a === void 0 ? void 0 : a.toUpperCase().toLowerCase();
|
|
74
75
|
b = b === null || b === void 0 ? void 0 : b.toUpperCase().toLowerCase();
|
|
@@ -99,17 +100,6 @@ function getAssertionTypesForTarget(target) {
|
|
|
99
100
|
].includes(assertType.value));
|
|
100
101
|
case newman_types_1.AssertionTarget.Header:
|
|
101
102
|
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
103
|
default:
|
|
114
104
|
return exports.ASSERT_TYPES;
|
|
115
105
|
}
|
|
@@ -447,6 +437,27 @@ function generateJsonBodyAssertion(description, assertType, requiresValues, path
|
|
|
447
437
|
if (requiresValues) {
|
|
448
438
|
propertyAccessor = valueToUnquotedString(propertyAccessor);
|
|
449
439
|
}
|
|
440
|
+
switch (assertType) {
|
|
441
|
+
case 'Present':
|
|
442
|
+
case 'NotPresent':
|
|
443
|
+
case 'Equals':
|
|
444
|
+
case 'NotEquals':
|
|
445
|
+
case 'Contains':
|
|
446
|
+
case 'DoesNotContain':
|
|
447
|
+
case 'StartsWith':
|
|
448
|
+
case 'EndsWith':
|
|
449
|
+
case 'MatchesRegExp':
|
|
450
|
+
break;
|
|
451
|
+
case 'GreaterThan':
|
|
452
|
+
case 'GreaterThanOrEqualTo':
|
|
453
|
+
case 'LessThan':
|
|
454
|
+
case 'LessThanOrEqualTo':
|
|
455
|
+
propertyAccessor = `parseFloat(${propertyAccessor})`;
|
|
456
|
+
expectedValue = `parseFloat(${expectedValue})`;
|
|
457
|
+
break;
|
|
458
|
+
default:
|
|
459
|
+
throw new Error(`Unexpected header assert type: ${assertType}`);
|
|
460
|
+
}
|
|
450
461
|
return generatePostmanAssertion(description, propertyAccessor, assertType, expectedValue, caseSensitive);
|
|
451
462
|
}
|
|
452
463
|
function generateJsonBodyVariableAssignment(variableName, path) {
|
|
@@ -504,6 +515,7 @@ function generateHeaderAssertion(description, assertType, headerName, expectedVa
|
|
|
504
515
|
}
|
|
505
516
|
const normalizedHeaderName = JSON.stringify(headerName);
|
|
506
517
|
let test;
|
|
518
|
+
let target = `pm.response.headers.get(${normalizedHeaderName})`;
|
|
507
519
|
switch (assertType) {
|
|
508
520
|
case 'Present':
|
|
509
521
|
test = `pm.response.to.have.header(${normalizedHeaderName})`;
|
|
@@ -523,11 +535,13 @@ function generateHeaderAssertion(description, assertType, headerName, expectedVa
|
|
|
523
535
|
case 'GreaterThanOrEqualTo':
|
|
524
536
|
case 'LessThan':
|
|
525
537
|
case 'LessThanOrEqualTo':
|
|
526
|
-
|
|
538
|
+
target = `parseFloat(${target})`;
|
|
539
|
+
expectedValue = `parseFloat(${expectedValue})`;
|
|
540
|
+
break;
|
|
527
541
|
default:
|
|
528
542
|
throw new Error(`Unexpected header assert type: ${assertType}`);
|
|
529
543
|
}
|
|
530
|
-
return generatePostmanTest(description, test !== null && test !== void 0 ? test : generatePostmanExpect(
|
|
544
|
+
return generatePostmanTest(description, test !== null && test !== void 0 ? test : generatePostmanExpect(target, assertType, expectedValue, caseSensitive));
|
|
531
545
|
}
|
|
532
546
|
function generateSizeAssertion(description, target, type, expectedValue) {
|
|
533
547
|
if (!(expectedValue === null || expectedValue === void 0 ? void 0 : expectedValue.length)) {
|
|
@@ -797,21 +811,23 @@ function isSupportedAuthType(authDefinition) {
|
|
|
797
811
|
}
|
|
798
812
|
exports.isSupportedAuthType = isSupportedAuthType;
|
|
799
813
|
function isJson(contentType) {
|
|
800
|
-
return (
|
|
801
|
-
(contentType.startsWith('application/json') ||
|
|
802
|
-
contentType.startsWith('application/vnd.api+json')));
|
|
814
|
+
return contentTypeMatches(contentType, (ct) => ct.startsWith('application/json'), (ct) => ct.match(new RegExp(`${MEDIA_TYPE_TOKEN}\/${MEDIA_TYPE_TOKEN}\\+json.*`, 'i')));
|
|
803
815
|
}
|
|
804
816
|
exports.isJson = isJson;
|
|
805
817
|
function isXML(contentType) {
|
|
806
|
-
return (
|
|
807
|
-
(contentType.startsWith('application/xml') ||
|
|
808
|
-
contentType.startsWith('text/xml')));
|
|
818
|
+
return contentTypeMatches(contentType, (ct) => ct.startsWith('application/xml'), (ct) => ct.startsWith('text/xml'), (ct) => ct.match(new RegExp(`${MEDIA_TYPE_TOKEN}\/${MEDIA_TYPE_TOKEN}\\+xml.*`, 'i')));
|
|
809
819
|
}
|
|
810
820
|
exports.isXML = isXML;
|
|
811
821
|
function isText(contentType) {
|
|
812
|
-
return
|
|
822
|
+
return contentTypeMatches(contentType, (ct) => ct.startsWith('text/'));
|
|
813
823
|
}
|
|
814
824
|
exports.isText = isText;
|
|
825
|
+
function contentTypeMatches(contentType, ...predicates) {
|
|
826
|
+
if (!contentType) {
|
|
827
|
+
return false;
|
|
828
|
+
}
|
|
829
|
+
return predicates.some((predicate) => predicate(contentType));
|
|
830
|
+
}
|
|
815
831
|
function getFormDataArray(item) {
|
|
816
832
|
var _a, _b, _c;
|
|
817
833
|
if (getRequestMode(item) === 'formdata') {
|