From 3cb182410b7abd6019392955fae67e3a772c36e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Thu, 1 Oct 2026 13:57:16 -0400 Subject: [PATCH] =?UTF-8?q?T48m=20Docs=20=C2=B7=20E2E:=20a=20hashless=20pr?= =?UTF-8?q?ose=20link=20proves=20routing=20in=20place;=20the=20section=20l?= =?UTF-8?q?ink=20keeps=20its=20own=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/e2e/docs.spec.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/frontend/e2e/docs.spec.ts b/frontend/e2e/docs.spec.ts index 4b37530..e204dc8 100644 --- a/frontend/e2e/docs.spec.ts +++ b/frontend/e2e/docs.spec.ts @@ -72,13 +72,25 @@ test("an on-this-page link moves to its section", async ({ page, isMobile }) => await expect(page.locator("#when-it-fails")).toBeInViewport(); }); -test("a link in a guide routes in place to its section", async ({ page }) => { +/** Marks the page, so a reload shows as a lost mark. */ +const mark = (page: Page) => page.evaluate(() => ((window as unknown as { kept: boolean }).kept = true)); +const kept = (page: Page) => page.evaluate(() => (window as unknown as { kept?: boolean }).kept === true); + +test("a link in a guide routes in place", async ({ page }) => { + await page.goto("/docs/"); + await mark(page); + await page.locator(".prose a", { hasText: "components page" }).click(); + await expect(page).toHaveURL("/components/"); + expect(await kept(page)).toBe(true); +}); + +test("a link to another guide's section lands on it", async ({ page }) => { await page.goto("/docs/installation/"); - await page.evaluate(() => ((window as unknown as { kept: boolean }).kept = true)); + await mark(page); await page.locator(".prose a", { hasText: "first window" }).click(); await expect(page).toHaveURL("/docs/#a-first-window"); await expect(page.locator("#a-first-window")).toBeInViewport(); - expect(await page.evaluate(() => (window as unknown as { kept?: boolean }).kept)).toBe(true); + expect(await kept(page)).toBe(true); }); test("a code sample is the compiled example, and Copy copies it", async ({ page, context, browserName, isMobile }) => {