test(web): 第一批列表页测试 — 7 个页面 + 修复导入路径
- AppointmentList / FollowUpTaskList / FollowUpRecordList / ConsultationList - FollowUpTemplateList / DialysisManageList / OfflineEventList - 修复 FollowUpTemplateList 导入路径 bug (../../../ → ../../)
This commit is contained in:
21
apps/web/src/pages/health/AppointmentList.test.tsx
Normal file
21
apps/web/src/pages/health/AppointmentList.test.tsx
Normal file
@@ -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<string, unknown>[],
|
||||
});
|
||||
28
apps/web/src/pages/health/ConsultationList.test.tsx
Normal file
28
apps/web/src/pages/health/ConsultationList.test.tsx
Normal file
@@ -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<string, unknown>[],
|
||||
});
|
||||
30
apps/web/src/pages/health/DialysisManageList.test.tsx
Normal file
30
apps/web/src/pages/health/DialysisManageList.test.tsx
Normal file
@@ -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<string, unknown>[],
|
||||
});
|
||||
26
apps/web/src/pages/health/FollowUpRecordList.test.tsx
Normal file
26
apps/web/src/pages/health/FollowUpRecordList.test.tsx
Normal file
@@ -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<string, unknown>[],
|
||||
});
|
||||
27
apps/web/src/pages/health/FollowUpTaskList.test.tsx
Normal file
27
apps/web/src/pages/health/FollowUpTaskList.test.tsx
Normal file
@@ -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<string, unknown>[],
|
||||
});
|
||||
29
apps/web/src/pages/health/FollowUpTemplateList.test.tsx
Normal file
29
apps/web/src/pages/health/FollowUpTemplateList.test.tsx
Normal file
@@ -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<string, unknown>[],
|
||||
});
|
||||
@@ -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<string, string> = {
|
||||
phone: '电话', outpatient: '门诊', home_visit: '家访',
|
||||
|
||||
29
apps/web/src/pages/health/OfflineEventList.test.tsx
Normal file
29
apps/web/src/pages/health/OfflineEventList.test.tsx
Normal file
@@ -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<string, unknown>[],
|
||||
});
|
||||
Reference in New Issue
Block a user