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"; /** * 홈 「지금 집중하는 것」 편집기가 부르는 두 목록. * *
이 둘이 서버에 없던 동안 화면은 404 를 받고 「이 프로젝트에 열린 질문이 없습니다」라고 * 적었다 — 실제로는 넷이 있었고 공개 사이트에도 나오고 있었다. 작성자에게는 자기가 아직 쓰지 * 않은 것으로 보였다. 서버 쪽에도 같은 가드가 있다(`ContractRouteCoverageTest`). */ const EXPECTED = [ { operationId: "listStudioQuestions", method: "GET", path: "/api/v1/studio/questions" }, { operationId: "listStudioProjectDecisions", method: "GET", path: "/api/v1/studio/projects/{id}/decisions", }, ] as const; test("편집기가 고를 목록을 읽는 연산이 등록되어 있다", () => { 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("게이트웨이가 두 목록을 각자의 연산으로 부른다", async () => { const { createHttpManagementGateway } = await import( "../../../src/features/tech-log/adapters/http/http-management-gateway.ts" ); const called: { operationId: string; input: unknown }[] = []; const gateway = createHttpManagementGateway({ http: { execute: (operationId: string, input: unknown) => { called.push({ operationId, input }); return Promise.resolve({ ok: true as const, value: { items: [] } }); }, }, } as never); const projectId = "11111111-1111-4111-8111-111111111111"; await gateway.listQuestions(0, 100); await gateway.listProjectDecisions(projectId); assert.deepEqual( called.map((entry) => entry.operationId), ["listStudioQuestions", "listStudioProjectDecisions"], ); // 결정은 프로젝트 안에서만 산다 — id 를 빠뜨리면 서버는 어느 프로젝트인지 알 수 없다. assert.equal((called[1]!.input as { id?: string }).id, projectId); });