Files
tech-log-frontend/tests/features/tech-log/studio-decision-authoring.test.tsx
T
DongHyeonkaandClaude Opus 5 a6413d0301 feat: 문서 종류를 독자의 말로 바꾸고 미해결을 눈에 띄게 한다
이 저장소의 종류 이름은 글을 담아 둔 방식의 이름이었다 — Case, Reference,
Open Question. 독자는 그 말을 배우고 나서야 목록을 읽을 수 있었고, 정작
뜻풀이는 홈 바닥(2,000px 아래)에 있었다. 이름이 하는 일을 말하게 한다:

  Case → 직접 해보니        Reference → 다음에 쓸 기준
  Question → 아직 모르는 것  Concept → 어떻게 동작하나
  Decision → 이렇게 하기로

이름이 스스로 설명하므로 홈 바닥의 뜻풀이 섹션은 종류별 입구로 바꾼다.
그 목록에 손으로 적어 둔 `OpenQuestion` 은 사이트 어디에도 없는 여섯 번째
표기였다. 탐색 필터·Case/개념 breadcrumb·종류별 화면 제목도 각자 이름을
적고 있었다 — 전부 공용 표를 쓰게 한다.

목록의 종류 표시는 다섯이 같은 회색 11px 이라 스캔되지 않았다. 색을 다섯
칠하는 대신 지식의 상태 셋(확인함·정리함·미해결)으로 가르고 미해결만
강조한다. 이 기록에서 가장 정직한 신호인데 가장 안 보였다.

mono 글꼴과 대문자 변환도 걷어낸다 — 이름이 한국어 문구가 되었고, mono 는
한글을 갖지 않아 낱말 사이만 벌어진다.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011nAjrqNHGPNngN4aUbcyvJ
2026-09-01 15:19:47 +09:00

183 lines
7.2 KiB
TypeScript

// @vitest-environment jsdom
import { render, screen, waitFor, within } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import type { ReactNode } from "react";
import { MemoryRouter, useLocation, useNavigate } from "react-router-dom";
import { describe, expect, it } from "vitest";
import { createTechLogFeatureInstalledInput } from "../../../src/features/tech-log/adapters/create-tech-log-feature-input.ts";
import { MOCK_STUDIO_INSTALL_CONTEXT } from "../../helpers/studio-install-context.ts";
import { FIXTURE_IDS } from "../../../src/features/tech-log/adapters/mock/fixtures.ts";
import type { StudioGateway } from "../../../src/features/tech-log/application/ports/studio-gateway.ts";
import type { WorkingCopyInput } from "../../../src/features/tech-log/contracts/studio/contract.ts";
import { DocumentEditorScreen } from "../../../src/features/tech-log/presentation/studio/components/document-editor-screen.tsx";
import { NewDocumentForm } from "../../../src/features/tech-log/presentation/studio/components/new-document-form.tsx";
import { StudioProvider } from "../../../src/features/tech-log/presentation/studio/studio-provider.tsx";
import { createManagementGatewayStub } from "../../helpers/management-gateway-stub.ts";
type DecisionInput = Extract<WorkingCopyInput, { kind: "PROJECT_DECISION" }>;
function decisionInput(): DecisionInput {
return {
kind: "PROJECT_DECISION",
title: "목록 페이징과 컬렉션 로딩을 분리합니다",
slug: "feed-pagination-boundary",
summary: "부모 페이지를 먼저 고정하고 연관 컬렉션을 별도로 조회합니다.",
topicId: FIXTURE_IDS.topicJpa,
projectId: FIXTURE_IDS.projectBackend,
relations: [
{
id: null,
targetId: FIXTURE_IDS.fetchJoinCase,
reason: "판단 근거",
order: 0,
},
],
decisionStatus: "ADOPTED",
decidedOn: "2026-08-11",
statement: "목록 조회와 컬렉션 로딩을 서로 다른 단계로 수행합니다.",
rationale: "Fetch Join이 DB LIMIT를 제거하는 문제를 피합니다.",
consequences: [
{
id: "99999999-9999-4999-8999-999999999991",
text: "목록 조회는 한 번의 SQL로 끝나지 않습니다.",
order: 0,
},
],
};
}
function RouterStudioProvider({
gateway,
children,
}: Readonly<{ gateway: StudioGateway; children: ReactNode }>) {
const navigate = useNavigate();
return (
<StudioProvider
createManagementGateway={createManagementGatewayStub}
createGateway={() => gateway}
navigate={(href) => { void navigate(href); }}
>
{children}
</StudioProvider>
);
}
function LocationProbe() {
return <output aria-label="현재 경로">{useLocation().pathname}</output>;
}
describe("TechLog Studio project decision authoring", () => {
it("creates Decision as the fourth working-copy type", async () => {
const user = userEvent.setup();
const gateway = createTechLogFeatureInstalledInput(MOCK_STUDIO_INSTALL_CONTEXT).input.createStudioGateway();
render(
<MemoryRouter initialEntries={["/studio/documents/new"]}>
<RouterStudioProvider gateway={gateway}>
<NewDocumentForm />
<LocationProbe />
</RouterStudioProvider>
</MemoryRouter>,
);
await user.click(screen.getByRole("radio", { name: /Decision/ }));
await user.click(screen.getByRole("button", { name: "작업본 만들기" }));
await waitFor(() => {
expect(screen.getByLabelText("현재 경로")).toHaveTextContent(
/^\/studio\/documents\/[0-9a-f-]+\/edit$/,
);
});
expect((await gateway.listDocuments({ kind: "PROJECT_DECISION" })).items)
.toHaveLength(1);
});
it("validates, previews, and publishes a project-scoped Decision", async () => {
const gateway = createTechLogFeatureInstalledInput(MOCK_STUDIO_INSTALL_CONTEXT).input.createStudioGateway();
const document = await gateway.createDocument(decisionInput(), {
idempotencyKey: "create-project-decision",
});
const validation = await gateway.validateDocument(
document.id,
{ expectedVersion: document.version },
{ idempotencyKey: "validate-project-decision" },
);
expect(validation).toMatchObject({ status: "VALID", issues: [] });
const preview = await gateway.createPreview(
document.id,
{
expectedVersion: document.version,
validationId: validation.validationId,
},
{ idempotencyKey: "preview-project-decision" },
);
expect(preview.renderModel).toMatchObject({
kind: "PROJECT_DECISION",
status: "ADOPTED",
publicPath: "/projects/backend-skeleton/decisions#feed-pagination-boundary",
});
const published = await gateway.publishDocument(
document.id,
{
expectedVersion: document.version,
validationId: validation.validationId,
previewId: preview.previewId,
acknowledgedWarningCodes: [],
},
{ idempotencyKey: "publish-project-decision" },
);
expect(published.publication.publicPath).toBe(
"/projects/backend-skeleton/decisions#feed-pagination-boundary",
);
});
it("edits Decision fields and renders the project decision card preview", async () => {
const user = userEvent.setup();
const gateway = createTechLogFeatureInstalledInput(MOCK_STUDIO_INSTALL_CONTEXT).input.createStudioGateway();
const document = await gateway.createDocument(decisionInput(), {
idempotencyKey: "edit-project-decision",
});
render(
<MemoryRouter initialEntries={[`/studio/documents/${document.id}/edit`]}>
<StudioProvider
createManagementGateway={createManagementGatewayStub} createGateway={() => gateway}>
<DocumentEditorScreen documentId={document.id} />
</StudioProvider>
</MemoryRouter>,
);
expect(await screen.findByLabelText("결정 상태")).toHaveValue("ADOPTED");
expect(screen.getByLabelText("결정일")).toHaveValue("2026-08-11");
expect(screen.getByLabelText("결정문")).toHaveValue(
"목록 조회와 컬렉션 로딩을 서로 다른 단계로 수행합니다.",
);
expect(screen.getByLabelText("판단 이유")).toHaveValue(
"Fetch Join이 DB LIMIT를 제거하는 문제를 피합니다.",
);
expect(screen.getByLabelText("영향 1")).toHaveValue(
"목록 조회는 한 번의 SQL로 끝나지 않습니다.",
);
expect(screen.getByLabelText("근거 1 대상")).toHaveValue(
FIXTURE_IDS.fetchJoinCase,
);
expect(screen.getByRole("complementary", { name: "작업 상태" }))
.toHaveTextContent("종류이렇게 하기로");
const preview = screen.getByRole("region", { name: "즉시 미리보기" });
expect(
within(preview).getByRole("heading", {
name: "목록 페이징과 컬렉션 로딩을 분리합니다",
}),
).toBeVisible();
expect(within(preview).getByText("판단 이유")).toBeVisible();
expect(within(preview).getByText("영향")).toBeVisible();
expect(within(preview).getByText("근거 기록")).toBeVisible();
expect(within(preview).getByRole("link", {
name: "컬렉션 Fetch Join과 페이징은 왜 충돌하는가",
})).toHaveAttribute("href", "/cases/collection-fetch-join-pagination");
});
});