feat: 자료를 해시가 아니라 뜻으로 고르고, 검증이 막는 것을 세어 준다

Asset 목록이 `assetKey` 를 앞세우고 있었다. key 는 본문이 가리키는 불변 식별자이지
사람이 기억하는 이름이 아니다 — 스무 줄이면 해시 같은 문자열 스무 개에서 찾던 도식을
눈으로 골라야 했다. 파일 이름을 앞에 두고 형식·치수·크기를 함께 적는다. key 는 아래에
작게 남긴다(복사해 쓰는 값이라 지우지 않는다).

「사용 0건」과 「사용 3건」이 같은 회색으로 나란했다. 쓰이지 않는 자료는 지워도 되는
것이고 쓰이는 자료는 지우면 화면이 깨지므로, 그 차이를 말로 가른다. 상세에서는 어느
기록이 쓰는지를 링크로 연다 — 바꾸거나 지우기 전에 무엇이 깨질지 숫자만으로는 알 수
없다. 관리 상태도 `ARCHIVED` 대신 「보관됨」으로 적는다.

검증 결과는 오류와 경고가 한 목록에 섞여 있었다. 게시 전에 작성자가 알아야 하는 것은
"게시를 막는 것이 몇 개인가" 하나인데, 그 답을 얻으려면 줄마다 배지를 읽어야 했다.
둘을 갈라 각각의 수를 제목에 적는다.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015c8cBFUaVr7KLVUx6ujz7D
This commit is contained in:
DongHyeonka
2026-09-15 20:33:07 +09:00
co-authored by Claude Opus 5
parent 9545860605
commit ae6da7156e
4 changed files with 167 additions and 57 deletions
+33 -28
View File
@@ -162,7 +162,7 @@ test("shows archive instead of delete for an asset in use", async () => {
hasPublicationHistory: true,
})} />);
await user.click(await screen.findByRole("button", { name: "boundary" }));
await user.click(await screen.findByRole("button", { name: "b.svg" }));
assert.ok(await screen.findByRole("button", { name: "보관" }));
expect(screen.queryByRole("button", { name: "삭제" })).not.toBeInTheDocument();
@@ -183,7 +183,7 @@ test("surfaces ASSET_IN_USE when the server rejects a delete", async () => {
},
)} />);
await user.click(await screen.findByRole("button", { name: "boundary" }));
await user.click(await screen.findByRole("button", { name: "b.svg" }));
// 삭제는 이제 확인을 한 번 거친다. 상세의 버튼이 창을 열고, 창의 버튼이 실제로 지운다.
await user.click(await screen.findByRole("button", { name: "삭제" }));
await user.click(
@@ -205,9 +205,9 @@ test("archives an asset by sending the expected command and merging the server's
});
render(<AssetLibrary gateway={gateway} />);
const row = (await screen.findByRole("button", { name: "boundary" })).closest("li");
const row = (await screen.findByRole("button", { name: "b.svg" })).closest("li");
assert.ok(row);
await user.click(await screen.findByRole("button", { name: "boundary" }));
await user.click(await screen.findByRole("button", { name: "b.svg" }));
await user.click(await screen.findByRole("button", { name: "보관" }));
assert.ok(await screen.findByText("보관했습니다."));
@@ -225,7 +225,8 @@ test("archives an asset by sending the expected command and merging the server's
// response instead of just leaving the old row in place. `findByText`
// above already settled on the post-update render, so this can assert
// directly instead of polling.
assert.ok(row.textContent?.includes("ARCHIVED"));
// 상태는 이제 사람이 읽는 말로 나온다 — 화면에 영문 상수를 그대로 찍던 자리였다.
assert.ok(row.textContent?.includes("보관됨"));
});
// Fix round 1 (I1 + Minor 4). Combines the delete success path's gateway
@@ -244,7 +245,7 @@ test("removes the asset and restores focus to the page heading, not the detached
});
render(<AssetLibrary gateway={gateway} />);
await user.click(await screen.findByRole("button", { name: "boundary" }));
await user.click(await screen.findByRole("button", { name: "b.svg" }));
// 삭제는 이제 확인을 한 번 거친다. 상세의 버튼이 창을 열고, 창의 버튼이 실제로 지운다.
await user.click(await screen.findByRole("button", { name: "삭제" }));
await user.click(
@@ -257,7 +258,7 @@ test("removes the asset and restores focus to the page heading, not the detached
const options = deleteCalls[0].options as { idempotencyKey?: unknown };
assert.equal(typeof options.idempotencyKey, "string");
assert.ok((options.idempotencyKey as string).length > 0);
expect(screen.queryByRole("button", { name: "boundary" })).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "b.svg" })).not.toBeInTheDocument();
// `findByText` above already settled on the post-delete render -- the
// `queueMicrotask`-scheduled focus call has necessarily run by then, since
@@ -288,8 +289,12 @@ test("removes the asset and restores focus to the page heading, not the detached
type ListCall = Readonly<{ q?: string; cursor?: string; limit?: number }>;
type ListPage = Readonly<{ items: unknown[]; nextCursor: string | null }>;
/*
자료마다 사람이 부르는 이름이 다르다. 목록이 `assetKey` 를 앞세우던 동안 픽스처도 key 로만
갈라져 있었는데, 화면이 파일 이름으로 고르게 되었으므로 픽스처도 그 이름을 따로 갖는다.
*/
function assetNamed(assetKey: string, id: string) {
return { ...(ASSET as object), id, assetKey } as never;
return { ...(ASSET as object), id, assetKey, originalFilename: `${assetKey}.svg` } as never;
}
function libraryGateway(respond: (query: ListCall) => ListPage) {
@@ -324,12 +329,12 @@ test("searches assets with the typed query and announces the new result count",
);
render(<AssetLibrary gateway={gateway} />);
await screen.findByRole("button", { name: "newer-diagram" });
await screen.findByRole("button", { name: "newer-diagram.svg" });
await user.type(screen.getByLabelText("Asset 검색"), "older");
await user.click(screen.getByRole("button", { name: "검색" }));
assert.ok(await screen.findByRole("button", { name: "older-diagram" }));
expect(screen.queryByRole("button", { name: "newer-diagram" })).not.toBeInTheDocument();
assert.ok(await screen.findByRole("button", { name: "older-diagram.svg" }));
expect(screen.queryByRole("button", { name: "newer-diagram.svg" })).not.toBeInTheDocument();
assert.equal(calls.at(-1)?.q, "older");
// The result count lives in a `role="status"` region so a screen reader is
// told the list changed -- a silently re-rendered list is the failure mode
@@ -345,7 +350,7 @@ test("typing alone never reaches the gateway -- only the submitted query does",
const { gateway, calls } = libraryGateway(() => ({ items: [ASSET], nextCursor: null }));
render(<AssetLibrary gateway={gateway} />);
await screen.findByRole("button", { name: "boundary" });
await screen.findByRole("button", { name: "b.svg" });
assert.equal(calls.length, 1);
await user.type(screen.getByLabelText("Asset 검색"), "boundary");
@@ -364,12 +369,12 @@ test("loads the next page with the server cursor and appends it to the list", as
);
render(<AssetLibrary gateway={gateway} />);
await screen.findByRole("button", { name: "page-one" });
await screen.findByRole("button", { name: "page-one.svg" });
await user.click(screen.getByRole("button", { name: "더 보기" }));
assert.ok(await screen.findByRole("button", { name: "page-two" }));
assert.ok(await screen.findByRole("button", { name: "page-two.svg" }));
// Appended, not replaced: the first page must stay reachable.
assert.ok(screen.getByRole("button", { name: "page-one" }));
assert.ok(screen.getByRole("button", { name: "page-one.svg" }));
assert.equal(calls.at(-1)?.cursor, "cursor-1");
// Exhausted paging removes the control rather than leaving a button that
// does nothing.
@@ -387,17 +392,17 @@ test("더 보기 moves focus to the first newly loaded asset instead of strandin
);
render(<AssetLibrary gateway={gateway} />);
await screen.findByRole("button", { name: "focus-page-one" });
await screen.findByRole("button", { name: "focus-page-one.svg" });
await user.click(screen.getByRole("button", { name: "더 보기" }));
const appended = await screen.findByRole("button", { name: "focus-page-two" });
const appended = await screen.findByRole("button", { name: "focus-page-two.svg" });
expect(appended).toHaveFocus();
});
test("offers no 더 보기 control when the server reports no next cursor", async () => {
render(<AssetLibrary gateway={gatewayOf({ asset: ASSET, usages: [], hasPublicationHistory: false })} />);
await screen.findByRole("button", { name: "boundary" });
await screen.findByRole("button", { name: "b.svg" });
expect(screen.queryByRole("button", { name: "더 보기" })).not.toBeInTheDocument();
});
@@ -414,16 +419,16 @@ test("a new search restarts paging from the first page instead of carrying the o
});
render(<AssetLibrary gateway={gateway} />);
await screen.findByRole("button", { name: "reset-page-one" });
await screen.findByRole("button", { name: "reset-page-one.svg" });
await user.click(screen.getByRole("button", { name: "더 보기" }));
await screen.findByRole("button", { name: "reset-page-two" });
await screen.findByRole("button", { name: "reset-page-two.svg" });
await user.type(screen.getByLabelText("Asset 검색"), "reset-found");
await user.click(screen.getByRole("button", { name: "검색" }));
assert.ok(await screen.findByRole("button", { name: "reset-found" }));
expect(screen.queryByRole("button", { name: "reset-page-one" })).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "reset-page-two" })).not.toBeInTheDocument();
assert.ok(await screen.findByRole("button", { name: "reset-found.svg" }));
expect(screen.queryByRole("button", { name: "reset-page-one.svg" })).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "reset-page-two.svg" })).not.toBeInTheDocument();
assert.equal(calls.at(-1)?.cursor, undefined);
});
@@ -456,7 +461,7 @@ test("a slow earlier search never overwrites the newer search's results", async
await act(async () => {
pending[0]!.settle({ items: [initial], nextCursor: null });
});
await screen.findByRole("button", { name: "race-initial" });
await screen.findByRole("button", { name: "race-initial.svg" });
const input = screen.getByLabelText("Asset 검색");
await user.clear(input);
@@ -472,7 +477,7 @@ test("a slow earlier search never overwrites the newer search's results", async
await act(async () => {
pending[2]!.settle({ items: [fast], nextCursor: null });
});
await screen.findByRole("button", { name: "race-fast" });
await screen.findByRole("button", { name: "race-fast.svg" });
// The abandoned "slow" request lands last. Nothing about it may reach the
// screen: the user is looking at "fast" results.
@@ -480,8 +485,8 @@ test("a slow earlier search never overwrites the newer search's results", async
pending[1]!.settle({ items: [slow], nextCursor: null });
});
expect(screen.queryByRole("button", { name: "race-slow" })).not.toBeInTheDocument();
assert.ok(screen.getByRole("button", { name: "race-fast" }));
expect(screen.queryByRole("button", { name: "race-slow.svg" })).not.toBeInTheDocument();
assert.ok(screen.getByRole("button", { name: "race-fast.svg" }));
});
test("a search that matches nothing says so instead of claiming no asset was ever uploaded", async () => {
@@ -491,7 +496,7 @@ test("a search that matches nothing says so instead of claiming no asset was eve
);
render(<AssetLibrary gateway={gateway} />);
await screen.findByRole("button", { name: "boundary" });
await screen.findByRole("button", { name: "b.svg" });
await user.type(screen.getByLabelText("Asset 검색"), "없는키");
await user.click(screen.getByRole("button", { name: "검색" }));