Files
tech-log-frontend/tests/features/tech-log/topic-variant-wiring.test.ts
T
DongHyeonkaandClaude Opus 5 4da6d77c43 feat: 기록을 축에 걸고, 탐색을 주제로 묶는다
기록↔축 연결을 저장할 경로가 없었다. `record_variant` 는 공개 조회가 읽기만 할 뿐
아무도 쓰지 않았고, 계약의 `variantIds` 도 어디에도 닿지 않았다. 관계와 같은 「통째
교체」 방식으로 세 저장소(문서·질문·결정)에 배선한다 — 클라이언트가 보낸 배열이 곧 최종
상태이고, diff 를 뜨면 순서 재배열과 삭제를 구분하지 못한다.

문서 편집기에서 고른 주제의 축을 체크박스로 고른다. 축은 주제 안에서만 뜻이 있으므로
카탈로그에 섞지 않고 따로 읽는다. 아무 축에도 걸지 않아도 되고, 그 경우 이 기록은 그
주제의 공통 기록이 된다 — 빈 줄이 곧 「공통」이라 따로 표시하지 않는다.

탐색은 `type=CONCEPT` 을 조용히 버리고 있었다. 필터 폼은 개념을 고를 수 있게 하는데
화면 쪽 목록에는 개념이 없어서, 고르면 주소만 바뀌고 아무것도 걸리지 않았다. 목록을
손으로 적지 않고 `Record<RecordKind, …>` 에서 뽑아 컴파일러가 잡게 한다.

그리고 탐색을 주제로 묶는다. 게시 순서 한 줄로는 무엇이 있는지는 보여도 무엇에 대한
것들인지가 보이지 않아, 스무 편이 넘어가면 목록이 아니라 더미가 된다.

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

82 lines
3.2 KiB
TypeScript

import assert from "node:assert/strict";
import { test } from "vitest";
import { TECH_LOG_MANAGEMENT_CONTRIBUTION } from "../../../src/features/tech-log/contracts/tech-log-management-contract-contribution.ts";
/**
* 축(variant) CRUD 네 연산이 실제로 나가는 주소와 메서드.
*
* <p>계약에만 있고 기여 목록에 없으면 타입에는 멀쩡히 보이는데 부를 수가 없다. 축을 더할 때
* 정확히 그 상태였다 — 계약에 넷이 다 있는데 화면에서 하나도 부를 수 없었다.
*/
const EXPECTED = [
{ operationId: "listTopicVariants", method: "GET", path: "/api/v1/studio/topics/{id}/variants" },
{
operationId: "createTopicVariant",
method: "POST",
path: "/api/v1/studio/topics/{id}/variants",
},
{
operationId: "updateTopicVariant",
method: "PUT",
path: "/api/v1/studio/topics/{id}/variants/{variantId}",
},
{
operationId: "deleteTopicVariant",
method: "DELETE",
path: "/api/v1/studio/topics/{id}/variants/{variantId}",
},
] as const;
test("축 CRUD 네 연산이 자기 주소와 메서드로 등록되어 있다", () => {
const byId = new Map(
TECH_LOG_MANAGEMENT_CONTRIBUTION.http.map((entry) => [entry.contract.operationId, entry]),
);
for (const expected of EXPECTED) {
const installed = byId.get(expected.operationId);
assert.ok(installed, `${expected.operationId} 가 기여 목록에 있어야 한다`);
assert.equal(installed.contract.method, expected.method);
assert.equal(installed.contract.pathTemplate, expected.path);
}
});
/**
* 주소가 있는 것과 게이트웨이가 그것을 부르는 것은 다르다 — 삭제 경로에서 겪은 그대로다.
* 그래서 게이트웨이를 실제로 불러 어떤 연산이 어떤 인자로 나가는지 본다.
*/
test("게이트웨이가 축 연산을 주제 id 와 함께 부른다", async () => {
const { createHttpManagementGateway } = await import(
"../../../src/features/tech-log/adapters/http/http-management-gateway.ts"
);
const called: { operationId: string; input: unknown }[] = [];
const gateway = createHttpManagementGateway({
operations: {
execute: (operationId: string, input: unknown) => {
called.push({ operationId, input });
return Promise.resolve({ kind: "SUCCESS", value: [] });
},
},
} as never);
const topicId = "11111111-1111-4111-8111-111111111111";
const variantId = "22222222-2222-4222-8222-222222222222";
await gateway.listTopicVariants(topicId);
await gateway.createTopicVariant(topicId, { slug: "bff", title: "BFF" });
await gateway.updateTopicVariant(topicId, variantId, { slug: "bff", title: "BFF" });
await gateway.deleteTopicVariant(topicId, variantId, 3);
assert.deepEqual(
called.map((entry) => entry.operationId),
["listTopicVariants", "createTopicVariant", "updateTopicVariant", "deleteTopicVariant"],
);
// 경로가 주제를 요구한다. 주제 id 를 빠뜨리면 서버는 다른 주제의 축을 보게 된다.
for (const entry of called) {
assert.equal((entry.input as { id?: string }).id, topicId, entry.operationId);
}
for (const entry of called.slice(2)) {
assert.equal((entry.input as { variantId?: string }).variantId, variantId, entry.operationId);
}
});