fix(screenshots): regenerate screenshots from the current demo, remove older sets

tests/screenshot/run.mjs now clears PNGs a previous run left in its output directory and writes playground/screenshots/MANIFEST.json (output directory, sha256 per PNG, sha256 of the demo state rendered). One run produced the 24 PNGs in playground/screenshots/v1.15.0/ (12 surfaces x 2 themes, including the dark onboarding view removed in 1.18.1).

Removed the v1.10.0, v1.11.0, v1.14.0 and v2-mockup sets (77 PNGs) and tests/screenshot/shoot-mockup.local.mjs. Chose regenerate for the set the runner writes and delete for the rest, because the current runner cannot reproduce the older layouts, and the mockup script reads an HTML file that is not in the repository, so its output could never be regenerated from a clone.

README gallery, docs/playground.md and tests/screenshot/README.md now point at v1.15.0 and describe the 12 surfaces the runner captures. The manifest gate goes green: 4/4.

OCR (Apple Vision, local): 0 of 24 PNGs in the tree carry text from the older demo; known positives from 715950b were found (2 of 2).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kjell Tore Guttormsen 2026-09-23 14:43:42 +02:00
commit 2ed24add12
Signed by: ktg
SSH key fingerprint: SHA256:JakMjO6FTBBzN0Bhfj9saOoEjaFxlSdYuZQQpM/lF9Q
107 changed files with 98 additions and 81 deletions

View file

@ -6,7 +6,10 @@
// main-area med per-artifact view + import-modal). Skjermbilder oppdatert
// til å fange v3-surfaces.
//
// Output: playground/screenshots/v1.15.0/<surface>-<theme>.png
// Output: playground/screenshots/v1.15.0/<surface>-<theme>.png, plus
// playground/screenshots/MANIFEST.json (sha256 per PNG + sha256 of the demo
// state rendered). tests/kb-update/test-screenshots-manifest.test.mjs fails
// when a PNG in the tree is not output of this run or the demo changed since.
//
// Usage:
// cd tests/screenshot
@ -17,7 +20,8 @@
import { chromium } from 'playwright';
import { fileURLToPath } from 'node:url';
import { dirname, resolve, join } from 'node:path';
import { mkdirSync, existsSync } from 'node:fs';
import { mkdirSync, existsSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
import { createHash } from 'node:crypto';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
@ -25,12 +29,35 @@ const PLUGIN_ROOT = resolve(__dirname, '..', '..');
const HTML_PATH = join(PLUGIN_ROOT, 'playground', 'ms-ai-architect-playground.html');
const OUT_DIR = join(PLUGIN_ROOT, 'playground', 'screenshots', 'v1.15.0');
const HTML_URL = 'file://' + HTML_PATH;
const MANIFEST_PATH = join(PLUGIN_ROOT, 'playground', 'screenshots', 'MANIFEST.json');
const VIEWPORT = { width: 1440, height: 900 };
const FULL_PAGE = true;
function ensureOutDir() {
if (!existsSync(OUT_DIR)) mkdirSync(OUT_DIR, { recursive: true });
// The set is exactly one run's output: drop PNGs a previous run left behind.
for (const f of readdirSync(OUT_DIR)) if (f.endsWith('.png')) rmSync(join(OUT_DIR, f));
}
const sha256 = (buf) => createHash('sha256').update(buf).digest('hex');
function writeManifest() {
const html = readFileSync(HTML_PATH, 'utf8');
const demo = html.match(/<script type="application\/json" id="demo-state-v1">([\s\S]*?)<\/script>/);
if (!demo) throw new Error('demo-state-v1 block not found in ' + HTML_PATH);
const files = {};
for (const f of readdirSync(OUT_DIR).filter((n) => n.endsWith('.png')).sort()) {
files[f] = sha256(readFileSync(join(OUT_DIR, f)));
}
const manifest = {
generator: 'tests/screenshot/run.mjs',
dir: 'playground/screenshots/' + OUT_DIR.split('/').pop(),
demoStateSha256: sha256(demo[1]),
files
};
writeFileSync(MANIFEST_PATH, JSON.stringify(manifest, null, 2) + '\n');
console.log(' → MANIFEST.json (' + Object.keys(files).length + ' PNGs)');
}
async function setTheme(page, theme) {
@ -195,6 +222,7 @@ async function main() {
for (const theme of ['dark', 'light']) {
await captureAllSurfaces(page, theme);
}
writeManifest();
console.log('\n[screenshot] done — output: ' + OUT_DIR);
} finally {
await browser.close();