diff --git a/apps/web/src/test/fixtures/healthFixtures.ts b/apps/web/src/test/fixtures/healthFixtures.ts new file mode 100644 index 0000000..ac3f18a --- /dev/null +++ b/apps/web/src/test/fixtures/healthFixtures.ts @@ -0,0 +1,94 @@ +// --- 患者 --- +export function createPatientFixture(overrides: Record = {}) { + return { + id: 'patient-1', + name: '张三', + gender: 'male', + birth_date: '1990-01-15', + blood_type: 'A', + status: 'active', + verification_status: 'verified', + source: 'manual', + created_at: '2026-04-01T10:00:00Z', + updated_at: '2026-04-01T10:00:00Z', + version: 1, + ...overrides, + }; +} + +// --- 医生 --- +export function createDoctorFixture(overrides: Record = {}) { + return { + id: 'doctor-1', + user_id: 'user-doc-1', + name: '李医生', + department: '内科', + title: '主治医师', + specialization: '心血管内科', + phone: '13800000001', + email: 'doctor1@test.com', + status: 'online', + created_at: '2026-04-01T10:00:00Z', + updated_at: '2026-04-01T10:00:00Z', + version: 1, + ...overrides, + }; +} + +// --- 告警 --- +export function createAlertFixture(overrides: Record = {}) { + return { + id: 'alert-1', + patient_id: 'patient-1', + patient_name: '张三', + alert_type: 'vital_sign', + severity: 'high', + status: 'active', + message: '血压异常偏高', + created_at: '2026-04-01T10:00:00Z', + updated_at: '2026-04-01T10:00:00Z', + version: 1, + ...overrides, + }; +} + +// --- 预约 --- +export function createAppointmentFixture(overrides: Record = {}) { + return { + id: 'appt-1', + patient_id: 'patient-1', + patient_name: '张三', + doctor_id: 'doctor-1', + doctor_name: '李医生', + appointment_date: '2026-05-10', + start_time: '09:00', + end_time: '09:30', + status: 'pending', + type: 'follow_up', + notes: '', + created_at: '2026-04-01T10:00:00Z', + updated_at: '2026-04-01T10:00:00Z', + version: 1, + ...overrides, + }; +} + +// --- 批量生成 --- +export function createFixtureList( + factory: (overrides?: Record) => T, + count: number, + overridesList: Record[] = [], +): T[] { + return Array.from({ length: count }, (_, i) => factory(overridesList[i] || {})); +} + +// --- 分页响应包装 --- +export function wrapPaginated(items: T[], total?: number) { + return { + data: items, + total: total ?? items.length, + page: 1, + page_size: 20, + total_pages: Math.ceil((total ?? items.length) / 20), + }; +} diff --git a/apps/web/src/test/fixtures/index.ts b/apps/web/src/test/fixtures/index.ts new file mode 100644 index 0000000..cda4a4a --- /dev/null +++ b/apps/web/src/test/fixtures/index.ts @@ -0,0 +1 @@ +export * from './healthFixtures';