제목 아래 맥락 블록(ContextNavigator)과 난간의 Related 가 같은 것을 두 번 말하고 있었다. 난간 하나만 남기고, 거기에 주제가 정한 사고 순서의 바로 앞·뒤 한 칸을 둔다. 기록 화면은 그 순서를 알아야 하므로 자기 주제의 기록 목록을 함께 받는다. 주제의 사고 순서는 종류마다 한 편이 아니라 전부를 세우고, 관계가 가리키는 프로젝트 결정을 기준 다음 칸에 끼운다. 답이 나온 질문은 흐름에는 남되 「아직 답하지 못한 질문」으로 다시 서지 않는다. 문서 머리말의 빵부스러기는 프로젝트/주제만 남기고 종류는 링크가 아닌 한 줄로 내린다. 홈의 「종류별로 읽기」는 주 내비가 이미 데려가므로 내린다. `tests/component/inline-line-breaks.test.tsx` 는 머리말의 `<p>` 를 전부 세고 있어서 종류 한 줄이 늘자 깨졌다. 요약만 세도록 좁혔다 — 문단 나누기를 망가뜨리면 여전히 실패한다. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cfj8mZ9QmT3MEKonzM5xPj
182 lines
5.7 KiB
TypeScript
182 lines
5.7 KiB
TypeScript
// @vitest-environment jsdom
|
|
|
|
import { render, screen, within } from "@testing-library/react";
|
|
import { MemoryRouter } from "react-router-dom";
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
import type { components } from "../../../src/features/tech-log/contracts/studio/generated.ts";
|
|
import type {
|
|
ResolveEvidenceAsset,
|
|
ResolvePublishedLabel,
|
|
} from "../../../src/features/tech-log/domain/public-render-content.ts";
|
|
import { PublicRecordRenderer } from "../../../src/features/tech-log/presentation/shared/public-render/public-record-renderer.tsx";
|
|
|
|
type RenderModel = components["schemas"]["PublicRenderModel"];
|
|
type RecordKind = RenderModel["kind"];
|
|
|
|
const base = {
|
|
slug: "sample",
|
|
title: "표본 기록",
|
|
summary: "요약",
|
|
topic: { id: "topic-kvm", label: "CPU 가상화", publicPath: "/topics/cpu" },
|
|
project: { id: "project-v", label: "가상화", publicPath: "/projects/gasanghwa" },
|
|
relations: [
|
|
{
|
|
id: "relation-1",
|
|
targetId: "reference-1",
|
|
targetKind: "REFERENCE" as const,
|
|
title: "이어지는 기준",
|
|
publicPath: "/references/linked",
|
|
reason: "이 기록의 결론이 그대로 이 기준이 되었다.",
|
|
order: 1,
|
|
},
|
|
],
|
|
renderContext: { generatedAt: "2030-01-02T00:00:00Z", dependencyRevision: "r1" },
|
|
};
|
|
|
|
/*
|
|
종류마다 하나씩 둔다. `Record<RecordKind, …>` 라 종류가 늘면 컴파일러가 빈 자리를 잡는다 —
|
|
이 저장소에서 손으로 나열한 목록에 새 종류를 빠뜨리는 일이 반복됐고, 맥락 덩어리가 한 종류에서만
|
|
빠지면 그 종류로 들어온 방문자에게만 조용히 사슬이 끊긴다.
|
|
*/
|
|
const MODELS: Record<RecordKind, RenderModel> = {
|
|
CASE: {
|
|
...base,
|
|
kind: "CASE",
|
|
publicPath: "/cases/sample",
|
|
problem: "문제",
|
|
conclusion: "결론",
|
|
environment: "환경",
|
|
reproduction: "데이터셋",
|
|
lastVerifiedOn: "2030-01-02",
|
|
bodyBlocks: [],
|
|
},
|
|
CONCEPT: {
|
|
...base,
|
|
kind: "CONCEPT",
|
|
publicPath: "/concepts/sample",
|
|
basisVersion: "Linux 6.8",
|
|
bodyBlocks: [],
|
|
},
|
|
SETUP: {
|
|
...base,
|
|
kind: "SETUP",
|
|
publicPath: "/setups/sample",
|
|
pinnedVersions: [{ name: "Keycloak", version: "26.7.0" }],
|
|
bodyBlocks: [],
|
|
},
|
|
REFERENCE: {
|
|
...base,
|
|
kind: "REFERENCE",
|
|
publicPath: "/references/sample",
|
|
purpose: "쓰는 이유",
|
|
rules: [{ id: "11111111-1111-4111-8111-111111111111", title: "기준 하나", body: "본문", order: 1 }],
|
|
applyWhen: [{ id: "22222222-2222-4222-8222-222222222222", text: "적용", order: 1 }],
|
|
exceptions: [],
|
|
examples: [],
|
|
verifiedOn: "2030-01-02",
|
|
},
|
|
QUESTION: {
|
|
...base,
|
|
kind: "QUESTION",
|
|
publicPath: "/questions/sample",
|
|
status: "OPEN",
|
|
facts: [],
|
|
assumptions: [],
|
|
unknowns: [],
|
|
constraints: [],
|
|
options: [],
|
|
nextValidation: "다음 검증",
|
|
resolution: null,
|
|
},
|
|
PROJECT_DECISION: {
|
|
...base,
|
|
kind: "PROJECT_DECISION",
|
|
publicPath: "/projects/gasanghwa/decisions#sample",
|
|
status: "ADOPTED",
|
|
decidedOn: "2030-01-02",
|
|
statement: "결정",
|
|
rationale: "이유",
|
|
consequences: [],
|
|
},
|
|
};
|
|
|
|
// 이 검사는 본문을 보지 않는다. 본문이 빈 기록이라 이 둘은 불리지 않는다.
|
|
const dependencies = {
|
|
resolveEvidenceAsset: (key: string) => ({
|
|
src: `/media/${key}`,
|
|
width: 1,
|
|
height: 1,
|
|
triggerLabel: "열기",
|
|
dialogLabel: "그림",
|
|
}),
|
|
resolvePublishedLabel: () => undefined,
|
|
} satisfies {
|
|
resolveEvidenceAsset: ResolveEvidenceAsset;
|
|
resolvePublishedLabel: ResolvePublishedLabel;
|
|
};
|
|
|
|
describe("Record는 위치와 앞뒤 탐색만 보여 준다", () => {
|
|
const navigation = {
|
|
previous: {
|
|
label: "열린 질문",
|
|
title: "앞에서 확인할 질문",
|
|
path: "/questions/previous",
|
|
},
|
|
next: {
|
|
label: "적용 기준",
|
|
title: "다음에 읽을 기준",
|
|
path: "/references/next",
|
|
},
|
|
} as const;
|
|
|
|
for (const kind of ["CASE", "CONCEPT", "SETUP", "REFERENCE", "QUESTION"] as const) {
|
|
it(`${kind} 기록이 Project / Topic / Previous / Current / Next만 rail에 보여 준다`, () => {
|
|
render(
|
|
<MemoryRouter>
|
|
<PublicRecordRenderer
|
|
{...dependencies}
|
|
model={MODELS[kind]}
|
|
navigation={navigation}
|
|
/>
|
|
</MemoryRouter>,
|
|
);
|
|
|
|
// 예전처럼 제목 아래에 별도 Context Path를 다시 그리지 않는다.
|
|
expect(screen.queryByRole("navigation", { name: "이 기록의 맥락" })).toBeNull();
|
|
|
|
const breadcrumb = screen.getByRole("navigation", { name: "문서 경로" });
|
|
expect(breadcrumb).toHaveTextContent("가상화/CPU 가상화");
|
|
|
|
const context = screen.getByRole("navigation", { name: "읽기 맥락" });
|
|
expect(within(context).getByRole("link", { name: "가상화" })).toHaveAttribute(
|
|
"href",
|
|
"/projects/gasanghwa",
|
|
);
|
|
expect(within(context).getByRole("link", { name: "CPU 가상화" })).toHaveAttribute(
|
|
"href",
|
|
"/topics/cpu",
|
|
);
|
|
expect(within(context).getByRole("link", { name: /앞에서 확인할 질문/ })).toHaveAttribute(
|
|
"href",
|
|
"/questions/previous",
|
|
);
|
|
expect(within(context).getByText(/Current/)).toBeInTheDocument();
|
|
expect(within(context).getByRole("link", { name: /다음에 읽을 기준/ })).toHaveAttribute(
|
|
"href",
|
|
"/references/next",
|
|
);
|
|
});
|
|
}
|
|
|
|
it("Project Decision도 본문 위에 별도 Context Path를 만들지 않는다", () => {
|
|
render(
|
|
<MemoryRouter>
|
|
<PublicRecordRenderer {...dependencies} model={MODELS.PROJECT_DECISION} />
|
|
</MemoryRouter>,
|
|
);
|
|
|
|
expect(screen.queryByRole("navigation", { name: "이 기록의 맥락" })).toBeNull();
|
|
});
|
|
});
|