mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-12-01 21:05:42 +09:00
Builder E2E still misses the three-minute target. The latest warm ten-shard run passed, but shard 6 took 4:29 from runner start to completion. This PR remains a draft. The ten shard jobs took 2:21–4:29. Their test phases took 1:20–3:31 and their test durations summed to about 4,018 seconds across 136 tests. At three Playwright workers per shard, that is a 2:14 average lower bound before roughly 45–60 seconds of runner setup; some shards have much more work than average. The latest managed Form consolidation passed on shard 7, but that shard still took 4:06. Shard 5 ranged from 4:40 to 3:20 across two warm runs with no shard 5 code change, so a single run is not evidence of a stable speedup. This branch caches the compiled Builder for E2E-only changes and commits the schema snapshot so shards do not repeat migrations. The separate Supabase migration job still applies all migrations. Each shard now restores the compiled Builder cache directly. A warm run confirmed the artifact wait and download were skipped; a miss run confirmed the fallback. New runners still restore pnpm, Playwright, and Builder caches, and start a database. Related Form redirect, Email, feedback, resource, and managed delivery outcomes now use fewer generated production Previews while retaining named steps and assertions. Three generated resource tests now share one project and Preview; the combined test passed in 52 seconds on CI versus three prior tests of about 76–79 seconds each. The newest managed Form test combines navigation, two Action delivery, and multipart upload in one Preview and passed both locally and in CI. Four workers per shard were tested and reverted: full E2E rose from 4:46 to 5:32, with 57–64% CPU scheduling pressure on several shards and zero memory pressure. In the latest shard 7 run, seven generated Preview startups summed to 200 seconds across parallel tests. Repeated Builder canvas startup and saves dominate other shards. Caching and small test consolidations are insufficient for the target; the remaining work needs a test architecture that keeps production Preview and real Builder coverage while avoiding full compilation or reload for every behavior case. ### Status - [x] Measure per-test, key phase, and runner CPU/memory times. - [x] Cache compiled Builder inputs and commit a schema snapshot while retaining the full migration check. - [x] Keep dashboard UI creation coverage while using faster setup in unrelated tests. - [x] Fix the MCP Preview redirect observation race with a regression test. - [x] Consolidate related redirect, Email, feedback, resource, and managed Form outcomes while retaining assertions. - [x] Verify formatting, Builder typecheck, focused local tests, and the latest warm ten-shard CI run. - [ ] Diagnose and eliminate intermittent Chromium startup failures beyond the concurrent Email binding case. - [ ] Run managed Form callback protocol and browser checks against one production Preview. - [ ] Cut repeated Builder and production Preview work enough for every shard to finish within three minutes. - [ ] Verify cold and warm ten-shard CI runs under three minutes. No user-facing documentation or fixture bundle changes are needed.
154 lines
3.6 KiB
TypeScript
154 lines
3.6 KiB
TypeScript
import type { Frame, Page } from "@playwright/test";
|
|
import { getProjectBuilderUrl } from "../test";
|
|
import { measure } from "../perf";
|
|
|
|
const delay = (ms: number) =>
|
|
new Promise<void>((resolve) => setTimeout(resolve, ms));
|
|
|
|
export const getCanvasInstanceSelector = (instanceSelector: string[]) =>
|
|
`[data-ws-selector="${instanceSelector.join(",")}"]`;
|
|
|
|
export const getCanvasInstance = ({
|
|
canvas,
|
|
instanceSelector,
|
|
}: {
|
|
canvas: Frame;
|
|
instanceSelector: string[];
|
|
}) => canvas.locator(getCanvasInstanceSelector(instanceSelector)).first();
|
|
|
|
export const getCanvasFrame = async (page: Page) => {
|
|
const iframe = await page.locator("iframe").first().elementHandle();
|
|
return (await iframe?.contentFrame()) ?? undefined;
|
|
};
|
|
|
|
export const waitForCanvasFrame = async ({ page }: { page: Page }) => {
|
|
try {
|
|
await page.locator("iframe").first().waitFor({
|
|
state: "attached",
|
|
timeout: 30_000,
|
|
});
|
|
} catch (error) {
|
|
const bodyText = await page
|
|
.locator("body")
|
|
.innerText()
|
|
.catch(() => "");
|
|
throw new Error(`Expected canvas iframe. Body: ${bodyText}`, {
|
|
cause: error,
|
|
});
|
|
}
|
|
|
|
const startedAt = Date.now();
|
|
while (Date.now() - startedAt < 30_000) {
|
|
const canvas = await getCanvasFrame(page);
|
|
if (canvas !== undefined) {
|
|
return canvas;
|
|
}
|
|
await delay(250);
|
|
}
|
|
|
|
throw new Error("Expected canvas frame");
|
|
};
|
|
|
|
export const waitForCanvasText = async ({
|
|
page,
|
|
text,
|
|
}: {
|
|
page: Page;
|
|
text: string;
|
|
}) => {
|
|
const startedAt = Date.now();
|
|
let lastError: unknown;
|
|
|
|
while (Date.now() - startedAt < 30_000) {
|
|
const canvas = await getCanvasFrame(page);
|
|
if (canvas === undefined) {
|
|
await delay(250);
|
|
continue;
|
|
}
|
|
|
|
try {
|
|
await canvas.getByText(text).waitFor({
|
|
state: "visible",
|
|
timeout: 1_000,
|
|
});
|
|
return;
|
|
} catch (error) {
|
|
lastError = error;
|
|
await delay(250);
|
|
}
|
|
}
|
|
|
|
const canvas = await getCanvasFrame(page);
|
|
const frameText = await canvas
|
|
?.locator("body")
|
|
.innerText()
|
|
.catch(() => "");
|
|
const frameHtml = await canvas
|
|
?.locator("body")
|
|
.innerHTML()
|
|
.catch(() => "");
|
|
throw new Error(
|
|
`Expected canvas text "${text}". Frame text: ${frameText}. Frame HTML: ${frameHtml}`,
|
|
{ cause: lastError }
|
|
);
|
|
};
|
|
|
|
export const waitForCanvasTextHidden = async ({
|
|
page,
|
|
text,
|
|
}: {
|
|
page: Page;
|
|
text: string;
|
|
}) => {
|
|
const canvas = await waitForCanvasFrame({ page });
|
|
await canvas.getByText(text, { exact: true }).first().waitFor({
|
|
state: "hidden",
|
|
timeout: 30_000,
|
|
});
|
|
};
|
|
|
|
const openBuilderPage = async (page: Page, url: string): Promise<Frame> => {
|
|
await measure("builder page navigation", () => page.goto(url));
|
|
const canvas = await measure("builder canvas ready", () =>
|
|
waitForCanvasFrame({ page })
|
|
);
|
|
await measure("builder loading indicator hidden", () =>
|
|
page.getByRole("progressbar").waitFor({ state: "hidden", timeout: 30_000 })
|
|
);
|
|
return canvas;
|
|
};
|
|
|
|
export const openProjectBuilder = async ({
|
|
page,
|
|
projectId,
|
|
authToken,
|
|
mode,
|
|
features,
|
|
pageId,
|
|
}: {
|
|
page: Page;
|
|
projectId: string;
|
|
authToken?: string;
|
|
mode?: "content" | "preview";
|
|
features?: string[];
|
|
pageId?: string;
|
|
}): Promise<Frame> => {
|
|
const url = new URL(
|
|
getProjectBuilderUrl({ projectId, authToken, mode, features })
|
|
);
|
|
if (pageId !== undefined) {
|
|
url.searchParams.set("pageId", pageId);
|
|
}
|
|
return await openBuilderPage(page, url.href);
|
|
};
|
|
|
|
export const openBuilderUrl = async ({
|
|
page,
|
|
url,
|
|
}: {
|
|
page: Page;
|
|
url: string;
|
|
}): Promise<Frame> => {
|
|
return await openBuilderPage(page, url);
|
|
};
|