Files
miracles_in_motion/scripts/evidence/capture-header-screenshots.mjs
T
defiQUGandCursor 58e8f9fdb9 Complete MIM4U A+ evidence: potrace SVG, SiteHeader, and full-site a11y.
Consolidate header via SiteHeader, regenerate potrace nav lockups, add screenshot matrix and Lighthouse site audit scripts, fix PWA dismiss aria-label, and bump institutional grade to A+ (99/100).

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-15 21:30:20 -07:00

67 lines
2.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env node
/**
* Capture header logo screenshot matrix: viewport × color scheme.
* Usage: node scripts/evidence/capture-header-screenshots.mjs [--url URL] [--out DIR]
*/
import { mkdirSync, writeFileSync } from 'node:fs'
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
import { chromium } from 'playwright'
const __dirname = dirname(fileURLToPath(import.meta.url))
const repoRoot = join(__dirname, '../..')
const args = process.argv.slice(2)
const urlArg = args.find((a) => a.startsWith('--url='))
const outArg = args.find((a) => a.startsWith('--out='))
const url = urlArg ? urlArg.split('=')[1] : process.env.MIM4U_URL || 'https://mim4u.org'
const outDir =
outArg?.split('=')[1] ||
join(repoRoot, 'reports/status/evidence/header-logo-screenshots')
const viewports = [
{ id: 'mobile', width: 390, height: 844 },
{ id: 'tablet', width: 768, height: 1024 },
{ id: 'desktop', width: 1280, height: 800 },
]
mkdirSync(outDir, { recursive: true })
const browser = await chromium.launch({ headless: true })
const manifest = {
capturedAt: new Date().toISOString(),
url,
shots: [],
}
try {
for (const scheme of ['light', 'dark']) {
for (const vp of viewports) {
const context = await browser.newContext({
viewport: { width: vp.width, height: vp.height },
colorScheme: scheme,
})
const page = await context.newPage()
await page.goto(url, { waitUntil: 'networkidle', timeout: 60000 })
await page.evaluate(() => {
localStorage.setItem('cookie-consent', 'accepted')
})
await page.reload({ waitUntil: 'networkidle' })
const nav = page.locator('nav.mim-site-nav').first()
await nav.waitFor({ state: 'visible', timeout: 15000 })
const file = `${vp.id}-${scheme}.png`
const filePath = join(outDir, file)
await nav.screenshot({ path: filePath })
manifest.shots.push({ file, viewport: vp.id, colorScheme: scheme, width: vp.width })
await context.close()
console.log(`Captured ${file}`)
}
}
} finally {
await browser.close()
}
writeFileSync(join(outDir, 'manifest.json'), `${JSON.stringify(manifest, null, 2)}\n`)
console.log(`Manifest: ${join(outDir, 'manifest.json')}`)