홈(`src/presentation/pages/home-page.tsx`)이 페이지 템플릿 대신 자기 `section.ui-page`와 `PageHeader`를 쓰고, 시작 링크를 `<Link className="ui-button …">`으로 `LinkButton`을 손으로 다시 만든다. `PRODUCT.md`는 홈이 파생 서비스에 남는다고 적는다. 그래서 그대로 복제되고 개발자가 따라 하는 예가 된다. `LinkButton`의 variant·size가 바뀌면 홈만 어긋난다. 고른 방법: `StandardPage`(heading 슬롯에 eyebrow·제목·설명)와 `LinkButton variant="primary"/"secondary"`로 바꾼다. 준비 목록, 런타임 요약, 시작 링크는 템플릿의 본문 자리에 `home-page__sections`(블록 사이 `--space-6`)로 묶어 둔다. 템플릿 본문 자리에는 간격이 없어, 묶지 않으면 런타임 요약이 카드에 붙는다(첫 골든에서 보고 고쳤다). component 시험이 홈의 링크가 standard 템플릿 안의 `ui-button ui-button--primary`인지 본다. 위험·한계: 머리말과 본문 사이는 템플릿 간격(`--space-5`)이라 홈의 세로 간격이 조금 바뀐다. 시각 골든은 이 커밋에서 다시 찍고 이유를 PR 본문에 적는다. 홈이 템플릿과 `LinkButton`을 쓰면서 번들러가 청크 둘을 합쳤다. 초기 JS는 파일 17 → 15개, gzip 194,397 → 194,143 B, Service Worker precache 자산은 24 → 22개다. `config/scale/feature-shape-ceilings.json`은 측정 스크립트 (`node scripts/scale/measure-feature-shape-growth.ts --initial-baseline --write`, desktop)가 쓴 그대로다. 검증: `tests/component/starter-pages.test.tsx`와 시각 골든은 desktop에서 돌린다(PR 본문). Refs: 1112/04-06
106 lines
3.7 KiB
TypeScript
106 lines
3.7 KiB
TypeScript
// @vitest-environment jsdom
|
|
|
|
import { render, screen, waitFor } from "@testing-library/react";
|
|
import userEvent from "@testing-library/user-event";
|
|
import { MemoryRouter } from "react-router-dom";
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
import { formatMessage, LocaleProvider } from "../../src/presentation/i18n/index.ts";
|
|
import HomePage from "../../src/presentation/pages/home-page.tsx";
|
|
import { ApplicationProvider } from "../../src/presentation/providers/application-provider.tsx";
|
|
import { PreferenceProviders } from "../../src/presentation/providers/preference-providers.tsx";
|
|
import { AppRouter } from "../../src/presentation/routes/app-router.tsx";
|
|
import { createTestApplication } from "../helpers/create-test-application.ts";
|
|
|
|
/**
|
|
* The starter screens (`/` and `/examples/platform`) are the template's
|
|
* content, not the platform (0929/10-02). A product that replaces them deletes
|
|
* the `starter-*.test.tsx` files with them; the platform tests run on the
|
|
* test-only feature's pages and keep passing. 1103/09-04: the other example
|
|
* screens are a removable feature, tested in its own test folder.
|
|
*/
|
|
|
|
function renderApp(
|
|
url: string,
|
|
application = createTestApplication(),
|
|
) {
|
|
window.history.pushState({}, "", url);
|
|
return render(
|
|
<ApplicationProvider application={application}>
|
|
<PreferenceProviders>
|
|
<AppRouter />
|
|
</PreferenceProviders>
|
|
</ApplicationProvider>,
|
|
);
|
|
}
|
|
|
|
describe("starter home page", () => {
|
|
// 1112/05-15. A generic div's aria-label is dropped by assistive technology;
|
|
// the readiness list is a named group.
|
|
it("names the readiness list as a group", async () => {
|
|
renderApp("/");
|
|
|
|
expect(
|
|
await screen.findByRole("group", { name: formatMessage("ko-KR", "home.readiness") }),
|
|
).toBeVisible();
|
|
});
|
|
|
|
// 1112/04-06. The home page a product keeps is an example of the page
|
|
// templates and primitives, not of hand-made copies of them.
|
|
it("lays the home page out with the standard template and link buttons", async () => {
|
|
const { container } = renderApp("/");
|
|
|
|
const action = await screen.findByRole("link", { name: "플랫폼 구성 보기" });
|
|
expect(action.closest("article.page-template--standard")).not.toBeNull();
|
|
expect(action).toHaveClass("ui-button", "ui-button--primary");
|
|
expect(container.querySelectorAll("section.ui-page")).toHaveLength(0);
|
|
});
|
|
|
|
it("reaches the platform overview from the starter actions", async () => {
|
|
const user = userEvent.setup();
|
|
renderApp("/");
|
|
|
|
await user.click(
|
|
await screen.findByRole("link", { name: "플랫폼 구성 보기" }),
|
|
);
|
|
|
|
await waitFor(() =>
|
|
expect(
|
|
screen.getByRole("heading", { name: "플랫폼 구성", level: 1 }),
|
|
).toHaveFocus(),
|
|
);
|
|
});
|
|
|
|
it("stops the release summary from loading forever", async () => {
|
|
render(
|
|
<ApplicationProvider
|
|
application={createTestApplication({
|
|
releaseInfo: {
|
|
getCurrent: async () => {
|
|
throw new Error("manifest unavailable");
|
|
},
|
|
refresh: async () => {
|
|
throw new Error("manifest unavailable");
|
|
},
|
|
},
|
|
})}
|
|
>
|
|
<LocaleProvider>
|
|
{/* HomePage renders router links, so it needs a router but not the app one. */}
|
|
<MemoryRouter>
|
|
<HomePage />
|
|
</MemoryRouter>
|
|
</LocaleProvider>
|
|
</ApplicationProvider>,
|
|
);
|
|
await waitFor(() =>
|
|
expect(
|
|
screen.getByText("런타임 정보를 확인하지 못했습니다."),
|
|
).toBeVisible(),
|
|
);
|
|
expect(
|
|
screen.queryByText("검증된 런타임 정보를 확인하고 있습니다."),
|
|
).not.toBeInTheDocument();
|
|
});
|
|
});
|