feat: add form validation and disable submit buttons when fields are empty

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
2026-02-11 17:04:55 +08:00
parent b69df2454e
commit b35874b120
36 changed files with 1287 additions and 39 deletions

View File

@@ -0,0 +1,30 @@
import { describe, it, expect } from 'vitest';
import ApiFetch from '@/lib/api-fetch';
describe('FileStorage API', () => {
it('should fetch a list of files from /api/fileStorage/findMany', async () => {
const response = await ApiFetch.api.fileStorage.findMany.get();
expect(response.status).toBe(200);
const responseBody = response.data as any;
expect(responseBody.data).toBeInstanceOf(Array);
expect(responseBody.data.length).toBe(2);
expect(responseBody.data[0].name).toBe('file1.jpg');
});
it('should create a file using /api/fileStorage/create', async () => {
const mockFile = new File(['hello'], 'hello.png', { type: 'image/png' });
const response = await ApiFetch.api.fileStorage.create.post({
file: mockFile,
name: 'hello.png',
});
expect(response.status).toBe(200);
const responseBody = response.data as any;
expect(responseBody.data.realName).toBe('hello.png');
expect(responseBody.data.id).toBe('3');
});
});