chore: establish TechLog migration baseline
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
import { createHash } from "node:crypto";
|
||||
import { existsSync, readFileSync } from "node:fs";
|
||||
import { resolve } from "node:path";
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
const publicDirectory = resolve(process.cwd(), "public");
|
||||
|
||||
const approvedSvgAssets = [
|
||||
{
|
||||
relativePath: "favicon.svg",
|
||||
sha256: "e6d2e59b7b5bbb0342e0fb496dfc262decbfe4426bbb7b047aec8d467d1dc6f7",
|
||||
},
|
||||
{
|
||||
relativePath: "media/fetch-strategy-boundary.svg",
|
||||
sha256: "b07926823ed77fc200f962a1f64a440e130cefa6bed31144b611612af9b02606",
|
||||
},
|
||||
] as const;
|
||||
|
||||
const localEvidenceAssets = {
|
||||
"fetch-strategy-boundary": {
|
||||
src: "/media/fetch-strategy-boundary.svg",
|
||||
width: 1080,
|
||||
height: 420,
|
||||
triggerLabel: "Fetch Join과 Batch Fetch 비교 다이어그램 크게 보기",
|
||||
dialogLabel: "Fetch Join과 Batch Fetch의 페이징 경계 확대",
|
||||
},
|
||||
} as const;
|
||||
|
||||
function getLocalEvidenceAsset(key: string) {
|
||||
const asset = localEvidenceAssets[key as keyof typeof localEvidenceAssets];
|
||||
if (!asset) {
|
||||
throw new Error(`Unknown local evidence asset: ${key}`);
|
||||
}
|
||||
|
||||
return asset;
|
||||
}
|
||||
|
||||
function sha256(filePath: string) {
|
||||
return createHash("sha256").update(readFileSync(filePath)).digest("hex");
|
||||
}
|
||||
|
||||
describe("TechLog migration baseline", () => {
|
||||
it("preserves each approved SVG asset byte-for-byte", () => {
|
||||
for (const asset of approvedSvgAssets) {
|
||||
const assetPath = resolve(publicDirectory, asset.relativePath);
|
||||
|
||||
expect(existsSync(assetPath), asset.relativePath).toBe(true);
|
||||
expect(sha256(assetPath), asset.relativePath).toBe(asset.sha256);
|
||||
}
|
||||
});
|
||||
|
||||
it("resolves the fetch strategy evidence to its published asset contract", () => {
|
||||
expect(getLocalEvidenceAsset("fetch-strategy-boundary")).toEqual({
|
||||
src: "/media/fetch-strategy-boundary.svg",
|
||||
width: 1080,
|
||||
height: 420,
|
||||
triggerLabel: "Fetch Join과 Batch Fetch 비교 다이어그램 크게 보기",
|
||||
dialogLabel: "Fetch Join과 Batch Fetch의 페이징 경계 확대",
|
||||
});
|
||||
|
||||
const evidencePath = resolve(
|
||||
publicDirectory,
|
||||
getLocalEvidenceAsset("fetch-strategy-boundary").src.slice(1),
|
||||
);
|
||||
expect(existsSync(evidencePath)).toBe(true);
|
||||
expect(sha256(evidencePath)).toBe(
|
||||
"b07926823ed77fc200f962a1f64a440e130cefa6bed31144b611612af9b02606",
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user