fix: 개념 삭제가 질문 삭제로 떨어지던 것을 고친다
개념을 지우려 하면 「질문을 찾을 수 없습니다」가 났다. 세 가지가 겹쳤다. 게이트웨이가 종류를 삼항으로 이어 붙여, 마지막 else 가 모르는 종류를 다 받아 갔다 — 개념이 deleteQuestion 으로 떨어졌다. 화면은 종류를 `as "CASE" | "REFERENCE" | "QUESTION"` 으로 좁혀 넘겼으므로 타입도 잡지 못했다. 포트의 종류 목록도 손으로 나열해 셋에 머물러 있었다. 삼항을 Record<DeletableDocumentKind, string> 표로 바꾼다 — 종류가 늘면 빠진 자리를 타입이 잡는다. 캐스팅을 걷어내고, 계약 기여 목록에 deleteConceptDraft 를 등록한다. 이 목록에 빠뜨리면 요청이 조용히 다른 주소로 나가므로(어제 페이지 인자가 그랬다) 네 종류가 각각 자기 주소로 나가는지 확인하는 가드를 함께 둔다 — 등록을 지우면 깨지는 것을 확인했다. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011nAjrqNHGPNngN4aUbcyvJ
This commit is contained in:
co-authored by
Claude Opus 5
parent
8c5dbe1a0d
commit
dec86bd1f2
@@ -0,0 +1,40 @@
|
||||
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";
|
||||
import type { DeletableDocumentKind } from "../../../src/features/tech-log/application/ports/management-gateway.ts";
|
||||
|
||||
/**
|
||||
* 종류마다 지우는 주소가 다르다. 이 대응이 어긋나면 지우려던 것과 다른 종류의 API 를 부른다.
|
||||
*
|
||||
* <p>실제로 그렇게 났다: 개념을 더할 때 관리 계약에 삭제 경로를 만들지 않았고, 게이트웨이가
|
||||
* 종류를 삼항으로 이어 붙여 마지막 else 가 남은 것을 다 받아 갔다. 부르는 화면은 종류를
|
||||
* `as "CASE" | "REFERENCE" | "QUESTION"` 으로 좁혀 넘겼으므로 타입도 잡지 못했다. 개념을
|
||||
* 지우려 하면 질문 삭제가 불렸고 「질문을 찾을 수 없습니다」가 났다.
|
||||
*/
|
||||
const EXPECTED: Record<DeletableDocumentKind, { operationId: string; path: string }> = {
|
||||
CASE: { operationId: "deleteCaseDraft", path: "/api/v1/studio/cases/{id}" },
|
||||
REFERENCE: { operationId: "deleteReferenceDraft", path: "/api/v1/studio/references/{id}" },
|
||||
QUESTION: { operationId: "deleteQuestion", path: "/api/v1/studio/questions/{id}" },
|
||||
CONCEPT: { operationId: "deleteConceptDraft", path: "/api/v1/studio/concepts/{id}" },
|
||||
};
|
||||
|
||||
test("지울 수 있는 종류마다 자기 주소가 있고 서로 겹치지 않는다", () => {
|
||||
const byId = new Map(
|
||||
TECH_LOG_MANAGEMENT_CONTRIBUTION.http.map((entry) => [entry.contract.operationId, entry]),
|
||||
);
|
||||
|
||||
const paths = new Set<string>();
|
||||
for (const [kind, expected] of Object.entries(EXPECTED)) {
|
||||
const installed = byId.get(expected.operationId);
|
||||
assert.ok(installed, `${kind} 를 지우는 ${expected.operationId} 가 계약에 있어야 한다`);
|
||||
assert.equal(installed.contract.method, "DELETE");
|
||||
assert.equal(
|
||||
installed.contract.pathTemplate,
|
||||
expected.path,
|
||||
`${kind} 는 자기 주소로 나가야 한다`,
|
||||
);
|
||||
assert.ok(!paths.has(expected.path), `${kind} 가 다른 종류와 같은 주소를 쓴다`);
|
||||
paths.add(expected.path);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user