重构基线
This commit is contained in:
@@ -52,6 +52,19 @@ async function saveScreenshot(page, name) {
|
||||
return target;
|
||||
}
|
||||
|
||||
async function assertMaterialIconSurface(locator, label, minCount) {
|
||||
const iconCount = await locator.locator('.material-symbols-outlined, .slash-item-icon, .block-drag-menu-icon').count();
|
||||
if (iconCount < minCount) {
|
||||
throw new Error(`${label} 至少应渲染 ${minCount} 个图标容器,实际: ${iconCount}`);
|
||||
}
|
||||
const text = ((await locator.textContent()) || '').trim();
|
||||
const legacyGlyphs = ['⚙', '×', '✕', '⋮', '◣', '↻'];
|
||||
const leaked = legacyGlyphs.filter((glyph) => text.includes(glyph));
|
||||
if (leaked.length > 0) {
|
||||
throw new Error(`${label} 不应泄漏旧 Unicode 图标: ${leaked.join(', ')}`);
|
||||
}
|
||||
}
|
||||
|
||||
async function waitForRuntimeIsland(page, uiTimeoutMs) {
|
||||
const root = page.locator('[data-testid="mnote-leptos-tiptap-island-editor-root"]').first();
|
||||
await root.waitFor({ state: "visible", timeout: uiTimeoutMs });
|
||||
@@ -110,7 +123,12 @@ async function setBlockHandleFixture(page, uiTimeoutMs) {
|
||||
async function closePageAiIfOpen(page) {
|
||||
const closeButton = page.locator('[data-page-ai-action="close"]').first();
|
||||
if (await closeButton.isVisible().catch(() => false)) {
|
||||
await closeButton.click().catch(() => undefined);
|
||||
await closeButton.click({ force: true }).catch(async () => {
|
||||
await page.evaluate(() => {
|
||||
const button = document.querySelector('[data-page-ai-action="close"]');
|
||||
if (button instanceof HTMLElement) button.click();
|
||||
}).catch(() => undefined);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,6 +252,7 @@ async function main() {
|
||||
});
|
||||
});
|
||||
await page.route("**/api/hermes/client/events/run_task490_stop", async (route) => {
|
||||
await new Promise((resolve) => setTimeout(resolve, UI_TIMEOUT_MS * 2));
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
headers: { "content-type": "text/event-stream; charset=utf-8" },
|
||||
@@ -309,11 +328,11 @@ async function main() {
|
||||
null,
|
||||
{ timeout: UI_TIMEOUT_MS },
|
||||
);
|
||||
const stopButton = page.locator('[data-page-ai-action="stop-run"]').first();
|
||||
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('[data-page-ai-action="stop-run"]');
|
||||
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,
|
||||
@@ -343,6 +362,7 @@ async function main() {
|
||||
await slashMenu.waitFor({ state: "visible", timeout: UI_TIMEOUT_MS });
|
||||
const slashText = (await slashMenu.textContent()) || "";
|
||||
assert(slashText.trim().length > 0, "slash menu 必须显示可选项");
|
||||
await assertMaterialIconSurface(slashMenu, "slash menu", 4);
|
||||
screenshots.slashMenu = await saveScreenshot(page, "03-slash-menu");
|
||||
await page.keyboard.press("Escape");
|
||||
|
||||
@@ -358,6 +378,7 @@ async function main() {
|
||||
await blockMenu.waitFor({ state: "visible", timeout: UI_TIMEOUT_MS });
|
||||
const blockMenuText = (await blockMenu.textContent()) || "";
|
||||
assert(blockMenuText.includes("删除") || blockMenuText.includes("Delete"), `block handle menu 缺少基础操作: ${blockMenuText}`);
|
||||
await assertMaterialIconSurface(blockMenu, "block handle menu", 8);
|
||||
screenshots.blockHandleMenu = await saveScreenshot(page, "04-block-handle-menu");
|
||||
|
||||
const result = {
|
||||
|
||||
Reference in New Issue
Block a user