feat: complete TechLog Studio publication flow

This commit is contained in:
DongHyeonka
2026-08-16 00:35:11 +09:00
parent 9c6906fc6f
commit c5c8b9423c
60 changed files with 2028 additions and 2948 deletions
@@ -1,164 +0,0 @@
// @vitest-environment jsdom
import { render, screen, waitFor, within } from "@testing-library/react";
import { describe, expect, it } from "vitest";
import { SERVER_STATE_PROFILES } from "../../src/contracts/server-state.ts";
import { COMPOSED_CONTRACT_CONTRIBUTIONS } from "../../src/features/installed-contract-contributions.ts";
import { ROUTE_REGISTRY } from "../../src/features/installed-feature-contracts.ts";
import PlatformOverviewPage from "../../src/presentation/examples/platform-overview-page.tsx";
import { LocaleProvider } from "../../src/presentation/i18n/index.ts";
import { ApplicationProvider } from "../../src/presentation/providers/application-provider.tsx";
import { createTestApplication } from "../helpers/create-test-application.ts";
import { createRuntimeCapabilitiesStub } from "../helpers/runtime-capabilities-stub.ts";
/**
* The page must stay a projection of the installed registries. Every assertion
* below derives its expectation from the same registry the page reads, so a
* template that removes its sample feature still satisfies this suite.
*/
function renderPage() {
return render(
<ApplicationProvider application={createTestApplication()}>
<LocaleProvider>
<PlatformOverviewPage />
</LocaleProvider>
</ApplicationProvider>,
);
}
function tableByCaption(caption: string): HTMLElement {
return screen.getByRole("table", { name: caption });
}
/** A metric is a `dt`/`dd` pair, which carries no ARIA role to query by. */
function metricByLabel(scope: HTMLElement, label: string): HTMLElement {
const term = within(scope).getByText(label).closest(".platform-metric");
if (!(term instanceof HTMLElement)) {
throw new Error(`No metric is labelled ${label}`);
}
return term;
}
describe("platform overview page", () => {
it("renders one route row per installed route registry entry", () => {
renderPage();
const table = tableByCaption("설치된 라우트 목록");
const dataRows = within(table).getAllByRole("row").slice(1);
expect(dataRows).toHaveLength(Object.keys(ROUTE_REGISTRY).length);
for (const definition of Object.values(ROUTE_REGISTRY)) {
expect(
within(table).getByText(definition.routeId),
).toBeInTheDocument();
}
});
it("renders one operation row per installed HTTP contract", () => {
const operationIds = [
...COMPOSED_CONTRACT_CONTRIBUTIONS.httpByOperationId.keys(),
];
renderPage();
if (operationIds.length === 0) {
expect(
screen.getByRole("heading", {
name: "설치된 HTTP 오퍼레이션이 없습니다.",
}),
).toBeVisible();
return;
}
const table = tableByCaption("설치된 HTTP 오퍼레이션");
expect(within(table).getAllByRole("row").slice(1)).toHaveLength(
operationIds.length,
);
for (const operationId of operationIds) {
expect(within(table).getByText(operationId)).toBeInTheDocument();
}
});
it("renders every fixed server-state profile with its own budget", () => {
renderPage();
const table = tableByCaption("서버 상태 프로파일");
for (const profile of Object.values(SERVER_STATE_PROFILES)) {
expect(within(table).getByText(profile.profileId)).toBeInTheDocument();
}
expect(within(table).getAllByRole("row").slice(1)).toHaveLength(
Object.keys(SERVER_STATE_PROFILES).length,
);
});
it("labels a capability that was never selected as unselected", () => {
renderPage();
const region = screen.getByRole("region", { name: "선택적 런타임 능력" });
expect(within(region).getAllByText("미선택")).toHaveLength(4);
expect(within(region).queryByText("운영자가 비활성화함")).toBeNull();
});
it("separates an operator disable from a capability that was never selected", () => {
render(
<ApplicationProvider
application={createTestApplication({
runtimeCapabilities: createRuntimeCapabilitiesStub({
SERVICE_WORKER: { selected: 1, active: 0, override: "DISABLED" },
OFFLINE_COMMANDS: { selected: 1, active: 1 },
}),
})}
>
<LocaleProvider>
<PlatformOverviewPage />
</LocaleProvider>
</ApplicationProvider>,
);
const region = screen.getByRole("region", { name: "선택적 런타임 능력" });
expect(within(region).getByText("운영자가 비활성화함")).toBeVisible();
expect(within(region).getByText("활성 (1)")).toBeVisible();
expect(within(region).getAllByText("미선택")).toHaveLength(2);
});
it("counts installed contract packages separately from template fixtures", () => {
const fixtures = COMPOSED_CONTRACT_CONTRIBUTIONS.contributions.filter(
(contribution) => contribution.source.kind === "TEMPLATE_FIXTURE",
).length;
renderPage();
const summary = screen.getByRole("region", { name: "설치 요약" });
const packages = metricByLabel(summary, "외부 계약 패키지");
expect(
within(packages).getByText(
`${COMPOSED_CONTRACT_CONTRIBUTIONS.externalPackages.length}`,
),
).toBeVisible();
expect(
within(packages).getByText(`템플릿 픽스처 ${fixtures}`),
).toBeVisible();
expect(
within(metricByLabel(summary, "라우트")).getByText(
`${Object.keys(ROUTE_REGISTRY).length}`,
),
).toBeVisible();
});
it("renders the verified release identity once the runtime resolves it", async () => {
renderPage();
const region = screen.getByRole("region", { name: "릴리스 신원" });
await waitFor(() =>
expect(
within(metricByLabel(region, "빌드")).getByText("test-build"),
).toBeVisible(),
);
expect(
within(metricByLabel(region, "릴리스")).getByText("test-release"),
).toBeVisible();
});
});
+42 -59
View File
@@ -1,6 +1,6 @@
// @vitest-environment jsdom
import { render, screen, waitFor } from "@testing-library/react";
import { render, screen, waitFor, within } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { describe, expect, expectTypeOf, it } from "vitest";
import { z } from "zod";
@@ -12,6 +12,8 @@ import {
} from "react-router-dom";
import { createAnonymousSessionAdapter } from "../../src/adapters/auth/external-session-adapter.ts";
import { createTechLogFeatureInstalledInput } from "../../src/features/tech-log/adapters/create-tech-log-feature-input.ts";
import { TECH_LOG_FEATURE_ID } from "../../src/features/tech-log/application/tech-log-feature-input.ts";
import { ApplicationProvider } from "../../src/presentation/providers/application-provider.tsx";
import {
AppRouter,
@@ -54,7 +56,7 @@ const groupedFixtureCodecs = Object.freeze({
const reviewFixtureRegistry = Object.freeze({
REVIEW_FIXTURE: Object.freeze({
...ROUTE_REGISTRY.APP_HOME,
...ROUTE_REGISTRY.TECH_LOG_HOME,
routeId: "REVIEW_FIXTURE",
path: "/review/:reviewId",
paramsSchema: "ReviewFixtureParams",
@@ -100,10 +102,12 @@ function compileTimeGroupedRouteContract() {
void compileTimeGroupedRouteContract;
function renderRouter() {
const techLog = createTechLogFeatureInstalledInput();
return render(
<ApplicationProvider
application={createTestApplication({
session: createAnonymousSessionAdapter(),
featureInputs: { [TECH_LOG_FEATURE_ID]: techLog.input },
})}
>
<AppRouter />
@@ -159,7 +163,7 @@ describe("generic application router", () => {
it("assembles generic Public and Studio parents with Studio catch-all precedence", () => {
const registry = {
APP_HOME: ROUTE_REGISTRY.APP_HOME,
TECH_LOG_HOME: ROUTE_REGISTRY.TECH_LOG_HOME,
STUDIO_FIXTURE: {
...ROUTE_REGISTRY.NOT_FOUND,
routeId: "STUDIO_FIXTURE",
@@ -169,7 +173,7 @@ describe("generic application router", () => {
NOT_FOUND: ROUTE_REGISTRY.NOT_FOUND,
};
const runtime = {
APP_HOME: ROUTE_RUNTIME.APP_HOME,
TECH_LOG_HOME: ROUTE_RUNTIME.TECH_LOG_HOME,
STUDIO_FIXTURE: ROUTE_RUNTIME.NOT_FOUND,
NOT_FOUND: ROUTE_RUNTIME.NOT_FOUND,
};
@@ -220,7 +224,7 @@ describe("generic application router", () => {
"test-build",
groupedFixtureCodecs,
),
).toThrow("Missing route runtime: APP_HOME");
).toThrow("Missing route runtime: TECH_LOG_HOME");
});
it("renders a non-installed Studio wildcard leaf without rewriting its URL", async () => {
@@ -277,10 +281,11 @@ describe("generic application router", () => {
const routes = createGroupedRouteObjects(
{
PROTECTED_FIXTURE: {
...ROUTE_REGISTRY.APP_HOME,
...ROUTE_REGISTRY.TECH_LOG_HOME,
routeId: "PROTECTED_FIXTURE",
path: "/private-fixture",
access: "session-required",
searchSchema: null,
},
},
{
@@ -317,89 +322,67 @@ describe("generic application router", () => {
).toBeVisible();
});
it("reaches the platform overview from the home starter actions", async () => {
it("renders the installed TechLog home in the Public layout", async () => {
const user = userEvent.setup();
window.history.pushState({}, "", "/");
renderRouter();
// The starter action lives inside the lazily loaded home chunk, so this is
// the first wait in the file that has to outlast a chunk load rather than
// an already-mounted shell element.
expect(
await screen.findByRole("heading", { name: "TechLog", level: 1 }),
).toBeVisible();
expect(screen.getByRole("navigation", { name: "주요 탐색" })).toBeVisible();
await user.click(
await screen.findByRole(
within(screen.getByRole("navigation", { name: "주요 탐색" })).getByRole(
"link",
{ name: "플랫폼 구성 보기" },
{ timeout: 5000 },
{ name: "프로젝트" },
),
);
await waitFor(() =>
expect(
screen.getByRole("heading", { name: "플랫폼 구성", level: 1 }),
).toHaveFocus(),
);
expect(
await screen.findByRole("heading", { name: "프로젝트", level: 1 }),
).toBeVisible();
expect(window.location.pathname).toBe("/projects");
});
it("renders the app shell and not-found route without a feature input", async () => {
it("renders the Public shell and TechLog not-found route", async () => {
window.history.pushState({}, "", "/missing");
renderRouter();
expect(
await screen.findByRole("heading", {
name: "페이지를 찾을 수 없습니다.",
name: "404",
level: 1,
}),
).toBeVisible();
expect(screen.getByRole("navigation", { name: "주요 탐색" })).toBeVisible();
expect(screen.getByRole("main")).toBeVisible();
});
it("preserves authorization around grouped registered leaves", async () => {
window.history.pushState({}, "", "/examples/reference-resources");
renderRouter();
expect(
await screen.findByRole("heading", { name: "세션이 필요합니다." }),
screen.getByRole("heading", { name: "This page could not be found." }),
).toBeVisible();
expect(screen.getByRole("navigation", { name: "주요 탐색" })).toBeVisible();
});
it("navigates between registry-backed platform routes", async () => {
const user = userEvent.setup();
window.history.pushState({}, "", "/");
it("keeps Studio routes inside the persistent Studio layout", async () => {
window.history.pushState({}, "", "/studio");
renderRouter();
await user.click(
await screen.findByRole("link", { name: "UI 구성요소" }),
);
expect(
await screen.findByRole("heading", { name: "UI 구성요소", level: 1 }),
await screen.findByRole("heading", { name: "작업 흐름" }),
).toBeVisible();
expect(window.location.pathname).toBe("/examples/ui");
expect(document.title).toBe("UI 구성요소 · Tech Log");
await waitFor(() =>
expect(
screen.getByRole("heading", { name: "UI 구성요소", level: 1 }),
).toHaveFocus(),
expect(screen.getByRole("navigation", { name: "Studio 주 탐색" })).toBeVisible();
expect(screen.getByRole("link", { name: "공개 사이트 보기" })).toHaveAttribute(
"href",
"/",
);
});
it("focuses the route heading again when the lazy chunk is already cached", async () => {
// §9.7. The first visit resolves the route module asynchronously, so the
// router lifecycle and the page header commit separately. A later visit
// renders the cached module in the same commit, which is the ordering that
// must still hand focus to the heading rather than leaving it on main.
const user = userEvent.setup();
window.history.pushState({}, "", "/");
it("gives the Studio wildcard precedence over the Public not-found route", async () => {
window.history.pushState({}, "", "/studio/missing");
renderRouter();
for (const label of ["UI 구성요소", "화면 상태", "UI 구성요소"]) {
await user.click(await screen.findByRole("link", { name: label }));
await waitFor(() =>
expect(
screen.getByRole("heading", { name: label, level: 1 }),
).toHaveFocus(),
);
}
expect(
await screen.findByRole("heading", {
name: "Studio 화면을 찾을 수 없습니다",
}),
).toBeVisible();
expect(screen.getByRole("navigation", { name: "Studio 주 탐색" })).toBeVisible();
expect(window.location.pathname).toBe("/studio/missing");
});
});
+31 -7
View File
@@ -31,10 +31,32 @@ const releaseManifest = {
releaseId: "local-release",
builtAt: "2026-07-26T00:00:00.000Z",
routeChunks: {
"route-home": "assets/home.js",
"route-examples-ui": "assets/ui.js",
"route-examples-states": "assets/states.js",
"route-examples-auth": "assets/auth.js",
"route-tech-log-home": "assets/tech-log-home.js",
"route-tech-log-explore": "assets/tech-log-explore.js",
"route-tech-log-explore-kind": "assets/tech-log-explore-kind.js",
"route-tech-log-case": "assets/tech-log-case.js",
"route-tech-log-reference": "assets/tech-log-reference.js",
"route-tech-log-question": "assets/tech-log-question.js",
"route-tech-log-topic": "assets/tech-log-topic.js",
"route-tech-log-projects": "assets/tech-log-projects.js",
"route-tech-log-project": "assets/tech-log-project.js",
"route-tech-log-project-records": "assets/tech-log-project-records.js",
"route-tech-log-project-decisions": "assets/tech-log-project-decisions.js",
"route-tech-log-project-activity": "assets/tech-log-project-activity.js",
"route-tech-log-releases": "assets/tech-log-releases.js",
"route-tech-log-release": "assets/tech-log-release.js",
"route-tech-log-profile": "assets/tech-log-profile.js",
"route-tech-log-search": "assets/tech-log-search.js",
"route-tech-log-studio-home": "assets/tech-log-studio-home.js",
"route-tech-log-studio-documents": "assets/tech-log-studio-documents.js",
"route-tech-log-studio-document-new": "assets/tech-log-studio-document-new.js",
"route-tech-log-studio-document-edit": "assets/tech-log-studio-document-edit.js",
"route-tech-log-studio-document-validation": "assets/tech-log-studio-document-validation.js",
"route-tech-log-studio-document-preview": "assets/tech-log-studio-document-preview.js",
"route-tech-log-studio-document-publish": "assets/tech-log-studio-document-publish.js",
"route-tech-log-studio-publications": "assets/tech-log-studio-publications.js",
"route-tech-log-studio-publication-preview": "assets/tech-log-studio-publication-preview.js",
"route-tech-log-studio-not-found": "assets/tech-log-studio-not-found.js",
"route-not-found": "assets/not-found.js",
},
};
@@ -62,12 +84,14 @@ describe("production runtime application tree", () => {
expect(
await screen.findByRole("heading", {
name: "Tech Log",
name: "TechLog",
}),
).toBeVisible();
expect(
await screen.findByText("빌드 local-build · 릴리스 local-release"),
).toBeVisible();
await screen.findAllByText(
"문제를 재현하고 검증해 운영 가능한 설계로 연결합니다.",
),
).toHaveLength(2);
expect(fetcher).toHaveBeenCalledTimes(2);
expect(composition).not.toHaveProperty("ports");
});