|
|
@@ -308,47 +308,6 @@ vi.mock('sonner', () => ({
|
|
|
},
|
|
|
}));
|
|
|
|
|
|
-// Mock 枚举包
|
|
|
-vi.mock('@d8d/allin-enums', () => ({
|
|
|
- DisabilityType: {
|
|
|
- VISION: 'vision',
|
|
|
- HEARING: 'hearing',
|
|
|
- SPEECH: 'speech',
|
|
|
- PHYSICAL: 'physical',
|
|
|
- INTELLECTUAL: 'intellectual',
|
|
|
- MENTAL: 'mental',
|
|
|
- MULTIPLE: 'multiple',
|
|
|
- },
|
|
|
- DISABILITY_TYPES: ['vision', 'hearing', 'speech', 'physical', 'intellectual', 'mental', 'multiple'],
|
|
|
- getDisabilityTypeLabel: vi.fn((type) => {
|
|
|
- const labels: Record<string, string> = {
|
|
|
- vision: '视力残疾',
|
|
|
- hearing: '听力残疾',
|
|
|
- speech: '言语残疾',
|
|
|
- physical: '肢体残疾',
|
|
|
- intellectual: '智力残疾',
|
|
|
- mental: '精神残疾',
|
|
|
- multiple: '多重残疾',
|
|
|
- };
|
|
|
- return labels[type] || type;
|
|
|
- }),
|
|
|
- DisabilityLevel: {
|
|
|
- ONE: 1,
|
|
|
- TWO: 2,
|
|
|
- THREE: 3,
|
|
|
- FOUR: 4,
|
|
|
- },
|
|
|
- DISABILITY_LEVELS: [1, 2, 3, 4],
|
|
|
- getDisabilityLevelLabel: vi.fn((level) => {
|
|
|
- const labels: Record<number, string> = {
|
|
|
- 1: '一级',
|
|
|
- 2: '二级',
|
|
|
- 3: '三级',
|
|
|
- 4: '四级',
|
|
|
- };
|
|
|
- return labels[level] || level.toString();
|
|
|
- }),
|
|
|
-}));
|
|
|
|
|
|
// Mock area-management-ui 的 API - 使用简单的mock
|
|
|
// 注意:我们不再mock UI组件,只mock API
|
|
|
@@ -577,8 +536,12 @@ describe('残疾人个人管理集成测试', () => {
|
|
|
fireEvent.change(disabilityLevelSelect, { target: { value: '二级' } });
|
|
|
|
|
|
// 选择省份和城市
|
|
|
- await completeRadixSelectFlow('area-select-province', '1', { useFireEvent: true });
|
|
|
- await completeRadixSelectFlow('area-select-city', '2', { useFireEvent: true });
|
|
|
+ await act(async () => {
|
|
|
+ await completeRadixSelectFlow('area-select-province', '北京市', { useFireEvent: true });
|
|
|
+ });
|
|
|
+ await act(async () => {
|
|
|
+ await completeRadixSelectFlow('area-select-city', '东城区', { useFireEvent: true });
|
|
|
+ });
|
|
|
|
|
|
// 提交表单
|
|
|
const submitButton = screen.getByText('创建');
|
|
|
@@ -594,18 +557,9 @@ describe('残疾人个人管理集成测试', () => {
|
|
|
// 检查是否有验证错误显示
|
|
|
const validationErrors = screen.queryAllByText(/不能为空/);
|
|
|
if (validationErrors.length > 0) {
|
|
|
- console.debug('验证错误:', validationErrors.map(err => err.textContent));
|
|
|
+ // 验证错误已显示
|
|
|
}
|
|
|
|
|
|
- // 检查表单字段值
|
|
|
- console.debug('表单提交状态 - 检查字段值:');
|
|
|
- const nameInput2 = screen.getByPlaceholderText('请输入姓名');
|
|
|
- const provinceSelect2 = screen.getByTestId('province-select-form');
|
|
|
- const citySelect2 = screen.getByTestId('city-select-form');
|
|
|
-
|
|
|
- console.debug('name:', (nameInput2 as HTMLInputElement).value);
|
|
|
- console.debug('province select value:', (provinceSelect2 as HTMLSelectElement).value);
|
|
|
- console.debug('city select value:', (citySelect2 as HTMLSelectElement).value);
|
|
|
|
|
|
// 验证API调用 - 增加等待时间
|
|
|
await waitFor(() => {
|
|
|
@@ -762,10 +716,14 @@ describe('残疾人个人管理集成测试', () => {
|
|
|
expect(screen.getByTestId('area-select')).toBeInTheDocument();
|
|
|
|
|
|
// 选择省份
|
|
|
- await completeRadixSelectFlow('area-select-province', '1', { useFireEvent: true });
|
|
|
+ await act(async () => {
|
|
|
+ await completeRadixSelectFlow('area-select-province', '北京市', { useFireEvent: true });
|
|
|
+ });
|
|
|
|
|
|
// 选择城市
|
|
|
- await completeRadixSelectFlow('area-select-city', '2', { useFireEvent: true });
|
|
|
+ await act(async () => {
|
|
|
+ await completeRadixSelectFlow('area-select-city', '东城区', { useFireEvent: true });
|
|
|
+ });
|
|
|
|
|
|
// 选择区县
|
|
|
await completeRadixSelectFlow('area-select-district', '3', { useFireEvent: true });
|
|
|
@@ -837,17 +795,24 @@ describe('残疾人个人管理集成测试', () => {
|
|
|
fireEvent.change(idAddressInput, { target: { value: '北京市东城区' } });
|
|
|
|
|
|
// 选择性别
|
|
|
- await completeRadixSelectFlow('gender-select', '男', { useFireEvent: true });
|
|
|
+ const genderSelect = screen.getByTestId('gender-select');
|
|
|
+ fireEvent.change(genderSelect, { target: { value: '男' } });
|
|
|
|
|
|
// 选择残疾类型
|
|
|
- await completeRadixSelectFlow('disability-type-select', '视力残疾', { useFireEvent: true });
|
|
|
+ const disabilityTypeSelect = screen.getByTestId('disability-type-select');
|
|
|
+ fireEvent.change(disabilityTypeSelect, { target: { value: '视力残疾' } });
|
|
|
|
|
|
// 选择残疾等级
|
|
|
- await completeRadixSelectFlow('disability-level-select', '一级', { useFireEvent: true });
|
|
|
+ const disabilityLevelSelect = screen.getByTestId('disability-level-select');
|
|
|
+ fireEvent.change(disabilityLevelSelect, { target: { value: '一级' } });
|
|
|
|
|
|
// 选择省份和城市
|
|
|
- await completeRadixSelectFlow('area-select-province', '1', { useFireEvent: true });
|
|
|
- await completeRadixSelectFlow('area-select-city', '2', { useFireEvent: true });
|
|
|
+ await act(async () => {
|
|
|
+ await completeRadixSelectFlow('area-select-province', '北京市', { useFireEvent: true });
|
|
|
+ });
|
|
|
+ await act(async () => {
|
|
|
+ await completeRadixSelectFlow('area-select-city', '东城区', { useFireEvent: true });
|
|
|
+ });
|
|
|
|
|
|
// 提交表单
|
|
|
const submitButton = screen.getByText('创建');
|