라벨은 고쳤는데 요약이 여전히 비어 있었다. 값이 경계 세 곳을 지나며 사라진다: 평탄화가 담고(고침), 렌더 모델로 바꿀 때 버리고, 화면 목록으로 넘길 때 또 버렸다. 렌더 모델 계약(ResolvedRelation)에 담을 자리 자체가 없었고 additionalProperties: false 라 실을 수도 없었다. 계약에 summary 를 더하고(required 아님 — 이미 나가 있는 응답을 깨지 않는다) 세 경계를 모두 잇는다. Studio 미리보기도 같은 렌더 모델을 쓰므로 그쪽에서도 같은 요약이 보인다. 가드는 요약이 화면에 그려지는 것과, 그것이 링크 이름에는 들어가지 않는 것을 함께 본다 — 이름에 들어가면 관계 목록을 훑을 때 링크 하나가 문단이 된다. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011nAjrqNHGPNngN4aUbcyvJ
117 lines
5.3 KiB
TypeScript
117 lines
5.3 KiB
TypeScript
// @vitest-environment jsdom
|
|
|
|
import { render } from "@testing-library/react";
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
import { ProseText } from "../../src/features/tech-log/presentation/shared/public-render/prose-text.tsx";
|
|
|
|
/**
|
|
* 산문 칸이 오래 평문으로 나갔다. 빈 줄로 나눈 문단이 문단으로 보이지 않았고, 작성자가 백틱으로
|
|
* 적은 식별자가 백틱째 화면에 나왔다 — 그 원문이 카드와 검색 결과까지 그대로 퍼졌다.
|
|
*/
|
|
describe("산문 칸", () => {
|
|
it("빈 줄로 나눈 문단을 문단으로 그린다", () => {
|
|
const { container } = render(<ProseText text={"첫 문단.\n\n둘째 문단."} />);
|
|
const paragraphs = container.querySelectorAll("p");
|
|
expect(paragraphs).toHaveLength(2);
|
|
expect(paragraphs[0]).toHaveTextContent("첫 문단.");
|
|
expect(paragraphs[1]).toHaveTextContent("둘째 문단.");
|
|
});
|
|
|
|
it("빈 줄을 여러 개 띄워도 빈 문단을 만들지 않는다", () => {
|
|
const { container } = render(<ProseText text={"가.\n\n\n\n나."} />);
|
|
expect(container.querySelectorAll("p")).toHaveLength(2);
|
|
});
|
|
|
|
it("문단 안의 줄바꿈은 그 자리에 지킨다", () => {
|
|
const { container } = render(<ProseText text={"첫 줄\n둘째 줄"} />);
|
|
expect(container.querySelectorAll("p")).toHaveLength(1);
|
|
expect(container.querySelectorAll("br")).toHaveLength(1);
|
|
});
|
|
|
|
it("백틱으로 감싼 조각을 코드로 읽는다", () => {
|
|
const { container } = render(
|
|
<ProseText text={"`로그인 상태가 만료되었다` 와 `Access Token` 은 다르다"} />,
|
|
);
|
|
const codes = [...container.querySelectorAll("code")].map((el) => el.textContent);
|
|
expect(codes).toEqual(["로그인 상태가 만료되었다", "Access Token"]);
|
|
// 백틱은 화면에 남지 않아야 한다 — 카드와 검색 결과까지 퍼지던 것이 이 문자다.
|
|
expect(container.textContent).not.toContain("`");
|
|
});
|
|
|
|
it("백틱 짝이 맞지 않으면 원문을 그대로 둔다", () => {
|
|
const { container } = render(<ProseText text={"백틱 하나 ` 만 있다"} />);
|
|
expect(container.querySelectorAll("code")).toHaveLength(0);
|
|
expect(container.textContent).toContain("`");
|
|
});
|
|
|
|
it("빈 문자열이면 아무것도 그리지 않는다", () => {
|
|
const { container } = render(<ProseText text={" \n\n "} />);
|
|
expect(container.querySelectorAll("p")).toHaveLength(0);
|
|
});
|
|
});
|
|
|
|
/**
|
|
* 릴리스 노트의 각 칸은 Markdown 으로 쓰이는데 목록으로만 읽혀서, 소제목과 블록 문법이 항목에
|
|
* 섞여 나왔다. 그 노트의 내용이 하필 "본문의 표·코드·callout·그림이 렌더링됩니다" 였다.
|
|
*/
|
|
describe("릴리스 노트 목록 읽기", () => {
|
|
it("소제목·수평선·블록 울타리를 항목으로 세지 않는다", async () => {
|
|
const { markdownLines } = await import(
|
|
"../../src/features/tech-log/adapters/http/public-content-mapping.ts"
|
|
);
|
|
expect(
|
|
markdownLines("## 작성\n\n- 편집 화면의 버튼을 줄였습니다.\n- 채워야 할 칸을 표시합니다.\n\n---\n\n## 본문 문법\n:::note\n- 표를 지원합니다."),
|
|
).toEqual([
|
|
"편집 화면의 버튼을 줄였습니다.",
|
|
"채워야 할 칸을 표시합니다.",
|
|
"표를 지원합니다.",
|
|
]);
|
|
});
|
|
|
|
it("번호 목록도 항목으로 읽는다", async () => {
|
|
const { markdownLines } = await import(
|
|
"../../src/features/tech-log/adapters/http/public-content-mapping.ts"
|
|
);
|
|
expect(markdownLines("1. 첫째\n2. 둘째")).toEqual(["첫째", "둘째"]);
|
|
});
|
|
});
|
|
|
|
/**
|
|
* 관계 목록의 요약. 계약은 관계마다 요약을 주는데 경계 세 곳(평탄화 → 렌더 모델 → 화면 목록)을
|
|
* 지나며 조용히 사라졌다. 독자가 목록에서 보는 것이 제목뿐이라, 왜 이 기록이 걸려 있는지는
|
|
* 눌러 봐야 알 수 있었다.
|
|
*/
|
|
describe("관계 목록", () => {
|
|
it("대상 요약을 제목 아래 보여 주되 링크 이름에는 넣지 않는다", async () => {
|
|
const { PublicDocumentRelations } = await import(
|
|
"../../src/features/tech-log/presentation/shared/public-render/public-document-relations.tsx"
|
|
);
|
|
const { MemoryRouter: Router } = await import("react-router-dom");
|
|
const { container, getByRole } = render(
|
|
<Router>
|
|
<PublicDocumentRelations
|
|
relations={[
|
|
{
|
|
reason: "이 기준의 근거가 된 기록",
|
|
title: "SPA에서 토큰을 직접 관리하면서 드러난 경계",
|
|
path: "/cases/spa-browser-credential-boundary",
|
|
summary: "SPA가 public OAuth client로 code를 직접 교환한다.",
|
|
},
|
|
]}
|
|
/>
|
|
</Router>,
|
|
);
|
|
expect(container.querySelector(".document-relations li p")).toHaveTextContent(
|
|
"SPA가 public OAuth client로 code를 직접 교환한다.",
|
|
);
|
|
/*
|
|
링크 이름에 요약이 들어가면 관계 목록을 훑을 때 링크 하나하나가 문단이 되어 목록으로서
|
|
쓸모가 없어진다 — 이름은 「관계 이름 + 제목」까지다.
|
|
*/
|
|
const link = getByRole("link", { name: /이 기준의 근거가 된 기록/ });
|
|
expect(link.getAttribute("aria-label")).toBeNull();
|
|
expect(link).not.toHaveAccessibleName(/code를 직접 교환/);
|
|
});
|
|
});
|