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:
@@ -1,19 +1,30 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { Bot, Sparkles } from "lucide-react";
|
||||
import {Sparkles } from "lucide-react";
|
||||
import { listDigitalTwins, buildDigitalTwin, simulateTwin } from "@/lib/api-v2";
|
||||
import { PageContainer, Card, Badge } from "@/components/shared/PageContainer";
|
||||
import { LoadingSpinner } from "@/components/shared/LoadingSpinner";
|
||||
import { EmptyState } from "@/components/shared/EmptyState";
|
||||
import { toast } from "sonner";
|
||||
|
||||
/** 数字孪生模型项。 */
|
||||
interface DigitalTwinItem {
|
||||
accuracy_score?: number;
|
||||
}
|
||||
|
||||
/** 模拟结果。 */
|
||||
interface SimulationResult {
|
||||
projected_outcome: string;
|
||||
confidence?: number;
|
||||
}
|
||||
|
||||
export default function DigitalTwinsPage() {
|
||||
const [items, setItems] = useState<Record<string, any>[]>([]);
|
||||
const [items, setItems] = useState<DigitalTwinItem[]>([]);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [companyData, setCompanyData] = useState("");
|
||||
const [scenario, setScenario] = useState("");
|
||||
const [simResult, setSimResult] = useState<Record<string, any> | null>(null);
|
||||
const [simResult, setSimResult] = useState<SimulationResult | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
listDigitalTwins("")
|
||||
@@ -29,8 +40,8 @@ export default function DigitalTwinsPage() {
|
||||
}
|
||||
try {
|
||||
const resp = await buildDigitalTwin(companyData);
|
||||
toast.success("数字孪生模型已构建");
|
||||
setItems([resp.data as Record<string, any>, ...items]);
|
||||
toast.success("数字孿生模型已构建");
|
||||
setItems([resp.data as DigitalTwinItem, ...items]);
|
||||
} catch {
|
||||
toast.error("构建失败");
|
||||
}
|
||||
@@ -43,7 +54,7 @@ export default function DigitalTwinsPage() {
|
||||
}
|
||||
try {
|
||||
const resp = await simulateTwin({}, scenario);
|
||||
setSimResult(resp.data as Record<string, any>);
|
||||
setSimResult(resp.data as SimulationResult);
|
||||
} catch {
|
||||
toast.error("模拟失败");
|
||||
}
|
||||
@@ -85,9 +96,9 @@ export default function DigitalTwinsPage() {
|
||||
</button>
|
||||
{simResult && (
|
||||
<div className="mt-3 text-sm text-gray-600">
|
||||
<p>预测结果:{simResult.projected_outcome as string}</p>
|
||||
<p>预测结果:{simResult.projected_outcome}</p>
|
||||
{simResult.confidence != null && (
|
||||
<p className="mt-1">置信度:<Badge color="blue">{((simResult.confidence as number) * 100).toFixed(0)}%</Badge></p>
|
||||
<p className="mt-1">置信度:<Badge color="blue">{(simResult.confidence * 100).toFixed(0)}%</Badge></p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
@@ -104,8 +115,8 @@ export default function DigitalTwinsPage() {
|
||||
<div className="flex items-center justify-between">
|
||||
<h3 className="font-medium text-gray-900">数字孪生模型</h3>
|
||||
{item.accuracy_score != null && (
|
||||
<Badge color={(item.accuracy_score as number) > 0.7 ? "green" : "amber"}>
|
||||
精度 {((item.accuracy_score as number) * 100).toFixed(0)}%
|
||||
<Badge color={item.accuracy_score > 0.7 ? "green" : "amber"}>
|
||||
精度 {(item.accuracy_score * 100).toFixed(0)}%
|
||||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user