09-29 템플릿 동기화(c80320d, ebea300→af3d8e6)가 템플릿 e2e 시험을
그대로 들여왔다. 그 시험은 이 제품이 지운 템플릿 예시 화면을 연다.
- app-shell: 제목 「Tech Log」(지금 브랜드는 「TechLog」), 템플릿 drawer의
「메뉴」 버튼과 /examples/states.
- production-csp: 제목 「Clean Architecture Frontend」와 「화면 상태」 링크.
- scroll-restoration: /examples/ui와 .app-shell__header.
그래서 세 엔진 모두에서 요소를 찾지 못해 떨어진다.
같은 동작을 TechLog 화면으로 본다.
- 홈 제목은 TechLog, 이동할 화면은 주요 탐색의 「프로젝트」.
- drawer는 TechLog의 details.mobile-nav와 「모바일 주요 탐색」.
- 긴 화면은 Case(1280x720에서 약 6,000px), 해시 대상은 그 안의 h2.
- production-csp는 경로가 바뀐 것을 URL과 제목으로만 확인한다. 초점은
app-shell 시험이 따로 본다. 그래야 초점 결함과 상관없이 CSP 검사가 돈다.
위험·한계: 옮긴 시험 가운데 셋은 제품이 그 동작을 하지 않아 여전히
떨어진다. 시험을 고쳐서 생긴 실패가 아니라, 템플릿 이름 때문에 가려져
있던 실패다.
- 경로 이동 뒤 초점: app-router.tsx는 「shell이 초점을 맡는다」며 이동을
뺐지만, TechLog Public shell에는 초점 처리가 없다. drawer 링크로 이동해도
새 화면의 제목으로 초점이 가지 않는다.
- 뒤로 가기 스크롤 복원: Case에서 900px 내려갔다가 다른 화면에 갔다
돌아오면 0이다.
- 해시로 연 Case에서 대상 h2로 스크롤하지 않는다. TechLog 화면은 해시를
처리하는 PageHeader를 쓰지 않는다(project-decisions-page만 따로 처리).
정할 것(초점 정책)이 있어 이 PR에서 제품을 고치지 않는다.
검증: production-csp는 세 엔진 모두 통과한다. 첫 번째 app-shell
시험(홈 부팅)과 scroll-restoration의 화면 열기까지는 통과하고, 위 세
동작에서 떨어진다.
50 lines
2.1 KiB
TypeScript
50 lines
2.1 KiB
TypeScript
import { expect, test, type Page } from "../support/browser/strict-browser-test.ts";
|
|
|
|
const scrollY = (page: Page) => page.evaluate(() => Math.round(window.scrollY));
|
|
|
|
// Template sync (af3d8e6). Upstream scrolls its long example page; this product
|
|
// deleted it, and a TechLog Case (about 6,000px at 1280x720) is the long page.
|
|
const LONG_PAGE = "/cases/collection-fetch-join-pagination";
|
|
const LONG_PAGE_TITLE = "컬렉션 Fetch Join과 페이징은 왜 충돌하는가";
|
|
|
|
// 08-08. Back restores where the user was; a new route starts at the top.
|
|
// The Case body fills in after the title, so the test waits for it before it
|
|
// scrolls.
|
|
test("restores the scroll position when navigating back", async ({ page }) => {
|
|
const heading = page.getByRole("heading", { level: 1 });
|
|
await page.goto(LONG_PAGE);
|
|
await expect(heading).toHaveText(LONG_PAGE_TITLE);
|
|
await expect(page.locator("main [aria-busy='true']")).toHaveCount(0);
|
|
await expect(page.locator("#remaining-cost")).toBeAttached();
|
|
await page.evaluate(() => window.scrollTo(0, 900));
|
|
await expect.poll(() => scrollY(page)).toBe(900);
|
|
|
|
await page
|
|
.getByRole("navigation", { name: "주요 탐색" })
|
|
.getByRole("link", { name: "프로젝트" })
|
|
.click();
|
|
await expect(heading).toHaveText("프로젝트");
|
|
await expect.poll(() => scrollY(page)).toBe(0);
|
|
|
|
await page.goBack();
|
|
await expect(heading).toHaveText(LONG_PAGE_TITLE);
|
|
await expect.poll(() => scrollY(page)).toBe(900);
|
|
});
|
|
|
|
// A section well below the first screen. The header is the TechLog site header.
|
|
test("opens a hash link at its target below the sticky header", async ({
|
|
page,
|
|
}) => {
|
|
await page.goto(`${LONG_PAGE}#separate-loading`);
|
|
const target = page.locator("#separate-loading");
|
|
await expect(target).toBeInViewport();
|
|
const top = await target.evaluate((element) =>
|
|
Math.round(element.getBoundingClientRect().top),
|
|
);
|
|
const headerBottom = await page
|
|
.locator(".site-header")
|
|
.evaluate((element) => Math.round(element.getBoundingClientRect().bottom));
|
|
expect(top).toBeGreaterThanOrEqual(headerBottom);
|
|
expect(await scrollY(page)).toBeGreaterThan(0);
|
|
});
|