From a6bd4b0432e971cd48f9e1b635dfda0a2cdc7cff Mon Sep 17 00:00:00 2001 From: zhengwr Date: Sat, 20 Jun 2026 09:56:52 +0800 Subject: [PATCH] =?UTF-8?q?feat(routes):=20=E6=8E=A5=E7=BA=BF=20/new-featu?= =?UTF-8?q?re=20=E4=B8=8E=20/ai-feature=EF=BC=88admin-gated=20=E9=A1=B5?= =?UTF-8?q?=E5=86=85=E5=AE=88=E6=8A=A4=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 (1M context) --- src/App.routes.test.tsx | 47 +++++++++++++++++++++++++++++++++++++++++ src/App.tsx | 5 +++++ 2 files changed, 52 insertions(+) create mode 100644 src/App.routes.test.tsx diff --git a/src/App.routes.test.tsx b/src/App.routes.test.tsx new file mode 100644 index 0000000..31f1b5e --- /dev/null +++ b/src/App.routes.test.tsx @@ -0,0 +1,47 @@ +import '@testing-library/jest-dom'; +import { render, screen, waitFor } from '@testing-library/react'; +import { MemoryRouter, Routes, Route } from 'react-router-dom'; +import { vi, describe, it, expect } from 'vitest'; +import { NewFeatureShell } from './pages/NewFeatureShell'; +import { AiFeatureForm } from './pages/AiFeatureForm'; + +vi.mock('./auth/token', () => ({ + getProfile: () => ({ userId: 'ADMIN', account: 'admin', name: 'x', roles: [] }), +})); +vi.mock('./api/meta', () => ({ listEntities: vi.fn().mockResolvedValue([]), createEntity: vi.fn() })); +vi.mock('./api/recipe', () => ({ + listRecipes: () => [{ id: 'maintenance-crud-v1', label: '维护型 CRUD' }], + compileRecipe: vi.fn(), +})); +vi.mock('./api/publish', () => ({ publishFeature: vi.fn() })); +vi.mock('./api/menu', () => ({ fetchMenu: vi.fn().mockResolvedValue({ roots: [] }), collectLeaves: vi.fn() })); +vi.mock('./api/ai', async (io) => { + const actual = await io(); + return { ...actual, autoDevelop: vi.fn() }; +}); + +describe('新路由可达', () => { + it('/new-feature 渲染 NewFeatureShell', async () => { + render( + + + } /> + } /> + + , + ); + await waitFor(() => expect(screen.getByTestId('new-feature-shell')).toBeInTheDocument()); + }); + + it('/ai-feature 渲染 AiFeatureForm', () => { + render( + + + } /> + } /> + + , + ); + expect(screen.getByTestId('ai-feature-form')).toBeInTheDocument(); + }); +}); diff --git a/src/App.tsx b/src/App.tsx index 0854115..bf0d160 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -8,6 +8,8 @@ import { PageRenderPage } from './pages/PageRenderPage'; import { TodoPage } from './pages/TodoPage'; import { WorkbenchPage } from './pages/WorkbenchPage'; import { DesignCenterPage } from './pages/DesignCenterPage'; +import { NewFeatureShell } from './pages/NewFeatureShell'; +import { AiFeatureForm } from './pages/AiFeatureForm'; import { ModelerPage } from './pages/ModelerPage'; // 把 401 跳登录的 handler 注入 http 层(在路由上下文内,可用 navigate) @@ -41,6 +43,9 @@ export default function App() { } /> {/* 设计中心(管理员集中式低代码设计入口,替代每页设计按钮)*/} } /> + {/* 人走五环编排壳 + AI ①面入口(admin-gated,页内早返回守护)*/} + } /> + } /> {/* 建模器(五环第①环·元数据→表,仅管理员)*/} } /> {/* 根路径默认跳工作台 */}