fix: exercise production evidence asset lookup
This commit is contained in:
@@ -4,6 +4,8 @@ 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 = [
|
||||
@@ -17,25 +19,6 @@ const approvedSvgAssets = [
|
||||
},
|
||||
] 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");
|
||||
}
|
||||
@@ -51,7 +34,7 @@ describe("TechLog migration baseline", () => {
|
||||
});
|
||||
|
||||
it("resolves the fetch strategy evidence to its published asset contract", () => {
|
||||
expect(getLocalEvidenceAsset("fetch-strategy-boundary")).toEqual({
|
||||
expect(getEvidenceAsset("fetch-strategy-boundary")).toEqual({
|
||||
src: "/media/fetch-strategy-boundary.svg",
|
||||
width: 1080,
|
||||
height: 420,
|
||||
@@ -61,11 +44,14 @@ describe("TechLog migration baseline", () => {
|
||||
|
||||
const evidencePath = resolve(
|
||||
publicDirectory,
|
||||
getLocalEvidenceAsset("fetch-strategy-boundary").src.slice(1),
|
||||
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",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user