feat: assemble responsive app shell navigation
This commit is contained in:
@@ -1,24 +1,72 @@
|
||||
// @vitest-environment jsdom
|
||||
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { createAnonymousSessionAdapter } from "../../src/adapters/auth/external-session-adapter.js";
|
||||
import {
|
||||
createAnonymousSessionAdapter,
|
||||
createDemoSessionAdapter,
|
||||
} from "../../src/adapters/auth/external-session-adapter.js";
|
||||
import { AppRouter } from "../../src/presentation/routes/app-router.jsx";
|
||||
|
||||
describe("application router", () => {
|
||||
it("renders not-found without making an API request", () => {
|
||||
it("renders the app shell and not-found route without an API request", async () => {
|
||||
window.history.pushState({}, "", "/missing");
|
||||
render(<AppRouter authSession={createAnonymousSessionAdapter()} />);
|
||||
|
||||
expect(
|
||||
screen.getByRole("heading", { name: "페이지를 찾을 수 없습니다." }),
|
||||
await screen.findByRole("heading", {
|
||||
name: "페이지를 찾을 수 없습니다.",
|
||||
}),
|
||||
).toBeVisible();
|
||||
expect(screen.getByRole("navigation", { name: "주요 탐색" })).toBeVisible();
|
||||
expect(screen.getByRole("main")).toBeVisible();
|
||||
});
|
||||
|
||||
it("shows session-required UX without claiming authorization", () => {
|
||||
it("navigates between registry-backed example routes", async () => {
|
||||
const user = userEvent.setup();
|
||||
window.history.pushState({}, "", "/");
|
||||
render(<AppRouter authSession={createAnonymousSessionAdapter()} />);
|
||||
|
||||
await user.click(
|
||||
await screen.findByRole("link", { name: "UI 구성요소", exact: true }),
|
||||
);
|
||||
|
||||
expect(
|
||||
await screen.findByRole("heading", { name: "UI 구성요소", level: 1 }),
|
||||
).toBeVisible();
|
||||
expect(window.location.pathname).toBe("/examples/ui");
|
||||
});
|
||||
|
||||
it("reacts to demo sign-in and opens the protected integration route", async () => {
|
||||
const user = userEvent.setup();
|
||||
const authSession = createDemoSessionAdapter();
|
||||
window.history.pushState({}, "", "/sample/resources");
|
||||
render(<AppRouter authSession={authSession} />);
|
||||
|
||||
expect(
|
||||
await screen.findByRole("heading", { name: "세션이 필요합니다." }),
|
||||
).toBeVisible();
|
||||
await user.click(screen.getByRole("button", { name: "로그인 시작" }));
|
||||
|
||||
expect(
|
||||
await screen.findByRole("heading", { name: "보호된 연동 지점" }),
|
||||
).toBeVisible();
|
||||
expect(screen.getByText("인증됨")).toBeVisible();
|
||||
});
|
||||
|
||||
it("fails closed when the auth integration does not change state", async () => {
|
||||
const user = userEvent.setup();
|
||||
window.history.pushState({}, "", "/sample/resources");
|
||||
render(<AppRouter authSession={createAnonymousSessionAdapter()} />);
|
||||
expect(screen.getByRole("heading", { name: "세션이 필요합니다." })).toBeVisible();
|
||||
expect(screen.getByRole("button", { name: "로그인" })).toBeVisible();
|
||||
|
||||
await user.click(
|
||||
await screen.findByRole("button", { name: "로그인 시작" }),
|
||||
);
|
||||
|
||||
expect(
|
||||
screen.getByRole("heading", { name: "세션이 필요합니다." }),
|
||||
).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user