Skip to content

Commit e58016e

Browse files
authored
chore: suite metadata hostname and device (#244)
1 parent 0f471ae commit e58016e

File tree

8 files changed

+37
-20
lines changed

8 files changed

+37
-20
lines changed

package-lock.json

+9-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "testbeats",
3-
"version": "2.1.1",
3+
"version": "2.1.2",
44
"description": "Publish test results to Microsoft Teams, Google Chat, Slack and InfluxDB",
55
"main": "src/index.js",
66
"types": "./src/index.d.ts",
@@ -55,7 +55,7 @@
5555
"pretty-ms": "^7.0.1",
5656
"rosters": "0.0.1",
5757
"sade": "^1.8.1",
58-
"test-results-parser": "0.2.4"
58+
"test-results-parser": "0.2.5"
5959
},
6060
"devDependencies": {
6161
"c8": "^7.12.0",

src/extensions/error-clusters.extension.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const { BaseExtension } = require('./base.extension');
22
const { STATUS, HOOK } = require("../helpers/constants");
3+
const { truncate } = require('../helpers/helper');
34

45
class ErrorClustersExtension extends BaseExtension {
56

@@ -35,7 +36,7 @@ class ErrorClustersExtension extends BaseExtension {
3536

3637
const texts = [];
3738
for (const cluster of clusters) {
38-
texts.push(`${cluster.failure} - ${this.bold(`(x${cluster.count})`)}`);
39+
texts.push(`${truncate(cluster.failure, 150)} - ${this.bold(`(x${cluster.count})`)}`);
3940
}
4041
this.text = this.mergeTexts(texts);
4142
}

src/helpers/helper.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,15 @@ function processData(data) {
4646
return data;
4747
}
4848

49+
/**
50+
*
51+
* @param {string} text
52+
* @param {number} length
53+
* @returns
54+
*/
4955
function truncate(text, length) {
5056
if (text && text.length > length) {
51-
return text.slice(0, length) + "...";
57+
return text.slice(0, length).trim() + "...";
5258
} else {
5359
return text;
5460
}

src/platforms/base.platform.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,22 @@ class BasePlatform {
103103

104104
const texts = [];
105105

106+
// webdriver io
107+
if (suite.metadata.device && typeof suite.metadata.device === 'string') {
108+
texts.push(`${suite.metadata.device}`);
109+
}
110+
106111
if (suite.metadata.platform && suite.metadata.platform.name && suite.metadata.platform.version) {
107-
texts.push(`${suite.metadata.platform.name} ${suite.metadata.platform.version}`)
112+
texts.push(`${suite.metadata.platform.name} ${suite.metadata.platform.version}`);
108113
}
109114

110115
if (suite.metadata.browser && suite.metadata.browser.name && suite.metadata.browser.version) {
111-
texts.push(`${suite.metadata.browser.name} ${suite.metadata.browser.version}`)
116+
texts.push(`${suite.metadata.browser.name} ${suite.metadata.browser.version}`);
117+
}
118+
119+
// playwright
120+
if (suite.metadata.hostname && typeof suite.metadata.hostname === 'string') {
121+
texts.push(`${suite.metadata.hostname}`);
112122
}
113123

114124
return texts.join(' • ');

test/mocks/chat.mock.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ addInteractionHandler('post test-summary with suite metadata to chat', () => {
605605
"widgets": [
606606
{
607607
"textParagraph": {
608-
"text": "<b>✅ Addition</b><br><br><b>Results</b>: 1 / 1 Passed (100%)<br><b>Duration</b>: 1ms<br><br>Windows 11 • firefox 129.0<br><br><b>✅ Addition</b><br><br><b>Results</b>: 1 / 1 Passed (100%)<br><b>Duration</b>: 1ms<br><br>Windows 11 • chrome 129.0"
608+
"text": "<b>✅ Addition</b><br><br><b>Results</b>: 1 / 1 Passed (100%)<br><b>Duration</b>: 1ms<br><br>Desktop • Windows 11 • firefox 129.0<br><br><b>✅ Addition</b><br><br><b>Results</b>: 1 / 1 Passed (100%)<br><b>Duration</b>: 1ms<br><br>Desktop • Windows 11 • chrome 129.0"
609609
}
610610
}
611611
]

test/mocks/slack.mock.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -853,14 +853,14 @@ addInteractionHandler('post test-summary to slack with suite metadata', () => {
853853
"type": "section",
854854
"text": {
855855
"type": "mrkdwn",
856-
"text": "*✅ Addition*\n\n*Results*: 1 / 1 Passed (100%)\n*Duration*: 1ms\n\nWindows 11 • firefox 129.0"
856+
"text": "*✅ Addition*\n\n*Results*: 1 / 1 Passed (100%)\n*Duration*: 1ms\n\nDesktop • Windows 11 • firefox 129.0"
857857
}
858858
},
859859
{
860860
"type": "section",
861861
"text": {
862862
"type": "mrkdwn",
863-
"text": "*✅ Addition*\n\n*Results*: 1 / 1 Passed (100%)\n*Duration*: 1ms\n\nWindows 11 • chrome 129.0"
863+
"text": "*✅ Addition*\n\n*Results*: 1 / 1 Passed (100%)\n*Duration*: 1ms\n\nDesktop • Windows 11 • chrome 129.0"
864864
}
865865
}
866866
],

test/mocks/teams.mock.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1849,7 +1849,7 @@ addInteractionHandler('post test-summary with suite metadata to teams', () => {
18491849
},
18501850
{
18511851
"type": "TextBlock",
1852-
"text": "Windows 11 • firefox 129.0",
1852+
"text": "Desktop • Windows 11 • firefox 129.0",
18531853
"wrap": true
18541854
},
18551855
{
@@ -1874,7 +1874,7 @@ addInteractionHandler('post test-summary with suite metadata to teams', () => {
18741874
},
18751875
{
18761876
"type": "TextBlock",
1877-
"text": "Windows 11 • chrome 129.0",
1877+
"text": "Desktop • Windows 11 • chrome 129.0",
18781878
"wrap": true
18791879
}
18801880
],

0 commit comments

Comments
 (0)