fix: move page ai launcher to pi lab

This commit is contained in:
Agent Board
2026-07-13 09:00:19 +08:00
parent 2f5902e3e7
commit d6a25afa0a
11 changed files with 80 additions and 73 deletions
+16 -57
View File
@@ -296,64 +296,23 @@ async function main() {
const aiButton = page.locator('[data-testid="wolai-floating-ai"]').first();
await aiButton.waitFor({ state: "visible", timeout: UI_TIMEOUT_MS });
const floatingAiText = ((await aiButton.textContent()) || "").trim();
assert(floatingAiText === "π", `浮动 AI 入口应退役旧 OpenHub 前端并显示 Pi Lab π: ${floatingAiText}`);
await aiButton.click({ timeout: UI_TIMEOUT_MS });
const aiDrawer = page.locator('[data-testid="wolai-page-ai-drawer"]').first();
await aiDrawer.waitFor({ state: "visible", timeout: UI_TIMEOUT_MS });
const aiText = (await aiDrawer.textContent()) || "";
assert(aiText.includes("Hermes"), `Page AI drawer 必须显示 Hermes 入口: ${aiText}`);
assert(await page.locator("[data-page-ai-input]").first().isVisible(), "Page AI drawer 必须显示输入框");
screenshots.pageAi = await saveScreenshot(page, "02-page-ai");
await closePageAiIfOpen(page);
await page.waitForFunction(
() => {
const drawer = document.querySelector('[data-testid="wolai-page-ai-drawer"]');
const trigger = document.querySelector('[data-testid="wolai-floating-ai"]');
return drawer instanceof HTMLElement
&& drawer.hidden === true
&& trigger instanceof HTMLElement
&& trigger.getAttribute("data-state") === "closed"
&& trigger.getAttribute("aria-expanded") === "false";
},
null,
{ timeout: UI_TIMEOUT_MS },
);
await aiButton.click({ timeout: UI_TIMEOUT_MS });
await aiDrawer.waitFor({ state: "visible", timeout: UI_TIMEOUT_MS });
await page.locator("[data-page-ai-input]").fill("Task490 stop smoke", { timeout: UI_TIMEOUT_MS });
await page.locator('[data-page-ai-action="send"]').click({ timeout: UI_TIMEOUT_MS });
await page.waitForFunction(
() => document.documentElement.getAttribute("data-mnote-page-ai-run-status") === "running"
&& document.documentElement.getAttribute("data-mnote-page-ai-run-id") === "run_task490_stop",
null,
{ timeout: UI_TIMEOUT_MS },
);
const stopButton = page.locator('.wolai-page-ai-stop[data-page-ai-action="stop-run"]').first();
await stopButton.waitFor({ state: "visible", timeout: UI_TIMEOUT_MS });
await page.waitForFunction(
() => {
const stop = document.querySelector('.wolai-page-ai-stop[data-page-ai-action="stop-run"]');
return stop instanceof HTMLButtonElement && stop.disabled === false && stop.getAttribute("aria-disabled") === "false";
},
null,
{ timeout: UI_TIMEOUT_MS },
);
await stopButton.click({ timeout: UI_TIMEOUT_MS });
await page.waitForFunction(
() => document.documentElement.getAttribute("data-mnote-page-ai-run-status") === "aborted",
null,
{ timeout: UI_TIMEOUT_MS },
);
await page.locator('[data-page-ai-conversation]').getByText("已请求停止当前 AI run。").waitFor({
state: "visible",
timeout: UI_TIMEOUT_MS,
});
assert(capturedPageAi.runs.length === 1, "Page AI stop smoke 应先发起一个 run");
assert(capturedPageAi.aborts.length === 1, "点击停止应调用 abort API 一次");
const abortBody = JSON.parse(capturedPageAi.aborts[0] || "{}");
assert(abortBody.reason === "page_ai_user_stop", "abort API 应记录用户停止原因");
screenshots.pageAiStopped = await saveScreenshot(page, "02b-page-ai-stopped");
await closePageAiIfOpen(page);
const piDrawer = page.locator('[data-page-ai-pi-lab="drawer"]').first();
await piDrawer.waitFor({ state: "visible", timeout: UI_TIMEOUT_MS });
assert(await page.locator("[data-page-ai-pi-lab-input]").first().isVisible(), "Pi Lab drawer 必须显示输入框");
const retiredFrontend = await page.evaluate(() => ({
legacyDrawerOpen: Boolean(document.querySelector('[data-testid="wolai-page-ai-drawer"]:not([hidden])')),
opencodeHost: Boolean(document.querySelector('[data-page-ai-opencode-host="true"]')),
opencodeIframe: Boolean(document.querySelector('[data-page-ai-opencode-iframe]')),
}));
assert(retiredFrontend.legacyDrawerOpen === false, "浮动 Pi 入口不能打开旧 Page AI/OpenHub drawer");
assert(retiredFrontend.opencodeHost === false, "浮动 Pi 入口不能打开 opencode/OpenHub host 前端");
assert(retiredFrontend.opencodeIframe === false, "浮动 Pi 入口不能保留 opencode/OpenHub iframe");
screenshots.pageAi = await saveScreenshot(page, "02-pi-lab");
await page.locator("[data-page-ai-pi-lab-close]").click({ timeout: UI_TIMEOUT_MS });
await piDrawer.waitFor({ state: "hidden", timeout: UI_TIMEOUT_MS });
await setBlockHandleFixture(page, UI_TIMEOUT_MS);
await editor.click({ timeout: UI_TIMEOUT_MS });