mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
test: reorganize fixture files into modality-first layout (phase 6b)
Move all fixture files from flat/mixed dirs (content/, media/, documents/,
formats/, hostile/, root loose) into the modality-first hierarchy:
image/{valid,formats,edge,hostile}, video/{valid,formats,hostile},
audio/{valid,formats,hostile}, document/{valid,formats,edge,hostile},
data/valid/, security/. Update index.ts paths, fixtureDir aliases,
all literal refs in 17 e2e/qa/script files, manifest.json, and the
three generator scripts. 163 files moved, 0 dropped, 100 new tests
from expanded document scan.
This commit is contained in:
Vendored
+21
-10
@@ -1,22 +1,33 @@
|
||||
#!/usr/bin/env node
|
||||
// Stamps sha256 + bytes for the real `content/` heroes into manifest.json.
|
||||
// Provenance (sourceUrl/license) is filled by hand in Step 2 -- this only fills hashes.
|
||||
// Stamps sha256 + bytes for real fixture assets into manifest.json.
|
||||
// Provenance (sourceUrl/license) is filled by hand -- this only fills hashes.
|
||||
import { createHash } from "node:crypto";
|
||||
import { readdirSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { existsSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { dirname, join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const ROOT = dirname(fileURLToPath(import.meta.url));
|
||||
const contentDir = join(ROOT, "content");
|
||||
const existing = JSON.parse(readFileSync(join(ROOT, "manifest.json"), "utf8"));
|
||||
const byPath = new Map(existing.assets.map((a) => [a.path, a]));
|
||||
|
||||
for (const name of readdirSync(contentDir)) {
|
||||
const rel = `content/${name}`;
|
||||
const bytes = readFileSync(join(contentDir, name));
|
||||
const sha256 = createHash("sha256").update(bytes).digest("hex");
|
||||
const prev = byPath.get(rel) ?? { path: rel, sourceUrl: "UNVERIFIED", license: "UNVERIFIED", toolsServed: [] };
|
||||
byPath.set(rel, { ...prev, sha256, bytes: bytes.length });
|
||||
// Scan each modality valid dir (replaces the old content/ scan)
|
||||
const SCAN_DIRS = [
|
||||
"image/valid",
|
||||
"video/valid",
|
||||
"audio/valid",
|
||||
"document/valid",
|
||||
];
|
||||
|
||||
for (const dir of SCAN_DIRS) {
|
||||
const absDir = join(ROOT, dir);
|
||||
if (!existsSync(absDir)) continue;
|
||||
for (const name of readdirSync(absDir)) {
|
||||
const rel = `${dir}/${name}`;
|
||||
const bytes = readFileSync(join(absDir, name));
|
||||
const sha256 = createHash("sha256").update(bytes).digest("hex");
|
||||
const prev = byPath.get(rel) ?? { path: rel, sourceUrl: "UNVERIFIED", license: "UNVERIFIED", toolsServed: [] };
|
||||
byPath.set(rel, { ...prev, sha256, bytes: bytes.length });
|
||||
}
|
||||
}
|
||||
const assets = [...byPath.values()].sort((a, b) => a.path.localeCompare(b.path));
|
||||
writeFileSync(join(ROOT, "manifest.json"), JSON.stringify({ assets }, null, 2));
|
||||
|
||||
Reference in New Issue
Block a user