제목 아래 맥락 블록(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
117 lines
4.8 KiB
TypeScript
117 lines
4.8 KiB
TypeScript
// @vitest-environment jsdom
|
|
|
|
import { render } from "@testing-library/react";
|
|
import { MemoryRouter } from "react-router-dom";
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
import { PublicRecordRenderer } from "../../src/features/tech-log/presentation/shared/public-render/public-record-renderer.tsx";
|
|
|
|
import {
|
|
InlineRenderer,
|
|
PlainText,
|
|
} from "../../src/features/tech-log/presentation/shared/public-render/inline-renderer.tsx";
|
|
|
|
/**
|
|
* 작성자가 엔터로 나눠 쓴 글이 한 줄로 이어져 보였다. Markdown 이 한 번의 줄바꿈을 문단 내 공백으로
|
|
* 읽고, 파서가 그 줄바꿈을 텍스트에 남긴 뒤, HTML 이 다시 공백으로 접기 때문이다. 미리보기와 공개
|
|
* 화면이 같은 렌더러를 쓰므로 두 곳 모두에서 그랬다.
|
|
*/
|
|
describe("문단 안의 줄바꿈", () => {
|
|
it("줄바꿈을 <br> 로 그린다", () => {
|
|
const { container } = render(
|
|
<InlineRenderer content={[{ type: "TEXT", text: "첫째 줄\n둘째 줄" }]} />,
|
|
);
|
|
expect(container.querySelectorAll("br")).toHaveLength(1);
|
|
expect(container.textContent).toBe("첫째 줄둘째 줄");
|
|
});
|
|
|
|
it("줄바꿈이 없으면 <br> 를 넣지 않는다", () => {
|
|
const { container } = render(
|
|
<InlineRenderer content={[{ type: "TEXT", text: "한 줄" }]} />,
|
|
);
|
|
expect(container.querySelectorAll("br")).toHaveLength(0);
|
|
expect(container.textContent).toBe("한 줄");
|
|
});
|
|
|
|
it("여러 번 엔터를 친 만큼 내려간다", () => {
|
|
const { container } = render(
|
|
<InlineRenderer content={[{ type: "TEXT", text: "가\n나\n다" }]} />,
|
|
);
|
|
expect(container.querySelectorAll("br")).toHaveLength(2);
|
|
});
|
|
});
|
|
|
|
/**
|
|
* 요약·문제·결론·환경은 Markdown 을 거치지 않고 그대로 그려진다. 본문만 고쳤을 때 이 칸들이
|
|
* 여전히 이어져 보인 이유이고, 작성자가 "아직 안 고쳐졌다" 고 본 것도 이쪽이다.
|
|
*/
|
|
describe("Markdown 을 거치지 않는 평문 칸", () => {
|
|
it("작성자가 나눠 쓴 줄을 지킨다", () => {
|
|
const { container } = render(<PlainText text={"문제 첫 줄\n문제 둘째 줄"} />);
|
|
expect(container.querySelectorAll("br")).toHaveLength(1);
|
|
});
|
|
|
|
it("한 줄이면 <br> 를 넣지 않는다", () => {
|
|
const { container } = render(<PlainText text="한 줄" />);
|
|
expect(container.querySelectorAll("br")).toHaveLength(0);
|
|
});
|
|
});
|
|
|
|
/**
|
|
* 문서 머리말의 요약. 상한이 2000자가 되면서 요약은 한 문장이 아니라 여러 문단이 되었고,
|
|
* 예전에는 빈 줄까지 <br> 로 나가 문단 사이 여백이 없었다.
|
|
*
|
|
* <p>이 가드는 한동안 엉뚱한 것을 지키고 있었다 — `PublicDocumentHeader` 라는 컴포넌트를 세웠는데
|
|
* 화면을 실제로 그리는 것은 `PublicRecordRenderer` 였고, 그 컴포넌트는 아무도 부르지 않는 죽은
|
|
* 코드였다. 지금은 진짜로 그려지는 쪽을 본다.
|
|
*/
|
|
describe("문서 머리말의 요약", () => {
|
|
const model = {
|
|
kind: "QUESTION",
|
|
slug: "session-store-boundary",
|
|
title: "세션 저장소 경계",
|
|
summary: "Mediator와 BFF는 서로 다른 저장소를 쓴다.\n둘 다 메모리에 있다.\n\n인스턴스를 늘리면 설계가 필요하다.",
|
|
publicPath: "/questions/session-store-boundary",
|
|
topic: { label: "인증", publicPath: "/explore?topic=auth" },
|
|
project: { label: "Keycloak", publicPath: "/projects/keycloak" },
|
|
relations: [],
|
|
renderContext: { generatedAt: "2026-08-31T00:00:00Z", dependencyRevision: "r1" },
|
|
status: "OPEN",
|
|
facts: [],
|
|
assumptions: [],
|
|
unknowns: [],
|
|
constraints: [],
|
|
options: [],
|
|
nextValidation: "",
|
|
resolution: null,
|
|
} as never;
|
|
|
|
it("빈 줄은 문단으로, 문단 안 줄바꿈은 줄바꿈으로 그린다", () => {
|
|
const { container } = render(
|
|
<MemoryRouter>
|
|
<PublicRecordRenderer
|
|
model={model}
|
|
resolvePublishedLabel={() => undefined}
|
|
resolveEvidenceAsset={() => {
|
|
throw new Error("이 문서에는 도식이 없다");
|
|
}}
|
|
/>
|
|
</MemoryRouter>,
|
|
);
|
|
/*
|
|
머리말에는 요약 말고도 종류를 적은 한 줄(`.section-kicker`)이 있다. 이 가드가 보는 것은
|
|
요약이 문단으로 나뉘는가이므로 그 줄은 빼고 센다 — 예전처럼 머리말의 `<p>` 를 전부 세면
|
|
머리말에 줄이 하나 늘 때마다 요약과 상관없이 깨진다.
|
|
*/
|
|
const paragraphs = container.querySelectorAll(
|
|
".public-document-header p:not(.section-kicker)",
|
|
);
|
|
expect(paragraphs).toHaveLength(2);
|
|
expect(
|
|
container.querySelectorAll(".public-document-header p:not(.section-kicker) br"),
|
|
).toHaveLength(1);
|
|
expect(paragraphs[0]).toHaveTextContent("둘 다 메모리에 있다.");
|
|
expect(paragraphs[1]).toHaveTextContent("인스턴스를 늘리면 설계가 필요하다.");
|
|
});
|
|
});
|