Skip to content

Commit 6b4a728

Browse files
docs: static accepter v2 docs
1 parent 6d68803 commit 6b4a728

2 files changed

Lines changed: 72 additions & 8 deletions

File tree

‎docs/html-reporter/static-accepter.mdx‎

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ A typical flow may look as follows:
1919

2020
1. A CI job finishes running tests, generates the html-reporter bundle, and uploads the static report somewhere reviewers can reach it.
2121
2. A reviewer opens that static report, stages the screenshots that should become the new baselines, and presses **Commit**.
22-
3. html-reporter packages the staged screenshots together with repository metadata and sends them to a service that you operate. That service runs persistently (for example on your infrastructure or as a cloud function) and is responsible for updating the pull request with the new baselines.
22+
3. html-reporter sends the staged screenshots through the configured accepter: either the legacy HTTP service that you operate, or a runtime ESM module such as Static Accepter v2.
2323

24-
The static accepter is disabled in GUI mode. To expose it in the static bundle you must configure repository, pull request, and service URLs as shown below.
24+
The static accepter is disabled in GUI mode. To expose it in the static bundle you must configure repository and pull request URLs plus either the legacy service or a v2 module, as shown below.
2525

2626
## Configuration prerequisites
2727

@@ -49,11 +49,43 @@ plugins: {
4949
}
5050
```
5151

52-
- The accepter is ignored unless the `enabled` flag is set and the report is opened in static mode. `repositoryUrl`, `pullRequestUrl`, and `serviceUrl` are mandatory; missing values disable the feature inside the bundle.
52+
- The accepter is ignored unless the `enabled` flag is set and the report is opened in static mode. `repositoryUrl` and `pullRequestUrl` are always mandatory. Configure `serviceUrl` for the legacy HTTP flow or `moduleUrl` for Static Accepter v2; when `moduleUrl` is present, it takes precedence and `serviceUrl` is not required.
5353
- Images collected for committing always reference the stored baseline path. The accepter throws if the underlying tool cannot provide a `refImg.relativePath`, because the service needs the final repository-relative destination for each file.
5454
- `axiosRequestOptions` (optional) are forwarded to the HTTP client used by the report UI so you can tweak timeouts, headers, or authentication parameters required by your service.
5555

56-
## High-level workflow
56+
## Static Accepter v2
57+
58+
Static Accepter v2 delegates downloading, batching, authenticated commit creation, and final Submit/Suggest confirmation to a runtime ESM module. To enable the production client, set `moduleUrl` in the existing configuration block:
59+
60+
```js
61+
plugins: {
62+
'html-reporter/testplane': {
63+
enabled: true,
64+
staticImageAccepter: {
65+
enabled: true,
66+
repositoryUrl: 'https://github.com/org/project',
67+
pullRequestUrl: 'https://github.com/org/project/pull/42',
68+
moduleUrl: 'https://my-static-accepter-service.com/v2/script.js',
69+
}
70+
}
71+
}
72+
```
73+
74+
The module is imported by the report page at runtime and is not included in the html-reporter bundle. Opening the commit dialog starts the import; the final **Commit** button remains disabled until it succeeds. The final click calls the module synchronously so the browser preserves user activation for the static accepter v2 popup.
75+
76+
The popup owns confirmation and all static accepter API requests. html-reporter does not embed an iframe, open the popup itself, send protocol messages, split commits, or call static accepter `/_api/v2/*` endpoints. While the operation is pending, the report shows download/commit/confirmation/submit progress and keeps the staged set unchanged. `submitted` and `suggested` results mark the staged images as committed; cancellation or an error leaves them staged for retry.
77+
78+
Before publishing a report with v2, verify the following browser integration requirements:
79+
80+
- The exact report origin is allowed by static accepter.
81+
- The report CSP permits the `moduleUrl` origin in `script-src` and permits screenshot origins in `connect-src`.
82+
- Screenshot origins return CORS headers that allow the report origin.
83+
- The report does not use `Cross-Origin-Opener-Policy: same-origin`, because static accepter requires `window.opener` for its popup protocol.
84+
- Reviewers are authenticated in static accepter, have access to the pull request, and allow popups for the report origin.
85+
86+
If `moduleUrl` is omitted, html-reporter preserves the legacy HTTP behavior described below.
87+
88+
## Legacy HTTP workflow
5789

5890
1. Reviewers browse the static report, stage the screenshots they want to promote, and open the **Commit** dialog.
5991
2. html-reporter gathers the staged entries, fetches the binary data for each actual image, and builds a `multipart/form-data` payload that includes repository metadata, the chosen commit message, and every image file.

‎i18n/ru/docusaurus-plugin-content-docs/current/html-reporter/static-accepter.mdx‎

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ import Admonition from "@theme/Admonition";
1919

2020
1. CI-прогон завершает тесты, генерирует сборку html-reporter и выкладывает статический отчёт в доступное ревьюерам место.
2121
2. Ревьюер открывает этот отчёт, помечает скриншоты, которые должны стать новыми эталонами, и нажимает **Commit**.
22-
3. html-reporter упаковывает выбранные скриншоты вместе с метаданными репозитория и отправляет их на принадлежащий вам сервис. Этот сервис работает постоянно (например, в вашем кластере или как облачная функция) и обновляет pull request новыми эталонами.
22+
3. html-reporter отправляет выбранные скриншоты через настроенный accepter: либо через принадлежащий вам legacy HTTP-сервис, либо через загружаемый во время выполнения ESM-модуль, например Static Accepter v2.
2323

24-
В режиме GUI эта функция выключена, потому что локальный интерфейс уже умеет принимать скриншоты напрямую. Чтобы элементы UI принятия скриншотов появились в статическом отчёте, необходимо задать URL репозитория, pull request'а и сервиса, как показано ниже.
24+
В режиме GUI эта функция выключена, потому что локальный интерфейс уже умеет принимать скриншоты напрямую. Чтобы элементы UI принятия скриншотов появились в статическом отчёте, необходимо задать URL репозитория и pull request'а, а также legacy-сервиса или модуля v2, как показано ниже.
2525

2626
## Предварительная настройка
2727

@@ -49,11 +49,43 @@ plugins: {
4949
}
5050
```
5151

52-
- Элементы для принятия скриншотов в статическом отчёте не появятся, если не задан `enabled` или отчёт открыт не в статическом режиме. `repositoryUrl`, `pullRequestUrl` и `serviceUrl` обязательны; без них кнопка «Accept» недоступна.
52+
- Элементы для принятия скриншотов в статическом отчёте не появятся, если не задан `enabled` или отчёт открыт не в статическом режиме. `repositoryUrl` и `pullRequestUrl` обязательны всегда. Для legacy HTTP-сценария настройте `serviceUrl`, а для Static Accepter v2 — `moduleUrl`. Если задан `moduleUrl`, он имеет приоритет, а `serviceUrl` не требуется.
5353
- Сохраняемые изображения всегда ссылаются на путь эталона. html-reporter выбросит ошибку, если инструмент не предоставляет `refImg.relativePath`, потому что сервису нужен конечный относительный путь для каждого файла.
5454
- Параметр `axiosRequestOptions` (необязательный) прокидывается в HTTP-клиент интерфейса отчёта — так можно настроить таймауты, заголовки или авторизацию, требуемые вашим сервисом.
5555

56-
## Общая схема работы
56+
## Static Accepter v2
57+
58+
Static Accepter v2 делегирует загружаемому во время выполнения ESM-модулю скачивание изображений, пакетную обработку, аутентификацию, создание коммита и финальное подтверждение Submit/Suggest. Чтобы включить клиент для production-окружения, задайте `moduleUrl` в существующем блоке конфигурации:
59+
60+
```js
61+
plugins: {
62+
'html-reporter/testplane': {
63+
enabled: true,
64+
staticImageAccepter: {
65+
enabled: true,
66+
repositoryUrl: 'https://github.com/org/project',
67+
pullRequestUrl: 'https://github.com/org/project/pull/42',
68+
moduleUrl: 'https://my-static-accepter-service.com/v2/script.js',
69+
}
70+
}
71+
}
72+
```
73+
74+
Страница отчёта импортирует модуль во время выполнения, он не включается в сборку html-reporter. Импорт начинается при открытии диалога коммита, а финальная кнопка **Commit** остаётся выключенной, пока импорт не завершится успешно. По финальному клику модуль вызывается синхронно, чтобы браузер сохранил пользовательскую активацию (user activation), необходимую для всплывающего окна Static Accepter v2.
75+
76+
Всплывающее окно отвечает за подтверждение и все запросы к API Static Accepter. html-reporter не встраивает iframe, не открывает всплывающее окно самостоятельно, не отправляет протокольные сообщения, не разбивает коммиты и не вызывает эндпоинты Static Accepter `/_api/v2/*`. Пока операция выполняется, отчёт показывает прогресс скачивания, создания коммита, подтверждения и отправки, а набор выбранных изображений остаётся неизменным. Результаты `submitted` и `suggested` помечают выбранные изображения как принятые; отмена или ошибка оставляет их выбранными для повторной попытки.
77+
78+
Перед публикацией отчёта с v2 проверьте следующие требования к интеграции с браузером:
79+
80+
- В Static Accepter разрешён точный источник (origin) отчёта.
81+
- CSP отчёта разрешает источник `moduleUrl` в `script-src`, а источники скриншотов — в `connect-src`.
82+
- Серверы скриншотов возвращают CORS-заголовки, разрешающие origin отчёта.
83+
- Для отчёта не задан `Cross-Origin-Opener-Policy: same-origin`, потому что протокол всплывающего окна Static Accepter использует `window.opener`.
84+
- Ревьюеры аутентифицированы в Static Accepter, имеют доступ к pull request'у и разрешили всплывающие окна для origin отчёта.
85+
86+
Если `moduleUrl` не задан, html-reporter сохраняет описанное ниже legacy HTTP-поведение.
87+
88+
## Legacy HTTP-сценарий
5789

5890
1. Ревьюер просматривает статический отчёт, отмечает скриншоты и открывает диалог **Commit**.
5991
2. html-reporter собирает выбранные элементы, загружает бинарные данные каждого «actual»-скриншота и формирует `multipart/form-data`, содержащий метаданные репозитория, сообщение коммита и файлы изображений.

0 commit comments

Comments
 (0)