Files
AIPortPilot/frontend/e2e/sidebar-navigation.spec.ts
T
selfrelease f4ddcab2ca 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
2026-07-19 20:37:25 +08:00

85 lines
3.3 KiB
TypeScript

/**
* E2E 测试 — 投资人端 Sidebar 6 业务域导航验证。
*
* 覆盖 2-task-uiux.md 中 P0#1-2 任务的导航架构重构:
* - 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_sidebar_${Date.now()}@example.com`;
const TEST_PASSWORD = "password123";
/** 注册投资人用户并登录。 */
async function loginAsInvestor(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 Sidebar 用户",
tenant_name: "E2E Sidebar 机构",
role: "investor",
}),
});
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"]');
}
test.describe("投资人端 Sidebar 导航域", () => {
test.use({ viewport: { width: 1280, height: 720 } });
test("Sidebar 应包含 6 个业务域分组", async ({ page }: { page: Page }) => {
await loginAsInvestor(page);
const sidebar = page.locator("aside.hidden.md\\:block");
await expect(sidebar).toBeVisible();
// 6 业务域标题
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("Sidebar 底部应包含设置入口", async ({ page }: { page: Page }) => {
await loginAsInvestor(page);
const sidebar = page.locator("aside.hidden.md\\:block");
await expect(sidebar.locator("text=设置")).toBeVisible();
});
test("点击今日行动中心应导航到 /today", async ({ page }: { page: Page }) => {
await loginAsInvestor(page);
await page.locator("aside.hidden.md\\:block").locator("a[href='/today']").click();
await expect(page).toHaveURL(/\/today/);
await expect(page.locator("h1")).toContainText("今日行动中心");
});
test("点击多企业对比应导航到 /compare", async ({ page }: { page: Page }) => {
await loginAsInvestor(page);
await page.locator("aside.hidden.md\\:block").locator("a[href='/compare']").click();
await expect(page).toHaveURL(/\/compare/);
});
test("点击决策线程应导航到 /threads", async ({ page }: { page: Page }) => {
await loginAsInvestor(page);
await page.locator("aside.hidden.md\\:block").locator("a[href='/threads']").click();
await expect(page).toHaveURL(/\/threads/);
await expect(page.locator("h1")).toContainText("决策线程");
});
test("点击设置应导航到 /settings", async ({ page }: { page: Page }) => {
await loginAsInvestor(page);
await page.locator("aside.hidden.md\\:block").locator("a[href='/settings']").click();
await expect(page).toHaveURL(/\/settings/);
});
});