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

46 lines
2.1 KiB
TypeScript

import { test, expect } from "../fixtures";
test.describe("知识库页面", () => {
test.beforeEach(async ({ authenticatedPage }) => {
await authenticatedPage.goto("/dashboard/knowledge");
await authenticatedPage.waitForLoadState("networkidle");
});
test("知识库页面标题正确显示", async ({ authenticatedPage }) => {
await expect(authenticatedPage.getByRole("heading", { name: "知识库", exact: true })).toBeVisible({ timeout: 10000 });
});
test("知识库页面副标题正确显示", async ({ authenticatedPage }) => {
await expect(authenticatedPage.getByText("管理行业和企业知识")).toBeVisible({ timeout: 10000 });
});
test("知识库页面显示创建知识库按钮", async ({ authenticatedPage }) => {
await expect(authenticatedPage.getByRole("button", { name: "创建知识库" }).first()).toBeVisible({ timeout: 10000 });
});
test("知识库页面显示企业知识库和行业知识库Tab", async ({ authenticatedPage }) => {
// 等待 Tab 出现(页面可能先显示 loading 状态)
const enterpriseTab = authenticatedPage.getByText(/企业知识库/).first();
const industryTab = authenticatedPage.getByText(/行业知识库/).first();
const hasEnterprise = await enterpriseTab.isVisible({ timeout: 15000 }).catch(() => false);
const hasIndustry = await industryTab.isVisible({ timeout: 3000 }).catch(() => false);
if (!hasEnterprise && !hasIndustry) { test.skip(); return; }
expect(hasEnterprise || hasIndustry).toBeTruthy();
});
test("无知识库时显示空状态", async ({ authenticatedPage }) => {
const emptyState = authenticatedPage.getByText("还没有知识库");
if (await emptyState.isVisible({ timeout: 5000 }).catch(() => false)) {
await expect(emptyState).toBeVisible();
} else {
test.skip();
}
});
test("点击创建知识库打开对话框", async ({ authenticatedPage }) => {
await authenticatedPage.getByRole("button", { name: "创建知识库" }).first().click();
const dialog = authenticatedPage.getByRole("dialog");
await expect(dialog).toBeVisible({ timeout: 10000 });
});
});