`~/Desktop/tech-log-frontend` 가 세 번 더 고쳐져 있었다. 소스 열셋이 바뀌고 둘이
새로 생겼다(`markdown-block-editor`, `catalog-property-picker`). 검사 넷도 함께 바뀌었다.
기능이 바뀐 것부터 적는다.
**편집기에서 즉시 미리보기가 빠졌다.** v2 에서 「편집/나란히/미리보기」 모드가 생겼고,
v4 가 그 모드 자체를 없앴다 — 글 쓰는 화면은 하나이고 공개 렌더는 편집기의 두 번째
상태가 아니라는 판단이다. 직전 리뷰의 완료 조건 하나("preview 는 Desktop/Mobile 을
실제로 전환할 수 있다")가 이로써 다시 미적용이 된다. `InstantPreview` 는 파일로 남아
있으나 편집기 어디서도 부르지 않는다.
**본문이 textarea 에서 블록 편집기로 바뀌었다.** 기존 markdown 을 문단·제목·목록·인용·
코드·구분선·raw 로 읽고 같은 `bodyMarkdown` 계약으로 되돌려 쓴다. 읽었다가 그대로 다시
쓰는 왕복이 글을 바꾸면 작성자가 문서를 열어 저장하기만 해도 내용이 상하므로, 이
저장소가 실제로 쓰는 문법(앵커 단 소제목, 이름표 단 코드 울타리, `:::evidence`, 표,
인용, 목록, 구분선)을 하나씩 넣어 왕복을 검사로 고정했다. 빈 줄이 겹친 자리만 한 줄로
접히고 글자는 그대로다 — 그 예외도 검사에 적었다.
Project·Topic 이 검색 가능한 고르개로, 상태가 인라인 알약으로 바뀌었고, 메타데이터는
접히는 속성 면으로 내려갔다.
`useImperativeHandle` 안에서 부르는 `commit` 이 렌더마다 새로 만들어져 lint 가 막았다.
`useCallback` 으로 고정했다 — 바뀌는 것은 `onChange` 하나다.
Node 24 로 게이트 재실행: check:types · lint · test:unit(1829) · test:component(152) ·
test:tech-log(432) 전부 통과.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015c8cBFUaVr7KLVUx6ujz7D
173 lines
7.0 KiB
TypeScript
173 lines
7.0 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 on the single document surface without a preview mode", async () => {
|
|
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>,
|
|
);
|
|
|
|
const decisionStatus = await screen.findByRole("group", { name: "결정 상태" });
|
|
expect(within(decisionStatus).getByRole("button", { name: "ADOPTED" })).toHaveAttribute("aria-pressed", "true");
|
|
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.getByLabelText("현재 문서")).toHaveTextContent("PROJECT_DECISION");
|
|
expect(screen.getByRole("main", { name: "문서 편집" })).toBeVisible();
|
|
expect(screen.queryByRole("button", { name: "나란히" })).not.toBeInTheDocument();
|
|
expect(screen.queryByRole("button", { name: "미리보기" })).not.toBeInTheDocument();
|
|
expect(screen.queryByRole("region", { name: "즉시 미리보기" })).not.toBeInTheDocument();
|
|
});
|
|
});
|