testit-js-commons 3.6.1 → 3.7.0-TMS-5.6
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.
|
@@ -52,12 +52,20 @@ class BaseConverter {
|
|
|
52
52
|
description: step.description,
|
|
53
53
|
parameters: step.parameters,
|
|
54
54
|
attachments: step.attachments,
|
|
55
|
-
outcome: step.outcome ?
|
|
55
|
+
outcome: step.outcome ? step.outcome : undefined,
|
|
56
56
|
stepResults: (_a = step.steps) === null || _a === void 0 ? void 0 : _a.map((step) => this.toOriginStep(step)),
|
|
57
57
|
};
|
|
58
58
|
if (step.duration !== undefined) {
|
|
59
59
|
model.duration = step.duration;
|
|
60
60
|
}
|
|
61
|
+
if (step.startedOn !== undefined) {
|
|
62
|
+
// @ts-ignore
|
|
63
|
+
model.startedOn = step.startedOn;
|
|
64
|
+
}
|
|
65
|
+
if (step.completedOn !== undefined) {
|
|
66
|
+
// @ts-ignore
|
|
67
|
+
model.completedOn = step.completedOn;
|
|
68
|
+
}
|
|
61
69
|
return model;
|
|
62
70
|
}
|
|
63
71
|
}
|
|
@@ -6,6 +6,7 @@ exports.escapeHtmlInObjectArray = escapeHtmlInObjectArray;
|
|
|
6
6
|
const NO_ESCAPE_HTML_ENV_VAR = 'NO_ESCAPE_HTML';
|
|
7
7
|
// Regex pattern to detect HTML tags
|
|
8
8
|
const HTML_TAG_PATTERN = /<\S.*?(?:>|\/>)/;
|
|
9
|
+
const NO_ESCAPE_KEYS = new Set(['externalId', 'autoTestExternalId']);
|
|
9
10
|
// Regex patterns to escape only non-escaped characters
|
|
10
11
|
const LESS_THAN_PATTERN = /</;
|
|
11
12
|
const GREATER_THAN_PATTERN = />/;
|
|
@@ -85,6 +86,9 @@ function processProperties(obj) {
|
|
|
85
86
|
try {
|
|
86
87
|
const value = obj[key];
|
|
87
88
|
if (typeof value === 'string') {
|
|
89
|
+
if (NO_ESCAPE_KEYS.has(key)) {
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
88
92
|
// Escape string properties
|
|
89
93
|
obj[key] = escapeHtmlTags(value);
|
|
90
94
|
}
|
|
@@ -9,17 +9,17 @@ describe('HtmlEscapeUtils', () => {
|
|
|
9
9
|
describe('escapeHtmlTags', () => {
|
|
10
10
|
it('should escape < and > characters', () => {
|
|
11
11
|
const input = 'Hello <script>alert("XSS")</script> world';
|
|
12
|
-
const expected = 'Hello
|
|
12
|
+
const expected = 'Hello <script>alert("XSS")</script> world';
|
|
13
13
|
expect((0, html_escape_util_1.escapeHtmlTags)(input)).toBe(expected);
|
|
14
14
|
});
|
|
15
15
|
it('should not escape already escaped characters', () => {
|
|
16
16
|
const input = 'Already \\<escaped\\> tags';
|
|
17
|
-
const expected = 'Already
|
|
17
|
+
const expected = 'Already \\<escaped\\> tags';
|
|
18
18
|
expect((0, html_escape_util_1.escapeHtmlTags)(input)).toBe(expected);
|
|
19
19
|
});
|
|
20
20
|
it('should handle mixed escaped and unescaped characters', () => {
|
|
21
21
|
const input = 'Mixed \\<escaped\\> and <unescaped> tags';
|
|
22
|
-
const expected = 'Mixed
|
|
22
|
+
const expected = 'Mixed \\<escaped\\> and <unescaped> tags';
|
|
23
23
|
expect((0, html_escape_util_1.escapeHtmlTags)(input)).toBe(expected);
|
|
24
24
|
});
|
|
25
25
|
it('should return null for null input', () => {
|
|
@@ -45,17 +45,17 @@ describe('HtmlEscapeUtils', () => {
|
|
|
45
45
|
});
|
|
46
46
|
it('should escape only when HTML tags are present', () => {
|
|
47
47
|
const input = 'Price < $100 and <script>alert("test")</script>';
|
|
48
|
-
const expected = 'Price
|
|
48
|
+
const expected = 'Price < $100 and <script>alert("test")</script>';
|
|
49
49
|
expect((0, html_escape_util_1.escapeHtmlTags)(input)).toBe(expected);
|
|
50
50
|
});
|
|
51
51
|
it('should detect self-closing tags', () => {
|
|
52
52
|
const input = 'Image: <img src="test.jpg"/> and text';
|
|
53
|
-
const expected = 'Image:
|
|
53
|
+
const expected = 'Image: <img src="test.jpg"/> and text';
|
|
54
54
|
expect((0, html_escape_util_1.escapeHtmlTags)(input)).toBe(expected);
|
|
55
55
|
});
|
|
56
56
|
it('should detect tags with attributes', () => {
|
|
57
57
|
const input = 'Link: <a href="http://example.com">click here</a>';
|
|
58
|
-
const expected = 'Link:
|
|
58
|
+
const expected = 'Link: <a href="http://example.com">click here</a>';
|
|
59
59
|
expect((0, html_escape_util_1.escapeHtmlTags)(input)).toBe(expected);
|
|
60
60
|
});
|
|
61
61
|
it('should not process malformed tags without proper structure', () => {
|
|
@@ -71,10 +71,21 @@ describe('HtmlEscapeUtils', () => {
|
|
|
71
71
|
count: 123
|
|
72
72
|
};
|
|
73
73
|
const result = (0, html_escape_util_1.escapeHtmlInObject)(input);
|
|
74
|
-
expect(result.name).toBe('Test
|
|
75
|
-
expect(result.description).toBe('Description with
|
|
74
|
+
expect(result.name).toBe('Test <script>');
|
|
75
|
+
expect(result.description).toBe('Description with <tags>');
|
|
76
76
|
expect(result.count).toBe(123);
|
|
77
77
|
});
|
|
78
|
+
it('should not escape externalId and autoTestExternalId', () => {
|
|
79
|
+
const input = {
|
|
80
|
+
externalId: '<test>',
|
|
81
|
+
autoTestExternalId: '<auto>',
|
|
82
|
+
name: 'Name <b>bold</b>',
|
|
83
|
+
};
|
|
84
|
+
const result = (0, html_escape_util_1.escapeHtmlInObject)(input);
|
|
85
|
+
expect(result.externalId).toBe('<test>');
|
|
86
|
+
expect(result.autoTestExternalId).toBe('<auto>');
|
|
87
|
+
expect(result.name).toBe('Name <b>bold</b>');
|
|
88
|
+
});
|
|
78
89
|
it('should handle nested objects', () => {
|
|
79
90
|
const input = {
|
|
80
91
|
title: 'Main <title>',
|
|
@@ -84,8 +95,8 @@ describe('HtmlEscapeUtils', () => {
|
|
|
84
95
|
}
|
|
85
96
|
};
|
|
86
97
|
const result = (0, html_escape_util_1.escapeHtmlInObject)(input);
|
|
87
|
-
expect(result.title).toBe('Main
|
|
88
|
-
expect(result.nested.subtitle).toBe('Sub
|
|
98
|
+
expect(result.title).toBe('Main <title>');
|
|
99
|
+
expect(result.nested.subtitle).toBe('Sub <title>');
|
|
89
100
|
expect(result.nested.value).toBe(42);
|
|
90
101
|
});
|
|
91
102
|
it('should handle arrays of strings', () => {
|
|
@@ -93,7 +104,7 @@ describe('HtmlEscapeUtils', () => {
|
|
|
93
104
|
tags: ['<tag1>', '<tag2>', 'normal']
|
|
94
105
|
};
|
|
95
106
|
const result = (0, html_escape_util_1.escapeHtmlInObject)(input);
|
|
96
|
-
expect(result.tags).toEqual(['
|
|
107
|
+
expect(result.tags).toEqual(['<tag1>', '<tag2>', 'normal']);
|
|
97
108
|
});
|
|
98
109
|
it('should handle arrays of objects', () => {
|
|
99
110
|
const input = {
|
|
@@ -103,8 +114,8 @@ describe('HtmlEscapeUtils', () => {
|
|
|
103
114
|
]
|
|
104
115
|
};
|
|
105
116
|
const result = (0, html_escape_util_1.escapeHtmlInObject)(input);
|
|
106
|
-
expect(result.items[0].name).toBe('
|
|
107
|
-
expect(result.items[1].name).toBe('
|
|
117
|
+
expect(result.items[0].name).toBe('<item1>');
|
|
118
|
+
expect(result.items[1].name).toBe('<item2>');
|
|
108
119
|
});
|
|
109
120
|
it('should handle null and undefined values', () => {
|
|
110
121
|
const input = {
|
|
@@ -115,7 +126,7 @@ describe('HtmlEscapeUtils', () => {
|
|
|
115
126
|
const result = (0, html_escape_util_1.escapeHtmlInObject)(input);
|
|
116
127
|
expect(result.nullValue).toBeNull();
|
|
117
128
|
expect(result.undefinedValue).toBeUndefined();
|
|
118
|
-
expect(result.text).toBe('
|
|
129
|
+
expect(result.text).toBe('<script>');
|
|
119
130
|
});
|
|
120
131
|
it('should return null for null input', () => {
|
|
121
132
|
expect((0, html_escape_util_1.escapeHtmlInObject)(null)).toBeNull();
|
|
@@ -136,7 +147,7 @@ describe('HtmlEscapeUtils', () => {
|
|
|
136
147
|
name: 'Test <script>'
|
|
137
148
|
};
|
|
138
149
|
const result = (0, html_escape_util_1.escapeHtmlInObject)(input);
|
|
139
|
-
expect(result.name).toBe('Test
|
|
150
|
+
expect(result.name).toBe('Test <script>');
|
|
140
151
|
});
|
|
141
152
|
it('should handle simple types without modification', () => {
|
|
142
153
|
expect((0, html_escape_util_1.escapeHtmlInObject)('simple string')).toBe('simple string');
|
|
@@ -152,9 +163,9 @@ describe('HtmlEscapeUtils', () => {
|
|
|
152
163
|
{ name: '<item2>', value: 2 }
|
|
153
164
|
];
|
|
154
165
|
const result = (0, html_escape_util_1.escapeHtmlInObjectArray)(input);
|
|
155
|
-
expect(result === null || result === void 0 ? void 0 : result[0].name).toBe('
|
|
166
|
+
expect(result === null || result === void 0 ? void 0 : result[0].name).toBe('<item1>');
|
|
156
167
|
expect(result === null || result === void 0 ? void 0 : result[0].value).toBe(1);
|
|
157
|
-
expect(result === null || result === void 0 ? void 0 : result[1].name).toBe('
|
|
168
|
+
expect(result === null || result === void 0 ? void 0 : result[1].name).toBe('<item2>');
|
|
158
169
|
expect(result === null || result === void 0 ? void 0 : result[1].value).toBe(2);
|
|
159
170
|
});
|
|
160
171
|
it('should return null for null input', () => {
|
|
@@ -190,10 +201,10 @@ describe('HtmlEscapeUtils', () => {
|
|
|
190
201
|
}
|
|
191
202
|
];
|
|
192
203
|
const result = (0, html_escape_util_1.escapeHtmlInObjectArray)(input);
|
|
193
|
-
expect(result === null || result === void 0 ? void 0 : result[0].title).toBe('
|
|
194
|
-
expect(result === null || result === void 0 ? void 0 : result[0].items).toEqual(['
|
|
195
|
-
expect(result === null || result === void 0 ? void 0 : result[0].nested.subtitle).toBe('
|
|
196
|
-
expect(result === null || result === void 0 ? void 0 : result[0].nested.data[0].field).toBe('
|
|
204
|
+
expect(result === null || result === void 0 ? void 0 : result[0].title).toBe('<Title>');
|
|
205
|
+
expect(result === null || result === void 0 ? void 0 : result[0].items).toEqual(['<tag1>', '<tag2>']);
|
|
206
|
+
expect(result === null || result === void 0 ? void 0 : result[0].nested.subtitle).toBe('<Subtitle>');
|
|
207
|
+
expect(result === null || result === void 0 ? void 0 : result[0].nested.data[0].field).toBe('<Field>');
|
|
197
208
|
});
|
|
198
209
|
});
|
|
199
210
|
describe('Edge cases and error handling', () => {
|
|
@@ -217,7 +228,7 @@ describe('HtmlEscapeUtils', () => {
|
|
|
217
228
|
name: '<test>'
|
|
218
229
|
};
|
|
219
230
|
const result = (0, html_escape_util_1.escapeHtmlInObject)(maliciousObj);
|
|
220
|
-
expect(result.name).toBe('
|
|
231
|
+
expect(result.name).toBe('<test>');
|
|
221
232
|
});
|
|
222
233
|
it('should handle mixed content with and without HTML tags', () => {
|
|
223
234
|
const mixedContent = {
|
|
@@ -227,7 +238,7 @@ describe('HtmlEscapeUtils', () => {
|
|
|
227
238
|
};
|
|
228
239
|
const result = (0, html_escape_util_1.escapeHtmlInObject)(mixedContent);
|
|
229
240
|
expect(result.safeText).toBe('Price: 10 < 20'); // No escaping
|
|
230
|
-
expect(result.htmlContent).toBe('Click
|
|
241
|
+
expect(result.htmlContent).toBe('Click <button>here</button>'); // Escaped
|
|
231
242
|
expect(result.mathExpression).toBe('Result: x > 5'); // No escaping
|
|
232
243
|
});
|
|
233
244
|
});
|
|
@@ -82,21 +82,23 @@ class AutotestsService extends common_1.BaseService {
|
|
|
82
82
|
}
|
|
83
83
|
loadAutotest(autotest, status) {
|
|
84
84
|
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
var _a, _b;
|
|
85
86
|
const originAutotest = yield this.getAutotestByExternalId(autotest.externalId);
|
|
86
87
|
if (!originAutotest) {
|
|
87
88
|
yield this.createAutotest(autotest);
|
|
88
89
|
return;
|
|
89
90
|
}
|
|
91
|
+
const mergedAutotest = Object.assign(Object.assign({}, autotest), { namespace: (_a = autotest.namespace) !== null && _a !== void 0 ? _a : originAutotest.namespace, classname: (_b = autotest.classname) !== null && _b !== void 0 ? _b : originAutotest.classname });
|
|
90
92
|
switch (status) {
|
|
91
93
|
case autotests_type_1.Status.PASSED:
|
|
92
|
-
yield this.updateAutotest(
|
|
94
|
+
yield this.updateAutotest(mergedAutotest);
|
|
93
95
|
return;
|
|
94
96
|
case autotests_type_1.Status.FAILED:
|
|
95
|
-
yield this.updateAutotestFromFailed(originAutotest,
|
|
97
|
+
yield this.updateAutotestFromFailed(originAutotest, mergedAutotest);
|
|
96
98
|
return;
|
|
97
99
|
case autotests_type_1.Status.SKIPPED:
|
|
98
100
|
if (originAutotest.name != undefined && originAutotest.externalId != undefined) {
|
|
99
|
-
yield this.updateAutotestFromFailed(originAutotest,
|
|
101
|
+
yield this.updateAutotestFromFailed(originAutotest, mergedAutotest);
|
|
100
102
|
return;
|
|
101
103
|
}
|
|
102
104
|
console.log(`Cannot update skipped autotest ${autotest.name} without name or externalId`);
|
|
@@ -116,7 +116,7 @@ class TestRunsService extends common_1.BaseService {
|
|
|
116
116
|
return __awaiter(this, void 0, void 0, function* () {
|
|
117
117
|
try {
|
|
118
118
|
const testRun = yield this.getTestRun(testRunId);
|
|
119
|
-
if (testRun.stateName
|
|
119
|
+
if (testRun.stateName === "NotStarted") {
|
|
120
120
|
yield this._client.startTestRun(testRunId);
|
|
121
121
|
}
|
|
122
122
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "testit-js-commons",
|
|
3
|
-
"version": "3.6
|
|
3
|
+
"version": "3.7.0-TMS-5.6",
|
|
4
4
|
"description": "JavaScript commons for Test IT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"dotenv": "^16.0.3",
|
|
40
|
-
"testit-api-client": "7.1.0"
|
|
40
|
+
"testit-api-client": "7.1.0-TMS-5.6"
|
|
41
41
|
},
|
|
42
42
|
"files": [
|
|
43
43
|
"lib"
|