#!/usr/bin/env node // Capture playground screenshots for v1.15.0 documentation. // // v1.15.0: v2 project-surface (renderProjectSurface med screen-tabs + // category-tabs) erstattet av renderProjectView (sidebar med 17 artifacts + // main-area med per-artifact view + import-modal). Skjermbilder oppdatert // til å fange v3-surfaces. // // Output: playground/screenshots/v1.15.0/-.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 // npm install // npx playwright install chromium # ~150MB download, one-time // node run.mjs import { chromium } from 'playwright'; import { fileURLToPath } from 'node:url'; import { dirname, resolve, join } from 'node:path'; 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); 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(/