fix(presentation): draw query access failures with the access surfaces (08-11)
AsyncSurface drew auth-required, forbidden and not-found query failures with its own copy while the gallery used AccessSurface. Both now use one set, and a state surface without a handler shows no dead button. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
ee9b09563a
commit
a5fff8f4b7
@@ -7,6 +7,7 @@ import { describe, expect, it, vi } from "vitest";
|
||||
import { deriveAsyncState } from "../../src/application/view-models/async-state.ts";
|
||||
import { AsyncSurface } from "../../src/presentation/components/async-surface.tsx";
|
||||
import { createFailure } from "../../src/contracts/errors.ts";
|
||||
import { AccessSurface } from "../../src/presentation/design-system/index.ts";
|
||||
|
||||
describe("async UI state matrix", () => {
|
||||
it.each([
|
||||
@@ -233,6 +234,41 @@ describe("async UI state matrix", () => {
|
||||
expect(screen.getByText("표시할 항목이 없습니다.")).toBeVisible();
|
||||
});
|
||||
|
||||
// 08-11. A query failure and the gallery draw one access set, not two.
|
||||
it.each([
|
||||
["AUTH_REQUIRED", "auth-required"],
|
||||
["FORBIDDEN", "forbidden"],
|
||||
["NOT_FOUND", "not-found"],
|
||||
] as const)(
|
||||
"renders a %s query failure with the gallery's access surface",
|
||||
async (kind, accessKind) => {
|
||||
const user = userEvent.setup();
|
||||
const action = vi.fn();
|
||||
const failure = createFailure(kind, "LIST", 0);
|
||||
const gallery = render(
|
||||
<AccessSurface kind={accessKind} onAction={() => {}} />,
|
||||
);
|
||||
const expected = gallery.container.querySelector(".state-surface");
|
||||
expect(expected).not.toBeNull();
|
||||
const expectedText = expected?.textContent;
|
||||
gallery.unmount();
|
||||
|
||||
render(
|
||||
<AsyncSurface
|
||||
state={deriveAsyncState({ failure })}
|
||||
onAction={action}
|
||||
/>,
|
||||
);
|
||||
const alert = screen.getByRole("alert");
|
||||
expect(alert).toHaveAttribute("data-message-key", failure.userMessageKey);
|
||||
expect(alert.querySelector(".state-surface")?.textContent).toBe(
|
||||
expectedText,
|
||||
);
|
||||
await user.click(screen.getByRole("button"));
|
||||
expect(action).toHaveBeenCalledOnce();
|
||||
},
|
||||
);
|
||||
|
||||
it("does not retain a terminal error after usable data is restored", () => {
|
||||
const failed = deriveAsyncState({
|
||||
failure: createFailure("SERVER_FAILURE", "LIST", 0),
|
||||
|
||||
Reference in New Issue
Block a user