fix(web-test): скриншоты падений доезжают до Allure-отчёта

Вложение «Screenshot on failure» весило 0 B у всех красных тестов —
две независимых причины, маскирующие друг друга.

1. slugify сохранял кириллицу в именах артефактов. Allure CLI молча не
   находит вложение с не-ASCII именем: пишет "size": 0 без ссылки на файл
   (JAVA_OPTS с file.encoding/sun.jnu.encoding не помогает). Теперь slugify
   транслитерирует кириллицу и схлопывает остальное не-ASCII в дефис.
   Чинит и видео — оно использовало то же имя.

2. Скриншот 1С-ошибки писался в фиксированный <навык>/error-shot.png:
   вне reportDir (репортер аттачит по basename → мёртвая ссылка) и одним
   именем на весь прогон (каждый следующий тест перетирал предыдущий).
   exec-context получил setErrorShotDir + уникальные имена; раннер
   направляет их в reportDir. Дефолт для интерактивных exec/run не менялся.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Nick Shirokov
2026-07-15 15:36:48 +03:00
parent 3f1168b975
commit 3889c7279f
3 changed files with 64 additions and 12 deletions
+21 -4
View File
@@ -1,4 +1,4 @@
// web-test cli/util v1.2 — generic helpers for CLI commands
// web-test cli/util v1.3 — generic helpers for CLI commands
// Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
export function out(obj) {
@@ -35,12 +35,29 @@ export function elapsed2(start, stop) {
return Math.round(((stop || Date.now()) - start) / 100) / 10;
}
const TRANSLIT = {
а: 'a', б: 'b', в: 'v', г: 'g', д: 'd', е: 'e', ё: 'e', ж: 'zh', з: 'z', и: 'i',
й: 'y', к: 'k', л: 'l', м: 'm', н: 'n', о: 'o', п: 'p', р: 'r', с: 's', т: 't',
у: 'u', ф: 'f', х: 'h', ц: 'ts', ч: 'ch', ш: 'sh', щ: 'sch', ъ: '', ы: 'y', ь: '',
э: 'e', ю: 'yu', я: 'ya',
};
/**
* ASCII-only slug for artifact file names (screenshots, videos).
* Non-ASCII names are unusable as Allure attachments: the Allure CLI silently
* fails to resolve them and emits `"size": 0` with no link to the file
* (JAVA_OPTS encoding flags do not help). Cyrillic is transliterated so the
* name stays readable; anything else non-ASCII collapses to `-`.
*/
export function slugify(s) {
return String(s).trim()
.replace(/[\s/\\:*?"<>|]+/g, '-')
const ascii = String(s).trim().toLowerCase()
.replace(/[а-яё]/g, ch => TRANSLIT[ch] ?? '-');
return ascii
.replace(/[^a-z0-9._-]+/g, '-')
.replace(/-+/g, '-')
.replace(/^-|-$/g, '')
.slice(0, 60) || 'step';
.slice(0, 60)
.replace(/^-|-$/g, '') || 'step';
}
export function formatDuration(seconds) {