diff --git a/docs/_partials/specs/version-en.mdx b/docs/_partials/specs/version.mdx similarity index 100% rename from docs/_partials/specs/version-en.mdx rename to docs/_partials/specs/version.mdx diff --git a/docs/commands/browser/restoreState.mdx b/docs/commands/browser/restoreState.mdx index fdcb2cf..2e7f048 100644 --- a/docs/commands/browser/restoreState.mdx +++ b/docs/commands/browser/restoreState.mdx @@ -1,5 +1,5 @@ import Admonition from "@theme/Admonition"; -import Version from "../../_partials/specs/version-en.mdx"; +import Version from "../../_partials/specs/version.mdx"; # restoreState diff --git a/docs/commands/browser/saveState.mdx b/docs/commands/browser/saveState.mdx index d70b70e..6d3116a 100644 --- a/docs/commands/browser/saveState.mdx +++ b/docs/commands/browser/saveState.mdx @@ -1,4 +1,4 @@ -import Version from "../../_partials/specs/version-en.mdx"; +import Version from "../../_partials/specs/version.mdx"; # saveState diff --git a/docs/config/after-all.mdx b/docs/config/after-all.mdx index 9c46ceb..9457ed1 100644 --- a/docs/config/after-all.mdx +++ b/docs/config/after-all.mdx @@ -1,8 +1,8 @@ -import Version from "../_partials/specs/version-en.mdx"; +import Version from "../_partials/specs/version.mdx"; # afterAll - + ## Overview {#overview} diff --git a/docs/config/before-all.mdx b/docs/config/before-all.mdx index 918f579..28065bc 100644 --- a/docs/config/before-all.mdx +++ b/docs/config/before-all.mdx @@ -1,8 +1,8 @@ -import Version from "../_partials/specs/version-en.mdx"; +import Version from "../_partials/specs/version.mdx"; # beforeAll - + ## Overview {#overview} diff --git a/docs/html-reporter/html-reporter-setup.mdx b/docs/html-reporter/html-reporter-setup.mdx index 1591577..2f6e6f9 100644 --- a/docs/html-reporter/html-reporter-setup.mdx +++ b/docs/html-reporter/html-reporter-setup.mdx @@ -1,6 +1,8 @@ +import Version from "../_partials/specs/version.mdx"; + --- -sidebar_position: 2 ---- + +## sidebar_position: 2 import Tabs from "@theme/Tabs"; import TabItem from "@theme/TabItem"; @@ -35,6 +37,7 @@ import ConfigExamples from "/docs/_partials/html-reporter-config-examples.mdx"; [plugins](#plugins)`Plugin[]``[]`A list of plugins with their settings. [customScripts](#customscripts)`AnyFunction[]``[]`A list of functions that implement custom scripts. For example, Yandex.Metrika scripts or a Bug. [yandexMetrika](#yandexmetrika)`YandexMetrika`*see below*[Yandex.Metrika][yandex-metrika]. +[generateBadges](#generatebadges)`GenerateBadges``null`A callback that is called after every test run. It receives the test result and returns a list of badges. @@ -288,6 +291,82 @@ If you don't want to share analytics with us, you can disable it in any of the f - Using environment variables: `html_reporter_yandex_metrika_enabled=false` or simply `NO_ANALYTICS=true` - Using CLI arguments: `--html-reporter-yandex_metrika_enabled=false` +### generateBadges + + + +A callback that is called after every test run. It receives the test result and returns a list of badges. + +Usage example: here we set the issue name and URL, the branch name. + +```typescript title="testplane.config.ts" +{ + // other Testplane config... + plugins: { + "html-reporter/testplane": { + //... + generateBadges: (test) => [ + { + title: test.meta.issueTitle, + icon: 'LogoYandexTracker', + url: test.meta.issueUrl, + }, + { + title: test.meta.branch, + icon: 'BranchesRight', + }, + ] + } + } +} +``` + +An example of a test where you can set metadata. + +```typescript title="testplane.config.ts" +describe("badges", () => { + it("badge example", async ({ browser }) => { + await browser.setMeta("issueTitle", "ticket-1234"); + await browser.setMeta("issueUrl", "https://example.com"); + await browser.setMeta("branch", "master"); + + await browser.pause(3000); + }); +}); +``` + +#### Badge params + + + + + + + + + + + + + + + + + + + + + + + + + + +
**Name****Type****Description**
`title``string` + Optional parameter. Displayed badge title. If not provided, the badge will not + render. +
`icon``string`Optional parameter. Name of icon from [GravityUI][gravity-ui-icons].
`url``string`Optional parameter. Url of badge.
+ ### Passing parameters via the CLI {#setup_by_cli} 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: [how-to-create-counter]: https://yandex.ru/support/metrica/general/creating-counter.html [merge-reports]: ../html-reporter-commands#merge-reports [http-server]: https://github.com/http-party/http-server#http-server-a-simple-static-http-server +[gravity-ui-icons]: https://gravity-ui.com/ru/icons diff --git a/docs/_partials/specs/version-ru.mdx b/i18n/ru/docusaurus-plugin-content-docs/current/_partials/specs/version.mdx similarity index 100% rename from docs/_partials/specs/version-ru.mdx rename to i18n/ru/docusaurus-plugin-content-docs/current/_partials/specs/version.mdx diff --git a/i18n/ru/docusaurus-plugin-content-docs/current/commands/browser/restoreState.mdx b/i18n/ru/docusaurus-plugin-content-docs/current/commands/browser/restoreState.mdx index b2d9080..af37c0f 100644 --- a/i18n/ru/docusaurus-plugin-content-docs/current/commands/browser/restoreState.mdx +++ b/i18n/ru/docusaurus-plugin-content-docs/current/commands/browser/restoreState.mdx @@ -1,5 +1,5 @@ import Admonition from "@theme/Admonition"; -import Version from "../../../../../../docs/_partials/specs/version-ru.mdx"; +import Version from "../../_partials/specs/version.mdx"; # restoreState diff --git a/i18n/ru/docusaurus-plugin-content-docs/current/commands/browser/saveState.mdx b/i18n/ru/docusaurus-plugin-content-docs/current/commands/browser/saveState.mdx index e582791..17ee7f6 100644 --- a/i18n/ru/docusaurus-plugin-content-docs/current/commands/browser/saveState.mdx +++ b/i18n/ru/docusaurus-plugin-content-docs/current/commands/browser/saveState.mdx @@ -1,4 +1,4 @@ -import Version from "../../../../../../docs/_partials/specs/version-ru.mdx"; +import Version from "../../_partials/specs/version.mdx"; # saveState diff --git a/i18n/ru/docusaurus-plugin-content-docs/current/config/after-all.mdx b/i18n/ru/docusaurus-plugin-content-docs/current/config/after-all.mdx index 5f67957..addb975 100644 --- a/i18n/ru/docusaurus-plugin-content-docs/current/config/after-all.mdx +++ b/i18n/ru/docusaurus-plugin-content-docs/current/config/after-all.mdx @@ -1,8 +1,8 @@ -import Version from "../../../../../docs/_partials/specs/version-ru.mdx"; +import Version from "../_partials/specs/version.mdx"; # afterAll - + ## Обзор {#overview} diff --git a/i18n/ru/docusaurus-plugin-content-docs/current/config/before-all.mdx b/i18n/ru/docusaurus-plugin-content-docs/current/config/before-all.mdx index 0993ace..0ca8097 100644 --- a/i18n/ru/docusaurus-plugin-content-docs/current/config/before-all.mdx +++ b/i18n/ru/docusaurus-plugin-content-docs/current/config/before-all.mdx @@ -1,8 +1,8 @@ -import Version from "../../../../../docs/_partials/specs/version-ru.mdx"; +import Version from "../_partials/specs/version.mdx"; # beforeAll - + ## Обзор {#overview} diff --git a/i18n/ru/docusaurus-plugin-content-docs/current/html-reporter/html-reporter-setup.mdx b/i18n/ru/docusaurus-plugin-content-docs/current/html-reporter/html-reporter-setup.mdx index 20ce6b5..9d462dc 100644 --- a/i18n/ru/docusaurus-plugin-content-docs/current/html-reporter/html-reporter-setup.mdx +++ b/i18n/ru/docusaurus-plugin-content-docs/current/html-reporter/html-reporter-setup.mdx @@ -1,6 +1,8 @@ +import Version from "../_partials/specs/version.mdx"; + --- -sidebar_position: 2 ---- + +## sidebar_position: 2 import Admonition from "@theme/Admonition"; import ConfigExamples from "../_partials/html-reporter-config-examples.mdx"; @@ -33,6 +35,7 @@ import ConfigExamples from "../_partials/html-reporter-config-examples.mdx"; [plugins](#plugins)`Plugin[]``[]`Список плагинов с их настройками. [customScripts](#customscripts)`AnyFunction[]``[]`Список функций, реализующих кастомные скрипты. Например, скрипты Яндекс.Метрики или Жучка. [yandexMetrika](#yandexmetrika)`YandexMetrika`*см. ниже*[Яндекс.Метрика][yandex-metrika]. +[generateBadges](#generatebadges)`GenerateBadges``null`Функция, который вызывается после каждого запуска теста. Он получает результат теста и возвращает список бейджей. @@ -286,6 +289,82 @@ customScripts: [ - С помощью переменных окружения: `html_reporter_yandex_metrika_enabled=false` или просто `NO_ANALYTICS=true` - С помощью аргументов CLI: `--html-reporter-yandex_metrika_enabled=false` +### generateBadges + + + +Функция, который вызывается после каждого запуска теста. Он получает результат теста и возвращает список бейджей. + +Пример использования: здесь мы задаём имя задачи со ссылкой на неё и название ветки. + +```typescript title="testplane.config.ts" +{ + // other Testplane config... + plugins: { + "html-reporter/testplane": { + //... + generateBadges: (test) => [ + { + title: test.meta.issueTitle, + icon: 'LogoYandexTracker', + url: test.meta.issueUrl, + }, + { + title: test.meta.branch, + icon: 'BranchesRight', + }, + ] + } + } +} +``` + +Пример установки метаданных в тесте. + +```typescript title="testplane.config.ts" +describe("badges", () => { + it("badge example", async ({ browser }) => { + await browser.setMeta("issueTitle", "ticket-1234"); + await browser.setMeta("issueUrl", "https://example.com"); + await browser.setMeta("branch", "master"); + + await browser.pause(3000); + }); +}); +``` + +#### Badge params + + + + + + + + + + + + + + + + + + + + + + + + + + +
**Имя****Тип****Описание**
`title``string` + Опциональный параметр. Отображаемое имя бейджа, но если не передать то бейдж не + будет показываться. +
`icon``string`Опциональный параметр. Имя иконки из [GravityUI][gravity-ui-icons].
`url``string`Опциональный параметр. Ссылка, открываемая при нажатии.
+ ### Передача параметров через CLI {#setup_by_cli} Все параметры плагина, которые можно определить в конфиге, можно также передать в виде опций командной строки или через переменные окружения во время запуска testplane. Используйте префикс `--html-reporter-` для опций командной строки и `html_reporter_` — для переменных окружения.