Ryuiso 5 mesiacov pred
rodič
commit
c1e7c6dd5e
3 zmenil súbory, kde vykonal 0 pridanie a 817 odobranie
  1. 0 171
      tests/README.md
  2. 0 344
      tests/platform-migration.test.js
  3. 0 302
      tests/zhipu-routing.test.js

+ 0 - 171
tests/README.md

@@ -1,171 +0,0 @@
-# 测试文档
-
-## 概述
-
-本项目包含严格的单元测试,用于验证平台迁移和代码结构的正确性。
-
-## 测试文件
-
-### `platform-migration.test.js`
-
-这是一个综合性的平台迁移测试套件,包含以下测试类别:
-
-#### 1. 目录结构测试
-- ✅ 验证 `platforms` 目录存在
-- ✅ 验证 `zhipu` 目录存在
-- ✅ 验证 `zhipu` 子目录完整(questionAnswer, knowledgeLib, dataExport)
-- ✅ 验证 `deepseek` 目录保持存在
-
-#### 2. 路由配置测试
-- ✅ 验证 zhipu 路由路径配置(至少3个路径)
-- ✅ 验证 zhipu 导入路径配置(至少5个导入)
-- ✅ 验证没有遗留旧路径引用
-- ✅ 验证 deepseek 路由路径保持正确
-
-#### 3. 文件完整性测试
-- ✅ 验证关键文件存在
-- ✅ 验证文件内容可读
-- ✅ 验证所有必要的组件文件
-
-#### 4. 导入路径测试
-- ✅ 验证没有遗留旧导入路径
-- ✅ 验证新导入路径被正确使用
-- ✅ 验证路径引用的一致性
-
-#### 5. 构建兼容性测试
-- ✅ 验证 TypeScript 配置存在
-- ✅ 验证 Vite 配置存在
-- ✅ 验证 package.json 存在
-
-## 运行测试
-
-```bash
-# 运行平台迁移测试
-node tests/platform-migration.test.js
-```
-
-## 测试结果示例
-
-```
-🚀 开始平台迁移测试...
-
-🏗️  测试目录结构...
-🛣️  测试路由配置...
-📁 测试文件完整性...
-📦 测试导入路径...
-🔨 测试构建兼容性...
-
-📊 测试结果汇总:
-   总测试数: 23
-   通过: 23
-   失败: 0
-   成功率: 100.00%
-
-📋 详细结果:
-   1. ✅ platforms 目录存在
-   2. ✅ zhipu 目录存在
-   3. ✅ zhipu 子目录完整
-   ...
-
-🎉 所有测试通过!平台迁移成功。
-```
-
-## 测试覆盖率
-
-当前测试覆盖了以下关键方面:
-
-- **目录结构**: 100% 覆盖
-- **路由配置**: 100% 覆盖
-- **文件完整性**: 100% 覆盖
-- **导入路径**: 100% 覆盖
-- **构建兼容性**: 100% 覆盖
-
-## 最近修复记录
-
-### 智谱AI路由跳转问题修复 (2024-01-XX)
-
-**问题描述**: 智谱AI平台切换后,所有按钮都会重定向到404页面。
-
-**根本原因**: 
-1. 导航组件中的智谱AI菜单项仍使用旧路径(`/questionAnswer`、`/knowledgeLib`、`/dataExport`)
-2. 布局组件中的默认路径切换逻辑仍使用旧路径
-
-**修复内容**:
-1. 更新 `src/pages/layout/components/Nav.tsx` 中的智谱AI菜单项路径:
-   - `/questionAnswer` → `/zhipu/questionAnswer`
-   - `/knowledgeLib` → `/zhipu/knowledgeLib`
-   - `/dataExport` → `/zhipu/dataExport`
-
-2. 更新 `src/pages/layout/index.tsx` 中的默认路径切换逻辑:
-   - 智谱AI默认路径从 `/questionAnswer` 改为 `/zhipu/questionAnswer`
-
-**验证结果**:
-- ✅ 所有测试通过(23项测试,100%通过率)
-- ✅ 构建成功
-- ✅ 智谱AI平台路由跳转正常
-
-## 添加新测试
-
-要添加新的测试用例,请在 `PlatformMigrationTests` 类中添加新的测试方法:
-
-```javascript
-testNewFeature() {
-    console.log('\n🔍 测试新功能...');
-    
-    // 测试逻辑
-    const result = someTestLogic();
-    
-    this.collector.addResult(
-        '新功能测试',
-        result,
-        result ? '' : '测试失败的原因'
-    );
-}
-```
-
-然后在 `runAllTests()` 方法中调用新测试:
-
-```javascript
-runAllTests() {
-    console.log('🚀 开始平台迁移测试...\n');
-    
-    this.testDirectoryStructure();
-    this.testRouterConfiguration();
-    this.testFileIntegrity();
-    this.testImportPaths();
-    this.testBuildCompatibility();
-    this.testNewFeature(); // 添加新测试
-    
-    // 输出结果
-    this.collector.printResults();
-}
-```
-
-## 测试最佳实践
-
-1. **测试隔离**: 每个测试应该独立运行,不依赖其他测试的结果
-2. **清晰命名**: 测试名称应该清楚地描述测试的目的
-3. **详细错误信息**: 失败时提供详细的错误信息,便于调试
-4. **覆盖率**: 确保测试覆盖所有关键功能点
-5. **自动化**: 测试应该能够自动化运行,无需人工干预
-
-## 持续集成
-
-建议在 CI/CD 流程中包含这些测试:
-
-```yaml
-# .github/workflows/test.yml
-name: Platform Migration Tests
-on: [push, pull_request]
-jobs:
-  test:
-    runs-on: ubuntu-latest
-    steps:
-      - uses: actions/checkout@v2
-      - uses: actions/setup-node@v2
-        with:
-          node-version: '18'
-      - run: npm install
-      - run: node tests/platform-migration.test.js
-      - run: npm run build
-```

+ 0 - 344
tests/platform-migration.test.js

@@ -1,344 +0,0 @@
-import fs from 'fs';
-import path from 'path';
-import { fileURLToPath } from 'url';
-
-const __filename = fileURLToPath(import.meta.url);
-const __dirname = path.dirname(__filename);
-
-// 测试配置
-const TEST_CONFIG = {
-    sourceDir: path.join(__dirname, '..', 'src'),
-    platformsDir: path.join(__dirname, '..', 'src', 'pages', 'platforms'),
-    zhipuDir: path.join(__dirname, '..', 'src', 'pages', 'platforms', 'zhipu'),
-    deepseekDir: path.join(__dirname, '..', 'src', 'pages', 'deepseek'),
-    routerFile: path.join(__dirname, '..', 'src', 'router.tsx'),
-    apiFile: path.join(__dirname, '..', 'src', 'apis', 'index.ts'),
-};
-
-// 测试结果收集器
-class TestResultCollector {
-    constructor() {
-        this.results = [];
-        this.passed = 0;
-        this.failed = 0;
-    }
-
-    addResult(testName, passed, details = '') {
-        const result = { testName, passed, details, timestamp: new Date() };
-        this.results.push(result);
-        if (passed) {
-            this.passed++;
-        } else {
-            this.failed++;
-        }
-    }
-
-    getSummary() {
-        return {
-            total: this.results.length,
-            passed: this.passed,
-            failed: this.failed,
-            successRate: this.results.length > 0 ? (this.passed / this.results.length * 100).toFixed(2) : 0
-        };
-    }
-
-    printResults() {
-        console.log('\n📊 测试结果汇总:');
-        console.log(`   总测试数: ${this.results.length}`);
-        console.log(`   通过: ${this.passed}`);
-        console.log(`   失败: ${this.failed}`);
-        console.log(`   成功率: ${this.getSummary().successRate}%`);
-        
-        console.log('\n📋 详细结果:');
-        this.results.forEach((result, index) => {
-            const status = result.passed ? '✅' : '❌';
-            console.log(`   ${index + 1}. ${status} ${result.testName}`);
-            if (!result.passed && result.details) {
-                console.log(`      详情: ${result.details}`);
-            }
-        });
-    }
-}
-
-// 测试工具函数
-class TestUtils {
-    static fileExists(filePath) {
-        try {
-            return fs.existsSync(filePath);
-        } catch (error) {
-            return false;
-        }
-    }
-
-    static readFile(filePath) {
-        try {
-            return fs.readFileSync(filePath, 'utf8');
-        } catch (error) {
-            return null;
-        }
-    }
-
-    static listDirectories(dirPath) {
-        try {
-            return fs.readdirSync(dirPath, { withFileTypes: true })
-                .filter(dirent => dirent.isDirectory())
-                .map(dirent => dirent.name);
-        } catch (error) {
-            return [];
-        }
-    }
-
-    static countOccurrences(text, pattern) {
-        const matches = text.match(new RegExp(pattern, 'g'));
-        return matches ? matches.length : 0;
-    }
-}
-
-// 测试用例
-class PlatformMigrationTests {
-    constructor() {
-        this.collector = new TestResultCollector();
-    }
-
-    // 测试1: 验证目录结构
-    testDirectoryStructure() {
-        console.log('\n🏗️  测试目录结构...');
-        
-        // 测试 platforms 目录存在
-        const platformsExists = TestUtils.fileExists(TEST_CONFIG.platformsDir);
-        this.collector.addResult(
-            'platforms 目录存在',
-            platformsExists,
-            platformsExists ? '' : `目录不存在: ${TEST_CONFIG.platformsDir}`
-        );
-
-        // 测试 zhipu 目录存在
-        const zhipuExists = TestUtils.fileExists(TEST_CONFIG.zhipuDir);
-        this.collector.addResult(
-            'zhipu 目录存在',
-            zhipuExists,
-            zhipuExists ? '' : `目录不存在: ${TEST_CONFIG.zhipuDir}`
-        );
-
-        // 测试 zhipu 子目录
-        if (zhipuExists) {
-            const zhipuSubDirs = TestUtils.listDirectories(TEST_CONFIG.zhipuDir);
-            const expectedDirs = ['questionAnswer', 'knowledgeLib', 'dataExport'];
-            const missingDirs = expectedDirs.filter(dir => !zhipuSubDirs.includes(dir));
-            
-            this.collector.addResult(
-                'zhipu 子目录完整',
-                missingDirs.length === 0,
-                missingDirs.length > 0 ? `缺少目录: ${missingDirs.join(', ')}` : ''
-            );
-        }
-
-        // 测试 deepseek 目录仍然存在
-        const deepseekExists = TestUtils.fileExists(TEST_CONFIG.deepseekDir);
-        this.collector.addResult(
-            'deepseek 目录保持存在',
-            deepseekExists,
-            deepseekExists ? '' : `目录不存在: ${TEST_CONFIG.deepseekDir}`
-        );
-    }
-
-    // 测试2: 验证路由配置
-    testRouterConfiguration() {
-        console.log('\n🛣️  测试路由配置...');
-        
-        const routerContent = TestUtils.readFile(TEST_CONFIG.routerFile);
-        if (!routerContent) {
-            this.collector.addResult('路由文件可读', false, '无法读取路由文件');
-            return;
-        }
-
-        // 测试 zhipu 路由路径
-        const zhipuPathCount = TestUtils.countOccurrences(routerContent, '/zhipu/');
-        this.collector.addResult(
-            'zhipu 路由路径配置',
-            zhipuPathCount >= 3,
-            zhipuPathCount < 3 ? `期望至少3个zhipu路径,实际找到${zhipuPathCount}个` : ''
-        );
-
-        // 测试 zhipu 导入路径
-        const zhipuImportCount = TestUtils.countOccurrences(routerContent, '@/pages/platforms/zhipu/');
-        this.collector.addResult(
-            'zhipu 导入路径配置',
-            zhipuImportCount >= 5,
-            zhipuImportCount < 5 ? `期望至少5个zhipu导入路径,实际找到${zhipuImportCount}个` : ''
-        );
-
-        // 测试没有遗留的旧路径
-        const oldPathCount = TestUtils.countOccurrences(routerContent, '@/pages/(questionAnswer|knowledgeLib|dataExport)');
-        this.collector.addResult(
-            '没有遗留旧路径',
-            oldPathCount === 0,
-            oldPathCount > 0 ? `发现${oldPathCount}个遗留的旧路径引用` : ''
-        );
-
-        // 测试 deepseek 路径仍然正确
-        const deepseekPathCount = TestUtils.countOccurrences(routerContent, '/deepseek/');
-        this.collector.addResult(
-            'deepseek 路由路径保持',
-            deepseekPathCount >= 3,
-            deepseekPathCount < 3 ? `期望至少3个deepseek路径,实际找到${deepseekPathCount}个` : ''
-        );
-    }
-
-    // 测试3: 验证文件完整性
-    testFileIntegrity() {
-        console.log('\n📁 测试文件完整性...');
-        
-        // 测试关键文件存在
-        const criticalFiles = [
-            path.join(TEST_CONFIG.zhipuDir, 'questionAnswer', 'list', 'index.tsx'),
-            path.join(TEST_CONFIG.zhipuDir, 'questionAnswer', 'info', 'index.tsx'),
-            path.join(TEST_CONFIG.zhipuDir, 'knowledgeLib', 'list', 'index.tsx'),
-            path.join(TEST_CONFIG.zhipuDir, 'knowledgeLib', 'detail', 'index.tsx'),
-            path.join(TEST_CONFIG.zhipuDir, 'dataExport', 'index.tsx'),
-        ];
-
-        criticalFiles.forEach(filePath => {
-            const exists = TestUtils.fileExists(filePath);
-            const fileName = path.basename(filePath);
-            this.collector.addResult(
-                `文件存在: ${fileName}`,
-                exists,
-                exists ? '' : `文件不存在: ${filePath}`
-            );
-        });
-
-        // 测试文件内容可读
-        const testFile = path.join(TEST_CONFIG.zhipuDir, 'questionAnswer', 'list', 'index.tsx');
-        const content = TestUtils.readFile(testFile);
-        this.collector.addResult(
-            '文件内容可读',
-            content !== null,
-            content === null ? `无法读取文件内容: ${testFile}` : ''
-        );
-    }
-
-    // 测试4: 验证导入路径
-    testImportPaths() {
-        console.log('\n📦 测试导入路径...');
-        
-        // 检查是否有任何文件引用了旧的路径
-        const oldImportPatterns = [
-            '@/pages/questionAnswer',
-            '@/pages/knowledgeLib', 
-            '@/pages/dataExport'
-        ];
-
-        oldImportPatterns.forEach(pattern => {
-            const files = this.findFilesWithPattern(pattern);
-            this.collector.addResult(
-                `没有遗留 ${pattern} 导入`,
-                files.length === 0,
-                files.length > 0 ? `发现${files.length}个文件包含旧导入: ${files.slice(0, 3).join(', ')}` : ''
-            );
-        });
-
-        // 检查新的导入路径
-        const newImportPatterns = [
-            '@/pages/platforms/zhipu/questionAnswer',
-            '@/pages/platforms/zhipu/knowledgeLib',
-            '@/pages/platforms/zhipu/dataExport'
-        ];
-
-        newImportPatterns.forEach(pattern => {
-            const files = this.findFilesWithPattern(pattern);
-            this.collector.addResult(
-                `新导入路径 ${pattern} 被使用`,
-                files.length > 0,
-                files.length === 0 ? `没有找到使用新导入路径的文件` : ''
-            );
-        });
-    }
-
-    // 测试5: 验证构建兼容性
-    testBuildCompatibility() {
-        console.log('\n🔨 测试构建兼容性...');
-        
-        // 检查 TypeScript 配置
-        const tsConfigPath = path.join(__dirname, '..', 'tsconfig.json');
-        const tsConfigExists = TestUtils.fileExists(tsConfigPath);
-        this.collector.addResult(
-            'TypeScript 配置存在',
-            tsConfigExists,
-            tsConfigExists ? '' : 'tsconfig.json 不存在'
-        );
-
-        // 检查 Vite 配置
-        const viteConfigPath = path.join(__dirname, '..', 'vite.config.ts');
-        const viteConfigExists = TestUtils.fileExists(viteConfigPath);
-        this.collector.addResult(
-            'Vite 配置存在',
-            viteConfigExists,
-            viteConfigExists ? '' : 'vite.config.ts 不存在'
-        );
-
-        // 检查 package.json
-        const packageJsonPath = path.join(__dirname, '..', 'package.json');
-        const packageJsonExists = TestUtils.fileExists(packageJsonPath);
-        this.collector.addResult(
-            'package.json 存在',
-            packageJsonExists,
-            packageJsonExists ? '' : 'package.json 不存在'
-        );
-    }
-
-    // 辅助方法:查找包含特定模式的文件
-    findFilesWithPattern(pattern) {
-        const files = [];
-        this.searchInDirectory(TEST_CONFIG.sourceDir, pattern, files);
-        return files;
-    }
-
-    searchInDirectory(dir, pattern, files) {
-        try {
-            const items = fs.readdirSync(dir);
-            items.forEach(item => {
-                const fullPath = path.join(dir, item);
-                const stat = fs.statSync(fullPath);
-                
-                if (stat.isDirectory()) {
-                    this.searchInDirectory(fullPath, pattern, files);
-                } else if (stat.isFile() && /\.(ts|tsx|js|jsx)$/.test(item)) {
-                    const content = TestUtils.readFile(fullPath);
-                    if (content && content.includes(pattern)) {
-                        files.push(path.relative(TEST_CONFIG.sourceDir, fullPath));
-                    }
-                }
-            });
-        } catch (error) {
-            // 忽略错误,继续搜索
-        }
-    }
-
-    // 运行所有测试
-    runAllTests() {
-        console.log('🚀 开始平台迁移测试...\n');
-        
-        this.testDirectoryStructure();
-        this.testRouterConfiguration();
-        this.testFileIntegrity();
-        this.testImportPaths();
-        this.testBuildCompatibility();
-
-        // 输出结果
-        this.collector.printResults();
-
-        // 返回测试结果
-        const summary = this.collector.getSummary();
-        if (summary.failed > 0) {
-            console.log('\n⚠️  部分测试失败,请检查上述问题。');
-            process.exit(1);
-        } else {
-            console.log('\n🎉 所有测试通过!平台迁移成功。');
-        }
-    }
-}
-
-// 运行测试
-const tests = new PlatformMigrationTests();
-tests.runAllTests();

+ 0 - 302
tests/zhipu-routing.test.js

@@ -1,302 +0,0 @@
-import fs from 'fs';
-import path from 'path';
-import { fileURLToPath } from 'url';
-
-const __filename = fileURLToPath(import.meta.url);
-const __dirname = path.dirname(__filename);
-
-// 测试配置
-const TEST_CONFIG = {
-    routerFile: path.join(__dirname, '..', 'src', 'router.tsx'),
-    navFile: path.join(__dirname, '..', 'src', 'pages', 'layout', 'components', 'Nav.tsx'),
-    layoutFile: path.join(__dirname, '..', 'src', 'pages', 'layout', 'index.tsx'),
-};
-
-// 测试结果收集器
-class TestResultCollector {
-    constructor() {
-        this.results = [];
-        this.passed = 0;
-        this.failed = 0;
-    }
-
-    addResult(testName, passed, details = '') {
-        const result = { testName, passed, details, timestamp: new Date() };
-        this.results.push(result);
-        if (passed) {
-            this.passed++;
-        } else {
-            this.failed++;
-        }
-    }
-
-    printResults() {
-        console.log('\n📊 智谱AI路由测试结果:');
-        console.log(`   总测试数: ${this.results.length}`);
-        console.log(`   通过: ${this.passed}`);
-        console.log(`   失败: ${this.failed}`);
-        console.log(`   成功率: ${this.results.length > 0 ? (this.passed / this.results.length * 100).toFixed(2) : 0}%`);
-        
-        console.log('\n📋 详细结果:');
-        this.results.forEach((result, index) => {
-            const status = result.passed ? '✅' : '❌';
-            console.log(`   ${index + 1}. ${status} ${result.testName}`);
-            if (!result.passed && result.details) {
-                console.log(`      详情: ${result.details}`);
-            }
-        });
-    }
-}
-
-// 测试工具函数
-class TestUtils {
-    static readFile(filePath) {
-        try {
-            return fs.readFileSync(filePath, 'utf8');
-        } catch (error) {
-            return null;
-        }
-    }
-
-    static countOccurrences(text, pattern) {
-        const matches = text.match(new RegExp(pattern, 'g'));
-        return matches ? matches.length : 0;
-    }
-
-    static findPattern(text, pattern) {
-        const matches = text.match(new RegExp(pattern, 'g'));
-        return matches || [];
-    }
-}
-
-// 智谱AI路由测试
-class ZhipuRoutingTests {
-    constructor() {
-        this.collector = new TestResultCollector();
-    }
-
-    // 测试1: 验证路由配置中的智谱AI路径
-    testRouterZhipuPaths() {
-        console.log('\n🛣️  测试路由配置中的智谱AI路径...');
-        
-        const routerContent = TestUtils.readFile(TEST_CONFIG.routerFile);
-        if (!routerContent) {
-            this.collector.addResult('路由文件可读', false, '无法读取路由文件');
-            return;
-        }
-
-        // 测试智谱AI路由路径
-        const zhipuPaths = [
-            '/zhipu/questionAnswer',
-            '/zhipu/knowledgeLib',
-            '/zhipu/dataExport'
-        ];
-
-        zhipuPaths.forEach(path => {
-            const count = TestUtils.countOccurrences(routerContent, path.replace('/', '\\/'));
-            this.collector.addResult(
-                `路由路径 ${path} 存在`,
-                count > 0,
-                count === 0 ? `未找到路由路径: ${path}` : ''
-            );
-        });
-
-        // 测试智谱AI导入路径
-        const zhipuImports = [
-            '@/pages/platforms/zhipu/questionAnswer/list/index',
-            '@/pages/platforms/zhipu/questionAnswer/info/index',
-            '@/pages/platforms/zhipu/knowledgeLib/list/index',
-            '@/pages/platforms/zhipu/knowledgeLib/detail/index',
-            '@/pages/platforms/zhipu/dataExport/index'
-        ];
-
-        zhipuImports.forEach(importPath => {
-            const count = TestUtils.countOccurrences(routerContent, importPath.replace(/\//g, '\\/'));
-            this.collector.addResult(
-                `导入路径 ${importPath} 存在`,
-                count > 0,
-                count === 0 ? `未找到导入路径: ${importPath}` : ''
-            );
-        });
-    }
-
-    // 测试2: 验证导航组件中的智谱AI路径
-    testNavZhipuPaths() {
-        console.log('\n🧭 测试导航组件中的智谱AI路径...');
-        
-        const navContent = TestUtils.readFile(TEST_CONFIG.navFile);
-        if (!navContent) {
-            this.collector.addResult('导航文件可读', false, '无法读取导航文件');
-            return;
-        }
-
-        // 测试智谱AI菜单项
-        const zhipuMenuItems = [
-            '/zhipu/questionAnswer',
-            '/zhipu/knowledgeLib',
-            '/zhipu/dataExport'
-        ];
-
-        zhipuMenuItems.forEach(path => {
-            const count = TestUtils.countOccurrences(navContent, path.replace('/', '\\/'));
-            this.collector.addResult(
-                `导航菜单项 ${path} 存在`,
-                count > 0,
-                count === 0 ? `未找到导航菜单项: ${path}` : ''
-            );
-        });
-
-        // 测试智谱AI路由跳转
-        const zhipuNavigations = [
-            'router\\.navigate\\(\\s*\\{\\s*pathname:\\s*[\'"]/zhipu/questionAnswer[\'"]\\s*\\}\\)',
-            'router\\.navigate\\(\\s*\\{\\s*pathname:\\s*[\'"]/zhipu/knowledgeLib[\'"]\\s*\\}\\)',
-            'router\\.navigate\\(\\s*\\{\\s*pathname:\\s*[\'"]/zhipu/dataExport[\'"]\\s*\\}\\)'
-        ];
-
-        zhipuNavigations.forEach(navPattern => {
-            const count = TestUtils.countOccurrences(navContent, navPattern);
-            this.collector.addResult(
-                `路由跳转 ${navPattern} 存在`,
-                count > 0,
-                count === 0 ? `未找到路由跳转: ${navPattern}` : ''
-            );
-        });
-    }
-
-    // 测试3: 验证布局组件中的智谱AI默认路径
-    testLayoutZhipuDefaultPath() {
-        console.log('\n🏗️  测试布局组件中的智谱AI默认路径...');
-        
-        const layoutContent = TestUtils.readFile(TEST_CONFIG.layoutFile);
-        if (!layoutContent) {
-            this.collector.addResult('布局文件可读', false, '无法读取布局文件');
-            return;
-        }
-
-        // 测试智谱AI默认路径
-        const zhipuDefaultPath = '/zhipu/questionAnswer';
-        const count = TestUtils.countOccurrences(layoutContent, zhipuDefaultPath.replace('/', '\\/'));
-        this.collector.addResult(
-            `智谱AI默认路径 ${zhipuDefaultPath} 存在`,
-            count > 0,
-            count === 0 ? `未找到智谱AI默认路径: ${zhipuDefaultPath}` : ''
-        );
-
-        // 测试菜单类型切换逻辑
-        const menuTypeLogic = 'value === 1 \\? \'/deepseek/questionAnswer\' : \'/zhipu/questionAnswer\'';
-        const logicCount = TestUtils.countOccurrences(layoutContent, menuTypeLogic);
-        this.collector.addResult(
-            '菜单类型切换逻辑正确',
-            logicCount > 0,
-            logicCount === 0 ? '未找到正确的菜单类型切换逻辑' : ''
-        );
-    }
-
-    // 测试4: 验证没有遗留的旧路径
-    testNoLegacyPaths() {
-        console.log('\n🚫 测试没有遗留的旧路径...');
-        
-        const routerContent = TestUtils.readFile(TEST_CONFIG.routerFile);
-        const navContent = TestUtils.readFile(TEST_CONFIG.navFile);
-        const layoutContent = TestUtils.readFile(TEST_CONFIG.layoutFile);
-        
-        const allContent = [routerContent, navContent, layoutContent].filter(Boolean).join('\n');
-
-        // 检查旧路径
-        const oldPaths = [
-            '/questionAnswer',
-            '/knowledgeLib',
-            '/dataExport'
-        ];
-
-        oldPaths.forEach(path => {
-            const count = TestUtils.countOccurrences(allContent, path.replace('/', '\\/'));
-            this.collector.addResult(
-                `没有遗留旧路径 ${path}`,
-                count === 0,
-                count > 0 ? `发现${count}个遗留的旧路径: ${path}` : ''
-            );
-        });
-
-        // 检查旧导入路径
-        const oldImports = [
-            '@/pages/questionAnswer',
-            '@/pages/knowledgeLib',
-            '@/pages/dataExport'
-        ];
-
-        oldImports.forEach(importPath => {
-            const count = TestUtils.countOccurrences(allContent, importPath.replace(/\//g, '\\/'));
-            this.collector.addResult(
-                `没有遗留旧导入路径 ${importPath}`,
-                count === 0,
-                count > 0 ? `发现${count}个遗留的旧导入路径: ${importPath}` : ''
-            );
-        });
-    }
-
-    // 测试5: 验证路由完整性
-    testRouteCompleteness() {
-        console.log('\n✅ 测试路由完整性...');
-        
-        const routerContent = TestUtils.readFile(TEST_CONFIG.routerFile);
-        if (!routerContent) {
-            this.collector.addResult('路由文件可读', false, '无法读取路由文件');
-            return;
-        }
-
-        // 检查所有必要的路由都存在
-        const requiredRoutes = [
-            { path: '/zhipu/questionAnswer', name: '智谱AI问答应用' },
-            { path: '/zhipu/questionAnswer/create', name: '智谱AI创建应用' },
-            { path: '/zhipu/questionAnswer/modify', name: '智谱AI修改应用' },
-            { path: '/zhipu/knowledgeLib', name: '智谱AI知识库' },
-            { path: '/zhipu/knowledgeLib/:knowledgeId', name: '智谱AI知识库详情' },
-            { path: '/zhipu/dataExport', name: '智谱AI数据导出' }
-        ];
-
-        requiredRoutes.forEach(route => {
-            const count = TestUtils.countOccurrences(routerContent, route.path.replace(/\//g, '\\/'));
-            this.collector.addResult(
-                `路由 ${route.name} 存在`,
-                count > 0,
-                count === 0 ? `未找到路由: ${route.path}` : ''
-            );
-        });
-
-        // 检查面包屑配置
-        const breadcrumbCount = TestUtils.countOccurrences(routerContent, 'breadcrumbName');
-        this.collector.addResult(
-            '面包屑配置完整',
-            breadcrumbCount >= 6,
-            breadcrumbCount < 6 ? `面包屑配置不足,期望至少6个,实际${breadcrumbCount}个` : ''
-        );
-    }
-
-    // 运行所有测试
-    runAllTests() {
-        console.log('🚀 开始智谱AI路由测试...\n');
-        
-        this.testRouterZhipuPaths();
-        this.testNavZhipuPaths();
-        this.testLayoutZhipuDefaultPath();
-        this.testNoLegacyPaths();
-        this.testRouteCompleteness();
-
-        // 输出结果
-        this.collector.printResults();
-
-        // 返回测试结果
-        const summary = { passed: this.collector.passed, failed: this.collector.failed, total: this.collector.results.length };
-        if (summary.failed > 0) {
-            console.log('\n⚠️  部分测试失败,智谱AI路由可能存在问题。');
-            process.exit(1);
-        } else {
-            console.log('\n🎉 所有测试通过!智谱AI路由配置正确。');
-        }
-    }
-}
-
-// 运行测试
-const tests = new ZhipuRoutingTests();
-tests.runAllTests();