// 批量操作 API 测试 const request = require('supertest'); const app = require('../../backend/src/index'); describe('Batch API', () => { let token; beforeAll(async () => { const loginRes = await request(app) .post('/api/auth/login') .send({ username: 'testuser', password: 'test123' }); token = loginRes.body.token; }); describe('POST /api/batch/delete', () => { it('should batch delete files', async () => { const response = await request(app) .post('/api/batch/delete') .set('Authorization', `Bearer ${token}`) .send({ fileIds: [1, 2, 3] }); expect(response.status).toBe(200); expect(response.body).toHaveProperty('deleted'); }); }); describe('POST /api/batch/move', () => { it('should batch move files', async () => { const response = await request(app) .post('/api/batch/move') .set('Authorization', `Bearer ${token}`) .send({ fileIds: [1, 2], targetFolderId: 10 }); expect(response.status).toBe(200); expect(response.body).toHaveProperty('moved'); }); }); });