This commit is contained in:
seb
2026-10-08 22:46:52 +02:00
parent ee93f71b27
commit 3cf0e932b2
2 changed files with 10 additions and 4 deletions

View File

@@ -12,8 +12,8 @@
"build": "vite build", "build": "vite build",
"preview": "vite preview", "preview": "vite preview",
"preview:https": "VITE_HTTPS=1 vite preview", "preview:https": "VITE_HTTPS=1 vite preview",
"lint": "eslint .", "rig:collect": "node test/collect.mjs",
"rig:reference": "node test/collect.mjs && node test/capture.mjs --out=test/screenshots/reference", "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" "rig:compare": "node test/capture.mjs --out=test/screenshots/current && node test/compare.mjs --tolerance=0.001"
}, },
"dependencies": { "dependencies": {

View File

@@ -2,7 +2,8 @@
* Collects a deterministic fixture snapshot from the live testing backend. * Collects a deterministic fixture snapshot from the live testing backend.
* *
* Usage: * 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 * 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 * 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; let imageBytes = 0;
for (const hash of hashes) { 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 { try {
const buf = await get(token, `/api/thumb/${hash}`, { binary: true }); 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`; snapshot.images[hash] = `${hash}.avif`;
imageBytes += buf.length; imageBytes += buf.length;
} catch (err) { } catch (err) {