Skip to content

Commit

Permalink
added title suffix support
Browse files Browse the repository at this point in the history
  • Loading branch information
ASaiAnudeep committed Dec 1, 2021
1 parent f8fc0db commit 38078bb
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 3 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,27 @@ To use environment variables in the config file, wrap the environment variable n

![teams-summary-report](https://github.com/test-results-reporter/reporter/raw/main/assets/slack/test-summary-single-suite.png)

### Options

#### reports

| Property | Description | Attribute |
|----------|------------------------------------|-----------|
| targets | list of targets to publish reports | Required |
| results | list of results to parse | Required |
| options | common options for all targets | Optional |

##### targets

| Property | Description | Attribute |
|--------------|--------------------------------|-------------------|
| name | name of the target | Required/Optional |
| url | url of the target | Required/Optional |
| publish | type of report to publish | Required/Optional |
| links | links to be part of the report | Optional |
| title | title of the report | Optional |
| title_suffix | suffix to add to title | Optional |

## Supports

### Targets
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "test-results-reporter",
"version": "0.0.11",
"version": "0.0.12",
"description": "Publish test results to Microsoft Teams and Slack",
"main": "src/index.js",
"bin": {
Expand Down
3 changes: 3 additions & 0 deletions src/targets/slack.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ function getRootPayload() {

function getTitleText(result, options) {
const title = options.title ? options.title : result.name;
if (options.title_suffix) {
return `*${title} ${options.title_suffix}*`;
}
return `*${title}*`;
}

Expand Down
10 changes: 9 additions & 1 deletion src/targets/teams.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@ const request = require('phin-retry');
const { toColonNotation } = require('colon-notation');
const { getPercentage, getReportType, getUrl, truncate } = require('../helpers/helper');

function getTitleText(result, options) {
const title = options.title ? options.title : result.name;
if (options.title_suffix) {
return `${title} ${options.title_suffix}`;
}
return `${title}`;
}

function getTitleTextBlock(testResult, opts) {
const title = opts.title ? opts.title : testResult.name;
const title = getTitleText(testResult, opts);
const emoji = testResult.status === 'PASS' ? '✅' : '❌';
return {
"type": "TextBlock",
Expand Down

0 comments on commit 38078bb

Please sign in to comment.