testbeats 2.2.1 → 2.2.2
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "testbeats",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.2",
|
|
4
4
|
"description": "Publish test results to Microsoft Teams, Google Chat, Slack and InfluxDB",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"prompts": "^2.4.2",
|
|
57
57
|
"rosters": "0.0.1",
|
|
58
58
|
"sade": "^1.8.1",
|
|
59
|
-
"test-results-parser": "0.2.
|
|
59
|
+
"test-results-parser": "0.2.6"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"c8": "^10.1.2",
|
|
@@ -99,7 +99,7 @@ class BeatsAttachments {
|
|
|
99
99
|
}
|
|
100
100
|
form.append('file_images', JSON.stringify(file_images));
|
|
101
101
|
await this.api.uploadAttachments(form.getHeaders(), form.getBuffer());
|
|
102
|
-
logger.info(`🏞️
|
|
102
|
+
logger.info(`🏞️ Uploaded ${count} attachments`);
|
|
103
103
|
}
|
|
104
104
|
} catch (error) {
|
|
105
105
|
logger.error(`❌ Unable to upload attachments: ${error.message}`, error);
|
|
@@ -212,7 +212,7 @@ class PublishCommand {
|
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
async #setupExtensions() {
|
|
215
|
-
logger.info('⚙️
|
|
215
|
+
logger.info('⚙️ Setting up extensions...');
|
|
216
216
|
try {
|
|
217
217
|
for (const config of this.configs) {
|
|
218
218
|
const extensions = config.extensions || [];
|
|
@@ -19,7 +19,7 @@ async function getAutomationBuilds(inputs) {
|
|
|
19
19
|
url: `${getBaseUrl(inputs)}/automate/builds.json?limit=100`,
|
|
20
20
|
auth: {
|
|
21
21
|
username: inputs.username,
|
|
22
|
-
password: inputs.
|
|
22
|
+
password: inputs.access_key
|
|
23
23
|
},
|
|
24
24
|
});
|
|
25
25
|
}
|
|
@@ -34,7 +34,7 @@ async function getAutomationBuildSessions(inputs, build_id) {
|
|
|
34
34
|
url: `${getBaseUrl(inputs)}/automate/builds/${build_id}/sessions.json`,
|
|
35
35
|
auth: {
|
|
36
36
|
username: inputs.username,
|
|
37
|
-
password: inputs.
|
|
37
|
+
password: inputs.access_key
|
|
38
38
|
},
|
|
39
39
|
});
|
|
40
40
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -2,7 +2,9 @@ import { PerformanceParseOptions } from 'performance-results-parser';
|
|
|
2
2
|
import PerformanceTestResult from 'performance-results-parser/src/models/PerformanceTestResult';
|
|
3
3
|
import { Schedule, User } from 'rosters';
|
|
4
4
|
import { ParseOptions } from 'test-results-parser';
|
|
5
|
-
|
|
5
|
+
import TestResult from 'test-results-parser/src/models/TestResult';
|
|
6
|
+
|
|
7
|
+
export { TestResult };
|
|
6
8
|
|
|
7
9
|
export interface ITarget {
|
|
8
10
|
name: TargetName;
|
|
@@ -229,7 +231,9 @@ export interface TargetInputs {
|
|
|
229
231
|
metrics?: MetricConfig[];
|
|
230
232
|
}
|
|
231
233
|
|
|
232
|
-
export interface SlackInputs extends TargetInputs {
|
|
234
|
+
export interface SlackInputs extends TargetInputs {
|
|
235
|
+
message_format?: 'blocks' | 'attachments';
|
|
236
|
+
}
|
|
233
237
|
|
|
234
238
|
export interface TeamsInputs extends TargetInputs {
|
|
235
239
|
width?: string;
|
package/src/targets/slack.js
CHANGED
|
@@ -9,7 +9,11 @@ const { getValidMetrics, getMetricValuesText } = require('../helpers/performance
|
|
|
9
9
|
const TestResult = require('test-results-parser/src/models/TestResult');
|
|
10
10
|
const { getPlatform } = require('../platforms');
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
const STATUSES = {
|
|
13
|
+
GOOD: ':white_check_mark:',
|
|
14
|
+
WARNING: ':warning:',
|
|
15
|
+
DANGER: ':x:'
|
|
16
|
+
}
|
|
13
17
|
|
|
14
18
|
const COLORS = {
|
|
15
19
|
GOOD: '#36A64F',
|
|
@@ -78,7 +82,15 @@ function getTitleText(result, target, {allowTitleLink = true} = {}) {
|
|
|
78
82
|
if (allowTitleLink && target.inputs.title_link) {
|
|
79
83
|
text = `<${target.inputs.title_link}|${text}>`;
|
|
80
84
|
}
|
|
81
|
-
|
|
85
|
+
if (target.inputs.message_format === 'blocks') {
|
|
86
|
+
if (result.status !== 'PASS') {
|
|
87
|
+
return `${STATUSES.DANGER} ${text}`;
|
|
88
|
+
} else {
|
|
89
|
+
return `${STATUSES.GOOD} ${text}`;
|
|
90
|
+
}
|
|
91
|
+
} else {
|
|
92
|
+
return text;
|
|
93
|
+
}
|
|
82
94
|
}
|
|
83
95
|
|
|
84
96
|
function getResultText(result) {
|
|
@@ -160,15 +172,25 @@ function getRootPayload({ result, target, payload }) {
|
|
|
160
172
|
color = COLORS.DANGER;
|
|
161
173
|
}
|
|
162
174
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
175
|
+
|
|
176
|
+
const fallback_text = `${getTitleText(result, target, {allowTitleLink: false})}\nResults: ${getResultText(result)}`;
|
|
177
|
+
|
|
178
|
+
if (target.inputs.message_format === 'blocks') {
|
|
179
|
+
return {
|
|
180
|
+
"text": fallback_text,
|
|
181
|
+
"blocks": payload.blocks
|
|
182
|
+
}
|
|
183
|
+
} else {
|
|
184
|
+
return {
|
|
185
|
+
"attachments": [
|
|
186
|
+
{
|
|
187
|
+
"color": color,
|
|
188
|
+
"blocks": payload.blocks,
|
|
189
|
+
"fallback": fallback_text,
|
|
190
|
+
}
|
|
191
|
+
]
|
|
192
|
+
}
|
|
193
|
+
}
|
|
172
194
|
}
|
|
173
195
|
|
|
174
196
|
async function setPerformancePayload({ result, target, payload }) {
|
|
@@ -280,7 +302,7 @@ async function handleErrors({ target, errors }) {
|
|
|
280
302
|
}
|
|
281
303
|
});
|
|
282
304
|
|
|
283
|
-
|
|
305
|
+
let payload = {
|
|
284
306
|
"attachments": [
|
|
285
307
|
{
|
|
286
308
|
"color": COLORS.DANGER,
|
|
@@ -290,6 +312,13 @@ async function handleErrors({ target, errors }) {
|
|
|
290
312
|
]
|
|
291
313
|
};
|
|
292
314
|
|
|
315
|
+
if (target.inputs.message_format === 'blocks') {
|
|
316
|
+
payload = {
|
|
317
|
+
"text": title, // fallback text
|
|
318
|
+
blocks
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
293
322
|
return request.post({
|
|
294
323
|
url: target.inputs.url,
|
|
295
324
|
body: payload
|