58 lines
1.9 KiB
TypeScript
58 lines
1.9 KiB
TypeScript
import { createHash } from "node:crypto";
|
|
import { existsSync, readFileSync } from "node:fs";
|
|
import { resolve } from "node:path";
|
|
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
import { getEvidenceAsset } from "../../../src/features/tech-log/adapters/static/evidence-assets.ts";
|
|
|
|
const publicDirectory = resolve(process.cwd(), "public");
|
|
|
|
const approvedSvgAssets = [
|
|
{
|
|
relativePath: "favicon.svg",
|
|
sha256: "e6d2e59b7b5bbb0342e0fb496dfc262decbfe4426bbb7b047aec8d467d1dc6f7",
|
|
},
|
|
{
|
|
relativePath: "media/fetch-strategy-boundary.svg",
|
|
sha256: "b07926823ed77fc200f962a1f64a440e130cefa6bed31144b611612af9b02606",
|
|
},
|
|
] as const;
|
|
|
|
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(getEvidenceAsset("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,
|
|
getEvidenceAsset("fetch-strategy-boundary").src.slice(1),
|
|
);
|
|
expect(existsSync(evidencePath)).toBe(true);
|
|
expect(sha256(evidencePath)).toBe(
|
|
"b07926823ed77fc200f962a1f64a440e130cefa6bed31144b611612af9b02606",
|
|
);
|
|
expect(() => getEvidenceAsset("unknown")).toThrow(
|
|
"Unknown local evidence asset: unknown",
|
|
);
|
|
});
|
|
});
|