mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-12-01 21:05:42 +09:00
Builder E2E still takes too long. The goal is all 145 cases under 3 minutes end to end, with exactly ten shards and the same UI, MCP, and generated Preview checks. This PR has not met that goal. ### Measured results - Initial green CI run: 9m43s from build start to the last shard; slowest test step 439s. - Best green run after replacing repeated UI project setup: about 5m35s; slowest test step 250s. - Best green run (393e51c): about 4m59s; slowest test step 201s. The two-file rebalance reduced the prior green run by about 50s. The 3-minute goal remains unmet. - Latest green run (de2f4ed): about 5m56s; slowest test step 257s. All ten shards and required workflows passed. The preceding green run took about 6m09s, showing substantial run-to-run variation. - The 119 content-mode project setup calls fell from 599s to 23.5s of aggregate worker time by using the app's dev login and project creation API. The sum of shard test steps fell from 2,178s to 1,721s in the first run with this change. Per-shard wall time still varies substantially between runs. - The shared build takes about 85s, including roughly 30s of setup and 51s of Builder compilation. During tests, the four-CPU shard runners showed 27–52% CPU scheduling pressure and 0% memory pressure; peak memory was unavailable. ### Changes - Cache the test schema and share one Builder build artifact across ten shards. Shard setup overlaps the build; each shard still starts an isolated database. - Keep real MCP and browser sessions alive for repeated Preview submissions, and reuse generated Previews where checks can share one. - Give independent cases separate projects and run them within the existing shard workers. Keep exactly ten shards. - Create content-mode fixture projects through the app's normal login and project API, using its CSRF token. Dedicated UI project creation remains in the Builder project fixture. - Capture managed Form responses before fast redirects discard their bodies. Fix drag targeting and unique drag fixture IDs. - Report CPU and memory pressure for every shard. Allow the MCP browser startup enough time under CI load. An earlier shard rebalance worsened the run and was reverted; a measured two-file rebalance improved the slowest shard without changing test logic. ### Verification and remaining work Focused local runs passed for a single project, three projects sharing one session, a paid-plan MCP project, and the MCP Preview form case. Builder and Vision typechecks, lint, formatting, the ten-shard matrix check, and Vision regression tests passed. All required workflows passed onde2f4ed. The latest review fix also passed all 63 Vision tests, Vision typecheck, lint, and formatting locally. - [x] Profile the full suite and measure complete ten-shard CI runs. - [x] Remove repeated UI project setup from the shared fixture. - [x] Measure CPU and memory pressure in CI. - [ ] Reduce Builder interactions, generated Preview work, and build time enough to finish under 3 minutes. - [x] Resolve five review threads and verify the affected paths. - [x] Check authoritative Builder documentation; these test harness and capture fixes do not change user-facing behavior or documentation. CI still checks out and installs dependencies, builds Builder, uploads and downloads its artifact, starts a database for each shard, and runs real browsers and generated production Previews. Warm caches remove downloads and schema generation, but do not remove setup, compilation, browser work, or cache transfers. No product behavior or authoritative documentation changed.
105 lines
2.7 KiB
TypeScript
105 lines
2.7 KiB
TypeScript
import { parseBuilderUrl } from "@webstudio-is/protocol";
|
|
import {
|
|
test as base,
|
|
type Browser,
|
|
type BrowserContextOptions,
|
|
} from "@playwright/test";
|
|
import env from "../app/env/env.server";
|
|
|
|
const builderPort = process.env.PORT ?? "3000";
|
|
|
|
export const builderUrl =
|
|
process.env.E2E_BUILDER_URL ?? `https://127.0.0.1:${builderPort}`;
|
|
|
|
const builderUrlObject = new URL(builderUrl);
|
|
|
|
export const dashboardUrl = `${builderUrlObject.protocol}//wstd.dev:${builderUrlObject.port}`;
|
|
|
|
export const postgrestUrl = env.POSTGREST_URL;
|
|
|
|
export const browserContextOptions: BrowserContextOptions = {
|
|
ignoreHTTPSErrors: true,
|
|
permissions: ["clipboard-read", "clipboard-write"],
|
|
};
|
|
|
|
const isLoopbackHost = (hostname: string) =>
|
|
hostname === "127.0.0.1" || hostname === "localhost" || hostname === "::1";
|
|
|
|
export const getBrowserLaunchOptions = (url = builderUrl) => {
|
|
const hostname = new URL(url).hostname;
|
|
if (isLoopbackHost(hostname) === false) {
|
|
return {};
|
|
}
|
|
return {
|
|
args: [
|
|
"--host-resolver-rules=MAP wstd.dev 127.0.0.1,MAP *.wstd.dev 127.0.0.1",
|
|
],
|
|
};
|
|
};
|
|
|
|
export const newBrowserContext = (browser: Browser) =>
|
|
browser.newContext(browserContextOptions);
|
|
|
|
export const withBrowserContext = async <Result>(
|
|
browser: Browser,
|
|
run: (
|
|
context: Awaited<ReturnType<typeof newBrowserContext>>
|
|
) => Promise<Result> | Result
|
|
) => {
|
|
const context = await newBrowserContext(browser);
|
|
try {
|
|
return await run(context);
|
|
} finally {
|
|
await context.close();
|
|
}
|
|
};
|
|
|
|
export const test = base.extend<{}, { mcpClientCleanup: void }>({
|
|
mcpClientCleanup: [
|
|
async ({}, use) => {
|
|
await use();
|
|
const { closePreviewFormMcpClient } =
|
|
await import("./flows/mcp-preview-submit");
|
|
await closePreviewFormMcpClient();
|
|
},
|
|
{ scope: "worker", auto: true },
|
|
],
|
|
});
|
|
|
|
export const newIsolatedPage = async (browser: Browser) => {
|
|
const context = await newBrowserContext(browser);
|
|
return {
|
|
page: await context.newPage(),
|
|
close: () => context.close(),
|
|
};
|
|
};
|
|
|
|
export const getProjectBuilderUrl = ({
|
|
projectId,
|
|
authToken,
|
|
mode,
|
|
features,
|
|
}: {
|
|
projectId: string;
|
|
authToken?: string;
|
|
mode?: "content" | "preview";
|
|
features?: string[];
|
|
}) => {
|
|
const url = new URL(dashboardUrl);
|
|
url.hostname = `p-${projectId}.wstd.dev`;
|
|
if (authToken !== undefined) {
|
|
url.searchParams.set("authToken", authToken);
|
|
}
|
|
if (mode !== undefined) {
|
|
url.searchParams.set("mode", mode);
|
|
}
|
|
if (features !== undefined && features.length > 0) {
|
|
url.searchParams.set("features", features.join(","));
|
|
}
|
|
return url.href;
|
|
};
|
|
|
|
export const getProjectIdFromBuilderUrl = (url: string) => {
|
|
return parseBuilderUrl(url).projectId;
|
|
};
|