// @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(); const paragraphs = container.querySelectorAll("p"); expect(paragraphs).toHaveLength(2); expect(paragraphs[0]).toHaveTextContent("첫 문단."); expect(paragraphs[1]).toHaveTextContent("둘째 문단."); }); it("빈 줄을 여러 개 띄워도 빈 문단을 만들지 않는다", () => { const { container } = render(); expect(container.querySelectorAll("p")).toHaveLength(2); }); it("문단 안의 줄바꿈은 그 자리에 지킨다", () => { const { container } = render(); expect(container.querySelectorAll("p")).toHaveLength(1); expect(container.querySelectorAll("br")).toHaveLength(1); }); it("백틱으로 감싼 조각을 코드로 읽는다", () => { const { container } = render( , ); const codes = [...container.querySelectorAll("code")].map((el) => el.textContent); expect(codes).toEqual(["로그인 상태가 만료되었다", "Access Token"]); // 백틱은 화면에 남지 않아야 한다 — 카드와 검색 결과까지 퍼지던 것이 이 문자다. expect(container.textContent).not.toContain("`"); }); it("백틱 짝이 맞지 않으면 원문을 그대로 둔다", () => { const { container } = render(); expect(container.querySelectorAll("code")).toHaveLength(0); expect(container.textContent).toContain("`"); }); it("빈 문자열이면 아무것도 그리지 않는다", () => { const { container } = render(); 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(["첫째", "둘째"]); }); });