소유자 결정(2026-11-07, design-docs repo-structure/README.md 3.4절)으로 템플릿 샘플을 지운다. 샘플이 맡던 시험 대상은 앞 커밋들이 옮겼다. 참조 기능과 예제 화면, 두 context, 그 시험, e2e 3개, 수동 접근성 기록 7개, 런타임 프로필 키, test:reference-feature(명령, 산출물, 게이트 참조), 커버리지 정책 행을 지웠다. removable-template-features 목록은 비우고 장치는 남겼다: test:sample-removal은 인자가 없으면 목록을 하나씩 지우고, 비면 SKIP을 출력하고 보고서에 건너뛴 사례를 남긴다. 기능 스위치 시험과 홈 시작 링크 스위치 시험은 시험 전용 fixture 기능으로 옮겼다. browser soak은 생성 기능을 넣은 빌드에서 돈다. 문서의 샘플 경로를 고쳤다. 날짜가 붙은 설계·리뷰 기록의 본문은 그대로 두었다. 레지스트리 기준선(update:registry-baseline, OWNER DongHyeonka), CI 계약 기준선과 workflow, 초기 JS 기록(194,354B, 17파일, 첫 기능 6,327B, 기능 539B, context 4B)을 다시 받았다. 위험: 레지스트리 행 삭제는 breaking이다. 샘플을 고쳐 쓰는 다운스트림은 수정/삭제 충돌을 만난다. 성능 lab의 기능 라우트 측정은 템플릿에 공개 기능 라우트가 없어 measured:false다. TEMPLATE_FIXTURE 출처는 플랫폼 코드에 남았다. 검증(desktop): check:types, lint, check:architecture, check:registries, check:ci, verify:documentation, test:unit, test:component, test:contract, test:integration, test:recipes, test:coverage(Risk coverage PASS 378/378, 문턱 68개), test:e2e 183, test:a11y, test:visual, test:storybook, test:browser-capabilities, test:feature-scaffold PASS(76 checks), test:sample-removal SKIP, build, check:bundle.
133 lines
5.3 KiB
TypeScript
133 lines
5.3 KiB
TypeScript
// @vitest-environment jsdom
|
|
|
|
import { render, screen, within } from "@testing-library/react";
|
|
import { describe, expect, it, vi } from "vitest";
|
|
|
|
import { createAnonymousSessionAdapter } from "../../src/adapters/auth/external-session-adapter.ts";
|
|
import { ROUTE_REGISTRY } from "../../src/features/installed-feature-contracts.ts";
|
|
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";
|
|
import { FIXTURE_FEATURE_ID, FIXTURE_FEATURE_MODULE } from "../helpers/fixture-feature.tsx";
|
|
import { createProductFeaturesStub } from "../helpers/runtime-capabilities-stub.ts";
|
|
|
|
// The test-only feature (tests/helpers/fixture-feature.tsx): the template
|
|
// installs none.
|
|
vi.mock("../../src/.generated/product-feature-index.ts", async () => ({
|
|
DECLARED_PRODUCT_FEATURE_IDS: ["fixture-feature"],
|
|
PRODUCT_FEATURE_MODULES: [(await import("../helpers/fixture-feature.tsx")).FIXTURE_FEATURE_MODULE],
|
|
}));
|
|
vi.mock("../../src/.generated/product-context-index.ts", async () => ({
|
|
PRODUCT_CONTEXT_MODULES: [(await import("../helpers/fixture-feature.tsx")).FIXTURE_CONTEXT_MODULE],
|
|
}));
|
|
|
|
/**
|
|
* §3.5. The runtime kill switch, exercised through the running app rather than
|
|
* through the resolver that computes it.
|
|
*
|
|
* Withdrawing a feature from navigation is not the same as taking it out of
|
|
* service: a typed deep link would still mount it. Both halves are asserted
|
|
* here, on the same render, so the switch cannot be half-wired. These ran on
|
|
* the template's reference sample and example screens until they were
|
|
* deleted (2026-11-07).
|
|
*/
|
|
const routes: Readonly<Record<string, (typeof ROUTE_REGISTRY)[keyof typeof ROUTE_REGISTRY]>> =
|
|
ROUTE_REGISTRY;
|
|
// A public page of the feature in the primary navigation, and its menu name.
|
|
const FEATURE_ROUTE = routes["FIXTURE_FIRST_PAGE"]!;
|
|
const FEATURE_LINK = (FIXTURE_FEATURE_MODULE.messages["ko-KR"] as Readonly<Record<string, string>>)[
|
|
"route.FIXTURE_FIRST_PAGE.navigation"
|
|
]!;
|
|
|
|
function renderAt(path: string, disabled: boolean) {
|
|
window.history.pushState({}, "", path);
|
|
return render(
|
|
<ApplicationProvider
|
|
application={createTestApplication({
|
|
session: createAnonymousSessionAdapter(),
|
|
...(disabled
|
|
? {
|
|
productFeatures: createProductFeaturesStub({
|
|
[FIXTURE_FEATURE_ID]: "DISABLED_BY_CONFIG",
|
|
}),
|
|
}
|
|
: {}),
|
|
})}
|
|
>
|
|
<PreferenceProviders>
|
|
<AppRouter />
|
|
</PreferenceProviders>
|
|
</ApplicationProvider>,
|
|
);
|
|
}
|
|
|
|
const disabledSurface = () =>
|
|
screen.queryByText(
|
|
(_, element) => element?.getAttribute("data-disabled-feature") === FIXTURE_FEATURE_ID,
|
|
);
|
|
|
|
describe("runtime product feature switch", () => {
|
|
it("advertises the feature's route while the feature is active", async () => {
|
|
renderAt("/", false);
|
|
expect(
|
|
await screen.findAllByRole("link", { name: FEATURE_LINK }),
|
|
).not.toHaveLength(0);
|
|
});
|
|
|
|
it("withdraws the feature's route from navigation when it is disabled", async () => {
|
|
renderAt("/", true);
|
|
// The shell itself still renders: disabling a feature is not an outage.
|
|
expect(await screen.findAllByRole("navigation")).not.toHaveLength(0);
|
|
expect(
|
|
screen.queryByRole("link", { name: FEATURE_LINK }),
|
|
).toBeNull();
|
|
});
|
|
|
|
// 1105/08-03. The home page's starter links read the same switch as the
|
|
// shell's navigation: switched off at runtime, the feature's screens are
|
|
// not offered there, and the next active screens take their place.
|
|
it("leaves the feature's screens out of the home page's starter links when it is disabled", async () => {
|
|
renderAt("/", true);
|
|
|
|
const starter = await screen.findByRole("region", { name: "준비된 화면 살펴보기" });
|
|
const starterPaths = within(starter)
|
|
.getAllByRole("link")
|
|
.map((link) => link.getAttribute("href"));
|
|
const [navigation] = screen.getAllByRole("navigation", { name: "주요 탐색" });
|
|
const advertised = within(navigation!)
|
|
.getAllByRole("link")
|
|
.map((link) => link.getAttribute("href"))
|
|
.filter((path) => path !== "/");
|
|
|
|
expect(starterPaths).not.toContain(FEATURE_ROUTE.path);
|
|
expect(starterPaths).toEqual(advertised.slice(0, 3));
|
|
});
|
|
|
|
it("offers the feature's screens among the starter links while it is active", async () => {
|
|
renderAt("/", false);
|
|
|
|
const starter = await screen.findByRole("region", { name: "준비된 화면 살펴보기" });
|
|
expect(
|
|
within(starter)
|
|
.getAllByRole("link")
|
|
.map((link) => link.getAttribute("href")),
|
|
).toContain(FEATURE_ROUTE.path);
|
|
});
|
|
|
|
it("takes the feature out of service for a direct deep link", async () => {
|
|
renderAt(FEATURE_ROUTE.path, true);
|
|
expect(
|
|
await screen.findByText(
|
|
(_, element) => element?.getAttribute("data-disabled-feature") === FIXTURE_FEATURE_ID,
|
|
),
|
|
).toBeTruthy();
|
|
});
|
|
|
|
it("serves the same deep link while the feature is active", async () => {
|
|
renderAt(FEATURE_ROUTE.path, false);
|
|
expect(await screen.findByRole("heading", { level: 1 })).toBeTruthy();
|
|
expect(disabledSurface()).toBeNull();
|
|
});
|
|
});
|