From 6709df62ede340f871873b9211b66463486ec532 Mon Sep 17 00:00:00 2001 From: iven Date: Sun, 3 May 2026 23:19:55 +0800 Subject: [PATCH] =?UTF-8?q?test(web):=20=E7=AC=AC=E4=B8=80=E6=89=B9?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E9=A1=B5=E6=B5=8B=E8=AF=95=20=E2=80=94=207?= =?UTF-8?q?=20=E4=B8=AA=E9=A1=B5=E9=9D=A2=20+=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - AppointmentList / FollowUpTaskList / FollowUpRecordList / ConsultationList - FollowUpTemplateList / DialysisManageList / OfflineEventList - 修复 FollowUpTemplateList 导入路径 bug (../../../ → ../../) --- .../src/pages/health/AppointmentList.test.tsx | 21 +++++++++++++ .../pages/health/ConsultationList.test.tsx | 28 +++++++++++++++++ .../pages/health/DialysisManageList.test.tsx | 30 +++++++++++++++++++ .../pages/health/FollowUpRecordList.test.tsx | 26 ++++++++++++++++ .../pages/health/FollowUpTaskList.test.tsx | 27 +++++++++++++++++ .../health/FollowUpTemplateList.test.tsx | 29 ++++++++++++++++++ .../src/pages/health/FollowUpTemplateList.tsx | 4 +-- .../pages/health/OfflineEventList.test.tsx | 29 ++++++++++++++++++ 8 files changed, 192 insertions(+), 2 deletions(-) create mode 100644 apps/web/src/pages/health/AppointmentList.test.tsx create mode 100644 apps/web/src/pages/health/ConsultationList.test.tsx create mode 100644 apps/web/src/pages/health/DialysisManageList.test.tsx create mode 100644 apps/web/src/pages/health/FollowUpRecordList.test.tsx create mode 100644 apps/web/src/pages/health/FollowUpTaskList.test.tsx create mode 100644 apps/web/src/pages/health/FollowUpTemplateList.test.tsx create mode 100644 apps/web/src/pages/health/OfflineEventList.test.tsx diff --git a/apps/web/src/pages/health/AppointmentList.test.tsx b/apps/web/src/pages/health/AppointmentList.test.tsx new file mode 100644 index 0000000..33e3a89 --- /dev/null +++ b/apps/web/src/pages/health/AppointmentList.test.tsx @@ -0,0 +1,21 @@ +import { createListPageTests } from '../../test/factories/listPageTests'; +import { createFixtureList, createAppointmentFixture } from '../../test/fixtures'; +import AppointmentList from './AppointmentList'; + +const mockAppointments = createFixtureList(createAppointmentFixture, 15, [ + { id: 'appt-1', patient_name: '张三', doctor_name: '李医生', status: 'pending' }, + { id: 'appt-2', patient_name: '王五', doctor_name: '赵医生', status: 'confirmed' }, +]); + +createListPageTests({ + Component: AppointmentList, + apiPath: '/api/v1/health/appointments', + columns: ['患者', '医护', '预约日期', '状态'], + firstRowTexts: ['张三'], + totalItems: 15, + hasCreateButton: true, + createButtonText: '新建预约', + hasSearch: true, + hasPagination: false, + mockItems: mockAppointments as Record[], +}); diff --git a/apps/web/src/pages/health/ConsultationList.test.tsx b/apps/web/src/pages/health/ConsultationList.test.tsx new file mode 100644 index 0000000..c715b44 --- /dev/null +++ b/apps/web/src/pages/health/ConsultationList.test.tsx @@ -0,0 +1,28 @@ +import { createListPageTests } from '../../test/factories/listPageTests'; +import ConsultationList from './ConsultationList'; + +const mockConsultations = Array.from({ length: 8 }, (_, i) => ({ + id: `consult-${i + 1}`, + patient_id: `patient-${i + 1}`, + patient_name: `患者${i + 1}`, + doctor_id: `doctor-1`, + doctor_name: '李医生', + status: (['waiting', 'active', 'closed'] as const)[i % 3], + type: 'online', + created_at: '2026-04-01T10:00:00Z', + updated_at: '2026-04-01T10:00:00Z', + version: 1, +})); + +createListPageTests({ + Component: ConsultationList, + apiPath: '/api/v1/health/consultation-sessions', + columns: ['患者', '医护', '状态'], + firstRowTexts: ['患者1'], + totalItems: 8, + hasCreateButton: true, + createButtonText: '新建会话', + hasSearch: true, + hasPagination: false, + mockItems: mockConsultations as Record[], +}); diff --git a/apps/web/src/pages/health/DialysisManageList.test.tsx b/apps/web/src/pages/health/DialysisManageList.test.tsx new file mode 100644 index 0000000..6272d07 --- /dev/null +++ b/apps/web/src/pages/health/DialysisManageList.test.tsx @@ -0,0 +1,30 @@ +import { createListPageTests } from '../../test/factories/listPageTests'; +import DialysisManageList from './DialysisManageList'; + +// DialysisManageList 需要先选择患者才会加载表格数据 +// 使用 route 带 patient_id 参数模拟已有患者选择的场景 +const mockDialysis = Array.from({ length: 6 }, (_, i) => ({ + id: `dialysis-${i + 1}`, + patient_id: `patient-1`, + patient_name: `患者1`, + dialysis_date: '2026-05-10', + status: (['scheduled', 'in_progress', 'completed'] as const)[i % 3], + dialysis_type: 'hemodialysis', + created_at: '2026-04-01T10:00:00Z', + updated_at: '2026-04-01T10:00:00Z', + version: 1, +})); + +createListPageTests({ + Component: DialysisManageList, + apiPath: '/api/v1/health/dialysis-records', + columns: ['透析日期', '状态'], + firstRowTexts: ['患者1'], + totalItems: 6, + hasCreateButton: true, + createButtonText: '添加记录', + hasSearch: true, + hasPagination: false, + route: '/?patient_id=patient-1', + mockItems: mockDialysis as Record[], +}); diff --git a/apps/web/src/pages/health/FollowUpRecordList.test.tsx b/apps/web/src/pages/health/FollowUpRecordList.test.tsx new file mode 100644 index 0000000..161e9ca --- /dev/null +++ b/apps/web/src/pages/health/FollowUpRecordList.test.tsx @@ -0,0 +1,26 @@ +import { createListPageTests } from '../../test/factories/listPageTests'; +import FollowUpRecordList from './FollowUpRecordList'; + +const mockRecords = Array.from({ length: 10 }, (_, i) => ({ + id: `record-${i + 1}`, + patient_id: `patient-${i + 1}`, + patient_name: `患者${i + 1}`, + task_id: `task-${i + 1}`, + status: i % 2 === 0 ? 'completed' : 'cancelled', + follow_up_date: '2026-05-10', + created_at: '2026-04-01T10:00:00Z', + updated_at: '2026-04-01T10:00:00Z', + version: 1, +})); + +createListPageTests({ + Component: FollowUpRecordList, + apiPath: '/api/v1/health/follow-up-records', + columns: ['执行人', '执行日期'], + firstRowTexts: ['record-1'], + totalItems: 10, + hasCreateButton: false, + hasSearch: true, + hasPagination: false, + mockItems: mockRecords as Record[], +}); diff --git a/apps/web/src/pages/health/FollowUpTaskList.test.tsx b/apps/web/src/pages/health/FollowUpTaskList.test.tsx new file mode 100644 index 0000000..e1e95d5 --- /dev/null +++ b/apps/web/src/pages/health/FollowUpTaskList.test.tsx @@ -0,0 +1,27 @@ +import { createListPageTests } from '../../test/factories/listPageTests'; +import FollowUpTaskList from './FollowUpTaskList'; + +const mockTasks = Array.from({ length: 10 }, (_, i) => ({ + id: `task-${i + 1}`, + patient_id: `patient-${i + 1}`, + patient_name: `患者${i + 1}`, + template_id: `tmpl-1`, + template_name: '血压随访', + status: i % 2 === 0 ? 'pending' : 'completed', + due_date: '2026-05-15', + created_at: '2026-04-01T10:00:00Z', + updated_at: '2026-04-01T10:00:00Z', + version: 1, +})); + +createListPageTests({ + Component: FollowUpTaskList, + apiPath: '/api/v1/health/follow-up-tasks', + columns: ['患者', '状态'], + firstRowTexts: ['患者1'], + totalItems: 10, + hasCreateButton: false, + hasSearch: true, + hasPagination: false, + mockItems: mockTasks as Record[], +}); diff --git a/apps/web/src/pages/health/FollowUpTemplateList.test.tsx b/apps/web/src/pages/health/FollowUpTemplateList.test.tsx new file mode 100644 index 0000000..a86ae6e --- /dev/null +++ b/apps/web/src/pages/health/FollowUpTemplateList.test.tsx @@ -0,0 +1,29 @@ +import { createListPageTests } from '../../test/factories/listPageTests'; +import FollowUpTemplateList from './FollowUpTemplateList'; + +const mockTemplates = Array.from({ length: 5 }, (_, i) => ({ + id: `tmpl-${i + 1}`, + name: `随访模板${i + 1}`, + description: `描述${i + 1}`, + category: 'chronic', + follow_up_type: 'phone', + field_count: 3, + frequency_days: 30, + status: 'active', + created_at: '2026-04-01T10:00:00Z', + updated_at: '2026-04-01T10:00:00Z', + version: 1, +})); + +createListPageTests({ + Component: FollowUpTemplateList, + apiPath: '/api/v1/health/follow-up-templates', + columns: ['模板名称', '状态'], + firstRowTexts: ['随访模板1'], + totalItems: 5, + hasCreateButton: true, + createButtonText: '新建模板', + hasSearch: false, + hasPagination: false, + mockItems: mockTemplates as Record[], +}); diff --git a/apps/web/src/pages/health/FollowUpTemplateList.tsx b/apps/web/src/pages/health/FollowUpTemplateList.tsx index bdb14a4..3b2ef0d 100644 --- a/apps/web/src/pages/health/FollowUpTemplateList.tsx +++ b/apps/web/src/pages/health/FollowUpTemplateList.tsx @@ -12,8 +12,8 @@ import { type FollowUpTemplateListItem, type FollowUpTemplate, type TemplateFieldReq, -} from '../../../api/health/followUpTemplates'; -import { AuthButton } from '../../../components/AuthButton'; +} from '../../api/health/followUpTemplates'; +import { AuthButton } from '../../components/AuthButton'; const TYPE_MAP: Record = { phone: '电话', outpatient: '门诊', home_visit: '家访', diff --git a/apps/web/src/pages/health/OfflineEventList.test.tsx b/apps/web/src/pages/health/OfflineEventList.test.tsx new file mode 100644 index 0000000..76c2968 --- /dev/null +++ b/apps/web/src/pages/health/OfflineEventList.test.tsx @@ -0,0 +1,29 @@ +import { createListPageTests } from '../../test/factories/listPageTests'; +import OfflineEventList from './OfflineEventList'; + +const mockEvents = Array.from({ length: 4 }, (_, i) => ({ + id: `event-${i + 1}`, + title: `线下活动${i + 1}`, + event_date: '2026-05-20', + location: '社区活动中心', + status: 'upcoming', + max_participants: 50, + points_reward: 100, + participant_count: i * 10, + created_at: '2026-04-01T10:00:00Z', + updated_at: '2026-04-01T10:00:00Z', + version: 1, +})); + +createListPageTests({ + Component: OfflineEventList, + apiPath: '/api/v1/health/admin/offline-events', + columns: ['活动名称', '活动日期', '状态'], + firstRowTexts: ['线下活动1'], + totalItems: 4, + hasCreateButton: true, + createButtonText: '新建活动', + hasSearch: true, + hasPagination: false, + mockItems: mockEvents as Record[], +});