diff --git a/package.json b/package.json index 4d43bf6..0713222 100644 --- a/package.json +++ b/package.json @@ -12,8 +12,8 @@ "build": "vite build", "preview": "vite preview", "preview:https": "VITE_HTTPS=1 vite preview", - "lint": "eslint .", - "rig:reference": "node test/collect.mjs && node test/capture.mjs --out=test/screenshots/reference", + "rig:collect": "node test/collect.mjs", + "rig:reference": "node test/capture.mjs --out=test/screenshots/reference", "rig:compare": "node test/capture.mjs --out=test/screenshots/current && node test/compare.mjs --tolerance=0.001" }, "dependencies": { diff --git a/test/collect.mjs b/test/collect.mjs index 0bdb414..bf958c8 100644 --- a/test/collect.mjs +++ b/test/collect.mjs @@ -2,7 +2,8 @@ * Collects a deterministic fixture snapshot from the live testing backend. * * Usage: - * npm run rig:reference (runs collect first, then captures) + * npm run rig:collect (collects snapshot fixtures from live backend) + * npm run rig:reference (captures reference screenshots) * * Reads ../dashback/.env for GOOGLE_CLIENT_ID (stored as googleClientId in the * snapshot) and mints a JWT for user id 1 with the backend's own env + signing @@ -235,9 +236,14 @@ async function main() { let imageBytes = 0; for (const hash of hashes) { + const dest = path.join(IMAGE_DIR, `${hash}.avif`); + if (fs.existsSync(dest) && fs.statSync(dest).size > 0) { + snapshot.images[hash] = `${hash}.avif`; + continue; + } try { const buf = await get(token, `/api/thumb/${hash}`, { binary: true }); - fs.writeFileSync(path.join(IMAGE_DIR, `${hash}.avif`), buf); + fs.writeFileSync(dest, buf); snapshot.images[hash] = `${hash}.avif`; imageBytes += buf.length; } catch (err) {