// @vitest-environment jsdom import { render, screen } from "@testing-library/react"; import { describe, expect, it } from "vitest"; import { SampleResourcePage } from "../../src/sample/contract-fixture/sample-resource-page.jsx"; describe("removable sample feature page", () => { it("renders the API-to-view-model result through AsyncSurface", async () => { /** @type {Parameters[0]["facade"]} */ const facade = { listResources: async () => ({ ok: /** @type {const} */ (true), value: [ { resourceId: "resource-1", title: "Example", createdAtLabel: null, }, ], }), createResource: async () => ({ ok: /** @type {const} */ (true), value: { resourceId: "resource-created", title: "Created", createdAtLabel: null, }, }), }; render(); expect(screen.getByLabelText("불러오는 중")).toBeVisible(); expect(await screen.findByText("Example")).toBeVisible(); }); it("renders normalized terminal errors without raw DTO fields", async () => { /** @type {Parameters[0]["facade"]} */ const facade = { listResources: async () => ({ ok: /** @type {const} */ (false), error: { kind: "SERVER_FAILURE", code: "SERVER_FAILURE", retryable: true, operationId: "LIST_SAMPLE_RESOURCES", attemptCount: 1, userMessageKey: "error.server_failure", action: "retry", }, }), createResource: async () => ({ ok: /** @type {const} */ (true), value: { resourceId: "resource-created", title: "Created", createdAtLabel: null, }, }), }; render(); const alert = await screen.findByRole("alert"); expect(alert).toHaveTextContent("요청을 완료하지 못했습니다."); expect(alert).toHaveAttribute( "data-message-key", "error.server_failure", ); }); });