주제 탭 (H1 연장). 홈 탭에 주제를 전부 세우고 목록 아래 「다른 주제 N개 보기」
줄을 없앴다. 축이 둘 이상인 주제만 탭이 되던 규칙 때문에 여섯 중 둘만 올라오고
나머지 넷은 비교표를 다 읽어야 만나는 작은 글씨 한 줄로 갔다. 축은 주제가
자라면서 생기는 것이지 기록이 없다는 뜻이 아니다. 축이 없는 주제는 그 주제의
기록을 세우고, 기록이 없으면 그렇다고 분명히 말한다.
탭 하나가 패널 하나를 가리키게 고쳤다. 탭 전부가 같은 패널을 가리키면 고르지
않은 탭이 "내가 저 패널을 연다" 고 말하면서 패널은 다른 탭의 이름을 달게 된다.
H1. `/studio/documents` 와 `/studio/publications` 의 검색·필터·쪽수를 주소에
담는다. 담지 않던 동안 3쪽에서 문서를 열고 뒤로 오면 1쪽이었고 필터도 사라졌다.
공개 `/search` 는 처음부터 담고 있었다.
H4. 문서 종류 이름을 `document-kind-labels.ts` 하나로 모았다. 세 곳에 흩어져
있어서 같은 CASE 가 목록에서는 「검증 기록」, 새 문서에서는 「Case」, 검색에서는
또 다른 이름이었다.
H5. `project.stage` 가 화면에 `DESIGN` 으로 그대로 새어 나왔다. 같은 프로젝트를
Studio 는 「설계」로 불렀다 — 두 화면이 다른 말을 했다.
H6. 값이 없는데 라벨만 그려지던 자리를 막았다. 네 프로젝트 중 셋이 「현재 목표」
라벨만 있고 값이 비어 있었다.
M2. 대시보드의 숫자를 목록으로 가는 길로 만들고, 할 일이 없는 구역은 그리지
않는다. 공개 홈 설정 폼은 작업 목록 한가운데에서 뒤로 옮겼다.
M3. 작업본 목록에 프로젝트 필터와 정렬을 더했다. 공개 `/explore` 는 독자에게
셋을 주는데 61개를 관리하는 작성자에게는 둘뿐이었다.
M4. 게시 기록의 필터 제출 방식을 작업본 목록에 맞췄다 — 셀렉트는 즉시, 검색만
버튼이다.
M5. MOCK 시절 문구("세션이 끝나면 사라집니다")를 지웠다. 실서버에는 작업본이
남는다.
M7. `aria-current="page"` 가 현재 페이지가 아닌 링크에 붙었다. 정확히 일치할
때만 붙게 하고 구역 강조는 따로 계산한다.
M8. 홈의 첫 화면을 비교표로 바꿨다. 다른 데서 얻을 수 없는 유일한 것이 y≈600 에
묻혀 있었다.
`ListDocumentsQuery.kind` 가 손으로 적은 union 이라 개념과 환경 구성이 빠져
있었다 — 그 둘은 작업본 목록에서 걸러 볼 수가 없었다. 계약 타입으로 바꿨다.
M9 는 고치지 않는다. 「문제·결론이 11px 회색」이라는 지적이 지금 빌드에서
재현되지 않는다 — 실측은 17px `rgb(63,66,73)` 이고 본문이 18px 같은 색이다.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PTnWufiY9ATv57egkKKVAV
640 lines
26 KiB
TypeScript
640 lines
26 KiB
TypeScript
// @vitest-environment jsdom
|
|
|
|
import { act, render, screen, waitFor, within } from "@testing-library/react";
|
|
import userEvent from "@testing-library/user-event";
|
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
import { lazy, type ComponentType } from "react";
|
|
import {
|
|
createMemoryRouter,
|
|
Outlet,
|
|
RouterProvider,
|
|
type RouterProviderProps,
|
|
} from "react-router-dom";
|
|
|
|
import { createTechLogFeatureInstalledInput } from "../../../src/features/tech-log/adapters/create-tech-log-feature-input.ts";
|
|
import { MOCK_STUDIO_INSTALL_CONTEXT } from "../../helpers/studio-install-context.ts";
|
|
import {
|
|
TECH_LOG_ROUTE_REGISTRY,
|
|
TECH_LOG_ROUTE_RUNTIME_CONTRACT,
|
|
type TechLogRouteId,
|
|
} from "../../../src/features/tech-log/contracts/tech-log-route-contract.ts";
|
|
import {
|
|
moveFocus,
|
|
normalizeFocus,
|
|
shouldNormalizeFocusUrl,
|
|
} from "../../../src/features/tech-log/domain/public/focus-state.ts";
|
|
import { PublicShell } from "../../../src/features/tech-log/presentation/public/public-shell.tsx";
|
|
import { ExploreKindPage } from "../../../src/features/tech-log/presentation/public/pages/explore-kind-page.tsx";
|
|
import { ExplorePage } from "../../../src/features/tech-log/presentation/public/pages/explore-page.tsx";
|
|
import { HomePage } from "../../../src/features/tech-log/presentation/public/pages/home-page.tsx";
|
|
import { SearchPage } from "../../../src/features/tech-log/presentation/public/pages/search-page.tsx";
|
|
import { PublicNotFoundPage as NotFoundPage } from "../../../src/features/tech-log/presentation/public/pages/public-not-found-page.tsx";
|
|
import { TECH_LOG_ROUTE_CODECS } from "../../../src/features/tech-log/presentation/tech-log-route-codecs.ts";
|
|
import { ApplicationProvider } from "../../../src/presentation/providers/application-provider.tsx";
|
|
import { createGroupedRouteObjects } from "../../../src/presentation/routes/app-router.tsx";
|
|
import { PLATFORM_ROUTE_CODECS } from "../../../src/presentation/routes/platform-route-codecs.ts";
|
|
import { createTestApplication } from "../../helpers/create-test-application.ts";
|
|
import { renderWithQueryProviders } from "../../helpers/query-providers.tsx";
|
|
|
|
const routeCodecs = Object.freeze({
|
|
...PLATFORM_ROUTE_CODECS,
|
|
...TECH_LOG_ROUTE_CODECS,
|
|
});
|
|
|
|
const routeComponents = {
|
|
TECH_LOG_HOME: HomePage,
|
|
TECH_LOG_EXPLORE: ExplorePage,
|
|
TECH_LOG_EXPLORE_KIND: ExploreKindPage,
|
|
TECH_LOG_SEARCH: SearchPage,
|
|
} as const;
|
|
|
|
type DiscoveryRouteId = keyof typeof routeComponents;
|
|
|
|
type DiscoveryRenderOptions = Readonly<{
|
|
NotFoundComponent?: ComponentType;
|
|
application?: ReturnType<typeof createTestApplication>;
|
|
}>;
|
|
|
|
async function renderDiscoveryRoute<RouteId extends DiscoveryRouteId>(
|
|
routeId: RouteId,
|
|
initialEntry: string,
|
|
options: DiscoveryRenderOptions = {},
|
|
) {
|
|
const definition = TECH_LOG_ROUTE_REGISTRY[routeId];
|
|
const runtime = TECH_LOG_ROUTE_RUNTIME_CONTRACT[routeId];
|
|
const Component = routeComponents[routeId];
|
|
const router = createMemoryRouter(
|
|
createGroupedRouteObjects(
|
|
{
|
|
[routeId]: definition,
|
|
NOT_FOUND: TECH_LOG_ROUTE_REGISTRY.NOT_FOUND,
|
|
},
|
|
{
|
|
[routeId]: {
|
|
moduleId: runtime.moduleId,
|
|
Component,
|
|
},
|
|
NOT_FOUND: {
|
|
moduleId: TECH_LOG_ROUTE_RUNTIME_CONTRACT.NOT_FOUND.moduleId,
|
|
Component: options.NotFoundComponent ?? NotFoundPage,
|
|
},
|
|
},
|
|
{
|
|
PUBLIC: (
|
|
<PublicShell>
|
|
<Outlet />
|
|
</PublicShell>
|
|
),
|
|
STUDIO: <Outlet />,
|
|
},
|
|
"task-7-test-build",
|
|
routeCodecs,
|
|
),
|
|
{ initialEntries: [initialEntry] },
|
|
);
|
|
const techLog = createTechLogFeatureInstalledInput(MOCK_STUDIO_INSTALL_CONTEXT).input;
|
|
const view = render(
|
|
renderWithQueryProviders(
|
|
<ApplicationProvider
|
|
application={
|
|
options.application ??
|
|
createTestApplication({
|
|
featureInputs: { "tech-log": techLog },
|
|
})
|
|
}
|
|
>
|
|
<RouterProvider router={router} />
|
|
</ApplicationProvider>,
|
|
));
|
|
// 포트가 async 가 되면서 첫 페인트에는 데이터가 없다. 화면이 정착한 뒤
|
|
// 단언하도록 여기서 한 번 기다린다 — 각 테스트에 흩어 놓으면 빠뜨린 곳이 생긴다.
|
|
// `main` 을 기다리지 않는다 — 이 파일에는 의도적으로 렌더에 실패하는 라우트도 있고,
|
|
// 그때는 main 이 아예 없다. 로딩 표면이 사라지는 것이 두 경우 모두에 맞는 기준이다.
|
|
await waitFor(() =>
|
|
expect(document.querySelector(".state-surface--loading")).toBeNull(),
|
|
);
|
|
return { ...view, router } satisfies ReturnType<typeof render> & {
|
|
router: RouterProviderProps["router"];
|
|
};
|
|
}
|
|
|
|
beforeEach(() => {
|
|
vi.stubGlobal("requestAnimationFrame", (callback: FrameRequestCallback) => {
|
|
callback(0);
|
|
return 1;
|
|
});
|
|
});
|
|
|
|
afterEach(() => {
|
|
vi.unstubAllGlobals();
|
|
});
|
|
|
|
describe("TechLog home discovery", () => {
|
|
it("renders the exact identity, focus, latest ordering, and explore choices", async () => {
|
|
const { router } = await renderDiscoveryRoute(
|
|
"TECH_LOG_HOME",
|
|
"/?focus=invalid&focus=question",
|
|
);
|
|
|
|
expect(screen.getByRole("heading", { level: 1, name: "TechLog" })).toBeVisible();
|
|
expect(
|
|
within(screen.getByRole("main")).getByText(
|
|
"문제를 재현하고 검증해 실제 운영에 적용할 수 있는 형태로 정리합니다.",
|
|
),
|
|
).toHaveClass("identity-statement");
|
|
expect(screen.getByText("지금 집중하는 것")).toHaveClass("section-kicker");
|
|
|
|
await waitFor(() => {
|
|
expect(router.state.location.search).toBe("?focus=current");
|
|
});
|
|
expect(screen.getByRole("tab", { name: "현재 작업" })).toHaveAttribute(
|
|
"aria-selected",
|
|
"true",
|
|
);
|
|
/*
|
|
패널은 묶음마다 하나뿐이라 고른 탭만 그것을 가리킨다. 탭 전부가 같은 패널을 가리키면
|
|
고르지 않은 탭이 "내가 저 패널을 연다" 고 말하면서 패널은 다른 탭의 이름을 달게 된다.
|
|
그래서 검사도 고른 탭에만 건다.
|
|
*/
|
|
/*
|
|
두 탭 묶음이 서로 다른 모양을 쓴다. 「지금 집중하는 것」은 탭마다 패널이 하나씩이고,
|
|
주제 탭은 패널이 하나뿐이라 고른 탭만 그것을 가리킨다 — 전부가 같은 패널을 가리키면
|
|
고르지 않은 탭이 "내가 저 패널을 연다" 고 말하면서 패널은 다른 탭의 이름을 달게 된다.
|
|
|
|
두 모양에 다 성립하는 것은 이것이다: 가리키는 패널이 있으면 그 패널은 실제로 있고
|
|
자기를 가리킨 탭의 이름을 달고 있다.
|
|
*/
|
|
for (const tab of screen.getAllByRole("tab")) {
|
|
const panelId = tab.getAttribute("aria-controls");
|
|
if (!panelId) {
|
|
expect(tab.getAttribute("aria-selected")).toBe("false");
|
|
continue;
|
|
}
|
|
expect(document.getElementById(panelId)).toHaveAttribute(
|
|
"aria-labelledby",
|
|
tab.id,
|
|
);
|
|
}
|
|
|
|
/*
|
|
홈은 앞의 몇 편만 편다. 주제 허브가 생긴 지금 홈이 할 일은 목록을 통째로 펴 두는 것이
|
|
아니라 무엇을 견줬고 지금 무엇을 하고 있는지를 보여 주는 것이다 — 목록이 홈의 절반을
|
|
차지하면 그 둘이 스크롤 아래로 밀린다.
|
|
*/
|
|
const latest = screen.getByRole("region", { name: "최근 기록" });
|
|
expect(
|
|
within(latest).getAllByRole("heading", { level: 3 }).map((heading) =>
|
|
heading.textContent,
|
|
),
|
|
).toEqual([
|
|
"컬렉션 Fetch Join과 페이징은 왜 충돌하는가",
|
|
"파일 저장소 계약을 하나로 통합했습니다",
|
|
"Authorization Code Flow에서 state와 nonce의 경계",
|
|
"oauth2-proxy 뒤에서 토큰을 다시 검증할 것인가",
|
|
]);
|
|
/*
|
|
종류 이름은 목록도 범례도 같은 표에서 가져온다. 목록만 영문 대문자로 나가던 동안 홈 한
|
|
화면에 종류 이름이 아홉 개 떠 있었고, 독자는 `CASE` 와 「검증 기록」이 같은 것이라는
|
|
단서를 어디서도 받지 못했다.
|
|
*/
|
|
expect(
|
|
[...new Set(
|
|
Array.from(latest.querySelectorAll(".latest-time > span"), (span) => span.textContent),
|
|
)].every((label) => /^[가-힣 ]+$/u.test(label ?? "")),
|
|
).toBe(true);
|
|
/*
|
|
종류별 입구. 예전에는 이 자리가 낱말 뜻풀이였고 이름이 `Case`·`OpenQuestion` 같은
|
|
저장소의 말이었다. 이름이 하는 일을 말하도록 바뀌었으므로 설명도 함께 바뀐다.
|
|
프로젝트는 종류가 아니라 그릇이므로 이 목록에서 뺐다 — 주 내비가 이미 데려간다.
|
|
*/
|
|
expect(
|
|
screen.getByRole("link", { name: /무엇을 해보고 무엇을 확인했는지.*검증 기록/ }),
|
|
).toHaveAttribute("href", "/explore/cases");
|
|
expect(
|
|
screen.getByRole("link", { name: /아직 답하지 못한 것과 다음 검증.*열린 질문/ }),
|
|
).toHaveAttribute("href", "/explore/questions");
|
|
});
|
|
|
|
it("moves linked tabs with arrows, Home, and End while synchronizing the URL", async () => {
|
|
const user = userEvent.setup();
|
|
const { router } = await renderDiscoveryRoute("TECH_LOG_HOME", "/?focus=question");
|
|
const question = screen.getByRole("tab", { name: "열린 질문" });
|
|
question.focus();
|
|
|
|
await user.keyboard("{ArrowRight}");
|
|
expect(screen.getByRole("tab", { name: "최근 결정" })).toHaveFocus();
|
|
expect(router.state.location.search).toBe("?focus=decision");
|
|
expect(screen.getByRole("heading", { name: /Filesystem과 Object Storage/ })).toBeVisible();
|
|
|
|
await user.keyboard("{ArrowRight}");
|
|
expect(screen.getByRole("tab", { name: "현재 작업" })).toHaveFocus();
|
|
expect(router.state.location.search).toBe("?focus=current");
|
|
|
|
await user.keyboard("{End}");
|
|
expect(screen.getByRole("tab", { name: "최근 결정" })).toHaveFocus();
|
|
await user.keyboard("{Home}");
|
|
expect(screen.getByRole("tab", { name: "현재 작업" })).toHaveFocus();
|
|
/*
|
|
탭 묶음이 둘이다 — 「지금 집중하는 것」과 주제 탭. 각 묶음은 패널을 하나만 펴 두므로
|
|
화면 전체에서 둘이다. 주제 탭이 생기기 전에는 하나였다.
|
|
*/
|
|
expect(screen.getAllByRole("tabpanel")).toHaveLength(2);
|
|
});
|
|
|
|
it("treats external focus URL changes as authoritative without stealing focus", async () => {
|
|
const { router } = await renderDiscoveryRoute(
|
|
"TECH_LOG_HOME",
|
|
"/?focus=current&state=latest-empty#latest",
|
|
);
|
|
const current = screen.getByRole("tab", { name: "현재 작업" });
|
|
current.focus();
|
|
|
|
await router.navigate("/?focus=question&state=latest-empty#latest");
|
|
|
|
await waitFor(() => {
|
|
expect(screen.getByRole("tab", { name: "열린 질문" })).toHaveAttribute(
|
|
"aria-selected",
|
|
"true",
|
|
);
|
|
});
|
|
expect(router.state.location).toMatchObject({
|
|
pathname: "/",
|
|
search: "?focus=question&state=latest-empty",
|
|
hash: "#latest",
|
|
});
|
|
expect(screen.getByRole("tab", { name: "열린 질문" })).toHaveAttribute(
|
|
"tabindex",
|
|
"0",
|
|
);
|
|
expect(current).toHaveAttribute("aria-selected", "false");
|
|
expect(current).toHaveAttribute("tabindex", "-1");
|
|
expect(current).toHaveFocus();
|
|
expect(
|
|
screen.getByRole("tabpanel", { name: "열린 질문" }),
|
|
).toBeVisible();
|
|
expect(document.getElementById("focus-panel-current")).toHaveAttribute(
|
|
"hidden",
|
|
);
|
|
|
|
await router.navigate("/?focus=decision&state=latest-empty#latest");
|
|
|
|
await waitFor(() => {
|
|
expect(screen.getByRole("tab", { name: "최근 결정" })).toHaveAttribute(
|
|
"aria-selected",
|
|
"true",
|
|
);
|
|
});
|
|
expect(router.state.location).toMatchObject({
|
|
pathname: "/",
|
|
search: "?focus=decision&state=latest-empty",
|
|
hash: "#latest",
|
|
});
|
|
expect(screen.getByRole("tab", { name: "최근 결정" })).toHaveAttribute(
|
|
"tabindex",
|
|
"0",
|
|
);
|
|
expect(screen.getByRole("tabpanel", { name: "최근 결정" })).toBeVisible();
|
|
/*
|
|
탭 묶음이 둘이다 — 「지금 집중하는 것」과 주제 탭. 각 묶음은 패널을 하나만 펴 두므로
|
|
화면 전체에서 둘이다. 주제 탭이 생기기 전에는 하나였다.
|
|
*/
|
|
expect(screen.getAllByRole("tabpanel")).toHaveLength(2);
|
|
});
|
|
|
|
it("preserves the source home empty and error states", async () => {
|
|
const emptyView = await renderDiscoveryRoute("TECH_LOG_HOME", "/?state=latest-empty");
|
|
expect(screen.getByText("아직 공개된 기록이 없습니다.")).toHaveClass(
|
|
"latest-state--empty",
|
|
);
|
|
emptyView.unmount();
|
|
|
|
const latestErrorView = await renderDiscoveryRoute(
|
|
"TECH_LOG_HOME",
|
|
"/?state=latest-error",
|
|
);
|
|
expect(screen.getByRole("alert")).toHaveTextContent(
|
|
"최근 기록을 불러오지 못했습니다.",
|
|
);
|
|
expect(screen.getByRole("link", { name: "다시 시도" })).toHaveAttribute(
|
|
"href",
|
|
"/#latest",
|
|
);
|
|
latestErrorView.unmount();
|
|
|
|
const errorView = await renderDiscoveryRoute("TECH_LOG_HOME", "/?state=site-error");
|
|
expect(
|
|
screen.getByRole("heading", { name: "페이지를 불러오지 못했습니다." }),
|
|
).toBeVisible();
|
|
expect(screen.getByText("PREVIEW-HOME-500")).toBeVisible();
|
|
errorView.unmount();
|
|
|
|
await renderDiscoveryRoute("TECH_LOG_HOME", "/?state=focus-empty");
|
|
expect(screen.queryByText("지금 집중하는 것")).not.toBeInTheDocument();
|
|
});
|
|
});
|
|
|
|
describe("TechLog explore discovery", () => {
|
|
it("filters by kind, topic, and project and keeps source result structure", async () => {
|
|
const user = userEvent.setup();
|
|
const { router } = await renderDiscoveryRoute(
|
|
"TECH_LOG_EXPLORE",
|
|
"/explore?type=CASE&topic=jpa&project=backend-skeleton",
|
|
);
|
|
|
|
expect(screen.getByRole("heading", { level: 1, name: "탐색" })).toBeVisible();
|
|
expect(
|
|
screen.getByText("유형과 기술 주제, 프로젝트를 조합해 공개 기록을 찾습니다."),
|
|
).toBeVisible();
|
|
// 필터의 선택지는 카탈로그가 도착한 뒤 채워지고, select 의 값도 그때 설정된다.
|
|
await waitFor(() => {
|
|
expect(screen.getByLabelText("유형")).toHaveValue("CASE");
|
|
expect(screen.getByLabelText("주제")).toHaveValue("jpa");
|
|
expect(screen.getByLabelText("프로젝트")).toHaveValue("backend-skeleton");
|
|
});
|
|
// 주제 선택지는 보이는 이름과 보내는 값이 다르다. 값이 이름이면 slug 로 거르는 API 가
|
|
// 0건을 돌려주고, 화면은 「조건에 맞는 공개 기록이 없습니다」만 남는다 — 운영에서 실제로
|
|
// 그랬다. 목록에서 유도한 값이라 이 단언이 없으면 조용히 되돌아간다.
|
|
expect(
|
|
within(screen.getByLabelText("주제")).getByRole("option", { name: "Authentication" }),
|
|
).toHaveValue("authentication");
|
|
expect(screen.getByText("1개의 공개 기록")).toBeVisible();
|
|
expect(
|
|
screen.getByRole("link", { name: /컬렉션 Fetch Join과 페이징은 왜 충돌하는가/ }),
|
|
).toHaveAttribute("href", "/cases/collection-fetch-join-pagination");
|
|
|
|
await user.selectOptions(screen.getByLabelText("유형"), "QUESTION");
|
|
await user.selectOptions(screen.getByLabelText("주제"), "authentication");
|
|
await user.selectOptions(screen.getByLabelText("프로젝트"), "auth-lab");
|
|
await user.click(screen.getByRole("button", { name: "적용" }));
|
|
|
|
await waitFor(() => {
|
|
expect(router.state.location.search).toBe(
|
|
"?project=auth-lab&topic=authentication&type=QUESTION",
|
|
);
|
|
});
|
|
expect(screen.getByText("1개의 공개 기록")).toBeVisible();
|
|
expect(
|
|
screen.getByRole("link", { name: /oauth2-proxy가 전달한 토큰을 다시 검증해야 하는가/ }),
|
|
).toBeVisible();
|
|
|
|
await user.click(screen.getByRole("link", { name: "필터 초기화" }));
|
|
await waitFor(() => {
|
|
expect(router.state.location.pathname).toBe("/explore");
|
|
expect(router.state.location.search).toBe("");
|
|
});
|
|
expect(screen.getByText("7개의 공개 기록")).toBeVisible();
|
|
/*
|
|
탐색은 오래 게시 순서 한 줄이었다. 무엇이 있는지는 보이지만 무엇에 대한 것들인지는 보이지
|
|
않아서, 스무 편이 넘어가면 목록이 아니라 더미가 된다. 이제 주제로 묶고, 묶음은 기록이
|
|
많은 주제부터 온다 — 가장 많이 다룬 것이 이 기록의 중심이다.
|
|
*/
|
|
expect(
|
|
within(screen.getByRole("main"))
|
|
.getAllByRole("heading", { level: 3 })
|
|
.map((heading) => heading.textContent),
|
|
).toEqual(["JPA", "Authentication", "Kubernetes", "Redis"]);
|
|
// 주제 이름은 그 주제 화면으로 가는 링크다.
|
|
expect(screen.getByRole("link", { name: "JPA" })).toHaveAttribute("href", "/topics/jpa");
|
|
// 묶음 안에서는 원래 순서(게시 역순)를 그대로 지킨다.
|
|
expect(
|
|
within(screen.getByRole("main"))
|
|
.getAllByRole("listitem")
|
|
.map((item) => within(item).getByRole("link").getAttribute("href")),
|
|
).toEqual([
|
|
"/cases/collection-fetch-join-pagination",
|
|
"/references/jpa-list-fetch-strategy",
|
|
"/questions/collection-fetch-join-with-pagination",
|
|
"/references/state-and-nonce-boundary",
|
|
"/questions/validate-edge-token-again",
|
|
"/concepts/kubernetes-scheduling",
|
|
"/cases/redis-adapter-ttl-boundary",
|
|
]);
|
|
});
|
|
|
|
it("renders the distinct no-result state for an unmatched query filter", async () => {
|
|
await renderDiscoveryRoute("TECH_LOG_EXPLORE", "/explore?topic=missing");
|
|
|
|
expect(screen.getByText("0개의 공개 기록")).toBeVisible();
|
|
expect(screen.getByText("조건에 맞는 공개 기록이 없습니다.")).toHaveClass(
|
|
"public-empty-state",
|
|
);
|
|
expect(screen.queryByRole("list", { name: "공개 기록" })).not.toBeInTheDocument();
|
|
expect(screen.getByRole("link", { name: "필터 초기화" })).toHaveAttribute(
|
|
"href",
|
|
"/explore",
|
|
);
|
|
});
|
|
|
|
it("keeps kind-specific copy, filtering, count, ordering, and back navigation", async () => {
|
|
await renderDiscoveryRoute(
|
|
"TECH_LOG_EXPLORE_KIND",
|
|
"/explore/questions?topic=JPA&project=backend-skeleton",
|
|
);
|
|
|
|
expect(
|
|
screen.getByRole("heading", { level: 1, name: "열린 질문" }),
|
|
).toBeVisible();
|
|
expect(
|
|
screen.getByText("확인한 사실과 미지수, 다음 검증을 공개적으로 추적합니다."),
|
|
).toBeVisible();
|
|
expect(screen.queryByLabelText("유형")).not.toBeInTheDocument();
|
|
expect(screen.getByText("1개의 공개 기록")).toBeVisible();
|
|
expect(
|
|
screen.getByRole("link", { name: /컬렉션 Fetch Join을 유지하면서 페이징할 수 있는가/ }),
|
|
).toHaveAttribute("href", "/questions/collection-fetch-join-with-pagination");
|
|
expect(
|
|
screen.getByRole("link", { name: "전체 탐색으로 돌아가기" }),
|
|
).toHaveAttribute("href", "/explore");
|
|
});
|
|
|
|
it("keeps the unreachable unknown-kind client fallback accessible", async () => {
|
|
const { router, container } = await renderDiscoveryRoute(
|
|
"TECH_LOG_EXPLORE_KIND",
|
|
"/explore/unknown",
|
|
);
|
|
|
|
expect(router.state.location.pathname).toBe("/explore/unknown");
|
|
expect(
|
|
await screen.findByRole("heading", { name: "페이지를 찾을 수 없습니다." }),
|
|
).toBeVisible();
|
|
expect(
|
|
screen.queryByRole("heading", { name: "화면을 표시하지 못했습니다." }),
|
|
).not.toBeInTheDocument();
|
|
expect(container.querySelector(".site-frame")).not.toBeNull();
|
|
});
|
|
|
|
it("recovers a rejecting registered not-found runtime under its own chunk contract", async () => {
|
|
let rejectNotFound: ((reason?: unknown) => void) | undefined;
|
|
const LazyNotFound = lazy(
|
|
() =>
|
|
new Promise<{ default: typeof NotFoundPage }>((_resolve, reject) => {
|
|
rejectNotFound = reject;
|
|
}),
|
|
);
|
|
const notFoundChunkRead = vi.fn(() => "assets/not-found.js");
|
|
const exploreKindChunkRead = vi.fn(() => "assets/explore-kind.js");
|
|
const routeChunks = {
|
|
get "route-not-found"() {
|
|
return notFoundChunkRead();
|
|
},
|
|
get "route-tech-log-explore-kind"() {
|
|
return exploreKindChunkRead();
|
|
},
|
|
};
|
|
const release = {
|
|
buildId: "task-7-test-build",
|
|
releaseId: "task-7-test-release",
|
|
configSchemaVersion: "1",
|
|
apiContractVersion: "1",
|
|
assetManifestHash: "task-7-test-hash",
|
|
routeChunks,
|
|
};
|
|
const record = vi.fn();
|
|
const techLog = createTechLogFeatureInstalledInput(MOCK_STUDIO_INSTALL_CONTEXT).input;
|
|
const application = createTestApplication({
|
|
diagnostics: { record },
|
|
releaseInfo: {
|
|
getCurrent: async () => release,
|
|
refresh: async () => release,
|
|
},
|
|
featureInputs: { "tech-log": techLog },
|
|
});
|
|
const { router, container } = await renderDiscoveryRoute(
|
|
"TECH_LOG_EXPLORE_KIND",
|
|
"/explore/unknown",
|
|
{ NotFoundComponent: LazyNotFound, application },
|
|
);
|
|
|
|
expect(
|
|
screen.getByText("화면을 준비하고 있습니다.").closest("section"),
|
|
).toHaveAttribute("data-surface", "none");
|
|
await waitFor(() => expect(rejectNotFound).toBeTypeOf("function"));
|
|
await act(async () => {
|
|
rejectNotFound?.(
|
|
new TypeError("Failed to fetch dynamically imported module"),
|
|
);
|
|
});
|
|
|
|
expect(
|
|
await screen.findByRole("heading", {
|
|
name: "화면 자산을 복구하지 못했습니다.",
|
|
}),
|
|
).toBeVisible();
|
|
expect(notFoundChunkRead).toHaveBeenCalledOnce();
|
|
expect(exploreKindChunkRead).not.toHaveBeenCalled();
|
|
expect(router.state.location.pathname).toBe("/explore/unknown");
|
|
expect(container.querySelector(".site-frame")).not.toBeNull();
|
|
expect(
|
|
screen.queryByRole("heading", { name: "화면을 표시하지 못했습니다." }),
|
|
).not.toBeInTheDocument();
|
|
|
|
const routeChangedRecords = record.mock.calls
|
|
.map(([entry]) => entry)
|
|
.filter((entry) => entry.eventId === "route.changed");
|
|
expect(routeChangedRecords).toEqual([
|
|
expect.objectContaining({
|
|
context: expect.objectContaining({
|
|
route_id: "TECH_LOG_EXPLORE_KIND",
|
|
}),
|
|
}),
|
|
]);
|
|
expect(
|
|
record.mock.calls.some(([entry]) => entry.eventId === "ui.render.failed"),
|
|
).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe("TechLog search discovery", () => {
|
|
it("normalizes repeated queries, preserves result ordering, and navigates canonically", async () => {
|
|
const user = userEvent.setup();
|
|
const { router } = await renderDiscoveryRoute(
|
|
"TECH_LOG_SEARCH",
|
|
"/search?q=%20JPA%20&q=Redis&unknown=drop",
|
|
);
|
|
|
|
await waitFor(() => {
|
|
expect(router.state.location.search).toBe("?q=JPA");
|
|
});
|
|
expect(screen.getByRole("searchbox", { name: "검색어" })).toHaveValue("JPA");
|
|
expect(screen.getByRole("heading", { name: "“JPA” 검색 결과" })).toBeVisible();
|
|
expect(screen.getByText("4개의 검색 결과")).toBeVisible();
|
|
expect(
|
|
screen.getAllByRole("listitem").map((item) =>
|
|
within(item).queryByRole("link")?.getAttribute("href"),
|
|
),
|
|
).toEqual([
|
|
"/cases/collection-fetch-join-pagination",
|
|
"/references/jpa-list-fetch-strategy",
|
|
"/questions/collection-fetch-join-with-pagination",
|
|
"/projects/backend-skeleton",
|
|
]);
|
|
|
|
await user.click(
|
|
screen.getByRole("link", { name: /JPA 목록 조회에서 Fetch 전략을 선택하는 기준/ }),
|
|
);
|
|
expect(router.state.location.pathname).toBe("/references/jpa-list-fetch-strategy");
|
|
});
|
|
|
|
it("submits from the keyboard and synchronizes the searchbox with URL changes", async () => {
|
|
const user = userEvent.setup();
|
|
const { router } = await renderDiscoveryRoute("TECH_LOG_SEARCH", "/search");
|
|
const input = await screen.findByRole("searchbox", { name: "검색어" });
|
|
|
|
await user.type(input, "Redis{Enter}");
|
|
await waitFor(() => {
|
|
expect(router.state.location.search).toBe("?q=Redis");
|
|
});
|
|
expect(screen.getByRole("heading", { name: "“Redis” 검색 결과" })).toBeVisible();
|
|
expect(screen.getByText("2개의 검색 결과")).toBeVisible();
|
|
|
|
await router.navigate("/search?q=Keycloak");
|
|
await waitFor(() => {
|
|
expect(screen.getByRole("searchbox", { name: "검색어" })).toHaveValue(
|
|
"Keycloak",
|
|
);
|
|
});
|
|
expect(screen.getByText("1개의 검색 결과")).toBeVisible();
|
|
});
|
|
|
|
it("normalizes an explicitly empty first query and renders all canonical results", async () => {
|
|
const { router } = await renderDiscoveryRoute(
|
|
"TECH_LOG_SEARCH",
|
|
"/search?q=%20%20&q=JPA",
|
|
);
|
|
|
|
await waitFor(() => {
|
|
expect(router.state.location.search).toBe("");
|
|
});
|
|
expect(await screen.findByRole("heading", { name: "전체 검색 결과" })).toBeVisible();
|
|
expect(screen.getByText("10개의 검색 결과")).toBeVisible();
|
|
expect(screen.getByRole("searchbox", { name: "검색어" })).toHaveValue("");
|
|
});
|
|
|
|
it("renders the exact zero-result state without a result list", async () => {
|
|
await renderDiscoveryRoute("TECH_LOG_SEARCH", "/search?q=존재하지않음");
|
|
|
|
expect(screen.getByText("0개의 검색 결과")).toBeVisible();
|
|
expect(screen.getByText("일치하는 공개 기록이 없습니다.")).toHaveClass(
|
|
"public-empty-state",
|
|
);
|
|
expect(within(screen.getByRole("main")).queryByRole("list")).toBeNull();
|
|
});
|
|
});
|
|
|
|
describe("home focus domain", () => {
|
|
it("normalizes selection and wraps all supported keyboard movements", async () => {
|
|
const keys = ["current", "question", "decision"] as const;
|
|
|
|
expect(normalizeFocus(undefined, keys)).toBe("current");
|
|
expect(normalizeFocus("missing", keys)).toBe("current");
|
|
expect(normalizeFocus("question", keys)).toBe("question");
|
|
expect(normalizeFocus("question", [])).toBeNull();
|
|
expect(shouldNormalizeFocusUrl(undefined, "current")).toBe(false);
|
|
expect(shouldNormalizeFocusUrl("", "current")).toBe(true);
|
|
expect(moveFocus("current", "ArrowLeft", keys)).toBe("decision");
|
|
expect(moveFocus("decision", "ArrowRight", keys)).toBe("current");
|
|
expect(moveFocus("question", "Home", keys)).toBe("current");
|
|
expect(moveFocus("question", "End", keys)).toBe("decision");
|
|
});
|
|
});
|