test(website): wait for hydration before the hero tests scroll (#9762)

The router scrolls the window back to the top when the page hydrates. The
hero tests scrolled to the mockup right after load, so in WebKit the reset
sometimes landed after the test's scroll and the opening scene never started.

The language button turns enabled in the render after that reset. The
changelog and plugins specs already waited on it with their own copies; the
wait now lives in the shared fixtures and the hero tests open the page with it.
This commit is contained in:
Mohamed Boudra authored and GitHub committed 2026-11-15 18:32:17 +07:00
1 parent dd06bc0833
commit 5a7a60ae50
4 files changed
+24 -25

No files matched your search

+2 -5
View File
@@ -1,4 +1,4 @@
import { expect, test, type Locator, type Page } from "./fixtures";
import { expect, test, waitForHydration, type Locator, type Page } from "./fixtures";
// The page renders the repository's CHANGELOG.md, so releases are found by shape, never by version:
// a release with highlights has the toggle, a release without them does not.
@@ -6,12 +6,9 @@ function releases(page: Page): Locator {
return page.getByRole("region");
}
// The router resets the scroll position when the page hydrates. A click sent before that is aimed
// at where the control was, so wait for the page to be interactive: the language button is enabled
// once it has hydrated.
async function openChangelog(page: Page): Promise<void> {
await page.goto("/changelog");
await expect(page.getByRole("button", { name: /^Language/ }).first()).toBeEnabled();
await waitForHydration(page);
}
function releaseWithHighlights(page: Page): Locator {
+10 -1
View File
@@ -1,8 +1,17 @@
import { test as base } from "playwright/test";
import { expect, test as base, type Page } from "playwright/test";
export { expect } from "playwright/test";
export type { Locator, Page } from "playwright/test";
/**
* Waits until the page has hydrated. Server-rendered content shows before that, but it has no
* click handlers yet, and the router scrolls the window back to the top when it hydrates.
* The language button stays disabled until the render after that reset.
*/
export async function waitForHydration(page: Page) {
await expect(page.getByRole("button", { name: /^(Language|语言)/ }).first()).toBeEnabled();
}
export const test = base.extend({
page: async ({ page, baseURL }, run) => {
page.on("response", async (response) => {
+7 -8
View File
@@ -1,12 +1,13 @@
import { expect, test, type Locator, type Page } from "./fixtures";
import { expect, test, waitForHydration, type Locator, type Page } from "./fixtures";
const desktopName =
"Paseo desktop app with coding agents, a conversation, and a code diff open side by side";
async function openHomepage(page: Page) {
await page.setViewportSize({ width: 1512, height: 930 });
/** Opens the homepage once it has hydrated, so the router's scroll reset cannot undo a later scroll. */
async function openHomepage(page: Page, window = { width: 1512, height: 930 }) {
await page.setViewportSize(window);
await page.goto("/");
await expect(page.getByRole("button", { name: "Orchestration", exact: true })).toBeVisible();
await waitForHydration(page);
}
async function viewPhones(page: Page) {
@@ -148,8 +149,7 @@ test("the opening scene waits until most of the mockup is on screen", async ({ p
});
test("the opening scene starts in a window shorter than most of the mockup", async ({ page }) => {
await page.setViewportSize({ width: 1400, height: 400 });
await page.goto("/");
await openHomepage(page, { width: 1400, height: 400 });
const mockup = page.getByRole("img", { name: desktopName, exact: true });
const request = mockup.getByText("Fix the issues labeled ready, one worktree each.");
await mockup.scrollIntoViewIfNeeded();
@@ -240,8 +240,7 @@ test("picking a scene while the hero is still sliding in keeps the pills on scre
}) => {
// Reduced motion makes the scroll instant, so the test does not wait for one to settle.
await page.emulateMedia({ reducedMotion: "reduce" });
await page.setViewportSize({ width: 1280, height: 700 });
await page.goto("/");
await openHomepage(page, { width: 1280, height: 700 });
const mockup = page.getByRole("img", { name: desktopName, exact: true });
await playScene(page, "Remote", page.getByRole("button", { name: "Remote", pressed: true }));
+5 -11
View File
@@ -1,5 +1,5 @@
import securityPlugin from "./overview.fixture.json" with { type: "json" };
import { expect, test, type Page, type Locator } from "./fixtures";
import { expect, test, waitForHydration, type Page, type Locator } from "./fixtures";
import registry from "./registry.fixture.json" with { type: "json" };
import { CATEGORIES } from "../src/plugins/categories";
import copy from "../src/i18n/resources/en.json" with { type: "json" };
@@ -9,12 +9,6 @@ async function openPlugins(page: Page) {
await expect(page.getByRole("heading", { level: 1, name: /^Plugins/ })).toBeVisible();
}
async function waitForInteractivePage(page: Page) {
// Server-rendered content is visible before hydration attaches its click handlers.
// The language selector stays disabled until that page has hydrated.
await expect(page.getByRole("button", { name: "Language: English" }).first()).toBeEnabled();
}
function pluginCards(page: Page, section: string): Locator {
return page
.getByRole("region", { name: section })
@@ -84,18 +78,18 @@ test("browses from the directory into a category, a plugin, and its author", asy
});
});
await openPlugins(page);
await waitForInteractivePage(page);
await waitForHydration(page);
await page.getByRole("region", { name: "Categories" }).getByRole("link", { name: /Git/ }).click();
await expect(page).toHaveURL(/\/plugins\/category\/git$/);
await expect(page.getByRole("heading", { level: 1, name: /^Git/ })).toBeVisible();
await waitForInteractivePage(page);
await waitForHydration(page);
await expect(page.getByRole("link", { name: /Dracula/ })).toHaveCount(0);
await page.getByRole("link", { name: /Fresh Worktrees/ }).click();
await expect(page).toHaveURL(/\/plugins\/omercnet\/fresh-worktrees$/);
await expect(page.getByRole("heading", { name: "Fresh Worktrees" })).toHaveCount(1);
await waitForInteractivePage(page);
await waitForHydration(page);
await expect(page.getByText("paseo plugin add omercnet/fresh-worktrees")).toHaveCount(1);
await expect(
page.getByRole("heading", { level: 2, name: "Behavior", exact: true }),
@@ -192,7 +186,7 @@ test("keeps the directory's ranking window when searching", async ({ page }) =>
test("submits the visible search term when its input event was missed", async ({ page }) => {
await page.goto("/plugins?window=month");
await expect(page.getByRole("button", { name: "Language: English" }).first()).toBeEnabled();
await waitForHydration(page);
await fillSearchWithMissedInputEvent(page, "graphite");
await page.keyboard.press("Enter");