test: align generators with modality-first layout and prevent hero clobbering (phase 7)

- Remove media-30s.mp4 and media-30s.wav from gen-synthetic-content.mjs
  (these are committed real heroes, not synthetics to regenerate)
- Add skip-if-exists guards to all generators to prevent manifest hash
  breakage from encoder-version differences
- Add --force flag to gen-synthetic-content.mjs for deliberate overwrite
- Fix generate-test-fixtures.mjs to skip encrypted.pdf if it exists
  (qpdf AES encryption uses random IVs, non-deterministic)
- Fill provenance for 14 newly-scanned manifest entries after Phase 6b moves
- Verify all three generators produce expected output against new layout
This commit is contained in:
SnapOtter
2026-06-20 06:10:30 +08:00
parent 941ed27912
commit f100ba1b71
6 changed files with 198 additions and 64 deletions
+20 -14
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env node
import { spawnSync } from "node:child_process";
import { mkdirSync, writeFileSync } from "node:fs";
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
/**
* Generates the tiny media/document fixtures committed under tests/fixtures/.
* Requires ffmpeg on PATH (or FFMPEG_PATH) and qpdf (or QPDF_PATH).
@@ -154,20 +154,26 @@ await writeZip(
);
// Encrypted PDF fixture derived from test-3page.pdf via qpdf (AES-256).
const qpdf = whichBin("QPDF_PATH", "qpdf");
if (qpdf) {
const srcPdf = join(root, "tests/fixtures/document/valid/test-3page.pdf");
const encPdf = join(root, "tests/fixtures/document/valid/encrypted.pdf");
const qres = spawnSync(qpdf, [srcPdf, "--encrypt", "test123", "owner123", "256", "--", encPdf], {
stdio: "inherit",
});
if (qres.status !== 0) {
console.error("qpdf encryption failed");
process.exit(1);
}
console.log("encrypted.pdf written");
// Skip if the file already exists -- qpdf encryption uses random IVs, so
// re-running produces different bytes and would break manifest hashes.
const encPdf = join(root, "tests/fixtures/document/valid/encrypted.pdf");
if (existsSync(encPdf)) {
console.log("encrypted.pdf already exists; skipping (qpdf encryption is non-deterministic)");
} else {
console.warn("qpdf not found; skipping encrypted.pdf");
const qpdf = whichBin("QPDF_PATH", "qpdf");
if (qpdf) {
const srcPdf = join(root, "tests/fixtures/document/valid/test-3page.pdf");
const qres = spawnSync(qpdf, [srcPdf, "--encrypt", "test123", "owner123", "256", "--", encPdf], {
stdio: "inherit",
});
if (qres.status !== 0) {
console.error("qpdf encryption failed");
process.exit(1);
}
console.log("encrypted.pdf written");
} else {
console.warn("qpdf not found; skipping encrypted.pdf");
}
}
// tiny.html fixture for html-to-pdf tests.