From 0e789b530a5b47c737ef68e9b537dc433194d19e Mon Sep 17 00:00:00 2001 From: iven Date: Sun, 3 May 2026 23:03:04 +0800 Subject: [PATCH] =?UTF-8?q?test(web):=20=E6=B7=BB=E5=8A=A0=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E6=95=B0=E6=8D=AE=E5=B7=A5=E5=8E=82=20=E2=80=94=20hea?= =?UTF-8?q?lthFixtures=20+=20=E6=89=B9=E9=87=8F=E7=94=9F=E6=88=90=20+=20?= =?UTF-8?q?=E5=88=86=E9=A1=B5=E5=8C=85=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web/src/test/fixtures/healthFixtures.ts | 94 ++++++++++++++++++++ apps/web/src/test/fixtures/index.ts | 1 + 2 files changed, 95 insertions(+) create mode 100644 apps/web/src/test/fixtures/healthFixtures.ts create mode 100644 apps/web/src/test/fixtures/index.ts 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';