import { test, expect } from "../fixtures"; test.describe("Schema建议页面", () => { test.beforeEach(async ({ authenticatedPage }) => { await authenticatedPage.goto("/dashboard/schema"); await authenticatedPage.waitForLoadState("networkidle"); }); test("Schema建议页面标题正确显示", async ({ authenticatedPage }) => { await expect(authenticatedPage.getByRole("heading", { name: /Schema\s*建议/ })).toBeVisible({ timeout: 10000 }); }); test("Schema建议页面副标题正确显示", async ({ authenticatedPage }) => { await expect(authenticatedPage.getByText("结构化数据优化建议")).toBeVisible({ timeout: 10000 }); }); test("Schema建议页面显示生成建议按钮(有品牌时)", async ({ authenticatedPage }) => { const generateBtn = authenticatedPage.getByRole("button", { name: "生成建议" }); const hasBtn = await generateBtn.isVisible({ timeout: 10000 }).catch(() => false); if (!hasBtn) { test.skip(); return; } await expect(generateBtn).toBeVisible(); }); test("点击生成建议打开对话框(有品牌时)", async ({ authenticatedPage }) => { const generateBtn = authenticatedPage.getByRole("button", { name: "生成建议" }); const hasBtn = await generateBtn.isVisible({ timeout: 10000 }).catch(() => false); if (!hasBtn) { test.skip(); return; } await generateBtn.click(); const dialog = authenticatedPage.getByRole("dialog"); await expect(dialog).toBeVisible({ timeout: 10000 }); const urlInput = dialog.getByPlaceholder(/URL|网址|链接/).or(dialog.locator("input").first()); await expect(urlInput).toBeVisible({ timeout: 5000 }); }); test("无Schema建议时显示空状态", async ({ authenticatedPage }) => { const emptyState = authenticatedPage.getByText("暂无 Schema 建议"); if (await emptyState.isVisible({ timeout: 5000 }).catch(() => false)) { await expect(emptyState).toBeVisible(); } else { test.skip(); } }); });