|
|
@@ -305,79 +305,73 @@ describe('File API Integration Tests', () => {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- // describe('POST /api/v1/files/multipart-policy', () => {
|
|
|
- // it('should generate multipart upload policy successfully', async () => {
|
|
|
- // const mockRequestData = {
|
|
|
- // fileKey: 'large-file.zip',
|
|
|
- // totalSize: 1024 * 1024 * 100, // 100MB
|
|
|
- // partSize: 1024 * 1024 * 20, // 20MB
|
|
|
- // name: 'large-file.zip',
|
|
|
- // type: 'application/zip',
|
|
|
- // uploadUserId: 1
|
|
|
- // };
|
|
|
+ describe('POST /api/v1/files/multipart-policy', () => {
|
|
|
+ it('should generate multipart upload policy successfully', async () => {
|
|
|
+ const mockRequestData = {
|
|
|
+ fileKey: 'large-file.zip',
|
|
|
+ totalSize: 1024 * 1024 * 100, // 100MB
|
|
|
+ partSize: 1024 * 1024 * 20, // 20MB
|
|
|
+ name: 'large-file.zip',
|
|
|
+ type: 'application/zip',
|
|
|
+ uploadUserId: 1
|
|
|
+ };
|
|
|
|
|
|
- // const mockResponse = {
|
|
|
- // file: {
|
|
|
- // id: 1,
|
|
|
- // ...mockRequestData,
|
|
|
- // path: '1/test-uuid-123-large-file.zip',
|
|
|
- // description: null,
|
|
|
- // uploadUser: {} as any,
|
|
|
- // uploadTime: new Date(),
|
|
|
- // lastUpdated: null,
|
|
|
- // createdAt: new Date(),
|
|
|
- // updatedAt: new Date(),
|
|
|
- // fullUrl: Promise.resolve('https://minio.example.com/d8dai/1/test-uuid-123-large-file.zip')
|
|
|
- // },
|
|
|
- // uploadId: 'upload-123',
|
|
|
- // uploadUrls: ['url1', 'url2', 'url3', 'url4', 'url5'],
|
|
|
- // bucket: 'd8dai',
|
|
|
- // key: '1/test-uuid-123-large-file.zip'
|
|
|
- // };
|
|
|
+ const mockResponse = {
|
|
|
+ uploadId: 'upload-123',
|
|
|
+ bucket: 'd8dai',
|
|
|
+ key: '1/test-uuid-123-large-file.zip',
|
|
|
+ host: 'http://undefined:undefined',
|
|
|
+ partUrls: ['url1', 'url2', 'url3', 'url4', 'url5']
|
|
|
+ };
|
|
|
|
|
|
- // vi.mocked(mockFileService.createMultipartUploadPolicy).mockResolvedValue(mockResponse);
|
|
|
+ const mockCreateMultipartUploadPolicy = vi.fn().mockResolvedValue(mockResponse);
|
|
|
+ vi.mocked(FileService).mockImplementation(() => ({
|
|
|
+ createMultipartUploadPolicy: mockCreateMultipartUploadPolicy
|
|
|
+ } as unknown as FileService));
|
|
|
|
|
|
- // const response = await client.files['multipart-policy'].$post({
|
|
|
- // json: mockRequestData
|
|
|
- // },
|
|
|
- // {
|
|
|
- // headers: {
|
|
|
- // 'Authorization': 'Bearer test-token'
|
|
|
- // }
|
|
|
- // });
|
|
|
+ const response = await client.files['multipart-policy'].$post({
|
|
|
+ json: mockRequestData
|
|
|
+ },
|
|
|
+ {
|
|
|
+ headers: {
|
|
|
+ 'Authorization': 'Bearer test-token'
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
- // expect(response.status).toBe(200);
|
|
|
- // const result = await response.json();
|
|
|
- // expect(result).toEqual(mockResponse);
|
|
|
- // expect(mockFileService.createMultipartUploadPolicy).toHaveBeenCalledWith(
|
|
|
- // {
|
|
|
- // name: 'large-file.zip',
|
|
|
- // type: 'application/zip',
|
|
|
- // size: 104857600,
|
|
|
- // uploadUserId: 1
|
|
|
- // },
|
|
|
- // 5
|
|
|
- // );
|
|
|
- // });
|
|
|
+ expect(response.status).toBe(200);
|
|
|
+ const result = await response.json();
|
|
|
+ expect(result).toEqual(mockResponse);
|
|
|
+ expect(mockCreateMultipartUploadPolicy).toHaveBeenCalledWith(
|
|
|
+ {
|
|
|
+ fileKey: 'large-file.zip',
|
|
|
+ totalSize: 104857600,
|
|
|
+ partSize: 20971520,
|
|
|
+ name: 'large-file.zip',
|
|
|
+ type: 'application/zip',
|
|
|
+ uploadUserId: 1
|
|
|
+ },
|
|
|
+ 5
|
|
|
+ );
|
|
|
+ });
|
|
|
|
|
|
- // it('should validate multipart policy request data', async () => {
|
|
|
- // const invalidData = {
|
|
|
- // name: 'test.zip',
|
|
|
- // // Missing required fields: fileKey, totalSize, partSize
|
|
|
- // };
|
|
|
+ it('should validate multipart policy request data', async () => {
|
|
|
+ const invalidData = {
|
|
|
+ name: 'test.zip'
|
|
|
+ // Missing required fields: fileKey, totalSize, partSize
|
|
|
+ };
|
|
|
|
|
|
- // const response = await client.files['multipart-policy'].$post({
|
|
|
- // json: invalidData
|
|
|
- // },
|
|
|
- // {
|
|
|
- // headers: {
|
|
|
- // 'Authorization': 'Bearer test-token'
|
|
|
- // }
|
|
|
- // });
|
|
|
+ const response = await client.files['multipart-policy'].$post({
|
|
|
+ json: invalidData as any
|
|
|
+ },
|
|
|
+ {
|
|
|
+ headers: {
|
|
|
+ 'Authorization': 'Bearer test-token'
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
- // expect(response.status).toBe(400);
|
|
|
- // });
|
|
|
- // });
|
|
|
+ expect(response.status).toBe(400);
|
|
|
+ });
|
|
|
+ });
|
|
|
|
|
|
// describe('POST /api/v1/files/multipart-complete', () => {
|
|
|
// it('should complete multipart upload successfully', async () => {
|