세 가지가 각각 다른 곳에서 조용히 깨져 있었다. 작업본 목록의 프로젝트·정렬은 주소에 적히자마자 지워졌다. 라우트 검색 코덱이 STRIP_UNKNOWN 이라 선언하지 않은 키를 버리는데 `project` 와 `sort` 가 없었다 — 화면은 주소를 쓰고 라우터가 그것을 지워서, 프로젝트를 골라도 목록이 그대로였다. 카탈로그는 한 번만 불렀다. 한 번의 상한은 계약이 100으로 정해 두었으므로, 기록이 101개가 된 날 101번째부터는 관계 대상 선택에도 프로젝트 필터에도 나타나지 않았다. 응답의 `nextCursor` 를 따라 끝까지 읽는다. 게시 기록의 필터 줄은 세 칸 격자에 「검색칸 · 버튼 · 이벤트」로 잘려, 검색칸이 871px 로 벌어지고 이벤트 셀렉트는 91px 로 눌렸다 — 「게시 취소」가 그 너비에 들어가지 않았다. 버튼을 검색칸에 붙이고 칸을 둘로 줄인다. 검색 안내는 「제목 또는 요약」·「제목, 요약, slug」라고 적혀 있었지만 서버가 뒤지는 것은 제목뿐이다. 적힌 대로 고친다. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PTnWufiY9ATv57egkKKVAV
83 lines
2.9 KiB
TypeScript
83 lines
2.9 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import { collectCatalog } from "../../../src/features/tech-log/application/collect-catalog.ts";
|
|
import type {
|
|
CatalogQuery,
|
|
StudioGateway,
|
|
} from "../../../src/features/tech-log/application/ports/studio-gateway.ts";
|
|
import type { CatalogPage } from "../../../src/features/tech-log/contracts/studio/contract.ts";
|
|
|
|
type Entry = CatalogPage["items"][number];
|
|
|
|
function entry(index: number): Entry {
|
|
return {
|
|
id: `00000000-0000-4000-8000-${String(index).padStart(12, "0")}`,
|
|
type: "RELATION",
|
|
label: `기록 ${index}`,
|
|
dependencyRevision: `relation:${index}`,
|
|
};
|
|
}
|
|
|
|
/** 서버를 흉내 낸다 — 한 번에 100개까지만 주고, 더 있으면 커서를 함께 준다. */
|
|
function gatewayHolding(total: number) {
|
|
const all = Array.from({ length: total }, (_, index) => entry(index));
|
|
const calls: Array<string | undefined> = [];
|
|
const gateway: Pick<StudioGateway, "getCatalog"> = {
|
|
getCatalog(query: CatalogQuery) {
|
|
calls.push(query.cursor);
|
|
const limit = query.limit ?? 20;
|
|
const from = query.cursor === undefined ? 0 : Number(query.cursor);
|
|
const items = all.slice(from, from + limit);
|
|
const next = from + limit;
|
|
return Promise.resolve({
|
|
items,
|
|
nextCursor: next < all.length ? String(next) : null,
|
|
});
|
|
},
|
|
};
|
|
return { gateway, calls };
|
|
}
|
|
|
|
describe("catalog 는 커서를 끝까지 따라간다", () => {
|
|
/*
|
|
화면들은 `limit: 100` 으로 한 번만 부르고 있었다. 100 은 계약의 상한이라 더 크게 부를 수도
|
|
없어서, 기록이 101개가 된 날 101번째부터는 관계 대상 선택에 아예 나타나지 않았다 — 화면에는
|
|
아무 표시도 없이 "고를 수 없는 기록" 이 생겼다.
|
|
*/
|
|
it("상한을 넘는 기록도 빠짐없이 모은다", async () => {
|
|
const { gateway, calls } = gatewayHolding(105);
|
|
|
|
const items = await collectCatalog(gateway, { type: "RELATION" });
|
|
|
|
expect(items).toHaveLength(105);
|
|
expect(new Set(items.map((item) => item.id)).size).toBe(105);
|
|
expect(items.at(-1)?.label).toBe("기록 104");
|
|
expect(calls).toEqual([undefined, "100"]);
|
|
});
|
|
|
|
it("한 쪽으로 끝나면 한 번만 부른다", async () => {
|
|
const { gateway, calls } = gatewayHolding(4);
|
|
|
|
const items = await collectCatalog(gateway, { type: "PROJECT" });
|
|
|
|
expect(items).toHaveLength(4);
|
|
expect(calls).toEqual([undefined]);
|
|
});
|
|
|
|
/** 서버가 커서를 계속 주더라도 화면이 영원히 기다리지 않는다. */
|
|
it("커서가 끝나지 않아도 멈춘다", async () => {
|
|
let calls = 0;
|
|
const endless: Pick<StudioGateway, "getCatalog"> = {
|
|
getCatalog() {
|
|
calls += 1;
|
|
return Promise.resolve({ items: [entry(calls)], nextCursor: `cursor-${calls}` });
|
|
},
|
|
};
|
|
|
|
const items = await collectCatalog(endless, { type: "TOPIC" });
|
|
|
|
expect(calls).toBe(50);
|
|
expect(items).toHaveLength(50);
|
|
});
|
|
});
|