From 4962de1d5cbb5bfeec595973bfc7894776d5ffd8 Mon Sep 17 00:00:00 2001 From: Matysh Date: Sat, 3 Oct 2026 10:03:12 +0300 Subject: [PATCH] fix(ci): parse beta-derived docs CSV lists (#783) Keep repeated --expect-change flags compatible while accepting the comma-separated workflow input and ignoring whitespace, empty values, and duplicates. Issue: #783 User-Visible: no --- scripts/docs-accept.mjs | 12 +++++++----- test/docs-accept.test.mjs | 11 ++++++++++- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/scripts/docs-accept.mjs b/scripts/docs-accept.mjs index 14a0b4eb..1212d221 100644 --- a/scripts/docs-accept.mjs +++ b/scripts/docs-accept.mjs @@ -118,10 +118,11 @@ export function acceptedDocsManifest({ }; } -const list = (argv, name) => argv +export const cliList = (argv, name) => [...new Set(argv .filter((arg) => arg.startsWith(`--${name}=`)) - .map((arg) => arg.slice(name.length + 3)) - .filter(Boolean); + .flatMap((arg) => arg.slice(name.length + 3).split(',')) + .map((value) => value.trim()) + .filter(Boolean))]; /** * Манифест после приёмки «кадры те же попиксельно» (#512): от кандидата — @@ -275,9 +276,10 @@ async function main(argv) { if (existsSync(onDisk)) committed[scenario.id] = sha256(readFileSync(onDisk)); } - const declared = list(argv, 'expect-change'); + const declared = cliList(argv, 'expect-change'); const skipWitnesses = argv.includes('--no-witnesses'); - const skipReason = (list(argv, 'reason')[0] || '').trim(); + const skipReason = (argv.find((arg) => arg.startsWith('--reason=')) + ?.slice('--reason='.length) || '').trim(); const decision = docsAcceptancePlan({ ids, committed, candidate, declared, skipWitnesses, skipReason, }); diff --git a/test/docs-accept.test.mjs b/test/docs-accept.test.mjs index 1aeceb04..877ae431 100644 --- a/test/docs-accept.test.mjs +++ b/test/docs-accept.test.mjs @@ -6,7 +6,7 @@ import { readFileSync } from 'node:fs'; import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from 'node:fs'; import { tmpdir } from 'node:os'; import { join } from 'node:path'; -import { acceptIdentical, acceptedDocsManifest, identicalDecision, identicalDocsManifest, verifyDocsCandidate } from '../scripts/docs-accept.mjs'; +import { acceptIdentical, acceptedDocsManifest, cliList, identicalDecision, identicalDocsManifest, verifyDocsCandidate } from '../scripts/docs-accept.mjs'; import { DOC_SCREENSHOT_VERSION, DOC_SCREENSHOTS } from '../demo/docs/screenshots.mjs'; // Приёмка — единственное место, где картинки попадают в репозиторий, поэтому @@ -19,6 +19,15 @@ const FINGERPRINT = 'f'.repeat(64); const SCRIPT_SHA = 'a'.repeat(64); const bytesOf = (id) => Buffer.from(`картинка ${id}`); +test('beta-derived: docs expect-change accepts CSV and repeated flags', () => { + assert.deepEqual(cliList([ + '--expect-change=view-desktop, view-touch', + '--expect-change=view-desktop', + '--expect-change=', + '--other=ignored', + ], 'expect-change'), ['view-desktop', 'view-touch']); +}); + const candidate = (overrides = {}) => { const scenarios = {}; for (const scenario of DOC_SCREENSHOTS) {