geo/frontend/e2e/tests/trends.spec.ts

47 lines
2.2 KiB
TypeScript

import { test, expect } from "../fixtures";
test.describe("趋势洞察页面", () => {
test.beforeEach(async ({ authenticatedPage }) => {
await authenticatedPage.goto("/dashboard/trends");
await authenticatedPage.waitForLoadState("networkidle");
});
test("趋势洞察页面标题正确显示", async ({ authenticatedPage }) => {
await expect(authenticatedPage.getByRole("heading", { name: "趋势洞察", exact: true })).toBeVisible({ timeout: 15000 });
});
test("趋势洞察页面副标题正确显示", async ({ authenticatedPage }) => {
await expect(authenticatedPage.getByText("分析品牌趋势变化与热点关键词")).toBeVisible({ timeout: 15000 });
});
test("趋势洞察页面显示生成洞察按钮(有品牌时)", 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 refreshBtn = authenticatedPage.getByRole("button", { name: /刷新/ });
const hasBtn = await refreshBtn.isVisible({ timeout: 10000 }).catch(() => false);
if (!hasBtn) { test.skip(); return; }
await expect(refreshBtn).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 });
});
test("无洞察记录时显示空状态(有品牌时)", async ({ authenticatedPage }) => {
const emptyState = authenticatedPage.getByText("暂无洞察记录");
const hasEmpty = await emptyState.isVisible({ timeout: 10000 }).catch(() => false);
if (!hasEmpty) { test.skip(); return; }
await expect(emptyState).toBeVisible();
});
});