test(frontend): UIUX E2E 测试 — 新增路由导航/创始人端/Admin端/工作台/移动端适配
新增 6 个 E2E 测试文件,覆盖 2-task-uiux.md 全部 50 项任务: - uiux-navigation.spec.ts: 8 tests (today/compare/threads/workspace/ooda/ai-plus/profiles) - sidebar-navigation.spec.ts: 6 tests (投资人 Sidebar 6 业务域) - founder-uiux.spec.ts: 7 tests (创始人端 6 域导航) - admin-uiux.spec.ts: 3 tests (Admin 6 管理域 + 商业秘密保护) - workbench-uiux.spec.ts: 5 tests (Highlights/WorkMode/Tab/InsightRail) - mobile-uiux.spec.ts: 5 tests (移动端抽屉导航 + 创始人底部导航) 同时修复全部 no-explicit-any 警告,替换为 TypeScript 接口定义。 测试结果: 41 E2E passed, 405 backend passed
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* E2E 测试 — Admin 端 UIUX 导航与页面渲染验证。
|
||||
*
|
||||
* 覆盖 2-task-uiux.md 中 P0#7 + P2#28 任务的以下路由:
|
||||
* - /admin(系统概览)
|
||||
* - /admin/security(商业秘密保护配置)
|
||||
*
|
||||
* 验证 Admin 6 管理域 Sidebar 布局正确性。
|
||||
*
|
||||
* 前置条件:后端 http://localhost:8000 + 前端 http://localhost:3000 已启动。
|
||||
*/
|
||||
|
||||
import { test, expect, type Page } from "@playwright/test";
|
||||
|
||||
const API_BASE = "http://localhost:8000/api/v1";
|
||||
const TEST_EMAIL = `e2e_admin_${Date.now()}@example.com`;
|
||||
const TEST_PASSWORD = "password123";
|
||||
|
||||
/** 注册 Admin 用户并登录。 */
|
||||
async function loginAsAdmin(page: Page) {
|
||||
await fetch(`${API_BASE}/auth/register`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
email: TEST_EMAIL,
|
||||
password: TEST_PASSWORD,
|
||||
name: "E2E Admin 用户",
|
||||
tenant_name: "E2E Admin 机构",
|
||||
role: "admin",
|
||||
}),
|
||||
});
|
||||
|
||||
await page.goto("/login");
|
||||
await page.fill('input[id="email"]', TEST_EMAIL);
|
||||
await page.fill('input[id="password"]', TEST_PASSWORD);
|
||||
await page.click('button[type="submit"]');
|
||||
// Admin 用户登录后可能重定向到投资人端,需显式导航
|
||||
await page.goto('/admin');
|
||||
}
|
||||
|
||||
test.describe("Admin 端 UIUX 导航", () => {
|
||||
test("Admin 首页应显示系统概览和 ADMIN 徽章", async ({ page }: { page: Page }) => {
|
||||
await loginAsAdmin(page);
|
||||
// 应在 admin 页面
|
||||
await expect(page).toHaveURL(/\/admin/);
|
||||
// 应显示 ADMIN 徽章
|
||||
await expect(page.locator("text=ADMIN").first()).toBeVisible();
|
||||
});
|
||||
|
||||
test("Admin Sidebar 应包含 6 个管理域", async ({ page }: { page: Page }) => {
|
||||
await loginAsAdmin(page);
|
||||
// Sidebar 应包含 6 个管理域标题
|
||||
const sidebar = page.locator("aside");
|
||||
await expect(sidebar.locator("text=租户管理").first()).toBeVisible();
|
||||
await expect(sidebar.locator("text=用户管理").first()).toBeVisible();
|
||||
await expect(sidebar.locator("text=审计日志").first()).toBeVisible();
|
||||
await expect(sidebar.locator("text=数据源").first()).toBeVisible();
|
||||
await expect(sidebar.locator("text=安全配置").first()).toBeVisible();
|
||||
await expect(sidebar.locator("text=系统设置").first()).toBeVisible();
|
||||
});
|
||||
|
||||
test("商业秘密保护 /admin/security 应显示密级配置", async ({ page }: { page: Page }) => {
|
||||
await loginAsAdmin(page);
|
||||
await page.goto("/admin/security");
|
||||
await expect(page).toHaveURL(/\/admin\/security/);
|
||||
await expect(page.locator("h1")).toContainText("商业秘密");
|
||||
// 应显示密级选项按钮
|
||||
await expect(page.getByRole("button", { name: /公开/ })).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: /机密/ })).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: /绝密/ })).toBeVisible();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user