From 307f65d8f7370d39e057bbea4144a05add75386f Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Wed, 25 Nov 2026 21:06:43 +0700 Subject: [PATCH] Stabilize website scene and keyboard language checks (#10808) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(website): stabilize scene and keyboard language checks Drive scene frames explicitly so sparse browser paints do not consume the test deadline. Let the landing page commit a locale change while its optional plugin count loads. * test(website): advance the plugin panel crossfade before asserting removal * test(website): settle native animations during the plugin panel swap Playwright advances JavaScript frames, while the browser keeps a separate timeline for native animations. Finish the mockup’s finite native animations at the panel checkpoint so either animation path removes the outgoing panel. --- packages/website/e2e/i18n.spec.ts | 34 ++++++---- packages/website/e2e/mockups.spec.ts | 66 ++++++++++++++----- .../website/src/components/agent-route.tsx | 14 ++-- .../website/src/components/landing-page.tsx | 23 ++++--- .../website/src/routes/{-$locale}/index.tsx | 2 +- 5 files changed, 91 insertions(+), 48 deletions(-) diff --git a/packages/website/e2e/i18n.spec.ts b/packages/website/e2e/i18n.spec.ts index 20271cebf3..7c0b8989ae 100644 --- a/packages/website/e2e/i18n.spec.ts +++ b/packages/website/e2e/i18n.spec.ts @@ -9,19 +9,23 @@ async function chooseLanguage(page: Page, language: string) { await page.getByRole("menuitemradio", { name: language }).click(); } -async function withPageScriptsHeld(page: Page, run: (release: () => void) => Promise) { - let releaseScripts!: () => void; - const scriptsReleased = new Promise((resolve) => { - releaseScripts = resolve; +async function withRequestsHeld( + page: Page, + pattern: string, + run: (release: () => void) => Promise, +) { + let releaseRequests!: () => void; + const requestsReleased = new Promise((resolve) => { + releaseRequests = resolve; }); - await page.route("**/*.js", async (route) => { - await scriptsReleased; + await page.route(pattern, async (route) => { + await requestsReleased; await route.continue(); }); try { - await run(releaseScripts); + await run(releaseRequests); } finally { - releaseScripts(); + releaseRequests(); await page.unrouteAll({ behavior: "wait" }); } } @@ -198,13 +202,17 @@ test("switches language from the keyboard", async ({ page }) => { await expect(languageButton(page)).toBeFocused(); await page.keyboard.press("ArrowDown"); + await expect(page.getByRole("menuitemradio", { name: "English" })).toBeFocused(); await page.keyboard.press("ArrowDown"); await expect(page.getByRole("menuitemradio", { name: /简体中文/ })).toBeFocused(); - await page.keyboard.press("Enter"); - await expect(page).toHaveURL(/\/zh-CN$/); - await expect(languageButton(page)).toHaveText("ZH"); - await expect(languageButton(page)).toBeFocused(); + // A slow plugin count must not delay the new language or lose keyboard focus. + await withRequestsHeld(page, "**/_serverFn/**", async () => { + await page.keyboard.press("Enter"); + await expect(page).toHaveURL(/\/zh-CN$/); + await expect(languageButton(page)).toHaveText("ZH"); + await expect(languageButton(page)).toBeFocused(); + }); }); test.describe("on a phone", () => { @@ -260,7 +268,7 @@ test("shows the changelog in Chinese", async ({ page }) => { }); test("waits for scripts before enabling the language menu", async ({ page }) => { - await withPageScriptsHeld(page, async (releaseScripts) => { + await withRequestsHeld(page, "**/*.js", async (releaseScripts) => { await page.goto("/docs/cli#running-agents", { waitUntil: "commit" }); await expect(languageButton(page)).toBeVisible(); await expect(languageButton(page)).toBeDisabled(); diff --git a/packages/website/e2e/mockups.spec.ts b/packages/website/e2e/mockups.spec.ts index 8a84f92701..afdcf8b27e 100644 --- a/packages/website/e2e/mockups.spec.ts +++ b/packages/website/e2e/mockups.spec.ts @@ -10,6 +10,37 @@ async function openHomepage(page: Page, window = { width: 1512, height: 930 }) { await waitForHydration(page); } +/** The scene advances at most 64 ms per frame. Drive its frames independently of CI paint speed. */ +async function openHomepageWithSceneClock( + page: Page, + viewport?: { width: number; height: number }, +) { + await page.clock.install(); + await openHomepage(page, viewport); + await page.clock.pauseAt(await page.evaluate(() => Date.now() + 1000)); +} + +async function centerMockup(mockup: Locator) { + await mockup.evaluate((element) => + element.scrollIntoView({ block: "center", behavior: "instant" }), + ); +} + +async function finishPanelSwap(page: Page, mockup: Locator, outgoingPanel: Locator) { + await expect + .poll(async () => { + await page.clock.runFor(250); + // Playwright's clock drives JavaScript frames. Native animations use the document timeline. + await mockup.evaluate((element) => { + for (const animation of element.getAnimations({ subtree: true })) { + if (Number.isFinite(animation.effect?.getComputedTiming().endTime)) animation.finish(); + } + }); + return outgoingPanel.count(); + }) + .toBe(0); +} + async function viewPhones(page: Page) { await page.getByRole("img", { name: "Paseo agent chat", exact: true }).scrollIntoViewIfNeeded(); } @@ -110,12 +141,7 @@ test("the hero opens on orchestration across providers and machines", async ({ p test("the orchestration scene plays from an empty chat to the open roster of subagents", async ({ page, }) => { - // The scene clock moves at most 64ms per animation frame. Headless WebKit on a busy CI runner - // paints a few frames a second, so on the real clock the scene plays in slow motion and misses - // any wall-clock timeout. The test holds the page clock and plays the scene itself. - await page.clock.install(); - await openHomepage(page); - await page.clock.pauseAt(await page.evaluate(() => Date.now() + 1000)); + await openHomepageWithSceneClock(page); const mockup = page.getByRole("img", { name: desktopName, exact: true }); const composer = mockup.getByText("Message the agent, tag @files, or use /commands and /skills"); await playScene(page, "Orchestration", composer); @@ -141,30 +167,34 @@ test("the orchestration scene plays from an empty chat to the open roster of sub }); test("the opening scene waits until most of the mockup is on screen", async ({ page }) => { - await openHomepage(page); + await openHomepageWithSceneClock(page); const mockup = page.getByRole("img", { name: desktopName, exact: true }); const request = mockup.getByText("Fix the issues labeled ready, one worktree each."); await expect(mockup).not.toBeInViewport({ ratio: 0.6 }); // A scene that started at load sends the request within three seconds. - await page.waitForTimeout(4500); + await page.clock.runFor(4500); await expect(request).toHaveCount(0); - await mockup.scrollIntoViewIfNeeded(); - await expect(request).toBeVisible({ timeout: 10_000 }); + await centerMockup(mockup); + await expect(mockup).toBeInViewport({ ratio: 0.6 }); + await page.clock.runFor(4500); + await expect(request).toBeVisible(); }); test("the opening scene starts in a window shorter than most of the mockup", async ({ page }) => { - await openHomepage(page, { width: 1400, height: 320 }); + await openHomepageWithSceneClock(page, { width: 1400, height: 320 }); const mockup = page.getByRole("img", { name: desktopName, exact: true }); const request = mockup.getByText("Fix the issues labeled ready, one worktree each."); - await mockup.scrollIntoViewIfNeeded(); + await centerMockup(mockup); + await expect(mockup).toBeInViewport(); await expect(mockup).not.toBeInViewport({ ratio: 0.6 }); - await expect(request).toBeVisible({ timeout: 10_000 }); + await page.clock.runFor(4500); + await expect(request).toBeVisible(); }); test("the plugins scene installs the panel, then changes it on request", async ({ page }) => { - await openHomepage(page); + await openHomepageWithSceneClock(page); const mockup = page.getByRole("img", { name: desktopName, exact: true }); const changesPanel = mockup.getByText("Uncommitted", { exact: true }); const pluginPanel = mockup.getByText("Recently merged", { exact: true }); @@ -174,12 +204,14 @@ test("the plugins scene installs the panel, then changes it on request", async ( await expect(pluginPanel).toHaveCount(0); // Installing the plugin swaps the docked panel for the one the agent built. - await expect(pluginPanel).toBeVisible({ timeout: 20_000 }); - await expect(changesPanel).toHaveCount(0); + await page.clock.runFor(5500); + await expect(pluginPanel).toBeVisible(); + await finishPanelSwap(page, mockup, changesPanel); await expect(failingCheck).toHaveCount(0); // The second request reloads the plugin and the open panel lists the failing check. - await expect(failingCheck).toBeVisible({ timeout: 15_000 }); + await page.clock.runFor(6000); + await expect(failingCheck).toBeVisible(); await expect( mockup.getByText("paseo plugin reload release-radar", { exact: true }), ).toBeVisible(); diff --git a/packages/website/src/components/agent-route.tsx b/packages/website/src/components/agent-route.tsx index d7b636b7da..d48ab5852a 100644 --- a/packages/website/src/components/agent-route.tsx +++ b/packages/website/src/components/agent-route.tsx @@ -18,18 +18,14 @@ export function agentRouteOptions(slug: AgentPageSlug) { locale, }); }, - loader: async () => ({ pluginCount: await getPluginCount() }), + loader: () => ({ pluginCount: getPluginCount().catch(() => null) }), component: function AgentLandingPage() { const { t } = useTranslation(); - const data = useLoaderData({ strict: false }) as { pluginCount?: number | null } | undefined; + const { pluginCount } = useLoaderData({ strict: false }) as { + pluginCount: Promise; + }; const page = getAgentPage(slug, t); - return ( - - ); + return ; }, }; } diff --git a/packages/website/src/components/landing-page.tsx b/packages/website/src/components/landing-page.tsx index 596634dc94..158cf1594f 100644 --- a/packages/website/src/components/landing-page.tsx +++ b/packages/website/src/components/landing-page.tsx @@ -1,3 +1,4 @@ +import { Await } from "@tanstack/react-router"; import { PLUGINS_LINKED } from "~/plugins/launch"; import { categoryHref } from "~/plugins/links"; import type { CategorySlug } from "~/plugins/categories"; @@ -114,14 +115,14 @@ import "~/styles.css"; interface LandingPageProps { title: React.ReactNode; subtitle: React.ReactNode; - pluginCount?: number | null; + pluginCount: Promise; showHubEyebrow?: boolean; } export function LandingPage({ title, subtitle, - pluginCount = null, + pluginCount, showHubEyebrow = false, }: LandingPageProps) { return ( @@ -613,7 +614,7 @@ function ProductLead({ actions, }: { icon: LucideIcon; - title: string; + title: React.ReactNode; description?: string; actions?: React.ReactNode; }) { @@ -979,17 +980,23 @@ const PLUGIN_CLIENT_COMPONENTS = { ), }; -function ExtensibleSection({ pluginCount }: { pluginCount?: number | null }) { +function ExtensibleSection({ pluginCount }: { pluginCount: Promise }) { const { t } = useTranslation(); const pluginActions = React.useMemo(() => , []); const description = React.useMemo( () => , [], ); - const libraryTitle = - pluginCount && pluginCount > 0 - ? t("landing.plugins.libraryTitleCount", { count: pluginCount }) - : t("landing.plugins.libraryTitle"); + const libraryTitle = React.useMemo(() => { + const fallback = t("landing.plugins.libraryTitle"); + return ( + + {(count) => + count && count > 0 ? t("landing.plugins.libraryTitleCount", { count }) : fallback + } + + ); + }, [pluginCount, t]); return ( ({ pluginCount: await getPluginCount() }), + loader: () => ({ pluginCount: getPluginCount().catch(() => null) }), component: Home, });