Carries 359 template commits, tag v0.2.0 plus one documentation commit: the generator-built feature index with its app, bounded-context and feature declarations, the src/platform kernel and scale tooling, the 2026-09-24 src review fixes, and the 2026-09-25 maturity review round with its CHANGELOG [보안]/[계약] rows. 691 of the 824 template paths are applied, 85 of them merged with product changes; 127 are not carried. Product identity is unchanged: name, version 0.1.0, routes, design and the TechLog domain. Three decisions worth naming. TechLog stays composed directly, as the last two syncs recorded; its directory carries a NOT_INSTALLED marker that says so, and every installed-* composer takes the template's projection with TechLog added on top. The reference sample is no longer installed: the template now installs a feature only through feature-module.ts and context-routes.ts, which load the screens this product deleted, so its three operations, six schemas and one topic leave the registries, recorded as registry change evidence. And AppRouter mounts the platform and TechLog routes only; the template's bounded-context route gateway waits for a generator-installed feature. Required fixes: readSubject on the BFF session owner (without it every HTTP Studio session would close as integration-failed), zod through the facade in nine TechLog files, noUnusedLocals, and public/config.json written out to match the local profile. Derived baselines were recomputed after reproducing both sides' values: CI contract 101 commands / 106 references / 141 artifacts, gate shape c9adcf85; registry approval 2dc6c3a3; the runtime config schema baseline equals the schema at8210d48. Verified here: types, lint, architecture, adapter inventory, CI contract, i18n, design system, diagnostics, browser security, dev release manifest, TechLog contract and build pass; 220 component, 155 integration, 15 contract, 418 TechLog, 43 reference-feature, 18 recipe and 46 release-coherence tests pass, and 2381 of 2383 unit tests. Reproduced at8210d48first and unchanged: check:registries (byte-identical), test:runtime-schema, verify:documentation. Brought by the template and escalated rather than suppressed: check:request-fanout on TechLog's cursor pagination, check:remediation-ledger (fails upstream too), the shared-chunk hash test, and the registry-dependent sample removal and second-feature tests. Playwright suites were not run. Full record, the five open questions and the follow-ups in docs/operations/template-sync-2026-09-29.md. (cherry picked from commit b2170cf265dea45dc9cc05d3c61e627e97f31cdb)
169 lines
8.1 KiB
TypeScript
169 lines
8.1 KiB
TypeScript
// @vitest-environment jsdom
|
|
|
|
import { render, screen, waitFor, within } from "@testing-library/react";
|
|
import userEvent from "@testing-library/user-event";
|
|
import { Outlet, RouterProvider, createMemoryRouter } from "react-router-dom";
|
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
|
|
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 type { StudioGateway } from "../../../src/features/tech-log/application/ports/studio-gateway.ts";
|
|
import { StudioHomePage } from "../../../src/features/tech-log/presentation/studio/pages/studio-home-page.tsx";
|
|
import { StudioNotFoundPage } from "../../../src/features/tech-log/presentation/studio/pages/studio-not-found-page.tsx";
|
|
import { StudioShell } from "../../../src/features/tech-log/presentation/studio/studio-shell.tsx";
|
|
import { createExternalAuthSessionAdapter } from "../../../src/adapters/auth/external-session-adapter.ts";
|
|
import { ApplicationProvider } from "../../../src/presentation/providers/application-provider.tsx";
|
|
import { SessionProvider } from "../../../src/presentation/providers/session-provider.tsx";
|
|
import { createTestApplication } from "../../helpers/create-test-application.ts";
|
|
import { renderWithQueryProviders } from "../../helpers/query-providers.tsx";
|
|
|
|
import { studioGatewayFromApplication, withStudioGateway } from "../../helpers/studio-application-gateway-adapter.ts";
|
|
afterEach(() => vi.restoreAllMocks());
|
|
|
|
async function renderStudio(
|
|
initialEntry: string,
|
|
createStudioGateway: () => StudioGateway,
|
|
) {
|
|
const router = createMemoryRouter(
|
|
[
|
|
{
|
|
path: "/studio",
|
|
element: (
|
|
<StudioShell>
|
|
<Outlet />
|
|
</StudioShell>
|
|
),
|
|
children: [
|
|
{ index: true, element: <StudioHomePage /> },
|
|
{ path: "documents", element: <p>작업본 라우트</p> },
|
|
{ path: "documents/new", element: <p>새 문서 라우트</p> },
|
|
{ path: "publications", element: <p>게시 기록 라우트</p> },
|
|
{ path: "*", element: <StudioNotFoundPage /> },
|
|
],
|
|
},
|
|
],
|
|
{ initialEntries: [initialEntry] },
|
|
);
|
|
const installed = createTechLogFeatureInstalledInput(MOCK_STUDIO_INSTALL_CONTEXT).input;
|
|
const application = createTestApplication({
|
|
// The Studio shell draws its chrome only for an authenticated session — a
|
|
// signed-out visitor gets the sign-in surface and nothing else, which is
|
|
// what these tests are not about. In the real app AppRouter supplies both
|
|
// the session state and the provider; here the harness does.
|
|
session: createExternalAuthSessionAdapter({
|
|
readState: () => "authenticated" as const,
|
|
subscribe: () => () => {},
|
|
beginSignIn: async () => {},
|
|
signOut: async () => {},
|
|
attachCredential: async () => ({ headers: {} }),
|
|
recoverSession: async () => "restored" as const,
|
|
notifyUnauthenticated: () => {},
|
|
readSubject: () => "studio-shell-subject",
|
|
}),
|
|
featureInputs: {
|
|
"tech-log": {
|
|
...installed,
|
|
createStudioApplication: () =>
|
|
withStudioGateway(
|
|
installed.createStudioApplication(),
|
|
createStudioGateway(),
|
|
),
|
|
},
|
|
},
|
|
});
|
|
const view = render(
|
|
renderWithQueryProviders(
|
|
<ApplicationProvider application={application}>
|
|
<SessionProvider>
|
|
<RouterProvider router={router} />
|
|
</SessionProvider>
|
|
</ApplicationProvider>,
|
|
));
|
|
// 포트가 async 가 되면서 첫 페인트에는 데이터가 없다. 화면이 정착한 뒤
|
|
// 단언하도록 여기서 한 번 기다린다 — 각 테스트에 흩어 놓으면 빠뜨린 곳이 생긴다.
|
|
await screen.findByRole("main");
|
|
return { ...view, router };
|
|
}
|
|
|
|
describe("TechLog Studio shell", () => {
|
|
it("creates one application-provided gateway for child navigation and exposes the source header", async () => {
|
|
const user = userEvent.setup();
|
|
const gateway = studioGatewayFromApplication(createTechLogFeatureInstalledInput(MOCK_STUDIO_INSTALL_CONTEXT).input.createStudioApplication());
|
|
const createGateway = vi.fn(() => gateway);
|
|
|
|
const { container, router } = await renderStudio("/studio", createGateway);
|
|
|
|
expect(await screen.findByRole("heading", { level: 1, name: "작업 흐름" })).toBeVisible();
|
|
expect(createGateway).toHaveBeenCalledTimes(1);
|
|
expect(
|
|
Array.from(
|
|
container.querySelectorAll<HTMLAnchorElement>(".studio-desktop-navigation a"),
|
|
(link) => [link.textContent, link.getAttribute("href")],
|
|
),
|
|
/*
|
|
위에는 네 가지 일만 둔다. 목적지 여섯이 같은 무게로 늘어서 있으면, 묶음 이름으로 선을
|
|
그어도 처음 들어온 사람은 여섯 중 어디부터 가야 하는지를 스스로 판단해야 한다.
|
|
그 일 안의 화면은 일을 고른 뒤에 나타난다 — 여기서는 「작업」에 있으므로 작업본과 새 문서다.
|
|
*/
|
|
).toEqual([
|
|
["작업", "/studio/documents"],
|
|
["구조", "/studio/taxonomy"],
|
|
["자료", "/studio/assets"],
|
|
["게시", "/studio/publications"],
|
|
["작업본", "/studio/documents"],
|
|
["새 문서", "/studio/documents/new"],
|
|
["공개 사이트 보기", "/"],
|
|
]);
|
|
expect(screen.getByRole("link", { name: "공개 사이트 보기" })).toHaveAttribute("href", "/");
|
|
expect(screen.queryByText(/로그인|sign in/i)).not.toBeInTheDocument();
|
|
|
|
await user.click(within(screen.getByRole("navigation", { name: "Studio 주 탐색" })).getByRole("link", { name: "작업본" }));
|
|
|
|
expect(router.state.location.pathname).toBe("/studio/documents");
|
|
expect(screen.getByText("작업본 라우트")).toBeVisible();
|
|
expect(createGateway).toHaveBeenCalledTimes(1);
|
|
expect(screen.getAllByRole("link", { name: "작업본" })[0]).toHaveAttribute("aria-current", "page");
|
|
});
|
|
|
|
it("recreates the provider generation and cancels obsolete work after a persisted pageshow", async () => {
|
|
const user = userEvent.setup();
|
|
let firstSignal: AbortSignal | undefined;
|
|
const first = studioGatewayFromApplication(createTechLogFeatureInstalledInput(MOCK_STUDIO_INSTALL_CONTEXT).input.createStudioApplication());
|
|
const second = studioGatewayFromApplication(createTechLogFeatureInstalledInput(MOCK_STUDIO_INSTALL_CONTEXT).input.createStudioApplication());
|
|
vi.spyOn(first, "getDashboard").mockImplementation(({ signal } = {}) => {
|
|
firstSignal = signal;
|
|
return new Promise(() => {});
|
|
});
|
|
const secondDashboard = vi.spyOn(second, "getDashboard");
|
|
const createGateway = vi.fn()
|
|
.mockReturnValueOnce(first)
|
|
.mockReturnValueOnce(second);
|
|
|
|
await renderStudio("/studio", createGateway);
|
|
await waitFor(() => expect(firstSignal).toBeDefined());
|
|
await user.click(screen.getByRole("button", { name: "Studio 메뉴 열기" }));
|
|
expect(screen.getByRole("button", { name: "Studio 메뉴 닫기" })).toBeVisible();
|
|
|
|
window.dispatchEvent(new PageTransitionEvent("pageshow", { persisted: true }));
|
|
|
|
await waitFor(() => expect(createGateway).toHaveBeenCalledTimes(2));
|
|
expect(firstSignal?.aborted).toBe(true);
|
|
expect(screen.getByRole("button", { name: "Studio 메뉴 열기" })).toHaveAttribute("aria-expanded", "false");
|
|
expect(await screen.findByRole("heading", { level: 1, name: "작업 흐름" })).toBeVisible();
|
|
expect(secondDashboard).toHaveBeenCalledTimes(1);
|
|
});
|
|
|
|
it("keeps unknown Studio routes inside the Studio shell without authentication UI", async () => {
|
|
const createGateway = vi.fn(
|
|
() => studioGatewayFromApplication(createTechLogFeatureInstalledInput(MOCK_STUDIO_INSTALL_CONTEXT).input.createStudioApplication()),
|
|
);
|
|
|
|
await renderStudio("/studio/does-not-exist", createGateway);
|
|
|
|
expect(screen.getByRole("banner")).toHaveClass("studio-header");
|
|
expect(screen.getByRole("heading", { level: 1, name: "Studio 화면을 찾을 수 없습니다" })).toBeVisible();
|
|
expect(screen.getByRole("link", { name: "작업본으로 돌아가기" })).toHaveAttribute("href", "/studio/documents");
|
|
expect(screen.queryByText(/로그인|sign in/i)).not.toBeInTheDocument();
|
|
});
|
|
});
|