주제 탭 (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
310 lines
12 KiB
TypeScript
310 lines
12 KiB
TypeScript
// @vitest-environment jsdom
|
|
|
|
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
|
|
import userEvent from "@testing-library/user-event";
|
|
import { MemoryRouter } from "react-router-dom";
|
|
import {
|
|
afterAll,
|
|
afterEach,
|
|
beforeAll,
|
|
beforeEach,
|
|
describe,
|
|
expect,
|
|
it,
|
|
vi,
|
|
} 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 { StudioGatewayError } from "../../../src/features/tech-log/application/ports/studio-gateway-error.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 { PublicationEventPreviewScreen } from "../../../src/features/tech-log/presentation/studio/components/publication-event-preview-screen.tsx";
|
|
import { PublicationList } from "../../../src/features/tech-log/presentation/studio/components/publication-list.tsx";
|
|
import { PublishScreen } from "../../../src/features/tech-log/presentation/studio/components/publish-screen.tsx";
|
|
import { StudioProvider } from "../../../src/features/tech-log/presentation/studio/studio-provider.tsx";
|
|
import { createManagementGatewayStub } from "../../helpers/management-gateway-stub.ts";
|
|
|
|
const originalShowModal = HTMLDialogElement.prototype.showModal;
|
|
const originalClose = HTMLDialogElement.prototype.close;
|
|
|
|
class NoopIntersectionObserver implements IntersectionObserver {
|
|
readonly root = null;
|
|
readonly rootMargin = "0px";
|
|
readonly scrollMargin = "0px";
|
|
readonly thresholds = [0];
|
|
|
|
disconnect() {}
|
|
observe() {}
|
|
takeRecords(): IntersectionObserverEntry[] {
|
|
return [];
|
|
}
|
|
unobserve() {}
|
|
}
|
|
|
|
beforeAll(() => {
|
|
vi.stubGlobal("IntersectionObserver", NoopIntersectionObserver);
|
|
});
|
|
|
|
afterAll(() => {
|
|
vi.unstubAllGlobals();
|
|
});
|
|
|
|
beforeEach(() => {
|
|
Object.defineProperty(HTMLDialogElement.prototype, "showModal", {
|
|
configurable: true,
|
|
value(this: HTMLDialogElement) {
|
|
this.setAttribute("open", "");
|
|
},
|
|
});
|
|
Object.defineProperty(HTMLDialogElement.prototype, "close", {
|
|
configurable: true,
|
|
value(this: HTMLDialogElement) {
|
|
this.removeAttribute("open");
|
|
this.dispatchEvent(new Event("close"));
|
|
},
|
|
});
|
|
});
|
|
|
|
afterEach(() => {
|
|
vi.restoreAllMocks();
|
|
Object.defineProperty(HTMLDialogElement.prototype, "showModal", {
|
|
configurable: true,
|
|
value: originalShowModal,
|
|
});
|
|
Object.defineProperty(HTMLDialogElement.prototype, "close", {
|
|
configurable: true,
|
|
value: originalClose,
|
|
});
|
|
});
|
|
|
|
function renderInStudio(
|
|
node: React.ReactNode,
|
|
gateway: StudioGateway = createTechLogFeatureInstalledInput(MOCK_STUDIO_INSTALL_CONTEXT).input.createStudioGateway(),
|
|
navigate: (href: string) => void = () => undefined,
|
|
) {
|
|
return render(
|
|
<MemoryRouter initialEntries={["/studio"]}>
|
|
<StudioProvider
|
|
createManagementGateway={createManagementGatewayStub} createGateway={() => gateway} navigate={navigate}>
|
|
{node}
|
|
</StudioProvider>
|
|
</MemoryRouter>,
|
|
);
|
|
}
|
|
|
|
async function warningReadyDocument(gateway: StudioGateway) {
|
|
const input: WorkingCopyInput = {
|
|
kind: "CASE",
|
|
title: "게시 경고 예시",
|
|
slug: "publish-warning-example",
|
|
summary: "경고 확인 뒤 게시합니다.",
|
|
topicId: FIXTURE_IDS.topicJpa,
|
|
projectId: null,
|
|
relations: [],
|
|
problem: "경고가 있습니다.",
|
|
conclusion: "확인 뒤 게시합니다.",
|
|
environment: "Studio",
|
|
reproduction: "Mock",
|
|
lastVerifiedOn: "2026-08-14",
|
|
bodyMarkdown: "게시할 본문",
|
|
};
|
|
const document = await gateway.createDocument(input, {
|
|
idempotencyKey: "publication-test-create",
|
|
});
|
|
const validation = await gateway.validateDocument(
|
|
document.id,
|
|
{ expectedVersion: 1 },
|
|
{ idempotencyKey: "publication-test-validation" },
|
|
);
|
|
await gateway.createPreview(
|
|
document.id,
|
|
{ expectedVersion: 1, validationId: validation.validationId },
|
|
{ idempotencyKey: "publication-test-preview" },
|
|
);
|
|
return document;
|
|
}
|
|
|
|
function deferred<T>() {
|
|
let resolve!: (value: T) => void;
|
|
let reject!: (reason?: unknown) => void;
|
|
const promise = new Promise<T>((nextResolve, nextReject) => {
|
|
resolve = nextResolve;
|
|
reject = nextReject;
|
|
});
|
|
return { promise, resolve, reject };
|
|
}
|
|
|
|
describe("TechLog Studio publication flow", () => {
|
|
it("blocks invalid and stale saved versions before a publish command can start", async () => {
|
|
const invalid = renderInStudio(
|
|
<PublishScreen documentId={FIXTURE_IDS.edgeTokenQuestion} />,
|
|
);
|
|
expect(await screen.findByText("검증 오류를 먼저 수정해야 합니다")).toBeVisible();
|
|
expect(screen.queryByRole("button", { name: "게시" })).not.toBeInTheDocument();
|
|
invalid.unmount();
|
|
|
|
renderInStudio(<PublishScreen documentId={FIXTURE_IDS.fetchJoinCase} />);
|
|
expect(await screen.findByText("검증 결과가 현재 버전과 다릅니다")).toBeVisible();
|
|
expect(screen.getByRole("link", { name: "다시 검증" })).toHaveAttribute(
|
|
"href",
|
|
`/studio/documents/${FIXTURE_IDS.fetchJoinCase}/validation`,
|
|
);
|
|
});
|
|
|
|
it("publishes a current warning preview only after every warning is acknowledged", async () => {
|
|
const gateway = createTechLogFeatureInstalledInput(MOCK_STUDIO_INSTALL_CONTEXT).input.createStudioGateway();
|
|
const document = await warningReadyDocument(gateway);
|
|
const destinations: string[] = [];
|
|
renderInStudio(
|
|
<PublishScreen documentId={document.id} />,
|
|
gateway,
|
|
(href) => destinations.push(href),
|
|
);
|
|
|
|
const publish = await screen.findByRole("button", { name: "게시" });
|
|
expect(publish).toBeDisabled();
|
|
await userEvent.click(screen.getByRole("checkbox", { name: /PROJECT_MISSING/ }));
|
|
expect(publish).toBeEnabled();
|
|
await userEvent.click(publish);
|
|
|
|
await waitFor(() =>
|
|
expect(destinations[0]).toMatch(
|
|
/^\/studio\/publications\/[0-9a-f-]+\/preview$/,
|
|
),
|
|
);
|
|
expect(screen.getByRole("status", { name: "" })).toHaveTextContent("게시했습니다.");
|
|
expect((await gateway.listPublications({ limit: 100 })).items[0]).toMatchObject({
|
|
event: { type: "PUBLISHED", publishedVersion: 1 },
|
|
publication: { status: "PUBLISHED", publicPath: "/cases/publish-warning-example" },
|
|
});
|
|
});
|
|
|
|
it("keeps the publish pending state, preserves gateway command order, and retries with a new key", async () => {
|
|
const user = userEvent.setup();
|
|
const base = createTechLogFeatureInstalledInput(MOCK_STUDIO_INSTALL_CONTEXT).input.createStudioGateway();
|
|
const document = await warningReadyDocument(base);
|
|
const first = deferred<never>();
|
|
const calls: string[] = [];
|
|
const keys: string[] = [];
|
|
const publishDocument = vi
|
|
.fn<StudioGateway["publishDocument"]>()
|
|
.mockImplementationOnce((_id, _command, options) => {
|
|
calls.push("publishDocument");
|
|
keys.push(options.idempotencyKey);
|
|
return first.promise;
|
|
})
|
|
.mockImplementation((...args) => {
|
|
calls.push("publishDocument");
|
|
keys.push(args[2].idempotencyKey);
|
|
return base.publishDocument(...args);
|
|
});
|
|
const gateway = {
|
|
...base,
|
|
getDocument(...args: Parameters<StudioGateway["getDocument"]>) {
|
|
calls.push("getDocument");
|
|
return base.getDocument(...args);
|
|
},
|
|
getCurrentPreview(...args: Parameters<StudioGateway["getCurrentPreview"]>) {
|
|
calls.push("getCurrentPreview");
|
|
return base.getCurrentPreview(...args);
|
|
},
|
|
publishDocument,
|
|
} satisfies StudioGateway;
|
|
renderInStudio(<PublishScreen documentId={document.id} />, gateway);
|
|
|
|
await user.click(await screen.findByRole("checkbox", { name: /PROJECT_MISSING/ }));
|
|
await user.click(screen.getByRole("button", { name: "게시" }));
|
|
expect(screen.getByRole("button", { name: "게시 중…" })).toBeDisabled();
|
|
expect(calls.slice(0, 3)).toEqual([
|
|
"getDocument",
|
|
"getCurrentPreview",
|
|
"publishDocument",
|
|
]);
|
|
|
|
first.reject(new StudioGatewayError({
|
|
type: "https://techlog.local/problems/studio-unavailable",
|
|
title: "STUDIO_UNAVAILABLE",
|
|
status: 503,
|
|
detail: "Studio가 잠시 응답하지 않습니다.",
|
|
code: "STUDIO_UNAVAILABLE",
|
|
retryable: true,
|
|
}));
|
|
expect(await screen.findByRole("alert")).toHaveTextContent(
|
|
"Studio가 잠시 응답하지 않습니다.",
|
|
);
|
|
await user.click(screen.getByRole("button", { name: "게시" }));
|
|
await waitFor(() => expect(publishDocument).toHaveBeenCalledTimes(2));
|
|
expect(keys[1]).not.toBe(keys[0]);
|
|
});
|
|
|
|
it("filters publication events and recovers a failed history read", async () => {
|
|
const user = userEvent.setup();
|
|
const base = createTechLogFeatureInstalledInput(MOCK_STUDIO_INSTALL_CONTEXT).input.createStudioGateway();
|
|
const listPublications = vi
|
|
.fn<StudioGateway["listPublications"]>()
|
|
.mockRejectedValueOnce(new Error("offline"))
|
|
.mockImplementation((query, options) => base.listPublications(query, options));
|
|
renderInStudio(<PublicationList />, { ...base, listPublications });
|
|
|
|
expect(await screen.findByRole("alert")).toHaveTextContent(
|
|
"게시 기록을 불러오지 못했습니다offline",
|
|
);
|
|
await user.click(screen.getByRole("button", { name: "다시 시도" }));
|
|
expect(await screen.findByRole("heading", { name: "Redis Adapter가 도메인 TTL 정책을 소유하지 않는 이유" })).toBeVisible();
|
|
|
|
/*
|
|
필터 제출 방식이 작업본 목록과 같아졌다 — 셀렉트는 즉시 적용, 검색어만 버튼이다.
|
|
예전에는 이 화면만 둘을 묶어 「적용」을 눌렀고, 작성자는 화면마다 어느 쪽인지 기억해야 했다.
|
|
*/
|
|
await user.selectOptions(screen.getByLabelText("이벤트"), "UNPUBLISHED");
|
|
await user.type(screen.getByLabelText("검색"), "Fetch 전략");
|
|
await user.click(screen.getByRole("button", { name: "검색" }));
|
|
expect(await screen.findByRole("heading", { name: "JPA 목록 조회에서 Fetch 전략을 선택하는 기준" })).toBeVisible();
|
|
expect(screen.queryByRole("heading", { name: "Redis Adapter가 도메인 TTL 정책을 소유하지 않는 이유" })).not.toBeInTheDocument();
|
|
});
|
|
|
|
it("unpublishes only the selected current row after the source confirmation", async () => {
|
|
const user = userEvent.setup();
|
|
const gateway = createTechLogFeatureInstalledInput(MOCK_STUDIO_INSTALL_CONTEXT).input.createStudioGateway();
|
|
renderInStudio(<PublicationList />, gateway);
|
|
await user.click(
|
|
await screen.findByRole("button", { name: /Redis Adapter.*게시 취소/ }),
|
|
);
|
|
|
|
expect(screen.getByRole("dialog", { name: "게시를 취소할까요?" })).toHaveTextContent(
|
|
"Studio 게시 상태를 중단하고 게시 취소 이벤트를 남깁니다.",
|
|
);
|
|
expect(screen.getByText("작업본과 이전 Snapshot은 보존됩니다.")).toBeVisible();
|
|
await user.click(screen.getByRole("button", { name: "게시 취소 확인" }));
|
|
|
|
await waitFor(() => expect(screen.getAllByText("게시를 취소했습니다.").length).toBeGreaterThanOrEqual(1));
|
|
expect(await screen.findAllByRole("link", { name: "게시 취소 전 Snapshot 보기" })).not.toHaveLength(0);
|
|
});
|
|
|
|
it("renders the event's immutable snapshot instead of a newer working copy", async () => {
|
|
const view = renderInStudio(
|
|
<PublicationEventPreviewScreen publicationEventId={FIXTURE_IDS.fetchPublishedEvent} />,
|
|
);
|
|
|
|
expect(await screen.findByRole("heading", { level: 1, name: "컬렉션 Fetch Join과 페이징은 왜 충돌하는가" })).toBeVisible();
|
|
expect(screen.getByText(/반환된 20건 뒤에서 전체 컬렉션이 로드되는 과정/)).toBeVisible();
|
|
expect(screen.queryByText("게시 후 본문 측정값을 보완한 저장본입니다.")).not.toBeInTheDocument();
|
|
expect(view.container.querySelectorAll("main")).toHaveLength(0);
|
|
expect(view.container.querySelector(".public-record-embedded")).toBeInTheDocument();
|
|
});
|
|
|
|
it("keeps unknown publication events inside the Studio not-found screen", async () => {
|
|
renderInStudio(
|
|
<PublicationEventPreviewScreen publicationEventId="99999999-9999-4999-8999-999999999999" />,
|
|
);
|
|
|
|
expect(await screen.findByRole("heading", { level: 1, name: "게시 기록을 찾을 수 없습니다" })).toBeVisible();
|
|
expect(screen.getByRole("link", { name: "게시 기록으로 돌아가기" })).toHaveAttribute(
|
|
"href",
|
|
"/studio/publications",
|
|
);
|
|
});
|
|
});
|