perf(ci): reduce WebUI browser test overhead (#6580)

* perf(ci): reduce WebUI browser test overhead

* revert(ci): keep the runner package mirror

* perf(webui): use available CI browser workers
This commit is contained in:
chengyongru authored and GitHub committed 2026-11-06 15:09:03 +08:00
1 parent 11f738f0fe
commit fdd30e6dc9
2 files changed
+35 -28

No files matched your search

+33 -27
View File
@@ -84,31 +84,36 @@ for (const width of [390, 1440]) {
}); });
await page.route("**/api/webui/skills/trends?**", (route) => route.fulfill({ json: { trends: {} } })); await page.route("**/api/webui/skills/trends?**", (route) => route.fulfill({ json: { trends: {} } }));
for (const view of ["grouped", "single", "search"]) { for (const view of ["grouped", "single", "search"]) {
const open = async () => { pending = new Promise<void>((resolve) => { release = resolve; });
const requested = page.waitForRequest(view === "search" ? "**/api/webui/skills/search?**" : "**/api/webui/skills/trending?**");
try {
await page.goto(fixture("marketplace")); await page.goto(fixture("marketplace"));
if (view === "single") await page.getByRole("tab", { name: "skills.sh", exact: true }).click(); if (view === "single") await page.getByRole("tab", { name: "skills.sh", exact: true }).click();
if (view === "search") await page.locator("input").fill("project"); if (view === "search") await page.locator("input").fill("project");
}; await requested;
await open();
const loaded = page.locator(".group.py-3\\.5");
await expect(loaded).toHaveCount(view === "single" ? 5 : 10);
const rows = await loaded.evaluateAll((elements) => elements.map((element) => {
const r = element.getBoundingClientRect();
const text = element.querySelector("h3")!.parentElement!.parentElement!.getBoundingClientRect();
return { row: { x: r.x, y: r.y, width: r.width, height: r.height }, text: { x: text.x, width: text.width } };
}));
pending = new Promise<void>((resolve) => { release = resolve; });
try {
await open();
const skeletons = status(page).locator(".py-3\\.5"); const skeletons = status(page).locator(".py-3\\.5");
await expect(skeletons).toHaveCount(rows.length); const count = view === "single" ? 5 : 10;
for (let index = 0; index < rows.length; index++) { await expect(skeletons).toHaveCount(count);
sameBox(await box(skeletons.nth(index)), rows[index].row); const placeholders = [];
for (let index = 0; index < count; index++) {
const row = await box(skeletons.nth(index));
const text = await box(skeletons.nth(index).locator(".flex-1")); const text = await box(skeletons.nth(index).locator(".flex-1"));
expect(text.x).toBe(rows[index].text.x); placeholders.push({ row, text });
expect(text.width).toBe(rows[index].text.width);
} }
await noOverflow(page); await noOverflow(page);
release();
const loaded = page.locator(".group.py-3\\.5");
await expect(loaded).toHaveCount(count);
const rows = await loaded.evaluateAll((elements) => elements.map((element) => {
const r = element.getBoundingClientRect();
const text = element.querySelector("h3")!.parentElement!.parentElement!.getBoundingClientRect();
return { row: { x: r.x, y: r.y, width: r.width, height: r.height }, text: { x: text.x, width: text.width } };
}));
for (let index = 0; index < count; index++) {
sameBox(placeholders[index].row, rows[index].row);
expect(placeholders[index].text.x).toBe(rows[index].text.x);
expect(placeholders[index].text.width).toBe(rows[index].text.width);
}
} finally { release(); pending = undefined; } } finally { release(); pending = undefined; }
await page.goto("about:blank"); await page.goto("about:blank");
} }
@@ -125,23 +130,24 @@ for (const width of [390, 1440]) {
...(provider === "anthropic" ? { label: `Project ${index}`, description: "Code assistance" } : {}) })) } }); ...(provider === "anthropic" ? { label: `Project ${index}`, description: "Code assistance" } : {}) })) } });
}); });
for (const surface of ["models", "models-compact"]) { for (const surface of ["models", "models-compact"]) {
await page.goto(fixture(surface));
await page.getByRole("combobox").click();
const loaded = page.getByRole("option").first();
await expect(loaded).toBeVisible();
await settle(page);
const row = await box(loaded);
const icon = await box(loaded.locator(":scope > :first-child > :first-child"));
pending = new Promise<void>((resolve) => { release = resolve; }); pending = new Promise<void>((resolve) => { release = resolve; });
try { try {
await page.goto(fixture(surface)); await page.goto(fixture(surface));
const requested = page.waitForRequest("**/api/settings/provider-models?**");
await page.getByRole("combobox").click(); await page.getByRole("combobox").click();
await requested;
await expect(status(page)).toBeVisible(); await expect(status(page)).toBeVisible();
await settle(page); await settle(page);
const skeleton = status(page).locator(".px-2.py-1\\.5").first(); const skeleton = status(page).locator(".px-2.py-1\\.5").first();
sameBox(await box(skeleton), row); const row = await box(skeleton);
sameBox(await box(skeleton.locator(":scope > :first-child")), icon); const icon = await box(skeleton.locator(":scope > :first-child"));
await noOverflow(page); await noOverflow(page);
release();
const loaded = page.getByRole("option").first();
await expect(loaded).toBeVisible();
await settle(page);
sameBox(row, await box(loaded));
sameBox(icon, await box(loaded.locator(":scope > :first-child > :first-child")));
} finally { release(); pending = undefined; } } finally { release(); pending = undefined; }
await page.goto("about:blank"); await page.goto("about:blank");
} }
+2 -1
View File
@@ -1,3 +1,4 @@
import { availableParallelism } from "node:os";
import { defineConfig, devices } from "@playwright/test"; import { defineConfig, devices } from "@playwright/test";
const port = Number(process.env.NANOBOT_BROWSER_TEST_PORT ?? 4178); const port = Number(process.env.NANOBOT_BROWSER_TEST_PORT ?? 4178);
@@ -5,7 +6,7 @@ const port = Number(process.env.NANOBOT_BROWSER_TEST_PORT ?? 4178);
export default defineConfig({ export default defineConfig({
testDir: "./browser", testDir: "./browser",
fullyParallel: false, fullyParallel: false,
workers: 2, workers: process.env.CI ? Math.min(3, availableParallelism()) : 2,
retries: 0, retries: 0,
timeout: 30_000, timeout: 30_000,
reporter: "list", reporter: "list",