Skip to content

Commit df78971

Browse files
authored
feat(html-reporter): test badges
1 parent 477d620 commit df78971

File tree

12 files changed

+175
-16
lines changed

12 files changed

+175
-16
lines changed
File renamed without changes.

docs/commands/browser/restoreState.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Admonition from "@theme/Admonition";
2-
import Version from "../../_partials/specs/version-en.mdx";
2+
import Version from "../../_partials/specs/version.mdx";
33

44
# restoreState
55

docs/commands/browser/saveState.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Version from "../../_partials/specs/version-en.mdx";
1+
import Version from "../../_partials/specs/version.mdx";
22

33
# saveState
44

docs/config/after-all.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import Version from "../_partials/specs/version-en.mdx";
1+
import Version from "../_partials/specs/version.mdx";
22

33
# afterAll
44

5-
<Version version="8.33.0" />
5+
<Version version="8.31.7" />
66

77
## Overview {#overview}
88

docs/config/before-all.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import Version from "../_partials/specs/version-en.mdx";
1+
import Version from "../_partials/specs/version.mdx";
22

33
# beforeAll
44

5-
<Version version="8.33.0" />
5+
<Version version="8.31.7" />
66

77
## Overview {#overview}
88

docs/html-reporter/html-reporter-setup.mdx

Lines changed: 82 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import Version from "../_partials/specs/version.mdx";
2+
13
---
2-
sidebar_position: 2
3-
---
4+
5+
## sidebar_position: 2
46

57
import Tabs from "@theme/Tabs";
68
import TabItem from "@theme/TabItem";
@@ -35,6 +37,7 @@ import ConfigExamples from "/docs/_partials/html-reporter-config-examples.mdx";
3537
<tr><td>[plugins](#plugins)</td><td>`Plugin[]`</td><td>`[]`</td><td>A list of plugins with their settings.</td></tr>
3638
<tr><td>[customScripts](#customscripts)</td><td>`AnyFunction[]`</td><td>`[]`</td><td>A list of functions that implement custom scripts. For example, Yandex.Metrika scripts or a Bug.</td></tr>
3739
<tr><td>[yandexMetrika](#yandexmetrika)</td><td>`YandexMetrika`</td><td>*see below*</td><td>[Yandex.Metrika][yandex-metrika].</td></tr>
40+
<tr><td>[generateBadges](#generatebadges)</td><td>`GenerateBadges`</td><td>`null`</td><td>A callback that is called after every test run. It receives the test result and returns a list of badges.</td></tr>
3841

3942
</tbody>
4043
</table>
@@ -288,6 +291,82 @@ If you don't want to share analytics with us, you can disable it in any of the f
288291
- Using environment variables: `html_reporter_yandex_metrika_enabled=false` or simply `NO_ANALYTICS=true`
289292
- Using CLI arguments: `--html-reporter-yandex_metrika_enabled=false`
290293

294+
### generateBadges
295+
296+
<Version version="11.4.0" />
297+
298+
A callback that is called after every test run. It receives the test result and returns a list of badges.
299+
300+
Usage example: here we set the issue name and URL, the branch name.
301+
302+
```typescript title="testplane.config.ts"
303+
{
304+
// other Testplane config...
305+
plugins: {
306+
"html-reporter/testplane": {
307+
//...
308+
generateBadges: (test) => [
309+
{
310+
title: test.meta.issueTitle,
311+
icon: 'LogoYandexTracker',
312+
url: test.meta.issueUrl,
313+
},
314+
{
315+
title: test.meta.branch,
316+
icon: 'BranchesRight',
317+
},
318+
]
319+
}
320+
}
321+
}
322+
```
323+
324+
An example of a test where you can set metadata.
325+
326+
```typescript title="testplane.config.ts"
327+
describe("badges", () => {
328+
it("badge example", async ({ browser }) => {
329+
await browser.setMeta("issueTitle", "ticket-1234");
330+
await browser.setMeta("issueUrl", "https://example.com");
331+
await browser.setMeta("branch", "master");
332+
333+
await browser.pause(3000);
334+
});
335+
});
336+
```
337+
338+
#### Badge params
339+
340+
<table>
341+
<thead>
342+
<tr>
343+
<td>**Name**</td>
344+
<td>**Type**</td>
345+
<td>**Description**</td>
346+
</tr>
347+
</thead>
348+
<tbody>
349+
<tr>
350+
<td>`title`</td>
351+
<td>`string`</td>
352+
<td>
353+
Optional parameter. Displayed badge title. If not provided, the badge will not
354+
render.
355+
</td>
356+
</tr>
357+
<tr>
358+
<td>`icon`</td>
359+
<td>`string`</td>
360+
<td>Optional parameter. Name of icon from [GravityUI][gravity-ui-icons].</td>
361+
</tr>
362+
<tr>
363+
<td>`url`</td>
364+
<td>`string`</td>
365+
<td>Optional parameter. Url of badge.</td>
366+
</tr>
367+
</tbody>
368+
</table>
369+
291370
### Passing parameters via the CLI {#setup_by_cli}
292371

293372
All plugin parameters that can be defined in the config can also be passed as command line options or through environment variables during Testplane startup. Use the prefix `--html-reporter-` for command line options and `html_reporter_` for environment variables.
@@ -328,3 +407,4 @@ Files that are created during the execution of tests:
328407
[how-to-create-counter]: https://yandex.ru/support/metrica/general/creating-counter.html
329408
[merge-reports]: ../html-reporter-commands#merge-reports
330409
[http-server]: https://github.com/http-party/http-server#http-server-a-simple-static-http-server
410+
[gravity-ui-icons]: https://gravity-ui.com/ru/icons
File renamed without changes.

i18n/ru/docusaurus-plugin-content-docs/current/commands/browser/restoreState.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Admonition from "@theme/Admonition";
2-
import Version from "../../../../../../docs/_partials/specs/version-ru.mdx";
2+
import Version from "../../_partials/specs/version.mdx";
33

44
# restoreState
55

i18n/ru/docusaurus-plugin-content-docs/current/commands/browser/saveState.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Version from "../../../../../../docs/_partials/specs/version-ru.mdx";
1+
import Version from "../../_partials/specs/version.mdx";
22

33
# saveState
44

i18n/ru/docusaurus-plugin-content-docs/current/config/after-all.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import Version from "../../../../../docs/_partials/specs/version-ru.mdx";
1+
import Version from "../_partials/specs/version.mdx";
22

33
# afterAll
44

5-
<Version version="8.33.0" />
5+
<Version version="8.31.7" />
66

77
## Обзор {#overview}
88

0 commit comments

Comments
 (0)