// 已读取AGENTS.md import * as fs from 'fs'; import * as path from 'path'; /** * 第三十二批回归闸门:用户设置文件不得位于对外静态目录 */ describe('第三十二批用户设置文件私有化闸门', () => { const rootDir = path.resolve(__dirname, '../../'); const indexCode = fs.readFileSync(path.join(rootDir, 'server/src/index.ts'), 'utf-8'); it('设置文件路径必须位于私有 data 目录而非 /uploads', () => { expect(indexCode).not.toContain("path.resolve(uploadDir, 'user_settings.json')"); expect(indexCode).toContain('const userSettingsDir ='); expect(indexCode).toContain("path.resolve(userSettingsDir, 'user_settings.json')"); }); it('/uploads 仍仅用于静态资源', () => { expect(indexCode).toContain("app.use('/uploads', express.static(uploadDir))"); }); });