import { test, expect } from "../fixtures"; test.describe("内容分发中心 - 页面渲染测试", () => { test.beforeEach(async ({ authenticatedPage }) => { await authenticatedPage.goto("/dashboard/distribution"); await authenticatedPage.waitForLoadState("networkidle"); }); test("内容分发中心页面标题正确显示", async ({ authenticatedPage }) => { await expect( authenticatedPage.getByRole("heading", { name: "内容分发中心" }) ).toBeVisible({ timeout: 15000 }); }); test("内容分发中心页面副标题正确显示", async ({ authenticatedPage }) => { await expect( authenticatedPage.getByText("多平台智能分发与发布管理") ).toBeVisible({ timeout: 15000 }); }); test("内容分发中心页面显示平台规则和发布记录Tab", async ({ authenticatedPage }) => { const platformTab = authenticatedPage.getByRole("tab", { name: /平台规则/ }); const publishedTab = authenticatedPage.getByRole("tab", { name: /发布记录/ }); const hasPlatformTab = await platformTab.isVisible({ timeout: 10000 }).catch(() => false); const hasPublishedTab = await publishedTab.isVisible({ timeout: 5000 }).catch(() => false); if (!hasPlatformTab && !hasPublishedTab) { test.skip(); return; } expect(hasPlatformTab || hasPublishedTab).toBeTruthy(); }); }); test.describe("内容分发中心 - 平台规则Tab测试", () => { test.beforeEach(async ({ authenticatedPage }) => { await authenticatedPage.goto("/dashboard/distribution"); await authenticatedPage.waitForLoadState("networkidle"); }); test("平台规则Tab显示平台卡片或空状态", async ({ authenticatedPage }) => { const platformTab = authenticatedPage.getByRole("tab", { name: /平台规则/ }); const hasTab = await platformTab.isVisible({ timeout: 10000 }).catch(() => false); if (hasTab) { await platformTab.click(); await authenticatedPage.waitForLoadState("networkidle"); } const emptyState = authenticatedPage.getByText("暂无平台配置"); const platformCard = authenticatedPage.locator("[class*='rounded-xl'][class*='border']").filter({ hasText: /字上限/ }); const hasEmpty = await emptyState.isVisible({ timeout: 10000 }).catch(() => false); const hasCards = await platformCard.isVisible({ timeout: 5000 }).catch(() => false); expect(hasEmpty || hasCards).toBeTruthy(); }); }); test.describe("内容分发中心 - 发布记录Tab测试", () => { test.beforeEach(async ({ authenticatedPage }) => { await authenticatedPage.goto("/dashboard/distribution"); await authenticatedPage.waitForLoadState("networkidle"); }); test("点击发布记录Tab切换到发布记录", async ({ authenticatedPage }) => { const publishedTab = authenticatedPage.getByRole("tab", { name: /发布记录/ }); const hasTab = await publishedTab.isVisible({ timeout: 10000 }).catch(() => false); if (!hasTab) { test.skip(); return; } await publishedTab.click(); await authenticatedPage.waitForLoadState("networkidle"); const table = authenticatedPage.locator("table"); const emptyState = authenticatedPage.getByText("暂无发布记录"); const hasTable = await table.isVisible({ timeout: 10000 }).catch(() => false); const hasEmpty = await emptyState.isVisible({ timeout: 5000 }).catch(() => false); expect(hasTable || hasEmpty).toBeTruthy(); }); test("无发布记录时显示空状态", async ({ authenticatedPage }) => { const emptyState = authenticatedPage.getByText("暂无发布记录"); const hasEmpty = await emptyState.isVisible({ timeout: 5000 }).catch(() => false); if (!hasEmpty) { test.skip(); return; } await expect(emptyState).toBeVisible(); }); });