예제 화면 /examples/ui·/examples/states가 visual 골든 2장과 갤러리
브라우저 시험의 대상이다. 2026-11-07 소유자 결정으로 예제 화면을
지우므로 그 역할을 먼저 옮긴다(design-docs repo-structure/
04-frontend-layout.md 9.2절 2단계 (1)).
두 갤러리 화면을 그대로 src/presentation/design-system/
galleries.stories.tsx로 옮겼다. 화면 단위 story(parameters.page)는
preview가 여백을 더하지 않아 앱 안과 같은 폭으로 그려진다. visual
설정은 Storybook 정적 빌드를 두 번째 web server로 띄우고
(TEST_VISUAL_WORKSHOP_PORT, 빌드 명령은 workshop 설정과 같은
scripts/lib/storybook-static.ts), 골든 2장은 그 story를 찍는다. 어두운
골든은 테마 선택기가 없어 시스템 dark(colorScheme)로 그린다. e2e의
갤러리 상호작용(텍스트 필드, 모달 포커스, 메뉴·탭·토스트, 열린 대화
상자 axe, 320px 리플로)은 tests/storybook/galleries.spec.ts로 옮겼다.
위험: 골든의 픽셀 색 허용치(threshold 0.2)는 그대로다. 미세한 토큰
변화는 옛 골든처럼 새 골든도 잡지 못한다.
검증(desktop): test:storybook 6 passed, test:visual 7 passed,
playwright-run-isolation 단위 시험 통과. 변이 확인: --color-action을
파랑→빨강으로 바꾸면 새 골든이 어두운 쪽 42,313px, 밝은 쪽 22,359px
차이로 실패했다. 옛 골든(main f33e4778)도 40,238px, 22,511px로 실패했다.
미세 변이(어두운 --color-danger red-500→600, 밝은 --color-danger-surface
색상각 25→145)는 옛·새 골든 모두 통과했다. 변이는 되돌렸다.
140 lines
5.5 KiB
TypeScript
140 lines
5.5 KiB
TypeScript
import {
|
|
expect,
|
|
test,
|
|
type Page,
|
|
} from "../support/browser/strict-browser-test.ts";
|
|
import {
|
|
reservedOrigin,
|
|
TEST_PORT_VARIABLES,
|
|
} from "../../scripts/lib/run-isolation.ts";
|
|
import {
|
|
ROUTE_FEATURE_OWNER,
|
|
ROUTE_REGISTRY,
|
|
} from "../../src/features/installed-feature-contracts.ts";
|
|
|
|
// 11-02. `main` is drawn before the route chunk arrives; a screenshot taken
|
|
// then pins the loading surface instead of the page.
|
|
async function expectRouteHeading(page: Page, title: string) {
|
|
await expect(page.getByRole("heading", { level: 1 })).toHaveText(title);
|
|
}
|
|
|
|
/**
|
|
* A gallery story in the static workshop the config's second server serves
|
|
* (src/presentation/design-system/galleries.stories.tsx). The a11y addon's own
|
|
* axe run is switched off, as in tests/storybook: it has nothing to draw.
|
|
*/
|
|
async function openGalleryStory(page: Page, storyId: string, title: string) {
|
|
await page.goto(
|
|
`${reservedOrigin(TEST_PORT_VARIABLES.visualWorkshop)}/iframe.html?id=${storyId}&viewMode=story&globals=a11y.manual:!true`,
|
|
);
|
|
await expect(page.getByRole("heading", { level: 1 })).toHaveText(title);
|
|
}
|
|
|
|
/** `toHaveScreenshot` takes a stylesheet only as a file; a tag does the same. */
|
|
async function hide(page: Page, css: string) {
|
|
if (css !== "") await page.addStyleTag({ content: css });
|
|
}
|
|
|
|
/**
|
|
* 1103/12-01. These goldens are the template's own drawing: the shell, the
|
|
* home page and the platform overview. Those screens also draw whatever
|
|
* features are installed, so one `create:feature` failed this merge gate and
|
|
* only re-capturing template-owned PNGs made it pass. The screenshots leave
|
|
* the installed features' parts out (`display: none`, so a longer list does
|
|
* not move the rest): every link to a feature route, with its list item, and
|
|
* the overview sections that count or list the installed features. Their
|
|
* number and order are the component tests' subject; the shell's own CSS
|
|
* still fails here.
|
|
*/
|
|
const FEATURE_ROUTE_PATHS = Object.values(ROUTE_REGISTRY)
|
|
.filter((route) => ROUTE_FEATURE_OWNER[route.routeId] !== undefined)
|
|
.map((route) => route.path);
|
|
const WITHOUT_FEATURE_LINKS =
|
|
FEATURE_ROUTE_PATHS.length === 0
|
|
? ""
|
|
: `${FEATURE_ROUTE_PATHS.flatMap((path) => [
|
|
`li:has(> a[href="${path}"])`,
|
|
`a[href="${path}"]`,
|
|
]).join(",\n")} { display: none !important; }`;
|
|
const WITHOUT_INSTALLED_FEATURE_SECTIONS = `${[
|
|
"platform-summary-title",
|
|
"platform-routes-title",
|
|
"platform-contracts-title",
|
|
"platform-features-title",
|
|
]
|
|
.map((id) => `section[aria-labelledby="${id}"]`)
|
|
.join(",\n")} { display: none !important; }
|
|
section[aria-labelledby="platform-release-title"] .platform-metric:nth-child(4) dd {
|
|
/* The contract-set digest: a feature's contract package changes it. */
|
|
visibility: hidden !important;
|
|
}`;
|
|
|
|
test("wide application shell visual contract", async ({ page }) => {
|
|
await page.setViewportSize({ width: 1440, height: 900 });
|
|
await page.goto("/");
|
|
await expectRouteHeading(page, "Clean Architecture Frontend");
|
|
await hide(page, WITHOUT_FEATURE_LINKS);
|
|
await expect(page).toHaveScreenshot("app-shell-wide-light.png", {
|
|
fullPage: true,
|
|
});
|
|
});
|
|
|
|
test("compact drawer and pseudo-locale visual contract", async ({ page }) => {
|
|
await page.setViewportSize({ width: 390, height: 844 });
|
|
await page.goto("/");
|
|
await expectRouteHeading(page, "Clean Architecture Frontend");
|
|
await page.locator("#locale-preference").selectOption("en-XA");
|
|
await page.locator(".app-shell__menu-button").click();
|
|
await expect(page.locator(".ui-drawer")).toHaveJSProperty("open", true);
|
|
await hide(page, WITHOUT_FEATURE_LINKS);
|
|
await expect(page).toHaveScreenshot("app-shell-compact-pseudo-drawer.png", {
|
|
fullPage: true,
|
|
});
|
|
});
|
|
|
|
test.describe("in the dark color scheme", () => {
|
|
// The workshop has no theme selector: the theme provider follows the
|
|
// system preference there, as the app does until a user picks one.
|
|
test.use({ colorScheme: "dark" });
|
|
|
|
test("design-system gallery dark visual contract", async ({ page }) => {
|
|
await page.setViewportSize({ width: 1280, height: 900 });
|
|
await openGalleryStory(page, "platform-galleries--design-system", "UI 구성요소");
|
|
await expect(page.locator("html")).toHaveAttribute("data-theme", "dark");
|
|
await expect(page.getByRole("main")).toHaveScreenshot(
|
|
"design-system-gallery-dark.png",
|
|
);
|
|
});
|
|
});
|
|
|
|
test("loading empty error and access surfaces visual contract", async ({
|
|
page,
|
|
}) => {
|
|
await page.setViewportSize({ width: 1280, height: 1100 });
|
|
await openGalleryStory(page, "platform-galleries--screen-states", "화면 상태");
|
|
await expect(page.getByRole("main")).toHaveScreenshot(
|
|
"state-surfaces-light.png",
|
|
);
|
|
});
|
|
|
|
test("platform composition overview visual contract", async ({ page }) => {
|
|
await page.setViewportSize({ width: 1280, height: 1100 });
|
|
await page.goto("/examples/platform");
|
|
await expectRouteHeading(page, "플랫폼 구성");
|
|
await expect(
|
|
page.locator("section[aria-labelledby='platform-capabilities-title']"),
|
|
).toBeVisible();
|
|
// 1103/15-01. The contract tables fill in after the title; wait for them so
|
|
// the hidden sections are drawn in their final state either way.
|
|
await expect(page.locator("main [aria-busy='true']")).toHaveCount(0);
|
|
await expect(
|
|
page
|
|
.locator("section[aria-labelledby='platform-release-title'] dt")
|
|
.filter({ hasText: "계약 집합 다이제스트" }),
|
|
).toBeVisible();
|
|
await hide(page, WITHOUT_INSTALLED_FEATURE_SECTIONS);
|
|
await expect(page.getByRole("main")).toHaveScreenshot(
|
|
"platform-overview-light.png",
|
|
);
|
|
});
|