Files
tech-log-frontend/tests/features/tech-log/studio-decision-authoring.test.tsx
T
DongHyeonkaandClaude Opus 5 b9e29369ee fix: UX 리뷰의 남은 항목을 반영한다
주제 탭 (H1 연장). 홈 탭에 주제를 전부 세우고 목록 아래 「다른 주제 N개 보기」
줄을 없앴다. 축이 둘 이상인 주제만 탭이 되던 규칙 때문에 여섯 중 둘만 올라오고
나머지 넷은 비교표를 다 읽어야 만나는 작은 글씨 한 줄로 갔다. 축은 주제가
자라면서 생기는 것이지 기록이 없다는 뜻이 아니다. 축이 없는 주제는 그 주제의
기록을 세우고, 기록이 없으면 그렇다고 분명히 말한다.

탭 하나가 패널 하나를 가리키게 고쳤다. 탭 전부가 같은 패널을 가리키면 고르지
않은 탭이 "내가 저 패널을 연다" 고 말하면서 패널은 다른 탭의 이름을 달게 된다.

H1. `/studio/documents` 와 `/studio/publications` 의 검색·필터·쪽수를 주소에
담는다. 담지 않던 동안 3쪽에서 문서를 열고 뒤로 오면 1쪽이었고 필터도 사라졌다.
공개 `/search` 는 처음부터 담고 있었다.

H4. 문서 종류 이름을 `document-kind-labels.ts` 하나로 모았다. 세 곳에 흩어져
있어서 같은 CASE 가 목록에서는 「검증 기록」, 새 문서에서는 「Case」, 검색에서는
또 다른 이름이었다.

H5. `project.stage` 가 화면에 `DESIGN` 으로 그대로 새어 나왔다. 같은 프로젝트를
Studio 는 「설계」로 불렀다 — 두 화면이 다른 말을 했다.

H6. 값이 없는데 라벨만 그려지던 자리를 막았다. 네 프로젝트 중 셋이 「현재 목표」
라벨만 있고 값이 비어 있었다.

M2. 대시보드의 숫자를 목록으로 가는 길로 만들고, 할 일이 없는 구역은 그리지
않는다. 공개 홈 설정 폼은 작업 목록 한가운데에서 뒤로 옮겼다.

M3. 작업본 목록에 프로젝트 필터와 정렬을 더했다. 공개 `/explore` 는 독자에게
셋을 주는데 61개를 관리하는 작성자에게는 둘뿐이었다.

M4. 게시 기록의 필터 제출 방식을 작업본 목록에 맞췄다 — 셀렉트는 즉시, 검색만
버튼이다.

M5. MOCK 시절 문구("세션이 끝나면 사라집니다")를 지웠다. 실서버에는 작업본이
남는다.

M7. `aria-current="page"` 가 현재 페이지가 아닌 링크에 붙었다. 정확히 일치할
때만 붙게 하고 구역 강조는 따로 계산한다.

M8. 홈의 첫 화면을 비교표로 바꿨다. 다른 데서 얻을 수 없는 유일한 것이 y≈600 에
묻혀 있었다.

`ListDocumentsQuery.kind` 가 손으로 적은 union 이라 개념과 환경 구성이 빠져
있었다 — 그 둘은 작업본 목록에서 걸러 볼 수가 없었다. 계약 타입으로 바꿨다.

M9 는 고치지 않는다. 「문제·결론이 11px 회색」이라는 지적이 지금 빌드에서
재현되지 않는다 — 실측은 17px `rgb(63,66,73)` 이고 본문이 18px 같은 색이다.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PTnWufiY9ATv57egkKKVAV
2026-09-09 17:15:04 +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: /설계 결정/ }));
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");
});
});